cpuidle: Fail cpuidle device registration if there is one already
Rafael J. Wysocki
maintainerPATCH v2 1/1 cpuidle: Fail cpuidle device registration if there is one already
From: Rafael J. Wysocki <[email protected]>
Refuse to register a cpuidle device if the given CPU has a cpuidle device already and print a message regarding it.
Without this, an attempt to register a new cpuidle device without unregistering the existing one leads to the removal of the existing cpuidle device without removing its sysfs interface.
---
v1 -> v2:
* Add the new check before the driver module reference counting (Dhruva).
--- drivers/cpuidle/cpuidle.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/cpuidle/cpuidle.c +7 -1
@@ -635,8 +635,14 @@ static void __cpuidle_device_init(structstatic int __cpuidle_register_device (struct cpuidle_device *dev) {struct cpuidle_driver *drv =cpuidle_get_cpu_driver (dev); +unsigned int cpu = dev->cpu;int i, ret; +if (per_cpu (cpuidle_devices, cpu)) { +pr_info ("CPU%d: cpuidle device already registered\n" , cpu); +return -EEXIST ; + } +if (!try_module_get (drv->owner))return -EINVAL ;
@@ -648,7 +654,7 @@ static int __cpuidle_register_device(str dev->states_usage[i].disable |=CPUIDLE_STATE_DISABLED_BY_USER ; } -per_cpu (cpuidle_devices, dev->cpu) = dev; +per_cpu (cpuidle_devices, cpu) = dev;list_add (&dev->device_list, &cpuidle_detected_devices); ret =cpuidle_coupled_register_device (dev);
Hi Rafael,
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Refuse to register a cpuidle device if the given CPU has a cpuidle device already and print a message regarding it.
Without this, an attempt to register a new cpuidle device without unregistering the existing one leads to the removal of the existing cpuidle device without removing its sysfs interface.
Quoted 5 lines
Signed-off-by Rafael J. Wysocki <[email protected]>---
v1 -> v2:
* Add the new check before the driver module reference counting (Dhruva).
Thanks for addressing!
Quoted 8 lines
--- drivers/cpuidle/cpuidle.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/cpuidle/cpuidle.c static void __cpuidle_device_init(struct · line 642
Quoted 8 lines
drivers/cpuidle/cpuidle.c +3
-0@@ -635,8 +635,14 @@ static void __cpuidle_device_init(structstatic int __cpuidle_register_device (struct cpuidle_device *dev) {struct cpuidle_driver *drv =cpuidle_get_cpu_driver (dev); +unsigned int cpu = dev->cpu;int i, ret; +if (per_cpu (cpuidle_devices, cpu)) { +pr_info ("CPU%d: cpuidle device already registered\n" , cpu);
Sorry for not pointing this earlier,
perhaps pr_err makes more sense?
Anyway if you respin/ fix while applying:
Signature · 3 lines
Best regards, Dhruva Gole Texas Instruments Incorporated
Rafael J. Wysocki
maintainerQuoted 35 lines · Dhruva Gole
Hi Rafael,
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Refuse to register a cpuidle device if the given CPU has a cpuidle device already and print a message regarding it.
Without this, an attempt to register a new cpuidle device without unregistering the existing one leads to the removal of the existing cpuidle device without removing its sysfs interface.
Quoted 5 lines
Signed-off-by Rafael J. Wysocki <[email protected]>---
v1 -> v2:
* Add the new check before the driver module reference counting (Dhruva).Thanks for addressing!
Quoted 14 lines
--- drivers/cpuidle/cpuidle.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/cpuidle/cpuidle.c +1
-0@@ -635,8 +635,14 @@ static void __cpuidle_device_init(structstatic int __cpuidle_register_device (struct cpuidle_device *dev) {struct cpuidle_driver *drv =cpuidle_get_cpu_driver (dev); +unsigned int cpu = dev->cpu;int i, ret;
Quoted 5 lines
drivers/cpuidle/cpuidle.c static void __cpuidle_device_init(struct · line 642
Quoted 2 lines
drivers/cpuidle/cpuidle.c +2
-0+if (per_cpu (cpuidle_devices, cpu)) { +pr_info ("CPU%d: cpuidle device already registered\n" , cpu);Sorry for not pointing this earlier,
perhapspr_errmakes more sense?
No, this need not mean a functional issue.