Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpuidle: psci: Avoid initializing faux device if no DT idle states are present
@ 2025-05-02 14:01 Sudeep Holla
  2025-05-02 15:16 ` Ulf Hansson
  2025-05-07 13:55 ` Sudeep Holla
  0 siblings, 2 replies; 5+ messages in thread
From: Sudeep Holla @ 2025-05-02 14:01 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: Sudeep Holla, Lorenzo Pieralisi, Ulf Hansson, Rafael J. Wysocki,
	Jon Hunter

Commit af5376a77e87 ("cpuidle: psci: Transition to the faux device interface")
transitioned the PSCI cpuidle driver from using a platform device to the
faux device framework. However, unlike platform devices, the faux device
infrastructure logs an error when the probe function fails, even if the
failure is intentional or expected.

To prevent unnecessary error logs, we can skip creating the faux device
entirely if there are no PSCI idle states defined in the device tree.
Introduce a check for DT idle states during initialization and avoid
setting up the device if none are found.

This ensures cleaner logs and avoids misleading probe failure messages
when PSCI idle support is intentionally not described in DT.

Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Fixes: af5376a77e87 ("cpuidle: psci: Transition to the faux device interface")
Reported-by: Jon Hunter <jonathanh@nvidia.com>
Closes: https://lore.kernel.org/r/cf4e70e4-9fe5-4697-8744-8c12c41b5ff9@nvidia.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/cpuidle/cpuidle-psci.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c
index ee35ac816321..40f378c1dc9f 100644
--- a/drivers/cpuidle/cpuidle-psci.c
+++ b/drivers/cpuidle/cpuidle-psci.c
@@ -438,10 +438,29 @@ static struct faux_device_ops psci_cpuidle_ops = {
 	.probe = psci_cpuidle_probe,
 };
 
