forked from luck/tmp_suning_uos_patched
77dcfe2b9e
- Rework the main suspend-to-idle control flow to avoid repeating "noirq" device resume and suspend operations in case of spurious wakeups from the ACPI EC and decouple the ACPI EC wakeups support from the LPS0 _DSM support (Rafael Wysocki). - Extend the wakeup sources framework to expose wakeup sources as device objects in sysfs (Tri Vo, Stephen Boyd). - Expose system suspend statistics in sysfs (Kalesh Singh). - Introduce a new haltpoll cpuidle driver and a new matching governor for virtualized guests wanting to do guest-side polling in the idle loop (Marcelo Tosatti, Joao Martins, Wanpeng Li, Stephen Rothwell). - Fix the menu and teo cpuidle governors to allow the scheduler tick to be stopped if PM QoS is used to limit the CPU idle state exit latency in some cases (Rafael Wysocki). - Increase the resolution of the play_idle() argument to microseconds for more fine-grained injection of CPU idle cycles (Daniel Lezcano). - Switch over some users of cpuidle notifiers to the new QoS-based frequency limits and drop the CPUFREQ_ADJUST and CPUFREQ_NOTIFY policy notifier events (Viresh Kumar). - Add new cpufreq driver based on nvmem for sun50i (Yangtao Li). - Add support for MT8183 and MT8516 to the mediatek cpufreq driver (Andrew-sh.Cheng, Fabien Parent). - Add i.MX8MN support to the imx-cpufreq-dt cpufreq driver (Anson Huang). - Add qcs404 to cpufreq-dt-platdev blacklist (Jorge Ramirez-Ortiz). - Update the qcom cpufreq driver (among other things, to make it easier to extend and to use kryo cpufreq for other nvmem-based SoCs) and add qcs404 support to it (Niklas Cassel, Douglas RAILLARD, Sibi Sankar, Sricharan R). - Fix assorted issues and make assorted minor improvements in the cpufreq code (Colin Ian King, Douglas RAILLARD, Florian Fainelli, Gustavo Silva, Hariprasad Kelam). - Add new devfreq driver for NVidia Tegra20 (Dmitry Osipenko, Arnd Bergmann). - Add new Exynos PPMU events to devfreq events and extend that mechanism (Lukasz Luba). - Fix and clean up the exynos-bus devfreq driver (Kamil Konieczny). - Improve devfreq documentation and governor code, fix spelling typos in devfreq (Ezequiel Garcia, Krzysztof Kozlowski, Leonard Crestez, MyungJoo Ham, Gaël PORTAY). - Add regulators enable and disable to the OPP (operating performance points) framework (Kamil Konieczny). - Update the OPP framework to support multiple opp-suspend properties (Anson Huang). - Fix assorted issues and make assorted minor improvements in the OPP code (Niklas Cassel, Viresh Kumar, Yue Hu). - Clean up the generic power domains (genpd) framework (Ulf Hansson). - Clean up assorted pieces of power management code and documentation (Akinobu Mita, Amit Kucheria, Chuhong Yuan). - Update the pm-graph tool to version 5.5 including multiple fixes and improvements (Todd Brandt). - Update the cpupower utility (Benjamin Weis, Geert Uytterhoeven, Sébastien Szymanski). -----BEGIN PGP SIGNATURE----- iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAl2ArZ4SHHJqd0Byand5 c29ja2kubmV0AAoJEILEb/54YlRxgfYQAK80hs43vWQDmp7XKrN4pQe8+qYULAGO fBfrFl+NG9y/cnuqnt3NtA8MoyNsMMkMLkpkEDMfSbYqqH5ehEzX5+uGJWiWx8+Y oH5KU8MH7Tj/utYaalGzDt0AHfHZDIGC0NCUNQJVtE/4mOANFabwsCwscp4MrD5Q WjFN8U4BrsmWgJdZ/U9QIWcDZ0I+1etCF+rZG2yxSv31FMq2Zk/Qm4YyobqCvQFl TR9rxl08wqUmIYIz5cDjt/3AKH7NLLDqOTstbCL7cmufM5XPFc1yox69xc89UrIa 4AMgmDp7SMwFG/gdUPof0WQNmx7qxmiRAPleAOYBOZW/8jPNZk2y+RhM5NeF72m7 AFqYiuxqatkSb4IsT8fLzH9IUZOdYr8uSmoMQECw+MHdApaKFjFV8Lb/qx5+AwkD y7pwys8dZSamAjAf62eUzJDWcEwkNrujIisGrIXrVHb7ISbweskMOmdAYn9p4KgP dfRzpJBJ45IaMIdbaVXNpg3rP7Apfs7X1X+/ZhG6f+zHH3zYwr8Y81WPqX8WaZJ4 qoVCyxiVWzMYjY2/1lzjaAdqWojPWHQ3or3eBaK52DouyG3jY6hCDTLwU7iuqcCX jzAtrnqrNIKufvaObEmqcmYlIIOFT7QaJCtGUSRFQLfSon8fsVSR7LLeXoAMUJKT JWQenuNaJngK =TBDQ -----END PGP SIGNATURE----- Merge tag 'pm-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm Pull power management updates from Rafael Wysocki: "These include a rework of the main suspend-to-idle code flow (related to the handling of spurious wakeups), a switch over of several users of cpufreq notifiers to QoS-based limits, a new devfreq driver for Tegra20, a new cpuidle driver and governor for virtualized guests, an extension of the wakeup sources framework to expose wakeup sources as device objects in sysfs, and more. Specifics: - Rework the main suspend-to-idle control flow to avoid repeating "noirq" device resume and suspend operations in case of spurious wakeups from the ACPI EC and decouple the ACPI EC wakeups support from the LPS0 _DSM support (Rafael Wysocki). - Extend the wakeup sources framework to expose wakeup sources as device objects in sysfs (Tri Vo, Stephen Boyd). - Expose system suspend statistics in sysfs (Kalesh Singh). - Introduce a new haltpoll cpuidle driver and a new matching governor for virtualized guests wanting to do guest-side polling in the idle loop (Marcelo Tosatti, Joao Martins, Wanpeng Li, Stephen Rothwell). - Fix the menu and teo cpuidle governors to allow the scheduler tick to be stopped if PM QoS is used to limit the CPU idle state exit latency in some cases (Rafael Wysocki). - Increase the resolution of the play_idle() argument to microseconds for more fine-grained injection of CPU idle cycles (Daniel Lezcano). - Switch over some users of cpuidle notifiers to the new QoS-based frequency limits and drop the CPUFREQ_ADJUST and CPUFREQ_NOTIFY policy notifier events (Viresh Kumar). - Add new cpufreq driver based on nvmem for sun50i (Yangtao Li). - Add support for MT8183 and MT8516 to the mediatek cpufreq driver (Andrew-sh.Cheng, Fabien Parent). - Add i.MX8MN support to the imx-cpufreq-dt cpufreq driver (Anson Huang). - Add qcs404 to cpufreq-dt-platdev blacklist (Jorge Ramirez-Ortiz). - Update the qcom cpufreq driver (among other things, to make it easier to extend and to use kryo cpufreq for other nvmem-based SoCs) and add qcs404 support to it (Niklas Cassel, Douglas RAILLARD, Sibi Sankar, Sricharan R). - Fix assorted issues and make assorted minor improvements in the cpufreq code (Colin Ian King, Douglas RAILLARD, Florian Fainelli, Gustavo Silva, Hariprasad Kelam). - Add new devfreq driver for NVidia Tegra20 (Dmitry Osipenko, Arnd Bergmann). - Add new Exynos PPMU events to devfreq events and extend that mechanism (Lukasz Luba). - Fix and clean up the exynos-bus devfreq driver (Kamil Konieczny). - Improve devfreq documentation and governor code, fix spelling typos in devfreq (Ezequiel Garcia, Krzysztof Kozlowski, Leonard Crestez, MyungJoo Ham, Gaël PORTAY). - Add regulators enable and disable to the OPP (operating performance points) framework (Kamil Konieczny). - Update the OPP framework to support multiple opp-suspend properties (Anson Huang). - Fix assorted issues and make assorted minor improvements in the OPP code (Niklas Cassel, Viresh Kumar, Yue Hu). - Clean up the generic power domains (genpd) framework (Ulf Hansson). - Clean up assorted pieces of power management code and documentation (Akinobu Mita, Amit Kucheria, Chuhong Yuan). - Update the pm-graph tool to version 5.5 including multiple fixes and improvements (Todd Brandt). - Update the cpupower utility (Benjamin Weis, Geert Uytterhoeven, Sébastien Szymanski)" * tag 'pm-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (126 commits) cpuidle-haltpoll: Enable kvm guest polling when dedicated physical CPUs are available cpuidle-haltpoll: do not set an owner to allow modunload cpuidle-haltpoll: return -ENODEV on modinit failure cpuidle-haltpoll: set haltpoll as preferred governor cpuidle: allow governor switch on cpuidle_register_driver() PM: runtime: Documentation: add runtime_status ABI document pm-graph: make setVal unbuffered again for python2 and python3 powercap: idle_inject: Use higher resolution for idle injection cpuidle: play_idle: Increase the resolution to usec cpuidle-haltpoll: vcpu hotplug support cpufreq: Add qcs404 to cpufreq-dt-platdev blacklist cpufreq: qcom: Add support for qcs404 on nvmem driver cpufreq: qcom: Refactor the driver to make it easier to extend cpufreq: qcom: Re-organise kryo cpufreq to use it for other nvmem based qcom socs dt-bindings: opp: Add qcom-opp bindings with properties needed for CPR dt-bindings: opp: qcom-nvmem: Support pstates provided by a power domain Documentation: cpufreq: Update policy notifier documentation cpufreq: Remove CPUFREQ_ADJUST and CPUFREQ_NOTIFY policy notifier events PM / Domains: Verify PM domain type in dev_pm_genpd_set_performance_state() PM / Domains: Simplify genpd_lookup_dev() ...
305 lines
9.8 KiB
C
305 lines
9.8 KiB
C
/*
|
|
* cpuidle.h - a generic framework for CPU idle power management
|
|
*
|
|
* (C) 2007 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
|
|
* Shaohua Li <shaohua.li@intel.com>
|
|
* Adam Belay <abelay@novell.com>
|
|
*
|
|
* This code is licenced under the GPL.
|
|
*/
|
|
|
|
#ifndef _LINUX_CPUIDLE_H
|
|
#define _LINUX_CPUIDLE_H
|
|
|
|
#include <linux/percpu.h>
|
|
#include <linux/list.h>
|
|
#include <linux/hrtimer.h>
|
|
|
|
#define CPUIDLE_STATE_MAX 10
|
|
#define CPUIDLE_NAME_LEN 16
|
|
#define CPUIDLE_DESC_LEN 32
|
|
|
|
struct module;
|
|
|
|
struct cpuidle_device;
|
|
struct cpuidle_driver;
|
|
|
|
|
|
/****************************
|
|
* CPUIDLE DEVICE INTERFACE *
|
|
****************************/
|
|
|
|
struct cpuidle_state_usage {
|
|
unsigned long long disable;
|
|
unsigned long long usage;
|
|
unsigned long long time; /* in US */
|
|
unsigned long long above; /* Number of times it's been too deep */
|
|
unsigned long long below; /* Number of times it's been too shallow */
|
|
#ifdef CONFIG_SUSPEND
|
|
unsigned long long s2idle_usage;
|
|
unsigned long long s2idle_time; /* in US */
|
|
#endif
|
|
};
|
|
|
|
struct cpuidle_state {
|
|
char name[CPUIDLE_NAME_LEN];
|
|
char desc[CPUIDLE_DESC_LEN];
|
|
|
|
unsigned int flags;
|
|
unsigned int exit_latency; /* in US */
|
|
int power_usage; /* in mW */
|
|
unsigned int target_residency; /* in US */
|
|
bool disabled; /* disabled on all CPUs */
|
|
|
|
int (*enter) (struct cpuidle_device *dev,
|
|
struct cpuidle_driver *drv,
|
|
int index);
|
|
|
|
int (*enter_dead) (struct cpuidle_device *dev, int index);
|
|
|
|
/*
|
|
* CPUs execute ->enter_s2idle with the local tick or entire timekeeping
|
|
* suspended, so it must not re-enable interrupts at any point (even
|
|
* temporarily) or attempt to change states of clock event devices.
|
|
*/
|
|
void (*enter_s2idle) (struct cpuidle_device *dev,
|
|
struct cpuidle_driver *drv,
|
|
int index);
|
|
};
|
|
|
|
/* Idle State Flags */
|
|
#define CPUIDLE_FLAG_NONE (0x00)
|
|
#define CPUIDLE_FLAG_POLLING BIT(0) /* polling state */
|
|
#define CPUIDLE_FLAG_COUPLED BIT(1) /* state applies to multiple cpus */
|
|
#define CPUIDLE_FLAG_TIMER_STOP BIT(2) /* timer is stopped on this state */
|
|
|
|
struct cpuidle_device_kobj;
|
|
struct cpuidle_state_kobj;
|
|
struct cpuidle_driver_kobj;
|
|
|
|
struct cpuidle_device {
|
|
unsigned int registered:1;
|
|
unsigned int enabled:1;
|
|
unsigned int use_deepest_state:1;
|
|
unsigned int poll_time_limit:1;
|
|
unsigned int cpu;
|
|
ktime_t next_hrtimer;
|
|
|
|
int last_state_idx;
|
|
int last_residency;
|
|
u64 poll_limit_ns;
|
|
struct cpuidle_state_usage states_usage[CPUIDLE_STATE_MAX];
|
|
struct cpuidle_state_kobj *kobjs[CPUIDLE_STATE_MAX];
|
|
struct cpuidle_driver_kobj *kobj_driver;
|
|
struct cpuidle_device_kobj *kobj_dev;
|
|
struct list_head device_list;
|
|
|
|
#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
|
|
cpumask_t coupled_cpus;
|
|
struct cpuidle_coupled *coupled;
|
|
#endif
|
|
};
|
|
|
|
DECLARE_PER_CPU(struct cpuidle_device *, cpuidle_devices);
|
|
DECLARE_PER_CPU(struct cpuidle_device, cpuidle_dev);
|
|
|
|
/****************************
|
|
* CPUIDLE DRIVER INTERFACE *
|
|
****************************/
|
|
|
|
struct cpuidle_driver {
|
|
const char *name;
|
|
struct module *owner;
|
|
int refcnt;
|
|
|
|
/* used by the cpuidle framework to setup the broadcast timer */
|
|
unsigned int bctimer:1;
|
|
/* states array must be ordered in decreasing power consumption */
|
|
struct cpuidle_state states[CPUIDLE_STATE_MAX];
|
|
int state_count;
|
|
int safe_state_index;
|
|
|
|
/* the driver handles the cpus in cpumask */
|
|
struct cpumask *cpumask;
|
|
|
|
/* preferred governor to switch at register time */
|
|
const char *governor;
|
|
};
|
|
|
|
#ifdef CONFIG_CPU_IDLE
|
|
extern void disable_cpuidle(void);
|
|
extern bool cpuidle_not_available(struct cpuidle_driver *drv,
|
|
struct cpuidle_device *dev);
|
|
|
|
extern int cpuidle_select(struct cpuidle_driver *drv,
|
|
struct cpuidle_device *dev,
|
|
bool *stop_tick);
|
|
extern int cpuidle_enter(struct cpuidle_driver *drv,
|
|
struct cpuidle_device *dev, int index);
|
|
extern void cpuidle_reflect(struct cpuidle_device *dev, int index);
|
|
extern u64 cpuidle_poll_time(struct cpuidle_driver *drv,
|
|
struct cpuidle_device *dev);
|
|
|
|
extern int cpuidle_register_driver(struct cpuidle_driver *drv);
|
|
extern struct cpuidle_driver *cpuidle_get_driver(void);
|
|
extern struct cpuidle_driver *cpuidle_driver_ref(void);
|
|
extern void cpuidle_driver_unref(void);
|
|
extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
|
|
extern int cpuidle_register_device(struct cpuidle_device *dev);
|
|
extern void cpuidle_unregister_device(struct cpuidle_device *dev);
|
|
extern int cpuidle_register(struct cpuidle_driver *drv,
|
|
const struct cpumask *const coupled_cpus);
|
|
extern void cpuidle_unregister(struct cpuidle_driver *drv);
|
|
extern void cpuidle_pause_and_lock(void);
|
|
extern void cpuidle_resume_and_unlock(void);
|
|
extern void cpuidle_pause(void);
|
|
extern void cpuidle_resume(void);
|
|
extern int cpuidle_enable_device(struct cpuidle_device *dev);
|
|
extern void cpuidle_disable_device(struct cpuidle_device *dev);
|
|
extern int cpuidle_play_dead(void);
|
|
|
|
extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev);
|
|
static inline struct cpuidle_device *cpuidle_get_device(void)
|
|
{return __this_cpu_read(cpuidle_devices); }
|
|
#else
|
|
static inline void disable_cpuidle(void) { }
|
|
static inline bool cpuidle_not_available(struct cpuidle_driver *drv,
|
|
struct cpuidle_device *dev)
|
|
{return true; }
|
|
static inline int cpuidle_select(struct cpuidle_driver *drv,
|
|
struct cpuidle_device *dev, bool *stop_tick)
|
|
{return -ENODEV; }
|
|
static inline int cpuidle_enter(struct cpuidle_driver *drv,
|
|
struct cpuidle_device *dev, int index)
|
|
{return -ENODEV; }
|
|
static inline void cpuidle_reflect(struct cpuidle_device *dev, int index) { }
|
|
static inline u64 cpuidle_poll_time(struct cpuidle_driver *drv,
|
|
struct cpuidle_device *dev)
|
|
{return 0; }
|
|
static inline int cpuidle_register_driver(struct cpuidle_driver *drv)
|
|
{return -ENODEV; }
|
|
static inline struct cpuidle_driver *cpuidle_get_driver(void) {return NULL; }
|
|
static inline struct cpuidle_driver *cpuidle_driver_ref(void) {return NULL; }
|
|
static inline void cpuidle_driver_unref(void) {}
|
|
static inline void cpuidle_unregister_driver(struct cpuidle_driver *drv) { }
|
|
static inline int cpuidle_register_device(struct cpuidle_device *dev)
|
|
{return -ENODEV; }
|
|
static inline void cpuidle_unregister_device(struct cpuidle_device *dev) { }
|
|
static inline int cpuidle_register(struct cpuidle_driver *drv,
|
|
const struct cpumask *const coupled_cpus)
|
|
{return -ENODEV; }
|
|
static inline void cpuidle_unregister(struct cpuidle_driver *drv) { }
|
|
static inline void cpuidle_pause_and_lock(void) { }
|
|
static inline void cpuidle_resume_and_unlock(void) { }
|
|
static inline void cpuidle_pause(void) { }
|
|
static inline void cpuidle_resume(void) { }
|
|
static inline int cpuidle_enable_device(struct cpuidle_device *dev)
|
|
{return -ENODEV; }
|
|
static inline void cpuidle_disable_device(struct cpuidle_device *dev) { }
|
|
static inline int cpuidle_play_dead(void) {return -ENODEV; }
|
|
static inline struct cpuidle_driver *cpuidle_get_cpu_driver(
|
|
struct cpuidle_device *dev) {return NULL; }
|
|
static inline struct cpuidle_device *cpuidle_get_device(void) {return NULL; }
|
|
#endif
|
|
|
|
#ifdef CONFIG_CPU_IDLE
|
|
extern int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
|
|
struct cpuidle_device *dev);
|
|
extern int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
|
|
struct cpuidle_device *dev);
|
|
extern void cpuidle_use_deepest_state(bool enable);
|
|
#else
|
|
static inline int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
|
|
struct cpuidle_device *dev)
|
|
{return -ENODEV; }
|
|
static inline int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
|
|
struct cpuidle_device *dev)
|
|
{return -ENODEV; }
|
|
static inline void cpuidle_use_deepest_state(bool enable)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
/* kernel/sched/idle.c */
|
|
extern void sched_idle_set_state(struct cpuidle_state *idle_state);
|
|
extern void default_idle_call(void);
|
|
|
|
#ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
|
|
void cpuidle_coupled_parallel_barrier(struct cpuidle_device *dev, atomic_t *a);
|
|
#else
|
|
static inline void cpuidle_coupled_parallel_barrier(struct cpuidle_device *dev, atomic_t *a)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
#if defined(CONFIG_CPU_IDLE) && defined(CONFIG_ARCH_HAS_CPU_RELAX)
|
|
void cpuidle_poll_state_init(struct cpuidle_driver *drv);
|
|
#else
|
|
static inline void cpuidle_poll_state_init(struct cpuidle_driver *drv) {}
|
|
#endif
|
|
|
|
/******************************
|
|
* CPUIDLE GOVERNOR INTERFACE *
|
|
******************************/
|
|
|
|
struct cpuidle_governor {
|
|
char name[CPUIDLE_NAME_LEN];
|
|
struct list_head governor_list;
|
|
unsigned int rating;
|
|
|
|
int (*enable) (struct cpuidle_driver *drv,
|
|
struct cpuidle_device *dev);
|
|
void (*disable) (struct cpuidle_driver *drv,
|
|
struct cpuidle_device *dev);
|
|
|
|
int (*select) (struct cpuidle_driver *drv,
|
|
struct cpuidle_device *dev,
|
|
bool *stop_tick);
|
|
void (*reflect) (struct cpuidle_device *dev, int index);
|
|
};
|
|
|
|
#ifdef CONFIG_CPU_IDLE
|
|
extern int cpuidle_register_governor(struct cpuidle_governor *gov);
|
|
extern int cpuidle_governor_latency_req(unsigned int cpu);
|
|
#else
|
|
static inline int cpuidle_register_governor(struct cpuidle_governor *gov)
|
|
{return 0;}
|
|
#endif
|
|
|
|
#define __CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, \
|
|
idx, \
|
|
state, \
|
|
is_retention) \
|
|
({ \
|
|
int __ret = 0; \
|
|
\
|
|
if (!idx) { \
|
|
cpu_do_idle(); \
|
|
return idx; \
|
|
} \
|
|
\
|
|
if (!is_retention) \
|
|
__ret = cpu_pm_enter(); \
|
|
if (!__ret) { \
|
|
__ret = low_level_idle_enter(state); \
|
|
if (!is_retention) \
|
|
cpu_pm_exit(); \
|
|
} \
|
|
\
|
|
__ret ? -1 : idx; \
|
|
})
|
|
|
|
#define CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, idx) \
|
|
__CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, idx, idx, 0)
|
|
|
|
#define CPU_PM_CPU_IDLE_ENTER_RETENTION(low_level_idle_enter, idx) \
|
|
__CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, idx, idx, 1)
|
|
|
|
#define CPU_PM_CPU_IDLE_ENTER_PARAM(low_level_idle_enter, idx, state) \
|
|
__CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, idx, state, 0)
|
|
|
|
#define CPU_PM_CPU_IDLE_ENTER_RETENTION_PARAM(low_level_idle_enter, idx, state) \
|
|
__CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, idx, state, 1)
|
|
|
|
#endif /* _LINUX_CPUIDLE_H */
|