PM QoS: add a per-device latency constraints class
Subsystems (21)
PATCH v4 1/15 PM QoS: move and rename the implementation files
In reply to [email protected]From: Jean Pihet <[email protected]>
The PM QoS implementation files are better namedkernel/power/qos.c and include/linux/pm_qos.h.
The PM QoS support is compiled under the CONFIG_PM option.
--- arch/arm/mach-msm/clock.c | 2 +- drivers/acpi/processor_idle.c | 2 +- drivers/cpuidle/cpuidle.c | 2 +- drivers/cpuidle/governors/ladder.c | 2 +- drivers/cpuidle/governors/menu.c | 2 +- drivers/media/video/via-camera.c | 2 +- drivers/net/e1000e/netdev.c | 2 +- drivers/net/wireless/ipw2x00/ipw2100.c | 2 +- drivers/staging/msm/lcdc.c | 2 +- drivers/staging/msm/tvenc.c | 2 +- include/linux/netdevice.h | 2 +- include/linux/pm_qos.h | 61 ++++ include/linux/pm_qos_params.h | 38 --- include/sound/pcm.h | 2 +- kernel/Makefile | 2 +- kernel/pm_qos_params.c | 481 -------------------------------- kernel/power/Makefile | 2 +- kernel/power/qos.c | 481 ++++++++++++++++++++++++++++++++ net/mac80211/main.c | 2 +- net/mac80211/mlme.c | 2 +- net/mac80211/scan.c | 2 +- sound/core/pcm_native.c | 2 +- 22 files changed, 560 insertions(+), 537 deletions(-) create mode 100644 include/linux/pm_qos.h delete mode 100644 include/linux/pm_qos_params.h delete mode 100644 kernel/pm_qos_params.c create mode 100644 kernel/power/qos.c
arch/arm/mach-msm/clock.c +1 -1
@@ -18,7 +18,7 @@#include <linux/list.h> #include <linux/err.h> #include <linux/spinlock.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/mutex.h> #include <linux/clk.h> #include <linux/string.h>
drivers/acpi/processor_idle.c +1 -1
@@ -37,7 +37,7 @@#include <linux/dmi.h> #include <linux/moduleparam.h> #include <linux/sched.h> /* need_resched() */ -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/clockchips.h> #include <linux/cpuidle.h> #include <linux/irqflags.h>
drivers/cpuidle/cpuidle.c +1 -1
@@ -12,7 +12,7 @@#include <linux/mutex.h> #include <linux/sched.h> #include <linux/notifier.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/cpu.h> #include <linux/cpuidle.h> #include <linux/ktime.h>
drivers/cpuidle/governors/ladder.c +1 -1
@@ -14,7 +14,7 @@#include <linux/kernel.h> #include <linux/cpuidle.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/moduleparam.h> #include <linux/jiffies.h>
drivers/cpuidle/governors/menu.c +1 -1
@@ -12,7 +12,7 @@#include <linux/kernel.h> #include <linux/cpuidle.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/time.h> #include <linux/ktime.h> #include <linux/hrtimer.h>
drivers/media/video/via-camera.c +1 -1
@@ -21,7 +21,7 @@#include <media/videobuf-dma-sg.h> #include <linux/delay.h> #include <linux/dma-mapping.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/via-core.h> #include <linux/via-gpio.h> #include <linux/via_i2c.h>
drivers/net/e1000e/netdev.c +1 -1
@@ -46,7 +46,7 @@#include <linux/if_vlan.h> #include <linux/cpu.h> #include <linux/smp.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/pm_runtime.h> #include <linux/aer.h> #include <linux/prefetch.h>
drivers/net/wireless/ipw2x00/ipw2100.c +1 -1
@@ -161,7 +161,7 @@ that only one external action is invoked at a time.#include <linux/firmware.h> #include <linux/acpi.h> #include <linux/ctype.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <net/lib80211.h>
drivers/staging/msm/lcdc.c +1 -1
@@ -32,7 +32,7 @@#include <linux/uaccess.h> #include <linux/clk.h> #include <linux/platform_device.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include "msm_fb.h"
drivers/staging/msm/tvenc.c +1 -1
@@ -32,7 +32,7 @@#include <linux/uaccess.h> #include <linux/clk.h> #include <linux/platform_device.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #define TVENC_C #include "tvenc.h"
include/linux/netdevice.h +1 -1
@@ -31,7 +31,7 @@#include <linux/if_link.h> #ifdef __KERNEL__ -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/timer.h> #include <linux/delay.h> #include <linux/mm.h>
include/linux/pm_qos.h new file +61 -0
61 lines not on this page · raw message
include/linux/pm_qos_params.h deleted +0 -38
@@ -1,38 +0,0 @@ -#ifndef _LINUX_PM_QOS_PARAMS_H -#define _LINUX_PM_QOS_PARAMS_H -/* interface for the pm_qos_power infrastructure of the linux kernel. -* -* Mark Gross <[email protected]> -*/ -#include <linux/plist.h> -#include <linux/notifier.h> -#include <linux/miscdevice.h> - -#define PM_QOS_RESERVED 0 -#define PM_QOS_CPU_DMA_LATENCY 1 -#define PM_QOS_NETWORK_LATENCY 2 -#define PM_QOS_NETWORK_THROUGHPUT 3 - -#define PM_QOS_NUM_CLASSES 4 -#define PM_QOS_DEFAULT_VALUE -1 - -#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) -#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) -#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 - -struct pm_qos_request_list { -struct plist_node list; -int pm_qos_class; -}; - -void pm_qos_add_request (struct pm_qos_request_list *l,int pm_qos_class,s32 value); -void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, -s32 new_value); -void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req); - -int pm_qos_request (int pm_qos_class); -int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier); -int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier); -int pm_qos_request_active (struct pm_qos_request_list *req); - -#endif
include/sound/pcm.h +1 -1
@@ -29,7 +29,7 @@#include <linux/poll.h> #include <linux/mm.h> #include <linux/bitops.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #define snd_pcm_substream_chip (substream) ((substream)->private_data)#define snd_pcm_chip (pcm) ((pcm)->private_data)
kernel/Makefile +1 -1
@@ -9,7 +9,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o \ rcupdate.o extable.o params.o posix-timers.o \ kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ - notifier.o ksysfs.o pm_qos_params.o sched_clock.o cred.o \ + notifier.o ksysfs.o sched_clock.o cred.o \ async.o range.o jump_label.o obj-y += groups.o
kernel/pm_qos_params.c deleted +0 -481
481 lines not on this page · raw message
kernel/power/Makefile +1 -1
@@ -1,7 +1,7 @@ ccflags-$(CONFIG_PM_DEBUG) := -DDEBUG -obj-$(CONFIG_PM) += main.o +obj-$(CONFIG_PM) += main.o qos.o obj-$(CONFIG_PM_SLEEP) += console.o obj-$(CONFIG_FREEZER) += process.o obj-$(CONFIG_SUSPEND) += suspend.o
kernel/power/qos.c new file +481 -0
481 lines not on this page · raw message
net/mac80211/main.c +1 -1
@@ -19,7 +19,7 @@#include <linux/if_arp.h> #include <linux/rtnetlink.h> #include <linux/bitmap.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/inetdevice.h> #include <net/net_namespace.h> #include <net/cfg80211.h>
net/mac80211/mlme.c +1 -1
@@ -17,7 +17,7 @@#include <linux/if_arp.h> #include <linux/etherdevice.h> #include <linux/rtnetlink.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/crc32.h> #include <linux/slab.h> #include <net/mac80211.h>
net/mac80211/scan.c +1 -1
@@ -14,7 +14,7 @@#include <linux/if_arp.h> #include <linux/rtnetlink.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <net/sch_generic.h> #include <linux/slab.h> #include <net/mac80211.h>
sound/core/pcm_native.c +1 -1
@@ -23,7 +23,7 @@#include <linux/file.h> #include <linux/slab.h> #include <linux/time.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/uio.h> #include <linux/dma-mapping.h> #include <sound/core.h>
Signature · 1 line
1.7.2.5
PATCH v4 2/15 PM QoS: minor clean-ups
In reply to [email protected]From: Jean Pihet <[email protected]>
- Misc fixes to improve code readability:
. rename struct pm_qos_request_list to struct pm_qos_request, . rename pm_qos_req parameter to req in internal code,
consistenly use req in the API parameters,
. update the in-kernel API callers to the new parameters names, . rename of fields names (requests, list, node, constraints)
--- drivers/media/video/via-camera.c | 2 +- drivers/net/wireless/ipw2x00/ipw2100.c | 2 +- include/linux/netdevice.h | 2 +- include/linux/pm_qos.h | 22 ++++---- include/sound/pcm.h | 2 +- kernel/power/qos.c | 90 ++++++++++++++++--------------- 6 files changed, 61 insertions(+), 59 deletions(-)
drivers/media/video/via-camera.c +1 -1
@@ -69,7 +69,7 @@ struct via_camera {struct mutex lock;enum viacam_opstate opstate;unsigned long flags; -struct pm_qos_request_list qos_request; +struct pm_qos_request qos_request;/* * GPIO info for power/reset management */
drivers/net/wireless/ipw2x00/ipw2100.c +1 -1
@@ -174,7 +174,7 @@ that only one external action is invoked at a time.#define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2100 Network Driver"#define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation" -static struct pm_qos_request_list ipw2100_pm_qos_req; +static struct pm_qos_request ipw2100_pm_qos_req;/* Debugging stuff */ #ifdef CONFIG_IPW2100_DEBUG
include/linux/netdevice.h +1 -1
@@ -999,7 +999,7 @@ struct net_device {*/ char name[IFNAMSIZ ]; -struct pm_qos_request_list pm_qos_req; +struct pm_qos_request pm_qos_req;/* device name hash chain */ struct hlist_node name_hlist;
include/linux/pm_qos.h +11 -11
@@ -20,30 +20,30 @@#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 -struct pm_qos_request_list { -struct plist_node list; +struct pm_qos_request { +struct plist_node node;int pm_qos_class; };#ifdef CONFIG_PM -void pm_qos_add_request (struct pm_qos_request_list *l, -int pm_qos_class,s32 value); -void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class, +s32 value); +void pm_qos_update_request (struct pm_qos_request *req,s32 new_value); -void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req); +void pm_qos_remove_request (struct pm_qos_request *req);int pm_qos_request (int pm_qos_class);int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier); -int pm_qos_request_active (struct pm_qos_request_list *req); +int pm_qos_request_active (struct pm_qos_request *req);#else -static inline void pm_qos_add_request (struct pm_qos_request_list *l, +static inline void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) {return ; } -static inline void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +static inline void pm_qos_update_request (struct pm_qos_request *req,s32 new_value) {return ; } -static inline void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req) +static inline void pm_qos_remove_request (struct pm_qos_request *req) {return ; }static inline int pm_qos_request (int pm_qos_class)
@@ -54,7 +54,7 @@ static inline int pm_qos_add_notifier(int pm_qos_class,static inline int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier) {return 0 ; } -static inline int pm_qos_request_active (struct pm_qos_request_list *req) +static inline int pm_qos_request_active (struct pm_qos_request *req) {return 0 ; }#endif
include/sound/pcm.h +1 -1
@@ -373,7 +373,7 @@ struct snd_pcm_substream {int number;char name[32 ];/* substream name */ int stream;/* stream (direction) */ -struct pm_qos_request_list latency_pm_qos_req;/* pm_qos request */ +struct pm_qos_request latency_pm_qos_req;/* pm_qos request */ size_t buffer_bytes_max;/* limit ring buffer size */ struct snd_dma_buffer dma_buffer;unsigned int dma_buf_id;
kernel/power/qos.c +46 -44
254 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v4 3/15 PM QoS: code re-organization
In reply to [email protected]From: Jean Pihet <[email protected]>
Move around the PM QoS misc devices management code for better readability.
--- kernel/power/qos.c | 45 +++++++++++++++++++++++---------------------- 1 files changed, 23 insertions(+), 22 deletions(-)
kernel/power/qos.c +23 -22
@@ -190,28 +190,6 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node, NULL); } -static int register_pm_qos_misc (struct pm_qos_object *qos) -{ - qos->pm_qos_power_miscdev.minor =MISC_DYNAMIC_MINOR ; - qos->pm_qos_power_miscdev.name = qos->name; - qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; - -return misc_register (&qos->pm_qos_power_miscdev); -} - -static int find_pm_qos_object_by_minor (int minor) -{ -int pm_qos_class; - -for (pm_qos_class =0 ; - pm_qos_class <PM_QOS_NUM_CLASSES ; pm_qos_class++) { -if (minor == - pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) -return pm_qos_class; - } -return -1 ; -} -/** * pm_qos_request - returns current system wide qos expectation * @pm_qos_class: identification of which qos value is requested
@@ -364,6 +342,29 @@ int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier) }EXPORT_SYMBOL_GPL (pm_qos_remove_notifier); +/* User space interface to PM QoS classes via misc devices */ +static int register_pm_qos_misc (struct pm_qos_object *qos) +{ + qos->pm_qos_power_miscdev.minor =MISC_DYNAMIC_MINOR ; + qos->pm_qos_power_miscdev.name = qos->name; + qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; + +return misc_register (&qos->pm_qos_power_miscdev); +} + +static int find_pm_qos_object_by_minor (int minor) +{ +int pm_qos_class; + +for (pm_qos_class =0 ; + pm_qos_class <PM_QOS_NUM_CLASSES ; pm_qos_class++) { +if (minor == + pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) +return pm_qos_class; + } +return -1 ; +} +static int pm_qos_power_open (struct inode *inode,struct file *filp) {long pm_qos_class;
Signature · 1 line
1.7.2.5
PATCH v4 4/15 PM QoS: re-organize data structs
In reply to [email protected]From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support, re-organize the data strctures:
- add a struct pm_qos_constraints which contains the constraints related data
- update struct pm_qos_object contents to the PM QoS internal object data. Add a pointer to struct pm_qos_constraints
- update the internal code to use the new data structs.
--- include/linux/pm_qos.h | 19 ++++++++++ kernel/power/qos.c | 90 ++++++++++++++++++++++------------------------- 2 files changed, 61 insertions(+), 48 deletions(-)
include/linux/pm_qos.h +19 -0
@@ -25,6 +25,25 @@ struct pm_qos_request {int pm_qos_class; }; +enum pm_qos_type { +PM_QOS_UNITIALIZED , +PM_QOS_MAX ,/* return the largest value */ +PM_QOS_MIN /* return the smallest value */ +}; + +/* +* Note: The lockless read path depends on the CPU accessing +* target_value atomically. Atomic access is only guaranteed on all CPU +* types linux supports for 32 bit quantites +*/ +struct pm_qos_constraints { +struct plist_head list; +s32 target_value;/* Do not change to 64 bit */ +s32 default_value; +enum pm_qos_type type; +struct blocking_notifier_head *notifiers; +}; +#ifdef CONFIG_PM void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value);
kernel/power/qos.c +42 -48
179 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v4 5/15 PM QoS: generalize and export the constraints management code
In reply to [email protected]From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support:
- rename update_target to pm_qos_update_target
- generalize and export pm_qos_update_target for usage by the upcoming per-device latency constraints framework:
. operate on struct pm_qos_constraints for constraints management, . introduce an 'action' parameter for constraints add/update/remove, . the return value indicates if the aggregated constraint value has
changed,
- update the internal code to operate on struct pm_qos_constraints
- add a NULL pointer check in the API functions
--- include/linux/pm_qos.h | 14 ++++++ kernel/power/qos.c | 123 ++++++++++++++++++++++++++---------------------- 2 files changed, 81 insertions(+), 56 deletions(-)
include/linux/pm_qos.h +14 -0
@@ -44,7 +44,16 @@ struct pm_qos_constraints {struct blocking_notifier_head *notifiers; }; +/* Action requested to pm_qos_update_target */ +enum pm_qos_req_action { +PM_QOS_ADD_REQ ,/* Add a new request */ +PM_QOS_UPDATE_REQ ,/* Update an existing request */ +PM_QOS_REMOVE_REQ /* Remove an existing request */ +}; +#ifdef CONFIG_PM +int pm_qos_update_target (struct pm_qos_constraints *c,struct plist_node *node, +enum pm_qos_req_action action,int value);void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value); void pm_qos_update_request(struct pm_qos_request *req,
@@ -56,6 +65,11 @@ int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_request_active (struct pm_qos_request *req);#else +static inline int pm_qos_update_target (struct pm_qos_constraints *c, +struct plist_node *node, +enum pm_qos_req_action action, +int value) + {return 0 ; }static inline void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) {return ; }
kernel/power/qos.c +67 -56
215 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v4 6/15 PM QoS: implement the per-device PM QoS constraints
In reply to [email protected]From: Jean Pihet <[email protected]>
Implement the per-device PM QoS constraints by creating a device PM QoS API, which calls the PM QoS constraints management core code.
The per-device latency constraints data strctures are stored in the device dev_pm_info struct.
The device PM code calls the init and destroy of the per-device constraints data struct in order to support the dynamic insertion and removal of the devices in the system.
To minimize the data usage by the per-device constraints, the data struct is only allocated at the first call to dev_pm_qos_add_request. The data is later free'd when the device is removed from the system.
--- drivers/base/power/Makefile | 4 +- drivers/base/power/main.c | 3 + drivers/base/power/qos.c | 262 +++++++++++++++++++++++++++++++++++++++++++ include/linux/pm.h | 9 ++ include/linux/pm_qos.h | 39 +++++++ 5 files changed, 315 insertions(+), 2 deletions(-) create mode 100644 drivers/base/power/qos.c
drivers/base/power/Makefile +2 -2
@@ -1,8 +1,8 @@ -obj-$(CONFIG_PM) += sysfs.o generic_ops.o +obj-$(CONFIG_PM) += sysfs.o generic_ops.o qos.o obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o obj-$(CONFIG_PM_RUNTIME) += runtime.o obj-$(CONFIG_PM_TRACE_RTC) += trace.o obj-$(CONFIG_PM_OPP) += opp.o obj-$(CONFIG_HAVE_CLK) += clock_ops.o -ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG +ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG
drivers/base/power/main.c +3 -0
@@ -22,6 +22,7 @@#include <linux/mutex.h> #include <linux/pm.h> #include <linux/pm_runtime.h> +#include <linux/pm_qos.h> #include <linux/resume-trace.h> #include <linux/interrupt.h> #include <linux/sched.h>
@@ -97,6 +98,7 @@ void device_pm_add(struct device *dev) dev_name(dev->parent));list_add_tail (&dev->power.entry, &dpm_list);mutex_unlock (&dpm_list_mtx); +dev_pm_qos_constraints_init (dev); }/**
@@ -107,6 +109,7 @@ void device_pm_remove(struct device *dev) {pr_debug ("PM: Removing info for %s:%s\n" , dev->bus ? dev->bus->name :"No Bus" ,dev_name (dev)); +dev_pm_qos_constraints_destroy (dev);complete_all (&dev->power.completion);mutex_lock (&dpm_list_mtx);list_del_init (&dev->power.entry);
drivers/base/power/qos.c new file +262 -0
262 lines not on this page · raw message
include/linux/pm.h +9 -0
@@ -421,6 +421,13 @@ enum rpm_request {struct wakeup_source ; +/* Per-device PM QoS constraints data struct state */ +enum dev_pm_qos_state { +DEV_PM_QOS_NO_DEVICE ,/* No device present */ +DEV_PM_QOS_DEVICE_PRESENT ,/* Device present, data not allocated */ +DEV_PM_QOS_ALLOCATED ,/* Device present, data allocated */ +}; +struct dev_pm_info {pm_message_t power_state;unsigned int can_wakeup:1 ;
@@ -463,6 +470,8 @@ struct dev_pm_info {unsigned long accounting_timestamp;void *subsys_data;/* Owned by the subsystem. */ #endif +struct pm_qos_constraints *constraints; +enum dev_pm_qos_state constraints_state; };extern void update_pm_runtime_accounting (struct device *dev);
include/linux/pm_qos.h +39 -0
@@ -19,12 +19,18 @@#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 +#define PM_QOS_DEV_LAT_DEFAULT_VALUE 0struct pm_qos_request {struct plist_node node;int pm_qos_class; }; +struct dev_pm_qos_request { +struct plist_node node; +struct device *dev; +}; +enum pm_qos_type {PM_QOS_UNITIALIZED ,PM_QOS_MAX ,/* return the largest value */
@@ -64,6 +70,18 @@ int pm_qos_request(int pm_qos_class);int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_request_active (struct pm_qos_request *req); + +int dev_pm_qos_request_active (struct dev_pm_qos_request *req); +void dev_pm_qos_add_request (struct dev_pm_qos_request *req,struct device *dev, +s32 value); +void dev_pm_qos_update_request (struct dev_pm_qos_request *req,s32 new_value); +void dev_pm_qos_remove_request (struct dev_pm_qos_request *req); +int dev_pm_qos_add_notifier (struct device *dev, +struct notifier_block *notifier); +int dev_pm_qos_remove_notifier (struct device *dev, +struct notifier_block *notifier); +void dev_pm_qos_constraints_init (struct device *dev); +void dev_pm_qos_constraints_destroy (struct device *dev);#else static inline int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
@@ -89,6 +107,27 @@ static inline int pm_qos_remove_notifier(int pm_qos_class, {return 0 ; }static inline int pm_qos_request_active (struct pm_qos_request *req) {return 0 ; } + +static inline int dev_pm_qos_request_active (struct dev_pm_qos_request *req) + {return 0 ; } +static inline void dev_pm_qos_add_request (struct dev_pm_qos_request *req, +struct device *dev,s32 value) + {return ; } +static inline void dev_pm_qos_update_request (struct dev_pm_qos_request *req, +s32 new_value) + {return ; } +static inline void dev_pm_qos_remove_request (struct dev_pm_qos_request *req) + {return ; } +static inline int dev_pm_qos_add_notifier (struct device *dev, +struct notifier_block *notifier) + {return 0 ; } +static inline int dev_pm_qos_remove_notifier (struct device *dev, +struct notifier_block *notifier) + {return 0 ; } +static inline void dev_pm_qos_constraints_init (struct device *dev) + {return ; } +static inline void dev_pm_qos_constraints_destroy (struct device *dev) + {return ; }#endif #endif
Signature · 1 line
1.7.2.5
PATCH v4 7/15 PM QoS: add a global notification mechanism for the device constraints
In reply to [email protected]From: Jean Pihet <[email protected]>
Add a global notification chain that gets called upon changes to the aggregated constraint value for any device.
The notification callbacks are passing the full constraint request data in order for the callees to have access to it. The current use is for the platform low-level code to access the target device of the constraint.
--- drivers/base/power/qos.c | 114 ++++++++++++++++++++++++++++++++++++++++----- include/linux/pm_qos.h | 11 ++++ kernel/power/qos.c | 2 +- 3 files changed, 113 insertions(+), 14 deletions(-)
drivers/base/power/qos.c +101 -13
@@ -8,6 +8,12 @@* * This QoS design is best effort based. Dependents register their QoS needs. * Watchers register to keep track of the current QoS needs of the system. +* Watchers can register different types of notification callbacks: +* . a per-device notification callback using the dev_pm_qos_*_notifier API. +* The notification chain data is stored in the per-device constraint +* data struct. +* . a system-wide notification callback using the dev_pm_qos_*_global_notifier +* API. The notification chain data is stored in a static variable. * * Note about the per-device constraint data struct allocation: * . The per-device constraints data struct ptr is tored into the device
@@ -41,6 +47,7 @@#include <linux/kernel.h> +static BLOCKING_NOTIFIER_HEAD (dev_pm_notifiers);static void dev_pm_qos_constraints_allocate (struct device *dev);int dev_pm_qos_request_active (struct dev_pm_qos_request *req)
@@ -64,6 +71,8 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_request_active);void dev_pm_qos_add_request (struct dev_pm_qos_request *req,struct device *dev,s32 value) { +int ret, curr_value; +if (!req)/*guard against callers passing in null */ return ;
@@ -82,8 +91,19 @@ void dev_pm_qos_add_request(struct dev_pm_qos_request *req, struct device *dev,if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED )return ; -pm_qos_update_target (dev->power.constraints, - &req->node,PM_QOS_ADD_REQ , value); +/* +* Update constraints list and call the per-device callbacks if needed +*/ + ret =pm_qos_update_target (dev->power.constraints, + &req->node,PM_QOS_ADD_REQ , value); + +if (ret) { +/* Call the global callbacks if needed */ + curr_value =pm_qos_read_value (req->dev->power.constraints); +blocking_notifier_call_chain (&dev_pm_notifiers, + (unsigned long )curr_value, + req); + } }EXPORT_SYMBOL_GPL (dev_pm_qos_add_request);
@@ -98,8 +118,10 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_add_request);* Attempts are made to make this code callable on hot code paths. */ void dev_pm_qos_update_request (struct dev_pm_qos_request *req, -s32 new_value) +s32 new_value) { +int ret, curr_value; +if (!req)/*guard against callers passing in null */ return ;
@@ -113,10 +135,23 @@ void dev_pm_qos_update_request(struct dev_pm_qos_request *req,if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED )return ; -if (new_value != req->node.prio) -pm_qos_update_target ( - req->dev->power.constraints, - &req->node,PM_QOS_UPDATE_REQ , new_value); +if (new_value != req->node.prio) { +/* +* Update constraints list and call the per-device callbacks +* if needed +*/ + ret =pm_qos_update_target (req->dev->power.constraints, + &req->node,PM_QOS_UPDATE_REQ , + new_value); +if (ret) { +/* Call the global callbacks if needed */ + curr_value =pm_qos_read_value ( + req->dev->power.constraints); +blocking_notifier_call_chain (&dev_pm_notifiers, + (unsigned long )curr_value, + req); + } + } }EXPORT_SYMBOL_GPL (dev_pm_qos_update_request);
@@ -129,6 +164,8 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_update_request);*/ void dev_pm_qos_remove_request (struct dev_pm_qos_request *req) { +int ret, curr_value; +if (!req)/*guard against callers passing in null */ return ;
@@ -142,9 +179,20 @@ void dev_pm_qos_remove_request(struct dev_pm_qos_request *req)if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED )return ; -pm_qos_update_target (req->dev->power.constraints, - &req->node,PM_QOS_REMOVE_REQ , -PM_QOS_DEFAULT_VALUE ); +/* +* Update constraints list and call the per-device callbacks if needed +*/ + ret =pm_qos_update_target (req->dev->power.constraints, + &req->node,PM_QOS_REMOVE_REQ , +PM_QOS_DEFAULT_VALUE ); + +if (ret) { +/* Call the global callbacks if needed */ + curr_value =pm_qos_read_value (req->dev->power.constraints); +blocking_notifier_call_chain (&dev_pm_notifiers, + (unsigned long )curr_value, + req); + }memset (req,0 ,sizeof (*req)); }EXPORT_SYMBOL_GPL (dev_pm_qos_remove_request);
@@ -202,6 +250,36 @@ int dev_pm_qos_remove_notifier(struct device *dev, }EXPORT_SYMBOL_GPL (dev_pm_qos_remove_notifier); +/** +* dev_pm_qos_add_global_notifier - sets notification entry for changes to +* target value of the PM QoS constraints for any device +* +* @notifier: notifier block managed by caller. +* +* Will register the notifier into a notification chain that gets called +* upon changes to the target value for any device. +*/ +int dev_pm_qos_add_global_notifier (struct notifier_block *notifier) +{ +return blocking_notifier_chain_register (&dev_pm_notifiers, notifier); +} +EXPORT_SYMBOL_GPL (dev_pm_qos_add_global_notifier); + +/** +* dev_pm_qos_remove_global_notifier - deletes notification for changes to +* target value of PM QoS constraints for any device +* +* @notifier: notifier block to be removed. +* +* Will remove the notifier from the notification chain that gets called +* upon changes to the target value for any device. +*/ +int dev_pm_qos_remove_global_notifier (struct notifier_block *notifier) +{ +return blocking_notifier_chain_unregister (&dev_pm_notifiers, notifier); +} +EXPORT_SYMBOL_GPL (dev_pm_qos_remove_global_notifier); +/* Called at the first call to add_request, for constraint data allocation */ static void dev_pm_qos_constraints_allocate (struct device *dev) {
@@ -239,6 +317,7 @@ void dev_pm_qos_constraints_destroy(struct device *dev) {struct dev_pm_qos_request *req, *tmp;enum dev_pm_qos_state constraints_state = dev->power.constraints_state; +int ret =0 , curr_value; dev->power.constraints_state =DEV_PM_QOS_NO_DEVICE ;if (constraints_state ==DEV_PM_QOS_ALLOCATED ) {
@@ -250,9 +329,18 @@ void dev_pm_qos_constraints_destroy(struct device *dev)* Update constraints list and call the per-device * callbacks if needed */ -pm_qos_update_target (req->dev->power.constraints, - &req->node,PM_QOS_REMOVE_REQ , -PM_QOS_DEFAULT_VALUE ); + ret |=pm_qos_update_target (req->dev->power.constraints, + &req->node, +PM_QOS_REMOVE_REQ , +PM_QOS_DEFAULT_VALUE ); + +if (ret) { +/* Call the global callbacks if needed */ + curr_value = dev->power.constraints->default_value; +blocking_notifier_call_chain (&dev_pm_notifiers, + (unsigned long )curr_value, + req); + }kfree (dev->power.constraints->notifiers);kfree (dev->power.constraints);
include/linux/pm_qos.h +11 -0
@@ -70,6 +70,7 @@ int pm_qos_request(int pm_qos_class);int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_request_active (struct pm_qos_request *req); +s32 pm_qos_read_value (struct pm_qos_constraints *c);int dev_pm_qos_request_active (struct dev_pm_qos_request *req); void dev_pm_qos_add_request(struct dev_pm_qos_request *req, struct device *dev,
@@ -80,6 +81,8 @@ int dev_pm_qos_add_notifier(struct device *dev, struct notifier_block *notifier);int dev_pm_qos_remove_notifier (struct device *dev,struct notifier_block *notifier); +int dev_pm_qos_add_global_notifier (struct notifier_block *notifier); +int dev_pm_qos_remove_global_notifier (struct notifier_block *notifier);void dev_pm_qos_constraints_init (struct device *dev);void dev_pm_qos_constraints_destroy (struct device *dev);#else
@@ -107,6 +110,8 @@ static inline int pm_qos_remove_notifier(int pm_qos_class, {return 0 ; }static inline int pm_qos_request_active (struct pm_qos_request *req) {return 0 ; } +static inline s32 pm_qos_read_value (struct pm_qos_constraints *c) + {return 0 ; }static inline int dev_pm_qos_request_active (struct dev_pm_qos_request *req) {return 0 ; }
@@ -124,6 +129,12 @@ static inline int dev_pm_qos_add_notifier(struct device *dev,static inline int dev_pm_qos_remove_notifier (struct device *dev,struct notifier_block *notifier) {return 0 ; } +static inline int dev_pm_qos_add_global_notifier ( +struct notifier_block *notifier) + {return 0 ; } +static inline int dev_pm_qos_remove_global_notifier ( +struct notifier_block *notifier) + {return 0 ; }static inline void dev_pm_qos_constraints_init (struct device *dev) {return ; }static inline void dev_pm_qos_constraints_destroy (struct device *dev)
kernel/power/qos.c +1 -1
@@ -139,7 +139,7 @@ static inline int pm_qos_get_value(struct pm_qos_constraints *c) } } -static inline s32 pm_qos_read_value (struct pm_qos_constraints *c) +s32 pm_qos_read_value (struct pm_qos_constraints *c) {return c->target_value; }
Signature · 1 line
1.7.2.5
PATCH v4 8/15 OMAP: convert I2C driver to PM QoS for latency constraints
In reply to [email protected]From: Jean Pihet <[email protected]>
Convert the driver from the outdated omap_pm_set_max_mpu_wakeup_lat API to the new PM QoS API.
Since the constraint is on the MPU subsystem, use the PM_QOS_CPU_DMA_LATENCY class of PM QoS. The resulting MPU constraints are used by cpuidle to decide the next power state of the MPU subsystem.
Currently only OMAP3 is placing constraints on the MPU.
--- arch/arm/plat-omap/i2c.c | 20 -------------------- drivers/i2c/busses/i2c-omap.c | 31 ++++++++++++++++++------------- 2 files changed, 18 insertions(+), 33 deletions(-)
arch/arm/plat-omap/i2c.c +0 -20
@@ -34,7 +34,6 @@#include <mach/irqs.h> #include <plat/mux.h> #include <plat/i2c.h> -#include <plat/omap-pm.h> #include <plat/omap_device.h> #define OMAP_I2C_SIZE 0x3f
@@ -129,16 +128,6 @@ static inline int omap1_i2c_add_bus(int bus_id) #ifdef CONFIG_ARCH_OMAP2PLUS -/* - * XXX This function is a temporary compatibility wrapper - only - * needed until the I2C driver can be converted to call - * omap_pm_set_max_dev_wakeup_lat() and handle a return code. - */ -static void omap_pm_set_max_mpu_wakeup_lat_compat(struct device *dev, long t) -{ - omap_pm_set_max_mpu_wakeup_lat(dev, t); -} - static struct omap_device_pm_latency omap_i2c_latency[] = { [0] = { .deactivate_func = omap_device_idle_hwmods,
@@ -178,15 +167,6 @@ static inline int omap2_i2c_add_bus(int bus_id) dev_attr = (struct omap_i2c_dev_attr *)oh->dev_attr; pdata->flags = dev_attr->flags; -/* -* When waiting for completion of a i2c transfer, we need to -* set a wake up latency constraint for the MPU. This is to -* ensure quick enough wakeup from idle, when transfer -* completes. -* Only omap3 has support for constraints -*/ -if (cpu_is_omap34xx ()) - pdata->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat; od =omap_device_build (name, bus_id, oh, pdata,sizeof (struct omap_i2c_bus_platform_data ), omap_i2c_latency,ARRAY_SIZE (omap_i2c_latency),0 );
drivers/i2c/busses/i2c-omap.c +18 -13
@@ -40,6 +40,7 @@#include <linux/slab.h> #include <linux/i2c-omap.h> #include <linux/pm_runtime.h> +#include <linux/pm_qos.h> /* I2C controller revisions */ #define OMAP_I2C_OMAP1_REV_2 0x20
@@ -180,8 +181,7 @@ struct omap_i2c_dev {struct completion cmd_complete;struct resource *ioarea;u32 latency;/* maximum mpu wkup latency */ -void (*set_mpu_wkup_lat)(struct device *dev, -long latency); +struct pm_qos_request pm_qos_request;u32 speed;/* Speed of bus in Khz */ u16 cmd_err;u8 *buf;
@@ -657,8 +657,16 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)if (r <0 ) goto out; -if (dev->set_mpu_wkup_lat !=NULL ) - dev->set_mpu_wkup_lat (dev->dev, dev->latency); +/* +* When waiting for completion of a i2c transfer, we need to +* set a wake up latency constraint for the MPU. This is to +* ensure quick enough wakeup from idle, when transfer +* completes. +* Used on OMAP3 Only +*/ +if (cpu_is_omap34xx ()) +pm_qos_add_request (&dev->pm_qos_request,PM_QOS_CPU_DMA_LATENCY , + dev->latency);for (i =0 ; i < num; i++) { r =omap_i2c_xfer_msg (adap, &msgs[i], (i == (num -1 )));
@@ -666,8 +674,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)break ; } -if (dev->set_mpu_wkup_lat !=NULL ) - dev->set_mpu_wkup_lat (dev->dev,-1 ); +if (cpu_is_omap34xx ()) +pm_qos_remove_request (&dev->pm_qos_request);if (r ==0 ) r = num;
@@ -1021,13 +1029,10 @@ omap_i2c_probe(struct platform_device *pdev) goto err_release_region; } -if (pdata !=NULL ) { +if (pdata !=NULL ) speed = pdata->clkrate; - dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat; - }else { +else speed =100 ;/* Default speed */ - dev->set_mpu_wkup_lat =NULL ; - } dev->speed = speed; dev->idle =1 ;
@@ -1075,8 +1080,8 @@ omap_i2c_probe(struct platform_device *pdev) dev->fifo_size = (dev->fifo_size /2 ); dev->b_hw =1 ;/* Enable hardware fixes */ } -/* calculate wakeup latency constraint for MPU */ -if (dev->set_mpu_wkup_lat !=NULL ) +/* calculate wakeup latency constraint */ +if (cpu_is_omap34xx ()) dev->latency = (1000000 * dev->fifo_size) / (1000 * speed /8 ); }
Signature · 1 line
1.7.2.5
PATCH v4 9/15 OMAP: PM: create a PM layer plugin for per-device constraints
In reply to [email protected]From: Jean Pihet <[email protected]>
Created arch/arm/plat-omap/omap-pm-constraints.c file from arch/arm/plat-omap/omap-pm-noop.c and the associated Kconfig option OMAP_PM_CONSTRAINTS.
--- arch/arm/plat-omap/Kconfig | 7 + arch/arm/plat-omap/Makefile | 1 + arch/arm/plat-omap/omap-pm-constraints.c | 363 ++++++++++++++++++++++++++++++ 3 files changed, 371 insertions(+), 0 deletions(-) create mode 100644 arch/arm/plat-omap/omap-pm-constraints.c
arch/arm/plat-omap/Kconfig +7 -0
@@ -214,6 +214,13 @@ choice config OMAP_PM_NOOP bool "No-op/debug PM layer" +config OMAP_PM_CONSTRAINTS + depends on PM + bool "Per device constraints" + help + Select this option to enable the PM layer plugin for + the per-device constraints support + endchoice endmenu
arch/arm/plat-omap/Makefile +1 -0
@@ -32,3 +32,4 @@ obj-y += $(i2c-omap-m) $(i2c-omap-y) obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox.o obj-$(CONFIG_OMAP_PM_NOOP) += omap-pm-noop.o +obj-$(CONFIG_OMAP_PM_CONSTRAINTS) += omap-pm-constraints.o
arch/arm/plat-omap/omap-pm-constraints.c new file +363 -0
363 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v4 10/15 OMAP2+: powerdomain: control power domains next state
In reply to [email protected]From: Jean Pihet <[email protected]>
When a PM QoS device latency constraint is requested or removed the PM QoS layer notifies the underlying layer with the updated aggregated constraint value. The constraint is stored in the powerdomain constraints list and then applied to the corresponding power domain.
The power domains get the next power state programmed directly in the registers via pwrdm_wakeuplat_update_pwrst.
Tested on OMAP3 Beagleboard and OMAP4 Pandaboard in RET/OFF using wake-up latency constraints on MPU, CORE and PER.
--- arch/arm/mach-omap2/powerdomain.c | 191 +++++++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/powerdomain.h | 33 ++++++- 2 files changed, 222 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/powerdomain.c +191 -0
@@ -17,8 +17,10 @@#include <linux/kernel.h> #include <linux/types.h> #include <linux/list.h> +#include <linux/slab.h> #include <linux/errno.h> #include <linux/string.h> +#include <linux/pm_qos.h> #include <trace/events/power.h> #include "cm2xxx_3xxx.h"
@@ -104,6 +106,12 @@ static int _pwrdm_register(struct powerdomain *pwrdm)for (i =0 ; i < pwrdm->banks; i++) pwrdm->ret_mem_off_counter[i] =0 ; +/* Initialize the per-od wake-up constraints list and spinlock */ +spin_lock_init (&pwrdm->wkup_lat_plist_lock); +plist_head_init (&pwrdm->wkup_lat_plist_head, + &pwrdm->wkup_lat_plist_lock); + +/* Initialize the pwrdm state */ pwrdm_wait_transition (pwrdm); pwrdm->state =pwrdm_read_pwrst (pwrdm); pwrdm->state_counter[pwrdm->state] =1 ;
@@ -191,6 +199,77 @@ static int _pwrdm_post_transition_cb(struct powerdomain *pwrdm, void *unused)return 0 ; } +/** +* pwrdm_wakeuplat_update_pwrst - Update power domain power state if needed +* @pwrdm: struct powerdomain * to which requesting device belongs to. +* @min_latency: the allowed wake-up latency for the given power domain. A +* value of PM_QOS_DEV_LAT_DEFAULT_VALUE means 'no constraint' on the pwrdm. +* +* Finds the power domain next power state that fulfills the constraint. +* Programs a new target state if it is different from current power state. +* The power domains get the next power state programmed directly in the +* registers. +* +* Returns 0 upon success. +*/ +static int pwrdm_wakeuplat_update_pwrst (struct powerdomain *pwrdm, +long min_latency) +{ +int ret =0 , new_state =0 ; + +if (!pwrdm) { +WARN (1 ,"powerdomain: %s: invalid parameter(s)" , __func__); +return -EINVAL ; + } + +/* +* Apply constraints to power domains by programming +* the pwrdm next power state. +*/ + +/* Find power state with wakeup latency < minimum constraint */ +for (new_state =0x0 ; new_state <PWRDM_MAX_PWRSTS ; new_state++) { +if (min_latency ==PM_QOS_DEV_LAT_DEFAULT_VALUE || + pwrdm->wakeup_lat[new_state] <= min_latency) +break ; + } + +switch (new_state) { +case PWRDM_FUNC_PWRST_OFF : + new_state =PWRDM_POWER_OFF ; +break ; +case PWRDM_FUNC_PWRST_OSWR : +pwrdm_set_logic_retst (pwrdm,PWRDM_POWER_OFF ); + new_state =PWRDM_POWER_RET ; +break ; +case PWRDM_FUNC_PWRST_CSWR : +pwrdm_set_logic_retst (pwrdm,PWRDM_POWER_RET ); + new_state =PWRDM_POWER_RET ; +break ; +case PWRDM_FUNC_PWRST_INACTIVE : + new_state =PWRDM_POWER_INACTIVE ; +break ; +case PWRDM_FUNC_PWRST_ON : + new_state =PWRDM_POWER_ON ; +break ; +default : +pr_warn ("powerdomain: requested latency constraint not " +"supported %s set to ON state\n" , pwrdm->name); + new_state =PWRDM_POWER_ON ; +break ; + } + +if (pwrdm_read_next_pwrst (pwrdm) != new_state) + ret =omap_set_pwrdm_state (pwrdm, new_state); + +pr_debug ("powerdomain: %s pwrst: curr=%d, prev=%d next=%d " +"min_latency=%ld, set_state=%d\n" , pwrdm->name, +pwrdm_read_pwrst (pwrdm),pwrdm_read_prev_pwrst (pwrdm), +pwrdm_read_next_pwrst (pwrdm), min_latency, new_state); + +return ret; +} +/* Public functions */ /**
@@ -930,6 +1009,118 @@ int pwrdm_post_transition(void)return 0 ; } +/* +* pwrdm_set_wkup_lat_constraint - Set/update/remove a powerdomain wakeup +* latency constraint and apply it +* @pwrdm: struct powerdomain * which the constraint applies to +* @cookie: constraint identifier, used for tracking. +* @min_latency: minimum wakeup latency constraint (in microseconds) for +* the given pwrdm. The value of PM_QOS_DEV_LAT_DEFAULT_VALUE removes +* the constraint. +* +* Tracks the constraints by @cookie. +* Constraint set/update: Adds a new entry to powerdomain's wake-up latency +* constraint list. +* If the constraint identifier already exists in the list, the old value is +* overwritten. +* Constraint removal: Removes the identifier's entry from powerdomain's +* wakeup latency constraint list. +* +* Applies the strongest constraint value for the given pwrdm by calling +* pwrdm_wakeuplat_update_pwrst. +* +* Returns 0 upon success or a negative value in case of error. +* +* The caller must check the validity of the parameters. +*/ +int pwrdm_set_wkup_lat_constraint (struct powerdomain *pwrdm,void *cookie, +long min_latency) +{ +struct pwrdm_wkup_constraints_entry *user =NULL ; +struct pwrdm_wkup_constraints_entry *tmp_user, *new_user =NULL ; +int ret =0 , free_new_user =0 , free_node =0 ; +long value =PM_QOS_DEV_LAT_DEFAULT_VALUE ; +unsigned long flags; + +pr_debug ("powerdomain: %s: pwrdm %s, cookie=0x%p, min_latency=%ld\n" , + __func__, pwrdm->name, cookie, min_latency); + +if (min_latency !=PM_QOS_DEV_LAT_DEFAULT_VALUE ) { + new_user =kzalloc (sizeof (struct pwrdm_wkup_constraints_entry ), +GFP_KERNEL ); +if (!new_user) { +pr_err ("%s: FATAL ERROR: kzalloc failed\n" , __func__); +return -ENOMEM ; + } + free_new_user =1 ; + } + +spin_lock_irqsave (&pwrdm->wkup_lat_plist_lock, flags); + +/* Check if there already is a constraint for cookie */ +plist_for_each_entry (tmp_user, &pwrdm->wkup_lat_plist_head, node) { +if (tmp_user->cookie == cookie) { + user = tmp_user; +break ; + } + } + +if (min_latency !=PM_QOS_DEV_LAT_DEFAULT_VALUE ) { +/* If nothing to update, job done */ +if (user && (user->node.prio == min_latency)) + goto exit_ok; + +if (!user) { +/* Add new entry to the list */ + user = new_user; + user->cookie = cookie; + free_new_user =0 ; + }else { +/* Update existing entry */ +plist_del (&user->node, &pwrdm->wkup_lat_plist_head); + } + +plist_node_init (&user->node, min_latency); +plist_add (&user->node, &pwrdm->wkup_lat_plist_head); + }else { +if (user) { +/* Remove the constraint from the list */ +plist_del (&user->node, &pwrdm->wkup_lat_plist_head); + free_node =1 ; + }else { +/* Constraint not existing or list empty, do nothing */ + ret = -EINVAL ; + goto exit_error; + } + + } + +exit_ok: +/* Find the strongest constraint from the list */ +if (!plist_head_empty (&pwrdm->wkup_lat_plist_head)) + value =plist_first (&pwrdm->wkup_lat_plist_head)->prio; + +spin_unlock_irqrestore (&pwrdm->wkup_lat_plist_lock, flags); + +if (free_node) +kfree (user); + +if (free_new_user) +kfree (new_user); + +/* Apply the constraint to the pwrdm */ +pr_debug ("powerdomain: %s: pwrdm %s, value=%ld\n" , + __func__, pwrdm->name, value); +pwrdm_wakeuplat_update_pwrst (pwrdm, value); + +return 0 ; + +exit_error: +spin_unlock_irqrestore (&pwrdm->wkup_lat_plist_lock, flags); + +return ret; +} +/** * pwrdm_get_context_loss_count - get powerdomain's context loss count * @pwrdm: struct powerdomain * to wait for
arch/arm/mach-omap2/powerdomain.h +31 -2
@@ -19,7 +19,9 @@#include <linux/types.h> #include <linux/list.h> - +#include <linux/plist.h> +#include <linux/mutex.h> +#include <linux/spinlock.h> #include <linux/atomic.h> #include <plat/cpu.h>
@@ -43,6 +45,16 @@#define PWRSTS_RET_ON (PWRSTS_RET | PWRSTS_ON)#define PWRSTS_OFF_RET_ON (PWRSTS_OFF_RET | PWRSTS_ON) +/* Powerdomain functional power states */ +#define PWRDM_FUNC_PWRST_OFF 0x0 +#define PWRDM_FUNC_PWRST_OSWR 0x1 +#define PWRDM_FUNC_PWRST_CSWR 0x2 +#define PWRDM_FUNC_PWRST_INACTIVE 0x3 +#define PWRDM_FUNC_PWRST_ON 0x4 + +#define PWRDM_MAX_FUNC_PWRSTS 5 + +#define UNSUP_STATE -1/* Powerdomain flags */ #define PWRDM_HAS_HDWR_SAR (1 << 0)/* hardware save-and-restore support */
@@ -93,7 +105,12 @@ struct powerdomain;* @state_counter: * @timer: * @state_timer: -* +* @wakeup_lat: wakeup latencies (in us) for possible powerdomain power states +* Note about the wakeup latencies ordering: the values must be sorted +* in decremental order +* @wkup_lat_plist_head: pwrdm wake-up latency constraints list +* @wkup_lat_plist_lock: spinlock that protects the constraints lists +* domains states * @prcm_partition possible values are defined in mach-omap2/prcm44xx.h. */ struct powerdomain {
@@ -118,6 +135,15 @@ struct powerdomain {s64 timer;s64 state_timer[PWRDM_MAX_PWRSTS ];#endif +const u32 wakeup_lat[PWRDM_MAX_FUNC_PWRSTS ]; +struct plist_head wkup_lat_plist_head; +spinlock_t wkup_lat_plist_lock; +}; + +/* Linked list for the wake-up latency constraints */ +struct pwrdm_wkup_constraints_entry { +void *cookie; +struct plist_node node; };/**
@@ -207,6 +233,9 @@ int pwrdm_clkdm_state_switch(struct clockdomain *clkdm);int pwrdm_pre_transition (void );int pwrdm_post_transition (void );int pwrdm_set_lowpwrstchange (struct powerdomain *pwrdm); + +int pwrdm_set_wkup_lat_constraint (struct powerdomain *pwrdm,void *cookie, +long min_latency);u32 pwrdm_get_context_loss_count (struct powerdomain *pwrdm);bool pwrdm_can_ever_lose_context (struct powerdomain *pwrdm);
Signature · 1 line
1.7.2.5
PATCH v4 11/15 OMAP3: powerdomain data: add wake-up latency figures
In reply to [email protected]From: Jean Pihet <[email protected]>
Figures are added to the power domains structs.
Note: the figures are preliminary figures. More accurate measurements are needed. Also the conditions of measurements shall be investigated and described.
Tested on OMAP3 Beagleboard in RET/OFF using wake-up latency constraints on MPU, CORE and PER.
--- arch/arm/mach-omap2/powerdomains3xxx_data.c | 77 +++++++++++++++++++++++++++ 1 files changed, 77 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/powerdomains3xxx_data.c +77 -0
@@ -31,6 +31,13 @@/* * Powerdomains +* +* The wakeup_lat values are derived from measurements on +* the actual target. +* +* Note: the latency figures are preliminary and only used +* for the constraints framework validation. +* Actual figures and measurements conditions shall be added. */ static struct powerdomain iva2_pwrdm = {
@@ -52,6 +59,13 @@ static struct powerdomain iva2_pwrdm = { [2] = PWRSTS_OFF_ON, [3] = PWRSTS_ON, }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1100, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 350, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };static struct powerdomain mpu_3xxx_pwrdm = {
@@ -68,6 +82,13 @@ static struct powerdomain mpu_3xxx_pwrdm = { .pwrsts_mem_on = { [0] = PWRSTS_OFF_ON, }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 95, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 45, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/*
@@ -98,6 +119,13 @@ static struct powerdomain core_3xxx_pre_es3_1_pwrdm = { [0] = PWRSTS_OFF_RET_ON, /* MEM1ONSTATE */ [1 ] =PWRSTS_OFF_RET_ON ,/* MEM2ONSTATE */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 100, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 60, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, }; static struct powerdomain core_3xxx_es3_1_pwrdm = {
@@ -121,6 +149,13 @@ static struct powerdomain core_3xxx_es3_1_pwrdm = { [0] = PWRSTS_OFF_RET_ON, /* MEM1ONSTATE */ [1 ] =PWRSTS_OFF_RET_ON ,/* MEM2ONSTATE */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 100, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 60, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, }; static struct powerdomain dss_pwrdm = {
@@ -136,6 +171,13 @@ static struct powerdomain dss_pwrdm = { .pwrsts_mem_on = { [0 ] =PWRSTS_ON ,/* MEMONSTATE */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 70, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 20, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/*
@@ -157,6 +199,13 @@ static struct powerdomain sgx_pwrdm = { .pwrsts_mem_on = { [0 ] =PWRSTS_ON ,/* MEMONSTATE */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, }; static struct powerdomain cam_pwrdm = {
@@ -172,6 +221,13 @@ static struct powerdomain cam_pwrdm = { .pwrsts_mem_on = { [0 ] =PWRSTS_ON ,/* MEMONSTATE */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 850, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 35, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, }; static struct powerdomain per_pwrdm = {
@@ -187,6 +243,13 @@ static struct powerdomain per_pwrdm = { .pwrsts_mem_on = { [0 ] =PWRSTS_ON ,/* MEMONSTATE */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 200, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 110, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, }; static struct powerdomain emu_pwrdm = {
@@ -201,6 +264,13 @@ static struct powerdomain neon_pwrdm = { .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430), .pwrsts = PWRSTS_OFF_RET_ON, .pwrsts_logic_ret = PWRSTS_RET, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 200, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 35, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };static struct powerdomain usbhost_pwrdm = {
@@ -223,6 +293,13 @@ static struct powerdomain usbhost_pwrdm = { .pwrsts_mem_on = { [0 ] =PWRSTS_ON ,/* MEMONSTATE */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 800, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 150, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, }; static struct powerdomain dpll1_pwrdm = {
Signature · 1 line
1.7.2.5
PATCH v4 12/15 OMAP4: powerdomain data: add wake-up latency figures
In reply to [email protected]From: Vishwanath BS <[email protected]>
This patch adds wake up latency numbers for OMAP4. Note that these are preliminary numbers and need to be relooked.
The INACTIVE state is added as unsupported.
Tested on OMAP4 Pandaboard in RET/OFF using wake-up latency constraints on MPU, CORE and PER.
--- arch/arm/mach-omap2/powerdomains44xx_data.c | 84 +++++++++++++++++++++++++++ 1 files changed, 84 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/powerdomains44xx_data.c +84 -0
@@ -54,6 +54,13 @@ static struct powerdomain core_44xx_pwrdm = { [4] = PWRSTS_ON, /* ducati_unicache */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* gfx_44xx_pwrdm: 3D accelerator power domain */
@@ -71,6 +78,13 @@ static struct powerdomain gfx_44xx_pwrdm = { [0] = PWRSTS_ON, /* gfx_mem */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* abe_44xx_pwrdm: Audio back end power domain */
@@ -91,6 +105,13 @@ static struct powerdomain abe_44xx_pwrdm = { [1] = PWRSTS_ON, /* periphmem */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* dss_44xx_pwrdm: Display subsystem power domain */
@@ -109,6 +130,13 @@ static struct powerdomain dss_44xx_pwrdm = { [0] = PWRSTS_ON, /* dss_mem */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* tesla_44xx_pwrdm: Tesla processor power domain */
@@ -131,6 +159,13 @@ static struct powerdomain tesla_44xx_pwrdm = { [2] = PWRSTS_ON, /* tesla_l2 */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* wkup_44xx_pwrdm: Wake-up power domain */
@@ -164,6 +199,13 @@ static struct powerdomain cpu0_44xx_pwrdm = { .pwrsts_mem_on = { [0 ] =PWRSTS_ON ,/* cpu0_l1 */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* cpu1_44xx_pwrdm: MPU1 processor and Neon coprocessor power domain */
@@ -181,6 +223,13 @@ static struct powerdomain cpu1_44xx_pwrdm = { .pwrsts_mem_on = { [0 ] =PWRSTS_ON ,/* cpu1_l1 */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* emu_44xx_pwrdm: Emulation power domain */
@@ -218,6 +267,13 @@ static struct powerdomain mpu_44xx_pwrdm = { [1] = PWRSTS_ON, /* mpu_l2 */ [2] = PWRSTS_ON, /* mpu_ram */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* ivahd_44xx_pwrdm: IVA-HD power domain */
@@ -242,6 +298,13 @@ static struct powerdomain ivahd_44xx_pwrdm = { [3] = PWRSTS_ON, /* tcm2_mem */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* cam_44xx_pwrdm: Camera subsystem power domain */
@@ -259,6 +322,13 @@ static struct powerdomain cam_44xx_pwrdm = { [0] = PWRSTS_ON, /* cam_mem */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* l3init_44xx_pwrdm: L3 initators pheripherals power domain */
@@ -277,6 +347,13 @@ static struct powerdomain l3init_44xx_pwrdm = { [0] = PWRSTS_ON, /* l3init_bank1 */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* l4per_44xx_pwrdm: Target peripherals power domain */
@@ -297,6 +374,13 @@ static struct powerdomain l4per_44xx_pwrdm = { [1] = PWRSTS_ON, /* retained_bank */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/*
Signature · 1 line
1.7.2.5
PATCH v4 13/15 OMAP2+: omap_hwmod: manage the wake-up latency constraints
In reply to [email protected]From: Jean Pihet <[email protected]>
Hwmod is queried from the OMAP_PM layer to manage the power domains wake-up latency constraints. Hwmod retrieves the correct power domain and if it exists it calls the corresponding power domain function.
Tested on OMAP3 Beagleboard and OMAP4 Pandaboard in RET/OFF using wake-up latency constraints on MPU, CORE and PER.
--- arch/arm/mach-omap2/omap_hwmod.c | 26 +++++++++++++++++++++++++- arch/arm/plat-omap/include/plat/omap_hwmod.h | 2 ++ 2 files changed, 27 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/omap_hwmod.c +25 -1
@@ -143,6 +143,7 @@#include "powerdomain.h" #include <plat/clock.h> #include <plat/omap_hwmod.h> +#include <plat/omap_device.h> #include <plat/prcm.h> #include "cm2xxx_3xxx.h"
@@ -2618,11 +2619,34 @@ ohsps_unlock:return ret; } +/* +* omap_hwmod_set_wkup_constraint- set/release a wake-up latency constraint +* +* @oh: struct omap_hwmod* to which the target device belongs to. +* @cookie: identifier of the constraints list for @oh. +* @min_latency: the minimum allowed wake-up latency for @oh. +* +* Returns 0 upon success. +*/ +int omap_hwmod_set_wkup_lat_constraint (struct omap_hwmod *oh, +void *cookie,long min_latency) +{ +struct powerdomain *pwrdm =omap_hwmod_get_pwrdm (oh); + +if (!pwrdm) { +pr_err ("%s: Error: could not find powerdomain " +"for %s\n" , __func__, oh->name); +return -EINVAL ; + } + +return pwrdm_set_wkup_lat_constraint (pwrdm, cookie, min_latency); +} +/** * omap_hwmod_get_context_loss_count - get lost context count * @oh: struct omap_hwmod * * -* Query the powerdomain of of @oh to get the context loss +* Query the powerdomain of @oh to get the context loss * count for this device. * * Returns the context loss count of the powerdomain assocated with @oh
arch/arm/plat-omap/include/plat/omap_hwmod.h +2 -0
@@ -603,6 +603,8 @@ int omap_hwmod_for_each_by_class(const char *classname, void *user);int omap_hwmod_set_postsetup_state (struct omap_hwmod *oh,u8 state); +int omap_hwmod_set_wkup_lat_constraint (struct omap_hwmod *oh,void *cookie, +long min_latency);u32 omap_hwmod_get_context_loss_count (struct omap_hwmod *oh);int omap_hwmod_no_setup_reset (struct omap_hwmod *oh);
Signature · 1 line
1.7.2.5
PATCH v4 14/15 OMAP: PM CONSTRAINTS: implement the devices wake-up latency constraints
In reply to [email protected]From: Jean Pihet <[email protected]>
Implement the devices wake-up latency constraints using the global device PM QoS notification handler which applies the constraints to the underlying layer by calling the corresponding function at hwmod level.
Note: the bus throughput function is implemented but currently is a no-op. A new PM QoS class for the bus throughput needs to be added.
Tested on OMAP3 Beagleboard and OMAP4 Pandaboard in RET/OFF using wake-up latency constraints on MPU, CORE and PER.
--- arch/arm/plat-omap/include/plat/omap-pm.h | 128 --------------------- arch/arm/plat-omap/omap-pm-constraints.c | 173 +++++++++++++--------------- arch/arm/plat-omap/omap-pm-noop.c | 89 --------------- 3 files changed, 80 insertions(+), 310 deletions(-)
arch/arm/plat-omap/include/plat/omap-pm.h +0 -128
@@ -62,136 +62,8 @@ void omap_pm_if_exit(void);* Device-driver-originated constraints (via board-*.c files, platform_data) */ - -/** -* omap_pm_set_max_mpu_wakeup_lat - set the maximum MPU wakeup latency -* @dev: struct device * requesting the constraint -* @t: maximum MPU wakeup latency in microseconds -* -* Request that the maximum interrupt latency for the MPU to be no -* greater than @t microseconds. "Interrupt latency" in this case is -* defined as the elapsed time from the occurrence of a hardware or -* timer interrupt to the time when the device driver's interrupt -* service routine has been entered by the MPU. -* -* It is intended that underlying PM code will use this information to -* determine what power state to put the MPU powerdomain into, and -* possibly the CORE powerdomain as well, since interrupt handling -* code currently runs from SDRAM. Advanced PM or board*.c code may -* also configure interrupt controller priorities, OCP bus priorities, -* CPU speed(s), etc. -* -* This function will not affect device wakeup latency, e.g., time -* elapsed from when a device driver enables a hardware device with -* clk_enable(), to when the device is ready for register access or -* other use. To control this device wakeup latency, use -* omap_pm_set_max_dev_wakeup_lat() -* -* Multiple calls to omap_pm_set_max_mpu_wakeup_lat() will replace the -* previous t value. To remove the latency target for the MPU, call -* with t = -1. -* -* XXX This constraint will be deprecated soon in favor of the more -* general omap_pm_set_max_dev_wakeup_lat() -* -* Returns -EINVAL for an invalid argument, -ERANGE if the constraint -* is not satisfiable, or 0 upon success. -*/ -int omap_pm_set_max_mpu_wakeup_lat (struct device *dev,long t); - - -/** -* omap_pm_set_min_bus_tput - set minimum bus throughput needed by device -* @dev: struct device * requesting the constraint -* @tbus_id: interconnect to operate on (OCP_{INITIATOR,TARGET}_AGENT) -* @r: minimum throughput (in KiB/s) -* -* Request that the minimum data throughput on the OCP interconnect -* attached to device @dev interconnect agent @tbus_id be no less -* than @r KiB/s. -* -* It is expected that the OMAP PM or bus code will use this -* information to set the interconnect clock to run at the lowest -* possible speed that satisfies all current system users. The PM or -* bus code will adjust the estimate based on its model of the bus, so -* device driver authors should attempt to specify an accurate -* quantity for their device use case, and let the PM or bus code -* overestimate the numbers as necessary to handle request/response -* latency, other competing users on the system, etc. On OMAP2/3, if -* a driver requests a minimum L4 interconnect speed constraint, the -* code will also need to add an minimum L3 interconnect speed -* constraint, -* -* Multiple calls to omap_pm_set_min_bus_tput() will replace the -* previous rate value for this device. To remove the interconnect -* throughput restriction for this device, call with r = 0. -* -* Returns -EINVAL for an invalid argument, -ERANGE if the constraint -* is not satisfiable, or 0 upon success. -*/ int omap_pm_set_min_bus_tput (struct device *dev,u8 agent_id,unsigned long r); - -/** -* omap_pm_set_max_dev_wakeup_lat - set the maximum device enable latency -* @req_dev: struct device * requesting the constraint, or NULL if none -* @dev: struct device * to set the constraint one -* @t: maximum device wakeup latency in microseconds -* -* Request that the maximum amount of time necessary for a device @dev -* to become accessible after its clocks are enabled should be no -* greater than @t microseconds. Specifically, this represents the -* time from when a device driver enables device clocks with -* clk_enable(), to when the register reads and writes on the device -* will succeed. This function should be called before clk_disable() -* is called, since the power state transition decision may be made -* during clk_disable(). -* -* It is intended that underlying PM code will use this information to -* determine what power state to put the powerdomain enclosing this -* device into. -* -* Multiple calls to omap_pm_set_max_dev_wakeup_lat() will replace the -* previous wakeup latency values for this device. To remove the -* wakeup latency restriction for this device, call with t = -1. -* -* Returns -EINVAL for an invalid argument, -ERANGE if the constraint -* is not satisfiable, or 0 upon success. -*/ -int omap_pm_set_max_dev_wakeup_lat (struct device *req_dev,struct device *dev, -long t); - - -/** -* omap_pm_set_max_sdma_lat - set the maximum system DMA transfer start latency -* @dev: struct device * -* @t: maximum DMA transfer start latency in microseconds -* -* Request that the maximum system DMA transfer start latency for this -* device 'dev' should be no greater than 't' microseconds. "DMA -* transfer start latency" here is defined as the elapsed time from -* when a device (e.g., McBSP) requests that a system DMA transfer -* start or continue, to the time at which data starts to flow into -* that device from the system DMA controller. -* -* It is intended that underlying PM code will use this information to -* determine what power state to put the CORE powerdomain into. -* -* Since system DMA transfers may not involve the MPU, this function -* will not affect MPU wakeup latency. Use set_max_cpu_lat() to do -* so. Similarly, this function will not affect device wakeup latency -* -- use set_max_dev_wakeup_lat() to affect that. -* -* Multiple calls to set_max_sdma_lat() will replace the previous t -* value for this device. To remove the maximum DMA latency for this -* device, call with t = -1. -* -* Returns -EINVAL for an invalid argument, -ERANGE if the constraint -* is not satisfiable, or 0 upon success. -*/ -int omap_pm_set_max_sdma_lat (struct device *dev,long t); - -/** * omap_pm_set_min_clk_rate - set minimum clock rate requested by @dev * @dev: struct device * requesting the constraint
arch/arm/plat-omap/omap-pm-constraints.c +80 -93
222 lines not on this page · raw message
arch/arm/plat-omap/omap-pm-noop.c +0 -89
101 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v4 15/15 OMAP2+: cpuidle only influences the MPU state
In reply to [email protected]From: Jean Pihet <[email protected]>
Since cpuidle is a CPU centric framework it decides the MPU next power state based on the MPU exit_latency and target_residency figures.
The rest of the power domains get their next power state programmed from the devices PM QoS framework, via the devices wake-up latency constraints.
Note: the exit_latency and target_residency figures of the MPU include the MPU itself and the peripherals needed for the MPU to execute instructions (e.g. main memory, caches, IRQ controller, MMU etc). Some of those peripherals can belong to other power domains than the MPU subsystem and so the corresponding latencies must be included in this figure.
Tested on OMAP3 Beagleboard in RET/OFF using wake-up latency constraints on MPU, CORE and PER.
--- arch/arm/mach-omap2/cpuidle34xx.c | 42 +++++++++++------------------------- arch/arm/mach-omap2/pm.h | 17 +++++++++++++- 2 files changed, 28 insertions(+), 31 deletions(-)
arch/arm/mach-omap2/cpuidle34xx.c +13 -29
@@ -37,26 +37,26 @@#ifdef CONFIG_CPU_IDLE /* -* The latencies/thresholds for various C states have +* The MPU latencies/thresholds for various C states have * to be configured from the respective board files. * These are some default values (which might not provide * the best power savings) used on boards which do not * pass these details from the board file. */ static struct cpuidle_params cpuidle_params_table[] = { -/* C1 */ +/* C1 . MPU WFI + Core active */ {2 +2 ,5 ,1 }, -/* C2 */ +/* C2 . MPU WFI + Core inactive */ {10 +10 ,30 ,1 }, -/* C3 */ +/* C3 . MPU CSWR + Core inactive */ {50 +50 ,300 ,1 }, -/* C4 */ +/* C4 . MPU OFF + Core inactive */ {1500 +1800 ,4000 ,1 }, -/* C5 */ +/* C5 . MPU RET + Core RET */ {2500 +7500 ,12000 ,1 }, -/* C6 */ +/* C6 . MPU OFF + Core RET */ {3000 +8500 ,15000 ,1 }, -/* C7 */ +/* C7 . MPU OFF + Core OFF */ {10000 +30000 ,300000 ,1 }, };#define OMAP3_NUM_STATES ARRAY_SIZE(cpuidle_params_table)
@@ -64,7 +64,6 @@ static struct cpuidle_params cpuidle_params_table[] = {/* Mach specific information to be recorded in the C-state driver_data */ struct omap3_idle_statedata {u32 mpu_state; -u32 core_state;u8 valid; };struct omap3_idle_statedata omap3_idle_data[OMAP3_NUM_STATES ];
@@ -98,7 +97,7 @@ static int omap3_enter_idle(struct cpuidle_device *dev, {struct omap3_idle_statedata *cx =cpuidle_get_statedata (state);struct timespec ts_preidle, ts_postidle, ts_idle; -u32 mpu_state = cx->mpu_state, core_state = cx->core_state; +u32 mpu_state = cx->mpu_state;/* Used to keep track of the total time in idle */ getnstimeofday (&ts_preidle);
@@ -107,7 +106,6 @@ static int omap3_enter_idle(struct cpuidle_device *dev,local_fiq_disable ();pwrdm_set_next_pwrst (mpu_pd, mpu_state); -pwrdm_set_next_pwrst (core_pd, core_state);if (omap_irq_pending () ||need_resched ()) goto return_sleep_time;
@@ -156,6 +154,7 @@ static struct cpuidle_state *next_valid_state(struct cpuidle_device *dev,struct omap3_idle_statedata *cx =cpuidle_get_statedata (curr);u32 mpu_deepest_state =PWRDM_POWER_RET ;u32 core_deepest_state =PWRDM_POWER_RET ; +u32 core_next_state =pwrdm_read_next_pwrst (core_pd);if (enable_off_mode) { mpu_deepest_state =PWRDM_POWER_OFF ;
@@ -171,7 +170,7 @@ static struct cpuidle_state *next_valid_state(struct cpuidle_device *dev,/* Check if current state is valid */ if ((cx->valid) && (cx->mpu_state >= mpu_deepest_state) && - (cx->core_state >= core_deepest_state)) { + (core_next_state >= core_deepest_state)) {return curr; }else {int idx =OMAP3_NUM_STATES -1 ;
@@ -196,7 +195,7 @@ static struct cpuidle_state *next_valid_state(struct cpuidle_device *dev, cx =cpuidle_get_statedata (&dev->states[idx]);if ((cx->valid) && (cx->mpu_state >= mpu_deepest_state) && - (cx->core_state >= core_deepest_state)) { + (core_next_state >= core_deepest_state)) { next = &dev->states[idx];break ; }
@@ -242,19 +241,11 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev, }/* -* FIXME: we currently manage device-specific idle states -* for PER and CORE in combination with CPU-specific -* idle states. This is wrong, and device-specific -* idle management needs to be separated out into -* its own code. -*/ - -/* * Prevent PER off if CORE is not in retention or off as this * would disable PER wakeups completely. */ cx =cpuidle_get_statedata (state); - core_next_state = cx->core_state; + core_next_state =pwrdm_read_next_pwrst (core_pd); per_next_state = per_saved_state =pwrdm_read_next_pwrst (per_pd);if ((per_next_state ==PWRDM_POWER_OFF ) && (core_next_state >PWRDM_POWER_RET ))
@@ -346,32 +337,26 @@ int __init omap3_idle_init(void) dev->safe_state = &dev->states[0 ]; cx->valid =1 ;/* C1 is always valid */ cx->mpu_state =PWRDM_POWER_ON ; - cx->core_state =PWRDM_POWER_ON ;/* C2 . MPU WFI + Core inactive */ cx =_fill_cstate (dev,1 ,"MPU ON + CORE ON" ); cx->mpu_state =PWRDM_POWER_ON ; - cx->core_state =PWRDM_POWER_ON ;/* C3 . MPU CSWR + Core inactive */ cx =_fill_cstate (dev,2 ,"MPU RET + CORE ON" ); cx->mpu_state =PWRDM_POWER_RET ; - cx->core_state =PWRDM_POWER_ON ;/* C4 . MPU OFF + Core inactive */ cx =_fill_cstate (dev,3 ,"MPU OFF + CORE ON" ); cx->mpu_state =PWRDM_POWER_OFF ; - cx->core_state =PWRDM_POWER_ON ;/* C5 . MPU RET + Core RET */ cx =_fill_cstate (dev,4 ,"MPU RET + CORE RET" ); cx->mpu_state =PWRDM_POWER_RET ; - cx->core_state =PWRDM_POWER_RET ;/* C6 . MPU OFF + Core RET */ cx =_fill_cstate (dev,5 ,"MPU OFF + CORE RET" ); cx->mpu_state =PWRDM_POWER_OFF ; - cx->core_state =PWRDM_POWER_RET ;/* C7 . MPU OFF + Core OFF */ cx =_fill_cstate (dev,6 ,"MPU OFF + CORE OFF" );
@@ -386,7 +371,6 @@ int __init omap3_idle_init(void) __func__); } cx->mpu_state =PWRDM_POWER_OFF ; - cx->core_state =PWRDM_POWER_OFF ; dev->state_count =OMAP3_NUM_STATES ;if (cpuidle_register_device (dev)) {
arch/arm/mach-omap2/pm.h +15 -2
@@ -43,9 +43,22 @@ static inline int omap4_opp_init(void)* omap3_pm_init_cpuidle */ struct cpuidle_params { -u32 exit_latency;/* exit_latency = sleep + wake-up latencies */ +/* +* exit_latency = sleep + wake-up latencies of the MPU, +* which include the MPU itself and the peripherals needed +* for the MPU to execute instructions (e.g. main memory, +* caches, IRQ controller, MMU etc). Some of those peripherals +* can belong to other power domains than the MPU subsystem and so +* the corresponding latencies must be included in this figure. +*/ +u32 exit_latency; +/* +* target_residency: required amount of time in the C state +* to break even on energy cost +*/ u32 target_residency; -u8 valid;/* validates the C-state */ +/* validates the C-state on the given board */ +u8 valid; };#if defined(CONFIG_PM ) && defined(CONFIG_CPU_IDLE )
Signature · 1 line
1.7.2.5
v4 cover PM QoS: add a per-device latency constraints class
From: Jean Pihet <[email protected]>
This patch set is in an RFC state, for review and comments.
High level implementation:
1. Preparation of the PM QoS for the addition of a device PM QoS constraints framework:
. rename and move of the PM QoS implementation files to kernel/power/qos.c
and include/linux/pm_qos.h
. rename of API parameters and internal fields names
. Move around the PM QoS misc devices management code for better readability . re-organize the internal data structs
. generalize and export the constraints management core code
2. Implementation of the per-device PM QoS constraints:
. create drivers/base/power/qos.c for the implementation
. create a device PM QoS API, which calls the PM QoS constraints management
core code
. the per-device latency constraints data strctures are stored in the device
dev_pm_info struct
. the device PM code calls the init and destroy of the per-device constraints
data struct in order to support the dynamic insertion and removal of the devices in the system.
. to minimize the data usage by the per-device constraints, the data struct
is only allocated at the first call to dev_pm_qos_add_request. The data is later free'd when the device is removed from the system
. per-device notification callbacks can be registered and called upon a
change to the aggregated constraint value
3. add a global notification mechanism for the device constraints . add a global notification chain that gets called upon changes to the aggregated constraint value for any device.
. the notification callbacks are passing the full constraint request data
in order for the callees to have access to it. The current use is for the platform low-level code to access the target device of the constraint
4. Implement the OMAP low level constraints management code
. create a PM layer plugin for per-device constraints, compiled under
CONFIG_OMAP_PM_CONSTRAINTS=y
. implement the devices wake-up latency constraints using the global
device PM QoS notification handler which applies the constraints to the underlying layer
. implement the low level code which controls the power domains next power
states, through the hwmod and pwrdm layers
. add (preliminary) power domains wake-up latency figures for OMAP3&4 . cpuidle is a CPU centric framework so it decides the MPU next power state
based on the MPU exit_latency and target_residency figures. The rest of the power domains get their next power state programmed from the devices PM QoS framework, via the devices wake-up latency constraints.
. convert the OMAP I2C driver to the PM QoS API for MPU latency constraints
Questions:
1. the user space API is still under discussions on linux-omap and linux-pm MLs, cf. [1]. The idea is to add a user-space API for the devices constratins PM QoS, using a sysfs entry per device
[1] http://marc.info/?l=linux-omap&m=131232344503327&w=2
ToDo:
1. write Documentation for the new PM QoS class, once the RFC is agreed on
2. validate the constraints framework on OMAP4 HW (done on OMAP3)
3. Need testing on platforms other than OMAP
4. refine the power domains wake-up latency and the cpuidle figures
5. re-visit the OMAP power domains states initialization procedure. Currently the power states that have been changed from the constraints API which were applied before the initialization of the power domains are lost
Based on the master branch of the linux-omap git tree (3.0.0-rc7). Compile tested using OMAP and x86 generic defconfigs.
Lightly tested on OMAP3 Beagleboard (ES2.x).
Need testing on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/remove
Changelog:
v4:
. Complete devices PM QoS re-design:
. Separation from the existing PM QoS classes by adding a device PM QoS
API. The device code is re-using the PM QoS core code for constraints lists management and notification mechanism
. Addition of a devices PM QoS global notification mechanism, for interaction
with the low level platform code
v3:
. Complete PM QoS re-design after the comments on MLs
. Patch set split up for improved readability and easier maintenance
v2:
. Rework after comments on the mailing lists
. Added a notification of device insertion/removal from the device PM framework . Validated on OMAP3 HW
v1:
. Initial implementation
Jean Pihet (14):
PM QoS: move and rename the implementation files
PM QoS: minor clean-ups
PM QoS: code re-organization
PM QoS: re-organize data structs
PM QoS: generalize and export the constraints management code PM QoS: implement the per-device PM QoS constraints PM QoS: add a global notification mechanism for the device
constraints
OMAP: convert I2C driver to PM QoS for latency constraints
OMAP: PM: create a PM layer plugin for per-device constraints OMAP2+: powerdomain: control power domains next state
OMAP3: powerdomain data: add wake-up latency figures OMAP2+: omap_hwmod: manage the wake-up latency constraints
OMAP: PM CONSTRAINTS: implement the devices wake-up latency
constraints
OMAP2+: cpuidle only influences the MPU state
Vishwanath BS (1):
OMAP4: powerdomain data: add wake-up latency figures
arch/arm/mach-msm/clock.c | 2 +- arch/arm/mach-omap2/cpuidle34xx.c | 42 +-- arch/arm/mach-omap2/omap_hwmod.c | 26 ++- arch/arm/mach-omap2/pm.h | 17 +- arch/arm/mach-omap2/powerdomain.c | 191 ++++++++++ arch/arm/mach-omap2/powerdomain.h | 33 ++- arch/arm/mach-omap2/powerdomains3xxx_data.c | 77 ++++ arch/arm/mach-omap2/powerdomains44xx_data.c | 84 +++++ arch/arm/plat-omap/Kconfig | 7 + arch/arm/plat-omap/Makefile | 1 + arch/arm/plat-omap/i2c.c | 20 - arch/arm/plat-omap/include/plat/omap-pm.h | 128 ------- arch/arm/plat-omap/include/plat/omap_hwmod.h | 2 + arch/arm/plat-omap/omap-pm-constraints.c | 350 ++++++++++++++++++ arch/arm/plat-omap/omap-pm-noop.c | 89 ----- drivers/acpi/processor_idle.c | 2 +- drivers/base/power/Makefile | 4 +- drivers/base/power/main.c | 3 + drivers/base/power/qos.c | 350 ++++++++++++++++++ drivers/cpuidle/cpuidle.c | 2 +- drivers/cpuidle/governors/ladder.c | 2 +- drivers/cpuidle/governors/menu.c | 2 +- drivers/i2c/busses/i2c-omap.c | 31 +- drivers/media/video/via-camera.c | 4 +- drivers/net/e1000e/netdev.c | 2 +- drivers/net/wireless/ipw2x00/ipw2100.c | 4 +- drivers/staging/msm/lcdc.c | 2 +- drivers/staging/msm/tvenc.c | 2 +- include/linux/netdevice.h | 4 +- include/linux/pm.h | 9 + include/linux/pm_qos.h | 144 ++++++++ include/linux/pm_qos_params.h | 38 -- include/sound/pcm.h | 4 +- kernel/Makefile | 2 +- kernel/pm_qos_params.c | 481 ------------------------- kernel/power/Makefile | 2 +- kernel/power/qos.c | 489 ++++++++++++++++++++++++++ net/mac80211/main.c | 2 +- net/mac80211/mlme.c | 2 +- net/mac80211/scan.c | 2 +- sound/core/pcm_native.c | 2 +- 41 files changed, 1833 insertions(+), 827 deletions(-) create mode 100644 arch/arm/plat-omap/omap-pm-constraints.c create mode 100644 drivers/base/power/qos.c create mode 100644 include/linux/pm_qos.h delete mode 100644 include/linux/pm_qos_params.h delete mode 100644 kernel/pm_qos_params.c create mode 100644 kernel/power/qos.c
Signature · 1 line
1.7.2.5
PATCH v4 1/15 PM QoS: move and rename the implementation files
From: Jean Pihet <[email protected]>
The PM QoS implementation files are better namedkernel/power/qos.c and include/linux/pm_qos.h.
The PM QoS support is compiled under the CONFIG_PM option.
--- arch/arm/mach-msm/clock.c | 2 +- drivers/acpi/processor_idle.c | 2 +- drivers/cpuidle/cpuidle.c | 2 +- drivers/cpuidle/governors/ladder.c | 2 +- drivers/cpuidle/governors/menu.c | 2 +- drivers/media/video/via-camera.c | 2 +- drivers/net/e1000e/netdev.c | 2 +- drivers/net/wireless/ipw2x00/ipw2100.c | 2 +- drivers/staging/msm/lcdc.c | 2 +- drivers/staging/msm/tvenc.c | 2 +- include/linux/netdevice.h | 2 +- include/linux/pm_qos.h | 61 ++++ include/linux/pm_qos_params.h | 38 --- include/sound/pcm.h | 2 +- kernel/Makefile | 2 +- kernel/pm_qos_params.c | 481 -------------------------------- kernel/power/Makefile | 2 +- kernel/power/qos.c | 481 ++++++++++++++++++++++++++++++++ net/mac80211/main.c | 2 +- net/mac80211/mlme.c | 2 +- net/mac80211/scan.c | 2 +- sound/core/pcm_native.c | 2 +- 22 files changed, 560 insertions(+), 537 deletions(-) create mode 100644 include/linux/pm_qos.h delete mode 100644 include/linux/pm_qos_params.h delete mode 100644 kernel/pm_qos_params.c create mode 100644 kernel/power/qos.c
arch/arm/mach-msm/clock.c +1 -1
@@ -18,7 +18,7 @@#include <linux/list.h> #include <linux/err.h> #include <linux/spinlock.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/mutex.h> #include <linux/clk.h> #include <linux/string.h>
drivers/acpi/processor_idle.c +1 -1
@@ -37,7 +37,7 @@#include <linux/dmi.h> #include <linux/moduleparam.h> #include <linux/sched.h> /* need_resched() */ -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/clockchips.h> #include <linux/cpuidle.h> #include <linux/irqflags.h>
drivers/cpuidle/cpuidle.c +1 -1
@@ -12,7 +12,7 @@#include <linux/mutex.h> #include <linux/sched.h> #include <linux/notifier.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/cpu.h> #include <linux/cpuidle.h> #include <linux/ktime.h>
drivers/cpuidle/governors/ladder.c +1 -1
@@ -14,7 +14,7 @@#include <linux/kernel.h> #include <linux/cpuidle.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/moduleparam.h> #include <linux/jiffies.h>
drivers/cpuidle/governors/menu.c +1 -1
@@ -12,7 +12,7 @@#include <linux/kernel.h> #include <linux/cpuidle.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/time.h> #include <linux/ktime.h> #include <linux/hrtimer.h>
drivers/media/video/via-camera.c +1 -1
@@ -21,7 +21,7 @@#include <media/videobuf-dma-sg.h> #include <linux/delay.h> #include <linux/dma-mapping.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/via-core.h> #include <linux/via-gpio.h> #include <linux/via_i2c.h>
drivers/net/e1000e/netdev.c +1 -1
@@ -46,7 +46,7 @@#include <linux/if_vlan.h> #include <linux/cpu.h> #include <linux/smp.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/pm_runtime.h> #include <linux/aer.h> #include <linux/prefetch.h>
drivers/net/wireless/ipw2x00/ipw2100.c +1 -1
@@ -161,7 +161,7 @@ that only one external action is invoked at a time.#include <linux/firmware.h> #include <linux/acpi.h> #include <linux/ctype.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <net/lib80211.h>
drivers/staging/msm/lcdc.c +1 -1
@@ -32,7 +32,7 @@#include <linux/uaccess.h> #include <linux/clk.h> #include <linux/platform_device.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include "msm_fb.h"
drivers/staging/msm/tvenc.c +1 -1
@@ -32,7 +32,7 @@#include <linux/uaccess.h> #include <linux/clk.h> #include <linux/platform_device.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #define TVENC_C #include "tvenc.h"
include/linux/netdevice.h +1 -1
@@ -31,7 +31,7 @@#include <linux/if_link.h> #ifdef __KERNEL__ -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/timer.h> #include <linux/delay.h> #include <linux/mm.h>
include/linux/pm_qos.h new file +61 -0
61 lines not on this page · raw message
include/linux/pm_qos_params.h deleted +0 -38
@@ -1,38 +0,0 @@ -#ifndef _LINUX_PM_QOS_PARAMS_H -#define _LINUX_PM_QOS_PARAMS_H -/* interface for the pm_qos_power infrastructure of the linux kernel. -* -* Mark Gross <[email protected]> -*/ -#include <linux/plist.h> -#include <linux/notifier.h> -#include <linux/miscdevice.h> - -#define PM_QOS_RESERVED 0 -#define PM_QOS_CPU_DMA_LATENCY 1 -#define PM_QOS_NETWORK_LATENCY 2 -#define PM_QOS_NETWORK_THROUGHPUT 3 - -#define PM_QOS_NUM_CLASSES 4 -#define PM_QOS_DEFAULT_VALUE -1 - -#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) -#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) -#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 - -struct pm_qos_request_list { -struct plist_node list; -int pm_qos_class; -}; - -void pm_qos_add_request (struct pm_qos_request_list *l,int pm_qos_class,s32 value); -void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, -s32 new_value); -void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req); - -int pm_qos_request (int pm_qos_class); -int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier); -int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier); -int pm_qos_request_active (struct pm_qos_request_list *req); - -#endif
include/sound/pcm.h +1 -1
@@ -29,7 +29,7 @@#include <linux/poll.h> #include <linux/mm.h> #include <linux/bitops.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #define snd_pcm_substream_chip (substream) ((substream)->private_data)#define snd_pcm_chip (pcm) ((pcm)->private_data)
kernel/Makefile +1 -1
@@ -9,7 +9,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o \ rcupdate.o extable.o params.o posix-timers.o \ kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ - notifier.o ksysfs.o pm_qos_params.o sched_clock.o cred.o \ + notifier.o ksysfs.o sched_clock.o cred.o \ async.o range.o jump_label.o obj-y += groups.o
kernel/pm_qos_params.c deleted +0 -481
481 lines not on this page · raw message
kernel/power/Makefile +1 -1
@@ -1,7 +1,7 @@ ccflags-$(CONFIG_PM_DEBUG) := -DDEBUG -obj-$(CONFIG_PM) += main.o +obj-$(CONFIG_PM) += main.o qos.o obj-$(CONFIG_PM_SLEEP) += console.o obj-$(CONFIG_FREEZER) += process.o obj-$(CONFIG_SUSPEND) += suspend.o
kernel/power/qos.c new file +481 -0
481 lines not on this page · raw message
net/mac80211/main.c +1 -1
@@ -19,7 +19,7 @@#include <linux/if_arp.h> #include <linux/rtnetlink.h> #include <linux/bitmap.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/inetdevice.h> #include <net/net_namespace.h> #include <net/cfg80211.h>
net/mac80211/mlme.c +1 -1
@@ -17,7 +17,7 @@#include <linux/if_arp.h> #include <linux/etherdevice.h> #include <linux/rtnetlink.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/crc32.h> #include <linux/slab.h> #include <net/mac80211.h>
net/mac80211/scan.c +1 -1
@@ -14,7 +14,7 @@#include <linux/if_arp.h> #include <linux/rtnetlink.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <net/sch_generic.h> #include <linux/slab.h> #include <net/mac80211.h>
sound/core/pcm_native.c +1 -1
@@ -23,7 +23,7 @@#include <linux/file.h> #include <linux/slab.h> #include <linux/time.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/uio.h> #include <linux/dma-mapping.h> #include <sound/core.h>
Signature · 1 line
1.7.2.5
PATCH v4 2/15 PM QoS: minor clean-ups
In reply to [email protected]From: Jean Pihet <[email protected]>
- Misc fixes to improve code readability:
. rename struct pm_qos_request_list to struct pm_qos_request, . rename pm_qos_req parameter to req in internal code,
consistenly use req in the API parameters,
. update the in-kernel API callers to the new parameters names, . rename of fields names (requests, list, node, constraints)
--- drivers/media/video/via-camera.c | 2 +- drivers/net/wireless/ipw2x00/ipw2100.c | 2 +- include/linux/netdevice.h | 2 +- include/linux/pm_qos.h | 22 ++++---- include/sound/pcm.h | 2 +- kernel/power/qos.c | 90 ++++++++++++++++--------------- 6 files changed, 61 insertions(+), 59 deletions(-)
drivers/media/video/via-camera.c +1 -1
@@ -69,7 +69,7 @@ struct via_camera {struct mutex lock;enum viacam_opstate opstate;unsigned long flags; -struct pm_qos_request_list qos_request; +struct pm_qos_request qos_request;/* * GPIO info for power/reset management */
drivers/net/wireless/ipw2x00/ipw2100.c +1 -1
@@ -174,7 +174,7 @@ that only one external action is invoked at a time.#define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2100 Network Driver"#define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation" -static struct pm_qos_request_list ipw2100_pm_qos_req; +static struct pm_qos_request ipw2100_pm_qos_req;/* Debugging stuff */ #ifdef CONFIG_IPW2100_DEBUG
include/linux/netdevice.h +1 -1
@@ -999,7 +999,7 @@ struct net_device {*/ char name[IFNAMSIZ ]; -struct pm_qos_request_list pm_qos_req; +struct pm_qos_request pm_qos_req;/* device name hash chain */ struct hlist_node name_hlist;
include/linux/pm_qos.h +11 -11
@@ -20,30 +20,30 @@#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 -struct pm_qos_request_list { -struct plist_node list; +struct pm_qos_request { +struct plist_node node;int pm_qos_class; };#ifdef CONFIG_PM -void pm_qos_add_request (struct pm_qos_request_list *l, -int pm_qos_class,s32 value); -void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class, +s32 value); +void pm_qos_update_request (struct pm_qos_request *req,s32 new_value); -void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req); +void pm_qos_remove_request (struct pm_qos_request *req);int pm_qos_request (int pm_qos_class);int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier); -int pm_qos_request_active (struct pm_qos_request_list *req); +int pm_qos_request_active (struct pm_qos_request *req);#else -static inline void pm_qos_add_request (struct pm_qos_request_list *l, +static inline void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) {return ; } -static inline void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +static inline void pm_qos_update_request (struct pm_qos_request *req,s32 new_value) {return ; } -static inline void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req) +static inline void pm_qos_remove_request (struct pm_qos_request *req) {return ; }static inline int pm_qos_request (int pm_qos_class)
@@ -54,7 +54,7 @@ static inline int pm_qos_add_notifier(int pm_qos_class,static inline int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier) {return 0 ; } -static inline int pm_qos_request_active (struct pm_qos_request_list *req) +static inline int pm_qos_request_active (struct pm_qos_request *req) {return 0 ; }#endif
include/sound/pcm.h +1 -1
@@ -373,7 +373,7 @@ struct snd_pcm_substream {int number;char name[32 ];/* substream name */ int stream;/* stream (direction) */ -struct pm_qos_request_list latency_pm_qos_req;/* pm_qos request */ +struct pm_qos_request latency_pm_qos_req;/* pm_qos request */ size_t buffer_bytes_max;/* limit ring buffer size */ struct snd_dma_buffer dma_buffer;unsigned int dma_buf_id;
kernel/power/qos.c +46 -44
254 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v4 3/15 PM QoS: code re-organization
In reply to [email protected]From: Jean Pihet <[email protected]>
Move around the PM QoS misc devices management code for better readability.
--- kernel/power/qos.c | 45 +++++++++++++++++++++++---------------------- 1 files changed, 23 insertions(+), 22 deletions(-)
kernel/power/qos.c +23 -22
@@ -190,28 +190,6 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node, NULL); } -static int register_pm_qos_misc (struct pm_qos_object *qos) -{ - qos->pm_qos_power_miscdev.minor =MISC_DYNAMIC_MINOR ; - qos->pm_qos_power_miscdev.name = qos->name; - qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; - -return misc_register (&qos->pm_qos_power_miscdev); -} - -static int find_pm_qos_object_by_minor (int minor) -{ -int pm_qos_class; - -for (pm_qos_class =0 ; - pm_qos_class <PM_QOS_NUM_CLASSES ; pm_qos_class++) { -if (minor == - pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) -return pm_qos_class; - } -return -1 ; -} -/** * pm_qos_request - returns current system wide qos expectation * @pm_qos_class: identification of which qos value is requested
@@ -364,6 +342,29 @@ int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier) }EXPORT_SYMBOL_GPL (pm_qos_remove_notifier); +/* User space interface to PM QoS classes via misc devices */ +static int register_pm_qos_misc (struct pm_qos_object *qos) +{ + qos->pm_qos_power_miscdev.minor =MISC_DYNAMIC_MINOR ; + qos->pm_qos_power_miscdev.name = qos->name; + qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; + +return misc_register (&qos->pm_qos_power_miscdev); +} + +static int find_pm_qos_object_by_minor (int minor) +{ +int pm_qos_class; + +for (pm_qos_class =0 ; + pm_qos_class <PM_QOS_NUM_CLASSES ; pm_qos_class++) { +if (minor == + pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) +return pm_qos_class; + } +return -1 ; +} +static int pm_qos_power_open (struct inode *inode,struct file *filp) {long pm_qos_class;
Signature · 1 line
1.7.2.5
PATCH v4 4/15 PM QoS: re-organize data structs
In reply to [email protected]From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support, re-organize the data strctures:
- add a struct pm_qos_constraints which contains the constraints related data
- update struct pm_qos_object contents to the PM QoS internal object data. Add a pointer to struct pm_qos_constraints
- update the internal code to use the new data structs.
--- include/linux/pm_qos.h | 19 ++++++++++ kernel/power/qos.c | 90 ++++++++++++++++++++++------------------------- 2 files changed, 61 insertions(+), 48 deletions(-)
include/linux/pm_qos.h +19 -0
@@ -25,6 +25,25 @@ struct pm_qos_request {int pm_qos_class; }; +enum pm_qos_type { +PM_QOS_UNITIALIZED , +PM_QOS_MAX ,/* return the largest value */ +PM_QOS_MIN /* return the smallest value */ +}; + +/* +* Note: The lockless read path depends on the CPU accessing +* target_value atomically. Atomic access is only guaranteed on all CPU +* types linux supports for 32 bit quantites +*/ +struct pm_qos_constraints { +struct plist_head list; +s32 target_value;/* Do not change to 64 bit */ +s32 default_value; +enum pm_qos_type type; +struct blocking_notifier_head *notifiers; +}; +#ifdef CONFIG_PM void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value);
kernel/power/qos.c +42 -48
179 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v4 5/15 PM QoS: generalize and export the constraints management code
In reply to [email protected]From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support:
- rename update_target to pm_qos_update_target
- generalize and export pm_qos_update_target for usage by the upcoming per-device latency constraints framework:
. operate on struct pm_qos_constraints for constraints management, . introduce an 'action' parameter for constraints add/update/remove, . the return value indicates if the aggregated constraint value has
changed,
- update the internal code to operate on struct pm_qos_constraints
- add a NULL pointer check in the API functions
--- include/linux/pm_qos.h | 14 ++++++ kernel/power/qos.c | 123 ++++++++++++++++++++++++++---------------------- 2 files changed, 81 insertions(+), 56 deletions(-)
include/linux/pm_qos.h +14 -0
@@ -44,7 +44,16 @@ struct pm_qos_constraints {struct blocking_notifier_head *notifiers; }; +/* Action requested to pm_qos_update_target */ +enum pm_qos_req_action { +PM_QOS_ADD_REQ ,/* Add a new request */ +PM_QOS_UPDATE_REQ ,/* Update an existing request */ +PM_QOS_REMOVE_REQ /* Remove an existing request */ +}; +#ifdef CONFIG_PM +int pm_qos_update_target (struct pm_qos_constraints *c,struct plist_node *node, +enum pm_qos_req_action action,int value);void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value); void pm_qos_update_request(struct pm_qos_request *req,
@@ -56,6 +65,11 @@ int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_request_active (struct pm_qos_request *req);#else +static inline int pm_qos_update_target (struct pm_qos_constraints *c, +struct plist_node *node, +enum pm_qos_req_action action, +int value) + {return 0 ; }static inline void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) {return ; }
kernel/power/qos.c +67 -56
215 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v4 6/15 PM QoS: implement the per-device PM QoS constraints
In reply to [email protected]From: Jean Pihet <[email protected]>
Implement the per-device PM QoS constraints by creating a device PM QoS API, which calls the PM QoS constraints management core code.
The per-device latency constraints data strctures are stored in the device dev_pm_info struct.
The device PM code calls the init and destroy of the per-device constraints data struct in order to support the dynamic insertion and removal of the devices in the system.
To minimize the data usage by the per-device constraints, the data struct is only allocated at the first call to dev_pm_qos_add_request. The data is later free'd when the device is removed from the system.
--- drivers/base/power/Makefile | 4 +- drivers/base/power/main.c | 3 + drivers/base/power/qos.c | 262 +++++++++++++++++++++++++++++++++++++++++++ include/linux/pm.h | 9 ++ include/linux/pm_qos.h | 39 +++++++ 5 files changed, 315 insertions(+), 2 deletions(-) create mode 100644 drivers/base/power/qos.c
drivers/base/power/Makefile +2 -2
@@ -1,8 +1,8 @@ -obj-$(CONFIG_PM) += sysfs.o generic_ops.o +obj-$(CONFIG_PM) += sysfs.o generic_ops.o qos.o obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o obj-$(CONFIG_PM_RUNTIME) += runtime.o obj-$(CONFIG_PM_TRACE_RTC) += trace.o obj-$(CONFIG_PM_OPP) += opp.o obj-$(CONFIG_HAVE_CLK) += clock_ops.o -ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG +ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG
drivers/base/power/main.c +3 -0
@@ -22,6 +22,7 @@#include <linux/mutex.h> #include <linux/pm.h> #include <linux/pm_runtime.h> +#include <linux/pm_qos.h> #include <linux/resume-trace.h> #include <linux/interrupt.h> #include <linux/sched.h>
@@ -97,6 +98,7 @@ void device_pm_add(struct device *dev) dev_name(dev->parent));list_add_tail (&dev->power.entry, &dpm_list);mutex_unlock (&dpm_list_mtx); +dev_pm_qos_constraints_init (dev); }/**
@@ -107,6 +109,7 @@ void device_pm_remove(struct device *dev) {pr_debug ("PM: Removing info for %s:%s\n" , dev->bus ? dev->bus->name :"No Bus" ,dev_name (dev)); +dev_pm_qos_constraints_destroy (dev);complete_all (&dev->power.completion);mutex_lock (&dpm_list_mtx);list_del_init (&dev->power.entry);
drivers/base/power/qos.c new file +262 -0
262 lines not on this page · raw message
include/linux/pm.h +9 -0
@@ -421,6 +421,13 @@ enum rpm_request {struct wakeup_source ; +/* Per-device PM QoS constraints data struct state */ +enum dev_pm_qos_state { +DEV_PM_QOS_NO_DEVICE ,/* No device present */ +DEV_PM_QOS_DEVICE_PRESENT ,/* Device present, data not allocated */ +DEV_PM_QOS_ALLOCATED ,/* Device present, data allocated */ +}; +struct dev_pm_info {pm_message_t power_state;unsigned int can_wakeup:1 ;
@@ -463,6 +470,8 @@ struct dev_pm_info {unsigned long accounting_timestamp;void *subsys_data;/* Owned by the subsystem. */ #endif +struct pm_qos_constraints *constraints; +enum dev_pm_qos_state constraints_state; };extern void update_pm_runtime_accounting (struct device *dev);
include/linux/pm_qos.h +39 -0
@@ -19,12 +19,18 @@#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 +#define PM_QOS_DEV_LAT_DEFAULT_VALUE 0struct pm_qos_request {struct plist_node node;int pm_qos_class; }; +struct dev_pm_qos_request { +struct plist_node node; +struct device *dev; +}; +enum pm_qos_type {PM_QOS_UNITIALIZED ,PM_QOS_MAX ,/* return the largest value */
@@ -64,6 +70,18 @@ int pm_qos_request(int pm_qos_class);int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_request_active (struct pm_qos_request *req); + +int dev_pm_qos_request_active (struct dev_pm_qos_request *req); +void dev_pm_qos_add_request (struct dev_pm_qos_request *req,struct device *dev, +s32 value); +void dev_pm_qos_update_request (struct dev_pm_qos_request *req,s32 new_value); +void dev_pm_qos_remove_request (struct dev_pm_qos_request *req); +int dev_pm_qos_add_notifier (struct device *dev, +struct notifier_block *notifier); +int dev_pm_qos_remove_notifier (struct device *dev, +struct notifier_block *notifier); +void dev_pm_qos_constraints_init (struct device *dev); +void dev_pm_qos_constraints_destroy (struct device *dev);#else static inline int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
@@ -89,6 +107,27 @@ static inline int pm_qos_remove_notifier(int pm_qos_class, {return 0 ; }static inline int pm_qos_request_active (struct pm_qos_request *req) {return 0 ; } + +static inline int dev_pm_qos_request_active (struct dev_pm_qos_request *req) + {return 0 ; } +static inline void dev_pm_qos_add_request (struct dev_pm_qos_request *req, +struct device *dev,s32 value) + {return ; } +static inline void dev_pm_qos_update_request (struct dev_pm_qos_request *req, +s32 new_value) + {return ; } +static inline void dev_pm_qos_remove_request (struct dev_pm_qos_request *req) + {return ; } +static inline int dev_pm_qos_add_notifier (struct device *dev, +struct notifier_block *notifier) + {return 0 ; } +static inline int dev_pm_qos_remove_notifier (struct device *dev, +struct notifier_block *notifier) + {return 0 ; } +static inline void dev_pm_qos_constraints_init (struct device *dev) + {return ; } +static inline void dev_pm_qos_constraints_destroy (struct device *dev) + {return ; }#endif #endif
Signature · 1 line
1.7.2.5
PATCH v4 7/15 PM QoS: add a global notification mechanism for the device constraints
In reply to [email protected]From: Jean Pihet <[email protected]>
Add a global notification chain that gets called upon changes to the aggregated constraint value for any device.
The notification callbacks are passing the full constraint request data in order for the callees to have access to it. The current use is for the platform low-level code to access the target device of the constraint.
--- drivers/base/power/qos.c | 114 ++++++++++++++++++++++++++++++++++++++++----- include/linux/pm_qos.h | 11 ++++ kernel/power/qos.c | 2 +- 3 files changed, 113 insertions(+), 14 deletions(-)
drivers/base/power/qos.c +101 -13
@@ -8,6 +8,12 @@* * This QoS design is best effort based. Dependents register their QoS needs. * Watchers register to keep track of the current QoS needs of the system. +* Watchers can register different types of notification callbacks: +* . a per-device notification callback using the dev_pm_qos_*_notifier API. +* The notification chain data is stored in the per-device constraint +* data struct. +* . a system-wide notification callback using the dev_pm_qos_*_global_notifier +* API. The notification chain data is stored in a static variable. * * Note about the per-device constraint data struct allocation: * . The per-device constraints data struct ptr is tored into the device
@@ -41,6 +47,7 @@#include <linux/kernel.h> +static BLOCKING_NOTIFIER_HEAD (dev_pm_notifiers);static void dev_pm_qos_constraints_allocate (struct device *dev);int dev_pm_qos_request_active (struct dev_pm_qos_request *req)
@@ -64,6 +71,8 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_request_active);void dev_pm_qos_add_request (struct dev_pm_qos_request *req,struct device *dev,s32 value) { +int ret, curr_value; +if (!req)/*guard against callers passing in null */ return ;
@@ -82,8 +91,19 @@ void dev_pm_qos_add_request(struct dev_pm_qos_request *req, struct device *dev,if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED )return ; -pm_qos_update_target (dev->power.constraints, - &req->node,PM_QOS_ADD_REQ , value); +/* +* Update constraints list and call the per-device callbacks if needed +*/ + ret =pm_qos_update_target (dev->power.constraints, + &req->node,PM_QOS_ADD_REQ , value); + +if (ret) { +/* Call the global callbacks if needed */ + curr_value =pm_qos_read_value (req->dev->power.constraints); +blocking_notifier_call_chain (&dev_pm_notifiers, + (unsigned long )curr_value, + req); + } }EXPORT_SYMBOL_GPL (dev_pm_qos_add_request);
@@ -98,8 +118,10 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_add_request);* Attempts are made to make this code callable on hot code paths. */ void dev_pm_qos_update_request (struct dev_pm_qos_request *req, -s32 new_value) +s32 new_value) { +int ret, curr_value; +if (!req)/*guard against callers passing in null */ return ;
@@ -113,10 +135,23 @@ void dev_pm_qos_update_request(struct dev_pm_qos_request *req,if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED )return ; -if (new_value != req->node.prio) -pm_qos_update_target ( - req->dev->power.constraints, - &req->node,PM_QOS_UPDATE_REQ , new_value); +if (new_value != req->node.prio) { +/* +* Update constraints list and call the per-device callbacks +* if needed +*/ + ret =pm_qos_update_target (req->dev->power.constraints, + &req->node,PM_QOS_UPDATE_REQ , + new_value); +if (ret) { +/* Call the global callbacks if needed */ + curr_value =pm_qos_read_value ( + req->dev->power.constraints); +blocking_notifier_call_chain (&dev_pm_notifiers, + (unsigned long )curr_value, + req); + } + } }EXPORT_SYMBOL_GPL (dev_pm_qos_update_request);
@@ -129,6 +164,8 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_update_request);*/ void dev_pm_qos_remove_request (struct dev_pm_qos_request *req) { +int ret, curr_value; +if (!req)/*guard against callers passing in null */ return ;
@@ -142,9 +179,20 @@ void dev_pm_qos_remove_request(struct dev_pm_qos_request *req)if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED )return ; -pm_qos_update_target (req->dev->power.constraints, - &req->node,PM_QOS_REMOVE_REQ , -PM_QOS_DEFAULT_VALUE ); +/* +* Update constraints list and call the per-device callbacks if needed +*/ + ret =pm_qos_update_target (req->dev->power.constraints, + &req->node,PM_QOS_REMOVE_REQ , +PM_QOS_DEFAULT_VALUE ); + +if (ret) { +/* Call the global callbacks if needed */ + curr_value =pm_qos_read_value (req->dev->power.constraints); +blocking_notifier_call_chain (&dev_pm_notifiers, + (unsigned long )curr_value, + req); + }memset (req,0 ,sizeof (*req)); }EXPORT_SYMBOL_GPL (dev_pm_qos_remove_request);
@@ -202,6 +250,36 @@ int dev_pm_qos_remove_notifier(struct device *dev, }EXPORT_SYMBOL_GPL (dev_pm_qos_remove_notifier); +/** +* dev_pm_qos_add_global_notifier - sets notification entry for changes to +* target value of the PM QoS constraints for any device +* +* @notifier: notifier block managed by caller. +* +* Will register the notifier into a notification chain that gets called +* upon changes to the target value for any device. +*/ +int dev_pm_qos_add_global_notifier (struct notifier_block *notifier) +{ +return blocking_notifier_chain_register (&dev_pm_notifiers, notifier); +} +EXPORT_SYMBOL_GPL (dev_pm_qos_add_global_notifier); + +/** +* dev_pm_qos_remove_global_notifier - deletes notification for changes to +* target value of PM QoS constraints for any device +* +* @notifier: notifier block to be removed. +* +* Will remove the notifier from the notification chain that gets called +* upon changes to the target value for any device. +*/ +int dev_pm_qos_remove_global_notifier (struct notifier_block *notifier) +{ +return blocking_notifier_chain_unregister (&dev_pm_notifiers, notifier); +} +EXPORT_SYMBOL_GPL (dev_pm_qos_remove_global_notifier); +/* Called at the first call to add_request, for constraint data allocation */ static void dev_pm_qos_constraints_allocate (struct device *dev) {
@@ -239,6 +317,7 @@ void dev_pm_qos_constraints_destroy(struct device *dev) {struct dev_pm_qos_request *req, *tmp;enum dev_pm_qos_state constraints_state = dev->power.constraints_state; +int ret =0 , curr_value; dev->power.constraints_state =DEV_PM_QOS_NO_DEVICE ;if (constraints_state ==DEV_PM_QOS_ALLOCATED ) {
@@ -250,9 +329,18 @@ void dev_pm_qos_constraints_destroy(struct device *dev)* Update constraints list and call the per-device * callbacks if needed */ -pm_qos_update_target (req->dev->power.constraints, - &req->node,PM_QOS_REMOVE_REQ , -PM_QOS_DEFAULT_VALUE ); + ret |=pm_qos_update_target (req->dev->power.constraints, + &req->node, +PM_QOS_REMOVE_REQ , +PM_QOS_DEFAULT_VALUE ); + +if (ret) { +/* Call the global callbacks if needed */ + curr_value = dev->power.constraints->default_value; +blocking_notifier_call_chain (&dev_pm_notifiers, + (unsigned long )curr_value, + req); + }kfree (dev->power.constraints->notifiers);kfree (dev->power.constraints);
include/linux/pm_qos.h +11 -0
@@ -70,6 +70,7 @@ int pm_qos_request(int pm_qos_class);int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_request_active (struct pm_qos_request *req); +s32 pm_qos_read_value (struct pm_qos_constraints *c);int dev_pm_qos_request_active (struct dev_pm_qos_request *req); void dev_pm_qos_add_request(struct dev_pm_qos_request *req, struct device *dev,
@@ -80,6 +81,8 @@ int dev_pm_qos_add_notifier(struct device *dev, struct notifier_block *notifier);int dev_pm_qos_remove_notifier (struct device *dev,struct notifier_block *notifier); +int dev_pm_qos_add_global_notifier (struct notifier_block *notifier); +int dev_pm_qos_remove_global_notifier (struct notifier_block *notifier);void dev_pm_qos_constraints_init (struct device *dev);void dev_pm_qos_constraints_destroy (struct device *dev);#else
@@ -107,6 +110,8 @@ static inline int pm_qos_remove_notifier(int pm_qos_class, {return 0 ; }static inline int pm_qos_request_active (struct pm_qos_request *req) {return 0 ; } +static inline s32 pm_qos_read_value (struct pm_qos_constraints *c) + {return 0 ; }static inline int dev_pm_qos_request_active (struct dev_pm_qos_request *req) {return 0 ; }
@@ -124,6 +129,12 @@ static inline int dev_pm_qos_add_notifier(struct device *dev,static inline int dev_pm_qos_remove_notifier (struct device *dev,struct notifier_block *notifier) {return 0 ; } +static inline int dev_pm_qos_add_global_notifier ( +struct notifier_block *notifier) + {return 0 ; } +static inline int dev_pm_qos_remove_global_notifier ( +struct notifier_block *notifier) + {return 0 ; }static inline void dev_pm_qos_constraints_init (struct device *dev) {return ; }static inline void dev_pm_qos_constraints_destroy (struct device *dev)
kernel/power/qos.c +1 -1
@@ -139,7 +139,7 @@ static inline int pm_qos_get_value(struct pm_qos_constraints *c) } } -static inline s32 pm_qos_read_value (struct pm_qos_constraints *c) +s32 pm_qos_read_value (struct pm_qos_constraints *c) {return c->target_value; }
Signature · 1 line
1.7.2.5
PATCH v4 8/15 OMAP: convert I2C driver to PM QoS for latency constraints
In reply to [email protected]From: Jean Pihet <[email protected]>
Convert the driver from the outdated omap_pm_set_max_mpu_wakeup_lat API to the new PM QoS API.
Since the constraint is on the MPU subsystem, use the PM_QOS_CPU_DMA_LATENCY class of PM QoS. The resulting MPU constraints are used by cpuidle to decide the next power state of the MPU subsystem.
Currently only OMAP3 is placing constraints on the MPU.
--- arch/arm/plat-omap/i2c.c | 20 -------------------- drivers/i2c/busses/i2c-omap.c | 31 ++++++++++++++++++------------- 2 files changed, 18 insertions(+), 33 deletions(-)
arch/arm/plat-omap/i2c.c +0 -20
@@ -34,7 +34,6 @@#include <mach/irqs.h> #include <plat/mux.h> #include <plat/i2c.h> -#include <plat/omap-pm.h> #include <plat/omap_device.h> #define OMAP_I2C_SIZE 0x3f
@@ -129,16 +128,6 @@ static inline int omap1_i2c_add_bus(int bus_id) #ifdef CONFIG_ARCH_OMAP2PLUS -/* - * XXX This function is a temporary compatibility wrapper - only - * needed until the I2C driver can be converted to call - * omap_pm_set_max_dev_wakeup_lat() and handle a return code. - */ -static void omap_pm_set_max_mpu_wakeup_lat_compat(struct device *dev, long t) -{ - omap_pm_set_max_mpu_wakeup_lat(dev, t); -} - static struct omap_device_pm_latency omap_i2c_latency[] = { [0] = { .deactivate_func = omap_device_idle_hwmods,
@@ -178,15 +167,6 @@ static inline int omap2_i2c_add_bus(int bus_id) dev_attr = (struct omap_i2c_dev_attr *)oh->dev_attr; pdata->flags = dev_attr->flags; -/* -* When waiting for completion of a i2c transfer, we need to -* set a wake up latency constraint for the MPU. This is to -* ensure quick enough wakeup from idle, when transfer -* completes. -* Only omap3 has support for constraints -*/ -if (cpu_is_omap34xx ()) - pdata->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat; od =omap_device_build (name, bus_id, oh, pdata,sizeof (struct omap_i2c_bus_platform_data ), omap_i2c_latency,ARRAY_SIZE (omap_i2c_latency),0 );
drivers/i2c/busses/i2c-omap.c +18 -13
@@ -40,6 +40,7 @@#include <linux/slab.h> #include <linux/i2c-omap.h> #include <linux/pm_runtime.h> +#include <linux/pm_qos.h> /* I2C controller revisions */ #define OMAP_I2C_OMAP1_REV_2 0x20
@@ -180,8 +181,7 @@ struct omap_i2c_dev {struct completion cmd_complete;struct resource *ioarea;u32 latency;/* maximum mpu wkup latency */ -void (*set_mpu_wkup_lat)(struct device *dev, -long latency); +struct pm_qos_request pm_qos_request;u32 speed;/* Speed of bus in Khz */ u16 cmd_err;u8 *buf;
@@ -657,8 +657,16 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)if (r <0 ) goto out; -if (dev->set_mpu_wkup_lat !=NULL ) - dev->set_mpu_wkup_lat (dev->dev, dev->latency); +/* +* When waiting for completion of a i2c transfer, we need to +* set a wake up latency constraint for the MPU. This is to +* ensure quick enough wakeup from idle, when transfer +* completes. +* Used on OMAP3 Only +*/ +if (cpu_is_omap34xx ()) +pm_qos_add_request (&dev->pm_qos_request,PM_QOS_CPU_DMA_LATENCY , + dev->latency);for (i =0 ; i < num; i++) { r =omap_i2c_xfer_msg (adap, &msgs[i], (i == (num -1 )));
@@ -666,8 +674,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)break ; } -if (dev->set_mpu_wkup_lat !=NULL ) - dev->set_mpu_wkup_lat (dev->dev,-1 ); +if (cpu_is_omap34xx ()) +pm_qos_remove_request (&dev->pm_qos_request);if (r ==0 ) r = num;
@@ -1021,13 +1029,10 @@ omap_i2c_probe(struct platform_device *pdev) goto err_release_region; } -if (pdata !=NULL ) { +if (pdata !=NULL ) speed = pdata->clkrate; - dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat; - }else { +else speed =100 ;/* Default speed */ - dev->set_mpu_wkup_lat =NULL ; - } dev->speed = speed; dev->idle =1 ;
@@ -1075,8 +1080,8 @@ omap_i2c_probe(struct platform_device *pdev) dev->fifo_size = (dev->fifo_size /2 ); dev->b_hw =1 ;/* Enable hardware fixes */ } -/* calculate wakeup latency constraint for MPU */ -if (dev->set_mpu_wkup_lat !=NULL ) +/* calculate wakeup latency constraint */ +if (cpu_is_omap34xx ()) dev->latency = (1000000 * dev->fifo_size) / (1000 * speed /8 ); }
Signature · 1 line
1.7.2.5
PATCH v4 9/15 OMAP: PM: create a PM layer plugin for per-device constraints
In reply to [email protected]From: Jean Pihet <[email protected]>
Created arch/arm/plat-omap/omap-pm-constraints.c file from arch/arm/plat-omap/omap-pm-noop.c and the associated Kconfig option OMAP_PM_CONSTRAINTS.
--- arch/arm/plat-omap/Kconfig | 7 + arch/arm/plat-omap/Makefile | 1 + arch/arm/plat-omap/omap-pm-constraints.c | 363 ++++++++++++++++++++++++++++++ 3 files changed, 371 insertions(+), 0 deletions(-) create mode 100644 arch/arm/plat-omap/omap-pm-constraints.c
arch/arm/plat-omap/Kconfig +7 -0
@@ -214,6 +214,13 @@ choice config OMAP_PM_NOOP bool "No-op/debug PM layer" +config OMAP_PM_CONSTRAINTS + depends on PM + bool "Per device constraints" + help + Select this option to enable the PM layer plugin for + the per-device constraints support + endchoice endmenu
arch/arm/plat-omap/Makefile +1 -0
@@ -32,3 +32,4 @@ obj-y += $(i2c-omap-m) $(i2c-omap-y) obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox.o obj-$(CONFIG_OMAP_PM_NOOP) += omap-pm-noop.o +obj-$(CONFIG_OMAP_PM_CONSTRAINTS) += omap-pm-constraints.o
arch/arm/plat-omap/omap-pm-constraints.c new file +363 -0
363 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v4 10/15 OMAP2+: powerdomain: control power domains next state
In reply to [email protected]From: Jean Pihet <[email protected]>
When a PM QoS device latency constraint is requested or removed the PM QoS layer notifies the underlying layer with the updated aggregated constraint value. The constraint is stored in the powerdomain constraints list and then applied to the corresponding power domain.
The power domains get the next power state programmed directly in the registers via pwrdm_wakeuplat_update_pwrst.
Tested on OMAP3 Beagleboard and OMAP4 Pandaboard in RET/OFF using wake-up latency constraints on MPU, CORE and PER.
--- arch/arm/mach-omap2/powerdomain.c | 191 +++++++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/powerdomain.h | 33 ++++++- 2 files changed, 222 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/powerdomain.c +191 -0
@@ -17,8 +17,10 @@#include <linux/kernel.h> #include <linux/types.h> #include <linux/list.h> +#include <linux/slab.h> #include <linux/errno.h> #include <linux/string.h> +#include <linux/pm_qos.h> #include <trace/events/power.h> #include "cm2xxx_3xxx.h"
@@ -104,6 +106,12 @@ static int _pwrdm_register(struct powerdomain *pwrdm)for (i =0 ; i < pwrdm->banks; i++) pwrdm->ret_mem_off_counter[i] =0 ; +/* Initialize the per-od wake-up constraints list and spinlock */ +spin_lock_init (&pwrdm->wkup_lat_plist_lock); +plist_head_init (&pwrdm->wkup_lat_plist_head, + &pwrdm->wkup_lat_plist_lock); + +/* Initialize the pwrdm state */ pwrdm_wait_transition (pwrdm); pwrdm->state =pwrdm_read_pwrst (pwrdm); pwrdm->state_counter[pwrdm->state] =1 ;
@@ -191,6 +199,77 @@ static int _pwrdm_post_transition_cb(struct powerdomain *pwrdm, void *unused)return 0 ; } +/** +* pwrdm_wakeuplat_update_pwrst - Update power domain power state if needed +* @pwrdm: struct powerdomain * to which requesting device belongs to. +* @min_latency: the allowed wake-up latency for the given power domain. A +* value of PM_QOS_DEV_LAT_DEFAULT_VALUE means 'no constraint' on the pwrdm. +* +* Finds the power domain next power state that fulfills the constraint. +* Programs a new target state if it is different from current power state. +* The power domains get the next power state programmed directly in the +* registers. +* +* Returns 0 upon success. +*/ +static int pwrdm_wakeuplat_update_pwrst (struct powerdomain *pwrdm, +long min_latency) +{ +int ret =0 , new_state =0 ; + +if (!pwrdm) { +WARN (1 ,"powerdomain: %s: invalid parameter(s)" , __func__); +return -EINVAL ; + } + +/* +* Apply constraints to power domains by programming +* the pwrdm next power state. +*/ + +/* Find power state with wakeup latency < minimum constraint */ +for (new_state =0x0 ; new_state <PWRDM_MAX_PWRSTS ; new_state++) { +if (min_latency ==PM_QOS_DEV_LAT_DEFAULT_VALUE || + pwrdm->wakeup_lat[new_state] <= min_latency) +break ; + } + +switch (new_state) { +case PWRDM_FUNC_PWRST_OFF : + new_state =PWRDM_POWER_OFF ; +break ; +case PWRDM_FUNC_PWRST_OSWR : +pwrdm_set_logic_retst (pwrdm,PWRDM_POWER_OFF ); + new_state =PWRDM_POWER_RET ; +break ; +case PWRDM_FUNC_PWRST_CSWR : +pwrdm_set_logic_retst (pwrdm,PWRDM_POWER_RET ); + new_state =PWRDM_POWER_RET ; +break ; +case PWRDM_FUNC_PWRST_INACTIVE : + new_state =PWRDM_POWER_INACTIVE ; +break ; +case PWRDM_FUNC_PWRST_ON : + new_state =PWRDM_POWER_ON ; +break ; +default : +pr_warn ("powerdomain: requested latency constraint not " +"supported %s set to ON state\n" , pwrdm->name); + new_state =PWRDM_POWER_ON ; +break ; + } + +if (pwrdm_read_next_pwrst (pwrdm) != new_state) + ret =omap_set_pwrdm_state (pwrdm, new_state); + +pr_debug ("powerdomain: %s pwrst: curr=%d, prev=%d next=%d " +"min_latency=%ld, set_state=%d\n" , pwrdm->name, +pwrdm_read_pwrst (pwrdm),pwrdm_read_prev_pwrst (pwrdm), +pwrdm_read_next_pwrst (pwrdm), min_latency, new_state); + +return ret; +} +/* Public functions */ /**
@@ -930,6 +1009,118 @@ int pwrdm_post_transition(void)return 0 ; } +/* +* pwrdm_set_wkup_lat_constraint - Set/update/remove a powerdomain wakeup +* latency constraint and apply it +* @pwrdm: struct powerdomain * which the constraint applies to +* @cookie: constraint identifier, used for tracking. +* @min_latency: minimum wakeup latency constraint (in microseconds) for +* the given pwrdm. The value of PM_QOS_DEV_LAT_DEFAULT_VALUE removes +* the constraint. +* +* Tracks the constraints by @cookie. +* Constraint set/update: Adds a new entry to powerdomain's wake-up latency +* constraint list. +* If the constraint identifier already exists in the list, the old value is +* overwritten. +* Constraint removal: Removes the identifier's entry from powerdomain's +* wakeup latency constraint list. +* +* Applies the strongest constraint value for the given pwrdm by calling +* pwrdm_wakeuplat_update_pwrst. +* +* Returns 0 upon success or a negative value in case of error. +* +* The caller must check the validity of the parameters. +*/ +int pwrdm_set_wkup_lat_constraint (struct powerdomain *pwrdm,void *cookie, +long min_latency) +{ +struct pwrdm_wkup_constraints_entry *user =NULL ; +struct pwrdm_wkup_constraints_entry *tmp_user, *new_user =NULL ; +int ret =0 , free_new_user =0 , free_node =0 ; +long value =PM_QOS_DEV_LAT_DEFAULT_VALUE ; +unsigned long flags; + +pr_debug ("powerdomain: %s: pwrdm %s, cookie=0x%p, min_latency=%ld\n" , + __func__, pwrdm->name, cookie, min_latency); + +if (min_latency !=PM_QOS_DEV_LAT_DEFAULT_VALUE ) { + new_user =kzalloc (sizeof (struct pwrdm_wkup_constraints_entry ), +GFP_KERNEL ); +if (!new_user) { +pr_err ("%s: FATAL ERROR: kzalloc failed\n" , __func__); +return -ENOMEM ; + } + free_new_user =1 ; + } + +spin_lock_irqsave (&pwrdm->wkup_lat_plist_lock, flags); + +/* Check if there already is a constraint for cookie */ +plist_for_each_entry (tmp_user, &pwrdm->wkup_lat_plist_head, node) { +if (tmp_user->cookie == cookie) { + user = tmp_user; +break ; + } + } + +if (min_latency !=PM_QOS_DEV_LAT_DEFAULT_VALUE ) { +/* If nothing to update, job done */ +if (user && (user->node.prio == min_latency)) + goto exit_ok; + +if (!user) { +/* Add new entry to the list */ + user = new_user; + user->cookie = cookie; + free_new_user =0 ; + }else { +/* Update existing entry */ +plist_del (&user->node, &pwrdm->wkup_lat_plist_head); + } + +plist_node_init (&user->node, min_latency); +plist_add (&user->node, &pwrdm->wkup_lat_plist_head); + }else { +if (user) { +/* Remove the constraint from the list */ +plist_del (&user->node, &pwrdm->wkup_lat_plist_head); + free_node =1 ; + }else { +/* Constraint not existing or list empty, do nothing */ + ret = -EINVAL ; + goto exit_error; + } + + } + +exit_ok: +/* Find the strongest constraint from the list */ +if (!plist_head_empty (&pwrdm->wkup_lat_plist_head)) + value =plist_first (&pwrdm->wkup_lat_plist_head)->prio; + +spin_unlock_irqrestore (&pwrdm->wkup_lat_plist_lock, flags); + +if (free_node) +kfree (user); + +if (free_new_user) +kfree (new_user); + +/* Apply the constraint to the pwrdm */ +pr_debug ("powerdomain: %s: pwrdm %s, value=%ld\n" , + __func__, pwrdm->name, value); +pwrdm_wakeuplat_update_pwrst (pwrdm, value); + +return 0 ; + +exit_error: +spin_unlock_irqrestore (&pwrdm->wkup_lat_plist_lock, flags); + +return ret; +} +/** * pwrdm_get_context_loss_count - get powerdomain's context loss count * @pwrdm: struct powerdomain * to wait for
arch/arm/mach-omap2/powerdomain.h +31 -2
@@ -19,7 +19,9 @@#include <linux/types.h> #include <linux/list.h> - +#include <linux/plist.h> +#include <linux/mutex.h> +#include <linux/spinlock.h> #include <linux/atomic.h> #include <plat/cpu.h>
@@ -43,6 +45,16 @@#define PWRSTS_RET_ON (PWRSTS_RET | PWRSTS_ON)#define PWRSTS_OFF_RET_ON (PWRSTS_OFF_RET | PWRSTS_ON) +/* Powerdomain functional power states */ +#define PWRDM_FUNC_PWRST_OFF 0x0 +#define PWRDM_FUNC_PWRST_OSWR 0x1 +#define PWRDM_FUNC_PWRST_CSWR 0x2 +#define PWRDM_FUNC_PWRST_INACTIVE 0x3 +#define PWRDM_FUNC_PWRST_ON 0x4 + +#define PWRDM_MAX_FUNC_PWRSTS 5 + +#define UNSUP_STATE -1/* Powerdomain flags */ #define PWRDM_HAS_HDWR_SAR (1 << 0)/* hardware save-and-restore support */
@@ -93,7 +105,12 @@ struct powerdomain;* @state_counter: * @timer: * @state_timer: -* +* @wakeup_lat: wakeup latencies (in us) for possible powerdomain power states +* Note about the wakeup latencies ordering: the values must be sorted +* in decremental order +* @wkup_lat_plist_head: pwrdm wake-up latency constraints list +* @wkup_lat_plist_lock: spinlock that protects the constraints lists +* domains states * @prcm_partition possible values are defined in mach-omap2/prcm44xx.h. */ struct powerdomain {
@@ -118,6 +135,15 @@ struct powerdomain {s64 timer;s64 state_timer[PWRDM_MAX_PWRSTS ];#endif +const u32 wakeup_lat[PWRDM_MAX_FUNC_PWRSTS ]; +struct plist_head wkup_lat_plist_head; +spinlock_t wkup_lat_plist_lock; +}; + +/* Linked list for the wake-up latency constraints */ +struct pwrdm_wkup_constraints_entry { +void *cookie; +struct plist_node node; };/**
@@ -207,6 +233,9 @@ int pwrdm_clkdm_state_switch(struct clockdomain *clkdm);int pwrdm_pre_transition (void );int pwrdm_post_transition (void );int pwrdm_set_lowpwrstchange (struct powerdomain *pwrdm); + +int pwrdm_set_wkup_lat_constraint (struct powerdomain *pwrdm,void *cookie, +long min_latency);u32 pwrdm_get_context_loss_count (struct powerdomain *pwrdm);bool pwrdm_can_ever_lose_context (struct powerdomain *pwrdm);
Signature · 1 line
1.7.2.5
PATCH v4 11/15 OMAP3: powerdomain data: add wake-up latency figures
In reply to [email protected]From: Jean Pihet <[email protected]>
Figures are added to the power domains structs.
Note: the figures are preliminary figures. More accurate measurements are needed. Also the conditions of measurements shall be investigated and described.
Tested on OMAP3 Beagleboard in RET/OFF using wake-up latency constraints on MPU, CORE and PER.
--- arch/arm/mach-omap2/powerdomains3xxx_data.c | 77 +++++++++++++++++++++++++++ 1 files changed, 77 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/powerdomains3xxx_data.c +77 -0
@@ -31,6 +31,13 @@/* * Powerdomains +* +* The wakeup_lat values are derived from measurements on +* the actual target. +* +* Note: the latency figures are preliminary and only used +* for the constraints framework validation. +* Actual figures and measurements conditions shall be added. */ static struct powerdomain iva2_pwrdm = {
@@ -52,6 +59,13 @@ static struct powerdomain iva2_pwrdm = { [2] = PWRSTS_OFF_ON, [3] = PWRSTS_ON, }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1100, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 350, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };static struct powerdomain mpu_3xxx_pwrdm = {
@@ -68,6 +82,13 @@ static struct powerdomain mpu_3xxx_pwrdm = { .pwrsts_mem_on = { [0] = PWRSTS_OFF_ON, }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 95, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 45, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/*
@@ -98,6 +119,13 @@ static struct powerdomain core_3xxx_pre_es3_1_pwrdm = { [0] = PWRSTS_OFF_RET_ON, /* MEM1ONSTATE */ [1 ] =PWRSTS_OFF_RET_ON ,/* MEM2ONSTATE */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 100, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 60, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, }; static struct powerdomain core_3xxx_es3_1_pwrdm = {
@@ -121,6 +149,13 @@ static struct powerdomain core_3xxx_es3_1_pwrdm = { [0] = PWRSTS_OFF_RET_ON, /* MEM1ONSTATE */ [1 ] =PWRSTS_OFF_RET_ON ,/* MEM2ONSTATE */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 100, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 60, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, }; static struct powerdomain dss_pwrdm = {
@@ -136,6 +171,13 @@ static struct powerdomain dss_pwrdm = { .pwrsts_mem_on = { [0 ] =PWRSTS_ON ,/* MEMONSTATE */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 70, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 20, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/*
@@ -157,6 +199,13 @@ static struct powerdomain sgx_pwrdm = { .pwrsts_mem_on = { [0 ] =PWRSTS_ON ,/* MEMONSTATE */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, }; static struct powerdomain cam_pwrdm = {
@@ -172,6 +221,13 @@ static struct powerdomain cam_pwrdm = { .pwrsts_mem_on = { [0 ] =PWRSTS_ON ,/* MEMONSTATE */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 850, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 35, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, }; static struct powerdomain per_pwrdm = {
@@ -187,6 +243,13 @@ static struct powerdomain per_pwrdm = { .pwrsts_mem_on = { [0 ] =PWRSTS_ON ,/* MEMONSTATE */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 200, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 110, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, }; static struct powerdomain emu_pwrdm = {
@@ -201,6 +264,13 @@ static struct powerdomain neon_pwrdm = { .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430), .pwrsts = PWRSTS_OFF_RET_ON, .pwrsts_logic_ret = PWRSTS_RET, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 200, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 35, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };static struct powerdomain usbhost_pwrdm = {
@@ -223,6 +293,13 @@ static struct powerdomain usbhost_pwrdm = { .pwrsts_mem_on = { [0 ] =PWRSTS_ON ,/* MEMONSTATE */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 800, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 150, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, }; static struct powerdomain dpll1_pwrdm = {
Signature · 1 line
1.7.2.5
PATCH v4 12/15 OMAP4: powerdomain data: add wake-up latency figures
In reply to [email protected]From: Vishwanath BS <[email protected]>
This patch adds wake up latency numbers for OMAP4. Note that these are preliminary numbers and need to be relooked.
The INACTIVE state is added as unsupported.
Tested on OMAP4 Pandaboard in RET/OFF using wake-up latency constraints on MPU, CORE and PER.
--- arch/arm/mach-omap2/powerdomains44xx_data.c | 84 +++++++++++++++++++++++++++ 1 files changed, 84 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/powerdomains44xx_data.c +84 -0
@@ -54,6 +54,13 @@ static struct powerdomain core_44xx_pwrdm = { [4] = PWRSTS_ON, /* ducati_unicache */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* gfx_44xx_pwrdm: 3D accelerator power domain */
@@ -71,6 +78,13 @@ static struct powerdomain gfx_44xx_pwrdm = { [0] = PWRSTS_ON, /* gfx_mem */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* abe_44xx_pwrdm: Audio back end power domain */
@@ -91,6 +105,13 @@ static struct powerdomain abe_44xx_pwrdm = { [1] = PWRSTS_ON, /* periphmem */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* dss_44xx_pwrdm: Display subsystem power domain */
@@ -109,6 +130,13 @@ static struct powerdomain dss_44xx_pwrdm = { [0] = PWRSTS_ON, /* dss_mem */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* tesla_44xx_pwrdm: Tesla processor power domain */
@@ -131,6 +159,13 @@ static struct powerdomain tesla_44xx_pwrdm = { [2] = PWRSTS_ON, /* tesla_l2 */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* wkup_44xx_pwrdm: Wake-up power domain */
@@ -164,6 +199,13 @@ static struct powerdomain cpu0_44xx_pwrdm = { .pwrsts_mem_on = { [0 ] =PWRSTS_ON ,/* cpu0_l1 */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* cpu1_44xx_pwrdm: MPU1 processor and Neon coprocessor power domain */
@@ -181,6 +223,13 @@ static struct powerdomain cpu1_44xx_pwrdm = { .pwrsts_mem_on = { [0 ] =PWRSTS_ON ,/* cpu1_l1 */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* emu_44xx_pwrdm: Emulation power domain */
@@ -218,6 +267,13 @@ static struct powerdomain mpu_44xx_pwrdm = { [1] = PWRSTS_ON, /* mpu_l2 */ [2] = PWRSTS_ON, /* mpu_ram */ }, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* ivahd_44xx_pwrdm: IVA-HD power domain */
@@ -242,6 +298,13 @@ static struct powerdomain ivahd_44xx_pwrdm = { [3] = PWRSTS_ON, /* tcm2_mem */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* cam_44xx_pwrdm: Camera subsystem power domain */
@@ -259,6 +322,13 @@ static struct powerdomain cam_44xx_pwrdm = { [0] = PWRSTS_ON, /* cam_mem */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_CSWR] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* l3init_44xx_pwrdm: L3 initators pheripherals power domain */
@@ -277,6 +347,13 @@ static struct powerdomain l3init_44xx_pwrdm = { [0] = PWRSTS_ON, /* l3init_bank1 */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = 1000, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/* l4per_44xx_pwrdm: Target peripherals power domain */
@@ -297,6 +374,13 @@ static struct powerdomain l4per_44xx_pwrdm = { [1] = PWRSTS_ON, /* retained_bank */ }, .flags = PWRDM_HAS_LOWPOWERSTATECHANGE, + .wakeup_lat = { + [PWRDM_FUNC_PWRST_OFF] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_OSWR] = 600, + [PWRDM_FUNC_PWRST_CSWR] = 300, + [PWRDM_FUNC_PWRST_INACTIVE] = UNSUP_STATE, + [PWRDM_FUNC_PWRST_ON] = 0, + }, };/*
Signature · 1 line
1.7.2.5
PATCH v4 13/15 OMAP2+: omap_hwmod: manage the wake-up latency constraints
In reply to [email protected]From: Jean Pihet <[email protected]>
Hwmod is queried from the OMAP_PM layer to manage the power domains wake-up latency constraints. Hwmod retrieves the correct power domain and if it exists it calls the corresponding power domain function.
Tested on OMAP3 Beagleboard and OMAP4 Pandaboard in RET/OFF using wake-up latency constraints on MPU, CORE and PER.
--- arch/arm/mach-omap2/omap_hwmod.c | 26 +++++++++++++++++++++++++- arch/arm/plat-omap/include/plat/omap_hwmod.h | 2 ++ 2 files changed, 27 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/omap_hwmod.c +25 -1
@@ -143,6 +143,7 @@#include "powerdomain.h" #include <plat/clock.h> #include <plat/omap_hwmod.h> +#include <plat/omap_device.h> #include <plat/prcm.h> #include "cm2xxx_3xxx.h"
@@ -2618,11 +2619,34 @@ ohsps_unlock:return ret; } +/* +* omap_hwmod_set_wkup_constraint- set/release a wake-up latency constraint +* +* @oh: struct omap_hwmod* to which the target device belongs to. +* @cookie: identifier of the constraints list for @oh. +* @min_latency: the minimum allowed wake-up latency for @oh. +* +* Returns 0 upon success. +*/ +int omap_hwmod_set_wkup_lat_constraint (struct omap_hwmod *oh, +void *cookie,long min_latency) +{ +struct powerdomain *pwrdm =omap_hwmod_get_pwrdm (oh); + +if (!pwrdm) { +pr_err ("%s: Error: could not find powerdomain " +"for %s\n" , __func__, oh->name); +return -EINVAL ; + } + +return pwrdm_set_wkup_lat_constraint (pwrdm, cookie, min_latency); +} +/** * omap_hwmod_get_context_loss_count - get lost context count * @oh: struct omap_hwmod * * -* Query the powerdomain of of @oh to get the context loss +* Query the powerdomain of @oh to get the context loss * count for this device. * * Returns the context loss count of the powerdomain assocated with @oh
arch/arm/plat-omap/include/plat/omap_hwmod.h +2 -0
@@ -603,6 +603,8 @@ int omap_hwmod_for_each_by_class(const char *classname, void *user);int omap_hwmod_set_postsetup_state (struct omap_hwmod *oh,u8 state); +int omap_hwmod_set_wkup_lat_constraint (struct omap_hwmod *oh,void *cookie, +long min_latency);u32 omap_hwmod_get_context_loss_count (struct omap_hwmod *oh);int omap_hwmod_no_setup_reset (struct omap_hwmod *oh);
Signature · 1 line
1.7.2.5
PATCH v4 14/15 OMAP: PM CONSTRAINTS: implement the devices wake-up latency constraints
In reply to [email protected]From: Jean Pihet <[email protected]>
Implement the devices wake-up latency constraints using the global device PM QoS notification handler which applies the constraints to the underlying layer by calling the corresponding function at hwmod level.
Note: the bus throughput function is implemented but currently is a no-op. A new PM QoS class for the bus throughput needs to be added.
Tested on OMAP3 Beagleboard and OMAP4 Pandaboard in RET/OFF using wake-up latency constraints on MPU, CORE and PER.
--- arch/arm/plat-omap/include/plat/omap-pm.h | 128 --------------------- arch/arm/plat-omap/omap-pm-constraints.c | 173 +++++++++++++--------------- arch/arm/plat-omap/omap-pm-noop.c | 89 --------------- 3 files changed, 80 insertions(+), 310 deletions(-)
arch/arm/plat-omap/include/plat/omap-pm.h +0 -128
@@ -62,136 +62,8 @@ void omap_pm_if_exit(void);* Device-driver-originated constraints (via board-*.c files, platform_data) */ - -/** -* omap_pm_set_max_mpu_wakeup_lat - set the maximum MPU wakeup latency -* @dev: struct device * requesting the constraint -* @t: maximum MPU wakeup latency in microseconds -* -* Request that the maximum interrupt latency for the MPU to be no -* greater than @t microseconds. "Interrupt latency" in this case is -* defined as the elapsed time from the occurrence of a hardware or -* timer interrupt to the time when the device driver's interrupt -* service routine has been entered by the MPU. -* -* It is intended that underlying PM code will use this information to -* determine what power state to put the MPU powerdomain into, and -* possibly the CORE powerdomain as well, since interrupt handling -* code currently runs from SDRAM. Advanced PM or board*.c code may -* also configure interrupt controller priorities, OCP bus priorities, -* CPU speed(s), etc. -* -* This function will not affect device wakeup latency, e.g., time -* elapsed from when a device driver enables a hardware device with -* clk_enable(), to when the device is ready for register access or -* other use. To control this device wakeup latency, use -* omap_pm_set_max_dev_wakeup_lat() -* -* Multiple calls to omap_pm_set_max_mpu_wakeup_lat() will replace the -* previous t value. To remove the latency target for the MPU, call -* with t = -1. -* -* XXX This constraint will be deprecated soon in favor of the more -* general omap_pm_set_max_dev_wakeup_lat() -* -* Returns -EINVAL for an invalid argument, -ERANGE if the constraint -* is not satisfiable, or 0 upon success. -*/ -int omap_pm_set_max_mpu_wakeup_lat (struct device *dev,long t); - - -/** -* omap_pm_set_min_bus_tput - set minimum bus throughput needed by device -* @dev: struct device * requesting the constraint -* @tbus_id: interconnect to operate on (OCP_{INITIATOR,TARGET}_AGENT) -* @r: minimum throughput (in KiB/s) -* -* Request that the minimum data throughput on the OCP interconnect -* attached to device @dev interconnect agent @tbus_id be no less -* than @r KiB/s. -* -* It is expected that the OMAP PM or bus code will use this -* information to set the interconnect clock to run at the lowest -* possible speed that satisfies all current system users. The PM or -* bus code will adjust the estimate based on its model of the bus, so -* device driver authors should attempt to specify an accurate -* quantity for their device use case, and let the PM or bus code -* overestimate the numbers as necessary to handle request/response -* latency, other competing users on the system, etc. On OMAP2/3, if -* a driver requests a minimum L4 interconnect speed constraint, the -* code will also need to add an minimum L3 interconnect speed -* constraint, -* -* Multiple calls to omap_pm_set_min_bus_tput() will replace the -* previous rate value for this device. To remove the interconnect -* throughput restriction for this device, call with r = 0. -* -* Returns -EINVAL for an invalid argument, -ERANGE if the constraint -* is not satisfiable, or 0 upon success. -*/ int omap_pm_set_min_bus_tput (struct device *dev,u8 agent_id,unsigned long r); - -/** -* omap_pm_set_max_dev_wakeup_lat - set the maximum device enable latency -* @req_dev: struct device * requesting the constraint, or NULL if none -* @dev: struct device * to set the constraint one -* @t: maximum device wakeup latency in microseconds -* -* Request that the maximum amount of time necessary for a device @dev -* to become accessible after its clocks are enabled should be no -* greater than @t microseconds. Specifically, this represents the -* time from when a device driver enables device clocks with -* clk_enable(), to when the register reads and writes on the device -* will succeed. This function should be called before clk_disable() -* is called, since the power state transition decision may be made -* during clk_disable(). -* -* It is intended that underlying PM code will use this information to -* determine what power state to put the powerdomain enclosing this -* device into. -* -* Multiple calls to omap_pm_set_max_dev_wakeup_lat() will replace the -* previous wakeup latency values for this device. To remove the -* wakeup latency restriction for this device, call with t = -1. -* -* Returns -EINVAL for an invalid argument, -ERANGE if the constraint -* is not satisfiable, or 0 upon success. -*/ -int omap_pm_set_max_dev_wakeup_lat (struct device *req_dev,struct device *dev, -long t); - - -/** -* omap_pm_set_max_sdma_lat - set the maximum system DMA transfer start latency -* @dev: struct device * -* @t: maximum DMA transfer start latency in microseconds -* -* Request that the maximum system DMA transfer start latency for this -* device 'dev' should be no greater than 't' microseconds. "DMA -* transfer start latency" here is defined as the elapsed time from -* when a device (e.g., McBSP) requests that a system DMA transfer -* start or continue, to the time at which data starts to flow into -* that device from the system DMA controller. -* -* It is intended that underlying PM code will use this information to -* determine what power state to put the CORE powerdomain into. -* -* Since system DMA transfers may not involve the MPU, this function -* will not affect MPU wakeup latency. Use set_max_cpu_lat() to do -* so. Similarly, this function will not affect device wakeup latency -* -- use set_max_dev_wakeup_lat() to affect that. -* -* Multiple calls to set_max_sdma_lat() will replace the previous t -* value for this device. To remove the maximum DMA latency for this -* device, call with t = -1. -* -* Returns -EINVAL for an invalid argument, -ERANGE if the constraint -* is not satisfiable, or 0 upon success. -*/ -int omap_pm_set_max_sdma_lat (struct device *dev,long t); - -/** * omap_pm_set_min_clk_rate - set minimum clock rate requested by @dev * @dev: struct device * requesting the constraint
arch/arm/plat-omap/omap-pm-constraints.c +80 -93
222 lines not on this page · raw message
arch/arm/plat-omap/omap-pm-noop.c +0 -89
101 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH v4 15/15 OMAP2+: cpuidle only influences the MPU state
In reply to [email protected]From: Jean Pihet <[email protected]>
Since cpuidle is a CPU centric framework it decides the MPU next power state based on the MPU exit_latency and target_residency figures.
The rest of the power domains get their next power state programmed from the devices PM QoS framework, via the devices wake-up latency constraints.
Note: the exit_latency and target_residency figures of the MPU include the MPU itself and the peripherals needed for the MPU to execute instructions (e.g. main memory, caches, IRQ controller, MMU etc). Some of those peripherals can belong to other power domains than the MPU subsystem and so the corresponding latencies must be included in this figure.
Tested on OMAP3 Beagleboard in RET/OFF using wake-up latency constraints on MPU, CORE and PER.
--- arch/arm/mach-omap2/cpuidle34xx.c | 42 +++++++++++------------------------- arch/arm/mach-omap2/pm.h | 17 +++++++++++++- 2 files changed, 28 insertions(+), 31 deletions(-)
arch/arm/mach-omap2/cpuidle34xx.c +13 -29
@@ -37,26 +37,26 @@#ifdef CONFIG_CPU_IDLE /* -* The latencies/thresholds for various C states have +* The MPU latencies/thresholds for various C states have * to be configured from the respective board files. * These are some default values (which might not provide * the best power savings) used on boards which do not * pass these details from the board file. */ static struct cpuidle_params cpuidle_params_table[] = { -/* C1 */ +/* C1 . MPU WFI + Core active */ {2 +2 ,5 ,1 }, -/* C2 */ +/* C2 . MPU WFI + Core inactive */ {10 +10 ,30 ,1 }, -/* C3 */ +/* C3 . MPU CSWR + Core inactive */ {50 +50 ,300 ,1 }, -/* C4 */ +/* C4 . MPU OFF + Core inactive */ {1500 +1800 ,4000 ,1 }, -/* C5 */ +/* C5 . MPU RET + Core RET */ {2500 +7500 ,12000 ,1 }, -/* C6 */ +/* C6 . MPU OFF + Core RET */ {3000 +8500 ,15000 ,1 }, -/* C7 */ +/* C7 . MPU OFF + Core OFF */ {10000 +30000 ,300000 ,1 }, };#define OMAP3_NUM_STATES ARRAY_SIZE(cpuidle_params_table)
@@ -64,7 +64,6 @@ static struct cpuidle_params cpuidle_params_table[] = {/* Mach specific information to be recorded in the C-state driver_data */ struct omap3_idle_statedata {u32 mpu_state; -u32 core_state;u8 valid; };struct omap3_idle_statedata omap3_idle_data[OMAP3_NUM_STATES ];
@@ -98,7 +97,7 @@ static int omap3_enter_idle(struct cpuidle_device *dev, {struct omap3_idle_statedata *cx =cpuidle_get_statedata (state);struct timespec ts_preidle, ts_postidle, ts_idle; -u32 mpu_state = cx->mpu_state, core_state = cx->core_state; +u32 mpu_state = cx->mpu_state;/* Used to keep track of the total time in idle */ getnstimeofday (&ts_preidle);
@@ -107,7 +106,6 @@ static int omap3_enter_idle(struct cpuidle_device *dev,local_fiq_disable ();pwrdm_set_next_pwrst (mpu_pd, mpu_state); -pwrdm_set_next_pwrst (core_pd, core_state);if (omap_irq_pending () ||need_resched ()) goto return_sleep_time;
@@ -156,6 +154,7 @@ static struct cpuidle_state *next_valid_state(struct cpuidle_device *dev,struct omap3_idle_statedata *cx =cpuidle_get_statedata (curr);u32 mpu_deepest_state =PWRDM_POWER_RET ;u32 core_deepest_state =PWRDM_POWER_RET ; +u32 core_next_state =pwrdm_read_next_pwrst (core_pd);if (enable_off_mode) { mpu_deepest_state =PWRDM_POWER_OFF ;
@@ -171,7 +170,7 @@ static struct cpuidle_state *next_valid_state(struct cpuidle_device *dev,/* Check if current state is valid */ if ((cx->valid) && (cx->mpu_state >= mpu_deepest_state) && - (cx->core_state >= core_deepest_state)) { + (core_next_state >= core_deepest_state)) {return curr; }else {int idx =OMAP3_NUM_STATES -1 ;
@@ -196,7 +195,7 @@ static struct cpuidle_state *next_valid_state(struct cpuidle_device *dev, cx =cpuidle_get_statedata (&dev->states[idx]);if ((cx->valid) && (cx->mpu_state >= mpu_deepest_state) && - (cx->core_state >= core_deepest_state)) { + (core_next_state >= core_deepest_state)) { next = &dev->states[idx];break ; }
@@ -242,19 +241,11 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev, }/* -* FIXME: we currently manage device-specific idle states -* for PER and CORE in combination with CPU-specific -* idle states. This is wrong, and device-specific -* idle management needs to be separated out into -* its own code. -*/ - -/* * Prevent PER off if CORE is not in retention or off as this * would disable PER wakeups completely. */ cx =cpuidle_get_statedata (state); - core_next_state = cx->core_state; + core_next_state =pwrdm_read_next_pwrst (core_pd); per_next_state = per_saved_state =pwrdm_read_next_pwrst (per_pd);if ((per_next_state ==PWRDM_POWER_OFF ) && (core_next_state >PWRDM_POWER_RET ))
@@ -346,32 +337,26 @@ int __init omap3_idle_init(void) dev->safe_state = &dev->states[0 ]; cx->valid =1 ;/* C1 is always valid */ cx->mpu_state =PWRDM_POWER_ON ; - cx->core_state =PWRDM_POWER_ON ;/* C2 . MPU WFI + Core inactive */ cx =_fill_cstate (dev,1 ,"MPU ON + CORE ON" ); cx->mpu_state =PWRDM_POWER_ON ; - cx->core_state =PWRDM_POWER_ON ;/* C3 . MPU CSWR + Core inactive */ cx =_fill_cstate (dev,2 ,"MPU RET + CORE ON" ); cx->mpu_state =PWRDM_POWER_RET ; - cx->core_state =PWRDM_POWER_ON ;/* C4 . MPU OFF + Core inactive */ cx =_fill_cstate (dev,3 ,"MPU OFF + CORE ON" ); cx->mpu_state =PWRDM_POWER_OFF ; - cx->core_state =PWRDM_POWER_ON ;/* C5 . MPU RET + Core RET */ cx =_fill_cstate (dev,4 ,"MPU RET + CORE RET" ); cx->mpu_state =PWRDM_POWER_RET ; - cx->core_state =PWRDM_POWER_RET ;/* C6 . MPU OFF + Core RET */ cx =_fill_cstate (dev,5 ,"MPU OFF + CORE RET" ); cx->mpu_state =PWRDM_POWER_OFF ; - cx->core_state =PWRDM_POWER_RET ;/* C7 . MPU OFF + Core OFF */ cx =_fill_cstate (dev,6 ,"MPU OFF + CORE OFF" );
@@ -386,7 +371,6 @@ int __init omap3_idle_init(void) __func__); } cx->mpu_state =PWRDM_POWER_OFF ; - cx->core_state =PWRDM_POWER_OFF ; dev->state_count =OMAP3_NUM_STATES ;if (cpuidle_register_device (dev)) {
arch/arm/mach-omap2/pm.h +15 -2
@@ -43,9 +43,22 @@ static inline int omap4_opp_init(void)* omap3_pm_init_cpuidle */ struct cpuidle_params { -u32 exit_latency;/* exit_latency = sleep + wake-up latencies */ +/* +* exit_latency = sleep + wake-up latencies of the MPU, +* which include the MPU itself and the peripherals needed +* for the MPU to execute instructions (e.g. main memory, +* caches, IRQ controller, MMU etc). Some of those peripherals +* can belong to other power domains than the MPU subsystem and so +* the corresponding latencies must be included in this figure. +*/ +u32 exit_latency; +/* +* target_residency: required amount of time in the C state +* to break even on energy cost +*/ u32 target_residency; -u8 valid;/* validates the C-state */ +/* validates the C-state on the given board */ +u8 valid; };#if defined(CONFIG_PM ) && defined(CONFIG_CPU_IDLE )
Signature · 1 line
1.7.2.5
Quoted 70 lines · On Thursday, August 11, 2011, [email protected] wrote:
From: Jean Pihet <[email protected]>
This patch set is in an RFC state, for review and comments.
High level implementation:
1. Preparation of the PM QoS for the addition of a device PM QoS constraints framework:
. rename and move of the PM QoS implementation files tokernel/power/qos.c
andinclude/linux/pm_qos.h
. rename of API parameters and internal fields names
. Move around the PM QoS misc devices management code for better readability . re-organize the internal data structs
. generalize and export the constraints management core code2. Implementation of the per-device PM QoS constraints:
. createdrivers/base/power/qos.cfor the implementation
. create a device PM QoS API, which calls the PM QoS constraints management
core code
. the per-device latency constraints data strctures are stored in the device
dev_pm_infostruct
. the device PM code calls the init and destroy of the per-device constraints
data struct in order to support the dynamic insertion and removal of the devices in the system.
. to minimize the data usage by the per-device constraints, the data struct
is only allocated at the first call todev_pm_qos_add_request. The data is later free'd when the device is removed from the system
. per-device notification callbacks can be registered and called upon a
change to the aggregated constraint value3. add a global notification mechanism for the device constraints . add a global notification chain that gets called upon changes to the aggregated constraint value for any device.
. the notification callbacks are passing the full constraint request data
in order for the callees to have access to it. The current use is for the platform low-level code to access the target device of the constraint4. Implement the OMAP low level constraints management code
. create a PM layer plugin for per-device constraints, compiled under
CONFIG_OMAP_PM_CONSTRAINTS=y
. implement the devices wake-up latency constraints using the global
device PM QoS notification handler which applies the constraints to the underlying layer
. implement the low level code which controls the power domains next power
states, through the hwmod and pwrdm layers
. add (preliminary) power domains wake-up latency figures for OMAP3&4 . cpuidle is a CPU centric framework so it decides the MPU next power state
based on the MPUexit_latencyandtarget_residencyfigures. The rest of the power domains get their next power state programmed from the devices PM QoS framework, via the devices wake-up latency constraints.
. convert the OMAP I2C driver to the PM QoS API for MPU latency constraintsQuestions:
1. the user space API is still under discussions on linux-omap and linux-pm MLs, cf. [1]. The idea is to add a user-space API for the devices constratins PM QoS, using a sysfs entry per device[1] http://marc.info/?l=linux-omap&m=131232344503327&w=2
ToDo:
1. write Documentation for the new PM QoS class, once the RFC is agreed on
2. validate the constraints framework on OMAP4 HW (done on OMAP3)
3. Need testing on platforms other than OMAP
4. refine the power domains wake-up latency and the cpuidle figures
5. re-visit the OMAP power domains states initialization procedure. Currently the power states that have been changed from the constraints API which were applied before the initialization of the power domains are lost
Quoted 6 lines
Based on the master branch of the linux-omap git tree (3.0.0-rc7). Compile tested using OMAP and x86 generic defconfigs.
Lightly tested on OMAP3 Beagleboard (ES2.x).
Need testing on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/remove
The patchset looks really good to me, I don't think I have any major complaints about this version.
The only thing I'd like to ask at the moment is whether or not the compilation of drivers/base/power/qos.c should depend on CONFIG_PM_RUNTIME. Do you think it will be used by system suspend code on any platforms?
Also, I'd like to take the final patchset for 3.2, but I don't feel confident enough about the OMAP patches. If you want me to take them too, please make sure they are ACKed by the OMAP maintainers.
Thanks,
Rafael
Quoted 70 lines · On Thursday, August 11, 2011, [email protected] wrote:
From: Jean Pihet <[email protected]>
This patch set is in an RFC state, for review and comments.
High level implementation:
1. Preparation of the PM QoS for the addition of a device PM QoS constraints framework:
. rename and move of the PM QoS implementation files tokernel/power/qos.c
andinclude/linux/pm_qos.h
. rename of API parameters and internal fields names
. Move around the PM QoS misc devices management code for better readability . re-organize the internal data structs
. generalize and export the constraints management core code2. Implementation of the per-device PM QoS constraints:
. createdrivers/base/power/qos.cfor the implementation
. create a device PM QoS API, which calls the PM QoS constraints management
core code
. the per-device latency constraints data strctures are stored in the device
dev_pm_infostruct
. the device PM code calls the init and destroy of the per-device constraints
data struct in order to support the dynamic insertion and removal of the devices in the system.
. to minimize the data usage by the per-device constraints, the data struct
is only allocated at the first call todev_pm_qos_add_request. The data is later free'd when the device is removed from the system
. per-device notification callbacks can be registered and called upon a
change to the aggregated constraint value3. add a global notification mechanism for the device constraints . add a global notification chain that gets called upon changes to the aggregated constraint value for any device.
. the notification callbacks are passing the full constraint request data
in order for the callees to have access to it. The current use is for the platform low-level code to access the target device of the constraint4. Implement the OMAP low level constraints management code
. create a PM layer plugin for per-device constraints, compiled under
CONFIG_OMAP_PM_CONSTRAINTS=y
. implement the devices wake-up latency constraints using the global
device PM QoS notification handler which applies the constraints to the underlying layer
. implement the low level code which controls the power domains next power
states, through the hwmod and pwrdm layers
. add (preliminary) power domains wake-up latency figures for OMAP3&4 . cpuidle is a CPU centric framework so it decides the MPU next power state
based on the MPUexit_latencyandtarget_residencyfigures. The rest of the power domains get their next power state programmed from the devices PM QoS framework, via the devices wake-up latency constraints.
. convert the OMAP I2C driver to the PM QoS API for MPU latency constraintsQuestions:
1. the user space API is still under discussions on linux-omap and linux-pm MLs, cf. [1]. The idea is to add a user-space API for the devices constratins PM QoS, using a sysfs entry per device[1] http://marc.info/?l=linux-omap&m=131232344503327&w=2
ToDo:
1. write Documentation for the new PM QoS class, once the RFC is agreed on
2. validate the constraints framework on OMAP4 HW (done on OMAP3)
3. Need testing on platforms other than OMAP
4. refine the power domains wake-up latency and the cpuidle figures
5. re-visit the OMAP power domains states initialization procedure. Currently the power states that have been changed from the constraints API which were applied before the initialization of the power domains are lost
Quoted 6 lines
Based on the master branch of the linux-omap git tree (3.0.0-rc7). Compile tested using OMAP and x86 generic defconfigs.
Lightly tested on OMAP3 Beagleboard (ES2.x).
Need testing on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/remove
The patchset looks really good to me, I don't think I have any major complaints about this version.
The only thing I'd like to ask at the moment is whether or not the compilation of drivers/base/power/qos.c should depend on CONFIG_PM_RUNTIME. Do you think it will be used by system suspend code on any platforms?
Also, I'd like to take the final patchset for 3.2, but I don't feel confident enough about the OMAP patches. If you want me to take them too, please make sure they are ACKed by the OMAP maintainers.
Thanks,
Rafael
Hi Rafael,
2011/8/12 Rafael J. Wysocki <[email protected]>:
Quoted 5 lines · On Thursday, August 11, 2011, [email protected] wrote:
Quoted 4 lines
From: Jean Pihet <[email protected]>
This patch set is in an RFC state, for review and comments.
...
Quoted 22 lines
Quoted 22 lines
Questions:
1. the user space API is still under discussions on linux-omap and linux-pm MLs, cf. [1]. The idea is to add a user-space API for the devices constratins PM QoS, using a sysfs entry per device[1] http://marc.info/?l=linux-omap&m=131232344503327&w=2
ToDo:
1. write Documentation for the new PM QoS class, once the RFC is agreed on
2. validate the constraints framework on OMAP4 HW (done on OMAP3)
3. Need testing on platforms other than OMAP
4. refine the power domains wake-up latency and the cpuidle figures
5. re-visit the OMAP power domains states initialization procedure. Currently the power states that have been changed from the constraints API which were applied before the initialization of the power domains are lostBased on the master branch of the linux-omap git tree (3.0.0-rc7). Compile tested using OMAP and x86 generic defconfigs.
Quoted 6 lines
Quoted 3 lines
Lightly tested on OMAP3 Beagleboard (ES2.x).
Need testing on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/removeThe patchset looks really good to me, I don't think I have any major complaints about this version.
Ok good to hear it! I tried to address all comments and concerns in this release.
Quoted 5 lines
The only thing I'd like to ask at the moment is whether or not the compilation of
drivers/base/power/qos.cshould depend onCONFIG_PM_RUNTIME. Do you think it will be used by system suspend code on any platforms?
I would say it should only depend on CONFIG_PM because the dev PM QoS API can be used from any kernel code, being runtime PM code or not. I leave the decision to the PM framework experts.
Quoted 2 lines
Also, I'd like to take the final patchset for 3.2,
Ok good!
Quoted 2 lines
but I don't feel
confident enough about the OMAP patches.
The OMAP patches have been reviewed a few times already and the comments have been taken into account. Also i has been tested correctly on OMAP3.
Quoted 2 lines
If you want me to take them too,
please make sure they are ACKed by the OMAP maintainers.
For sure I need the Acks. I guess I now need to annoy OMAP folks about it ;p In the case the Acks are not gathered on time the generic patches could be merged in, then the OMAP generic code. Do you think it is a viable option?
The only concern I have is about the on-going OMAP PM initialization clean-up task, cf. ToDo list:
Quoted 1 line
Quoted 1 line
5. re-visit the OMAP power domains states initialization
procedure. Currently
Quoted 1 line
Quoted 1 line
the power states that have been changed from the constraints
API which were
Quoted 1 line
Quoted 1 line
applied before the initialization of the power domains are lost
On the other hand some testing is needed on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/remove functions. I tested the SD card insertion/removal on OMAP3.
Quoted 4 lines
Thanks,
Rafael
Thanks,
Jean
Hi Rafael,
2011/8/12 Rafael J. Wysocki <[email protected]>:
Quoted 5 lines · On Thursday, August 11, 2011, [email protected] wrote:
Quoted 4 lines
From: Jean Pihet <[email protected]>
This patch set is in an RFC state, for review and comments.
...
Quoted 22 lines
Quoted 22 lines
Questions:
1. the user space API is still under discussions on linux-omap and linux-pm MLs, cf. [1]. The idea is to add a user-space API for the devices constratins PM QoS, using a sysfs entry per device[1] http://marc.info/?l=linux-omap&m=131232344503327&w=2
ToDo:
1. write Documentation for the new PM QoS class, once the RFC is agreed on
2. validate the constraints framework on OMAP4 HW (done on OMAP3)
3. Need testing on platforms other than OMAP
4. refine the power domains wake-up latency and the cpuidle figures
5. re-visit the OMAP power domains states initialization procedure. Currently the power states that have been changed from the constraints API which were applied before the initialization of the power domains are lostBased on the master branch of the linux-omap git tree (3.0.0-rc7). Compile tested using OMAP and x86 generic defconfigs.
Quoted 6 lines
Quoted 3 lines
Lightly tested on OMAP3 Beagleboard (ES2.x).
Need testing on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/removeThe patchset looks really good to me, I don't think I have any major complaints about this version.
Ok good to hear it! I tried to address all comments and concerns in this release.
Quoted 5 lines
The only thing I'd like to ask at the moment is whether or not the compilation of
drivers/base/power/qos.cshould depend onCONFIG_PM_RUNTIME. Do you think it will be used by system suspend code on any platforms?
I would say it should only depend on CONFIG_PM because the dev PM QoS API can be used from any kernel code, being runtime PM code or not. I leave the decision to the PM framework experts.
Quoted 2 lines
Also, I'd like to take the final patchset for 3.2,
Ok good!
Quoted 2 lines
but I don't feel
confident enough about the OMAP patches.
The OMAP patches have been reviewed a few times already and the comments have been taken into account. Also i has been tested correctly on OMAP3.
Quoted 2 lines
If you want me to take them too,
please make sure they are ACKed by the OMAP maintainers.
For sure I need the Acks. I guess I now need to annoy OMAP folks about it ;p In the case the Acks are not gathered on time the generic patches could be merged in, then the OMAP generic code. Do you think it is a viable option?
The only concern I have is about the on-going OMAP PM initialization clean-up task, cf. ToDo list:
Quoted 1 line
Quoted 1 line
5. re-visit the OMAP power domains states initialization
procedure. Currently
Quoted 1 line
Quoted 1 line
the power states that have been changed from the constraints
API which were
Quoted 1 line
Quoted 1 line
applied before the initialization of the power domains are lost
On the other hand some testing is needed on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/remove functions. I tested the SD card insertion/removal on OMAP3.
Quoted 4 lines
Thanks,
Rafael
Thanks,
Jean
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi,
Quoted 59 lines · Jean Pihet
Hi Rafael,
2011/8/12 Rafael J. Wysocki <[email protected]>:
Quoted 5 lines · On Thursday, August 11, 2011, [email protected] wrote:
Quoted 4 lines
From: Jean Pihet <[email protected]>
This patch set is in an RFC state, for review and comments.
...
Quoted 22 lines
Quoted 22 lines
Questions:
1. the user space API is still under discussions on linux-omap and linux-pm MLs, cf. [1]. The idea is to add a user-space API for the devices constratins PM QoS, using a sysfs entry per device[1] http://marc.info/?l=linux-omap&m=131232344503327&w=2
ToDo:
1. write Documentation for the new PM QoS class, once the RFC is agreed on
2. validate the constraints framework on OMAP4 HW (done on OMAP3)
3. Need testing on platforms other than OMAP
4. refine the power domains wake-up latency and the cpuidle figures
5. re-visit the OMAP power domains states initialization procedure. Currently the power states that have been changed from the constraints API which were applied before the initialization of the power domains are lostBased on the master branch of the linux-omap git tree (3.0.0-rc7). Compile tested using OMAP and x86 generic defconfigs.
Quoted 6 lines
Quoted 3 lines
Lightly tested on OMAP3 Beagleboard (ES2.x).
Need testing on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/removeThe patchset looks really good to me, I don't think I have any major complaints about this version.
Ok good to hear it! I tried to address all comments and concerns in this release.
Quoted 5 lines
The only thing I'd like to ask at the moment is whether or not the compilation of
drivers/base/power/qos.cshould depend onCONFIG_PM_RUNTIME. Do you think it will be used by system suspend code on any platforms?I would say it should only depend on
CONFIG_PMbecause the dev PM QoS API can be used from any kernel code, being runtime PM code or not. I leave the decision to the PM framework experts.Quoted 2 lines
Also, I'd like to take the final patchset for 3.2,
Ok good!
Quoted 2 lines
but I don't feel
confident enough about the OMAP patches.The OMAP patches have been reviewed a few times already and the comments have been taken into account. Also i has been tested correctly on OMAP3.
Quoted 6 lines
Quoted 2 lines
If you want me to take them too,
please make sure they are ACKed by the OMAP maintainers.For sure I need the Acks. I guess I now need to annoy OMAP folks about it ;p In the case the Acks are not gathered on time the generic patches could be merged in, then the OMAP generic code. Do you think it is a viable option?
Yes, it is. I can take patches [1-7/15] alone.
Quoted 4 lines
The only concern I have is about the on-going OMAP PM initialization clean-up task, cf. ToDo list:
Quoted 1 line
Quoted 1 line
5. re-visit the OMAP power domains states initialization
procedure. Currently
Quoted 8 lines
Quoted 1 line
Quoted 1 line
the power states that have been changed from the constraints
API which were
Quoted 1 line
Quoted 1 line
applied before the initialization of the power domains are lost
On the other hand some testing is needed on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/remove functions. I tested the SD card insertion/removal on OMAP3.
OK, so are you going to make any more changes to patches [1-7/15]?
Rafael
Hi,
Quoted 59 lines · Jean Pihet
Hi Rafael,
2011/8/12 Rafael J. Wysocki <[email protected]>:
Quoted 5 lines · On Thursday, August 11, 2011, [email protected] wrote:
Quoted 4 lines
From: Jean Pihet <[email protected]>
This patch set is in an RFC state, for review and comments.
...
Quoted 22 lines
Quoted 22 lines
Questions:
1. the user space API is still under discussions on linux-omap and linux-pm MLs, cf. [1]. The idea is to add a user-space API for the devices constratins PM QoS, using a sysfs entry per device[1] http://marc.info/?l=linux-omap&m=131232344503327&w=2
ToDo:
1. write Documentation for the new PM QoS class, once the RFC is agreed on
2. validate the constraints framework on OMAP4 HW (done on OMAP3)
3. Need testing on platforms other than OMAP
4. refine the power domains wake-up latency and the cpuidle figures
5. re-visit the OMAP power domains states initialization procedure. Currently the power states that have been changed from the constraints API which were applied before the initialization of the power domains are lostBased on the master branch of the linux-omap git tree (3.0.0-rc7). Compile tested using OMAP and x86 generic defconfigs.
Quoted 6 lines
Quoted 3 lines
Lightly tested on OMAP3 Beagleboard (ES2.x).
Need testing on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/removeThe patchset looks really good to me, I don't think I have any major complaints about this version.
Ok good to hear it! I tried to address all comments and concerns in this release.
Quoted 5 lines
The only thing I'd like to ask at the moment is whether or not the compilation of
drivers/base/power/qos.cshould depend onCONFIG_PM_RUNTIME. Do you think it will be used by system suspend code on any platforms?I would say it should only depend on
CONFIG_PMbecause the dev PM QoS API can be used from any kernel code, being runtime PM code or not. I leave the decision to the PM framework experts.Quoted 2 lines
Also, I'd like to take the final patchset for 3.2,
Ok good!
Quoted 2 lines
but I don't feel
confident enough about the OMAP patches.The OMAP patches have been reviewed a few times already and the comments have been taken into account. Also i has been tested correctly on OMAP3.
Quoted 6 lines
Quoted 2 lines
If you want me to take them too,
please make sure they are ACKed by the OMAP maintainers.For sure I need the Acks. I guess I now need to annoy OMAP folks about it ;p In the case the Acks are not gathered on time the generic patches could be merged in, then the OMAP generic code. Do you think it is a viable option?
Yes, it is. I can take patches [1-7/15] alone.
Quoted 4 lines
The only concern I have is about the on-going OMAP PM initialization clean-up task, cf. ToDo list:
Quoted 1 line
Quoted 1 line
5. re-visit the OMAP power domains states initialization
procedure. Currently
Quoted 8 lines
Quoted 1 line
Quoted 1 line
the power states that have been changed from the constraints
API which were
Quoted 1 line
Quoted 1 line
applied before the initialization of the power domains are lost
On the other hand some testing is needed on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/remove functions. I tested the SD card insertion/removal on OMAP3.
OK, so are you going to make any more changes to patches [1-7/15]?
Rafael
Re: [PATCH 01/15] PM QoS: move and rename the implementation files
In reply to [email protected]Quoted 1,358 lines · On Thu, Aug 11, 2011 at 05:06:38PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
The PM QoS implementation files are better named
kernel/power/qos.candinclude/linux/pm_qos.h.The PM QoS support is compiled under the
CONFIG_PMoption.Signed-off-by Jean Pihet <[email protected]>--- arch/arm/mach-msm/clock.c | 2 +- drivers/acpi/processor_idle.c | 2 +- drivers/cpuidle/cpuidle.c | 2 +- drivers/cpuidle/governors/ladder.c | 2 +- drivers/cpuidle/governors/menu.c | 2 +- drivers/media/video/via-camera.c | 2 +- drivers/net/e1000e/netdev.c | 2 +- drivers/net/wireless/ipw2x00/ipw2100.c | 2 +- drivers/staging/msm/lcdc.c | 2 +- drivers/staging/msm/tvenc.c | 2 +- include/linux/netdevice.h | 2 +- include/linux/pm_qos.h | 61 ++++ include/linux/pm_qos_params.h | 38 --- include/sound/pcm.h | 2 +- kernel/Makefile | 2 +- kernel/pm_qos_params.c | 481 -------------------------------- kernel/power/Makefile | 2 +- kernel/power/qos.c | 481 ++++++++++++++++++++++++++++++++ net/mac80211/main.c | 2 +- net/mac80211/mlme.c | 2 +- net/mac80211/scan.c | 2 +- sound/core/pcm_native.c | 2 +- 22 files changed, 560 insertions(+), 537 deletions(-) create mode 100644 include/linux/pm_qos.h delete mode 100644 include/linux/pm_qos_params.h delete mode 100644 kernel/pm_qos_params.c create mode 100644 kernel/power/qos.carch/arm/mach-msm/clock.c +1
-1@@ -18,7 +18,7 @@#include <linux/list.h> #include <linux/err.h> #include <linux/spinlock.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/mutex.h> #include <linux/clk.h> #include <linux/string.h> drivers/acpi/processor_idle.c +1
-1@@ -37,7 +37,7 @@#include <linux/dmi.h> #include <linux/moduleparam.h> #include <linux/sched.h> /* need_resched() */ -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/clockchips.h> #include <linux/cpuidle.h> #include <linux/irqflags.h> drivers/cpuidle/cpuidle.c +1
-1@@ -12,7 +12,7 @@#include <linux/mutex.h> #include <linux/sched.h> #include <linux/notifier.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/cpu.h> #include <linux/cpuidle.h> #include <linux/ktime.h> drivers/cpuidle/governors/ladder.c +1
-1@@ -14,7 +14,7 @@#include <linux/kernel.h> #include <linux/cpuidle.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/moduleparam.h> #include <linux/jiffies.h> drivers/cpuidle/governors/menu.c +1
-1@@ -12,7 +12,7 @@#include <linux/kernel.h> #include <linux/cpuidle.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/time.h> #include <linux/ktime.h> #include <linux/hrtimer.h> drivers/media/video/via-camera.c +1
-1@@ -21,7 +21,7 @@#include <media/videobuf-dma-sg.h> #include <linux/delay.h> #include <linux/dma-mapping.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/via-core.h> #include <linux/via-gpio.h> #include <linux/via_i2c.h> drivers/net/e1000e/netdev.c +1
-1@@ -46,7 +46,7 @@#include <linux/if_vlan.h> #include <linux/cpu.h> #include <linux/smp.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/pm_runtime.h> #include <linux/aer.h> #include <linux/prefetch.h> drivers/net/wireless/ipw2x00/ipw2100.c +1
-1@@ -161,7 +161,7 @@ that only one external action is invoked at a time.#include <linux/firmware.h> #include <linux/acpi.h> #include <linux/ctype.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <net/lib80211.h> drivers/staging/msm/lcdc.c +1
-1@@ -32,7 +32,7 @@#include <linux/uaccess.h> #include <linux/clk.h> #include <linux/platform_device.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include "msm_fb.h" drivers/staging/msm/tvenc.c +1
-1@@ -32,7 +32,7 @@#include <linux/uaccess.h> #include <linux/clk.h> #include <linux/platform_device.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #define TVENC_C #include "tvenc.h" include/linux/netdevice.h +1
-1@@ -31,7 +31,7 @@#include <linux/if_link.h> #ifdef __KERNEL__ -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/timer.h> #include <linux/delay.h> #include <linux/mm.h> include/linux/pm_qos.h new file +61
-0@@ -0,0 +1,61 @@ +#ifndef _LINUX_PM_QOS_H +#define _LINUX_PM_QOS_H +/* interface for the pm_qos_power infrastructure of the linux kernel. +* +* Mark Gross <[email protected]> +*/ +#include <linux/plist.h> +#include <linux/notifier.h> +#include <linux/miscdevice.h> + +#define PM_QOS_RESERVED 0 +#define PM_QOS_CPU_DMA_LATENCY 1 +#define PM_QOS_NETWORK_LATENCY 2 +#define PM_QOS_NETWORK_THROUGHPUT 3 + +#define PM_QOS_NUM_CLASSES 4 +#define PM_QOS_DEFAULT_VALUE -1 + +#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) +#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) +#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 + +struct pm_qos_request_list { +struct plist_node list; +int pm_qos_class; +}; + +#ifdef CONFIG_PM +void pm_qos_add_request (struct pm_qos_request_list *l, +int pm_qos_class,s32 value); +void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +s32 new_value); +void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req); + +int pm_qos_request (int pm_qos_class); +int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier); +int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier); +int pm_qos_request_active (struct pm_qos_request_list *req); +#else +static inline void pm_qos_add_request (struct pm_qos_request_list *l, +int pm_qos_class,s32 value) + {return ; } +static inline void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +s32 new_value) + {return ; } +static inline void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req) + {return ; } + +static inline int pm_qos_request (int pm_qos_class) + {return 0 ; } +static inline int pm_qos_add_notifier (int pm_qos_class, +struct notifier_block *notifier) + {return 0 ; } +static inline int pm_qos_remove_notifier (int pm_qos_class, +struct notifier_block *notifier) + {return 0 ; } +static inline int pm_qos_request_active (struct pm_qos_request_list *req) + {return 0 ; } +#endif + +#endif include/linux/pm_qos_params.h deleted +0
-38@@ -1,38 +0,0 @@ -#ifndef _LINUX_PM_QOS_PARAMS_H -#define _LINUX_PM_QOS_PARAMS_H -/* interface for the pm_qos_power infrastructure of the linux kernel. -* -* Mark Gross <[email protected]> -*/ -#include <linux/plist.h> -#include <linux/notifier.h> -#include <linux/miscdevice.h> - -#define PM_QOS_RESERVED 0 -#define PM_QOS_CPU_DMA_LATENCY 1 -#define PM_QOS_NETWORK_LATENCY 2 -#define PM_QOS_NETWORK_THROUGHPUT 3 - -#define PM_QOS_NUM_CLASSES 4 -#define PM_QOS_DEFAULT_VALUE -1 - -#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) -#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) -#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 - -struct pm_qos_request_list { -struct plist_node list; -int pm_qos_class; -}; - -void pm_qos_add_request (struct pm_qos_request_list *l,int pm_qos_class,s32 value); -void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, -s32 new_value); -void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req); - -int pm_qos_request (int pm_qos_class); -int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier); -int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier); -int pm_qos_request_active (struct pm_qos_request_list *req); - -#endif include/sound/pcm.h +1
-1@@ -29,7 +29,7 @@#include <linux/poll.h> #include <linux/mm.h> #include <linux/bitops.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #define snd_pcm_substream_chip (substream) ((substream)->private_data)#define snd_pcm_chip (pcm) ((pcm)->private_data)kernel/Makefile +1
-1@@ -9,7 +9,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o \ rcupdate.o extable.o params.o posix-timers.o \ kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ - notifier.o ksysfs.o pm_qos_params.o sched_clock.o cred.o \ + notifier.o ksysfs.o sched_clock.o cred.o \ async.o range.o jump_label.o obj-y += groups.okernel/pm_qos_params.c deleted +0
-481@@ -1,481 +0,0 @@ -/* -* This module exposes the interface to kernel space for specifying -* QoS dependencies. It provides infrastructure for registration of: -* -* Dependents on a QoS value : register requests -* Watchers of QoS value : get notified when target QoS value changes -* -* This QoS design is best effort based. Dependents register their QoS needs. -* Watchers register to keep track of the current QoS needs of the system. -* -* There are 3 basic classes of QoS parameter: latency, timeout, throughput -* each have defined units: -* latency: usec -* timeout: usec <-- currently not used. -* throughput: kbs (kilo byte / sec) -* -* There are lists of pm_qos_objects each one wrapping requests, notifiers -* -* User mode requests on a QOS parameter register themselves to the -* subsystem by opening the device node /dev/... and writing there request to -* the node. As long as the process holds a file handle open to the node the -* client continues to be accounted for. Upon file release the usermode -* request is removed and a new qos target is computed. This way when the -* request that the application has is cleaned up when closes the file -* pointer or exits the pm_qos_object will get an opportunity to clean up. -* -* Mark Gross <[email protected]> -*/ - -/*#define DEBUG*/ - -#include <linux/pm_qos_params.h> -#include <linux/sched.h> -#include <linux/spinlock.h> -#include <linux/slab.h> -#include <linux/time.h> -#include <linux/fs.h> -#include <linux/device.h> -#include <linux/miscdevice.h> -#include <linux/string.h> -#include <linux/platform_device.h> -#include <linux/init.h> -#include <linux/kernel.h> - -#include <linux/uaccess.h> - -/* -* locking rule: all changes to requests or notifiers lists -* or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock -* held, taken with _irqsave. One lock to rule them all -*/ -enum pm_qos_type { -PM_QOS_MAX ,/* return the largest value */ -PM_QOS_MIN /* return the smallest value */ -}; - -/* -* Note: The lockless read path depends on the CPU accessing -* target_value atomically. Atomic access is only guaranteed on all CPU -* types linux supports for 32 bit quantites -*/ -struct pm_qos_object { -struct plist_head requests; -struct blocking_notifier_head *notifiers; -struct miscdevice pm_qos_power_miscdev; -char *name; -s32 target_value;/* Do not change to 64 bit */ -s32 default_value; -enum pm_qos_type type; -}; - -static DEFINE_SPINLOCK (pm_qos_lock); - -static struct pm_qos_object null_pm_qos; -static BLOCKING_NOTIFIER_HEAD (cpu_dma_lat_notifier); -static struct pm_qos_object cpu_dma_pm_qos = { - .requests =PLIST_HEAD_INIT (cpu_dma_pm_qos.requests, pm_qos_lock), - .notifiers = &cpu_dma_lat_notifier, - .name ="cpu_dma_latency" , - .target_value =PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE , - .default_value =PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE , - .type =PM_QOS_MIN , -}; - -static BLOCKING_NOTIFIER_HEAD (network_lat_notifier); -static struct pm_qos_object network_lat_pm_qos = { - .requests =PLIST_HEAD_INIT (network_lat_pm_qos.requests, pm_qos_lock), - .notifiers = &network_lat_notifier, - .name ="network_latency" , - .target_value =PM_QOS_NETWORK_LAT_DEFAULT_VALUE , - .default_value =PM_QOS_NETWORK_LAT_DEFAULT_VALUE , - .type =PM_QOS_MIN -}; - - -static BLOCKING_NOTIFIER_HEAD (network_throughput_notifier); -static struct pm_qos_object network_throughput_pm_qos = { - .requests =PLIST_HEAD_INIT (network_throughput_pm_qos.requests, pm_qos_lock), - .notifiers = &network_throughput_notifier, - .name ="network_throughput" , - .target_value =PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE , - .default_value =PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE , - .type =PM_QOS_MAX , -}; - - -static struct pm_qos_object *pm_qos_array[] = { - &null_pm_qos, - &cpu_dma_pm_qos, - &network_lat_pm_qos, - &network_throughput_pm_qos -}; - -static ssize_t pm_qos_power_write (struct file *filp,const char __user *buf, -size_t count,loff_t *f_pos); -static ssize_t pm_qos_power_read (struct file *filp,char __user *buf, -size_t count,loff_t *f_pos); -static int pm_qos_power_open (struct inode *inode,struct file *filp); -static int pm_qos_power_release (struct inode *inode,struct file *filp); - -static const struct file_operations pm_qos_power_fops = { - .write = pm_qos_power_write, - .read = pm_qos_power_read, - .open = pm_qos_power_open, - .release = pm_qos_power_release, - .llseek = noop_llseek, -}; - -/* unlocked internal variant */ -static inline int pm_qos_get_value (struct pm_qos_object *o) -{ -if (plist_head_empty (&o->requests)) -return o->default_value; - -switch (o->type) { -case PM_QOS_MIN : -return plist_first (&o->requests)->prio; - -case PM_QOS_MAX : -return plist_last (&o->requests)->prio; - -default : -/* runtime check for not using enum */ -BUG (); - } -} - -static inline s32 pm_qos_read_value (struct pm_qos_object *o) -{ -return o->target_value; -} - -static inline void pm_qos_set_value (struct pm_qos_object *o,s32 value) -{ - o->target_value = value; -} - -static void update_target (struct pm_qos_object *o,struct plist_node *node, -int del,int value) -{ -unsigned long flags; -int prev_value, curr_value; - -spin_lock_irqsave (&pm_qos_lock, flags); - prev_value =pm_qos_get_value (o); -/* PM_QOS_DEFAULT_VALUE is a signal that the value is unchanged */ -if (value !=PM_QOS_DEFAULT_VALUE ) { -/* -* to change the list, we atomically remove, reinit -* with new value and add, then see if the extremal -* changed -*/ -plist_del (node, &o->requests); -plist_node_init (node, value); -plist_add (node, &o->requests); - }else if (del) { -plist_del (node, &o->requests); - }else { -plist_add (node, &o->requests); - } - curr_value =pm_qos_get_value (o); -pm_qos_set_value (o, curr_value); -spin_unlock_irqrestore (&pm_qos_lock, flags); - -if (prev_value != curr_value) -blocking_notifier_call_chain (o->notifiers, - (unsigned long )curr_value, -NULL ); -} - -static int register_pm_qos_misc (struct pm_qos_object *qos) -{ - qos->pm_qos_power_miscdev.minor =MISC_DYNAMIC_MINOR ; - qos->pm_qos_power_miscdev.name = qos->name; - qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; - -return misc_register (&qos->pm_qos_power_miscdev); -} - -static int find_pm_qos_object_by_minor (int minor) -{ -int pm_qos_class; - -for (pm_qos_class =0 ; - pm_qos_class <PM_QOS_NUM_CLASSES ; pm_qos_class++) { -if (minor == - pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) -return pm_qos_class; - } -return -1 ; -} - -/** -* pm_qos_request - returns current system wide qos expectation -* @pm_qos_class: identification of which qos value is requested -* -* This function returns the current target value. -*/ -int pm_qos_request (int pm_qos_class) -{ -return pm_qos_read_value (pm_qos_array[pm_qos_class]); -} -EXPORT_SYMBOL_GPL (pm_qos_request); - -int pm_qos_request_active (struct pm_qos_request_list *req) -{ -return req->pm_qos_class !=0 ; -} -EXPORT_SYMBOL_GPL (pm_qos_request_active); - -/** -* pm_qos_add_request - inserts new qos request into the list -* @dep: pointer to a preallocated handle -* @pm_qos_class: identifies which list of qos request to use -* @value: defines the qos request -* -* This function inserts a new entry in the pm_qos_class list of requested qos -* performance characteristics. It recomputes the aggregate QoS expectations -* for the pm_qos_class of parameters and initializes the pm_qos_request_list -* handle. Caller needs to save this handle for later use in updates and -* removal. -*/ - -void pm_qos_add_request (struct pm_qos_request_list *dep, -int pm_qos_class,s32 value) -{ -struct pm_qos_object *o = pm_qos_array[pm_qos_class]; -int new_value; - -if (pm_qos_request_active (dep)) { -WARN (1 ,KERN_ERR "pm_qos_add_request() called for already added request\n" ); -return ; - } -if (value ==PM_QOS_DEFAULT_VALUE ) - new_value = o->default_value; -else - new_value = value; -plist_node_init (&dep->list, new_value); - dep->pm_qos_class = pm_qos_class; -update_target (o, &dep->list,0 ,PM_QOS_DEFAULT_VALUE ); -} -EXPORT_SYMBOL_GPL (pm_qos_add_request); - -/** -* pm_qos_update_request - modifies an existing qos request -* @pm_qos_req : handle to list element holding a pm_qos request to use -* @value: defines the qos request -* -* Updates an existing qos request for the pm_qos_class of parameters along -* with updating the target pm_qos_class value. -* -* Attempts are made to make this code callable on hot code paths. -*/ -void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, -s32 new_value) -{ -s32 temp; -struct pm_qos_object *o; - -if (!pm_qos_req)/*guard against callers passing in null */ -return ; - -if (!pm_qos_request_active (pm_qos_req)) { -WARN (1 ,KERN_ERR "pm_qos_update_request() called for unknown object\n" ); -return ; - } - - o = pm_qos_array[pm_qos_req->pm_qos_class]; - -if (new_value ==PM_QOS_DEFAULT_VALUE ) - temp = o->default_value; -else - temp = new_value; - -if (temp != pm_qos_req->list.prio) -update_target (o, &pm_qos_req->list,0 , temp); -} -EXPORT_SYMBOL_GPL (pm_qos_update_request); - -/** -* pm_qos_remove_request - modifies an existing qos request -* @pm_qos_req: handle to request list element -* -* Will remove pm qos request from the list of requests and -* recompute the current target value for the pm_qos_class. Call this -* on slow code paths. -*/ -void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req) -{ -struct pm_qos_object *o; - -if (pm_qos_req ==NULL ) -return ; -/* silent return to keep pcm code cleaner */ - -if (!pm_qos_request_active (pm_qos_req)) { -WARN (1 ,KERN_ERR "pm_qos_remove_request() called for unknown object\n" ); -return ; - } - - o = pm_qos_array[pm_qos_req->pm_qos_class]; -update_target (o, &pm_qos_req->list,1 ,PM_QOS_DEFAULT_VALUE ); -memset (pm_qos_req,0 ,sizeof (*pm_qos_req)); -} -EXPORT_SYMBOL_GPL (pm_qos_remove_request); - -/** -* pm_qos_add_notifier - sets notification entry for changes to target value -* @pm_qos_class: identifies which qos target changes should be notified. -* @notifier: notifier block managed by caller. -* -* will register the notifier into a notification chain that gets called -* upon changes to the pm_qos_class target value. -*/ -int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier) -{ -int retval; - - retval =blocking_notifier_chain_register ( - pm_qos_array[pm_qos_class]->notifiers, notifier); - -return retval; -} -EXPORT_SYMBOL_GPL (pm_qos_add_notifier); - -/** -* pm_qos_remove_notifier - deletes notification entry from chain. -* @pm_qos_class: identifies which qos target changes are notified. -* @notifier: notifier block to be removed. -* -* will remove the notifier from the notification chain that gets called -* upon changes to the pm_qos_class target value. -*/ -int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier) -{ -int retval; - - retval =blocking_notifier_chain_unregister ( - pm_qos_array[pm_qos_class]->notifiers, notifier); - -return retval; -} -EXPORT_SYMBOL_GPL (pm_qos_remove_notifier); - -static int pm_qos_power_open (struct inode *inode,struct file *filp) -{ -long pm_qos_class; - - pm_qos_class =find_pm_qos_object_by_minor (iminor (inode)); -if (pm_qos_class >=0 ) { -struct pm_qos_request_list *req =kzalloc (sizeof (*req),GFP_KERNEL ); -if (!req) -return -ENOMEM ; - -pm_qos_add_request (req, pm_qos_class,PM_QOS_DEFAULT_VALUE ); - filp->private_data = req; - -if (filp->private_data) -return 0 ; - } -return -EPERM ; -} - -static int pm_qos_power_release (struct inode *inode,struct file *filp) -{ -struct pm_qos_request_list *req; - - req = filp->private_data; -pm_qos_remove_request (req); -kfree (req); - -return 0 ; -} - - -static ssize_t pm_qos_power_read (struct file *filp,char __user *buf, -size_t count,loff_t *f_pos) -{ -s32 value; -unsigned long flags; -struct pm_qos_object *o; -struct pm_qos_request_list *pm_qos_req = filp->private_data; - -if (!pm_qos_req) -return -EINVAL ; -if (!pm_qos_request_active (pm_qos_req)) -return -EINVAL ; - - o = pm_qos_array[pm_qos_req->pm_qos_class]; -spin_lock_irqsave (&pm_qos_lock, flags); - value =pm_qos_get_value (o); -spin_unlock_irqrestore (&pm_qos_lock, flags); - -return simple_read_from_buffer (buf, count, f_pos, &value,sizeof (s32)); -} - -static ssize_t pm_qos_power_write (struct file *filp,const char __user *buf, -size_t count,loff_t *f_pos) -{ -s32 value; -struct pm_qos_request_list *pm_qos_req; - -if (count ==sizeof (s32)) { -if (copy_from_user (&value, buf,sizeof (s32))) -return -EFAULT ; - }else if (count <=11 ) {/* ASCII perhaps? */ -char ascii_value[11 ]; -unsigned long int ulval; -int ret; - -if (copy_from_user (ascii_value, buf, count)) -return -EFAULT ; - -if (count >10 ) { -if (ascii_value[10 ] =='\n' ) - ascii_value[10 ] ='\0' ; -else -return -EINVAL ; - }else { - ascii_value[count] ='\0' ; - } - ret =strict_strtoul (ascii_value,16 , &ulval); -if (ret) { -pr_debug ("%s, 0x%lx, 0x%x\n" , ascii_value, ulval, ret); -return -EINVAL ; - } - value = (s32 )lower_32_bits (ulval); - }else { -return -EINVAL ; - } - - pm_qos_req = filp->private_data; -pm_qos_update_request (pm_qos_req, value); - -return count; -} - - -static int __init pm_qos_power_init (void ) -{ -int ret =0 ; - - ret =register_pm_qos_misc (&cpu_dma_pm_qos); -if (ret <0 ) { -printk (KERN_ERR "pm_qos_param: cpu_dma_latency setup failed\n" ); -return ret; - } - ret =register_pm_qos_misc (&network_lat_pm_qos); -if (ret <0 ) { -printk (KERN_ERR "pm_qos_param: network_latency setup failed\n" ); -return ret; - } - ret =register_pm_qos_misc (&network_throughput_pm_qos); -if (ret <0 ) -printk (KERN_ERR -"pm_qos_param: network_throughput setup failed\n" ); - -return ret; -} - -late_initcall (pm_qos_power_init);kernel/power/Makefile +1
-1@@ -1,7 +1,7 @@ ccflags-$(CONFIG_PM_DEBUG) := -DDEBUG -obj-$(CONFIG_PM) += main.o +obj-$(CONFIG_PM) += main.o qos.o obj-$(CONFIG_PM_SLEEP) += console.o obj-$(CONFIG_FREEZER) += process.o obj-$(CONFIG_SUSPEND) += suspend.okernel/power/qos.c new file +481
-0@@ -0,0 +1,481 @@ +/* +* This module exposes the interface to kernel space for specifying +* QoS dependencies. It provides infrastructure for registration of: +* +* Dependents on a QoS value : register requests +* Watchers of QoS value : get notified when target QoS value changes +* +* This QoS design is best effort based. Dependents register their QoS needs. +* Watchers register to keep track of the current QoS needs of the system. +* +* There are 3 basic classes of QoS parameter: latency, timeout, throughput +* each have defined units: +* latency: usec +* timeout: usec <-- currently not used. +* throughput: kbs (kilo byte / sec) +* +* There are lists of pm_qos_objects each one wrapping requests, notifiers +* +* User mode requests on a QOS parameter register themselves to the +* subsystem by opening the device node /dev/... and writing there request to +* the node. As long as the process holds a file handle open to the node the +* client continues to be accounted for. Upon file release the usermode +* request is removed and a new qos target is computed. This way when the +* request that the application has is cleaned up when closes the file +* pointer or exits the pm_qos_object will get an opportunity to clean up. +* +* Mark Gross <[email protected]> +*/ + +/*#define DEBUG*/ + +#include <linux/pm_qos.h> +#include <linux/sched.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/time.h> +#include <linux/fs.h> +#include <linux/device.h> +#include <linux/miscdevice.h> +#include <linux/string.h> +#include <linux/platform_device.h> +#include <linux/init.h> +#include <linux/kernel.h> + +#include <linux/uaccess.h> + +/* +* locking rule: all changes to requests or notifiers lists +* or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock +* held, taken with _irqsave. One lock to rule them all +*/ +enum pm_qos_type { +PM_QOS_MAX ,/* return the largest value */ +PM_QOS_MIN /* return the smallest value */ +}; + +/* +* Note: The lockless read path depends on the CPU accessing +* target_value atomically. Atomic access is only guaranteed on all CPU +* types linux supports for 32 bit quantites +*/ +struct pm_qos_object { +struct plist_head requests; +struct blocking_notifier_head *notifiers; +struct miscdevice pm_qos_power_miscdev; +char *name; +s32 target_value;/* Do not change to 64 bit */ +s32 default_value; +enum pm_qos_type type; +}; + +static DEFINE_SPINLOCK (pm_qos_lock); + +static struct pm_qos_object null_pm_qos; +static BLOCKING_NOTIFIER_HEAD (cpu_dma_lat_notifier); +static struct pm_qos_object cpu_dma_pm_qos = { + .requests =PLIST_HEAD_INIT (cpu_dma_pm_qos.requests, pm_qos_lock), + .notifiers = &cpu_dma_lat_notifier, + .name ="cpu_dma_latency" , + .target_value =PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE , + .default_value =PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE , + .type =PM_QOS_MIN , +}; + +static BLOCKING_NOTIFIER_HEAD (network_lat_notifier); +static struct pm_qos_object network_lat_pm_qos = { + .requests =PLIST_HEAD_INIT (network_lat_pm_qos.requests, pm_qos_lock), + .notifiers = &network_lat_notifier, + .name ="network_latency" , + .target_value =PM_QOS_NETWORK_LAT_DEFAULT_VALUE , + .default_value =PM_QOS_NETWORK_LAT_DEFAULT_VALUE , + .type =PM_QOS_MIN +}; + + +static BLOCKING_NOTIFIER_HEAD (network_throughput_notifier); +static struct pm_qos_object network_throughput_pm_qos = { + .requests =PLIST_HEAD_INIT (network_throughput_pm_qos.requests, pm_qos_lock), + .notifiers = &network_throughput_notifier, + .name ="network_throughput" , + .target_value =PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE , + .default_value =PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE , + .type =PM_QOS_MAX , +}; + + +static struct pm_qos_object *pm_qos_array[] = { + &null_pm_qos, + &cpu_dma_pm_qos, + &network_lat_pm_qos, + &network_throughput_pm_qos +}; + +static ssize_t pm_qos_power_write (struct file *filp,const char __user *buf, +size_t count,loff_t *f_pos); +static ssize_t pm_qos_power_read (struct file *filp,char __user *buf, +size_t count,loff_t *f_pos); +static int pm_qos_power_open (struct inode *inode,struct file *filp); +static int pm_qos_power_release (struct inode *inode,struct file *filp); + +static const struct file_operations pm_qos_power_fops = { + .write = pm_qos_power_write, + .read = pm_qos_power_read, + .open = pm_qos_power_open, + .release = pm_qos_power_release, + .llseek = noop_llseek, +}; + +/* unlocked internal variant */ +static inline int pm_qos_get_value (struct pm_qos_object *o) +{ +if (plist_head_empty (&o->requests)) +return o->default_value; + +switch (o->type) { +case PM_QOS_MIN : +return plist_first (&o->requests)->prio; + +case PM_QOS_MAX : +return plist_last (&o->requests)->prio; + +default : +/* runtime check for not using enum */ +BUG (); + } +} + +static inline s32 pm_qos_read_value (struct pm_qos_object *o) +{ +return o->target_value; +} + +static inline void pm_qos_set_value (struct pm_qos_object *o,s32 value) +{ + o->target_value = value; +} + +static void update_target (struct pm_qos_object *o,struct plist_node *node, +int del,int value) +{ +unsigned long flags; +int prev_value, curr_value; + +spin_lock_irqsave (&pm_qos_lock, flags); + prev_value =pm_qos_get_value (o); +/* PM_QOS_DEFAULT_VALUE is a signal that the value is unchanged */ +if (value !=PM_QOS_DEFAULT_VALUE ) { +/* +* to change the list, we atomically remove, reinit +* with new value and add, then see if the extremal +* changed +*/ +plist_del (node, &o->requests); +plist_node_init (node, value); +plist_add (node, &o->requests); + }else if (del) { +plist_del (node, &o->requests); + }else { +plist_add (node, &o->requests); + } + curr_value =pm_qos_get_value (o); +pm_qos_set_value (o, curr_value); +spin_unlock_irqrestore (&pm_qos_lock, flags); + +if (prev_value != curr_value) +blocking_notifier_call_chain (o->notifiers, + (unsigned long )curr_value, +NULL ); +} + +static int register_pm_qos_misc (struct pm_qos_object *qos) +{ + qos->pm_qos_power_miscdev.minor =MISC_DYNAMIC_MINOR ; + qos->pm_qos_power_miscdev.name = qos->name; + qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; + +return misc_register (&qos->pm_qos_power_miscdev); +} + +static int find_pm_qos_object_by_minor (int minor) +{ +int pm_qos_class; + +for (pm_qos_class =0 ; + pm_qos_class <PM_QOS_NUM_CLASSES ; pm_qos_class++) { +if (minor == + pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) +return pm_qos_class; + } +return -1 ; +} + +/** +* pm_qos_request - returns current system wide qos expectation +* @pm_qos_class: identification of which qos value is requested +* +* This function returns the current target value. +*/ +int pm_qos_request (int pm_qos_class) +{ +return pm_qos_read_value (pm_qos_array[pm_qos_class]); +} +EXPORT_SYMBOL_GPL (pm_qos_request); + +int pm_qos_request_active (struct pm_qos_request_list *req) +{ +return req->pm_qos_class !=0 ; +} +EXPORT_SYMBOL_GPL (pm_qos_request_active); + +/** +* pm_qos_add_request - inserts new qos request into the list +* @dep: pointer to a preallocated handle +* @pm_qos_class: identifies which list of qos request to use +* @value: defines the qos request +* +* This function inserts a new entry in the pm_qos_class list of requested qos +* performance characteristics. It recomputes the aggregate QoS expectations +* for the pm_qos_class of parameters and initializes the pm_qos_request_list +* handle. Caller needs to save this handle for later use in updates and +* removal. +*/ + +void pm_qos_add_request (struct pm_qos_request_list *dep, +int pm_qos_class,s32 value) +{ +struct pm_qos_object *o = pm_qos_array[pm_qos_class]; +int new_value; + +if (pm_qos_request_active (dep)) { +WARN (1 ,KERN_ERR "pm_qos_add_request() called for already added request\n" ); +return ; + } +if (value ==PM_QOS_DEFAULT_VALUE ) + new_value = o->default_value; +else + new_value = value; +plist_node_init (&dep->list, new_value); + dep->pm_qos_class = pm_qos_class; +update_target (o, &dep->list,0 ,PM_QOS_DEFAULT_VALUE ); +} +EXPORT_SYMBOL_GPL (pm_qos_add_request); + +/** +* pm_qos_update_request - modifies an existing qos request +* @pm_qos_req : handle to list element holding a pm_qos request to use +* @value: defines the qos request +* +* Updates an existing qos request for the pm_qos_class of parameters along +* with updating the target pm_qos_class value. +* +* Attempts are made to make this code callable on hot code paths. +*/ +void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +s32 new_value) +{ +s32 temp; +struct pm_qos_object *o; + +if (!pm_qos_req)/*guard against callers passing in null */ +return ; + +if (!pm_qos_request_active (pm_qos_req)) { +WARN (1 ,KERN_ERR "pm_qos_update_request() called for unknown object\n" ); +return ; + } + + o = pm_qos_array[pm_qos_req->pm_qos_class]; + +if (new_value ==PM_QOS_DEFAULT_VALUE ) + temp = o->default_value; +else + temp = new_value; + +if (temp != pm_qos_req->list.prio) +update_target (o, &pm_qos_req->list,0 , temp); +} +EXPORT_SYMBOL_GPL (pm_qos_update_request); + +/** +* pm_qos_remove_request - modifies an existing qos request +* @pm_qos_req: handle to request list element +* +* Will remove pm qos request from the list of requests and +* recompute the current target value for the pm_qos_class. Call this +* on slow code paths. +*/ +void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req) +{ +struct pm_qos_object *o; + +if (pm_qos_req ==NULL ) +return ; +/* silent return to keep pcm code cleaner */ + +if (!pm_qos_request_active (pm_qos_req)) { +WARN (1 ,KERN_ERR "pm_qos_remove_request() called for unknown object\n" ); +return ; + } + + o = pm_qos_array[pm_qos_req->pm_qos_class]; +update_target (o, &pm_qos_req->list,1 ,PM_QOS_DEFAULT_VALUE ); +memset (pm_qos_req,0 ,sizeof (*pm_qos_req)); +} +EXPORT_SYMBOL_GPL (pm_qos_remove_request); + +/** +* pm_qos_add_notifier - sets notification entry for changes to target value +* @pm_qos_class: identifies which qos target changes should be notified. +* @notifier: notifier block managed by caller. +* +* will register the notifier into a notification chain that gets called +* upon changes to the pm_qos_class target value. +*/ +int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier) +{ +int retval; + + retval =blocking_notifier_chain_register ( + pm_qos_array[pm_qos_class]->notifiers, notifier); + +return retval; +} +EXPORT_SYMBOL_GPL (pm_qos_add_notifier); + +/** +* pm_qos_remove_notifier - deletes notification entry from chain. +* @pm_qos_class: identifies which qos target changes are notified. +* @notifier: notifier block to be removed. +* +* will remove the notifier from the notification chain that gets called +* upon changes to the pm_qos_class target value. +*/ +int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier) +{ +int retval; + + retval =blocking_notifier_chain_unregister ( + pm_qos_array[pm_qos_class]->notifiers, notifier); + +return retval; +} +EXPORT_SYMBOL_GPL (pm_qos_remove_notifier); + +static int pm_qos_power_open (struct inode *inode,struct file *filp) +{ +long pm_qos_class; + + pm_qos_class =find_pm_qos_object_by_minor (iminor (inode)); +if (pm_qos_class >=0 ) { +struct pm_qos_request_list *req =kzalloc (sizeof (*req),GFP_KERNEL ); +if (!req) +return -ENOMEM ; + +pm_qos_add_request (req, pm_qos_class,PM_QOS_DEFAULT_VALUE ); + filp->private_data = req; + +if (filp->private_data) +return 0 ; + } +return -EPERM ; +} + +static int pm_qos_power_release (struct inode *inode,struct file *filp) +{ +struct pm_qos_request_list *req; + + req = filp->private_data; +pm_qos_remove_request (req); +kfree (req); + +return 0 ; +} + + +static ssize_t pm_qos_power_read (struct file *filp,char __user *buf, +size_t count,loff_t *f_pos) +{ +s32 value; +unsigned long flags; +struct pm_qos_object *o; +struct pm_qos_request_list *pm_qos_req = filp->private_data; + +if (!pm_qos_req) +return -EINVAL ; +if (!pm_qos_request_active (pm_qos_req)) +return -EINVAL ; + + o = pm_qos_array[pm_qos_req->pm_qos_class]; +spin_lock_irqsave (&pm_qos_lock, flags); + value =pm_qos_get_value (o); +spin_unlock_irqrestore (&pm_qos_lock, flags); + +return simple_read_from_buffer (buf, count, f_pos, &value,sizeof (s32)); +} + +static ssize_t pm_qos_power_write (struct file *filp,const char __user *buf, +size_t count,loff_t *f_pos) +{ +s32 value; +struct pm_qos_request_list *pm_qos_req; + +if (count ==sizeof (s32)) { +if (copy_from_user (&value, buf,sizeof (s32))) +return -EFAULT ; + }else if (count <=11 ) {/* ASCII perhaps? */ +char ascii_value[11 ]; +unsigned long int ulval; +int ret; + +if (copy_from_user (ascii_value, buf, count)) +return -EFAULT ; + +if (count >10 ) { +if (ascii_value[10 ] =='\n' ) + ascii_value[10 ] ='\0' ; +else +return -EINVAL ; + }else { + ascii_value[count] ='\0' ; + } + ret =strict_strtoul (ascii_value,16 , &ulval); +if (ret) { +pr_debug ("%s, 0x%lx, 0x%x\n" , ascii_value, ulval, ret); +return -EINVAL ; + } + value = (s32 )lower_32_bits (ulval); + }else { +return -EINVAL ; + } + + pm_qos_req = filp->private_data; +pm_qos_update_request (pm_qos_req, value); + +return count; +} + + +static int __init pm_qos_power_init (void ) +{ +int ret =0 ; + + ret =register_pm_qos_misc (&cpu_dma_pm_qos); +if (ret <0 ) { +printk (KERN_ERR "pm_qos_param: cpu_dma_latency setup failed\n" ); +return ret; + } + ret =register_pm_qos_misc (&network_lat_pm_qos); +if (ret <0 ) { +printk (KERN_ERR "pm_qos_param: network_latency setup failed\n" ); +return ret; + } + ret =register_pm_qos_misc (&network_throughput_pm_qos); +if (ret <0 ) +printk (KERN_ERR +"pm_qos_param: network_throughput setup failed\n" ); + +return ret; +} + +late_initcall (pm_qos_power_init);net/mac80211/main.c +1
-1@@ -19,7 +19,7 @@#include <linux/if_arp.h> #include <linux/rtnetlink.h> #include <linux/bitmap.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/inetdevice.h> #include <net/net_namespace.h> #include <net/cfg80211.h> net/mac80211/mlme.c +1
-1@@ -17,7 +17,7 @@#include <linux/if_arp.h> #include <linux/etherdevice.h> #include <linux/rtnetlink.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/crc32.h> #include <linux/slab.h> #include <net/mac80211.h> net/mac80211/scan.c +1
-1@@ -14,7 +14,7 @@#include <linux/if_arp.h> #include <linux/rtnetlink.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <net/sch_generic.h> #include <linux/slab.h> #include <net/mac80211.h> sound/core/pcm_native.c +1
-1@@ -23,7 +23,7 @@#include <linux/file.h> #include <linux/slab.h> #include <linux/time.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/uio.h> #include <linux/dma-mapping.h> #include <sound/core.h> Signature · 1 line
1.7.2.5
Re: [PATCH 01/15] PM QoS: move and rename the implementation files
In reply to [email protected]Quoted 1,358 lines · On Thu, Aug 11, 2011 at 05:06:38PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
The PM QoS implementation files are better named
kernel/power/qos.candinclude/linux/pm_qos.h.The PM QoS support is compiled under the
CONFIG_PMoption.Signed-off-by Jean Pihet <[email protected]>--- arch/arm/mach-msm/clock.c | 2 +- drivers/acpi/processor_idle.c | 2 +- drivers/cpuidle/cpuidle.c | 2 +- drivers/cpuidle/governors/ladder.c | 2 +- drivers/cpuidle/governors/menu.c | 2 +- drivers/media/video/via-camera.c | 2 +- drivers/net/e1000e/netdev.c | 2 +- drivers/net/wireless/ipw2x00/ipw2100.c | 2 +- drivers/staging/msm/lcdc.c | 2 +- drivers/staging/msm/tvenc.c | 2 +- include/linux/netdevice.h | 2 +- include/linux/pm_qos.h | 61 ++++ include/linux/pm_qos_params.h | 38 --- include/sound/pcm.h | 2 +- kernel/Makefile | 2 +- kernel/pm_qos_params.c | 481 -------------------------------- kernel/power/Makefile | 2 +- kernel/power/qos.c | 481 ++++++++++++++++++++++++++++++++ net/mac80211/main.c | 2 +- net/mac80211/mlme.c | 2 +- net/mac80211/scan.c | 2 +- sound/core/pcm_native.c | 2 +- 22 files changed, 560 insertions(+), 537 deletions(-) create mode 100644 include/linux/pm_qos.h delete mode 100644 include/linux/pm_qos_params.h delete mode 100644 kernel/pm_qos_params.c create mode 100644 kernel/power/qos.carch/arm/mach-msm/clock.c +1
-1@@ -18,7 +18,7 @@#include <linux/list.h> #include <linux/err.h> #include <linux/spinlock.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/mutex.h> #include <linux/clk.h> #include <linux/string.h> drivers/acpi/processor_idle.c +1
-1@@ -37,7 +37,7 @@#include <linux/dmi.h> #include <linux/moduleparam.h> #include <linux/sched.h> /* need_resched() */ -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/clockchips.h> #include <linux/cpuidle.h> #include <linux/irqflags.h> drivers/cpuidle/cpuidle.c +1
-1@@ -12,7 +12,7 @@#include <linux/mutex.h> #include <linux/sched.h> #include <linux/notifier.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/cpu.h> #include <linux/cpuidle.h> #include <linux/ktime.h> drivers/cpuidle/governors/ladder.c +1
-1@@ -14,7 +14,7 @@#include <linux/kernel.h> #include <linux/cpuidle.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/moduleparam.h> #include <linux/jiffies.h> drivers/cpuidle/governors/menu.c +1
-1@@ -12,7 +12,7 @@#include <linux/kernel.h> #include <linux/cpuidle.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/time.h> #include <linux/ktime.h> #include <linux/hrtimer.h> drivers/media/video/via-camera.c +1
-1@@ -21,7 +21,7 @@#include <media/videobuf-dma-sg.h> #include <linux/delay.h> #include <linux/dma-mapping.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/via-core.h> #include <linux/via-gpio.h> #include <linux/via_i2c.h> drivers/net/e1000e/netdev.c +1
-1@@ -46,7 +46,7 @@#include <linux/if_vlan.h> #include <linux/cpu.h> #include <linux/smp.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/pm_runtime.h> #include <linux/aer.h> #include <linux/prefetch.h> drivers/net/wireless/ipw2x00/ipw2100.c +1
-1@@ -161,7 +161,7 @@ that only one external action is invoked at a time.#include <linux/firmware.h> #include <linux/acpi.h> #include <linux/ctype.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <net/lib80211.h> drivers/staging/msm/lcdc.c +1
-1@@ -32,7 +32,7 @@#include <linux/uaccess.h> #include <linux/clk.h> #include <linux/platform_device.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include "msm_fb.h" drivers/staging/msm/tvenc.c +1
-1@@ -32,7 +32,7 @@#include <linux/uaccess.h> #include <linux/clk.h> #include <linux/platform_device.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #define TVENC_C #include "tvenc.h" include/linux/netdevice.h +1
-1@@ -31,7 +31,7 @@#include <linux/if_link.h> #ifdef __KERNEL__ -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/timer.h> #include <linux/delay.h> #include <linux/mm.h> include/linux/pm_qos.h new file +61
-0@@ -0,0 +1,61 @@ +#ifndef _LINUX_PM_QOS_H +#define _LINUX_PM_QOS_H +/* interface for the pm_qos_power infrastructure of the linux kernel. +* +* Mark Gross <[email protected]> +*/ +#include <linux/plist.h> +#include <linux/notifier.h> +#include <linux/miscdevice.h> + +#define PM_QOS_RESERVED 0 +#define PM_QOS_CPU_DMA_LATENCY 1 +#define PM_QOS_NETWORK_LATENCY 2 +#define PM_QOS_NETWORK_THROUGHPUT 3 + +#define PM_QOS_NUM_CLASSES 4 +#define PM_QOS_DEFAULT_VALUE -1 + +#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) +#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) +#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 + +struct pm_qos_request_list { +struct plist_node list; +int pm_qos_class; +}; + +#ifdef CONFIG_PM +void pm_qos_add_request (struct pm_qos_request_list *l, +int pm_qos_class,s32 value); +void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +s32 new_value); +void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req); + +int pm_qos_request (int pm_qos_class); +int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier); +int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier); +int pm_qos_request_active (struct pm_qos_request_list *req); +#else +static inline void pm_qos_add_request (struct pm_qos_request_list *l, +int pm_qos_class,s32 value) + {return ; } +static inline void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +s32 new_value) + {return ; } +static inline void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req) + {return ; } + +static inline int pm_qos_request (int pm_qos_class) + {return 0 ; } +static inline int pm_qos_add_notifier (int pm_qos_class, +struct notifier_block *notifier) + {return 0 ; } +static inline int pm_qos_remove_notifier (int pm_qos_class, +struct notifier_block *notifier) + {return 0 ; } +static inline int pm_qos_request_active (struct pm_qos_request_list *req) + {return 0 ; } +#endif + +#endif include/linux/pm_qos_params.h deleted +0
-38@@ -1,38 +0,0 @@ -#ifndef _LINUX_PM_QOS_PARAMS_H -#define _LINUX_PM_QOS_PARAMS_H -/* interface for the pm_qos_power infrastructure of the linux kernel. -* -* Mark Gross <[email protected]> -*/ -#include <linux/plist.h> -#include <linux/notifier.h> -#include <linux/miscdevice.h> - -#define PM_QOS_RESERVED 0 -#define PM_QOS_CPU_DMA_LATENCY 1 -#define PM_QOS_NETWORK_LATENCY 2 -#define PM_QOS_NETWORK_THROUGHPUT 3 - -#define PM_QOS_NUM_CLASSES 4 -#define PM_QOS_DEFAULT_VALUE -1 - -#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) -#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) -#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 - -struct pm_qos_request_list { -struct plist_node list; -int pm_qos_class; -}; - -void pm_qos_add_request (struct pm_qos_request_list *l,int pm_qos_class,s32 value); -void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, -s32 new_value); -void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req); - -int pm_qos_request (int pm_qos_class); -int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier); -int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier); -int pm_qos_request_active (struct pm_qos_request_list *req); - -#endif include/sound/pcm.h +1
-1@@ -29,7 +29,7 @@#include <linux/poll.h> #include <linux/mm.h> #include <linux/bitops.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #define snd_pcm_substream_chip (substream) ((substream)->private_data)#define snd_pcm_chip (pcm) ((pcm)->private_data)kernel/Makefile +1
-1@@ -9,7 +9,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o \ rcupdate.o extable.o params.o posix-timers.o \ kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ - notifier.o ksysfs.o pm_qos_params.o sched_clock.o cred.o \ + notifier.o ksysfs.o sched_clock.o cred.o \ async.o range.o jump_label.o obj-y += groups.okernel/pm_qos_params.c deleted +0
-481@@ -1,481 +0,0 @@ -/* -* This module exposes the interface to kernel space for specifying -* QoS dependencies. It provides infrastructure for registration of: -* -* Dependents on a QoS value : register requests -* Watchers of QoS value : get notified when target QoS value changes -* -* This QoS design is best effort based. Dependents register their QoS needs. -* Watchers register to keep track of the current QoS needs of the system. -* -* There are 3 basic classes of QoS parameter: latency, timeout, throughput -* each have defined units: -* latency: usec -* timeout: usec <-- currently not used. -* throughput: kbs (kilo byte / sec) -* -* There are lists of pm_qos_objects each one wrapping requests, notifiers -* -* User mode requests on a QOS parameter register themselves to the -* subsystem by opening the device node /dev/... and writing there request to -* the node. As long as the process holds a file handle open to the node the -* client continues to be accounted for. Upon file release the usermode -* request is removed and a new qos target is computed. This way when the -* request that the application has is cleaned up when closes the file -* pointer or exits the pm_qos_object will get an opportunity to clean up. -* -* Mark Gross <[email protected]> -*/ - -/*#define DEBUG*/ - -#include <linux/pm_qos_params.h> -#include <linux/sched.h> -#include <linux/spinlock.h> -#include <linux/slab.h> -#include <linux/time.h> -#include <linux/fs.h> -#include <linux/device.h> -#include <linux/miscdevice.h> -#include <linux/string.h> -#include <linux/platform_device.h> -#include <linux/init.h> -#include <linux/kernel.h> - -#include <linux/uaccess.h> - -/* -* locking rule: all changes to requests or notifiers lists -* or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock -* held, taken with _irqsave. One lock to rule them all -*/ -enum pm_qos_type { -PM_QOS_MAX ,/* return the largest value */ -PM_QOS_MIN /* return the smallest value */ -}; - -/* -* Note: The lockless read path depends on the CPU accessing -* target_value atomically. Atomic access is only guaranteed on all CPU -* types linux supports for 32 bit quantites -*/ -struct pm_qos_object { -struct plist_head requests; -struct blocking_notifier_head *notifiers; -struct miscdevice pm_qos_power_miscdev; -char *name; -s32 target_value;/* Do not change to 64 bit */ -s32 default_value; -enum pm_qos_type type; -}; - -static DEFINE_SPINLOCK (pm_qos_lock); - -static struct pm_qos_object null_pm_qos; -static BLOCKING_NOTIFIER_HEAD (cpu_dma_lat_notifier); -static struct pm_qos_object cpu_dma_pm_qos = { - .requests =PLIST_HEAD_INIT (cpu_dma_pm_qos.requests, pm_qos_lock), - .notifiers = &cpu_dma_lat_notifier, - .name ="cpu_dma_latency" , - .target_value =PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE , - .default_value =PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE , - .type =PM_QOS_MIN , -}; - -static BLOCKING_NOTIFIER_HEAD (network_lat_notifier); -static struct pm_qos_object network_lat_pm_qos = { - .requests =PLIST_HEAD_INIT (network_lat_pm_qos.requests, pm_qos_lock), - .notifiers = &network_lat_notifier, - .name ="network_latency" , - .target_value =PM_QOS_NETWORK_LAT_DEFAULT_VALUE , - .default_value =PM_QOS_NETWORK_LAT_DEFAULT_VALUE , - .type =PM_QOS_MIN -}; - - -static BLOCKING_NOTIFIER_HEAD (network_throughput_notifier); -static struct pm_qos_object network_throughput_pm_qos = { - .requests =PLIST_HEAD_INIT (network_throughput_pm_qos.requests, pm_qos_lock), - .notifiers = &network_throughput_notifier, - .name ="network_throughput" , - .target_value =PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE , - .default_value =PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE , - .type =PM_QOS_MAX , -}; - - -static struct pm_qos_object *pm_qos_array[] = { - &null_pm_qos, - &cpu_dma_pm_qos, - &network_lat_pm_qos, - &network_throughput_pm_qos -}; - -static ssize_t pm_qos_power_write (struct file *filp,const char __user *buf, -size_t count,loff_t *f_pos); -static ssize_t pm_qos_power_read (struct file *filp,char __user *buf, -size_t count,loff_t *f_pos); -static int pm_qos_power_open (struct inode *inode,struct file *filp); -static int pm_qos_power_release (struct inode *inode,struct file *filp); - -static const struct file_operations pm_qos_power_fops = { - .write = pm_qos_power_write, - .read = pm_qos_power_read, - .open = pm_qos_power_open, - .release = pm_qos_power_release, - .llseek = noop_llseek, -}; - -/* unlocked internal variant */ -static inline int pm_qos_get_value (struct pm_qos_object *o) -{ -if (plist_head_empty (&o->requests)) -return o->default_value; - -switch (o->type) { -case PM_QOS_MIN : -return plist_first (&o->requests)->prio; - -case PM_QOS_MAX : -return plist_last (&o->requests)->prio; - -default : -/* runtime check for not using enum */ -BUG (); - } -} - -static inline s32 pm_qos_read_value (struct pm_qos_object *o) -{ -return o->target_value; -} - -static inline void pm_qos_set_value (struct pm_qos_object *o,s32 value) -{ - o->target_value = value; -} - -static void update_target (struct pm_qos_object *o,struct plist_node *node, -int del,int value) -{ -unsigned long flags; -int prev_value, curr_value; - -spin_lock_irqsave (&pm_qos_lock, flags); - prev_value =pm_qos_get_value (o); -/* PM_QOS_DEFAULT_VALUE is a signal that the value is unchanged */ -if (value !=PM_QOS_DEFAULT_VALUE ) { -/* -* to change the list, we atomically remove, reinit -* with new value and add, then see if the extremal -* changed -*/ -plist_del (node, &o->requests); -plist_node_init (node, value); -plist_add (node, &o->requests); - }else if (del) { -plist_del (node, &o->requests); - }else { -plist_add (node, &o->requests); - } - curr_value =pm_qos_get_value (o); -pm_qos_set_value (o, curr_value); -spin_unlock_irqrestore (&pm_qos_lock, flags); - -if (prev_value != curr_value) -blocking_notifier_call_chain (o->notifiers, - (unsigned long )curr_value, -NULL ); -} - -static int register_pm_qos_misc (struct pm_qos_object *qos) -{ - qos->pm_qos_power_miscdev.minor =MISC_DYNAMIC_MINOR ; - qos->pm_qos_power_miscdev.name = qos->name; - qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; - -return misc_register (&qos->pm_qos_power_miscdev); -} - -static int find_pm_qos_object_by_minor (int minor) -{ -int pm_qos_class; - -for (pm_qos_class =0 ; - pm_qos_class <PM_QOS_NUM_CLASSES ; pm_qos_class++) { -if (minor == - pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) -return pm_qos_class; - } -return -1 ; -} - -/** -* pm_qos_request - returns current system wide qos expectation -* @pm_qos_class: identification of which qos value is requested -* -* This function returns the current target value. -*/ -int pm_qos_request (int pm_qos_class) -{ -return pm_qos_read_value (pm_qos_array[pm_qos_class]); -} -EXPORT_SYMBOL_GPL (pm_qos_request); - -int pm_qos_request_active (struct pm_qos_request_list *req) -{ -return req->pm_qos_class !=0 ; -} -EXPORT_SYMBOL_GPL (pm_qos_request_active); - -/** -* pm_qos_add_request - inserts new qos request into the list -* @dep: pointer to a preallocated handle -* @pm_qos_class: identifies which list of qos request to use -* @value: defines the qos request -* -* This function inserts a new entry in the pm_qos_class list of requested qos -* performance characteristics. It recomputes the aggregate QoS expectations -* for the pm_qos_class of parameters and initializes the pm_qos_request_list -* handle. Caller needs to save this handle for later use in updates and -* removal. -*/ - -void pm_qos_add_request (struct pm_qos_request_list *dep, -int pm_qos_class,s32 value) -{ -struct pm_qos_object *o = pm_qos_array[pm_qos_class]; -int new_value; - -if (pm_qos_request_active (dep)) { -WARN (1 ,KERN_ERR "pm_qos_add_request() called for already added request\n" ); -return ; - } -if (value ==PM_QOS_DEFAULT_VALUE ) - new_value = o->default_value; -else - new_value = value; -plist_node_init (&dep->list, new_value); - dep->pm_qos_class = pm_qos_class; -update_target (o, &dep->list,0 ,PM_QOS_DEFAULT_VALUE ); -} -EXPORT_SYMBOL_GPL (pm_qos_add_request); - -/** -* pm_qos_update_request - modifies an existing qos request -* @pm_qos_req : handle to list element holding a pm_qos request to use -* @value: defines the qos request -* -* Updates an existing qos request for the pm_qos_class of parameters along -* with updating the target pm_qos_class value. -* -* Attempts are made to make this code callable on hot code paths. -*/ -void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, -s32 new_value) -{ -s32 temp; -struct pm_qos_object *o; - -if (!pm_qos_req)/*guard against callers passing in null */ -return ; - -if (!pm_qos_request_active (pm_qos_req)) { -WARN (1 ,KERN_ERR "pm_qos_update_request() called for unknown object\n" ); -return ; - } - - o = pm_qos_array[pm_qos_req->pm_qos_class]; - -if (new_value ==PM_QOS_DEFAULT_VALUE ) - temp = o->default_value; -else - temp = new_value; - -if (temp != pm_qos_req->list.prio) -update_target (o, &pm_qos_req->list,0 , temp); -} -EXPORT_SYMBOL_GPL (pm_qos_update_request); - -/** -* pm_qos_remove_request - modifies an existing qos request -* @pm_qos_req: handle to request list element -* -* Will remove pm qos request from the list of requests and -* recompute the current target value for the pm_qos_class. Call this -* on slow code paths. -*/ -void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req) -{ -struct pm_qos_object *o; - -if (pm_qos_req ==NULL ) -return ; -/* silent return to keep pcm code cleaner */ - -if (!pm_qos_request_active (pm_qos_req)) { -WARN (1 ,KERN_ERR "pm_qos_remove_request() called for unknown object\n" ); -return ; - } - - o = pm_qos_array[pm_qos_req->pm_qos_class]; -update_target (o, &pm_qos_req->list,1 ,PM_QOS_DEFAULT_VALUE ); -memset (pm_qos_req,0 ,sizeof (*pm_qos_req)); -} -EXPORT_SYMBOL_GPL (pm_qos_remove_request); - -/** -* pm_qos_add_notifier - sets notification entry for changes to target value -* @pm_qos_class: identifies which qos target changes should be notified. -* @notifier: notifier block managed by caller. -* -* will register the notifier into a notification chain that gets called -* upon changes to the pm_qos_class target value. -*/ -int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier) -{ -int retval; - - retval =blocking_notifier_chain_register ( - pm_qos_array[pm_qos_class]->notifiers, notifier); - -return retval; -} -EXPORT_SYMBOL_GPL (pm_qos_add_notifier); - -/** -* pm_qos_remove_notifier - deletes notification entry from chain. -* @pm_qos_class: identifies which qos target changes are notified. -* @notifier: notifier block to be removed. -* -* will remove the notifier from the notification chain that gets called -* upon changes to the pm_qos_class target value. -*/ -int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier) -{ -int retval; - - retval =blocking_notifier_chain_unregister ( - pm_qos_array[pm_qos_class]->notifiers, notifier); - -return retval; -} -EXPORT_SYMBOL_GPL (pm_qos_remove_notifier); - -static int pm_qos_power_open (struct inode *inode,struct file *filp) -{ -long pm_qos_class; - - pm_qos_class =find_pm_qos_object_by_minor (iminor (inode)); -if (pm_qos_class >=0 ) { -struct pm_qos_request_list *req =kzalloc (sizeof (*req),GFP_KERNEL ); -if (!req) -return -ENOMEM ; - -pm_qos_add_request (req, pm_qos_class,PM_QOS_DEFAULT_VALUE ); - filp->private_data = req; - -if (filp->private_data) -return 0 ; - } -return -EPERM ; -} - -static int pm_qos_power_release (struct inode *inode,struct file *filp) -{ -struct pm_qos_request_list *req; - - req = filp->private_data; -pm_qos_remove_request (req); -kfree (req); - -return 0 ; -} - - -static ssize_t pm_qos_power_read (struct file *filp,char __user *buf, -size_t count,loff_t *f_pos) -{ -s32 value; -unsigned long flags; -struct pm_qos_object *o; -struct pm_qos_request_list *pm_qos_req = filp->private_data; - -if (!pm_qos_req) -return -EINVAL ; -if (!pm_qos_request_active (pm_qos_req)) -return -EINVAL ; - - o = pm_qos_array[pm_qos_req->pm_qos_class]; -spin_lock_irqsave (&pm_qos_lock, flags); - value =pm_qos_get_value (o); -spin_unlock_irqrestore (&pm_qos_lock, flags); - -return simple_read_from_buffer (buf, count, f_pos, &value,sizeof (s32)); -} - -static ssize_t pm_qos_power_write (struct file *filp,const char __user *buf, -size_t count,loff_t *f_pos) -{ -s32 value; -struct pm_qos_request_list *pm_qos_req; - -if (count ==sizeof (s32)) { -if (copy_from_user (&value, buf,sizeof (s32))) -return -EFAULT ; - }else if (count <=11 ) {/* ASCII perhaps? */ -char ascii_value[11 ]; -unsigned long int ulval; -int ret; - -if (copy_from_user (ascii_value, buf, count)) -return -EFAULT ; - -if (count >10 ) { -if (ascii_value[10 ] =='\n' ) - ascii_value[10 ] ='\0' ; -else -return -EINVAL ; - }else { - ascii_value[count] ='\0' ; - } - ret =strict_strtoul (ascii_value,16 , &ulval); -if (ret) { -pr_debug ("%s, 0x%lx, 0x%x\n" , ascii_value, ulval, ret); -return -EINVAL ; - } - value = (s32 )lower_32_bits (ulval); - }else { -return -EINVAL ; - } - - pm_qos_req = filp->private_data; -pm_qos_update_request (pm_qos_req, value); - -return count; -} - - -static int __init pm_qos_power_init (void ) -{ -int ret =0 ; - - ret =register_pm_qos_misc (&cpu_dma_pm_qos); -if (ret <0 ) { -printk (KERN_ERR "pm_qos_param: cpu_dma_latency setup failed\n" ); -return ret; - } - ret =register_pm_qos_misc (&network_lat_pm_qos); -if (ret <0 ) { -printk (KERN_ERR "pm_qos_param: network_latency setup failed\n" ); -return ret; - } - ret =register_pm_qos_misc (&network_throughput_pm_qos); -if (ret <0 ) -printk (KERN_ERR -"pm_qos_param: network_throughput setup failed\n" ); - -return ret; -} - -late_initcall (pm_qos_power_init);kernel/power/Makefile +1
-1@@ -1,7 +1,7 @@ ccflags-$(CONFIG_PM_DEBUG) := -DDEBUG -obj-$(CONFIG_PM) += main.o +obj-$(CONFIG_PM) += main.o qos.o obj-$(CONFIG_PM_SLEEP) += console.o obj-$(CONFIG_FREEZER) += process.o obj-$(CONFIG_SUSPEND) += suspend.okernel/power/qos.c new file +481
-0@@ -0,0 +1,481 @@ +/* +* This module exposes the interface to kernel space for specifying +* QoS dependencies. It provides infrastructure for registration of: +* +* Dependents on a QoS value : register requests +* Watchers of QoS value : get notified when target QoS value changes +* +* This QoS design is best effort based. Dependents register their QoS needs. +* Watchers register to keep track of the current QoS needs of the system. +* +* There are 3 basic classes of QoS parameter: latency, timeout, throughput +* each have defined units: +* latency: usec +* timeout: usec <-- currently not used. +* throughput: kbs (kilo byte / sec) +* +* There are lists of pm_qos_objects each one wrapping requests, notifiers +* +* User mode requests on a QOS parameter register themselves to the +* subsystem by opening the device node /dev/... and writing there request to +* the node. As long as the process holds a file handle open to the node the +* client continues to be accounted for. Upon file release the usermode +* request is removed and a new qos target is computed. This way when the +* request that the application has is cleaned up when closes the file +* pointer or exits the pm_qos_object will get an opportunity to clean up. +* +* Mark Gross <[email protected]> +*/ + +/*#define DEBUG*/ + +#include <linux/pm_qos.h> +#include <linux/sched.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/time.h> +#include <linux/fs.h> +#include <linux/device.h> +#include <linux/miscdevice.h> +#include <linux/string.h> +#include <linux/platform_device.h> +#include <linux/init.h> +#include <linux/kernel.h> + +#include <linux/uaccess.h> + +/* +* locking rule: all changes to requests or notifiers lists +* or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock +* held, taken with _irqsave. One lock to rule them all +*/ +enum pm_qos_type { +PM_QOS_MAX ,/* return the largest value */ +PM_QOS_MIN /* return the smallest value */ +}; + +/* +* Note: The lockless read path depends on the CPU accessing +* target_value atomically. Atomic access is only guaranteed on all CPU +* types linux supports for 32 bit quantites +*/ +struct pm_qos_object { +struct plist_head requests; +struct blocking_notifier_head *notifiers; +struct miscdevice pm_qos_power_miscdev; +char *name; +s32 target_value;/* Do not change to 64 bit */ +s32 default_value; +enum pm_qos_type type; +}; + +static DEFINE_SPINLOCK (pm_qos_lock); + +static struct pm_qos_object null_pm_qos; +static BLOCKING_NOTIFIER_HEAD (cpu_dma_lat_notifier); +static struct pm_qos_object cpu_dma_pm_qos = { + .requests =PLIST_HEAD_INIT (cpu_dma_pm_qos.requests, pm_qos_lock), + .notifiers = &cpu_dma_lat_notifier, + .name ="cpu_dma_latency" , + .target_value =PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE , + .default_value =PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE , + .type =PM_QOS_MIN , +}; + +static BLOCKING_NOTIFIER_HEAD (network_lat_notifier); +static struct pm_qos_object network_lat_pm_qos = { + .requests =PLIST_HEAD_INIT (network_lat_pm_qos.requests, pm_qos_lock), + .notifiers = &network_lat_notifier, + .name ="network_latency" , + .target_value =PM_QOS_NETWORK_LAT_DEFAULT_VALUE , + .default_value =PM_QOS_NETWORK_LAT_DEFAULT_VALUE , + .type =PM_QOS_MIN +}; + + +static BLOCKING_NOTIFIER_HEAD (network_throughput_notifier); +static struct pm_qos_object network_throughput_pm_qos = { + .requests =PLIST_HEAD_INIT (network_throughput_pm_qos.requests, pm_qos_lock), + .notifiers = &network_throughput_notifier, + .name ="network_throughput" , + .target_value =PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE , + .default_value =PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE , + .type =PM_QOS_MAX , +}; + + +static struct pm_qos_object *pm_qos_array[] = { + &null_pm_qos, + &cpu_dma_pm_qos, + &network_lat_pm_qos, + &network_throughput_pm_qos +}; + +static ssize_t pm_qos_power_write (struct file *filp,const char __user *buf, +size_t count,loff_t *f_pos); +static ssize_t pm_qos_power_read (struct file *filp,char __user *buf, +size_t count,loff_t *f_pos); +static int pm_qos_power_open (struct inode *inode,struct file *filp); +static int pm_qos_power_release (struct inode *inode,struct file *filp); + +static const struct file_operations pm_qos_power_fops = { + .write = pm_qos_power_write, + .read = pm_qos_power_read, + .open = pm_qos_power_open, + .release = pm_qos_power_release, + .llseek = noop_llseek, +}; + +/* unlocked internal variant */ +static inline int pm_qos_get_value (struct pm_qos_object *o) +{ +if (plist_head_empty (&o->requests)) +return o->default_value; + +switch (o->type) { +case PM_QOS_MIN : +return plist_first (&o->requests)->prio; + +case PM_QOS_MAX : +return plist_last (&o->requests)->prio; + +default : +/* runtime check for not using enum */ +BUG (); + } +} + +static inline s32 pm_qos_read_value (struct pm_qos_object *o) +{ +return o->target_value; +} + +static inline void pm_qos_set_value (struct pm_qos_object *o,s32 value) +{ + o->target_value = value; +} + +static void update_target (struct pm_qos_object *o,struct plist_node *node, +int del,int value) +{ +unsigned long flags; +int prev_value, curr_value; + +spin_lock_irqsave (&pm_qos_lock, flags); + prev_value =pm_qos_get_value (o); +/* PM_QOS_DEFAULT_VALUE is a signal that the value is unchanged */ +if (value !=PM_QOS_DEFAULT_VALUE ) { +/* +* to change the list, we atomically remove, reinit +* with new value and add, then see if the extremal +* changed +*/ +plist_del (node, &o->requests); +plist_node_init (node, value); +plist_add (node, &o->requests); + }else if (del) { +plist_del (node, &o->requests); + }else { +plist_add (node, &o->requests); + } + curr_value =pm_qos_get_value (o); +pm_qos_set_value (o, curr_value); +spin_unlock_irqrestore (&pm_qos_lock, flags); + +if (prev_value != curr_value) +blocking_notifier_call_chain (o->notifiers, + (unsigned long )curr_value, +NULL ); +} + +static int register_pm_qos_misc (struct pm_qos_object *qos) +{ + qos->pm_qos_power_miscdev.minor =MISC_DYNAMIC_MINOR ; + qos->pm_qos_power_miscdev.name = qos->name; + qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; + +return misc_register (&qos->pm_qos_power_miscdev); +} + +static int find_pm_qos_object_by_minor (int minor) +{ +int pm_qos_class; + +for (pm_qos_class =0 ; + pm_qos_class <PM_QOS_NUM_CLASSES ; pm_qos_class++) { +if (minor == + pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) +return pm_qos_class; + } +return -1 ; +} + +/** +* pm_qos_request - returns current system wide qos expectation +* @pm_qos_class: identification of which qos value is requested +* +* This function returns the current target value. +*/ +int pm_qos_request (int pm_qos_class) +{ +return pm_qos_read_value (pm_qos_array[pm_qos_class]); +} +EXPORT_SYMBOL_GPL (pm_qos_request); + +int pm_qos_request_active (struct pm_qos_request_list *req) +{ +return req->pm_qos_class !=0 ; +} +EXPORT_SYMBOL_GPL (pm_qos_request_active); + +/** +* pm_qos_add_request - inserts new qos request into the list +* @dep: pointer to a preallocated handle +* @pm_qos_class: identifies which list of qos request to use +* @value: defines the qos request +* +* This function inserts a new entry in the pm_qos_class list of requested qos +* performance characteristics. It recomputes the aggregate QoS expectations +* for the pm_qos_class of parameters and initializes the pm_qos_request_list +* handle. Caller needs to save this handle for later use in updates and +* removal. +*/ + +void pm_qos_add_request (struct pm_qos_request_list *dep, +int pm_qos_class,s32 value) +{ +struct pm_qos_object *o = pm_qos_array[pm_qos_class]; +int new_value; + +if (pm_qos_request_active (dep)) { +WARN (1 ,KERN_ERR "pm_qos_add_request() called for already added request\n" ); +return ; + } +if (value ==PM_QOS_DEFAULT_VALUE ) + new_value = o->default_value; +else + new_value = value; +plist_node_init (&dep->list, new_value); + dep->pm_qos_class = pm_qos_class; +update_target (o, &dep->list,0 ,PM_QOS_DEFAULT_VALUE ); +} +EXPORT_SYMBOL_GPL (pm_qos_add_request); + +/** +* pm_qos_update_request - modifies an existing qos request +* @pm_qos_req : handle to list element holding a pm_qos request to use +* @value: defines the qos request +* +* Updates an existing qos request for the pm_qos_class of parameters along +* with updating the target pm_qos_class value. +* +* Attempts are made to make this code callable on hot code paths. +*/ +void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +s32 new_value) +{ +s32 temp; +struct pm_qos_object *o; + +if (!pm_qos_req)/*guard against callers passing in null */ +return ; + +if (!pm_qos_request_active (pm_qos_req)) { +WARN (1 ,KERN_ERR "pm_qos_update_request() called for unknown object\n" ); +return ; + } + + o = pm_qos_array[pm_qos_req->pm_qos_class]; + +if (new_value ==PM_QOS_DEFAULT_VALUE ) + temp = o->default_value; +else + temp = new_value; + +if (temp != pm_qos_req->list.prio) +update_target (o, &pm_qos_req->list,0 , temp); +} +EXPORT_SYMBOL_GPL (pm_qos_update_request); + +/** +* pm_qos_remove_request - modifies an existing qos request +* @pm_qos_req: handle to request list element +* +* Will remove pm qos request from the list of requests and +* recompute the current target value for the pm_qos_class. Call this +* on slow code paths. +*/ +void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req) +{ +struct pm_qos_object *o; + +if (pm_qos_req ==NULL ) +return ; +/* silent return to keep pcm code cleaner */ + +if (!pm_qos_request_active (pm_qos_req)) { +WARN (1 ,KERN_ERR "pm_qos_remove_request() called for unknown object\n" ); +return ; + } + + o = pm_qos_array[pm_qos_req->pm_qos_class]; +update_target (o, &pm_qos_req->list,1 ,PM_QOS_DEFAULT_VALUE ); +memset (pm_qos_req,0 ,sizeof (*pm_qos_req)); +} +EXPORT_SYMBOL_GPL (pm_qos_remove_request); + +/** +* pm_qos_add_notifier - sets notification entry for changes to target value +* @pm_qos_class: identifies which qos target changes should be notified. +* @notifier: notifier block managed by caller. +* +* will register the notifier into a notification chain that gets called +* upon changes to the pm_qos_class target value. +*/ +int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier) +{ +int retval; + + retval =blocking_notifier_chain_register ( + pm_qos_array[pm_qos_class]->notifiers, notifier); + +return retval; +} +EXPORT_SYMBOL_GPL (pm_qos_add_notifier); + +/** +* pm_qos_remove_notifier - deletes notification entry from chain. +* @pm_qos_class: identifies which qos target changes are notified. +* @notifier: notifier block to be removed. +* +* will remove the notifier from the notification chain that gets called +* upon changes to the pm_qos_class target value. +*/ +int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier) +{ +int retval; + + retval =blocking_notifier_chain_unregister ( + pm_qos_array[pm_qos_class]->notifiers, notifier); + +return retval; +} +EXPORT_SYMBOL_GPL (pm_qos_remove_notifier); + +static int pm_qos_power_open (struct inode *inode,struct file *filp) +{ +long pm_qos_class; + + pm_qos_class =find_pm_qos_object_by_minor (iminor (inode)); +if (pm_qos_class >=0 ) { +struct pm_qos_request_list *req =kzalloc (sizeof (*req),GFP_KERNEL ); +if (!req) +return -ENOMEM ; + +pm_qos_add_request (req, pm_qos_class,PM_QOS_DEFAULT_VALUE ); + filp->private_data = req; + +if (filp->private_data) +return 0 ; + } +return -EPERM ; +} + +static int pm_qos_power_release (struct inode *inode,struct file *filp) +{ +struct pm_qos_request_list *req; + + req = filp->private_data; +pm_qos_remove_request (req); +kfree (req); + +return 0 ; +} + + +static ssize_t pm_qos_power_read (struct file *filp,char __user *buf, +size_t count,loff_t *f_pos) +{ +s32 value; +unsigned long flags; +struct pm_qos_object *o; +struct pm_qos_request_list *pm_qos_req = filp->private_data; + +if (!pm_qos_req) +return -EINVAL ; +if (!pm_qos_request_active (pm_qos_req)) +return -EINVAL ; + + o = pm_qos_array[pm_qos_req->pm_qos_class]; +spin_lock_irqsave (&pm_qos_lock, flags); + value =pm_qos_get_value (o); +spin_unlock_irqrestore (&pm_qos_lock, flags); + +return simple_read_from_buffer (buf, count, f_pos, &value,sizeof (s32)); +} + +static ssize_t pm_qos_power_write (struct file *filp,const char __user *buf, +size_t count,loff_t *f_pos) +{ +s32 value; +struct pm_qos_request_list *pm_qos_req; + +if (count ==sizeof (s32)) { +if (copy_from_user (&value, buf,sizeof (s32))) +return -EFAULT ; + }else if (count <=11 ) {/* ASCII perhaps? */ +char ascii_value[11 ]; +unsigned long int ulval; +int ret; + +if (copy_from_user (ascii_value, buf, count)) +return -EFAULT ; + +if (count >10 ) { +if (ascii_value[10 ] =='\n' ) + ascii_value[10 ] ='\0' ; +else +return -EINVAL ; + }else { + ascii_value[count] ='\0' ; + } + ret =strict_strtoul (ascii_value,16 , &ulval); +if (ret) { +pr_debug ("%s, 0x%lx, 0x%x\n" , ascii_value, ulval, ret); +return -EINVAL ; + } + value = (s32 )lower_32_bits (ulval); + }else { +return -EINVAL ; + } + + pm_qos_req = filp->private_data; +pm_qos_update_request (pm_qos_req, value); + +return count; +} + + +static int __init pm_qos_power_init (void ) +{ +int ret =0 ; + + ret =register_pm_qos_misc (&cpu_dma_pm_qos); +if (ret <0 ) { +printk (KERN_ERR "pm_qos_param: cpu_dma_latency setup failed\n" ); +return ret; + } + ret =register_pm_qos_misc (&network_lat_pm_qos); +if (ret <0 ) { +printk (KERN_ERR "pm_qos_param: network_latency setup failed\n" ); +return ret; + } + ret =register_pm_qos_misc (&network_throughput_pm_qos); +if (ret <0 ) +printk (KERN_ERR +"pm_qos_param: network_throughput setup failed\n" ); + +return ret; +} + +late_initcall (pm_qos_power_init);net/mac80211/main.c +1
-1@@ -19,7 +19,7 @@#include <linux/if_arp.h> #include <linux/rtnetlink.h> #include <linux/bitmap.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/inetdevice.h> #include <net/net_namespace.h> #include <net/cfg80211.h> net/mac80211/mlme.c +1
-1@@ -17,7 +17,7 @@#include <linux/if_arp.h> #include <linux/etherdevice.h> #include <linux/rtnetlink.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/crc32.h> #include <linux/slab.h> #include <net/mac80211.h> net/mac80211/scan.c +1
-1@@ -14,7 +14,7 @@#include <linux/if_arp.h> #include <linux/rtnetlink.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <net/sch_generic.h> #include <linux/slab.h> #include <net/mac80211.h> sound/core/pcm_native.c +1
-1@@ -23,7 +23,7 @@#include <linux/file.h> #include <linux/slab.h> #include <linux/time.h> -#include <linux/pm_qos_params.h> +#include <linux/pm_qos.h> #include <linux/uio.h> #include <linux/dma-mapping.h> #include <sound/core.h> Signature · 1 line
1.7.2.5
Re: [PATCH 02/15] PM QoS: minor clean-ups
In reply to [email protected]Quoted 402 lines · On Thu, Aug 11, 2011 at 05:06:39PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
- Misc fixes to improve code readability:
. rename structpm_qos_request_listto structpm_qos_request, . renamepm_qos_reqparameter to req in internal code,
consistenly use req in the API parameters,
. update the in-kernel API callers to the new parameters names, . rename of fields names (requests, list, node, constraints)Signed-off-by Jean Pihet <[email protected]>--- drivers/media/video/via-camera.c | 2 +- drivers/net/wireless/ipw2x00/ipw2100.c | 2 +- include/linux/netdevice.h | 2 +- include/linux/pm_qos.h | 22 ++++---- include/sound/pcm.h | 2 +- kernel/power/qos.c | 90 ++++++++++++++++--------------- 6 files changed, 61 insertions(+), 59 deletions(-)drivers/media/video/via-camera.c +1
-1@@ -69,7 +69,7 @@ struct via_camera {struct mutex lock;enum viacam_opstate opstate;unsigned long flags; -struct pm_qos_request_list qos_request; +struct pm_qos_request qos_request;/* * GPIO info for power/reset management */ drivers/net/wireless/ipw2x00/ipw2100.c +1
-1@@ -174,7 +174,7 @@ that only one external action is invoked at a time.#define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2100 Network Driver"#define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation" -static struct pm_qos_request_list ipw2100_pm_qos_req; +static struct pm_qos_request ipw2100_pm_qos_req;/* Debugging stuff */ #ifdef CONFIG_IPW2100_DEBUG include/linux/netdevice.h +1
-1@@ -999,7 +999,7 @@ struct net_device {*/ char name[IFNAMSIZ ]; -struct pm_qos_request_list pm_qos_req; +struct pm_qos_request pm_qos_req;/* device name hash chain */ struct hlist_node name_hlist;include/linux/pm_qos.h +11
-11@@ -20,30 +20,30 @@#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 -struct pm_qos_request_list { -struct plist_node list; +struct pm_qos_request { +struct plist_node node;int pm_qos_class; };#ifdef CONFIG_PM -void pm_qos_add_request (struct pm_qos_request_list *l, -int pm_qos_class,s32 value); -void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class, +s32 value); +void pm_qos_update_request (struct pm_qos_request *req,s32 new_value); -void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req); +void pm_qos_remove_request (struct pm_qos_request *req);int pm_qos_request (int pm_qos_class);int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier); -int pm_qos_request_active (struct pm_qos_request_list *req); +int pm_qos_request_active (struct pm_qos_request *req);#else -static inline void pm_qos_add_request (struct pm_qos_request_list *l, +static inline void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) {return ; } -static inline void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +static inline void pm_qos_update_request (struct pm_qos_request *req,s32 new_value) {return ; } -static inline void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req) +static inline void pm_qos_remove_request (struct pm_qos_request *req) {return ; }static inline int pm_qos_request (int pm_qos_class)@@ -54,7 +54,7 @@ static inline int pm_qos_add_notifier(int pm_qos_class,static inline int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier) {return 0 ; } -static inline int pm_qos_request_active (struct pm_qos_request_list *req) +static inline int pm_qos_request_active (struct pm_qos_request *req) {return 0 ; }#endif include/sound/pcm.h +1
-1@@ -373,7 +373,7 @@ struct snd_pcm_substream {int number;char name[32 ];/* substream name */ int stream;/* stream (direction) */ -struct pm_qos_request_list latency_pm_qos_req;/* pm_qos request */ +struct pm_qos_request latency_pm_qos_req;/* pm_qos request */ size_t buffer_bytes_max;/* limit ring buffer size */ struct snd_dma_buffer dma_buffer;unsigned int dma_buf_id;kernel/power/qos.c +46
-44@@ -45,7 +45,7 @@#include <linux/uaccess.h> /* -* locking rule: all changes to requests or notifiers lists +* locking rule: all changes to constraints or notifiers lists * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock * held, taken with _irqsave. One lock to rule them all */ @@ -60,7 +60,7 @@ enum pm_qos_type {* types linux supports for 32 bit quantites */ struct pm_qos_object { -struct plist_head requests; +struct plist_head constraints;struct blocking_notifier_head *notifiers;struct miscdevice pm_qos_power_miscdev;char *name;@@ -74,7 +74,7 @@ static DEFINE_SPINLOCK(pm_qos_lock);static struct pm_qos_object null_pm_qos;static BLOCKING_NOTIFIER_HEAD (cpu_dma_lat_notifier);static struct pm_qos_object cpu_dma_pm_qos = { - .requests =PLIST_HEAD_INIT (cpu_dma_pm_qos.requests, pm_qos_lock), + .constraints =PLIST_HEAD_INIT (cpu_dma_pm_qos.constraints, pm_qos_lock), .notifiers = &cpu_dma_lat_notifier, .name ="cpu_dma_latency" , .target_value =PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE ,@@ -84,7 +84,8 @@ static struct pm_qos_object cpu_dma_pm_qos = {static BLOCKING_NOTIFIER_HEAD (network_lat_notifier);static struct pm_qos_object network_lat_pm_qos = { - .requests =PLIST_HEAD_INIT (network_lat_pm_qos.requests, pm_qos_lock), + .constraints =PLIST_HEAD_INIT (network_lat_pm_qos.constraints, + pm_qos_lock), .notifiers = &network_lat_notifier, .name ="network_latency" , .target_value =PM_QOS_NETWORK_LAT_DEFAULT_VALUE ,@@ -95,7 +96,8 @@ static struct pm_qos_object network_lat_pm_qos = {static BLOCKING_NOTIFIER_HEAD (network_throughput_notifier);static struct pm_qos_object network_throughput_pm_qos = { - .requests =PLIST_HEAD_INIT (network_throughput_pm_qos.requests, pm_qos_lock), + .constraints =PLIST_HEAD_INIT (network_throughput_pm_qos.constraints, + pm_qos_lock), .notifiers = &network_throughput_notifier, .name ="network_throughput" , .target_value =PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE ,@@ -129,15 +131,15 @@ static const struct file_operations pm_qos_power_fops = {/* unlocked internal variant */ static inline int pm_qos_get_value (struct pm_qos_object *o) { -if (plist_head_empty (&o->requests)) +if (plist_head_empty (&o->constraints))return o->default_value;switch (o->type) {case PM_QOS_MIN : -return plist_first (&o->requests)->prio; +return plist_first (&o->constraints)->prio;case PM_QOS_MAX : -return plist_last (&o->requests)->prio; +return plist_last (&o->constraints)->prio;default :/* runtime check for not using enum */ @@ -170,13 +172,13 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node,* with new value and add, then see if the extremal * changed */ -plist_del (node, &o->requests); +plist_del (node, &o->constraints);plist_node_init (node, value); -plist_add (node, &o->requests); +plist_add (node, &o->constraints); }else if (del) { -plist_del (node, &o->requests); +plist_del (node, &o->constraints); }else { -plist_add (node, &o->requests); +plist_add (node, &o->constraints); } curr_value =pm_qos_get_value (o);pm_qos_set_value (o, curr_value);@@ -222,7 +224,7 @@ int pm_qos_request(int pm_qos_class) }EXPORT_SYMBOL_GPL (pm_qos_request); -int pm_qos_request_active (struct pm_qos_request_list *req) +int pm_qos_request_active (struct pm_qos_request *req) {return req->pm_qos_class !=0 ; }@@ -230,24 +232,24 @@ EXPORT_SYMBOL_GPL(pm_qos_request_active);/** * pm_qos_add_request - inserts new qos request into the list -* @dep: pointer to a preallocated handle +* @req: pointer to a preallocated handle * @pm_qos_class: identifies which list of qos request to use * @value: defines the qos request * * This function inserts a new entry in the pm_qos_class list of requested qos * performance characteristics. It recomputes the aggregate QoS expectations -* for the pm_qos_class of parameters and initializes the pm_qos_request_list +* for the pm_qos_class of parameters and initializes the pm_qos_request * handle. Caller needs to save this handle for later use in updates and * removal. */ -void pm_qos_add_request (struct pm_qos_request_list *dep, +void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) {struct pm_qos_object *o = pm_qos_array[pm_qos_class];int new_value; -if (pm_qos_request_active (dep)) { +if (pm_qos_request_active (req)) {WARN (1 ,KERN_ERR "pm_qos_add_request() called for already added request\n" );return ; }@@ -255,15 +257,15 @@ void pm_qos_add_request(struct pm_qos_request_list *dep, new_value = o->default_value; else new_value = value; -plist_node_init (&dep->list, new_value); - dep->pm_qos_class = pm_qos_class; -update_target (o, &dep->list,0 ,PM_QOS_DEFAULT_VALUE ); +plist_node_init (&req->node, new_value); + req->pm_qos_class = pm_qos_class; +update_target (o, &req->node,0 ,PM_QOS_DEFAULT_VALUE ); }EXPORT_SYMBOL_GPL (pm_qos_add_request);/** * pm_qos_update_request - modifies an existing qos request -* @pm_qos_req : handle to list element holding a pm_qos request to use +* @req : handle to list element holding a pm_qos request to use * @value: defines the qos request * * Updates an existing qos request for the pm_qos_class of parameters along @@ -271,56 +273,56 @@ EXPORT_SYMBOL_GPL(pm_qos_add_request);* * Attempts are made to make this code callable on hot code paths. */ -void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +void pm_qos_update_request (struct pm_qos_request *req,s32 new_value) {s32 temp;struct pm_qos_object *o; -if (!pm_qos_req)/*guard against callers passing in null */ +if (!req)/*guard against callers passing in null */ return ; -if (!pm_qos_request_active (pm_qos_req)) { +if (!pm_qos_request_active (req)) {WARN (1 ,KERN_ERR "pm_qos_update_request() called for unknown object\n" );return ; } - o = pm_qos_array[pm_qos_req->pm_qos_class]; + o = pm_qos_array[req->pm_qos_class];if (new_value ==PM_QOS_DEFAULT_VALUE ) temp = o->default_value;else temp = new_value; -if (temp != pm_qos_req->list.prio) -update_target (o, &pm_qos_req->list,0 , temp); +if (temp != req->node.prio) +update_target (o, &req->node,0 , temp); }EXPORT_SYMBOL_GPL (pm_qos_update_request);/** * pm_qos_remove_request - modifies an existing qos request -* @pm_qos_req: handle to request list element +* @req: handle to request list element * -* Will remove pm qos request from the list of requests and +* Will remove pm qos request from the list of constraints and * recompute the current target value for the pm_qos_class. Call this * on slow code paths. */ -void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req) +void pm_qos_remove_request (struct pm_qos_request *req) {struct pm_qos_object *o; -if (pm_qos_req ==NULL ) +if (req ==NULL )return ;/* silent return to keep pcm code cleaner */ -if (!pm_qos_request_active (pm_qos_req)) { +if (!pm_qos_request_active (req)) {WARN (1 ,KERN_ERR "pm_qos_remove_request() called for unknown object\n" );return ; } - o = pm_qos_array[pm_qos_req->pm_qos_class]; -update_target (o, &pm_qos_req->list,1 ,PM_QOS_DEFAULT_VALUE ); -memset (pm_qos_req,0 ,sizeof (*pm_qos_req)); + o = pm_qos_array[req->pm_qos_class]; +update_target (o, &req->node,1 ,PM_QOS_DEFAULT_VALUE ); +memset (req,0 ,sizeof (*req)); }EXPORT_SYMBOL_GPL (pm_qos_remove_request);@@ -368,7 +370,7 @@ static int pm_qos_power_open(struct inode *inode, struct file *filp) pm_qos_class =find_pm_qos_object_by_minor (iminor (inode));if (pm_qos_class >=0 ) { -struct pm_qos_request_list *req =kzalloc (sizeof (*req),GFP_KERNEL ); +struct pm_qos_request *req =kzalloc (sizeof (*req),GFP_KERNEL );if (!req)return -ENOMEM ;@@ -383,7 +385,7 @@ static int pm_qos_power_open(struct inode *inode, struct file *filp)static int pm_qos_power_release (struct inode *inode,struct file *filp) { -struct pm_qos_request_list *req; +struct pm_qos_request *req; req = filp->private_data;pm_qos_remove_request (req);@@ -399,14 +401,14 @@ static ssize_t pm_qos_power_read(struct file *filp, char __user *buf,s32 value;unsigned long flags;struct pm_qos_object *o; -struct pm_qos_request_list *pm_qos_req = filp->private_data; +struct pm_qos_request *req = filp->private_data; -if (!pm_qos_req) +if (!req)return -EINVAL ; -if (!pm_qos_request_active (pm_qos_req)) +if (!pm_qos_request_active (req))return -EINVAL ; - o = pm_qos_array[pm_qos_req->pm_qos_class]; + o = pm_qos_array[req->pm_qos_class];spin_lock_irqsave (&pm_qos_lock, flags); value =pm_qos_get_value (o);spin_unlock_irqrestore (&pm_qos_lock, flags);@@ -418,7 +420,7 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) { s32 value; -struct pm_qos_request_list *pm_qos_req; +struct pm_qos_request *req;if (count ==sizeof (s32)) {if (copy_from_user (&value, buf,sizeof (s32)))@@ -449,8 +451,8 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,return -EINVAL ; } - pm_qos_req = filp->private_data; -pm_qos_update_request (pm_qos_req, value); + req = filp->private_data; +pm_qos_update_request (req, value);return count; }Signature · 1 line
1.7.2.5
Re: [PATCH 02/15] PM QoS: minor clean-ups
In reply to [email protected]Quoted 402 lines · On Thu, Aug 11, 2011 at 05:06:39PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
- Misc fixes to improve code readability:
. rename structpm_qos_request_listto structpm_qos_request, . renamepm_qos_reqparameter to req in internal code,
consistenly use req in the API parameters,
. update the in-kernel API callers to the new parameters names, . rename of fields names (requests, list, node, constraints)Signed-off-by Jean Pihet <[email protected]>--- drivers/media/video/via-camera.c | 2 +- drivers/net/wireless/ipw2x00/ipw2100.c | 2 +- include/linux/netdevice.h | 2 +- include/linux/pm_qos.h | 22 ++++---- include/sound/pcm.h | 2 +- kernel/power/qos.c | 90 ++++++++++++++++--------------- 6 files changed, 61 insertions(+), 59 deletions(-)drivers/media/video/via-camera.c +1
-1@@ -69,7 +69,7 @@ struct via_camera {struct mutex lock;enum viacam_opstate opstate;unsigned long flags; -struct pm_qos_request_list qos_request; +struct pm_qos_request qos_request;/* * GPIO info for power/reset management */ drivers/net/wireless/ipw2x00/ipw2100.c +1
-1@@ -174,7 +174,7 @@ that only one external action is invoked at a time.#define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2100 Network Driver"#define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation" -static struct pm_qos_request_list ipw2100_pm_qos_req; +static struct pm_qos_request ipw2100_pm_qos_req;/* Debugging stuff */ #ifdef CONFIG_IPW2100_DEBUG include/linux/netdevice.h +1
-1@@ -999,7 +999,7 @@ struct net_device {*/ char name[IFNAMSIZ ]; -struct pm_qos_request_list pm_qos_req; +struct pm_qos_request pm_qos_req;/* device name hash chain */ struct hlist_node name_hlist;include/linux/pm_qos.h +11
-11@@ -20,30 +20,30 @@#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 -struct pm_qos_request_list { -struct plist_node list; +struct pm_qos_request { +struct plist_node node;int pm_qos_class; };#ifdef CONFIG_PM -void pm_qos_add_request (struct pm_qos_request_list *l, -int pm_qos_class,s32 value); -void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class, +s32 value); +void pm_qos_update_request (struct pm_qos_request *req,s32 new_value); -void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req); +void pm_qos_remove_request (struct pm_qos_request *req);int pm_qos_request (int pm_qos_class);int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier); -int pm_qos_request_active (struct pm_qos_request_list *req); +int pm_qos_request_active (struct pm_qos_request *req);#else -static inline void pm_qos_add_request (struct pm_qos_request_list *l, +static inline void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) {return ; } -static inline void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +static inline void pm_qos_update_request (struct pm_qos_request *req,s32 new_value) {return ; } -static inline void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req) +static inline void pm_qos_remove_request (struct pm_qos_request *req) {return ; }static inline int pm_qos_request (int pm_qos_class)@@ -54,7 +54,7 @@ static inline int pm_qos_add_notifier(int pm_qos_class,static inline int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier) {return 0 ; } -static inline int pm_qos_request_active (struct pm_qos_request_list *req) +static inline int pm_qos_request_active (struct pm_qos_request *req) {return 0 ; }#endif include/sound/pcm.h +1
-1@@ -373,7 +373,7 @@ struct snd_pcm_substream {int number;char name[32 ];/* substream name */ int stream;/* stream (direction) */ -struct pm_qos_request_list latency_pm_qos_req;/* pm_qos request */ +struct pm_qos_request latency_pm_qos_req;/* pm_qos request */ size_t buffer_bytes_max;/* limit ring buffer size */ struct snd_dma_buffer dma_buffer;unsigned int dma_buf_id;kernel/power/qos.c +46
-44@@ -45,7 +45,7 @@#include <linux/uaccess.h> /* -* locking rule: all changes to requests or notifiers lists +* locking rule: all changes to constraints or notifiers lists * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock * held, taken with _irqsave. One lock to rule them all */ @@ -60,7 +60,7 @@ enum pm_qos_type {* types linux supports for 32 bit quantites */ struct pm_qos_object { -struct plist_head requests; +struct plist_head constraints;struct blocking_notifier_head *notifiers;struct miscdevice pm_qos_power_miscdev;char *name;@@ -74,7 +74,7 @@ static DEFINE_SPINLOCK(pm_qos_lock);static struct pm_qos_object null_pm_qos;static BLOCKING_NOTIFIER_HEAD (cpu_dma_lat_notifier);static struct pm_qos_object cpu_dma_pm_qos = { - .requests =PLIST_HEAD_INIT (cpu_dma_pm_qos.requests, pm_qos_lock), + .constraints =PLIST_HEAD_INIT (cpu_dma_pm_qos.constraints, pm_qos_lock), .notifiers = &cpu_dma_lat_notifier, .name ="cpu_dma_latency" , .target_value =PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE ,@@ -84,7 +84,8 @@ static struct pm_qos_object cpu_dma_pm_qos = {static BLOCKING_NOTIFIER_HEAD (network_lat_notifier);static struct pm_qos_object network_lat_pm_qos = { - .requests =PLIST_HEAD_INIT (network_lat_pm_qos.requests, pm_qos_lock), + .constraints =PLIST_HEAD_INIT (network_lat_pm_qos.constraints, + pm_qos_lock), .notifiers = &network_lat_notifier, .name ="network_latency" , .target_value =PM_QOS_NETWORK_LAT_DEFAULT_VALUE ,@@ -95,7 +96,8 @@ static struct pm_qos_object network_lat_pm_qos = {static BLOCKING_NOTIFIER_HEAD (network_throughput_notifier);static struct pm_qos_object network_throughput_pm_qos = { - .requests =PLIST_HEAD_INIT (network_throughput_pm_qos.requests, pm_qos_lock), + .constraints =PLIST_HEAD_INIT (network_throughput_pm_qos.constraints, + pm_qos_lock), .notifiers = &network_throughput_notifier, .name ="network_throughput" , .target_value =PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE ,@@ -129,15 +131,15 @@ static const struct file_operations pm_qos_power_fops = {/* unlocked internal variant */ static inline int pm_qos_get_value (struct pm_qos_object *o) { -if (plist_head_empty (&o->requests)) +if (plist_head_empty (&o->constraints))return o->default_value;switch (o->type) {case PM_QOS_MIN : -return plist_first (&o->requests)->prio; +return plist_first (&o->constraints)->prio;case PM_QOS_MAX : -return plist_last (&o->requests)->prio; +return plist_last (&o->constraints)->prio;default :/* runtime check for not using enum */ @@ -170,13 +172,13 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node,* with new value and add, then see if the extremal * changed */ -plist_del (node, &o->requests); +plist_del (node, &o->constraints);plist_node_init (node, value); -plist_add (node, &o->requests); +plist_add (node, &o->constraints); }else if (del) { -plist_del (node, &o->requests); +plist_del (node, &o->constraints); }else { -plist_add (node, &o->requests); +plist_add (node, &o->constraints); } curr_value =pm_qos_get_value (o);pm_qos_set_value (o, curr_value);@@ -222,7 +224,7 @@ int pm_qos_request(int pm_qos_class) }EXPORT_SYMBOL_GPL (pm_qos_request); -int pm_qos_request_active (struct pm_qos_request_list *req) +int pm_qos_request_active (struct pm_qos_request *req) {return req->pm_qos_class !=0 ; }@@ -230,24 +232,24 @@ EXPORT_SYMBOL_GPL(pm_qos_request_active);/** * pm_qos_add_request - inserts new qos request into the list -* @dep: pointer to a preallocated handle +* @req: pointer to a preallocated handle * @pm_qos_class: identifies which list of qos request to use * @value: defines the qos request * * This function inserts a new entry in the pm_qos_class list of requested qos * performance characteristics. It recomputes the aggregate QoS expectations -* for the pm_qos_class of parameters and initializes the pm_qos_request_list +* for the pm_qos_class of parameters and initializes the pm_qos_request * handle. Caller needs to save this handle for later use in updates and * removal. */ -void pm_qos_add_request (struct pm_qos_request_list *dep, +void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) {struct pm_qos_object *o = pm_qos_array[pm_qos_class];int new_value; -if (pm_qos_request_active (dep)) { +if (pm_qos_request_active (req)) {WARN (1 ,KERN_ERR "pm_qos_add_request() called for already added request\n" );return ; }@@ -255,15 +257,15 @@ void pm_qos_add_request(struct pm_qos_request_list *dep, new_value = o->default_value; else new_value = value; -plist_node_init (&dep->list, new_value); - dep->pm_qos_class = pm_qos_class; -update_target (o, &dep->list,0 ,PM_QOS_DEFAULT_VALUE ); +plist_node_init (&req->node, new_value); + req->pm_qos_class = pm_qos_class; +update_target (o, &req->node,0 ,PM_QOS_DEFAULT_VALUE ); }EXPORT_SYMBOL_GPL (pm_qos_add_request);/** * pm_qos_update_request - modifies an existing qos request -* @pm_qos_req : handle to list element holding a pm_qos request to use +* @req : handle to list element holding a pm_qos request to use * @value: defines the qos request * * Updates an existing qos request for the pm_qos_class of parameters along @@ -271,56 +273,56 @@ EXPORT_SYMBOL_GPL(pm_qos_add_request);* * Attempts are made to make this code callable on hot code paths. */ -void pm_qos_update_request (struct pm_qos_request_list *pm_qos_req, +void pm_qos_update_request (struct pm_qos_request *req,s32 new_value) {s32 temp;struct pm_qos_object *o; -if (!pm_qos_req)/*guard against callers passing in null */ +if (!req)/*guard against callers passing in null */ return ; -if (!pm_qos_request_active (pm_qos_req)) { +if (!pm_qos_request_active (req)) {WARN (1 ,KERN_ERR "pm_qos_update_request() called for unknown object\n" );return ; } - o = pm_qos_array[pm_qos_req->pm_qos_class]; + o = pm_qos_array[req->pm_qos_class];if (new_value ==PM_QOS_DEFAULT_VALUE ) temp = o->default_value;else temp = new_value; -if (temp != pm_qos_req->list.prio) -update_target (o, &pm_qos_req->list,0 , temp); +if (temp != req->node.prio) +update_target (o, &req->node,0 , temp); }EXPORT_SYMBOL_GPL (pm_qos_update_request);/** * pm_qos_remove_request - modifies an existing qos request -* @pm_qos_req: handle to request list element +* @req: handle to request list element * -* Will remove pm qos request from the list of requests and +* Will remove pm qos request from the list of constraints and * recompute the current target value for the pm_qos_class. Call this * on slow code paths. */ -void pm_qos_remove_request (struct pm_qos_request_list *pm_qos_req) +void pm_qos_remove_request (struct pm_qos_request *req) {struct pm_qos_object *o; -if (pm_qos_req ==NULL ) +if (req ==NULL )return ;/* silent return to keep pcm code cleaner */ -if (!pm_qos_request_active (pm_qos_req)) { +if (!pm_qos_request_active (req)) {WARN (1 ,KERN_ERR "pm_qos_remove_request() called for unknown object\n" );return ; } - o = pm_qos_array[pm_qos_req->pm_qos_class]; -update_target (o, &pm_qos_req->list,1 ,PM_QOS_DEFAULT_VALUE ); -memset (pm_qos_req,0 ,sizeof (*pm_qos_req)); + o = pm_qos_array[req->pm_qos_class]; +update_target (o, &req->node,1 ,PM_QOS_DEFAULT_VALUE ); +memset (req,0 ,sizeof (*req)); }EXPORT_SYMBOL_GPL (pm_qos_remove_request);@@ -368,7 +370,7 @@ static int pm_qos_power_open(struct inode *inode, struct file *filp) pm_qos_class =find_pm_qos_object_by_minor (iminor (inode));if (pm_qos_class >=0 ) { -struct pm_qos_request_list *req =kzalloc (sizeof (*req),GFP_KERNEL ); +struct pm_qos_request *req =kzalloc (sizeof (*req),GFP_KERNEL );if (!req)return -ENOMEM ;@@ -383,7 +385,7 @@ static int pm_qos_power_open(struct inode *inode, struct file *filp)static int pm_qos_power_release (struct inode *inode,struct file *filp) { -struct pm_qos_request_list *req; +struct pm_qos_request *req; req = filp->private_data;pm_qos_remove_request (req);@@ -399,14 +401,14 @@ static ssize_t pm_qos_power_read(struct file *filp, char __user *buf,s32 value;unsigned long flags;struct pm_qos_object *o; -struct pm_qos_request_list *pm_qos_req = filp->private_data; +struct pm_qos_request *req = filp->private_data; -if (!pm_qos_req) +if (!req)return -EINVAL ; -if (!pm_qos_request_active (pm_qos_req)) +if (!pm_qos_request_active (req))return -EINVAL ; - o = pm_qos_array[pm_qos_req->pm_qos_class]; + o = pm_qos_array[req->pm_qos_class];spin_lock_irqsave (&pm_qos_lock, flags); value =pm_qos_get_value (o);spin_unlock_irqrestore (&pm_qos_lock, flags);@@ -418,7 +420,7 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) { s32 value; -struct pm_qos_request_list *pm_qos_req; +struct pm_qos_request *req;if (count ==sizeof (s32)) {if (copy_from_user (&value, buf,sizeof (s32)))@@ -449,8 +451,8 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,return -EINVAL ; } - pm_qos_req = filp->private_data; -pm_qos_update_request (pm_qos_req, value); + req = filp->private_data; +pm_qos_update_request (req, value);return count; }Signature · 1 line
1.7.2.5
Re: [PATCH 03/15] PM QoS: code re-organization
In reply to [email protected]Quoted 76 lines · On Thu, Aug 11, 2011 at 05:06:40PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
Move around the PM QoS misc devices management code for better readability.
Signed-off-by Jean Pihet <[email protected]>--- kernel/power/qos.c | 45 +++++++++++++++++++++++---------------------- 1 files changed, 23 insertions(+), 22 deletions(-)kernel/power/qos.c +23
-22@@ -190,28 +190,6 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node, NULL); } -static int register_pm_qos_misc (struct pm_qos_object *qos) -{ - qos->pm_qos_power_miscdev.minor =MISC_DYNAMIC_MINOR ; - qos->pm_qos_power_miscdev.name = qos->name; - qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; - -return misc_register (&qos->pm_qos_power_miscdev); -} - -static int find_pm_qos_object_by_minor (int minor) -{ -int pm_qos_class; - -for (pm_qos_class =0 ; - pm_qos_class <PM_QOS_NUM_CLASSES ; pm_qos_class++) { -if (minor == - pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) -return pm_qos_class; - } -return -1 ; -} -/** * pm_qos_request - returns current system wide qos expectation * @pm_qos_class: identification of which qos value is requested @@ -364,6 +342,29 @@ int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier) }EXPORT_SYMBOL_GPL (pm_qos_remove_notifier); +/* User space interface to PM QoS classes via misc devices */ +static int register_pm_qos_misc (struct pm_qos_object *qos) +{ + qos->pm_qos_power_miscdev.minor =MISC_DYNAMIC_MINOR ; + qos->pm_qos_power_miscdev.name = qos->name; + qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; + +return misc_register (&qos->pm_qos_power_miscdev); +} + +static int find_pm_qos_object_by_minor (int minor) +{ +int pm_qos_class; + +for (pm_qos_class =0 ; + pm_qos_class <PM_QOS_NUM_CLASSES ; pm_qos_class++) { +if (minor == + pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) +return pm_qos_class; + } +return -1 ; +} +static int pm_qos_power_open (struct inode *inode,struct file *filp) {long pm_qos_class;Signature · 1 line
1.7.2.5
I don't see the point of this but its ok.
Re: [PATCH 03/15] PM QoS: code re-organization
In reply to [email protected]Quoted 76 lines · On Thu, Aug 11, 2011 at 05:06:40PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
Move around the PM QoS misc devices management code for better readability.
Signed-off-by Jean Pihet <[email protected]>--- kernel/power/qos.c | 45 +++++++++++++++++++++++---------------------- 1 files changed, 23 insertions(+), 22 deletions(-)kernel/power/qos.c +23
-22@@ -190,28 +190,6 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node, NULL); } -static int register_pm_qos_misc (struct pm_qos_object *qos) -{ - qos->pm_qos_power_miscdev.minor =MISC_DYNAMIC_MINOR ; - qos->pm_qos_power_miscdev.name = qos->name; - qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; - -return misc_register (&qos->pm_qos_power_miscdev); -} - -static int find_pm_qos_object_by_minor (int minor) -{ -int pm_qos_class; - -for (pm_qos_class =0 ; - pm_qos_class <PM_QOS_NUM_CLASSES ; pm_qos_class++) { -if (minor == - pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) -return pm_qos_class; - } -return -1 ; -} -/** * pm_qos_request - returns current system wide qos expectation * @pm_qos_class: identification of which qos value is requested @@ -364,6 +342,29 @@ int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier) }EXPORT_SYMBOL_GPL (pm_qos_remove_notifier); +/* User space interface to PM QoS classes via misc devices */ +static int register_pm_qos_misc (struct pm_qos_object *qos) +{ + qos->pm_qos_power_miscdev.minor =MISC_DYNAMIC_MINOR ; + qos->pm_qos_power_miscdev.name = qos->name; + qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; + +return misc_register (&qos->pm_qos_power_miscdev); +} + +static int find_pm_qos_object_by_minor (int minor) +{ +int pm_qos_class; + +for (pm_qos_class =0 ; + pm_qos_class <PM_QOS_NUM_CLASSES ; pm_qos_class++) { +if (minor == + pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) +return pm_qos_class; + } +return -1 ; +} +static int pm_qos_power_open (struct inode *inode,struct file *filp) {long pm_qos_class;Signature · 1 line
1.7.2.5
I don't see the point of this but its ok.
Re: [PATCH 04/15] PM QoS: re-organize data structs
In reply to [email protected]Quoted 21 lines · On Thu, Aug 11, 2011 at 05:06:41PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support, re-organize the data strctures:
- add a structpm_qos_constraintswhich contains the constraints related data
- update structpm_qos_objectcontents to the PM QoS internal object data. Add a pointer to structpm_qos_constraints
- update the internal code to use the new data structs.Signed-off-by Jean Pihet <[email protected]>--- include/linux/pm_qos.h | 19 ++++++++++ kernel/power/qos.c | 90 ++++++++++++++++++++++------------------------- 2 files changed, 61 insertions(+), 48 deletions(-)include/linux/pm_qos.h +0
-0
include/linux/pm_qos.h struct pm_qos_request { · line 29
Quoted 5 lines
include/linux/pm_qos.h +2
-0@@ -25,6 +25,25 @@ struct pm_qos_request {int pm_qos_class; }; +enum pm_qos_type { +PM_QOS_UNITIALIZED ,
what is this for?
Quoted 214 lines
include/linux/pm_qos.h +17
-0+PM_QOS_MAX ,/* return the largest value */ + PM_QOS_MIN /* return the smallest value */ +}; + +/* +* Note: The lockless read path depends on the CPU accessing +* target_value atomically. Atomic access is only guaranteed on all CPU +* types linux supports for 32 bit quantites +*/ +struct pm_qos_constraints { +struct plist_head list; +s32 target_value;/* Do not change to 64 bit */ +s32 default_value; +enum pm_qos_type type; +struct blocking_notifier_head *notifiers; +}; +#ifdef CONFIG_PM void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value);kernel/power/qos.c +42
-48@@ -49,62 +49,54 @@* or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock * held, taken with _irqsave. One lock to rule them all */ -enum pm_qos_type { -PM_QOS_MAX ,/* return the largest value */ -PM_QOS_MIN /* return the smallest value */ -}; - -/* -* Note: The lockless read path depends on the CPU accessing -* target_value atomically. Atomic access is only guaranteed on all CPU -* types linux supports for 32 bit quantites -*/ struct pm_qos_object { -struct plist_head constraints; -struct blocking_notifier_head *notifiers; +struct pm_qos_constraints *constraints;struct miscdevice pm_qos_power_miscdev;char *name; -s32 target_value;/* Do not change to 64 bit */ -s32 default_value; -enum pm_qos_type type; };static DEFINE_SPINLOCK (pm_qos_lock);static struct pm_qos_object null_pm_qos; +static BLOCKING_NOTIFIER_HEAD (cpu_dma_lat_notifier); -static struct pm_qos_object cpu_dma_pm_qos = { - .constraints =PLIST_HEAD_INIT (cpu_dma_pm_qos.constraints, pm_qos_lock), - .notifiers = &cpu_dma_lat_notifier, - .name ="cpu_dma_latency" , +static struct pm_qos_constraints cpu_dma_constraints = { + .list =PLIST_HEAD_INIT (cpu_dma_constraints.list, pm_qos_lock), .target_value =PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE , .default_value =PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE , .type =PM_QOS_MIN , + .notifiers = &cpu_dma_lat_notifier, +}; +static struct pm_qos_object cpu_dma_pm_qos = { + .constraints = &cpu_dma_constraints, + .name ="cpu_dma_latency" , };static BLOCKING_NOTIFIER_HEAD (network_lat_notifier); -static struct pm_qos_object network_lat_pm_qos = { - .constraints =PLIST_HEAD_INIT (network_lat_pm_qos.constraints, - pm_qos_lock), - .notifiers = &network_lat_notifier, - .name ="network_latency" , +static struct pm_qos_constraints network_lat_constraints = { + .list =PLIST_HEAD_INIT (network_lat_constraints.list, pm_qos_lock), .target_value =PM_QOS_NETWORK_LAT_DEFAULT_VALUE , .default_value =PM_QOS_NETWORK_LAT_DEFAULT_VALUE , - .type =PM_QOS_MIN + .type =PM_QOS_MIN , + .notifiers = &network_lat_notifier, +}; +static struct pm_qos_object network_lat_pm_qos = { + .constraints = &network_lat_constraints, + .name ="network_latency" , }; -static BLOCKING_NOTIFIER_HEAD (network_throughput_notifier); -static struct pm_qos_object network_throughput_pm_qos = { - .constraints =PLIST_HEAD_INIT (network_throughput_pm_qos.constraints, - pm_qos_lock), - .notifiers = &network_throughput_notifier, - .name ="network_throughput" , +static struct pm_qos_constraints network_tput_constraints = { + .list =PLIST_HEAD_INIT (network_tput_constraints.list, pm_qos_lock), .target_value =PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE , .default_value =PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE , .type =PM_QOS_MAX , + .notifiers = &network_throughput_notifier, +}; +static struct pm_qos_object network_throughput_pm_qos = { + .constraints = &network_tput_constraints, + .name ="network_throughput" , }; -static struct pm_qos_object *pm_qos_array[] = { &null_pm_qos,@@ -131,15 +123,15 @@ static const struct file_operations pm_qos_power_fops = {/* unlocked internal variant */ static inline int pm_qos_get_value (struct pm_qos_object *o) { -if (plist_head_empty (&o->constraints)) -return o->default_value; +if (plist_head_empty (&o->constraints->list)) +return o->constraints->default_value; -switch (o->type) { +switch (o->constraints->type) {case PM_QOS_MIN : -return plist_first (&o->constraints)->prio; +return plist_first (&o->constraints->list)->prio;case PM_QOS_MAX : -return plist_last (&o->constraints)->prio; +return plist_last (&o->constraints->list)->prio;default :/* runtime check for not using enum */ @@ -149,12 +141,12 @@ static inline int pm_qos_get_value(struct pm_qos_object *o)static inline s32 pm_qos_read_value (struct pm_qos_object *o) { -return o->target_value; +return o->constraints->target_value; }static inline void pm_qos_set_value (struct pm_qos_object *o,s32 value) { - o->target_value = value; + o->constraints->target_value = value; } static void update_target(struct pm_qos_object *o, struct plist_node *node,@@ -172,20 +164,20 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node,* with new value and add, then see if the extremal * changed */ -plist_del (node, &o->constraints); +plist_del (node, &o->constraints->list);plist_node_init (node, value); -plist_add (node, &o->constraints); +plist_add (node, &o->constraints->list); }else if (del) { -plist_del (node, &o->constraints); +plist_del (node, &o->constraints->list); }else { -plist_add (node, &o->constraints); +plist_add (node, &o->constraints->list); } curr_value =pm_qos_get_value (o);pm_qos_set_value (o, curr_value);spin_unlock_irqrestore (&pm_qos_lock, flags);if (prev_value != curr_value) -blocking_notifier_call_chain (o->notifiers, +blocking_notifier_call_chain (o->constraints->notifiers, (unsigned long )curr_value,NULL ); }@@ -232,7 +224,7 @@ void pm_qos_add_request(struct pm_qos_request *req,return ; }if (value ==PM_QOS_DEFAULT_VALUE ) - new_value = o->default_value; + new_value = o->constraints->default_value;else new_value = value;plist_node_init (&req->node, new_value);@@ -268,7 +260,7 @@ void pm_qos_update_request(struct pm_qos_request *req, o = pm_qos_array[req->pm_qos_class];if (new_value ==PM_QOS_DEFAULT_VALUE ) - temp = o->default_value; + temp = o->constraints->default_value;else temp = new_value;@@ -317,7 +309,8 @@ int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier)int retval; retval =blocking_notifier_chain_register ( - pm_qos_array[pm_qos_class]->notifiers, notifier); + pm_qos_array[pm_qos_class]->constraints->notifiers, + notifier);return retval; }@@ -336,7 +329,8 @@ int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier)int retval; retval =blocking_notifier_chain_unregister ( - pm_qos_array[pm_qos_class]->notifiers, notifier); + pm_qos_array[pm_qos_class]->constraints->notifiers, + notifier);return retval; }Signature · 1 line
1.7.2.5
looks ok but I'm wondering what the uninititalized qos type is for.
--mark
Re: [PATCH 04/15] PM QoS: re-organize data structs
In reply to [email protected]Quoted 21 lines · On Thu, Aug 11, 2011 at 05:06:41PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support, re-organize the data strctures:
- add a structpm_qos_constraintswhich contains the constraints related data
- update structpm_qos_objectcontents to the PM QoS internal object data. Add a pointer to structpm_qos_constraints
- update the internal code to use the new data structs.Signed-off-by Jean Pihet <[email protected]>--- include/linux/pm_qos.h | 19 ++++++++++ kernel/power/qos.c | 90 ++++++++++++++++++++++------------------------- 2 files changed, 61 insertions(+), 48 deletions(-)include/linux/pm_qos.h +0
-0
include/linux/pm_qos.h struct pm_qos_request { · line 29
Quoted 5 lines
include/linux/pm_qos.h +2
-0@@ -25,6 +25,25 @@ struct pm_qos_request {int pm_qos_class; }; +enum pm_qos_type { +PM_QOS_UNITIALIZED ,
what is this for?
Quoted 214 lines
include/linux/pm_qos.h +17
-0+PM_QOS_MAX ,/* return the largest value */ + PM_QOS_MIN /* return the smallest value */ +}; + +/* +* Note: The lockless read path depends on the CPU accessing +* target_value atomically. Atomic access is only guaranteed on all CPU +* types linux supports for 32 bit quantites +*/ +struct pm_qos_constraints { +struct plist_head list; +s32 target_value;/* Do not change to 64 bit */ +s32 default_value; +enum pm_qos_type type; +struct blocking_notifier_head *notifiers; +}; +#ifdef CONFIG_PM void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value);kernel/power/qos.c +42
-48@@ -49,62 +49,54 @@* or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock * held, taken with _irqsave. One lock to rule them all */ -enum pm_qos_type { -PM_QOS_MAX ,/* return the largest value */ -PM_QOS_MIN /* return the smallest value */ -}; - -/* -* Note: The lockless read path depends on the CPU accessing -* target_value atomically. Atomic access is only guaranteed on all CPU -* types linux supports for 32 bit quantites -*/ struct pm_qos_object { -struct plist_head constraints; -struct blocking_notifier_head *notifiers; +struct pm_qos_constraints *constraints;struct miscdevice pm_qos_power_miscdev;char *name; -s32 target_value;/* Do not change to 64 bit */ -s32 default_value; -enum pm_qos_type type; };static DEFINE_SPINLOCK (pm_qos_lock);static struct pm_qos_object null_pm_qos; +static BLOCKING_NOTIFIER_HEAD (cpu_dma_lat_notifier); -static struct pm_qos_object cpu_dma_pm_qos = { - .constraints =PLIST_HEAD_INIT (cpu_dma_pm_qos.constraints, pm_qos_lock), - .notifiers = &cpu_dma_lat_notifier, - .name ="cpu_dma_latency" , +static struct pm_qos_constraints cpu_dma_constraints = { + .list =PLIST_HEAD_INIT (cpu_dma_constraints.list, pm_qos_lock), .target_value =PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE , .default_value =PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE , .type =PM_QOS_MIN , + .notifiers = &cpu_dma_lat_notifier, +}; +static struct pm_qos_object cpu_dma_pm_qos = { + .constraints = &cpu_dma_constraints, + .name ="cpu_dma_latency" , };static BLOCKING_NOTIFIER_HEAD (network_lat_notifier); -static struct pm_qos_object network_lat_pm_qos = { - .constraints =PLIST_HEAD_INIT (network_lat_pm_qos.constraints, - pm_qos_lock), - .notifiers = &network_lat_notifier, - .name ="network_latency" , +static struct pm_qos_constraints network_lat_constraints = { + .list =PLIST_HEAD_INIT (network_lat_constraints.list, pm_qos_lock), .target_value =PM_QOS_NETWORK_LAT_DEFAULT_VALUE , .default_value =PM_QOS_NETWORK_LAT_DEFAULT_VALUE , - .type =PM_QOS_MIN + .type =PM_QOS_MIN , + .notifiers = &network_lat_notifier, +}; +static struct pm_qos_object network_lat_pm_qos = { + .constraints = &network_lat_constraints, + .name ="network_latency" , }; -static BLOCKING_NOTIFIER_HEAD (network_throughput_notifier); -static struct pm_qos_object network_throughput_pm_qos = { - .constraints =PLIST_HEAD_INIT (network_throughput_pm_qos.constraints, - pm_qos_lock), - .notifiers = &network_throughput_notifier, - .name ="network_throughput" , +static struct pm_qos_constraints network_tput_constraints = { + .list =PLIST_HEAD_INIT (network_tput_constraints.list, pm_qos_lock), .target_value =PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE , .default_value =PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE , .type =PM_QOS_MAX , + .notifiers = &network_throughput_notifier, +}; +static struct pm_qos_object network_throughput_pm_qos = { + .constraints = &network_tput_constraints, + .name ="network_throughput" , }; -static struct pm_qos_object *pm_qos_array[] = { &null_pm_qos,@@ -131,15 +123,15 @@ static const struct file_operations pm_qos_power_fops = {/* unlocked internal variant */ static inline int pm_qos_get_value (struct pm_qos_object *o) { -if (plist_head_empty (&o->constraints)) -return o->default_value; +if (plist_head_empty (&o->constraints->list)) +return o->constraints->default_value; -switch (o->type) { +switch (o->constraints->type) {case PM_QOS_MIN : -return plist_first (&o->constraints)->prio; +return plist_first (&o->constraints->list)->prio;case PM_QOS_MAX : -return plist_last (&o->constraints)->prio; +return plist_last (&o->constraints->list)->prio;default :/* runtime check for not using enum */ @@ -149,12 +141,12 @@ static inline int pm_qos_get_value(struct pm_qos_object *o)static inline s32 pm_qos_read_value (struct pm_qos_object *o) { -return o->target_value; +return o->constraints->target_value; }static inline void pm_qos_set_value (struct pm_qos_object *o,s32 value) { - o->target_value = value; + o->constraints->target_value = value; } static void update_target(struct pm_qos_object *o, struct plist_node *node,@@ -172,20 +164,20 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node,* with new value and add, then see if the extremal * changed */ -plist_del (node, &o->constraints); +plist_del (node, &o->constraints->list);plist_node_init (node, value); -plist_add (node, &o->constraints); +plist_add (node, &o->constraints->list); }else if (del) { -plist_del (node, &o->constraints); +plist_del (node, &o->constraints->list); }else { -plist_add (node, &o->constraints); +plist_add (node, &o->constraints->list); } curr_value =pm_qos_get_value (o);pm_qos_set_value (o, curr_value);spin_unlock_irqrestore (&pm_qos_lock, flags);if (prev_value != curr_value) -blocking_notifier_call_chain (o->notifiers, +blocking_notifier_call_chain (o->constraints->notifiers, (unsigned long )curr_value,NULL ); }@@ -232,7 +224,7 @@ void pm_qos_add_request(struct pm_qos_request *req,return ; }if (value ==PM_QOS_DEFAULT_VALUE ) - new_value = o->default_value; + new_value = o->constraints->default_value;else new_value = value;plist_node_init (&req->node, new_value);@@ -268,7 +260,7 @@ void pm_qos_update_request(struct pm_qos_request *req, o = pm_qos_array[req->pm_qos_class];if (new_value ==PM_QOS_DEFAULT_VALUE ) - temp = o->default_value; + temp = o->constraints->default_value;else temp = new_value;@@ -317,7 +309,8 @@ int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier)int retval; retval =blocking_notifier_chain_register ( - pm_qos_array[pm_qos_class]->notifiers, notifier); + pm_qos_array[pm_qos_class]->constraints->notifiers, + notifier);return retval; }@@ -336,7 +329,8 @@ int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier)int retval; retval =blocking_notifier_chain_unregister ( - pm_qos_array[pm_qos_class]->notifiers, notifier); + pm_qos_array[pm_qos_class]->constraints->notifiers, + notifier);return retval; }Signature · 1 line
1.7.2.5
looks ok but I'm wondering what the uninititalized qos type is for.
--mark
Re: [PATCH 05/15] PM QoS: generalize and export the constraints management code
In reply to [email protected]Quoted 25 lines · On Thu, Aug 11, 2011 at 05:06:42PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support:
- renameupdate_targettopm_qos_update_target
- generalize and exportpm_qos_update_targetfor usage by the upcoming per-device latency constraints framework:
. operate on structpm_qos_constraintsfor constraints management, . introduce an 'action' parameter for constraints add/update/remove, . the return value indicates if the aggregated constraint value has
changed,
- update the internal code to operate on structpm_qos_constraints
- add a NULL pointer check in the API functionsSigned-off-by Jean Pihet <[email protected]>--- include/linux/pm_qos.h | 14 ++++++ kernel/power/qos.c | 123 ++++++++++++++++++++++++++---------------------- 2 files changed, 81 insertions(+), 56 deletions(-)include/linux/pm_qos.h +0
-0
include/linux/pm_qos.h struct pm_qos_constraints { · line 53
Quoted 10 lines
include/linux/pm_qos.h +7
-0@@ -44,7 +44,16 @@ struct pm_qos_constraints {struct blocking_notifier_head *notifiers; }; +/* Action requested to pm_qos_update_target */ +enum pm_qos_req_action { +PM_QOS_ADD_REQ ,/* Add a new request */ +PM_QOS_UPDATE_REQ ,/* Update an existing request */ +PM_QOS_REMOVE_REQ /* Remove an existing request */ +}; +
What do you need this enum for? The function names *_update_*, *_add_*, and *_remove_* seem to be pretty redundant if you have to pass an enum that could possibly conflict with the function name.
include/linux/pm_qos.h struct pm_qos_constraints { · line 56
Quoted 3 lines
include/linux/pm_qos.h +2
-0#ifdef CONFIG_PM +int pm_qos_update_target (struct pm_qos_constraints *c,struct plist_node *node, +enum pm_qos_req_action action,int value);
The action for update_target better damn well be "PM_QOS_UPDATE_REQ" or there is something strange going on.... BTW what shold this function do if the pm_qos_req_action was *not* the UPDATE one?
pm_qos_update_target should be a static to the C- file along with the enum pm_qos_req_action.
Quoted 83 lines
include/linux/pm_qos.h +5
-0void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value); void pm_qos_update_request(struct pm_qos_request *req,@@ -56,6 +65,11 @@ int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_request_active (struct pm_qos_request *req);#else +static inline int pm_qos_update_target (struct pm_qos_constraints *c, +struct plist_node *node, +enum pm_qos_req_action action, +int value) + {return 0 ; }static inline void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) {return ; }kernel/power/qos.c +24
-14@@ -121,17 +121,17 @@ static const struct file_operations pm_qos_power_fops = { };/* unlocked internal variant */ -static inline int pm_qos_get_value (struct pm_qos_object *o) +static inline int pm_qos_get_value (struct pm_qos_constraints *c) { -if (plist_head_empty (&o->constraints->list)) -return o->constraints->default_value; +if (plist_head_empty (&c->list)) +return c->default_value; -switch (o->constraints->type) { +switch (c->type) {case PM_QOS_MIN : -return plist_first (&o->constraints->list)->prio; +return plist_first (&c->list)->prio;case PM_QOS_MAX : -return plist_last (&o->constraints->list)->prio; +return plist_last (&c->list)->prio;default :/* runtime check for not using enum */ @@ -139,47 +139,73 @@ static inline int pm_qos_get_value(struct pm_qos_object *o) } } -static inline s32 pm_qos_read_value (struct pm_qos_object *o) +static inline s32 pm_qos_read_value (struct pm_qos_constraints *c) { -return o->constraints->target_value; +return c->target_value; } -static inline void pm_qos_set_value (struct pm_qos_object *o,s32 value) +static inline void pm_qos_set_value (struct pm_qos_constraints *c,s32 value) { - o->constraints->target_value = value; + c->target_value = value; } -static void update_target (struct pm_qos_object *o,struct plist_node *node, -int del,int value) +/** +* pm_qos_update_target - manages the constraints list and calls the notifiers +* if needed +* @c: constraints data struct +* @node: request to add to the list, to update or to remove +* @action: action to take on the constraints list +* @value: value of the request to add or update +* +* This function returns 1 if the aggregated constraint value has changed, 0 +* otherwise. +*/ +int pm_qos_update_target (struct pm_qos_constraints *c,struct plist_node *node, +enum pm_qos_req_action action,int value) {unsigned long flags; -int prev_value, curr_value; +int prev_value, curr_value, new_value;spin_lock_irqsave (&pm_qos_lock, flags); - prev_value =pm_qos_get_value (o);
kernel/power/qos.c static inline int pm_qos_get_value(struct pm_qos_object *o) · line 177
Quoted 10 lines
kernel/power/qos.c +8
-2-/* PM_QOS_DEFAULT_VALUE is a signal that the value is unchanged */ -if (value !=PM_QOS_DEFAULT_VALUE ) { + prev_value =pm_qos_get_value (c); +if (value ==PM_QOS_DEFAULT_VALUE ) + new_value = c->default_value; +else + new_value = value; + +switch (action) { +case PM_QOS_REMOVE_REQ :
We have a remove request API already. This overloading of this interface feels wrong to me.
Quoted 7 lines
kernel/power/qos.c +3
-0+plist_del (node, &c->list); +break ; +case PM_QOS_UPDATE_REQ :/* * to change the list, we atomically remove, reinit * with new value and add, then see if the extremal * changed
kernel/power/qos.c static inline int pm_qos_get_value(struct pm_qos_object *o) · line 187
Quoted 10 lines
kernel/power/qos.c +2
-7*/ -plist_del (node, &o->constraints->list); -plist_node_init (node, value); -plist_add (node, &o->constraints->list); - }else if (del) { -plist_del (node, &o->constraints->list); - }else { -plist_add (node, &o->constraints->list); +plist_del (node, &c->list); +case PM_QOS_ADD_REQ :
Don't we have an API for adding a request? if you want to overload update like this then either we lose the add API or this shouldn't be here.
Quoted 49 lines
kernel/power/qos.c +19
-7+plist_node_init (node, new_value); +plist_add (node, &c->list); +break ; +default : +/* no action */ + ; } - curr_value =pm_qos_get_value (o); -pm_qos_set_value (o, curr_value); + + curr_value =pm_qos_get_value (c); +pm_qos_set_value (c, curr_value); +spin_unlock_irqrestore (&pm_qos_lock, flags); -if (prev_value != curr_value) -blocking_notifier_call_chain (o->constraints->notifiers, +if (prev_value != curr_value) { +blocking_notifier_call_chain (c->notifiers, (unsigned long )curr_value,NULL ); +return 1 ; + }else { +return 0 ; + } }/** @@ -190,7 +216,7 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node,*/ int pm_qos_request (int pm_qos_class) { -return pm_qos_read_value (pm_qos_array[pm_qos_class]); +return pm_qos_read_value (pm_qos_array[pm_qos_class]->constraints); }EXPORT_SYMBOL_GPL (pm_qos_request);@@ -216,20 +242,16 @@ EXPORT_SYMBOL_GPL(pm_qos_request_active);void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) { -struct pm_qos_object *o = pm_qos_array[pm_qos_class]; -int new_value; +if (!req)/*guard against callers passing in null */ +return ;if (pm_qos_request_active (req)) {WARN (1 ,KERN_ERR "pm_qos_add_request() called for already added request\n" );return ;
kernel/power/qos.c EXPORT_SYMBOL_GPL(pm_qos_request_active); · line 254
Quoted 10 lines
kernel/power/qos.c +2
-6} -if (value ==PM_QOS_DEFAULT_VALUE ) - new_value = o->constraints->default_value; -else - new_value = value; -plist_node_init (&req->node, new_value); req->pm_qos_class = pm_qos_class; -update_target (o, &req->node,0 ,PM_QOS_DEFAULT_VALUE ); +pm_qos_update_target (pm_qos_array[pm_qos_class]->constraints, + &req->node,PM_QOS_ADD_REQ , value);
Ok, using pm_qos_update_target to reduce the LOC is ok but I don't think this function and the enum should be exported outside of pm_qos.c
--mark
Quoted 78 lines
kernel/power/qos.c +9
-20}EXPORT_SYMBOL_GPL (pm_qos_add_request);@@ -246,9 +268,6 @@ EXPORT_SYMBOL_GPL(pm_qos_add_request);void pm_qos_update_request (struct pm_qos_request *req,s32 new_value) { -s32 temp; -struct pm_qos_object *o; -if (!req)/*guard against callers passing in null */ return ;@@ -257,15 +276,10 @@ void pm_qos_update_request(struct pm_qos_request *req,return ; } - o = pm_qos_array[req->pm_qos_class]; - -if (new_value ==PM_QOS_DEFAULT_VALUE ) - temp = o->constraints->default_value; -else - temp = new_value; - -if (temp != req->node.prio) -update_target (o, &req->node,0 , temp); +if (new_value != req->node.prio) +pm_qos_update_target ( + pm_qos_array[req->pm_qos_class]->constraints, + &req->node,PM_QOS_UPDATE_REQ , new_value); }EXPORT_SYMBOL_GPL (pm_qos_update_request);@@ -279,9 +293,7 @@ EXPORT_SYMBOL_GPL(pm_qos_update_request);*/ void pm_qos_remove_request (struct pm_qos_request *req) { -struct pm_qos_object *o; - -if (req ==NULL ) +if (!req)/*guard against callers passing in null */ return ;/* silent return to keep pcm code cleaner */ @@ -290,8 +302,9 @@ void pm_qos_remove_request(struct pm_qos_request *req)return ; } - o = pm_qos_array[req->pm_qos_class]; -update_target (o, &req->node,1 ,PM_QOS_DEFAULT_VALUE ); +pm_qos_update_target (pm_qos_array[req->pm_qos_class]->constraints, + &req->node,PM_QOS_REMOVE_REQ , +PM_QOS_DEFAULT_VALUE );memset (req,0 ,sizeof (*req)); }EXPORT_SYMBOL_GPL (pm_qos_remove_request);@@ -395,7 +408,6 @@ static ssize_t pm_qos_power_read(struct file *filp, char __user *buf, {s32 value;unsigned long flags; -struct pm_qos_object *o;struct pm_qos_request *req = filp->private_data;if (!req)@@ -403,9 +415,8 @@ static ssize_t pm_qos_power_read(struct file *filp, char __user *buf,if (!pm_qos_request_active (req))return -EINVAL ; - o = pm_qos_array[req->pm_qos_class];spin_lock_irqsave (&pm_qos_lock, flags); - value =pm_qos_get_value (o); + value =pm_qos_get_value (pm_qos_array[req->pm_qos_class]->constraints);spin_unlock_irqrestore (&pm_qos_lock, flags);return simple_read_from_buffer (buf, count, f_pos, &value,sizeof (s32));Signature · 1 line
1.7.2.5
Re: [PATCH 05/15] PM QoS: generalize and export the constraints management code
In reply to [email protected]Quoted 25 lines · On Thu, Aug 11, 2011 at 05:06:42PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support:
- renameupdate_targettopm_qos_update_target
- generalize and exportpm_qos_update_targetfor usage by the upcoming per-device latency constraints framework:
. operate on structpm_qos_constraintsfor constraints management, . introduce an 'action' parameter for constraints add/update/remove, . the return value indicates if the aggregated constraint value has
changed,
- update the internal code to operate on structpm_qos_constraints
- add a NULL pointer check in the API functionsSigned-off-by Jean Pihet <[email protected]>--- include/linux/pm_qos.h | 14 ++++++ kernel/power/qos.c | 123 ++++++++++++++++++++++++++---------------------- 2 files changed, 81 insertions(+), 56 deletions(-)include/linux/pm_qos.h +0
-0
include/linux/pm_qos.h struct pm_qos_constraints { · line 53
Quoted 10 lines
include/linux/pm_qos.h +7
-0@@ -44,7 +44,16 @@ struct pm_qos_constraints {struct blocking_notifier_head *notifiers; }; +/* Action requested to pm_qos_update_target */ +enum pm_qos_req_action { +PM_QOS_ADD_REQ ,/* Add a new request */ +PM_QOS_UPDATE_REQ ,/* Update an existing request */ +PM_QOS_REMOVE_REQ /* Remove an existing request */ +}; +
What do you need this enum for? The function names *_update_*, *_add_*, and *_remove_* seem to be pretty redundant if you have to pass an enum that could possibly conflict with the function name.
include/linux/pm_qos.h struct pm_qos_constraints { · line 56
Quoted 3 lines
include/linux/pm_qos.h +2
-0#ifdef CONFIG_PM +int pm_qos_update_target (struct pm_qos_constraints *c,struct plist_node *node, +enum pm_qos_req_action action,int value);
The action for update_target better damn well be "PM_QOS_UPDATE_REQ" or there is something strange going on.... BTW what shold this function do if the pm_qos_req_action was *not* the UPDATE one?
pm_qos_update_target should be a static to the C- file along with the enum pm_qos_req_action.
Quoted 83 lines
include/linux/pm_qos.h +5
-0void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value); void pm_qos_update_request(struct pm_qos_request *req,@@ -56,6 +65,11 @@ int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_request_active (struct pm_qos_request *req);#else +static inline int pm_qos_update_target (struct pm_qos_constraints *c, +struct plist_node *node, +enum pm_qos_req_action action, +int value) + {return 0 ; }static inline void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) {return ; }kernel/power/qos.c +24
-14@@ -121,17 +121,17 @@ static const struct file_operations pm_qos_power_fops = { };/* unlocked internal variant */ -static inline int pm_qos_get_value (struct pm_qos_object *o) +static inline int pm_qos_get_value (struct pm_qos_constraints *c) { -if (plist_head_empty (&o->constraints->list)) -return o->constraints->default_value; +if (plist_head_empty (&c->list)) +return c->default_value; -switch (o->constraints->type) { +switch (c->type) {case PM_QOS_MIN : -return plist_first (&o->constraints->list)->prio; +return plist_first (&c->list)->prio;case PM_QOS_MAX : -return plist_last (&o->constraints->list)->prio; +return plist_last (&c->list)->prio;default :/* runtime check for not using enum */ @@ -139,47 +139,73 @@ static inline int pm_qos_get_value(struct pm_qos_object *o) } } -static inline s32 pm_qos_read_value (struct pm_qos_object *o) +static inline s32 pm_qos_read_value (struct pm_qos_constraints *c) { -return o->constraints->target_value; +return c->target_value; } -static inline void pm_qos_set_value (struct pm_qos_object *o,s32 value) +static inline void pm_qos_set_value (struct pm_qos_constraints *c,s32 value) { - o->constraints->target_value = value; + c->target_value = value; } -static void update_target (struct pm_qos_object *o,struct plist_node *node, -int del,int value) +/** +* pm_qos_update_target - manages the constraints list and calls the notifiers +* if needed +* @c: constraints data struct +* @node: request to add to the list, to update or to remove +* @action: action to take on the constraints list +* @value: value of the request to add or update +* +* This function returns 1 if the aggregated constraint value has changed, 0 +* otherwise. +*/ +int pm_qos_update_target (struct pm_qos_constraints *c,struct plist_node *node, +enum pm_qos_req_action action,int value) {unsigned long flags; -int prev_value, curr_value; +int prev_value, curr_value, new_value;spin_lock_irqsave (&pm_qos_lock, flags); - prev_value =pm_qos_get_value (o);
kernel/power/qos.c static inline int pm_qos_get_value(struct pm_qos_object *o) · line 177
Quoted 10 lines
kernel/power/qos.c +8
-2-/* PM_QOS_DEFAULT_VALUE is a signal that the value is unchanged */ -if (value !=PM_QOS_DEFAULT_VALUE ) { + prev_value =pm_qos_get_value (c); +if (value ==PM_QOS_DEFAULT_VALUE ) + new_value = c->default_value; +else + new_value = value; + +switch (action) { +case PM_QOS_REMOVE_REQ :
We have a remove request API already. This overloading of this interface feels wrong to me.
Quoted 7 lines
kernel/power/qos.c +3
-0+plist_del (node, &c->list); +break ; +case PM_QOS_UPDATE_REQ :/* * to change the list, we atomically remove, reinit * with new value and add, then see if the extremal * changed
kernel/power/qos.c static inline int pm_qos_get_value(struct pm_qos_object *o) · line 187
Quoted 10 lines
kernel/power/qos.c +2
-7*/ -plist_del (node, &o->constraints->list); -plist_node_init (node, value); -plist_add (node, &o->constraints->list); - }else if (del) { -plist_del (node, &o->constraints->list); - }else { -plist_add (node, &o->constraints->list); +plist_del (node, &c->list); +case PM_QOS_ADD_REQ :
Don't we have an API for adding a request? if you want to overload update like this then either we lose the add API or this shouldn't be here.
Quoted 49 lines
kernel/power/qos.c +19
-7+plist_node_init (node, new_value); +plist_add (node, &c->list); +break ; +default : +/* no action */ + ; } - curr_value =pm_qos_get_value (o); -pm_qos_set_value (o, curr_value); + + curr_value =pm_qos_get_value (c); +pm_qos_set_value (c, curr_value); +spin_unlock_irqrestore (&pm_qos_lock, flags); -if (prev_value != curr_value) -blocking_notifier_call_chain (o->constraints->notifiers, +if (prev_value != curr_value) { +blocking_notifier_call_chain (c->notifiers, (unsigned long )curr_value,NULL ); +return 1 ; + }else { +return 0 ; + } }/** @@ -190,7 +216,7 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node,*/ int pm_qos_request (int pm_qos_class) { -return pm_qos_read_value (pm_qos_array[pm_qos_class]); +return pm_qos_read_value (pm_qos_array[pm_qos_class]->constraints); }EXPORT_SYMBOL_GPL (pm_qos_request);@@ -216,20 +242,16 @@ EXPORT_SYMBOL_GPL(pm_qos_request_active);void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) { -struct pm_qos_object *o = pm_qos_array[pm_qos_class]; -int new_value; +if (!req)/*guard against callers passing in null */ +return ;if (pm_qos_request_active (req)) {WARN (1 ,KERN_ERR "pm_qos_add_request() called for already added request\n" );return ;
kernel/power/qos.c EXPORT_SYMBOL_GPL(pm_qos_request_active); · line 254
Quoted 10 lines
kernel/power/qos.c +2
-6} -if (value ==PM_QOS_DEFAULT_VALUE ) - new_value = o->constraints->default_value; -else - new_value = value; -plist_node_init (&req->node, new_value); req->pm_qos_class = pm_qos_class; -update_target (o, &req->node,0 ,PM_QOS_DEFAULT_VALUE ); +pm_qos_update_target (pm_qos_array[pm_qos_class]->constraints, + &req->node,PM_QOS_ADD_REQ , value);
Ok, using pm_qos_update_target to reduce the LOC is ok but I don't think this function and the enum should be exported outside of pm_qos.c
--mark
Quoted 78 lines
kernel/power/qos.c +9
-20}EXPORT_SYMBOL_GPL (pm_qos_add_request);@@ -246,9 +268,6 @@ EXPORT_SYMBOL_GPL(pm_qos_add_request);void pm_qos_update_request (struct pm_qos_request *req,s32 new_value) { -s32 temp; -struct pm_qos_object *o; -if (!req)/*guard against callers passing in null */ return ;@@ -257,15 +276,10 @@ void pm_qos_update_request(struct pm_qos_request *req,return ; } - o = pm_qos_array[req->pm_qos_class]; - -if (new_value ==PM_QOS_DEFAULT_VALUE ) - temp = o->constraints->default_value; -else - temp = new_value; - -if (temp != req->node.prio) -update_target (o, &req->node,0 , temp); +if (new_value != req->node.prio) +pm_qos_update_target ( + pm_qos_array[req->pm_qos_class]->constraints, + &req->node,PM_QOS_UPDATE_REQ , new_value); }EXPORT_SYMBOL_GPL (pm_qos_update_request);@@ -279,9 +293,7 @@ EXPORT_SYMBOL_GPL(pm_qos_update_request);*/ void pm_qos_remove_request (struct pm_qos_request *req) { -struct pm_qos_object *o; - -if (req ==NULL ) +if (!req)/*guard against callers passing in null */ return ;/* silent return to keep pcm code cleaner */ @@ -290,8 +302,9 @@ void pm_qos_remove_request(struct pm_qos_request *req)return ; } - o = pm_qos_array[req->pm_qos_class]; -update_target (o, &req->node,1 ,PM_QOS_DEFAULT_VALUE ); +pm_qos_update_target (pm_qos_array[req->pm_qos_class]->constraints, + &req->node,PM_QOS_REMOVE_REQ , +PM_QOS_DEFAULT_VALUE );memset (req,0 ,sizeof (*req)); }EXPORT_SYMBOL_GPL (pm_qos_remove_request);@@ -395,7 +408,6 @@ static ssize_t pm_qos_power_read(struct file *filp, char __user *buf, {s32 value;unsigned long flags; -struct pm_qos_object *o;struct pm_qos_request *req = filp->private_data;if (!req)@@ -403,9 +415,8 @@ static ssize_t pm_qos_power_read(struct file *filp, char __user *buf,if (!pm_qos_request_active (req))return -EINVAL ; - o = pm_qos_array[req->pm_qos_class];spin_lock_irqsave (&pm_qos_lock, flags); - value =pm_qos_get_value (o); + value =pm_qos_get_value (pm_qos_array[req->pm_qos_class]->constraints);spin_unlock_irqrestore (&pm_qos_lock, flags);return simple_read_from_buffer (buf, count, f_pos, &value,sizeof (s32));Signature · 1 line
1.7.2.5
Re: [PATCH 06/15] PM QoS: implement the per-device PM QoS constraints
In reply to [email protected]Quoted 438 lines · On Thu, Aug 11, 2011 at 05:06:43PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
Implement the per-device PM QoS constraints by creating a device PM QoS API, which calls the PM QoS constraints management core code.
The per-device latency constraints data strctures are stored in the device
dev_pm_infostruct.The device PM code calls the init and destroy of the per-device constraints data struct in order to support the dynamic insertion and removal of the devices in the system.
To minimize the data usage by the per-device constraints, the data struct is only allocated at the first call to
dev_pm_qos_add_request. The data is later free'd when the device is removed from the system.Signed-off-by Jean Pihet <[email protected]>--- drivers/base/power/Makefile | 4 +- drivers/base/power/main.c | 3 + drivers/base/power/qos.c | 262 +++++++++++++++++++++++++++++++++++++++++++ include/linux/pm.h | 9 ++ include/linux/pm_qos.h | 39 +++++++ 5 files changed, 315 insertions(+), 2 deletions(-) create mode 100644 drivers/base/power/qos.cdrivers/base/power/Makefile +2
-2@@ -1,8 +1,8 @@ -obj-$(CONFIG_PM) += sysfs.o generic_ops.o +obj-$(CONFIG_PM) += sysfs.o generic_ops.o qos.o obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o obj-$(CONFIG_PM_RUNTIME) += runtime.o obj-$(CONFIG_PM_TRACE_RTC) += trace.o obj-$(CONFIG_PM_OPP) += opp.o obj-$(CONFIG_HAVE_CLK) += clock_ops.o -ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG +ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUGdrivers/base/power/main.c +3
-0@@ -22,6 +22,7 @@#include <linux/mutex.h> #include <linux/pm.h> #include <linux/pm_runtime.h> +#include <linux/pm_qos.h> #include <linux/resume-trace.h> #include <linux/interrupt.h> #include <linux/sched.h> @@ -97,6 +98,7 @@ void device_pm_add(struct device *dev) dev_name(dev->parent));list_add_tail (&dev->power.entry, &dpm_list);mutex_unlock (&dpm_list_mtx); +dev_pm_qos_constraints_init (dev); }/** @@ -107,6 +109,7 @@ void device_pm_remove(struct device *dev) {pr_debug ("PM: Removing info for %s:%s\n" , dev->bus ? dev->bus->name :"No Bus" ,dev_name (dev)); +dev_pm_qos_constraints_destroy (dev);complete_all (&dev->power.completion);mutex_lock (&dpm_list_mtx);list_del_init (&dev->power.entry);drivers/base/power/qos.c new file +262
-0@@ -0,0 +1,262 @@ +/* +* This module exposes the interface to kernel space for specifying +* per-device PM QoS dependencies. It provides infrastructure for registration +* of: +* +* Dependents on a QoS value : register requests +* Watchers of QoS value : get notified when target QoS value changes +* +* This QoS design is best effort based. Dependents register their QoS needs. +* Watchers register to keep track of the current QoS needs of the system. +* +* Note about the per-device constraint data struct allocation: +* . The per-device constraints data struct ptr is tored into the device +* dev_pm_info. +* . To minimize the data usage by the per-device constraints, the data struct +* is only allocated at the first call to dev_pm_qos_add_request. +* . The data is later free'd when the device is removed from the system. +* . The constraints_state variable from dev_pm_info tracks the data struct +* allocation state: +* DEV_PM_QOS_NO_DEVICE: No device present or device removed, no data +* allocated, +* DEV_PM_QOS_DEVICE_PRESENT: Device present, data not allocated and will be +* allocated at the first call to dev_pm_qos_add_request, +* DEV_PM_QOS_ALLOCATED: Device present, data allocated. The per-device +* PM QoS constraints framework is operational and constraints can be +* added, updated or removed using the dev_pm_qos_* API. +*/ + +/*#define DEBUG*/ + +#include <linux/pm_qos.h> +#include <linux/sched.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/time.h> +#include <linux/fs.h> +#include <linux/device.h> +#include <linux/string.h> +#include <linux/platform_device.h> +#include <linux/init.h> +#include <linux/kernel.h> + + +static void dev_pm_qos_constraints_allocate (struct device *dev); + +int dev_pm_qos_request_active (struct dev_pm_qos_request *req) +{ +return req->dev !=0 ; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_request_active); + +/** +* dev_pm_qos_add_request - inserts new qos request into the list +* @req: pointer to a preallocated handle +* @dev: target device for the constraint +* @value: defines the qos request +* +* This function inserts a new entry in the device constraints list of +* requested qos performance characteristics. It recomputes the aggregate +* QoS expectations of parameters and initializes the dev_pm_qos_request +* handle. Caller needs to save this handle for later use in updates and +* removal. +*/ +void dev_pm_qos_add_request (struct dev_pm_qos_request *req,struct device *dev, +s32 value) +{ +if (!req)/*guard against callers passing in null */ +return ; + +if (dev_pm_qos_request_active (req)) { +WARN (1 ,KERN_ERR "dev_pm_qos_add_request() called for already " +"added request\n" ); +return ; + } + req->dev = dev; + +/* Allocate the constraints struct on the first call to add_request */ +if (req->dev->power.constraints_state ==DEV_PM_QOS_DEVICE_PRESENT ) +dev_pm_qos_constraints_allocate (dev); + +/* Silently return if the device has been removed */ +if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return ; + +pm_qos_update_target (dev->power.constraints, + &req->node,PM_QOS_ADD_REQ , value); +} +EXPORT_SYMBOL_GPL (dev_pm_qos_add_request); + +/** +* dev_pm_qos_update_request - modifies an existing qos request +* @req : handle to list element holding a dev_pm_qos request to use +* @value: defines the qos request +* +* Updates an existing dev PM qos request along with updating the +* target value. +* +* Attempts are made to make this code callable on hot code paths. +*/ +void dev_pm_qos_update_request (struct dev_pm_qos_request *req, +s32 new_value) +{ +if (!req)/*guard against callers passing in null */ +return ; + +if (!dev_pm_qos_request_active (req)) { +WARN (1 ,KERN_ERR "dev_pm_qos_update_request() called for " +"unknown object\n" ); +return ; + } + +/* Silently return if the device has been removed */ +if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return ; + +if (new_value != req->node.prio) +pm_qos_update_target ( + req->dev->power.constraints, + &req->node,PM_QOS_UPDATE_REQ , new_value); +} +EXPORT_SYMBOL_GPL (dev_pm_qos_update_request); + +/** +* dev_pm_qos_remove_request - modifies an existing qos request +* @req: handle to request list element +* +* Will remove pm qos request from the list of constraints and +* recompute the current target value. Call this on slow code paths. +*/ +void dev_pm_qos_remove_request (struct dev_pm_qos_request *req) +{ +if (!req)/*guard against callers passing in null */ +return ; + +if (!dev_pm_qos_request_active (req)) { +WARN (1 ,KERN_ERR "dev_pm_qos_remove_request() called for " +"unknown object\n" ); +return ; + } + +/* Silently return if the device has been removed */ +if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return ; + +pm_qos_update_target (req->dev->power.constraints, + &req->node,PM_QOS_REMOVE_REQ , +PM_QOS_DEFAULT_VALUE ); +memset (req,0 ,sizeof (*req)); +} +EXPORT_SYMBOL_GPL (dev_pm_qos_remove_request); + +/** +* dev_pm_qos_add_notifier - sets notification entry for changes to target value +* of per-device PM QoS constraints +* +* @dev: target device for the constraint +* @notifier: notifier block managed by caller. +* +* Will register the notifier into a notification chain that gets called +* upon changes to the target value for the device. +*/ +int dev_pm_qos_add_notifier (struct device *dev,struct notifier_block *notifier) +{ +int retval =0 ; + +/* Silently return if the device has been removed */ +if (dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return retval; + + retval =blocking_notifier_chain_register ( + dev->power.constraints->notifiers, + notifier); + +return retval; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_add_notifier); + +/** +* dev_pm_qos_remove_notifier - deletes notification for changes to target value +* of per-device PM QoS constraints +* +* @dev: target device for the constraint +* @notifier: notifier block to be removed. +* +* Will remove the notifier from the notification chain that gets called +* upon changes to the target value. +*/ +int dev_pm_qos_remove_notifier (struct device *dev, +struct notifier_block *notifier) +{ +int retval =0 ; + +/* Silently return if the device has been removed */ +if (dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return retval; + + retval =blocking_notifier_chain_unregister ( + dev->power.constraints->notifiers, + notifier); + +return retval; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_remove_notifier); + +/* Called at the first call to add_request, for constraint data allocation */ +static void dev_pm_qos_constraints_allocate (struct device *dev) +{ +struct pm_qos_constraints *c; +struct blocking_notifier_head *n; + + c =kzalloc (sizeof (*c),GFP_KERNEL ); +if (!c) +return ; + + n =kzalloc (sizeof (*n),GFP_KERNEL ); +if (!n) { +kfree (c); +return ; + } +BLOCKING_INIT_NOTIFIER_HEAD (n); + + dev->power.constraints = c; +plist_head_init (&dev->power.constraints->list, &dev->power.lock); + dev->power.constraints->target_value =PM_QOS_DEV_LAT_DEFAULT_VALUE ; + dev->power.constraints->default_value =PM_QOS_DEV_LAT_DEFAULT_VALUE ; + dev->power.constraints->type =PM_QOS_MIN ; + dev->power.constraints->notifiers = n; + dev->power.constraints_state =DEV_PM_QOS_ALLOCATED ; +} + +/* Called from the device PM subsystem at device insertion */ +void dev_pm_qos_constraints_init (struct device *dev) +{ + dev->power.constraints_state =DEV_PM_QOS_DEVICE_PRESENT ; +} + +/* Called from the device PM subsystem at device removal */ +void dev_pm_qos_constraints_destroy (struct device *dev) +{ +struct dev_pm_qos_request *req, *tmp; +enum dev_pm_qos_state constraints_state = dev->power.constraints_state; + + dev->power.constraints_state =DEV_PM_QOS_NO_DEVICE ; +if (constraints_state ==DEV_PM_QOS_ALLOCATED ) { +/* Flush the constraints list for the device */ +plist_for_each_entry_safe (req, tmp, + &dev->power.constraints->list, + node) +/* +* Update constraints list and call the per-device +* callbacks if needed +*/ +pm_qos_update_target (req->dev->power.constraints, + &req->node,PM_QOS_REMOVE_REQ , +PM_QOS_DEFAULT_VALUE ); + +kfree (dev->power.constraints->notifiers); +kfree (dev->power.constraints); + dev->power.constraints =NULL ; + } +} +include/linux/pm.h +9
-0@@ -421,6 +421,13 @@ enum rpm_request {struct wakeup_source ; +/* Per-device PM QoS constraints data struct state */ +enum dev_pm_qos_state { +DEV_PM_QOS_NO_DEVICE ,/* No device present */ +DEV_PM_QOS_DEVICE_PRESENT ,/* Device present, data not allocated */ +DEV_PM_QOS_ALLOCATED ,/* Device present, data allocated */ +}; +struct dev_pm_info {pm_message_t power_state;unsigned int can_wakeup:1 ;@@ -463,6 +470,8 @@ struct dev_pm_info {unsigned long accounting_timestamp;void *subsys_data;/* Owned by the subsystem. */ #endif +struct pm_qos_constraints *constraints; +enum dev_pm_qos_state constraints_state; };extern void update_pm_runtime_accounting (struct device *dev);include/linux/pm_qos.h +39
-0@@ -19,12 +19,18 @@#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 +#define PM_QOS_DEV_LAT_DEFAULT_VALUE 0struct pm_qos_request {struct plist_node node;int pm_qos_class; }; +struct dev_pm_qos_request { +struct plist_node node; +struct device *dev; +}; +enum pm_qos_type {PM_QOS_UNITIALIZED ,PM_QOS_MAX ,/* return the largest value */ @@ -64,6 +70,18 @@ int pm_qos_request(int pm_qos_class);int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_request_active (struct pm_qos_request *req); + +int dev_pm_qos_request_active (struct dev_pm_qos_request *req); +void dev_pm_qos_add_request (struct dev_pm_qos_request *req,struct device *dev, +s32 value); +void dev_pm_qos_update_request (struct dev_pm_qos_request *req,s32 new_value); +void dev_pm_qos_remove_request (struct dev_pm_qos_request *req); +int dev_pm_qos_add_notifier (struct device *dev, +struct notifier_block *notifier); +int dev_pm_qos_remove_notifier (struct device *dev, +struct notifier_block *notifier); +void dev_pm_qos_constraints_init (struct device *dev); +void dev_pm_qos_constraints_destroy (struct device *dev);#else static inline int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,@@ -89,6 +107,27 @@ static inline int pm_qos_remove_notifier(int pm_qos_class, {return 0 ; }static inline int pm_qos_request_active (struct pm_qos_request *req) {return 0 ; } + +static inline int dev_pm_qos_request_active (struct dev_pm_qos_request *req) + {return 0 ; } +static inline void dev_pm_qos_add_request (struct dev_pm_qos_request *req, +struct device *dev,s32 value) + {return ; } +static inline void dev_pm_qos_update_request (struct dev_pm_qos_request *req, +s32 new_value) + {return ; } +static inline void dev_pm_qos_remove_request (struct dev_pm_qos_request *req) + {return ; } +static inline int dev_pm_qos_add_notifier (struct device *dev, +struct notifier_block *notifier) + {return 0 ; } +static inline int dev_pm_qos_remove_notifier (struct device *dev, +struct notifier_block *notifier) + {return 0 ; } +static inline void dev_pm_qos_constraints_init (struct device *dev) + {return ; } +static inline void dev_pm_qos_constraints_destroy (struct device *dev) + {return ; }#endif #endif Signature · 1 line
1.7.2.5
looks good (except for the use of those enums I don't care for)
--mark
Re: [PATCH 06/15] PM QoS: implement the per-device PM QoS constraints
In reply to [email protected]Quoted 438 lines · On Thu, Aug 11, 2011 at 05:06:43PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
Implement the per-device PM QoS constraints by creating a device PM QoS API, which calls the PM QoS constraints management core code.
The per-device latency constraints data strctures are stored in the device
dev_pm_infostruct.The device PM code calls the init and destroy of the per-device constraints data struct in order to support the dynamic insertion and removal of the devices in the system.
To minimize the data usage by the per-device constraints, the data struct is only allocated at the first call to
dev_pm_qos_add_request. The data is later free'd when the device is removed from the system.Signed-off-by Jean Pihet <[email protected]>--- drivers/base/power/Makefile | 4 +- drivers/base/power/main.c | 3 + drivers/base/power/qos.c | 262 +++++++++++++++++++++++++++++++++++++++++++ include/linux/pm.h | 9 ++ include/linux/pm_qos.h | 39 +++++++ 5 files changed, 315 insertions(+), 2 deletions(-) create mode 100644 drivers/base/power/qos.cdrivers/base/power/Makefile +2
-2@@ -1,8 +1,8 @@ -obj-$(CONFIG_PM) += sysfs.o generic_ops.o +obj-$(CONFIG_PM) += sysfs.o generic_ops.o qos.o obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o obj-$(CONFIG_PM_RUNTIME) += runtime.o obj-$(CONFIG_PM_TRACE_RTC) += trace.o obj-$(CONFIG_PM_OPP) += opp.o obj-$(CONFIG_HAVE_CLK) += clock_ops.o -ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG +ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUGdrivers/base/power/main.c +3
-0@@ -22,6 +22,7 @@#include <linux/mutex.h> #include <linux/pm.h> #include <linux/pm_runtime.h> +#include <linux/pm_qos.h> #include <linux/resume-trace.h> #include <linux/interrupt.h> #include <linux/sched.h> @@ -97,6 +98,7 @@ void device_pm_add(struct device *dev) dev_name(dev->parent));list_add_tail (&dev->power.entry, &dpm_list);mutex_unlock (&dpm_list_mtx); +dev_pm_qos_constraints_init (dev); }/** @@ -107,6 +109,7 @@ void device_pm_remove(struct device *dev) {pr_debug ("PM: Removing info for %s:%s\n" , dev->bus ? dev->bus->name :"No Bus" ,dev_name (dev)); +dev_pm_qos_constraints_destroy (dev);complete_all (&dev->power.completion);mutex_lock (&dpm_list_mtx);list_del_init (&dev->power.entry);drivers/base/power/qos.c new file +262
-0@@ -0,0 +1,262 @@ +/* +* This module exposes the interface to kernel space for specifying +* per-device PM QoS dependencies. It provides infrastructure for registration +* of: +* +* Dependents on a QoS value : register requests +* Watchers of QoS value : get notified when target QoS value changes +* +* This QoS design is best effort based. Dependents register their QoS needs. +* Watchers register to keep track of the current QoS needs of the system. +* +* Note about the per-device constraint data struct allocation: +* . The per-device constraints data struct ptr is tored into the device +* dev_pm_info. +* . To minimize the data usage by the per-device constraints, the data struct +* is only allocated at the first call to dev_pm_qos_add_request. +* . The data is later free'd when the device is removed from the system. +* . The constraints_state variable from dev_pm_info tracks the data struct +* allocation state: +* DEV_PM_QOS_NO_DEVICE: No device present or device removed, no data +* allocated, +* DEV_PM_QOS_DEVICE_PRESENT: Device present, data not allocated and will be +* allocated at the first call to dev_pm_qos_add_request, +* DEV_PM_QOS_ALLOCATED: Device present, data allocated. The per-device +* PM QoS constraints framework is operational and constraints can be +* added, updated or removed using the dev_pm_qos_* API. +*/ + +/*#define DEBUG*/ + +#include <linux/pm_qos.h> +#include <linux/sched.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/time.h> +#include <linux/fs.h> +#include <linux/device.h> +#include <linux/string.h> +#include <linux/platform_device.h> +#include <linux/init.h> +#include <linux/kernel.h> + + +static void dev_pm_qos_constraints_allocate (struct device *dev); + +int dev_pm_qos_request_active (struct dev_pm_qos_request *req) +{ +return req->dev !=0 ; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_request_active); + +/** +* dev_pm_qos_add_request - inserts new qos request into the list +* @req: pointer to a preallocated handle +* @dev: target device for the constraint +* @value: defines the qos request +* +* This function inserts a new entry in the device constraints list of +* requested qos performance characteristics. It recomputes the aggregate +* QoS expectations of parameters and initializes the dev_pm_qos_request +* handle. Caller needs to save this handle for later use in updates and +* removal. +*/ +void dev_pm_qos_add_request (struct dev_pm_qos_request *req,struct device *dev, +s32 value) +{ +if (!req)/*guard against callers passing in null */ +return ; + +if (dev_pm_qos_request_active (req)) { +WARN (1 ,KERN_ERR "dev_pm_qos_add_request() called for already " +"added request\n" ); +return ; + } + req->dev = dev; + +/* Allocate the constraints struct on the first call to add_request */ +if (req->dev->power.constraints_state ==DEV_PM_QOS_DEVICE_PRESENT ) +dev_pm_qos_constraints_allocate (dev); + +/* Silently return if the device has been removed */ +if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return ; + +pm_qos_update_target (dev->power.constraints, + &req->node,PM_QOS_ADD_REQ , value); +} +EXPORT_SYMBOL_GPL (dev_pm_qos_add_request); + +/** +* dev_pm_qos_update_request - modifies an existing qos request +* @req : handle to list element holding a dev_pm_qos request to use +* @value: defines the qos request +* +* Updates an existing dev PM qos request along with updating the +* target value. +* +* Attempts are made to make this code callable on hot code paths. +*/ +void dev_pm_qos_update_request (struct dev_pm_qos_request *req, +s32 new_value) +{ +if (!req)/*guard against callers passing in null */ +return ; + +if (!dev_pm_qos_request_active (req)) { +WARN (1 ,KERN_ERR "dev_pm_qos_update_request() called for " +"unknown object\n" ); +return ; + } + +/* Silently return if the device has been removed */ +if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return ; + +if (new_value != req->node.prio) +pm_qos_update_target ( + req->dev->power.constraints, + &req->node,PM_QOS_UPDATE_REQ , new_value); +} +EXPORT_SYMBOL_GPL (dev_pm_qos_update_request); + +/** +* dev_pm_qos_remove_request - modifies an existing qos request +* @req: handle to request list element +* +* Will remove pm qos request from the list of constraints and +* recompute the current target value. Call this on slow code paths. +*/ +void dev_pm_qos_remove_request (struct dev_pm_qos_request *req) +{ +if (!req)/*guard against callers passing in null */ +return ; + +if (!dev_pm_qos_request_active (req)) { +WARN (1 ,KERN_ERR "dev_pm_qos_remove_request() called for " +"unknown object\n" ); +return ; + } + +/* Silently return if the device has been removed */ +if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return ; + +pm_qos_update_target (req->dev->power.constraints, + &req->node,PM_QOS_REMOVE_REQ , +PM_QOS_DEFAULT_VALUE ); +memset (req,0 ,sizeof (*req)); +} +EXPORT_SYMBOL_GPL (dev_pm_qos_remove_request); + +/** +* dev_pm_qos_add_notifier - sets notification entry for changes to target value +* of per-device PM QoS constraints +* +* @dev: target device for the constraint +* @notifier: notifier block managed by caller. +* +* Will register the notifier into a notification chain that gets called +* upon changes to the target value for the device. +*/ +int dev_pm_qos_add_notifier (struct device *dev,struct notifier_block *notifier) +{ +int retval =0 ; + +/* Silently return if the device has been removed */ +if (dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return retval; + + retval =blocking_notifier_chain_register ( + dev->power.constraints->notifiers, + notifier); + +return retval; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_add_notifier); + +/** +* dev_pm_qos_remove_notifier - deletes notification for changes to target value +* of per-device PM QoS constraints +* +* @dev: target device for the constraint +* @notifier: notifier block to be removed. +* +* Will remove the notifier from the notification chain that gets called +* upon changes to the target value. +*/ +int dev_pm_qos_remove_notifier (struct device *dev, +struct notifier_block *notifier) +{ +int retval =0 ; + +/* Silently return if the device has been removed */ +if (dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return retval; + + retval =blocking_notifier_chain_unregister ( + dev->power.constraints->notifiers, + notifier); + +return retval; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_remove_notifier); + +/* Called at the first call to add_request, for constraint data allocation */ +static void dev_pm_qos_constraints_allocate (struct device *dev) +{ +struct pm_qos_constraints *c; +struct blocking_notifier_head *n; + + c =kzalloc (sizeof (*c),GFP_KERNEL ); +if (!c) +return ; + + n =kzalloc (sizeof (*n),GFP_KERNEL ); +if (!n) { +kfree (c); +return ; + } +BLOCKING_INIT_NOTIFIER_HEAD (n); + + dev->power.constraints = c; +plist_head_init (&dev->power.constraints->list, &dev->power.lock); + dev->power.constraints->target_value =PM_QOS_DEV_LAT_DEFAULT_VALUE ; + dev->power.constraints->default_value =PM_QOS_DEV_LAT_DEFAULT_VALUE ; + dev->power.constraints->type =PM_QOS_MIN ; + dev->power.constraints->notifiers = n; + dev->power.constraints_state =DEV_PM_QOS_ALLOCATED ; +} + +/* Called from the device PM subsystem at device insertion */ +void dev_pm_qos_constraints_init (struct device *dev) +{ + dev->power.constraints_state =DEV_PM_QOS_DEVICE_PRESENT ; +} + +/* Called from the device PM subsystem at device removal */ +void dev_pm_qos_constraints_destroy (struct device *dev) +{ +struct dev_pm_qos_request *req, *tmp; +enum dev_pm_qos_state constraints_state = dev->power.constraints_state; + + dev->power.constraints_state =DEV_PM_QOS_NO_DEVICE ; +if (constraints_state ==DEV_PM_QOS_ALLOCATED ) { +/* Flush the constraints list for the device */ +plist_for_each_entry_safe (req, tmp, + &dev->power.constraints->list, + node) +/* +* Update constraints list and call the per-device +* callbacks if needed +*/ +pm_qos_update_target (req->dev->power.constraints, + &req->node,PM_QOS_REMOVE_REQ , +PM_QOS_DEFAULT_VALUE ); + +kfree (dev->power.constraints->notifiers); +kfree (dev->power.constraints); + dev->power.constraints =NULL ; + } +} +include/linux/pm.h +9
-0@@ -421,6 +421,13 @@ enum rpm_request {struct wakeup_source ; +/* Per-device PM QoS constraints data struct state */ +enum dev_pm_qos_state { +DEV_PM_QOS_NO_DEVICE ,/* No device present */ +DEV_PM_QOS_DEVICE_PRESENT ,/* Device present, data not allocated */ +DEV_PM_QOS_ALLOCATED ,/* Device present, data allocated */ +}; +struct dev_pm_info {pm_message_t power_state;unsigned int can_wakeup:1 ;@@ -463,6 +470,8 @@ struct dev_pm_info {unsigned long accounting_timestamp;void *subsys_data;/* Owned by the subsystem. */ #endif +struct pm_qos_constraints *constraints; +enum dev_pm_qos_state constraints_state; };extern void update_pm_runtime_accounting (struct device *dev);include/linux/pm_qos.h +39
-0@@ -19,12 +19,18 @@#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 +#define PM_QOS_DEV_LAT_DEFAULT_VALUE 0struct pm_qos_request {struct plist_node node;int pm_qos_class; }; +struct dev_pm_qos_request { +struct plist_node node; +struct device *dev; +}; +enum pm_qos_type {PM_QOS_UNITIALIZED ,PM_QOS_MAX ,/* return the largest value */ @@ -64,6 +70,18 @@ int pm_qos_request(int pm_qos_class);int pm_qos_add_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_request_active (struct pm_qos_request *req); + +int dev_pm_qos_request_active (struct dev_pm_qos_request *req); +void dev_pm_qos_add_request (struct dev_pm_qos_request *req,struct device *dev, +s32 value); +void dev_pm_qos_update_request (struct dev_pm_qos_request *req,s32 new_value); +void dev_pm_qos_remove_request (struct dev_pm_qos_request *req); +int dev_pm_qos_add_notifier (struct device *dev, +struct notifier_block *notifier); +int dev_pm_qos_remove_notifier (struct device *dev, +struct notifier_block *notifier); +void dev_pm_qos_constraints_init (struct device *dev); +void dev_pm_qos_constraints_destroy (struct device *dev);#else static inline int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,@@ -89,6 +107,27 @@ static inline int pm_qos_remove_notifier(int pm_qos_class, {return 0 ; }static inline int pm_qos_request_active (struct pm_qos_request *req) {return 0 ; } + +static inline int dev_pm_qos_request_active (struct dev_pm_qos_request *req) + {return 0 ; } +static inline void dev_pm_qos_add_request (struct dev_pm_qos_request *req, +struct device *dev,s32 value) + {return ; } +static inline void dev_pm_qos_update_request (struct dev_pm_qos_request *req, +s32 new_value) + {return ; } +static inline void dev_pm_qos_remove_request (struct dev_pm_qos_request *req) + {return ; } +static inline int dev_pm_qos_add_notifier (struct device *dev, +struct notifier_block *notifier) + {return 0 ; } +static inline int dev_pm_qos_remove_notifier (struct device *dev, +struct notifier_block *notifier) + {return 0 ; } +static inline void dev_pm_qos_constraints_init (struct device *dev) + {return ; } +static inline void dev_pm_qos_constraints_destroy (struct device *dev) + {return ; }#endif #endif Signature · 1 line
1.7.2.5
looks good (except for the use of those enums I don't care for)
--mark
Re: [PATCH 05/15] PM QoS: generalize and export the constraints management code
In reply to mark grossQuoted 217 lines · mark gross
Quoted 25 lines · On Thu, Aug 11, 2011 at 05:06:42PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support:
- renameupdate_targettopm_qos_update_target
- generalize and exportpm_qos_update_targetfor usage by the upcoming per-device latency constraints framework:
. operate on structpm_qos_constraintsfor constraints management, . introduce an 'action' parameter for constraints add/update/remove, . the return value indicates if the aggregated constraint value has
changed,
- update the internal code to operate on structpm_qos_constraints
- add a NULL pointer check in the API functionsSigned-off-by Jean Pihet <[email protected]>--- include/linux/pm_qos.h | 14 ++++++ kernel/power/qos.c | 123 ++++++++++++++++++++++++++---------------------- 2 files changed, 81 insertions(+), 56 deletions(-)include/linux/pm_qos.h +0
-0include/linux/pm_qos.h struct pm_qos_constraints { · line 53
Quoted 10 lines
include/linux/pm_qos.h +7
-0@@ -44,7 +44,16 @@ struct pm_qos_constraints {struct blocking_notifier_head *notifiers; }; +/* Action requested to pm_qos_update_target */ +enum pm_qos_req_action { +PM_QOS_ADD_REQ ,/* Add a new request */ +PM_QOS_UPDATE_REQ ,/* Update an existing request */ +PM_QOS_REMOVE_REQ /* Remove an existing request */ +}; +What do you need this enum for? The function names *_update_*, *_add_*, and *_remove_* seem to be pretty redundant if you have to pass an enum that could possibly conflict with the function name.
include/linux/pm_qos.h struct pm_qos_constraints { · line 56
Quoted 3 lines
include/linux/pm_qos.h +2
-0#ifdef CONFIG_PM +int pm_qos_update_target (struct pm_qos_constraints *c,struct plist_node *node, +enum pm_qos_req_action action,int value);The action for
update_targetbetter damn well be "PM_QOS_UPDATE_REQ" or there is something strange going on.... BTW what shold this function do if thepm_qos_req_actionwas *not* the UPDATE one?
pm_qos_update_targetshould be a static to the C- file along with the enumpm_qos_req_action.Quoted 83 lines
include/linux/pm_qos.h +5
-0void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value); void pm_qos_update_request(struct pm_qos_request *req,@@ -56,6 +65,11 @@ int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_request_active (struct pm_qos_request *req);#else +static inline int pm_qos_update_target (struct pm_qos_constraints *c, +struct plist_node *node, +enum pm_qos_req_action action, +int value) + {return 0 ; }static inline void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) {return ; }kernel/power/qos.c +24
-14@@ -121,17 +121,17 @@ static const struct file_operations pm_qos_power_fops = { };/* unlocked internal variant */ -static inline int pm_qos_get_value (struct pm_qos_object *o) +static inline int pm_qos_get_value (struct pm_qos_constraints *c) { -if (plist_head_empty (&o->constraints->list)) -return o->constraints->default_value; +if (plist_head_empty (&c->list)) +return c->default_value; -switch (o->constraints->type) { +switch (c->type) {case PM_QOS_MIN : -return plist_first (&o->constraints->list)->prio; +return plist_first (&c->list)->prio;case PM_QOS_MAX : -return plist_last (&o->constraints->list)->prio; +return plist_last (&c->list)->prio;default :/* runtime check for not using enum */ @@ -139,47 +139,73 @@ static inline int pm_qos_get_value(struct pm_qos_object *o) } } -static inline s32 pm_qos_read_value (struct pm_qos_object *o) +static inline s32 pm_qos_read_value (struct pm_qos_constraints *c) { -return o->constraints->target_value; +return c->target_value; } -static inline void pm_qos_set_value (struct pm_qos_object *o,s32 value) +static inline void pm_qos_set_value (struct pm_qos_constraints *c,s32 value) { - o->constraints->target_value = value; + c->target_value = value; } -static void update_target (struct pm_qos_object *o,struct plist_node *node, -int del,int value) +/** +* pm_qos_update_target - manages the constraints list and calls the notifiers +* if needed +* @c: constraints data struct +* @node: request to add to the list, to update or to remove +* @action: action to take on the constraints list +* @value: value of the request to add or update +* +* This function returns 1 if the aggregated constraint value has changed, 0 +* otherwise. +*/ +int pm_qos_update_target (struct pm_qos_constraints *c,struct plist_node *node, +enum pm_qos_req_action action,int value) {unsigned long flags; -int prev_value, curr_value; +int prev_value, curr_value, new_value;spin_lock_irqsave (&pm_qos_lock, flags); - prev_value =pm_qos_get_value (o);kernel/power/qos.c static inline int pm_qos_get_value(struct pm_qos_object *o) · line 177
Quoted 10 lines
kernel/power/qos.c +8
-2-/* PM_QOS_DEFAULT_VALUE is a signal that the value is unchanged */ -if (value !=PM_QOS_DEFAULT_VALUE ) { + prev_value =pm_qos_get_value (c); +if (value ==PM_QOS_DEFAULT_VALUE ) + new_value = c->default_value; +else + new_value = value; + +switch (action) { +case PM_QOS_REMOVE_REQ :We have a remove request API already. This overloading of this interface feels wrong to me.
Quoted 7 lines
kernel/power/qos.c +3
-0+plist_del (node, &c->list); +break ; +case PM_QOS_UPDATE_REQ :/* * to change the list, we atomically remove, reinit * with new value and add, then see if the extremal * changed kernel/power/qos.c static inline int pm_qos_get_value(struct pm_qos_object *o) · line 187
Quoted 10 lines
kernel/power/qos.c +2
-7*/ -plist_del (node, &o->constraints->list); -plist_node_init (node, value); -plist_add (node, &o->constraints->list); - }else if (del) { -plist_del (node, &o->constraints->list); - }else { -plist_add (node, &o->constraints->list); +plist_del (node, &c->list); +case PM_QOS_ADD_REQ :Don't we have an API for adding a request? if you want to overload update like this then either we lose the add API or this shouldn't be here.
Quoted 46 lines
kernel/power/qos.c +19
-7+plist_node_init (node, new_value); +plist_add (node, &c->list); +break ; +default : +/* no action */ + ; } - curr_value =pm_qos_get_value (o); -pm_qos_set_value (o, curr_value); + + curr_value =pm_qos_get_value (c); +pm_qos_set_value (c, curr_value); +spin_unlock_irqrestore (&pm_qos_lock, flags); -if (prev_value != curr_value) -blocking_notifier_call_chain (o->constraints->notifiers, +if (prev_value != curr_value) { +blocking_notifier_call_chain (c->notifiers, (unsigned long )curr_value,NULL ); +return 1 ; + }else { +return 0 ; + } }/** @@ -190,7 +216,7 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node,*/ int pm_qos_request (int pm_qos_class) { -return pm_qos_read_value (pm_qos_array[pm_qos_class]); +return pm_qos_read_value (pm_qos_array[pm_qos_class]->constraints); }EXPORT_SYMBOL_GPL (pm_qos_request);@@ -216,20 +242,16 @@ EXPORT_SYMBOL_GPL(pm_qos_request_active);void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) { -struct pm_qos_object *o = pm_qos_array[pm_qos_class]; -int new_value; +if (!req)/*guard against callers passing in null */ +return ;
Quoted 16 lines
kernel/power/qos.c EXPORT_SYMBOL_GPL(pm_qos_request_active); · line 254
Quoted 13 lines
kernel/power/qos.c +2
-6if (pm_qos_request_active (req)) {WARN (1 ,KERN_ERR "pm_qos_add_request() called for already added request\n" );return ; } -if (value ==PM_QOS_DEFAULT_VALUE ) - new_value = o->constraints->default_value; -else - new_value = value; -plist_node_init (&req->node, new_value); req->pm_qos_class = pm_qos_class; -update_target (o, &req->node,0 ,PM_QOS_DEFAULT_VALUE ); +pm_qos_update_target (pm_qos_array[pm_qos_class]->constraints, + &req->node,PM_QOS_ADD_REQ , value);Ok, using
pm_qos_update_targetto reduce the LOC is ok but I don't think this function and the enum should be exported outside ofpm_qos.c
They are used by the next patches adding the per-device QoS.
Thanks,
Rafael
Re: [PATCH 05/15] PM QoS: generalize and export the constraints management code
In reply to mark grossQuoted 217 lines · mark gross
Quoted 25 lines · On Thu, Aug 11, 2011 at 05:06:42PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support:
- renameupdate_targettopm_qos_update_target
- generalize and exportpm_qos_update_targetfor usage by the upcoming per-device latency constraints framework:
. operate on structpm_qos_constraintsfor constraints management, . introduce an 'action' parameter for constraints add/update/remove, . the return value indicates if the aggregated constraint value has
changed,
- update the internal code to operate on structpm_qos_constraints
- add a NULL pointer check in the API functionsSigned-off-by Jean Pihet <[email protected]>--- include/linux/pm_qos.h | 14 ++++++ kernel/power/qos.c | 123 ++++++++++++++++++++++++++---------------------- 2 files changed, 81 insertions(+), 56 deletions(-)include/linux/pm_qos.h +0
-0include/linux/pm_qos.h struct pm_qos_constraints { · line 53
Quoted 10 lines
include/linux/pm_qos.h +7
-0@@ -44,7 +44,16 @@ struct pm_qos_constraints {struct blocking_notifier_head *notifiers; }; +/* Action requested to pm_qos_update_target */ +enum pm_qos_req_action { +PM_QOS_ADD_REQ ,/* Add a new request */ +PM_QOS_UPDATE_REQ ,/* Update an existing request */ +PM_QOS_REMOVE_REQ /* Remove an existing request */ +}; +What do you need this enum for? The function names *_update_*, *_add_*, and *_remove_* seem to be pretty redundant if you have to pass an enum that could possibly conflict with the function name.
include/linux/pm_qos.h struct pm_qos_constraints { · line 56
Quoted 3 lines
include/linux/pm_qos.h +2
-0#ifdef CONFIG_PM +int pm_qos_update_target (struct pm_qos_constraints *c,struct plist_node *node, +enum pm_qos_req_action action,int value);The action for
update_targetbetter damn well be "PM_QOS_UPDATE_REQ" or there is something strange going on.... BTW what shold this function do if thepm_qos_req_actionwas *not* the UPDATE one?
pm_qos_update_targetshould be a static to the C- file along with the enumpm_qos_req_action.Quoted 83 lines
include/linux/pm_qos.h +5
-0void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value); void pm_qos_update_request(struct pm_qos_request *req,@@ -56,6 +65,11 @@ int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);int pm_qos_remove_notifier (int pm_qos_class,struct notifier_block *notifier);int pm_qos_request_active (struct pm_qos_request *req);#else +static inline int pm_qos_update_target (struct pm_qos_constraints *c, +struct plist_node *node, +enum pm_qos_req_action action, +int value) + {return 0 ; }static inline void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) {return ; }kernel/power/qos.c +24
-14@@ -121,17 +121,17 @@ static const struct file_operations pm_qos_power_fops = { };/* unlocked internal variant */ -static inline int pm_qos_get_value (struct pm_qos_object *o) +static inline int pm_qos_get_value (struct pm_qos_constraints *c) { -if (plist_head_empty (&o->constraints->list)) -return o->constraints->default_value; +if (plist_head_empty (&c->list)) +return c->default_value; -switch (o->constraints->type) { +switch (c->type) {case PM_QOS_MIN : -return plist_first (&o->constraints->list)->prio; +return plist_first (&c->list)->prio;case PM_QOS_MAX : -return plist_last (&o->constraints->list)->prio; +return plist_last (&c->list)->prio;default :/* runtime check for not using enum */ @@ -139,47 +139,73 @@ static inline int pm_qos_get_value(struct pm_qos_object *o) } } -static inline s32 pm_qos_read_value (struct pm_qos_object *o) +static inline s32 pm_qos_read_value (struct pm_qos_constraints *c) { -return o->constraints->target_value; +return c->target_value; } -static inline void pm_qos_set_value (struct pm_qos_object *o,s32 value) +static inline void pm_qos_set_value (struct pm_qos_constraints *c,s32 value) { - o->constraints->target_value = value; + c->target_value = value; } -static void update_target (struct pm_qos_object *o,struct plist_node *node, -int del,int value) +/** +* pm_qos_update_target - manages the constraints list and calls the notifiers +* if needed +* @c: constraints data struct +* @node: request to add to the list, to update or to remove +* @action: action to take on the constraints list +* @value: value of the request to add or update +* +* This function returns 1 if the aggregated constraint value has changed, 0 +* otherwise. +*/ +int pm_qos_update_target (struct pm_qos_constraints *c,struct plist_node *node, +enum pm_qos_req_action action,int value) {unsigned long flags; -int prev_value, curr_value; +int prev_value, curr_value, new_value;spin_lock_irqsave (&pm_qos_lock, flags); - prev_value =pm_qos_get_value (o);kernel/power/qos.c static inline int pm_qos_get_value(struct pm_qos_object *o) · line 177
Quoted 10 lines
kernel/power/qos.c +8
-2-/* PM_QOS_DEFAULT_VALUE is a signal that the value is unchanged */ -if (value !=PM_QOS_DEFAULT_VALUE ) { + prev_value =pm_qos_get_value (c); +if (value ==PM_QOS_DEFAULT_VALUE ) + new_value = c->default_value; +else + new_value = value; + +switch (action) { +case PM_QOS_REMOVE_REQ :We have a remove request API already. This overloading of this interface feels wrong to me.
Quoted 7 lines
kernel/power/qos.c +3
-0+plist_del (node, &c->list); +break ; +case PM_QOS_UPDATE_REQ :/* * to change the list, we atomically remove, reinit * with new value and add, then see if the extremal * changed kernel/power/qos.c static inline int pm_qos_get_value(struct pm_qos_object *o) · line 187
Quoted 10 lines
kernel/power/qos.c +2
-7*/ -plist_del (node, &o->constraints->list); -plist_node_init (node, value); -plist_add (node, &o->constraints->list); - }else if (del) { -plist_del (node, &o->constraints->list); - }else { -plist_add (node, &o->constraints->list); +plist_del (node, &c->list); +case PM_QOS_ADD_REQ :Don't we have an API for adding a request? if you want to overload update like this then either we lose the add API or this shouldn't be here.
Quoted 46 lines
kernel/power/qos.c +19
-7+plist_node_init (node, new_value); +plist_add (node, &c->list); +break ; +default : +/* no action */ + ; } - curr_value =pm_qos_get_value (o); -pm_qos_set_value (o, curr_value); + + curr_value =pm_qos_get_value (c); +pm_qos_set_value (c, curr_value); +spin_unlock_irqrestore (&pm_qos_lock, flags); -if (prev_value != curr_value) -blocking_notifier_call_chain (o->constraints->notifiers, +if (prev_value != curr_value) { +blocking_notifier_call_chain (c->notifiers, (unsigned long )curr_value,NULL ); +return 1 ; + }else { +return 0 ; + } }/** @@ -190,7 +216,7 @@ static void update_target(struct pm_qos_object *o, struct plist_node *node,*/ int pm_qos_request (int pm_qos_class) { -return pm_qos_read_value (pm_qos_array[pm_qos_class]); +return pm_qos_read_value (pm_qos_array[pm_qos_class]->constraints); }EXPORT_SYMBOL_GPL (pm_qos_request);@@ -216,20 +242,16 @@ EXPORT_SYMBOL_GPL(pm_qos_request_active);void pm_qos_add_request (struct pm_qos_request *req,int pm_qos_class,s32 value) { -struct pm_qos_object *o = pm_qos_array[pm_qos_class]; -int new_value; +if (!req)/*guard against callers passing in null */ +return ;
Quoted 16 lines
kernel/power/qos.c EXPORT_SYMBOL_GPL(pm_qos_request_active); · line 254
Quoted 13 lines
kernel/power/qos.c +2
-6if (pm_qos_request_active (req)) {WARN (1 ,KERN_ERR "pm_qos_add_request() called for already added request\n" );return ; } -if (value ==PM_QOS_DEFAULT_VALUE ) - new_value = o->constraints->default_value; -else - new_value = value; -plist_node_init (&req->node, new_value); req->pm_qos_class = pm_qos_class; -update_target (o, &req->node,0 ,PM_QOS_DEFAULT_VALUE ); +pm_qos_update_target (pm_qos_array[pm_qos_class]->constraints, + &req->node,PM_QOS_ADD_REQ , value);Ok, using
pm_qos_update_targetto reduce the LOC is ok but I don't think this function and the enum should be exported outside ofpm_qos.c
They are used by the next patches adding the per-device QoS.
Thanks,
Rafael
Re: [PATCH 04/15] PM QoS: re-organize data structs
In reply to mark grossQuoted 25 lines · mark gross
Quoted 24 lines · On Thu, Aug 11, 2011 at 05:06:41PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support, re-organize the data strctures:
- add a structpm_qos_constraintswhich contains the constraints related data
- update structpm_qos_objectcontents to the PM QoS internal object data. Add a pointer to structpm_qos_constraints
- update the internal code to use the new data structs.Signed-off-by Jean Pihet <[email protected]>--- include/linux/pm_qos.h | 19 ++++++++++ kernel/power/qos.c | 90 ++++++++++++++++++++++------------------------- 2 files changed, 61 insertions(+), 48 deletions(-)include/linux/pm_qos.h +0
-0@@ -25,6 +25,25 @@ struct pm_qos_request {int pm_qos_class; };
Quoted 3 lines
include/linux/pm_qos.h struct pm_qos_request { · line 29
Quoted 2 lines
include/linux/pm_qos.h +2
-0+enum pm_qos_type { +PM_QOS_UNITIALIZED ,what is this for?
I seem to remember discussing that previously, but I can't recall what it's for. Jean?
Re: [PATCH 04/15] PM QoS: re-organize data structs
In reply to mark grossQuoted 25 lines · mark gross
Quoted 24 lines · On Thu, Aug 11, 2011 at 05:06:41PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support, re-organize the data strctures:
- add a structpm_qos_constraintswhich contains the constraints related data
- update structpm_qos_objectcontents to the PM QoS internal object data. Add a pointer to structpm_qos_constraints
- update the internal code to use the new data structs.Signed-off-by Jean Pihet <[email protected]>--- include/linux/pm_qos.h | 19 ++++++++++ kernel/power/qos.c | 90 ++++++++++++++++++++++------------------------- 2 files changed, 61 insertions(+), 48 deletions(-)include/linux/pm_qos.h +0
-0@@ -25,6 +25,25 @@ struct pm_qos_request {int pm_qos_class; };
Quoted 3 lines
include/linux/pm_qos.h struct pm_qos_request { · line 29
Quoted 2 lines
include/linux/pm_qos.h +2
-0+enum pm_qos_type { +PM_QOS_UNITIALIZED ,what is this for?
I seem to remember discussing that previously, but I can't recall what it's for. Jean?
Re: [PATCH 06/15] PM QoS: implement the per-device PM QoS constraints
In reply to [email protected]Hi,
Well, it looks like I should have reviewed this one more carefully.
Quoted 95 lines · On Thursday, August 11, 2011, [email protected] wrote:
From: Jean Pihet <[email protected]>
Implement the per-device PM QoS constraints by creating a device PM QoS API, which calls the PM QoS constraints management core code.
The per-device latency constraints data strctures are stored in the device
dev_pm_infostruct.The device PM code calls the init and destroy of the per-device constraints data struct in order to support the dynamic insertion and removal of the devices in the system.
To minimize the data usage by the per-device constraints, the data struct is only allocated at the first call to
dev_pm_qos_add_request. The data is later free'd when the device is removed from the system.Signed-off-by Jean Pihet <[email protected]>--- drivers/base/power/Makefile | 4 +- drivers/base/power/main.c | 3 + drivers/base/power/qos.c | 262 +++++++++++++++++++++++++++++++++++++++++++ include/linux/pm.h | 9 ++ include/linux/pm_qos.h | 39 +++++++ 5 files changed, 315 insertions(+), 2 deletions(-) create mode 100644 drivers/base/power/qos.cdrivers/base/power/Makefile +2
-2@@ -1,8 +1,8 @@ -obj-$(CONFIG_PM) += sysfs.o generic_ops.o +obj-$(CONFIG_PM) += sysfs.o generic_ops.o qos.o obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o obj-$(CONFIG_PM_RUNTIME) += runtime.o obj-$(CONFIG_PM_TRACE_RTC) += trace.o obj-$(CONFIG_PM_OPP) += opp.o obj-$(CONFIG_HAVE_CLK) += clock_ops.o -ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG +ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUGdrivers/base/power/main.c +3
-0@@ -22,6 +22,7 @@#include <linux/mutex.h> #include <linux/pm.h> #include <linux/pm_runtime.h> +#include <linux/pm_qos.h> #include <linux/resume-trace.h> #include <linux/interrupt.h> #include <linux/sched.h> @@ -97,6 +98,7 @@ void device_pm_add(struct device *dev) dev_name(dev->parent));list_add_tail (&dev->power.entry, &dpm_list);mutex_unlock (&dpm_list_mtx); +dev_pm_qos_constraints_init (dev); }/** @@ -107,6 +109,7 @@ void device_pm_remove(struct device *dev) {pr_debug ("PM: Removing info for %s:%s\n" , dev->bus ? dev->bus->name :"No Bus" ,dev_name (dev)); +dev_pm_qos_constraints_destroy (dev);complete_all (&dev->power.completion);mutex_lock (&dpm_list_mtx);list_del_init (&dev->power.entry);drivers/base/power/qos.c new file +19
-0@@ -0,0 +1,262 @@ +/* +* This module exposes the interface to kernel space for specifying +* per-device PM QoS dependencies. It provides infrastructure for registration +* of: +* +* Dependents on a QoS value : register requests +* Watchers of QoS value : get notified when target QoS value changes +* +* This QoS design is best effort based. Dependents register their QoS needs. +* Watchers register to keep track of the current QoS needs of the system. +* +* Note about the per-device constraint data struct allocation: +* . The per-device constraints data struct ptr is tored into the device +* dev_pm_info. +* . To minimize the data usage by the per-device constraints, the data struct +* is only allocated at the first call to dev_pm_qos_add_request. +* . The data is later free'd when the device is removed from the system. +* . The constraints_state variable from dev_pm_info tracks the data struct +* allocation state:
drivers/base/power/qos.c line 29
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+* DEV_PM_QOS_NO_DEVICE: No device present or device removed, no data +* allocated, +* DEV_PM_QOS_DEVICE_PRESENT: Device present, data not allocated and will be +* allocated at the first call to dev_pm_qos_add_request, +* DEV_PM_QOS_ALLOCATED: Device present, data allocated. The per-device +* PM QoS constraints framework is operational and constraints can be +* added, updated or removed using the dev_pm_qos_* API. +*/ + +/*#define DEBUG*/
Please remove this.
drivers/base/power/qos.c line 41
Quoted 12 lines
drivers/base/power/qos.c new file +12
-0+ +#include <linux/pm_qos.h> +#include <linux/sched.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/time.h> +#include <linux/fs.h> +#include <linux/device.h> +#include <linux/string.h> +#include <linux/platform_device.h> +#include <linux/init.h> +#include <linux/kernel.h>
Are you sure all of the headers are necessary?
drivers/base/power/qos.c line 50
Quoted 9 lines
drivers/base/power/qos.c new file +9
-0+ + +static void dev_pm_qos_constraints_allocate (struct device *dev); + +int dev_pm_qos_request_active (struct dev_pm_qos_request *req) +{ +return req->dev !=0 ; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_request_active);
That should be a static inline in a header.
Quoted 5 lines
drivers/base/power/qos.c new file +5
-0+ +/** +* dev_pm_qos_add_request - inserts new qos request into the list +* @req: pointer to a preallocated handle +* @dev: target device for the constraint
drivers/base/power/qos.c line 65
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+* @value: defines the qos request +* +* This function inserts a new entry in the device constraints list of +* requested qos performance characteristics. It recomputes the aggregate +* QoS expectations of parameters and initializes the dev_pm_qos_request +* handle. Caller needs to save this handle for later use in updates and +* removal. +*/ +void dev_pm_qos_add_request (struct dev_pm_qos_request *req,struct device *dev, +s32 value)
I'd use a different ordering of arguments, namely (dev, req, value).
drivers/base/power/qos.c line 68
Quoted 3 lines
drivers/base/power/qos.c new file +3
-0+{ +if (!req)/*guard against callers passing in null */ +return ;
Why not to check for !dev too?
drivers/base/power/qos.c line 79
Quoted 11 lines
drivers/base/power/qos.c new file +11
-0+ +if (dev_pm_qos_request_active (req)) { +WARN (1 ,KERN_ERR "dev_pm_qos_add_request() called for already " +"added request\n" ); +return ; + } + req->dev = dev; + +/* Allocate the constraints struct on the first call to add_request */ +if (req->dev->power.constraints_state ==DEV_PM_QOS_DEVICE_PRESENT ) +dev_pm_qos_constraints_allocate (dev);
Why not to do
+ if (!req->dev->power.constraints)
+ dev_pm_qos_constraints_allocate(dev);
drivers/base/power/qos.c line 84
Quoted 5 lines
drivers/base/power/qos.c new file +5
-0+ +/* Silently return if the device has been removed */ +if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return ; +
Hmm. What will happen if two callers run dev_pm_qos_add_request() concurrently for the same device?
Quoted 25 lines
drivers/base/power/qos.c new file +25
-0+pm_qos_update_target (dev->power.constraints, + &req->node,PM_QOS_ADD_REQ , value); +} +EXPORT_SYMBOL_GPL (dev_pm_qos_add_request); + +/** +* dev_pm_qos_update_request - modifies an existing qos request +* @req : handle to list element holding a dev_pm_qos request to use +* @value: defines the qos request +* +* Updates an existing dev PM qos request along with updating the +* target value. +* +* Attempts are made to make this code callable on hot code paths. +*/ +void dev_pm_qos_update_request (struct dev_pm_qos_request *req, +s32 new_value) +{ +if (!req)/*guard against callers passing in null */ +return ; + +if (!dev_pm_qos_request_active (req)) { +WARN (1 ,KERN_ERR "dev_pm_qos_update_request() called for " +"unknown object\n" ); +return ;
drivers/base/power/qos.c line 119
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+ } + +/* Silently return if the device has been removed */ +if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return ; + +if (new_value != req->node.prio) +pm_qos_update_target ( + req->dev->power.constraints, + &req->node,PM_QOS_UPDATE_REQ , new_value);
I'm not sure what prevents dev_pm_qos_constraints_destroy() from removing the list from under us while we're executing this?
Quoted 18 lines
drivers/base/power/qos.c new file +18
-0+} +EXPORT_SYMBOL_GPL (dev_pm_qos_update_request); + +/** +* dev_pm_qos_remove_request - modifies an existing qos request +* @req: handle to request list element +* +* Will remove pm qos request from the list of constraints and +* recompute the current target value. Call this on slow code paths. +*/ +void dev_pm_qos_remove_request (struct dev_pm_qos_request *req) +{ +if (!req)/*guard against callers passing in null */ +return ; + +if (!dev_pm_qos_request_active (req)) { +WARN (1 ,KERN_ERR "dev_pm_qos_remove_request() called for " +"unknown object\n" );
drivers/base/power/qos.c line 147
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+return ; + } + +/* Silently return if the device has been removed */ +if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return ; + +pm_qos_update_target (req->dev->power.constraints, + &req->node,PM_QOS_REMOVE_REQ , +PM_QOS_DEFAULT_VALUE );
Same here.
Quoted 15 lines
drivers/base/power/qos.c new file +15
-0+memset (req,0 ,sizeof (*req)); +} +EXPORT_SYMBOL_GPL (dev_pm_qos_remove_request); + +/** +* dev_pm_qos_add_notifier - sets notification entry for changes to target value +* of per-device PM QoS constraints +* +* @dev: target device for the constraint +* @notifier: notifier block managed by caller. +* +* Will register the notifier into a notification chain that gets called +* upon changes to the target value for the device. +*/ +int dev_pm_qos_add_notifier (struct device *dev,struct notifier_block *notifier)
drivers/base/power/qos.c line 172
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+{ +int retval =0 ; + +/* Silently return if the device has been removed */ +if (dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return retval; + + retval =blocking_notifier_chain_register ( + dev->power.constraints->notifiers, + notifier);
That may be racing with dev_pm_qos_constraints_destroy() too.
Quoted 17 lines
drivers/base/power/qos.c new file +17
-0+ +return retval; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_add_notifier); + +/** +* dev_pm_qos_remove_notifier - deletes notification for changes to target value +* of per-device PM QoS constraints +* +* @dev: target device for the constraint +* @notifier: notifier block to be removed. +* +* Will remove the notifier from the notification chain that gets called +* upon changes to the target value. +*/ +int dev_pm_qos_remove_notifier (struct device *dev, +struct notifier_block *notifier)
drivers/base/power/qos.c line 199
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+{ +int retval =0 ; + +/* Silently return if the device has been removed */ +if (dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return retval; + + retval =blocking_notifier_chain_unregister ( + dev->power.constraints->notifiers, + notifier);
Same here.
Quoted 25 lines
drivers/base/power/qos.c new file +25
-0+ +return retval; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_remove_notifier); + +/* Called at the first call to add_request, for constraint data allocation */ +static void dev_pm_qos_constraints_allocate (struct device *dev) +{ +struct pm_qos_constraints *c; +struct blocking_notifier_head *n; + + c =kzalloc (sizeof (*c),GFP_KERNEL ); +if (!c) +return ; + + n =kzalloc (sizeof (*n),GFP_KERNEL ); +if (!n) { +kfree (c); +return ; + } +BLOCKING_INIT_NOTIFIER_HEAD (n); + + dev->power.constraints = c; +plist_head_init (&dev->power.constraints->list, &dev->power.lock); + dev->power.constraints->target_value =PM_QOS_DEV_LAT_DEFAULT_VALUE ;
drivers/base/power/qos.c line 234
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+ dev->power.constraints->default_value =PM_QOS_DEV_LAT_DEFAULT_VALUE ; + dev->power.constraints->type =PM_QOS_MIN ; + dev->power.constraints->notifiers = n; + dev->power.constraints_state =DEV_PM_QOS_ALLOCATED ; +} + +/* Called from the device PM subsystem at device insertion */ +void dev_pm_qos_constraints_init (struct device *dev) +{ + dev->power.constraints_state =DEV_PM_QOS_DEVICE_PRESENT ;
Hmm. Is it insufficient to check if "constraints" is not NULL?
drivers/base/power/qos.c line 243
Quoted 9 lines
drivers/base/power/qos.c new file +9
-0+} + +/* Called from the device PM subsystem at device removal */ +void dev_pm_qos_constraints_destroy (struct device *dev) +{ +struct dev_pm_qos_request *req, *tmp; +enum dev_pm_qos_state constraints_state = dev->power.constraints_state; + + dev->power.constraints_state =DEV_PM_QOS_NO_DEVICE ;
I'm not sure what the purpose of this is. I'd simply check if "constraints" is not NULL and I'd flush the list if not.
Moreover, that has to go under a lock so that it doesn't race with the other functions above. I think you can reuse power.lock for that.
Quoted 9 lines
drivers/base/power/qos.c new file +9
-0+if (constraints_state ==DEV_PM_QOS_ALLOCATED ) { +/* Flush the constraints list for the device */ +plist_for_each_entry_safe (req, tmp, + &dev->power.constraints->list, + node) +/* +* Update constraints list and call the per-device +* callbacks if needed +*/
drivers/base/power/qos.c line 262
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+pm_qos_update_target (req->dev->power.constraints, + &req->node,PM_QOS_REMOVE_REQ , +PM_QOS_DEFAULT_VALUE ); + +kfree (dev->power.constraints->notifiers); +kfree (dev->power.constraints); + dev->power.constraints =NULL ; + } +} +
Thanks,
Rafael
Re: [PATCH 06/15] PM QoS: implement the per-device PM QoS constraints
In reply to [email protected]Hi,
Well, it looks like I should have reviewed this one more carefully.
Quoted 95 lines · On Thursday, August 11, 2011, [email protected] wrote:
From: Jean Pihet <[email protected]>
Implement the per-device PM QoS constraints by creating a device PM QoS API, which calls the PM QoS constraints management core code.
The per-device latency constraints data strctures are stored in the device
dev_pm_infostruct.The device PM code calls the init and destroy of the per-device constraints data struct in order to support the dynamic insertion and removal of the devices in the system.
To minimize the data usage by the per-device constraints, the data struct is only allocated at the first call to
dev_pm_qos_add_request. The data is later free'd when the device is removed from the system.Signed-off-by Jean Pihet <[email protected]>--- drivers/base/power/Makefile | 4 +- drivers/base/power/main.c | 3 + drivers/base/power/qos.c | 262 +++++++++++++++++++++++++++++++++++++++++++ include/linux/pm.h | 9 ++ include/linux/pm_qos.h | 39 +++++++ 5 files changed, 315 insertions(+), 2 deletions(-) create mode 100644 drivers/base/power/qos.cdrivers/base/power/Makefile +2
-2@@ -1,8 +1,8 @@ -obj-$(CONFIG_PM) += sysfs.o generic_ops.o +obj-$(CONFIG_PM) += sysfs.o generic_ops.o qos.o obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o obj-$(CONFIG_PM_RUNTIME) += runtime.o obj-$(CONFIG_PM_TRACE_RTC) += trace.o obj-$(CONFIG_PM_OPP) += opp.o obj-$(CONFIG_HAVE_CLK) += clock_ops.o -ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG +ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUGdrivers/base/power/main.c +3
-0@@ -22,6 +22,7 @@#include <linux/mutex.h> #include <linux/pm.h> #include <linux/pm_runtime.h> +#include <linux/pm_qos.h> #include <linux/resume-trace.h> #include <linux/interrupt.h> #include <linux/sched.h> @@ -97,6 +98,7 @@ void device_pm_add(struct device *dev) dev_name(dev->parent));list_add_tail (&dev->power.entry, &dpm_list);mutex_unlock (&dpm_list_mtx); +dev_pm_qos_constraints_init (dev); }/** @@ -107,6 +109,7 @@ void device_pm_remove(struct device *dev) {pr_debug ("PM: Removing info for %s:%s\n" , dev->bus ? dev->bus->name :"No Bus" ,dev_name (dev)); +dev_pm_qos_constraints_destroy (dev);complete_all (&dev->power.completion);mutex_lock (&dpm_list_mtx);list_del_init (&dev->power.entry);drivers/base/power/qos.c new file +19
-0@@ -0,0 +1,262 @@ +/* +* This module exposes the interface to kernel space for specifying +* per-device PM QoS dependencies. It provides infrastructure for registration +* of: +* +* Dependents on a QoS value : register requests +* Watchers of QoS value : get notified when target QoS value changes +* +* This QoS design is best effort based. Dependents register their QoS needs. +* Watchers register to keep track of the current QoS needs of the system. +* +* Note about the per-device constraint data struct allocation: +* . The per-device constraints data struct ptr is tored into the device +* dev_pm_info. +* . To minimize the data usage by the per-device constraints, the data struct +* is only allocated at the first call to dev_pm_qos_add_request. +* . The data is later free'd when the device is removed from the system. +* . The constraints_state variable from dev_pm_info tracks the data struct +* allocation state:
drivers/base/power/qos.c line 29
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+* DEV_PM_QOS_NO_DEVICE: No device present or device removed, no data +* allocated, +* DEV_PM_QOS_DEVICE_PRESENT: Device present, data not allocated and will be +* allocated at the first call to dev_pm_qos_add_request, +* DEV_PM_QOS_ALLOCATED: Device present, data allocated. The per-device +* PM QoS constraints framework is operational and constraints can be +* added, updated or removed using the dev_pm_qos_* API. +*/ + +/*#define DEBUG*/
Please remove this.
drivers/base/power/qos.c line 41
Quoted 12 lines
drivers/base/power/qos.c new file +12
-0+ +#include <linux/pm_qos.h> +#include <linux/sched.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/time.h> +#include <linux/fs.h> +#include <linux/device.h> +#include <linux/string.h> +#include <linux/platform_device.h> +#include <linux/init.h> +#include <linux/kernel.h>
Are you sure all of the headers are necessary?
drivers/base/power/qos.c line 50
Quoted 9 lines
drivers/base/power/qos.c new file +9
-0+ + +static void dev_pm_qos_constraints_allocate (struct device *dev); + +int dev_pm_qos_request_active (struct dev_pm_qos_request *req) +{ +return req->dev !=0 ; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_request_active);
That should be a static inline in a header.
Quoted 5 lines
drivers/base/power/qos.c new file +5
-0+ +/** +* dev_pm_qos_add_request - inserts new qos request into the list +* @req: pointer to a preallocated handle +* @dev: target device for the constraint
drivers/base/power/qos.c line 65
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+* @value: defines the qos request +* +* This function inserts a new entry in the device constraints list of +* requested qos performance characteristics. It recomputes the aggregate +* QoS expectations of parameters and initializes the dev_pm_qos_request +* handle. Caller needs to save this handle for later use in updates and +* removal. +*/ +void dev_pm_qos_add_request (struct dev_pm_qos_request *req,struct device *dev, +s32 value)
I'd use a different ordering of arguments, namely (dev, req, value).
drivers/base/power/qos.c line 68
Quoted 3 lines
drivers/base/power/qos.c new file +3
-0+{ +if (!req)/*guard against callers passing in null */ +return ;
Why not to check for !dev too?
drivers/base/power/qos.c line 79
Quoted 11 lines
drivers/base/power/qos.c new file +11
-0+ +if (dev_pm_qos_request_active (req)) { +WARN (1 ,KERN_ERR "dev_pm_qos_add_request() called for already " +"added request\n" ); +return ; + } + req->dev = dev; + +/* Allocate the constraints struct on the first call to add_request */ +if (req->dev->power.constraints_state ==DEV_PM_QOS_DEVICE_PRESENT ) +dev_pm_qos_constraints_allocate (dev);
Why not to do
+ if (!req->dev->power.constraints)
+ dev_pm_qos_constraints_allocate(dev);
drivers/base/power/qos.c line 84
Quoted 5 lines
drivers/base/power/qos.c new file +5
-0+ +/* Silently return if the device has been removed */ +if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return ; +
Hmm. What will happen if two callers run dev_pm_qos_add_request() concurrently for the same device?
Quoted 25 lines
drivers/base/power/qos.c new file +25
-0+pm_qos_update_target (dev->power.constraints, + &req->node,PM_QOS_ADD_REQ , value); +} +EXPORT_SYMBOL_GPL (dev_pm_qos_add_request); + +/** +* dev_pm_qos_update_request - modifies an existing qos request +* @req : handle to list element holding a dev_pm_qos request to use +* @value: defines the qos request +* +* Updates an existing dev PM qos request along with updating the +* target value. +* +* Attempts are made to make this code callable on hot code paths. +*/ +void dev_pm_qos_update_request (struct dev_pm_qos_request *req, +s32 new_value) +{ +if (!req)/*guard against callers passing in null */ +return ; + +if (!dev_pm_qos_request_active (req)) { +WARN (1 ,KERN_ERR "dev_pm_qos_update_request() called for " +"unknown object\n" ); +return ;
drivers/base/power/qos.c line 119
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+ } + +/* Silently return if the device has been removed */ +if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return ; + +if (new_value != req->node.prio) +pm_qos_update_target ( + req->dev->power.constraints, + &req->node,PM_QOS_UPDATE_REQ , new_value);
I'm not sure what prevents dev_pm_qos_constraints_destroy() from removing the list from under us while we're executing this?
Quoted 18 lines
drivers/base/power/qos.c new file +18
-0+} +EXPORT_SYMBOL_GPL (dev_pm_qos_update_request); + +/** +* dev_pm_qos_remove_request - modifies an existing qos request +* @req: handle to request list element +* +* Will remove pm qos request from the list of constraints and +* recompute the current target value. Call this on slow code paths. +*/ +void dev_pm_qos_remove_request (struct dev_pm_qos_request *req) +{ +if (!req)/*guard against callers passing in null */ +return ; + +if (!dev_pm_qos_request_active (req)) { +WARN (1 ,KERN_ERR "dev_pm_qos_remove_request() called for " +"unknown object\n" );
drivers/base/power/qos.c line 147
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+return ; + } + +/* Silently return if the device has been removed */ +if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return ; + +pm_qos_update_target (req->dev->power.constraints, + &req->node,PM_QOS_REMOVE_REQ , +PM_QOS_DEFAULT_VALUE );
Same here.
Quoted 15 lines
drivers/base/power/qos.c new file +15
-0+memset (req,0 ,sizeof (*req)); +} +EXPORT_SYMBOL_GPL (dev_pm_qos_remove_request); + +/** +* dev_pm_qos_add_notifier - sets notification entry for changes to target value +* of per-device PM QoS constraints +* +* @dev: target device for the constraint +* @notifier: notifier block managed by caller. +* +* Will register the notifier into a notification chain that gets called +* upon changes to the target value for the device. +*/ +int dev_pm_qos_add_notifier (struct device *dev,struct notifier_block *notifier)
drivers/base/power/qos.c line 172
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+{ +int retval =0 ; + +/* Silently return if the device has been removed */ +if (dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return retval; + + retval =blocking_notifier_chain_register ( + dev->power.constraints->notifiers, + notifier);
That may be racing with dev_pm_qos_constraints_destroy() too.
Quoted 17 lines
drivers/base/power/qos.c new file +17
-0+ +return retval; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_add_notifier); + +/** +* dev_pm_qos_remove_notifier - deletes notification for changes to target value +* of per-device PM QoS constraints +* +* @dev: target device for the constraint +* @notifier: notifier block to be removed. +* +* Will remove the notifier from the notification chain that gets called +* upon changes to the target value. +*/ +int dev_pm_qos_remove_notifier (struct device *dev, +struct notifier_block *notifier)
drivers/base/power/qos.c line 199
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+{ +int retval =0 ; + +/* Silently return if the device has been removed */ +if (dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return retval; + + retval =blocking_notifier_chain_unregister ( + dev->power.constraints->notifiers, + notifier);
Same here.
Quoted 25 lines
drivers/base/power/qos.c new file +25
-0+ +return retval; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_remove_notifier); + +/* Called at the first call to add_request, for constraint data allocation */ +static void dev_pm_qos_constraints_allocate (struct device *dev) +{ +struct pm_qos_constraints *c; +struct blocking_notifier_head *n; + + c =kzalloc (sizeof (*c),GFP_KERNEL ); +if (!c) +return ; + + n =kzalloc (sizeof (*n),GFP_KERNEL ); +if (!n) { +kfree (c); +return ; + } +BLOCKING_INIT_NOTIFIER_HEAD (n); + + dev->power.constraints = c; +plist_head_init (&dev->power.constraints->list, &dev->power.lock); + dev->power.constraints->target_value =PM_QOS_DEV_LAT_DEFAULT_VALUE ;
drivers/base/power/qos.c line 234
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+ dev->power.constraints->default_value =PM_QOS_DEV_LAT_DEFAULT_VALUE ; + dev->power.constraints->type =PM_QOS_MIN ; + dev->power.constraints->notifiers = n; + dev->power.constraints_state =DEV_PM_QOS_ALLOCATED ; +} + +/* Called from the device PM subsystem at device insertion */ +void dev_pm_qos_constraints_init (struct device *dev) +{ + dev->power.constraints_state =DEV_PM_QOS_DEVICE_PRESENT ;
Hmm. Is it insufficient to check if "constraints" is not NULL?
drivers/base/power/qos.c line 243
Quoted 9 lines
drivers/base/power/qos.c new file +9
-0+} + +/* Called from the device PM subsystem at device removal */ +void dev_pm_qos_constraints_destroy (struct device *dev) +{ +struct dev_pm_qos_request *req, *tmp; +enum dev_pm_qos_state constraints_state = dev->power.constraints_state; + + dev->power.constraints_state =DEV_PM_QOS_NO_DEVICE ;
I'm not sure what the purpose of this is. I'd simply check if "constraints" is not NULL and I'd flush the list if not.
Moreover, that has to go under a lock so that it doesn't race with the other functions above. I think you can reuse power.lock for that.
Quoted 9 lines
drivers/base/power/qos.c new file +9
-0+if (constraints_state ==DEV_PM_QOS_ALLOCATED ) { +/* Flush the constraints list for the device */ +plist_for_each_entry_safe (req, tmp, + &dev->power.constraints->list, + node) +/* +* Update constraints list and call the per-device +* callbacks if needed +*/
drivers/base/power/qos.c line 262
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+pm_qos_update_target (req->dev->power.constraints, + &req->node,PM_QOS_REMOVE_REQ , +PM_QOS_DEFAULT_VALUE ); + +kfree (dev->power.constraints->notifiers); +kfree (dev->power.constraints); + dev->power.constraints =NULL ; + } +} +
Thanks,
Rafael
Re: [PATCH 05/15] PM QoS: generalize and export the constraints management code
In reply to Rafael J. WysockiHi Rafael, Mark,
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · mark gross
Quoted 14 lines · On Thu, Aug 11, 2011 at 05:06:42PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support:
- renameupdate_targettopm_qos_update_target
- generalize and exportpm_qos_update_targetfor usage by the upcoming per-device latency constraints framework:
. operate on structpm_qos_constraintsfor constraints management, . introduce an 'action' parameter for constraints add/update/remove, . the return value indicates if the aggregated constraint value has changed,
- update the internal code to operate on structpm_qos_constraints
- add a NULL pointer check in the API functionsSigned-off-by Jean Pihet <[email protected]>
...
Quoted 12 lines
Quoted 12 lines
include/linux/pm_qos.h struct pm_qos_constraints { · line 53
Quoted 7 lines
include/linux/pm_qos.h +7
-0+/* Action requested to pm_qos_update_target */ +enum pm_qos_req_action { + PM_QOS_ADD_REQ, /* Add a new request */ + PM_QOS_UPDATE_REQ, /* Update an existing request */ + PM_QOS_REMOVE_REQ /* Remove an existing request */ +}; +What do you need this enum for? The function names *_update_*, *_add_*, and *_remove_* seem to be pretty redundant if you have to pass an enum that could possibly conflict with the function name.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
#ifdef
CONFIG_PM
+int pm_qos_update_target(structpm_qos_constraints*c, structplist_node*node,
+ enumpm_qos_req_actionaction, int value);The action for
update_targetbetter damn well be "PM_QOS_UPDATE_REQ" or there is something strange going on.... BTW what shold this function do if thepm_qos_req_actionwas *not* the UPDATE one?
The meaning of pm_qos_update_target is 'update the PM QoS target constraints lists'. As described in the changelog the intention of this patch is to implement the constraints lists management logic in update_target and simplify the API functions (add/update/remove). It is also exported for the upcoming (patch 06/15]) to use it as well.
...
Quoted 43 lines
Quoted 43 lines
Quoted 7 lines
+int pm_qos_update_target(struct
pm_qos_constraints*c, structplist_node*node,
+ enumpm_qos_req_actionaction, int value)
{
unsigned long flags;
- intprev_value,curr_value;
+ intprev_value,curr_value,new_value;Quoted 12 lines
spin_lock_irqsave(&pm_qos_lock, flags);
-prev_value=pm_qos_get_value(o);
- /*PM_QOS_DEFAULT_VALUEis a signal that the value is unchanged */
- if (value !=PM_QOS_DEFAULT_VALUE) {
+prev_value=pm_qos_get_value(c);
+ if (value ==PM_QOS_DEFAULT_VALUE)
+new_value=c->default_value;
+ else
+new_value= value;
+
+ switch (action) {
+ casePM_QOS_REMOVE_REQ:We have a remove request API already. This overloading of this interface feels wrong to me.
Quoted 9 lines
+
plist_del(node, &c->list);
+ break;
+ casePM_QOS_UPDATE_REQ:
/*
* to change the list, we atomically remove, reinit
* with new value and add, then see if the extremal
* changed
*/
-plist_del(node, &o->constraints->list);Quoted 8 lines
-
plist_node_init(node, value);
-plist_add(node, &o->constraints->list);
- } else if (del) {
-plist_del(node, &o->constraints->list);
- } else {
-plist_add(node, &o->constraints->list);
+plist_del(node, &c->list);
+ casePM_QOS_ADD_REQ:Don't we have an API for adding a request? if you want to overload update like this then either we lose the add API or this shouldn't be here.
...
Quoted 26 lines
Quoted 9 lines
Quoted 9 lines
kernel/power/qos.c +2
-2@@ -216,20 +242,16 @@ EXPORT_SYMBOL_GPL(pm_qos_request_active); void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class, s32 value) { - struct pm_qos_object *o = pm_qos_array[pm_qos_class]; - int new_value; + if (!req) /*guard against callers passing in null */ + return;Quoted 16 lines
kernel/power/qos.c EXPORT_SYMBOL_GPL(pm_qos_request_active); · line 254
Quoted 13 lines
kernel/power/qos.c +2
-6if (pm_qos_request_active(req)) { WARN(1, KERN_ERR "pm_qos_add_request() called for already added request\n"); return; } - if (value == PM_QOS_DEFAULT_VALUE) - new_value = o->constraints->default_value; - else - new_value = value; - plist_node_init(&req->node, new_value); req->pm_qos_class = pm_qos_class; - update_target(o, &req->node, 0, PM_QOS_DEFAULT_VALUE); + pm_qos_update_target(pm_qos_array[pm_qos_class]->constraints, + &req->node, PM_QOS_ADD_REQ, value);Ok, using
pm_qos_update_targetto reduce the LOC is ok but I don't think this function and the enum should be exported outside ofpm_qos.c
Quoted 1 line
They are used by the next patches adding the per-device QoS.
Exactly
Quoted 4 lines
Thanks,
Rafael
Jean
Re: [PATCH 05/15] PM QoS: generalize and export the constraints management code
In reply to Rafael J. WysockiHi Rafael, Mark,
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · mark gross
Quoted 14 lines · On Thu, Aug 11, 2011 at 05:06:42PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support:
- renameupdate_targettopm_qos_update_target
- generalize and exportpm_qos_update_targetfor usage by the upcoming per-device latency constraints framework:
. operate on structpm_qos_constraintsfor constraints management, . introduce an 'action' parameter for constraints add/update/remove, . the return value indicates if the aggregated constraint value has changed,
- update the internal code to operate on structpm_qos_constraints
- add a NULL pointer check in the API functionsSigned-off-by Jean Pihet <[email protected]>
...
Quoted 12 lines
Quoted 12 lines
include/linux/pm_qos.h struct pm_qos_constraints { · line 53
Quoted 7 lines
include/linux/pm_qos.h +7
-0+/* Action requested to pm_qos_update_target */ +enum pm_qos_req_action { + PM_QOS_ADD_REQ, /* Add a new request */ + PM_QOS_UPDATE_REQ, /* Update an existing request */ + PM_QOS_REMOVE_REQ /* Remove an existing request */ +}; +What do you need this enum for? The function names *_update_*, *_add_*, and *_remove_* seem to be pretty redundant if you have to pass an enum that could possibly conflict with the function name.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
#ifdef
CONFIG_PM
+int pm_qos_update_target(structpm_qos_constraints*c, structplist_node*node,
+ enumpm_qos_req_actionaction, int value);The action for
update_targetbetter damn well be "PM_QOS_UPDATE_REQ" or there is something strange going on.... BTW what shold this function do if thepm_qos_req_actionwas *not* the UPDATE one?
The meaning of pm_qos_update_target is 'update the PM QoS target constraints lists'. As described in the changelog the intention of this patch is to implement the constraints lists management logic in update_target and simplify the API functions (add/update/remove). It is also exported for the upcoming (patch 06/15]) to use it as well.
...
Quoted 43 lines
Quoted 43 lines
Quoted 7 lines
+int pm_qos_update_target(struct
pm_qos_constraints*c, structplist_node*node,
+ enumpm_qos_req_actionaction, int value)
{
unsigned long flags;
- intprev_value,curr_value;
+ intprev_value,curr_value,new_value;Quoted 12 lines
spin_lock_irqsave(&pm_qos_lock, flags);
-prev_value=pm_qos_get_value(o);
- /*PM_QOS_DEFAULT_VALUEis a signal that the value is unchanged */
- if (value !=PM_QOS_DEFAULT_VALUE) {
+prev_value=pm_qos_get_value(c);
+ if (value ==PM_QOS_DEFAULT_VALUE)
+new_value=c->default_value;
+ else
+new_value= value;
+
+ switch (action) {
+ casePM_QOS_REMOVE_REQ:We have a remove request API already. This overloading of this interface feels wrong to me.
Quoted 9 lines
+
plist_del(node, &c->list);
+ break;
+ casePM_QOS_UPDATE_REQ:
/*
* to change the list, we atomically remove, reinit
* with new value and add, then see if the extremal
* changed
*/
-plist_del(node, &o->constraints->list);Quoted 8 lines
-
plist_node_init(node, value);
-plist_add(node, &o->constraints->list);
- } else if (del) {
-plist_del(node, &o->constraints->list);
- } else {
-plist_add(node, &o->constraints->list);
+plist_del(node, &c->list);
+ casePM_QOS_ADD_REQ:Don't we have an API for adding a request? if you want to overload update like this then either we lose the add API or this shouldn't be here.
...
Quoted 26 lines
Quoted 9 lines
Quoted 9 lines
kernel/power/qos.c +2
-2@@ -216,20 +242,16 @@ EXPORT_SYMBOL_GPL(pm_qos_request_active); void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class, s32 value) { - struct pm_qos_object *o = pm_qos_array[pm_qos_class]; - int new_value; + if (!req) /*guard against callers passing in null */ + return;Quoted 16 lines
kernel/power/qos.c EXPORT_SYMBOL_GPL(pm_qos_request_active); · line 254
Quoted 13 lines
kernel/power/qos.c +2
-6if (pm_qos_request_active(req)) { WARN(1, KERN_ERR "pm_qos_add_request() called for already added request\n"); return; } - if (value == PM_QOS_DEFAULT_VALUE) - new_value = o->constraints->default_value; - else - new_value = value; - plist_node_init(&req->node, new_value); req->pm_qos_class = pm_qos_class; - update_target(o, &req->node, 0, PM_QOS_DEFAULT_VALUE); + pm_qos_update_target(pm_qos_array[pm_qos_class]->constraints, + &req->node, PM_QOS_ADD_REQ, value);Ok, using
pm_qos_update_targetto reduce the LOC is ok but I don't think this function and the enum should be exported outside ofpm_qos.c
Quoted 1 line
They are used by the next patches adding the per-device QoS.
Exactly
Quoted 4 lines
Thanks,
Rafael
Jean
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 04/15] PM QoS: re-organize data structs
In reply to Rafael J. WysockiRafael, Mark,
Quoted 26 lines · Rafael J. Wysocki
Quoted 25 lines · mark gross
Quoted 24 lines · On Thu, Aug 11, 2011 at 05:06:41PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support, re-organize the data strctures:
- add a structpm_qos_constraintswhich contains the constraints related data
- update structpm_qos_objectcontents to the PM QoS internal object data. Add a pointer to structpm_qos_constraints
- update the internal code to use the new data structs.Signed-off-by Jean Pihet <[email protected]>---
include/linux/pm_qos.h | 19 ++++++++++
kernel/power/qos.c | 90 ++++++++++++++++++++++-------------------------2 files changed, 61 insertions(+), 48 deletions(-)include/linux/pm_qos.h +0
-0@@ -25,6 +25,25 @@ struct pm_qos_request { int pm_qos_class; };
Quoted 7 lines
Quoted 3 lines
include/linux/pm_qos.h struct pm_qos_request { · line 29
Quoted 2 lines
include/linux/pm_qos.h +2
-0+enum pm_qos_type { + PM_QOS_UNITIALIZED,what is this for?
I seem to remember discussing that previously, but I can't recall what it's for. Jean?
Sorry it is a left over from the previous version, it has been used to detect non initialized data structs.
It is still used to detect an error in pm_qos_get_value and so by its callers pm_qos_update_target and pm_qos_power_read. I have to admit the usefulness is quite limited.
Is the removal of PM_QOS_UNITIALIZED needed? I would say no.
Regards,
Jean
Re: [PATCH 04/15] PM QoS: re-organize data structs
In reply to Rafael J. WysockiRafael, Mark,
Quoted 26 lines · Rafael J. Wysocki
Quoted 25 lines · mark gross
Quoted 24 lines · On Thu, Aug 11, 2011 at 05:06:41PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support, re-organize the data strctures:
- add a structpm_qos_constraintswhich contains the constraints related data
- update structpm_qos_objectcontents to the PM QoS internal object data. Add a pointer to structpm_qos_constraints
- update the internal code to use the new data structs.Signed-off-by Jean Pihet <[email protected]>---
include/linux/pm_qos.h | 19 ++++++++++
kernel/power/qos.c | 90 ++++++++++++++++++++++-------------------------2 files changed, 61 insertions(+), 48 deletions(-)include/linux/pm_qos.h +0
-0@@ -25,6 +25,25 @@ struct pm_qos_request { int pm_qos_class; };
Quoted 7 lines
Quoted 3 lines
include/linux/pm_qos.h struct pm_qos_request { · line 29
Quoted 2 lines
include/linux/pm_qos.h +2
-0+enum pm_qos_type { + PM_QOS_UNITIALIZED,what is this for?
I seem to remember discussing that previously, but I can't recall what it's for. Jean?
Sorry it is a left over from the previous version, it has been used to detect non initialized data structs.
It is still used to detect an error in pm_qos_get_value and so by its callers pm_qos_update_target and pm_qos_power_read. I have to admit the usefulness is quite limited.
Is the removal of PM_QOS_UNITIALIZED needed? I would say no.
Regards,
Jean
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 06/15] PM QoS: implement the per-device PM QoS constraints
In reply to Rafael J. WysockiRafael,
2011/8/13 Rafael J. Wysocki <[email protected]>:
Quoted 23 lines
Hi,
Well, it looks like I should have reviewed this one more carefully.
Quoted 18 lines · On Thursday, August 11, 2011, [email protected] wrote:
From: Jean Pihet <[email protected]>
Implement the per-device PM QoS constraints by creating a device PM QoS API, which calls the PM QoS constraints management core code.
The per-device latency constraints data strctures are stored in the device
dev_pm_infostruct.The device PM code calls the init and destroy of the per-device constraints data struct in order to support the dynamic insertion and removal of the devices in the system.
To minimize the data usage by the per-device constraints, the data struct is only allocated at the first call to
dev_pm_qos_add_request. The data is later free'd when the device is removed from the system.Signed-off-by Jean Pihet <[email protected]>---
...
Quoted 3 lines
Quoted 1 line
+/*#define DEBUG*/
Please remove this.
Ok
Quoted 15 lines
drivers/base/power/qos.c line 41
Quoted 13 lines
drivers/base/power/qos.c new file +12
-0+ +#include <linux/pm_qos.h> +#include <linux/sched.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/time.h> +#include <linux/fs.h> +#include <linux/device.h> +#include <linux/string.h> +#include <linux/platform_device.h> +#include <linux/init.h> +#include <linux/kernel.h> Are you sure all of the headers are necessary?
No. I can check that.
Quoted 12 lines
drivers/base/power/qos.c line 50
Quoted 10 lines
drivers/base/power/qos.c new file +9
-0+ + +static void dev_pm_qos_constraints_allocate (struct device *dev); + +int dev_pm_qos_request_active (struct dev_pm_qos_request *req) +{ + return req->dev != 0; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_request_active);That should be a static inline in a header.
Ok
Quoted 10 lines
Quoted 10 lines
drivers/base/power/qos.c new file +9
-0+ +/** +* dev_pm_qos_add_request - inserts new qos request into the list +* @req: pointer to a preallocated handle +* @dev: target device for the constraint +* @value: defines the qos request +* +* This function inserts a new entry in the device constraints list of +* requested qos performance characteristics. It recomputes the aggregate
Quoted 8 lines
Quoted 6 lines
+ * QoS expectations of parameters and initializes the
dev_pm_qos_request
+ * handle. Caller needs to save this handle for later use in updates and
+ * removal.
+ */
+void dev_pm_qos_add_request(structdev_pm_qos_request*req, struct device *dev,
+ s32 value)I'd use a different ordering of arguments, namely (dev, req, value).
Ok
Quoted 6 lines
Quoted 4 lines
+{
+ if (!req) /*guard against callers passing in null */
+ return;Why not to check for !dev too?
Ok that makes sense
Quoted 15 lines
drivers/base/power/qos.c line 79
Quoted 12 lines
drivers/base/power/qos.c new file +11
-0+ + if (dev_pm_qos_request_active(req)) { + WARN(1, KERN_ERR "dev_pm_qos_add_request() called for already " + "added request\n"); + return; + } + req->dev = dev; + + /* Allocate the constraints struct on the first call to add_request */ + if (req->dev->power.constraints_state == DEV_PM_QOS_DEVICE_PRESENT) + dev_pm_qos_constraints_allocate(dev);Why not to do
Quoted 2 lines
+ if (!req->dev->power.constraints)
+dev_pm_qos_constraints_allocate(dev);
Cf. my comments at the end of this message for the data structs alloc/free and the locking.
Quoted 9 lines
drivers/base/power/qos.c line 84
Quoted 6 lines
drivers/base/power/qos.c new file +5
-0+ + /* Silently return if the device has been removed */ + if (req->dev->power.constraints_state != DEV_PM_QOS_ALLOCATED) + return; +Hmm. What will happen if two callers run
dev_pm_qos_add_request()concurrently for the same device?
update_target is using the power.lock to protect the constraints lists changes.
Quoted 31 lines
Quoted 31 lines
+ pm_qos_update_target(dev->power.constraints,
+ &req->node,PM_QOS_ADD_REQ, value);drivers/base/power/qos.c new file +28
-0+} +EXPORT_SYMBOL_GPL (dev_pm_qos_add_request); + +/** +* dev_pm_qos_update_request - modifies an existing qos request +* @req : handle to list element holding a dev_pm_qos request to use +* @value: defines the qos request +* +* Updates an existing dev PM qos request along with updating the +* target value. +* +* Attempts are made to make this code callable on hot code paths. +*/ +void dev_pm_qos_update_request (struct dev_pm_qos_request *req, + s32 new_value) +{ + if (!req) /*guard against callers passing in null */ + return; + + if (!dev_pm_qos_request_active(req)) { + WARN(1, KERN_ERR "dev_pm_qos_update_request() called for " + "unknown object\n"); + return; + } + + /* Silently return if the device has been removed */ + if (req->dev->power.constraints_state != DEV_PM_QOS_ALLOCATED) + return;
Quoted 8 lines
Quoted 5 lines
+
+ if (new_value!=req->node.prio)
+ pm_qos_update_target(
+req->dev->power.constraints,
+&req->node,PM_QOS_UPDATE_REQ,new_value);I'm not sure what prevents
dev_pm_qos_constraints_destroy()from removing the list from under us while we're executing this?
Cf. my comments at the end of this message for the data structs alloc/free and the locking.
Quoted 141 lines
Quoted 19 lines
drivers/base/power/qos.c new file +18
-0+} +EXPORT_SYMBOL_GPL (dev_pm_qos_update_request); + +/** +* dev_pm_qos_remove_request - modifies an existing qos request +* @req: handle to request list element +* +* Will remove pm qos request from the list of constraints and +* recompute the current target value. Call this on slow code paths. +*/ +void dev_pm_qos_remove_request (struct dev_pm_qos_request *req) +{ + if (!req) /*guard against callers passing in null */ + return; + + if (!dev_pm_qos_request_active(req)) { + WARN(1, KERN_ERR "dev_pm_qos_remove_request() called for " + "unknown object\n");drivers/base/power/qos.c line 147
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+ return; + } + + /* Silently return if the device has been removed */ + if (req->dev->power.constraints_state != DEV_PM_QOS_ALLOCATED) + return; + + pm_qos_update_target(req->dev->power.constraints, + &req->node, PM_QOS_REMOVE_REQ, + PM_QOS_DEFAULT_VALUE);Same here.
Quoted 15 lines
+
memset(req, 0, sizeof(*req));drivers/base/power/qos.c new file +14
-0+} +EXPORT_SYMBOL_GPL (dev_pm_qos_remove_request); + +/** +* dev_pm_qos_add_notifier - sets notification entry for changes to target value +* of per-device PM QoS constraints +* +* @dev: target device for the constraint +* @notifier: notifier block managed by caller. +* +* Will register the notifier into a notification chain that gets called +* upon changes to the target value for the device. +*/ +int dev_pm_qos_add_notifier (struct device *dev,struct notifier_block *notifier)drivers/base/power/qos.c line 172
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+{ + int retval = 0; + + /* Silently return if the device has been removed */ + if (dev->power.constraints_state != DEV_PM_QOS_ALLOCATED) + return retval; + + retval = blocking_notifier_chain_register( + dev->power.constraints->notifiers, + notifier);That may be racing with
dev_pm_qos_constraints_destroy()too.Quoted 17 lines
drivers/base/power/qos.c new file +17
-0+ + return retval; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_add_notifier); + +/** +* dev_pm_qos_remove_notifier - deletes notification for changes to target value +* of per-device PM QoS constraints +* +* @dev: target device for the constraint +* @notifier: notifier block to be removed. +* +* Will remove the notifier from the notification chain that gets called +* upon changes to the target value. +*/ +int dev_pm_qos_remove_notifier (struct device *dev, + struct notifier_block *notifier)drivers/base/power/qos.c line 199
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+{ + int retval = 0; + + /* Silently return if the device has been removed */ + if (dev->power.constraints_state != DEV_PM_QOS_ALLOCATED) + return retval; + + retval = blocking_notifier_chain_unregister( + dev->power.constraints->notifiers, + notifier);Same here.
Quoted 25 lines
drivers/base/power/qos.c new file +25
-0+ + return retval; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_remove_notifier); + +/* Called at the first call to add_request, for constraint data allocation */ +static void dev_pm_qos_constraints_allocate (struct device *dev) +{ + struct pm_qos_constraints *c; + struct blocking_notifier_head *n; + + c = kzalloc(sizeof(*c), GFP_KERNEL); + if (!c) + return; + + n = kzalloc(sizeof(*n), GFP_KERNEL); + if (!n) { + kfree(c); + return; + } + BLOCKING_INIT_NOTIFIER_HEAD(n); + + dev->power.constraints = c; + plist_head_init(&dev->power.constraints->list, &dev->power.lock); + dev->power.constraints->target_value = PM_QOS_DEV_LAT_DEFAULT_VALUE;drivers/base/power/qos.c line 234
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+ dev->power.constraints->default_value = PM_QOS_DEV_LAT_DEFAULT_VALUE; + dev->power.constraints->type = PM_QOS_MIN; + dev->power.constraints->notifiers = n; + dev->power.constraints_state = DEV_PM_QOS_ALLOCATED; +} + +/* Called from the device PM subsystem at device insertion */ +void dev_pm_qos_constraints_init (struct device *dev) +{ + dev->power.constraints_state = DEV_PM_QOS_DEVICE_PRESENT;Hmm. Is it insufficient to check if "constraints" is not NULL?
drivers/base/power/qos.c line 243
Quoted 9 lines
drivers/base/power/qos.c new file +9
-0+} + +/* Called from the device PM subsystem at device removal */ +void dev_pm_qos_constraints_destroy (struct device *dev) +{ + struct dev_pm_qos_request *req, *tmp; + enum dev_pm_qos_state constraints_state = dev->power.constraints_state; + + dev->power.constraints_state = DEV_PM_QOS_NO_DEVICE;I'm not sure what the purpose of this is. I'd simply check if "constraints" is not NULL and I'd flush the list if not.
Quoted 3 lines
Moreover, that has to go under a lock so that it doesn't race with the other functions above. I think you can reuse power.lock for that.
Your remarks are inline with the concerns I had about the adata structs alloc/free and the locking.
1) data structs alloc/free
As described in the changelog:
Quoted 3 lines
Quoted 3 lines
To minimize the data usage by the per-device constraints, the data struct is only allocated at the first call to
dev_pm_qos_add_request. The data is later free'd when the device is removed from the system.
A basic state machine is needed in order to allocate the data at the first call to add_request and free it when the device is removed. Another option is to allocate the data when the device is added to the system and free it when the device is removed. That would make the code simpler but it is using a lot of memory for unneeded data.
2) Race conditions
I will add a lock to isolate the API callers from dev_pm_qos_constraints_destroy().
The power.lock is already used by update_target so another lock is needed to protect the data allocation/free.
I will rework this tomorrow and re-submit asap when it is ready. Is that OK?
Quoted 4 lines
Thanks,
Rafael
Thanks,
Jean
Re: [PATCH 06/15] PM QoS: implement the per-device PM QoS constraints
In reply to Rafael J. WysockiRafael,
2011/8/13 Rafael J. Wysocki <[email protected]>:
Quoted 23 lines
Hi,
Well, it looks like I should have reviewed this one more carefully.
Quoted 18 lines · On Thursday, August 11, 2011, [email protected] wrote:
From: Jean Pihet <[email protected]>
Implement the per-device PM QoS constraints by creating a device PM QoS API, which calls the PM QoS constraints management core code.
The per-device latency constraints data strctures are stored in the device
dev_pm_infostruct.The device PM code calls the init and destroy of the per-device constraints data struct in order to support the dynamic insertion and removal of the devices in the system.
To minimize the data usage by the per-device constraints, the data struct is only allocated at the first call to
dev_pm_qos_add_request. The data is later free'd when the device is removed from the system.Signed-off-by Jean Pihet <[email protected]>---
...
Quoted 3 lines
Quoted 1 line
+/*#define DEBUG*/
Please remove this.
Ok
Quoted 15 lines
drivers/base/power/qos.c line 41
Quoted 13 lines
drivers/base/power/qos.c new file +12
-0+ +#include <linux/pm_qos.h> +#include <linux/sched.h> +#include <linux/spinlock.h> +#include <linux/slab.h> +#include <linux/time.h> +#include <linux/fs.h> +#include <linux/device.h> +#include <linux/string.h> +#include <linux/platform_device.h> +#include <linux/init.h> +#include <linux/kernel.h> Are you sure all of the headers are necessary?
No. I can check that.
Quoted 12 lines
drivers/base/power/qos.c line 50
Quoted 10 lines
drivers/base/power/qos.c new file +9
-0+ + +static void dev_pm_qos_constraints_allocate (struct device *dev); + +int dev_pm_qos_request_active (struct dev_pm_qos_request *req) +{ + return req->dev != 0; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_request_active);That should be a static inline in a header.
Ok
Quoted 10 lines
Quoted 10 lines
drivers/base/power/qos.c new file +9
-0+ +/** +* dev_pm_qos_add_request - inserts new qos request into the list +* @req: pointer to a preallocated handle +* @dev: target device for the constraint +* @value: defines the qos request +* +* This function inserts a new entry in the device constraints list of +* requested qos performance characteristics. It recomputes the aggregate
Quoted 8 lines
Quoted 6 lines
+ * QoS expectations of parameters and initializes the
dev_pm_qos_request
+ * handle. Caller needs to save this handle for later use in updates and
+ * removal.
+ */
+void dev_pm_qos_add_request(structdev_pm_qos_request*req, struct device *dev,
+ s32 value)I'd use a different ordering of arguments, namely (dev, req, value).
Ok
Quoted 6 lines
Quoted 4 lines
+{
+ if (!req) /*guard against callers passing in null */
+ return;Why not to check for !dev too?
Ok that makes sense
Quoted 15 lines
drivers/base/power/qos.c line 79
Quoted 12 lines
drivers/base/power/qos.c new file +11
-0+ + if (dev_pm_qos_request_active(req)) { + WARN(1, KERN_ERR "dev_pm_qos_add_request() called for already " + "added request\n"); + return; + } + req->dev = dev; + + /* Allocate the constraints struct on the first call to add_request */ + if (req->dev->power.constraints_state == DEV_PM_QOS_DEVICE_PRESENT) + dev_pm_qos_constraints_allocate(dev);Why not to do
Quoted 2 lines
+ if (!req->dev->power.constraints)
+dev_pm_qos_constraints_allocate(dev);
Cf. my comments at the end of this message for the data structs alloc/free and the locking.
Quoted 9 lines
drivers/base/power/qos.c line 84
Quoted 6 lines
drivers/base/power/qos.c new file +5
-0+ + /* Silently return if the device has been removed */ + if (req->dev->power.constraints_state != DEV_PM_QOS_ALLOCATED) + return; +Hmm. What will happen if two callers run
dev_pm_qos_add_request()concurrently for the same device?
update_target is using the power.lock to protect the constraints lists changes.
Quoted 31 lines
Quoted 31 lines
+ pm_qos_update_target(dev->power.constraints,
+ &req->node,PM_QOS_ADD_REQ, value);drivers/base/power/qos.c new file +28
-0+} +EXPORT_SYMBOL_GPL (dev_pm_qos_add_request); + +/** +* dev_pm_qos_update_request - modifies an existing qos request +* @req : handle to list element holding a dev_pm_qos request to use +* @value: defines the qos request +* +* Updates an existing dev PM qos request along with updating the +* target value. +* +* Attempts are made to make this code callable on hot code paths. +*/ +void dev_pm_qos_update_request (struct dev_pm_qos_request *req, + s32 new_value) +{ + if (!req) /*guard against callers passing in null */ + return; + + if (!dev_pm_qos_request_active(req)) { + WARN(1, KERN_ERR "dev_pm_qos_update_request() called for " + "unknown object\n"); + return; + } + + /* Silently return if the device has been removed */ + if (req->dev->power.constraints_state != DEV_PM_QOS_ALLOCATED) + return;
Quoted 8 lines
Quoted 5 lines
+
+ if (new_value!=req->node.prio)
+ pm_qos_update_target(
+req->dev->power.constraints,
+&req->node,PM_QOS_UPDATE_REQ,new_value);I'm not sure what prevents
dev_pm_qos_constraints_destroy()from removing the list from under us while we're executing this?
Cf. my comments at the end of this message for the data structs alloc/free and the locking.
Quoted 141 lines
Quoted 19 lines
drivers/base/power/qos.c new file +18
-0+} +EXPORT_SYMBOL_GPL (dev_pm_qos_update_request); + +/** +* dev_pm_qos_remove_request - modifies an existing qos request +* @req: handle to request list element +* +* Will remove pm qos request from the list of constraints and +* recompute the current target value. Call this on slow code paths. +*/ +void dev_pm_qos_remove_request (struct dev_pm_qos_request *req) +{ + if (!req) /*guard against callers passing in null */ + return; + + if (!dev_pm_qos_request_active(req)) { + WARN(1, KERN_ERR "dev_pm_qos_remove_request() called for " + "unknown object\n");drivers/base/power/qos.c line 147
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+ return; + } + + /* Silently return if the device has been removed */ + if (req->dev->power.constraints_state != DEV_PM_QOS_ALLOCATED) + return; + + pm_qos_update_target(req->dev->power.constraints, + &req->node, PM_QOS_REMOVE_REQ, + PM_QOS_DEFAULT_VALUE);Same here.
Quoted 15 lines
+
memset(req, 0, sizeof(*req));drivers/base/power/qos.c new file +14
-0+} +EXPORT_SYMBOL_GPL (dev_pm_qos_remove_request); + +/** +* dev_pm_qos_add_notifier - sets notification entry for changes to target value +* of per-device PM QoS constraints +* +* @dev: target device for the constraint +* @notifier: notifier block managed by caller. +* +* Will register the notifier into a notification chain that gets called +* upon changes to the target value for the device. +*/ +int dev_pm_qos_add_notifier (struct device *dev,struct notifier_block *notifier)drivers/base/power/qos.c line 172
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+{ + int retval = 0; + + /* Silently return if the device has been removed */ + if (dev->power.constraints_state != DEV_PM_QOS_ALLOCATED) + return retval; + + retval = blocking_notifier_chain_register( + dev->power.constraints->notifiers, + notifier);That may be racing with
dev_pm_qos_constraints_destroy()too.Quoted 17 lines
drivers/base/power/qos.c new file +17
-0+ + return retval; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_add_notifier); + +/** +* dev_pm_qos_remove_notifier - deletes notification for changes to target value +* of per-device PM QoS constraints +* +* @dev: target device for the constraint +* @notifier: notifier block to be removed. +* +* Will remove the notifier from the notification chain that gets called +* upon changes to the target value. +*/ +int dev_pm_qos_remove_notifier (struct device *dev, + struct notifier_block *notifier)drivers/base/power/qos.c line 199
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+{ + int retval = 0; + + /* Silently return if the device has been removed */ + if (dev->power.constraints_state != DEV_PM_QOS_ALLOCATED) + return retval; + + retval = blocking_notifier_chain_unregister( + dev->power.constraints->notifiers, + notifier);Same here.
Quoted 25 lines
drivers/base/power/qos.c new file +25
-0+ + return retval; +} +EXPORT_SYMBOL_GPL (dev_pm_qos_remove_notifier); + +/* Called at the first call to add_request, for constraint data allocation */ +static void dev_pm_qos_constraints_allocate (struct device *dev) +{ + struct pm_qos_constraints *c; + struct blocking_notifier_head *n; + + c = kzalloc(sizeof(*c), GFP_KERNEL); + if (!c) + return; + + n = kzalloc(sizeof(*n), GFP_KERNEL); + if (!n) { + kfree(c); + return; + } + BLOCKING_INIT_NOTIFIER_HEAD(n); + + dev->power.constraints = c; + plist_head_init(&dev->power.constraints->list, &dev->power.lock); + dev->power.constraints->target_value = PM_QOS_DEV_LAT_DEFAULT_VALUE;drivers/base/power/qos.c line 234
Quoted 10 lines
drivers/base/power/qos.c new file +10
-0+ dev->power.constraints->default_value = PM_QOS_DEV_LAT_DEFAULT_VALUE; + dev->power.constraints->type = PM_QOS_MIN; + dev->power.constraints->notifiers = n; + dev->power.constraints_state = DEV_PM_QOS_ALLOCATED; +} + +/* Called from the device PM subsystem at device insertion */ +void dev_pm_qos_constraints_init (struct device *dev) +{ + dev->power.constraints_state = DEV_PM_QOS_DEVICE_PRESENT;Hmm. Is it insufficient to check if "constraints" is not NULL?
drivers/base/power/qos.c line 243
Quoted 9 lines
drivers/base/power/qos.c new file +9
-0+} + +/* Called from the device PM subsystem at device removal */ +void dev_pm_qos_constraints_destroy (struct device *dev) +{ + struct dev_pm_qos_request *req, *tmp; + enum dev_pm_qos_state constraints_state = dev->power.constraints_state; + + dev->power.constraints_state = DEV_PM_QOS_NO_DEVICE;I'm not sure what the purpose of this is. I'd simply check if "constraints" is not NULL and I'd flush the list if not.
Quoted 3 lines
Moreover, that has to go under a lock so that it doesn't race with the other functions above. I think you can reuse power.lock for that.
Your remarks are inline with the concerns I had about the adata structs alloc/free and the locking.
1) data structs alloc/free
As described in the changelog:
Quoted 3 lines
Quoted 3 lines
To minimize the data usage by the per-device constraints, the data struct is only allocated at the first call to
dev_pm_qos_add_request. The data is later free'd when the device is removed from the system.
A basic state machine is needed in order to allocate the data at the first call to add_request and free it when the device is removed. Another option is to allocate the data when the device is added to the system and free it when the device is removed. That would make the code simpler but it is using a lot of memory for unneeded data.
2) Race conditions
I will add a lock to isolate the API callers from dev_pm_qos_constraints_destroy().
The power.lock is already used by update_target so another lock is needed to protect the data allocation/free.
I will rework this tomorrow and re-submit asap when it is ready. Is that OK?
Quoted 4 lines
Thanks,
Rafael
Thanks,
Jean
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Rafael,
Quoted 79 lines · Rafael J. Wysocki
Hi,
Quoted 59 lines · Jean Pihet
Hi Rafael,
2011/8/12 Rafael J. Wysocki <[email protected]>:
Quoted 5 lines · On Thursday, August 11, 2011, [email protected] wrote:
Quoted 4 lines
From: Jean Pihet <[email protected]>
This patch set is in an RFC state, for review and comments.
...
Quoted 22 lines
Quoted 22 lines
Questions:
1. the user space API is still under discussions on linux-omap and linux-pm MLs, cf. [1]. The idea is to add a user-space API for the devices constratins PM QoS, using a sysfs entry per device[1] http://marc.info/?l=linux-omap&m=131232344503327&w=2
ToDo:
1. write Documentation for the new PM QoS class, once the RFC is agreed on
2. validate the constraints framework on OMAP4 HW (done on OMAP3)
3. Need testing on platforms other than OMAP
4. refine the power domains wake-up latency and the cpuidle figures
5. re-visit the OMAP power domains states initialization procedure. Currently the power states that have been changed from the constraints API which were applied before the initialization of the power domains are lostBased on the master branch of the linux-omap git tree (3.0.0-rc7). Compile tested using OMAP and x86 generic defconfigs.
Quoted 6 lines
Quoted 3 lines
Lightly tested on OMAP3 Beagleboard (ES2.x).
Need testing on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/removeThe patchset looks really good to me, I don't think I have any major complaints about this version.
Ok good to hear it! I tried to address all comments and concerns in this release.
Quoted 5 lines
The only thing I'd like to ask at the moment is whether or not the compilation of
drivers/base/power/qos.cshould depend onCONFIG_PM_RUNTIME. Do you think it will be used by system suspend code on any platforms?I would say it should only depend on
CONFIG_PMbecause the dev PM QoS API can be used from any kernel code, being runtime PM code or not. I leave the decision to the PM framework experts.Quoted 2 lines
Also, I'd like to take the final patchset for 3.2,
Ok good!
Quoted 2 lines
but I don't feel
confident enough about the OMAP patches.The OMAP patches have been reviewed a few times already and the comments have been taken into account. Also i has been tested correctly on OMAP3.
Quoted 6 lines
Quoted 2 lines
If you want me to take them too,
please make sure they are ACKed by the OMAP maintainers.For sure I need the Acks. I guess I now need to annoy OMAP folks about it ;p In the case the Acks are not gathered on time the generic patches could be merged in, then the OMAP generic code. Do you think it is a viable option?
Yes, it is. I can take patches [1-7/15] alone.
Quoted 8 lines
The only concern I have is about the on-going OMAP PM initialization clean-up task, cf. ToDo list:
>> 5. re-visit the OMAP power domains states initialization procedure. Currently
>> the power states that have been changed from the constraints API which were
>> applied before the initialization of the power domains are lost
Quoted 6 lines
Quoted 4 lines
On the other hand some testing is needed on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/remove functions. I tested the SD card insertion/removal on OMAP3.
OK, so are you going to make any more changes to patches [1-7/15]?
I am now reworking [06/15] after your comments.
Is that OK timewise?
Quoted 3 lines
Rafael
Thanks,
Jean
Rafael,
Quoted 79 lines · Rafael J. Wysocki
Hi,
Quoted 59 lines · Jean Pihet
Hi Rafael,
2011/8/12 Rafael J. Wysocki <[email protected]>:
Quoted 5 lines · On Thursday, August 11, 2011, [email protected] wrote:
Quoted 4 lines
From: Jean Pihet <[email protected]>
This patch set is in an RFC state, for review and comments.
...
Quoted 22 lines
Quoted 22 lines
Questions:
1. the user space API is still under discussions on linux-omap and linux-pm MLs, cf. [1]. The idea is to add a user-space API for the devices constratins PM QoS, using a sysfs entry per device[1] http://marc.info/?l=linux-omap&m=131232344503327&w=2
ToDo:
1. write Documentation for the new PM QoS class, once the RFC is agreed on
2. validate the constraints framework on OMAP4 HW (done on OMAP3)
3. Need testing on platforms other than OMAP
4. refine the power domains wake-up latency and the cpuidle figures
5. re-visit the OMAP power domains states initialization procedure. Currently the power states that have been changed from the constraints API which were applied before the initialization of the power domains are lostBased on the master branch of the linux-omap git tree (3.0.0-rc7). Compile tested using OMAP and x86 generic defconfigs.
Quoted 6 lines
Quoted 3 lines
Lightly tested on OMAP3 Beagleboard (ES2.x).
Need testing on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/removeThe patchset looks really good to me, I don't think I have any major complaints about this version.
Ok good to hear it! I tried to address all comments and concerns in this release.
Quoted 5 lines
The only thing I'd like to ask at the moment is whether or not the compilation of
drivers/base/power/qos.cshould depend onCONFIG_PM_RUNTIME. Do you think it will be used by system suspend code on any platforms?I would say it should only depend on
CONFIG_PMbecause the dev PM QoS API can be used from any kernel code, being runtime PM code or not. I leave the decision to the PM framework experts.Quoted 2 lines
Also, I'd like to take the final patchset for 3.2,
Ok good!
Quoted 2 lines
but I don't feel
confident enough about the OMAP patches.The OMAP patches have been reviewed a few times already and the comments have been taken into account. Also i has been tested correctly on OMAP3.
Quoted 6 lines
Quoted 2 lines
If you want me to take them too,
please make sure they are ACKed by the OMAP maintainers.For sure I need the Acks. I guess I now need to annoy OMAP folks about it ;p In the case the Acks are not gathered on time the generic patches could be merged in, then the OMAP generic code. Do you think it is a viable option?
Yes, it is. I can take patches [1-7/15] alone.
Quoted 8 lines
The only concern I have is about the on-going OMAP PM initialization clean-up task, cf. ToDo list:
>> 5. re-visit the OMAP power domains states initialization procedure. Currently
>> the power states that have been changed from the constraints API which were
>> applied before the initialization of the power domains are lost
Quoted 6 lines
Quoted 4 lines
On the other hand some testing is needed on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/remove functions. I tested the SD card insertion/removal on OMAP3.
OK, so are you going to make any more changes to patches [1-7/15]?
I am now reworking [06/15] after your comments.
Is that OK timewise?
Quoted 3 lines
Rafael
Thanks,
Jean
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 04/15] PM QoS: re-organize data structs
In reply to Jean PihetQuoted 37 lines · Jean Pihet
Rafael, Mark,
Quoted 26 lines · Rafael J. Wysocki
Quoted 25 lines · mark gross
Quoted 24 lines · On Thu, Aug 11, 2011 at 05:06:41PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support, re-organize the data strctures:
- add a structpm_qos_constraintswhich contains the constraints related data
- update structpm_qos_objectcontents to the PM QoS internal object data. Add a pointer to structpm_qos_constraints
- update the internal code to use the new data structs.Signed-off-by Jean Pihet <[email protected]>--- include/linux/pm_qos.h | 19 ++++++++++ kernel/power/qos.c | 90 ++++++++++++++++++++++------------------------- 2 files changed, 61 insertions(+), 48 deletions(-)include/linux/pm_qos.h +0
-0@@ -25,6 +25,25 @@ struct pm_qos_request {int pm_qos_class; };Quoted 7 lines
Quoted 3 lines
include/linux/pm_qos.h struct pm_qos_request { · line 29
Quoted 2 lines
include/linux/pm_qos.h +2
-0+enum pm_qos_type { +PM_QOS_UNITIALIZED ,what is this for?
I seem to remember discussing that previously, but I can't recall what it's for. Jean?
Quoted 7 lines
Sorry it is a left over from the previous version, it has been used to detect non initialized data structs.
It is still used to detect an error inpm_qos_get_valueand so by its callerspm_qos_update_targetandpm_qos_power_read. I have to admit the usefulness is quite limited.Is the removal of
PM_QOS_UNITIALIZEDneeded? I would say no.
I agree.
Thanks,
Rafael
Re: [PATCH 04/15] PM QoS: re-organize data structs
In reply to Jean PihetQuoted 37 lines · Jean Pihet
Rafael, Mark,
Quoted 26 lines · Rafael J. Wysocki
Quoted 25 lines · mark gross
Quoted 24 lines · On Thu, Aug 11, 2011 at 05:06:41PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support, re-organize the data strctures:
- add a structpm_qos_constraintswhich contains the constraints related data
- update structpm_qos_objectcontents to the PM QoS internal object data. Add a pointer to structpm_qos_constraints
- update the internal code to use the new data structs.Signed-off-by Jean Pihet <[email protected]>--- include/linux/pm_qos.h | 19 ++++++++++ kernel/power/qos.c | 90 ++++++++++++++++++++++------------------------- 2 files changed, 61 insertions(+), 48 deletions(-)include/linux/pm_qos.h +0
-0@@ -25,6 +25,25 @@ struct pm_qos_request {int pm_qos_class; };Quoted 7 lines
Quoted 3 lines
include/linux/pm_qos.h struct pm_qos_request { · line 29
Quoted 2 lines
include/linux/pm_qos.h +2
-0+enum pm_qos_type { +PM_QOS_UNITIALIZED ,what is this for?
I seem to remember discussing that previously, but I can't recall what it's for. Jean?
Quoted 7 lines
Sorry it is a left over from the previous version, it has been used to detect non initialized data structs.
It is still used to detect an error inpm_qos_get_valueand so by its callerspm_qos_update_targetandpm_qos_power_read. I have to admit the usefulness is quite limited.Is the removal of
PM_QOS_UNITIALIZEDneeded? I would say no.
I agree.
Thanks,
Rafael
Re: [PATCH 05/15] PM QoS: generalize and export the constraints management code
In reply to Jean PihetQuoted 39 lines · Jean Pihet
Hi Rafael, Mark,
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · mark gross
Quoted 14 lines · On Thu, Aug 11, 2011 at 05:06:42PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support:
- renameupdate_targettopm_qos_update_target
- generalize and exportpm_qos_update_targetfor usage by the upcoming per-device latency constraints framework:
. operate on structpm_qos_constraintsfor constraints management, . introduce an 'action' parameter for constraints add/update/remove, . the return value indicates if the aggregated constraint value has
changed,
- update the internal code to operate on structpm_qos_constraints
- add a NULL pointer check in the API functionsSigned-off-by Jean Pihet <[email protected]>...
Quoted 12 lines
Quoted 12 lines
include/linux/pm_qos.h struct pm_qos_constraints { · line 53
Quoted 7 lines
include/linux/pm_qos.h +7
-0+/* Action requested to pm_qos_update_target */ +enum pm_qos_req_action { +PM_QOS_ADD_REQ ,/* Add a new request */ +PM_QOS_UPDATE_REQ ,/* Update an existing request */ +PM_QOS_REMOVE_REQ /* Remove an existing request */ +}; +What do you need this enum for? The function names *_update_*, *_add_*, and *_remove_* seem to be pretty redundant if you have to pass an enum that could possibly conflict with the function name.
Quoted 6 lines
Quoted 6 lines
include/linux/pm_qos.h struct pm_qos_constraints { · line 56
Quoted 3 lines
#ifdef
CONFIG_PMinclude/linux/pm_qos.h +2
-0+int pm_qos_update_target (struct pm_qos_constraints *c,struct plist_node *node, +enum pm_qos_req_action action,int value);The action for
update_targetbetter damn well be "PM_QOS_UPDATE_REQ" or there is something strange going on.... BTW what shold this function do if thepm_qos_req_actionwas *not* the UPDATE one?
Quoted 5 lines
The meaning of
pm_qos_update_targetis 'update the PM QoS target constraints lists'. As described in the changelog the intention of this patch is to implement the constraints lists management logic inupdate_targetand simplify the API functions (add/update/remove). It is also exported for the upcoming (patch 06/15]) to use it as well.
The enums are fine by me and they allow us to simplify the code quite a bit.
Thanks,
Rafael
Re: [PATCH 05/15] PM QoS: generalize and export the constraints management code
In reply to Jean PihetQuoted 39 lines · Jean Pihet
Hi Rafael, Mark,
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · mark gross
Quoted 14 lines · On Thu, Aug 11, 2011 at 05:06:42PM +0200, [email protected] wrote:
From: Jean Pihet <[email protected]>
In preparation for the per-device constratins support:
- renameupdate_targettopm_qos_update_target
- generalize and exportpm_qos_update_targetfor usage by the upcoming per-device latency constraints framework:
. operate on structpm_qos_constraintsfor constraints management, . introduce an 'action' parameter for constraints add/update/remove, . the return value indicates if the aggregated constraint value has
changed,
- update the internal code to operate on structpm_qos_constraints
- add a NULL pointer check in the API functionsSigned-off-by Jean Pihet <[email protected]>...
Quoted 12 lines
Quoted 12 lines
include/linux/pm_qos.h struct pm_qos_constraints { · line 53
Quoted 7 lines
include/linux/pm_qos.h +7
-0+/* Action requested to pm_qos_update_target */ +enum pm_qos_req_action { +PM_QOS_ADD_REQ ,/* Add a new request */ +PM_QOS_UPDATE_REQ ,/* Update an existing request */ +PM_QOS_REMOVE_REQ /* Remove an existing request */ +}; +What do you need this enum for? The function names *_update_*, *_add_*, and *_remove_* seem to be pretty redundant if you have to pass an enum that could possibly conflict with the function name.
Quoted 6 lines
Quoted 6 lines
include/linux/pm_qos.h struct pm_qos_constraints { · line 56
Quoted 3 lines
#ifdef
CONFIG_PMinclude/linux/pm_qos.h +2
-0+int pm_qos_update_target (struct pm_qos_constraints *c,struct plist_node *node, +enum pm_qos_req_action action,int value);The action for
update_targetbetter damn well be "PM_QOS_UPDATE_REQ" or there is something strange going on.... BTW what shold this function do if thepm_qos_req_actionwas *not* the UPDATE one?
Quoted 5 lines
The meaning of
pm_qos_update_targetis 'update the PM QoS target constraints lists'. As described in the changelog the intention of this patch is to implement the constraints lists management logic inupdate_targetand simplify the API functions (add/update/remove). It is also exported for the upcoming (patch 06/15]) to use it as well.
The enums are fine by me and they allow us to simplify the code quite a bit.
Thanks,
Rafael
Re: [PATCH 06/15] PM QoS: implement the per-device PM QoS constraints
In reply to Jean PihetHi,
On Sunday, August 14, 2011, Jean Pihet wrote:
...
Quoted 29 lines
Quoted 14 lines
drivers/base/power/qos.c line 79
Quoted 11 lines
drivers/base/power/qos.c new file +11
-0+ +if (dev_pm_qos_request_active (req)) { +WARN (1 ,KERN_ERR "dev_pm_qos_add_request() called for already " +"added request\n" ); +return ; + } + req->dev = dev; + +/* Allocate the constraints struct on the first call to add_request */ +if (req->dev->power.constraints_state ==DEV_PM_QOS_DEVICE_PRESENT ) +dev_pm_qos_constraints_allocate (dev);Why not to do
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (!req->dev->power.constraints) + dev_pm_qos_constraints_allocate(dev);Cf. my comments at the end of this message for the data structs alloc/free and the locking.
Quoted 9 lines
drivers/base/power/qos.c line 84
Quoted 6 lines
drivers/base/power/qos.c new file +5
-0+ +/* Silently return if the device has been removed */ +if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return ; +Hmm. What will happen if two callers run
dev_pm_qos_add_request()concurrently for the same device?
Quoted 1 line
update_targetis using the power.lock to protect the constraints lists changes.
I was referring to the scenario in particular:
Suppose that there are no constraits for dev initially. A -> calls dev_pm_qos_add_request(dev)
B -> calls dev_pm_qos_add_request(dev)
A -> sees power.constraints_state == DEV_PM_QOS_DEVICE_PRESENT
and calls dev_pm_qos_constraints_allocate(dev)
B -> sees power.constraints_state == DEV_PM_QOS_DEVICE_PRESENT
and calls dev_pm_qos_constraints_allocate(dev)
As a result, the structure allocated by A is leaked.
...
Quoted 6 lines
Your remarks are inline with the concerns I had about the adata structs alloc/free and the locking.
1) data structs alloc/free
As described in the changelog:
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
To minimize the data usage by the per-device constraints, the data struct is only allocated at the first call to
dev_pm_qos_add_request. The data is later free'd when the device is removed from the system.A basic state machine is needed in order to allocate the data at the first call to
add_requestand free it when the device is removed. Another option is to allocate the data when the device is added to the system and free it when the device is removed. That would make the code simpler but it is using a lot of memory for unneeded data.
That's fine. You simply need to be more careful about the possible race conditions when the constraints objects are created and destroyed.
Quoted 5 lines
2) Race conditions
I will add a lock to isolate the API callers fromdev_pm_qos_constraints_destroy().
The power.lock is already used byupdate_targetso another lock is needed to protect the data allocation/free.
OK
Quoted 2 lines
I will rework this tomorrow and re-submit asap when it is ready. Is that OK?
Yes, it is.
Thanks,
Rafael
Re: [PATCH 06/15] PM QoS: implement the per-device PM QoS constraints
In reply to Jean PihetHi,
On Sunday, August 14, 2011, Jean Pihet wrote:
...
Quoted 29 lines
Quoted 14 lines
drivers/base/power/qos.c line 79
Quoted 11 lines
drivers/base/power/qos.c new file +11
-0+ +if (dev_pm_qos_request_active (req)) { +WARN (1 ,KERN_ERR "dev_pm_qos_add_request() called for already " +"added request\n" ); +return ; + } + req->dev = dev; + +/* Allocate the constraints struct on the first call to add_request */ +if (req->dev->power.constraints_state ==DEV_PM_QOS_DEVICE_PRESENT ) +dev_pm_qos_constraints_allocate (dev);Why not to do
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (!req->dev->power.constraints) + dev_pm_qos_constraints_allocate(dev);Cf. my comments at the end of this message for the data structs alloc/free and the locking.
Quoted 9 lines
drivers/base/power/qos.c line 84
Quoted 6 lines
drivers/base/power/qos.c new file +5
-0+ +/* Silently return if the device has been removed */ +if (req->dev->power.constraints_state !=DEV_PM_QOS_ALLOCATED ) +return ; +Hmm. What will happen if two callers run
dev_pm_qos_add_request()concurrently for the same device?
Quoted 1 line
update_targetis using the power.lock to protect the constraints lists changes.
I was referring to the scenario in particular:
Suppose that there are no constraits for dev initially. A -> calls dev_pm_qos_add_request(dev)
B -> calls dev_pm_qos_add_request(dev)
A -> sees power.constraints_state == DEV_PM_QOS_DEVICE_PRESENT
and calls dev_pm_qos_constraints_allocate(dev)
B -> sees power.constraints_state == DEV_PM_QOS_DEVICE_PRESENT
and calls dev_pm_qos_constraints_allocate(dev)
As a result, the structure allocated by A is leaked.
...
Quoted 6 lines
Your remarks are inline with the concerns I had about the adata structs alloc/free and the locking.
1) data structs alloc/free
As described in the changelog:
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
To minimize the data usage by the per-device constraints, the data struct is only allocated at the first call to
dev_pm_qos_add_request. The data is later free'd when the device is removed from the system.A basic state machine is needed in order to allocate the data at the first call to
add_requestand free it when the device is removed. Another option is to allocate the data when the device is added to the system and free it when the device is removed. That would make the code simpler but it is using a lot of memory for unneeded data.
That's fine. You simply need to be more careful about the possible race conditions when the constraints objects are created and destroyed.
Quoted 5 lines
2) Race conditions
I will add a lock to isolate the API callers fromdev_pm_qos_constraints_destroy().
The power.lock is already used byupdate_targetso another lock is needed to protect the data allocation/free.
OK
Quoted 2 lines
I will rework this tomorrow and re-submit asap when it is ready. Is that OK?
Yes, it is.
Thanks,
Rafael
Quoted 82 lines · Jean Pihet
Rafael,
Quoted 79 lines · Rafael J. Wysocki
Hi,
Quoted 59 lines · Jean Pihet
Hi Rafael,
2011/8/12 Rafael J. Wysocki <[email protected]>:
Quoted 5 lines · On Thursday, August 11, 2011, [email protected] wrote:
Quoted 4 lines
From: Jean Pihet <[email protected]>
This patch set is in an RFC state, for review and comments.
...
Quoted 22 lines
Quoted 22 lines
Questions:
1. the user space API is still under discussions on linux-omap and linux-pm MLs, cf. [1]. The idea is to add a user-space API for the devices constratins PM QoS, using a sysfs entry per device[1] http://marc.info/?l=linux-omap&m=131232344503327&w=2
ToDo:
1. write Documentation for the new PM QoS class, once the RFC is agreed on
2. validate the constraints framework on OMAP4 HW (done on OMAP3)
3. Need testing on platforms other than OMAP
4. refine the power domains wake-up latency and the cpuidle figures
5. re-visit the OMAP power domains states initialization procedure. Currently the power states that have been changed from the constraints API which were applied before the initialization of the power domains are lostBased on the master branch of the linux-omap git tree (3.0.0-rc7). Compile tested using OMAP and x86 generic defconfigs.
Quoted 6 lines
Quoted 3 lines
Lightly tested on OMAP3 Beagleboard (ES2.x).
Need testing on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/removeThe patchset looks really good to me, I don't think I have any major complaints about this version.
Ok good to hear it! I tried to address all comments and concerns in this release.
Quoted 5 lines
The only thing I'd like to ask at the moment is whether or not the compilation of
drivers/base/power/qos.cshould depend onCONFIG_PM_RUNTIME. Do you think it will be used by system suspend code on any platforms?I would say it should only depend on
CONFIG_PMbecause the dev PM QoS API can be used from any kernel code, being runtime PM code or not. I leave the decision to the PM framework experts.Quoted 2 lines
Also, I'd like to take the final patchset for 3.2,
Ok good!
Quoted 2 lines
but I don't feel
confident enough about the OMAP patches.The OMAP patches have been reviewed a few times already and the comments have been taken into account. Also i has been tested correctly on OMAP3.
Quoted 6 lines
Quoted 2 lines
If you want me to take them too,
please make sure they are ACKed by the OMAP maintainers.For sure I need the Acks. I guess I now need to annoy OMAP folks about it ;p In the case the Acks are not gathered on time the generic patches could be merged in, then the OMAP generic code. Do you think it is a viable option?
Yes, it is. I can take patches [1-7/15] alone.
Quoted 8 lines
The only concern I have is about the on-going OMAP PM initialization clean-up task, cf. ToDo list:
Quoted 1 line
Quoted 1 line
5. re-visit the OMAP power domains states initialization
procedure. Currently
Quoted 1 line
Quoted 1 line
the power states that have been changed from the constraints
API which were
Quoted 1 line
Quoted 1 line
applied before the initialization of the power domains are lost
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
On the other hand some testing is needed on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/remove functions. I tested the SD card insertion/removal on OMAP3.
OK, so are you going to make any more changes to patches [1-7/15]?
I am now reworking [06/15] after your comments.
Is that OK timewise?
It should be fine. I still need to have a closer look at [7/15] later today, I'll let you know if there's anything I'd like to change in there.
Thanks,
Rafael
Quoted 82 lines · Jean Pihet
Rafael,
Quoted 79 lines · Rafael J. Wysocki
Hi,
Quoted 59 lines · Jean Pihet
Hi Rafael,
2011/8/12 Rafael J. Wysocki <[email protected]>:
Quoted 5 lines · On Thursday, August 11, 2011, [email protected] wrote:
Quoted 4 lines
From: Jean Pihet <[email protected]>
This patch set is in an RFC state, for review and comments.
...
Quoted 22 lines
Quoted 22 lines
Questions:
1. the user space API is still under discussions on linux-omap and linux-pm MLs, cf. [1]. The idea is to add a user-space API for the devices constratins PM QoS, using a sysfs entry per device[1] http://marc.info/?l=linux-omap&m=131232344503327&w=2
ToDo:
1. write Documentation for the new PM QoS class, once the RFC is agreed on
2. validate the constraints framework on OMAP4 HW (done on OMAP3)
3. Need testing on platforms other than OMAP
4. refine the power domains wake-up latency and the cpuidle figures
5. re-visit the OMAP power domains states initialization procedure. Currently the power states that have been changed from the constraints API which were applied before the initialization of the power domains are lostBased on the master branch of the linux-omap git tree (3.0.0-rc7). Compile tested using OMAP and x86 generic defconfigs.
Quoted 6 lines
Quoted 3 lines
Lightly tested on OMAP3 Beagleboard (ES2.x).
Need testing on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/removeThe patchset looks really good to me, I don't think I have any major complaints about this version.
Ok good to hear it! I tried to address all comments and concerns in this release.
Quoted 5 lines
The only thing I'd like to ask at the moment is whether or not the compilation of
drivers/base/power/qos.cshould depend onCONFIG_PM_RUNTIME. Do you think it will be used by system suspend code on any platforms?I would say it should only depend on
CONFIG_PMbecause the dev PM QoS API can be used from any kernel code, being runtime PM code or not. I leave the decision to the PM framework experts.Quoted 2 lines
Also, I'd like to take the final patchset for 3.2,
Ok good!
Quoted 2 lines
but I don't feel
confident enough about the OMAP patches.The OMAP patches have been reviewed a few times already and the comments have been taken into account. Also i has been tested correctly on OMAP3.
Quoted 6 lines
Quoted 2 lines
If you want me to take them too,
please make sure they are ACKed by the OMAP maintainers.For sure I need the Acks. I guess I now need to annoy OMAP folks about it ;p In the case the Acks are not gathered on time the generic patches could be merged in, then the OMAP generic code. Do you think it is a viable option?
Yes, it is. I can take patches [1-7/15] alone.
Quoted 8 lines
The only concern I have is about the on-going OMAP PM initialization clean-up task, cf. ToDo list:
Quoted 1 line
Quoted 1 line
5. re-visit the OMAP power domains states initialization
procedure. Currently
Quoted 1 line
Quoted 1 line
the power states that have been changed from the constraints
API which were
Quoted 1 line
Quoted 1 line
applied before the initialization of the power domains are lost
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
On the other hand some testing is needed on platforms other than OMAP, because of the impact on the device insertion/removal in device_pm_add/remove functions. I tested the SD card insertion/removal on OMAP3.
OK, so are you going to make any more changes to patches [1-7/15]?
I am now reworking [06/15] after your comments.
Is that OK timewise?
It should be fine. I still need to have a closer look at [7/15] later today, I'll let you know if there's anything I'd like to change in there.
Thanks,
Rafael