Skip to content
This repository has been archived by the owner on Oct 5, 2018. It is now read-only.

Commit

Permalink
Merge branch 'working-hikey960-upstream-cpuidle' into working-hikey96…
Browse files Browse the repository at this point in the history
…0-upstream-rebase-v4.12-rc7-2017-06-27-16-41-21

* working-hikey960-upstream-cpuidle:
  cpuidle: Fix NULL driver checking
  ARM: cpuidle: Support asymmetric idle definition
  • Loading branch information
docularxu committed Jun 27, 2017
2 parents ff88baa + 17e3c5b commit ff812de
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 27 deletions.
1 change: 1 addition & 0 deletions drivers/cpuidle/Kconfig.arm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
config ARM_CPUIDLE
bool "Generic ARM/ARM64 CPU idle Driver"
select DT_IDLE_STATES
select CPU_IDLE_MULTIPLE_DRIVERS
help
Select this to enable generic cpuidle driver for ARM.
It provides a generic idle driver whose idle states are configured
Expand Down
62 changes: 38 additions & 24 deletions drivers/cpuidle/cpuidle-arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/slab.h>
#include <linux/topology.h>

#include <asm/cpuidle.h>

Expand All @@ -44,7 +45,7 @@ static int arm_enter_idle_state(struct cpuidle_device *dev,
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,
/*
Expand Down Expand Up @@ -80,30 +81,42 @@ static const struct of_device_id arm_idle_state_match[] __initconst = {
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;

ret = cpuidle_register_driver(drv);
if (ret) {
pr_err("Failed to register cpuidle driver\n");
return ret;
}

/*
* Call arch CPU operations in order to initialize
* idle states suspend back-end specific data
*/
for_each_possible_cpu(cpu) {

drv = kmemdup(&arm_idle_driver, sizeof(*drv), GFP_KERNEL);
if (!drv) {
ret = -ENOMEM;
goto out_fail;
}

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_fail;
}

ret = cpuidle_register_driver(drv);
if (ret) {
pr_err("Failed to register cpuidle driver\n");
goto out_fail;
}

/*
* Call arch CPU operations in order to initialize
* idle states suspend back-end specific data
*/
ret = arm_cpuidle_init(cpu);

/*
Expand Down Expand Up @@ -141,10 +154,11 @@ static int __init arm_idle_init(void)
dev = per_cpu(cpuidle_devices, cpu);
cpuidle_unregister_device(dev);
kfree(dev);
drv = cpuidle_get_driver();
cpuidle_unregister_driver(drv);
kfree(drv);
}

cpuidle_unregister_driver(drv);

return ret;
}
device_initcall(arm_idle_init);
8 changes: 5 additions & 3 deletions drivers/cpuidle/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,11 @@ EXPORT_SYMBOL_GPL(cpuidle_register_driver);
*/
void cpuidle_unregister_driver(struct cpuidle_driver *drv)
{
spin_lock(&cpuidle_driver_lock);
__cpuidle_unregister_driver(drv);
spin_unlock(&cpuidle_driver_lock);
if (drv) {
spin_lock(&cpuidle_driver_lock);
__cpuidle_unregister_driver(drv);
spin_unlock(&cpuidle_driver_lock);
}
}
EXPORT_SYMBOL_GPL(cpuidle_unregister_driver);

Expand Down

0 comments on commit ff812de

Please sign in to comment.