+static bool __init dt_idle_state_present(void)
+{
+	struct device_node *cpu_node __free(device_node);
+	struct device_node *state_node __free(device_node);
+
+	cpu_node = of_cpu_device_node_get(cpumask_first(cpu_possible_mask));
+	if (!cpu_node)
+		return false;
+
+	state_node = of_get_cpu_state_node(cpu_node, 0);
+	if (!state_node)
+		return false;
+
+	return !!of_match_node(psci_idle_state_match, state_node);
+}
+
 static int __init psci_idle_init(void)
 {
 	struct faux_device *fdev;
 
+	if (!dt_idle_state_present())
+		return 0;
+
 	fdev = faux_device_create("psci-cpuidle", NULL, &psci_cpuidle_ops);
 	if (!fdev) {
 		pr_err("Failed to create psci-cpuidle device\n");
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] cpuidle: psci: Avoid initializing faux device if no DT idle states are present
  2025-05-02 14:01 [PATCH] cpuidle: psci: Avoid initializing faux device if no DT idle states are present Sudeep Holla
@ 2025-05-02 15:16 ` Ulf Hansson
  2025-05-02 15:50   ` Sudeep Holla
  2025-05-07 13:55 ` Sudeep Holla
  1 sibling, 1 reply; 5+ messages in thread
From: Ulf Hansson @ 2025-05-02 15:16 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: linux-pm, linux-arm-kernel, Lorenzo Pieralisi, Rafael J. Wysocki,
	Jon Hunter

On Fri, 2 May 2025 at 16:01, Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> Commit af5376a77e87 ("cpuidle: psci: Transition to the faux device interface")
> transitioned the PSCI cpuidle driver from using a platform device to the
> faux device framework. However, unlike platform devices, the faux device
> infrastructure logs an error when the probe function fails, even if the
> failure is intentional or expected.
>
> To prevent unnecessary error logs, we can skip creating the faux device
> entirely if there are no PSCI idle states defined in the device tree.
> Introduce a check for DT idle states during initialization and avoid
> setting up the device if none are found.
>
> This ensures cleaner logs and avoids misleading probe failure messages
> when PSCI idle support is intentionally not described in DT.
>
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Fixes: af5376a77e87 ("cpuidle: psci: Transition to the faux device interface")
> Reported-by: Jon Hunter <jonathanh@nvidia.com>
> Closes: https://lore.kernel.org/r/cf4e70e4-9fe5-4697-8744-8c12c41b5ff9@nvidia.com
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Rafael, please pick this one.

BTW, I was not cced the original offending commit and it was funneld
via Rafael's tree. No worries this time, but probably easier to stick
with my pmdomain tree future wise, to avoid any churns. This is also
reflected in MAINTAINERS.

Kind regards
Uffe

> ---
>  drivers/cpuidle/cpuidle-psci.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/drivers/cpuidle/cpuidle-psci.c b/drivers/cpuidle/cpuidle-psci.c
> index ee35ac816321..40f378c1dc9f 100644
> --- a/drivers/cpuidle/cpuidle-psci.c
> +++ b/drivers/cpuidle/cpuidle-psci.c
> @@ -438,10 +438,29 @@ static struct faux_device_ops psci_cpuidle_ops = {
>         .probe = psci_cpuidle_probe,
>  };
>
> +static bool __init dt_idle_state_present(void)
> +{
> +       struct device_node *cpu_node __free(device_node);
> +       struct device_node *state_node __free(device_node);
> +
> +       cpu_node = of_cpu_device_node_get(cpumask_first(cpu_possible_mask));
> +       if (!cpu_node)
> +               return false;
> +
> +       state_node = of_get_cpu_state_node(cpu_node, 0);
> +       if (!state_node)
> +               return false;
> +
> +       return !!of_match_node(psci_idle_state_match, state_node);
> +}
> +
>  static int __init psci_idle_init(void)
>  {
>         struct faux_device *fdev;
>
> +       if (!dt_idle_state_present())
> +               return 0;
> +
>         fdev = faux_device_create("psci-cpuidle", NULL, &psci_cpuidle_ops);
>         if (!fdev) {
>                 pr_err("Failed to create psci-cpuidle device\n");
> --
> 2.34.1
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cpuidle: psci: Avoid initializing faux device if no DT idle states are present
  2025-05-02 15:16 ` Ulf Hansson
@ 2025-05-02 15:50   ` Sudeep Holla
  0 siblings, 0 replies; 5+ messages in thread
From: Sudeep Holla @ 2025-05-02 15:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-pm, linux-arm-kernel, Lorenzo Pieralisi, Sudeep Holla,
	Rafael J. Wysocki, Jon Hunter

On Fri, May 02, 2025 at 05:16:48PM +0200, Ulf Hansson wrote:
> On Fri, 2 May 2025 at 16:01, Sudeep Holla <sudeep.holla@arm.com> wrote:
> >
> > Commit af5376a77e87 ("cpuidle: psci: Transition to the faux device interface")
> > transitioned the PSCI cpuidle driver from using a platform device to the
> > faux device framework. However, unlike platform devices, the faux device
> > infrastructure logs an error when the probe function fails, even if the
> > failure is intentional or expected.
> >
> > To prevent unnecessary error logs, we can skip creating the faux device
> > entirely if there are no PSCI idle states defined in the device tree.
> > Introduce a check for DT idle states during initialization and avoid
> > setting up the device if none are found.
> >
> > This ensures cleaner logs and avoids misleading probe failure messages
> > when PSCI idle support is intentionally not described in DT.
> >
> > Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> > Cc: Ulf Hansson <ulf.hansson@linaro.org>
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Fixes: af5376a77e87 ("cpuidle: psci: Transition to the faux device interface")
> > Reported-by: Jon Hunter <jonathanh@nvidia.com>
> > Closes: https://lore.kernel.org/r/cf4e70e4-9fe5-4697-8744-8c12c41b5ff9@nvidia.com
> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> 
> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
> 
> Rafael, please pick this one.
> 
> BTW, I was not cced the original offending commit and it was funneld
> via Rafael's tree. No worries this time, but probably easier to stick
> with my pmdomain tree future wise, to avoid any churns. This is also
> reflected in MAINTAINERS.
> 

Understood. The original patch was part of the series and I seem to have
missed you on it. Sorry for that.

-- 
Regards,
Sudeep


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cpuidle: psci: Avoid initializing faux device if no DT idle states are present
  2025-05-02 14:01 [PATCH] cpuidle: psci: Avoid initializing faux device if no DT idle states are present Sudeep Holla
  2025-05-02 15:16 ` Ulf Hansson
@ 2025-05-07 13:55 ` Sudeep Holla
  2025-05-07 14:58   ` Rafael J. Wysocki
  1 sibling, 1 reply; 5+ messages in thread
From: Sudeep Holla @ 2025-05-07 13:55 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel
  Cc: Lorenzo Pieralisi, Ulf Hansson, Sudeep Holla, Rafael J. Wysocki,
	Jon Hunter

Hi Rafael,

On Fri, May 02, 2025 at 03:01:19PM +0100, Sudeep Holla wrote:
> Commit af5376a77e87 ("cpuidle: psci: Transition to the faux device interface")
> transitioned the PSCI cpuidle driver from using a platform device to the
> faux device framework. However, unlike platform devices, the faux device
> infrastructure logs an error when the probe function fails, even if the
> failure is intentional or expected.
> 
> To prevent unnecessary error logs, we can skip creating the faux device
> entirely if there are no PSCI idle states defined in the device tree.
> Introduce a check for DT idle states during initialization and avoid
> setting up the device if none are found.
> 
> This ensures cleaner logs and avoids misleading probe failure messages
> when PSCI idle support is intentionally not described in DT.
>

As you pointed out in another similar fix that exist only in the linux-next,
I have also missed to point out that fact here. This is only present in
the next. Let me know if you want me to drop the commit hash reference
and repost it with -next prefix which I generally do and somehow clearly
missed here. Sorry for that.

-- 
Regards,
Sudeep


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cpuidle: psci: Avoid initializing faux device if no DT idle states are present
  2025-05-07 13:55 ` Sudeep Holla
@ 2025-05-07 14:58   ` Rafael J. Wysocki
  0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2025-05-07 14:58 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: linux-pm, linux-arm-kernel, Lorenzo Pieralisi, Ulf Hansson,
	Rafael J. Wysocki, Jon Hunter

Hi Sudeep,

On Wed, May 7, 2025 at 3:56 PM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> Hi Rafael,
>
> On Fri, May 02, 2025 at 03:01:19PM +0100, Sudeep Holla wrote:
> > Commit af5376a77e87 ("cpuidle: psci: Transition to the faux device interface")
> > transitioned the PSCI cpuidle driver from using a platform device to the
> > faux device framework. However, unlike platform devices, the faux device
> > infrastructure logs an error when the probe function fails, even if the
> > failure is intentional or expected.
> >
> > To prevent unnecessary error logs, we can skip creating the faux device
> > entirely if there are no PSCI idle states defined in the device tree.
> > Introduce a check for DT idle states during initialization and avoid
> > setting up the device if none are found.
> >
> > This ensures cleaner logs and avoids misleading probe failure messages
> > when PSCI idle support is intentionally not described in DT.
> >
>
> As you pointed out in another similar fix that exist only in the linux-next,
> I have also missed to point out that fact here. This is only present in
> the next. Let me know if you want me to drop the commit hash reference
> and repost it with -next prefix which I generally do and somehow clearly
> missed here. Sorry for that.

No worries.

The cpuidle branch hasn't changed, so this is applicable with no changes.

Applied now, thanks!


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-05-07 15:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-02 14:01 [PATCH] cpuidle: psci: Avoid initializing faux device if no DT idle states are present Sudeep Holla
2025-05-02 15:16 ` Ulf Hansson
2025-05-02 15:50   ` Sudeep Holla
2025-05-07 13:55 ` Sudeep Holla
2025-05-07 14:58   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox