mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "André Draszik" <andre.draszik@linaro.org>
To: Peter Griffin <peter.griffin@linaro.org>,
	Tudor Ambarus	 <tudor.ambarus@linaro.org>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	Krzysztof Kozlowski <krzk@kernel.org>
Cc: William Mcvicker <willmcvicker@google.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	linux-arm-kernel@lists.infradead.org,
	 linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
	 kernel-team@android.com
Subject: Re: [PATCH v3] soc: samsung: exynos-pmu: Enable CPU Idle for gs101
Date: Thu, 03 Jul 2025 11:12:34 +0100	[thread overview]
Message-ID: <91a9d4dbe5504c493856ef81b30d98e7da925ac0.camel@linaro.org> (raw)
In-Reply-To: <20250627-gs101-cpuidle-v3-1-0200452dfe60@linaro.org>

Thanks Pete for your patch!

On Fri, 2025-06-27 at 14:08 +0100, Peter Griffin wrote:
> Register cpu pm notifiers for gs101 which call the
> gs101_cpu_pmu_online/offline callbacks which in turn program the ACPM
> hint. This is required to actually enter the C2 idle state.
> 
> A couple of corner cases are handled, namely when the system is rebooting
> or suspending we ignore the request. Additionally the request is ignored if
> the CPU is in CPU hot plug. Some common code is refactored so that it can
> be called from both the CPU hot plug callback and CPU PM notifier taking
> into account that CPU PM notifiers are called with IRQs disabled whereas
> CPU hotplug callbacks aren't.
> 
> Note: this patch has a runtime dependency on adding 'local-timer-stop' dt
> property to the CPU nodes. This informs the time framework to switch to a
> broadcast timer as the local timer will be shutdown. Without that DT
> property specified the system hangs in early boot with this patch applied.
> 
> Signed-off-by: Peter Griffin <peter.griffin@linaro.org>

With this applied, I see the following during boot:

[    1.841304][    T0] =============================
[    1.841422][    T0] [ BUG: Invalid wait context ]
[    1.841550][    T0] 6.16.0-rc4-next-20250702+ #54 Tainted: G     U          T  
[    1.841727][    T0] -----------------------------
[    1.841844][    T0] swapper/0/0 is trying to lock:
[    1.841965][    T0] ffff000800ee84b8 (&pmu_context->cpupm_lock){....}-{3:3}
[    1.842001][    T0] , at: gs101_cpu_pm_notify_callback+0x48/0x100
[    1.842309][    T0] other info that might help us debug this:
[    1.842613][    T0] context-{5:5}
[    1.842987][    T0] 1 lock held by swapper/0/0:
[    1.843442][    T0]  #0: 
[    1.843859][    T0] ffffafe9d8f1f100
[    1.844282][    T0]  (
[    1.844618][    T0] cpu_pm_notifier.lock
[    1.844980][    T0] ){....}-{2:2}, at: cpu_pm_enter+0x30/0x88
[    1.845340][    T0] stack backtrace:
[    1.845855][    T0] CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Tainted: G     U          T   6.16.0-rc4-next-20250702+ #54 PREEMPT 
[    1.845878][    T0] Tainted: [U]=USER, [T]=RANDSTRUCT
[    1.845884][    T0] Hardware name: Oriole (DT)
[    1.845897][    T0] Call trace:
[    1.845909][    T0]  show_stack+0x24/0x38 (C)
[    1.845934][    T0]  dump_stack_lvl+0x40/0xc0
[    1.845949][    T0]  dump_stack+0x18/0x24
[    1.845956][    T0]  __lock_acquire+0xc68/0xd90
[    1.845976][    T0]  lock_acquire+0x14c/0x2b8
[    1.845985][    T0]  _raw_spin_lock+0x54/0x78
[    1.846011][    T0]  gs101_cpu_pm_notify_callback+0x48/0x100
[    1.846021][    T0]  notifier_call_chain+0xb0/0x198
[    1.846046][    T0]  raw_notifier_call_chain_robust+0x50/0xb0
[    1.846053][    T0]  cpu_pm_enter+0x4c/0x88
[    1.846063][    T0]  psci_enter_idle_state+0x2c/0x70
[    1.846078][    T0]  cpuidle_enter_state+0x14c/0x4c0
[    1.846097][    T0]  cpuidle_enter+0x44/0x68
[    1.846121][    T0]  do_idle+0x1f0/0x2a8
[    1.846142][    T0]  cpu_startup_entry+0x40/0x50
[    1.846152][    T0]  rest_init+0x1c4/0x1d0
[    1.846161][    T0]  start_kernel+0x358/0x438
[    1.846181][    T0]  __primary_switched+0x88/0x98

> 
> [...]
> 
> @@ -444,6 +586,18 @@ static int exynos_pmu_probe(struct platform_device *pdev)
>  			 */
>  			dev_warn(&pdev->dev, "pmu-intr-gen syscon unavailable\n");
>  		} else {
> +			pmu_context->hotplug_ing =
> +				devm_kmalloc_array(dev, num_possible_cpus(),
> +						   sizeof(bool), GFP_KERNEL);

I haven't done a full review, but sizeof(bool) should be rewritten as
sizeof(*pmu_context->hotplug_ing)

> [...]
>  
> @@ -471,10 +628,32 @@ static int exynos_pmu_probe(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int exynos_cpupm_suspend_noirq(struct device *dev)
> +{
> +	atomic_set(&pmu_context->sys_suspended, 1);
> +	return 0;
> +}
> +
> +static int exynos_cpupm_resume_noirq(struct device *dev)
> +{
> +	atomic_set(&pmu_context->sys_suspended, 0);
> +	return 0;
> +}
> +
> +static const struct dev_pm_ops cpupm_pm_ops = {
> +	.suspend_noirq = exynos_cpupm_suspend_noirq,
> +	.resume_noirq = exynos_cpupm_resume_noirq,
> +};
> +#endif
> +
>  static struct platform_driver exynos_pmu_driver = {
>  	.driver  = {
>  		.name   = "exynos-pmu",
>  		.of_match_table = exynos_pmu_of_device_ids,
> +#ifdef CONFIG_PM_SLEEP
> +		.pm = &cpupm_pm_ops,
> +#endif

This can use pm_sleep_ptr() instead to avoid the ifdef.

Cheers,
Andre'

  reply	other threads:[~2025-07-03 10:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-27 13:08 Peter Griffin
2025-07-03 10:12 ` André Draszik [this message]
2025-07-03 10:19   ` Krzysztof Kozlowski
2025-07-08 15:51     ` Peter Griffin
2025-07-08 15:50   ` Peter Griffin
2025-07-03 11:01 ` André Draszik
2025-07-09 10:04   ` Peter Griffin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=91a9d4dbe5504c493856ef81b30d98e7da925ac0.camel@linaro.org \
    --to=andre.draszik@linaro.org \
    --cc=alim.akhtar@samsung.com \
    --cc=kernel-team@android.com \
    --cc=krzk@kernel.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=peter.griffin@linaro.org \
    --cc=tudor.ambarus@linaro.org \
    --cc=willmcvicker@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®