Skip to content

Commit 5836ebe

Browse files
sudeep-hollarafaeljw
authored andcommitted
cpuidle: psci: Avoid initializing faux device if no DT idle states are present
Commit af5376a ("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. Fixes: af5376a ("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> Link: https://patch.msgid.link/20250502140119.2578909-1-sudeep.holla@arm.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent e80e134 commit 5836ebe

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

drivers/cpuidle/cpuidle-psci.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,29 @@ static struct faux_device_ops psci_cpuidle_ops = {
438438
.probe = psci_cpuidle_probe,
439439
};
440440

441+
static bool __init dt_idle_state_present(void)
442+
{
443+
struct device_node *cpu_node __free(device_node);
444+
struct device_node *state_node __free(device_node);
445+
446+
cpu_node = of_cpu_device_node_get(cpumask_first(cpu_possible_mask));
447+
if (!cpu_node)
448+
return false;
449+
450+
state_node = of_get_cpu_state_node(cpu_node, 0);
451+
if (!state_node)
452+
return false;
453+
454+
return !!of_match_node(psci_idle_state_match, state_node);
455+
}
456+
441457
static int __init psci_idle_init(void)
442458
{
443459
struct faux_device *fdev;
444460

461+
if (!dt_idle_state_present())
462+
return 0;
463+
445464
fdev = faux_device_create("psci-cpuidle", NULL, &psci_cpuidle_ops);
446465
if (!fdev) {
447466
pr_err("Failed to create psci-cpuidle device\n");

0 commit comments

Comments
 (0)