mirror of https://github.com/OpenIPC/firmware.git
156 lines
3.9 KiB
Diff
156 lines
3.9 KiB
Diff
diff -drupN a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c
|
|
--- a/drivers/cpuidle/cpuidle-arm.c 2018-08-06 17:23:04.000000000 +0300
|
|
+++ b/drivers/cpuidle/cpuidle-arm.c 2022-06-12 05:28:14.000000000 +0300
|
|
@@ -18,7 +18,8 @@
|
|
#include <linux/module.h>
|
|
#include <linux/of.h>
|
|
#include <linux/slab.h>
|
|
-
|
|
+#include <linux/topology.h>
|
|
+#include <linux/smp.h>
|
|
#include <asm/cpuidle.h>
|
|
|
|
#include "dt_idle_states.h"
|
|
@@ -36,6 +37,19 @@
|
|
static int arm_enter_idle_state(struct cpuidle_device *dev,
|
|
struct cpuidle_driver *drv, int idx)
|
|
{
|
|
+#if !defined(CONFIG_SUNXI_CPU0IDLE)
|
|
+ /*
|
|
+ * FIXME:may delete this code when sunxi cpuidle is ok.
|
|
+ */
|
|
+#ifdef CONFIG_ARM_SUNXI_CPUIDLE
|
|
+ if (!smp_processor_id())
|
|
+#endif
|
|
+ {
|
|
+ cpu_do_idle();
|
|
+ return idx;
|
|
+ }
|
|
+#endif
|
|
+
|
|
/*
|
|
* Pass idle state index to arm_cpuidle_suspend which in turn
|
|
* will call the CPU ops suspend protocol with idle index as a
|
|
@@ -44,7 +58,7 @@ static int arm_enter_idle_state(struct c
|
|
return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, idx);
|
|
}
|
|
|
|
-static struct cpuidle_driver arm_idle_driver = {
|
|
+static struct cpuidle_driver arm_idle_driver __initdata = {
|
|
.name = "arm_idle",
|
|
.owner = THIS_MODULE,
|
|
/*
|
|
@@ -80,30 +94,42 @@ static const struct of_device_id arm_idl
|
|
static int __init arm_idle_init(void)
|
|
{
|
|
int cpu, ret;
|
|
- struct cpuidle_driver *drv = &arm_idle_driver;
|
|
+ struct cpuidle_driver *drv;
|
|
struct cpuidle_device *dev;
|
|
|
|
- /*
|
|
- * Initialize idle states data, starting at index 1.
|
|
- * This driver is DT only, if no DT idle states are detected (ret == 0)
|
|
- * let the driver initialization fail accordingly since there is no
|
|
- * reason to initialize the idle driver if only wfi is supported.
|
|
- */
|
|
- ret = dt_init_idle_driver(drv, arm_idle_state_match, 1);
|
|
- if (ret <= 0)
|
|
- return ret ? : -ENODEV;
|
|
+ for_each_possible_cpu(cpu) {
|
|
|
|
- ret = cpuidle_register_driver(drv);
|
|
- if (ret) {
|
|
- pr_err("Failed to register cpuidle driver\n");
|
|
- return ret;
|
|
- }
|
|
+ drv = kmemdup(&arm_idle_driver, sizeof(*drv), GFP_KERNEL);
|
|
+ if (!drv) {
|
|
+ ret = -ENOMEM;
|
|
+ goto out_fail;
|
|
+ }
|
|
|
|
- /*
|
|
- * Call arch CPU operations in order to initialize
|
|
- * idle states suspend back-end specific data
|
|
- */
|
|
- for_each_possible_cpu(cpu) {
|
|
+ drv->cpumask = (struct cpumask *)cpumask_of(cpu);
|
|
+
|
|
+ /*
|
|
+ * Initialize idle states data, starting at index 1. This
|
|
+ * driver is DT only, if no DT idle states are detected (ret
|
|
+ * == 0) let the driver initialization fail accordingly since
|
|
+ * there is no reason to initialize the idle driver if only
|
|
+ * wfi is supported.
|
|
+ */
|
|
+ ret = dt_init_idle_driver(drv, arm_idle_state_match, 1);
|
|
+ if (ret <= 0) {
|
|
+ ret = ret ? : -ENODEV;
|
|
+ goto out_kfree_drv;
|
|
+ }
|
|
+
|
|
+ ret = cpuidle_register_driver(drv);
|
|
+ if (ret) {
|
|
+ pr_err("Failed to register cpuidle driver\n");
|
|
+ goto out_kfree_drv;
|
|
+ }
|
|
+
|
|
+ /*
|
|
+ * Call arch CPU operations in order to initialize
|
|
+ * idle states suspend back-end specific data
|
|
+ */
|
|
ret = arm_cpuidle_init(cpu);
|
|
|
|
/*
|
|
@@ -115,14 +141,14 @@ static int __init arm_idle_init(void)
|
|
|
|
if (ret) {
|
|
pr_err("CPU %d failed to init idle CPU ops\n", cpu);
|
|
- goto out_fail;
|
|
+ goto out_unregister_drv;
|
|
}
|
|
|
|
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
|
|
if (!dev) {
|
|
pr_err("Failed to allocate cpuidle device\n");
|
|
ret = -ENOMEM;
|
|
- goto out_fail;
|
|
+ goto out_unregister_drv;
|
|
}
|
|
dev->cpu = cpu;
|
|
|
|
@@ -130,21 +156,28 @@ static int __init arm_idle_init(void)
|
|
if (ret) {
|
|
pr_err("Failed to register cpuidle device for CPU %d\n",
|
|
cpu);
|
|
- kfree(dev);
|
|
- goto out_fail;
|
|
+ goto out_kfree_dev;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
+
|
|
+out_kfree_dev:
|
|
+ kfree(dev);
|
|
+out_unregister_drv:
|
|
+ cpuidle_unregister_driver(drv);
|
|
+out_kfree_drv:
|
|
+ kfree(drv);
|
|
out_fail:
|
|
while (--cpu >= 0) {
|
|
dev = per_cpu(cpuidle_devices, cpu);
|
|
+ drv = cpuidle_get_cpu_driver(dev);
|
|
cpuidle_unregister_device(dev);
|
|
+ cpuidle_unregister_driver(drv);
|
|
kfree(dev);
|
|
+ kfree(drv);
|
|
}
|
|
|
|
- cpuidle_unregister_driver(drv);
|
|
-
|
|
return ret;
|
|
}
|
|
device_initcall(arm_idle_init);
|