Re: [PATCH 5/7] PM / QoS: Make it possible to expose PM QoS device flags to user space
On Mon, Oct 08, 2012 at 10:07:58AM +0200, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Define two device PM QoS flags, PM_QOS_FLAG_NO_POWER_OFF > and PM_QOS_FLAG_REMOTE_WAKEUP, and introduce routines > dev_pm_qos_expose_flags() and dev_pm_qos_hide_flags() allowing the > caller to expose those two flags to user space or to hide them > from it, respectively. > > After the flags have been exposed, user space will see two > additional sysfs attributes, pm_qos_no_power_off and > pm_qos_remote_wakeup, under the device's /sys/devices/.../power/ > directory. Then, writing 1 to one of them will update the > PM QoS flags request owned by user space so that the corresponding > flag is requested to be set. In turn, writing 0 to one of them > will cause the corresponding flag in the user space's request to > be cleared (however, the owners of the other PM QoS flags requests > for the same device may still request the flag to be set and it > may be effectively set even if user space doesn't request that). > > Signed-off-by: Rafael J. Wysocki > Reviewed-by: Jean Pihet > --- > Documentation/ABI/testing/sysfs-devices-power | 31 > drivers/base/power/power.h|6 > drivers/base/power/qos.c | 167 > -- > drivers/base/power/sysfs.c| 95 +- > include/linux/pm.h|1 > include/linux/pm_qos.h| 26 > 6 files changed, 278 insertions(+), 48 deletions(-) > > Index: linux/include/linux/pm_qos.h > === > --- linux.orig/include/linux/pm_qos.h > +++ linux/include/linux/pm_qos.h > @@ -34,6 +34,9 @@ enum pm_qos_flags_status { > #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 > #define PM_QOS_DEV_LAT_DEFAULT_VALUE 0 > > +#define PM_QOS_FLAG_NO_POWER_OFF (1 << 0) > +#define PM_QOS_FLAG_REMOTE_WAKEUP(1 << 1) > + > struct pm_qos_request { > struct plist_node node; > int pm_qos_class; > @@ -86,6 +89,8 @@ struct pm_qos_flags { > struct dev_pm_qos { > struct pm_qos_constraints latency; > struct pm_qos_flags flags; > + struct dev_pm_qos_request *latency_req; > + struct dev_pm_qos_request *flags_req; I think I'm getting it now. if someday we have per device throughput you would have us add a pm_qos_constraints throughput; and a dev_pm_qos_request *throughput_req; > }; > > /* Action requested to pm_qos_update_target */ > @@ -187,10 +192,31 @@ static inline int dev_pm_qos_add_ancesto > #ifdef CONFIG_PM_RUNTIME > int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value); > void dev_pm_qos_hide_latency_limit(struct device *dev); > +int dev_pm_qos_expose_flags(struct device *dev, s32 value); > +void dev_pm_qos_hide_flags(struct device *dev); > +int dev_pm_qos_update_flags(struct device *dev, s32 mask, bool set); > + > +static inline s32 dev_pm_qos_requested_latency(struct device *dev) > +{ > + return dev->power.qos->latency_req->data.pnode.prio; > +} > + > +static inline s32 dev_pm_qos_requested_flags(struct device *dev) > +{ > + return dev->power.qos->flags_req->data.flr.flags; > +} > #else > static inline int dev_pm_qos_expose_latency_limit(struct device *dev, s32 > value) > { return 0; } > static inline void dev_pm_qos_hide_latency_limit(struct device *dev) {} > +static inline int dev_pm_qos_expose_flags(struct device *dev, s32 value) > + { return 0; } > +static inline void dev_pm_qos_hide_flags(struct device *dev) {} > +static inline int dev_pm_qos_update_flags(struct device *dev, s32 m, bool > set) > + { return 0; } > + > +static inline s32 dev_pm_qos_requested_latency(struct device *dev) { return > 0; } > +static inline s32 dev_pm_qos_requested_flags(struct device *dev) { return 0; > } > #endif > > #endif > Index: linux/include/linux/pm.h > === > --- linux.orig/include/linux/pm.h > +++ linux/include/linux/pm.h > @@ -548,7 +548,6 @@ struct dev_pm_info { > unsigned long active_jiffies; > unsigned long suspended_jiffies; > unsigned long accounting_timestamp; > - struct dev_pm_qos_request *pq_req; > #endif > struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */ > struct dev_pm_qos *qos; > Index: linux/drivers/base/power/qos.c > === > --- linux.orig/drivers/base/power/qos.c > +++ linux/drivers/base/power/qos.c > @@ -40,6 +40,7 @@ > #include > #include > #include > +#include > > #include "power.h" > > @@ -322,6 +323,36 @@ int dev_pm_qos_add_request(struct device > EXPORT_SYMBOL_GPL(dev_pm_qos_add_request); > > /** > + * __dev_pm_qos_update_request - Modify an existing device PM QoS request. > + * @req : PM QoS
Re: [PATCH 5/7] PM / QoS: Make it possible to expose PM QoS device flags to user space
On Mon, Oct 08, 2012 at 10:07:58AM +0200, Rafael J. Wysocki wrote: From: Rafael J. Wysocki rafael.j.wyso...@intel.com Define two device PM QoS flags, PM_QOS_FLAG_NO_POWER_OFF and PM_QOS_FLAG_REMOTE_WAKEUP, and introduce routines dev_pm_qos_expose_flags() and dev_pm_qos_hide_flags() allowing the caller to expose those two flags to user space or to hide them from it, respectively. After the flags have been exposed, user space will see two additional sysfs attributes, pm_qos_no_power_off and pm_qos_remote_wakeup, under the device's /sys/devices/.../power/ directory. Then, writing 1 to one of them will update the PM QoS flags request owned by user space so that the corresponding flag is requested to be set. In turn, writing 0 to one of them will cause the corresponding flag in the user space's request to be cleared (however, the owners of the other PM QoS flags requests for the same device may still request the flag to be set and it may be effectively set even if user space doesn't request that). Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com Reviewed-by: Jean Pihet j-pi...@ti.com --- Documentation/ABI/testing/sysfs-devices-power | 31 drivers/base/power/power.h|6 drivers/base/power/qos.c | 167 -- drivers/base/power/sysfs.c| 95 +- include/linux/pm.h|1 include/linux/pm_qos.h| 26 6 files changed, 278 insertions(+), 48 deletions(-) Index: linux/include/linux/pm_qos.h === --- linux.orig/include/linux/pm_qos.h +++ linux/include/linux/pm_qos.h @@ -34,6 +34,9 @@ enum pm_qos_flags_status { #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 #define PM_QOS_DEV_LAT_DEFAULT_VALUE 0 +#define PM_QOS_FLAG_NO_POWER_OFF (1 0) +#define PM_QOS_FLAG_REMOTE_WAKEUP(1 1) + struct pm_qos_request { struct plist_node node; int pm_qos_class; @@ -86,6 +89,8 @@ struct pm_qos_flags { struct dev_pm_qos { struct pm_qos_constraints latency; struct pm_qos_flags flags; + struct dev_pm_qos_request *latency_req; + struct dev_pm_qos_request *flags_req; I think I'm getting it now. if someday we have per device throughput you would have us add a pm_qos_constraints throughput; and a dev_pm_qos_request *throughput_req; }; /* Action requested to pm_qos_update_target */ @@ -187,10 +192,31 @@ static inline int dev_pm_qos_add_ancesto #ifdef CONFIG_PM_RUNTIME int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value); void dev_pm_qos_hide_latency_limit(struct device *dev); +int dev_pm_qos_expose_flags(struct device *dev, s32 value); +void dev_pm_qos_hide_flags(struct device *dev); +int dev_pm_qos_update_flags(struct device *dev, s32 mask, bool set); + +static inline s32 dev_pm_qos_requested_latency(struct device *dev) +{ + return dev-power.qos-latency_req-data.pnode.prio; +} + +static inline s32 dev_pm_qos_requested_flags(struct device *dev) +{ + return dev-power.qos-flags_req-data.flr.flags; +} #else static inline int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value) { return 0; } static inline void dev_pm_qos_hide_latency_limit(struct device *dev) {} +static inline int dev_pm_qos_expose_flags(struct device *dev, s32 value) + { return 0; } +static inline void dev_pm_qos_hide_flags(struct device *dev) {} +static inline int dev_pm_qos_update_flags(struct device *dev, s32 m, bool set) + { return 0; } + +static inline s32 dev_pm_qos_requested_latency(struct device *dev) { return 0; } +static inline s32 dev_pm_qos_requested_flags(struct device *dev) { return 0; } #endif #endif Index: linux/include/linux/pm.h === --- linux.orig/include/linux/pm.h +++ linux/include/linux/pm.h @@ -548,7 +548,6 @@ struct dev_pm_info { unsigned long active_jiffies; unsigned long suspended_jiffies; unsigned long accounting_timestamp; - struct dev_pm_qos_request *pq_req; #endif struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */ struct dev_pm_qos *qos; Index: linux/drivers/base/power/qos.c === --- linux.orig/drivers/base/power/qos.c +++ linux/drivers/base/power/qos.c @@ -40,6 +40,7 @@ #include linux/device.h #include linux/mutex.h #include linux/export.h +#include linux/pm_runtime.h #include power.h @@ -322,6 +323,36 @@ int dev_pm_qos_add_request(struct device EXPORT_SYMBOL_GPL(dev_pm_qos_add_request); /** + * __dev_pm_qos_update_request - Modify an existing device PM QoS request. + * @req : PM QoS request to
[PATCH 5/7] PM / QoS: Make it possible to expose PM QoS device flags to user space
From: Rafael J. Wysocki Define two device PM QoS flags, PM_QOS_FLAG_NO_POWER_OFF and PM_QOS_FLAG_REMOTE_WAKEUP, and introduce routines dev_pm_qos_expose_flags() and dev_pm_qos_hide_flags() allowing the caller to expose those two flags to user space or to hide them from it, respectively. After the flags have been exposed, user space will see two additional sysfs attributes, pm_qos_no_power_off and pm_qos_remote_wakeup, under the device's /sys/devices/.../power/ directory. Then, writing 1 to one of them will update the PM QoS flags request owned by user space so that the corresponding flag is requested to be set. In turn, writing 0 to one of them will cause the corresponding flag in the user space's request to be cleared (however, the owners of the other PM QoS flags requests for the same device may still request the flag to be set and it may be effectively set even if user space doesn't request that). Signed-off-by: Rafael J. Wysocki Reviewed-by: Jean Pihet --- Documentation/ABI/testing/sysfs-devices-power | 31 drivers/base/power/power.h|6 drivers/base/power/qos.c | 167 -- drivers/base/power/sysfs.c| 95 +- include/linux/pm.h|1 include/linux/pm_qos.h| 26 6 files changed, 278 insertions(+), 48 deletions(-) Index: linux/include/linux/pm_qos.h === --- linux.orig/include/linux/pm_qos.h +++ linux/include/linux/pm_qos.h @@ -34,6 +34,9 @@ enum pm_qos_flags_status { #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE0 #define PM_QOS_DEV_LAT_DEFAULT_VALUE 0 +#define PM_QOS_FLAG_NO_POWER_OFF (1 << 0) +#define PM_QOS_FLAG_REMOTE_WAKEUP (1 << 1) + struct pm_qos_request { struct plist_node node; int pm_qos_class; @@ -86,6 +89,8 @@ struct pm_qos_flags { struct dev_pm_qos { struct pm_qos_constraints latency; struct pm_qos_flags flags; + struct dev_pm_qos_request *latency_req; + struct dev_pm_qos_request *flags_req; }; /* Action requested to pm_qos_update_target */ @@ -187,10 +192,31 @@ static inline int dev_pm_qos_add_ancesto #ifdef CONFIG_PM_RUNTIME int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value); void dev_pm_qos_hide_latency_limit(struct device *dev); +int dev_pm_qos_expose_flags(struct device *dev, s32 value); +void dev_pm_qos_hide_flags(struct device *dev); +int dev_pm_qos_update_flags(struct device *dev, s32 mask, bool set); + +static inline s32 dev_pm_qos_requested_latency(struct device *dev) +{ + return dev->power.qos->latency_req->data.pnode.prio; +} + +static inline s32 dev_pm_qos_requested_flags(struct device *dev) +{ + return dev->power.qos->flags_req->data.flr.flags; +} #else static inline int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value) { return 0; } static inline void dev_pm_qos_hide_latency_limit(struct device *dev) {} +static inline int dev_pm_qos_expose_flags(struct device *dev, s32 value) + { return 0; } +static inline void dev_pm_qos_hide_flags(struct device *dev) {} +static inline int dev_pm_qos_update_flags(struct device *dev, s32 m, bool set) + { return 0; } + +static inline s32 dev_pm_qos_requested_latency(struct device *dev) { return 0; } +static inline s32 dev_pm_qos_requested_flags(struct device *dev) { return 0; } #endif #endif Index: linux/include/linux/pm.h === --- linux.orig/include/linux/pm.h +++ linux/include/linux/pm.h @@ -548,7 +548,6 @@ struct dev_pm_info { unsigned long active_jiffies; unsigned long suspended_jiffies; unsigned long accounting_timestamp; - struct dev_pm_qos_request *pq_req; #endif struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */ struct dev_pm_qos *qos; Index: linux/drivers/base/power/qos.c === --- linux.orig/drivers/base/power/qos.c +++ linux/drivers/base/power/qos.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "power.h" @@ -322,6 +323,36 @@ int dev_pm_qos_add_request(struct device EXPORT_SYMBOL_GPL(dev_pm_qos_add_request); /** + * __dev_pm_qos_update_request - Modify an existing device PM QoS request. + * @req : PM QoS request to modify. + * @new_value: New value to request. + */ +int __dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value) +{ + s32 curr_value; + int ret = 0; + + if (!req->dev->power.qos) + return -ENODEV; + + switch(req->type) { + case DEV_PM_QOS_LATENCY: + curr_value = req->data.pnode.prio; + break; + case DEV_PM_QOS_FLAGS: +
[PATCH 5/7] PM / QoS: Make it possible to expose PM QoS device flags to user space
From: Rafael J. Wysocki rafael.j.wyso...@intel.com Define two device PM QoS flags, PM_QOS_FLAG_NO_POWER_OFF and PM_QOS_FLAG_REMOTE_WAKEUP, and introduce routines dev_pm_qos_expose_flags() and dev_pm_qos_hide_flags() allowing the caller to expose those two flags to user space or to hide them from it, respectively. After the flags have been exposed, user space will see two additional sysfs attributes, pm_qos_no_power_off and pm_qos_remote_wakeup, under the device's /sys/devices/.../power/ directory. Then, writing 1 to one of them will update the PM QoS flags request owned by user space so that the corresponding flag is requested to be set. In turn, writing 0 to one of them will cause the corresponding flag in the user space's request to be cleared (however, the owners of the other PM QoS flags requests for the same device may still request the flag to be set and it may be effectively set even if user space doesn't request that). Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com Reviewed-by: Jean Pihet j-pi...@ti.com --- Documentation/ABI/testing/sysfs-devices-power | 31 drivers/base/power/power.h|6 drivers/base/power/qos.c | 167 -- drivers/base/power/sysfs.c| 95 +- include/linux/pm.h|1 include/linux/pm_qos.h| 26 6 files changed, 278 insertions(+), 48 deletions(-) Index: linux/include/linux/pm_qos.h === --- linux.orig/include/linux/pm_qos.h +++ linux/include/linux/pm_qos.h @@ -34,6 +34,9 @@ enum pm_qos_flags_status { #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE0 #define PM_QOS_DEV_LAT_DEFAULT_VALUE 0 +#define PM_QOS_FLAG_NO_POWER_OFF (1 0) +#define PM_QOS_FLAG_REMOTE_WAKEUP (1 1) + struct pm_qos_request { struct plist_node node; int pm_qos_class; @@ -86,6 +89,8 @@ struct pm_qos_flags { struct dev_pm_qos { struct pm_qos_constraints latency; struct pm_qos_flags flags; + struct dev_pm_qos_request *latency_req; + struct dev_pm_qos_request *flags_req; }; /* Action requested to pm_qos_update_target */ @@ -187,10 +192,31 @@ static inline int dev_pm_qos_add_ancesto #ifdef CONFIG_PM_RUNTIME int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value); void dev_pm_qos_hide_latency_limit(struct device *dev); +int dev_pm_qos_expose_flags(struct device *dev, s32 value); +void dev_pm_qos_hide_flags(struct device *dev); +int dev_pm_qos_update_flags(struct device *dev, s32 mask, bool set); + +static inline s32 dev_pm_qos_requested_latency(struct device *dev) +{ + return dev-power.qos-latency_req-data.pnode.prio; +} + +static inline s32 dev_pm_qos_requested_flags(struct device *dev) +{ + return dev-power.qos-flags_req-data.flr.flags; +} #else static inline int dev_pm_qos_expose_latency_limit(struct device *dev, s32 value) { return 0; } static inline void dev_pm_qos_hide_latency_limit(struct device *dev) {} +static inline int dev_pm_qos_expose_flags(struct device *dev, s32 value) + { return 0; } +static inline void dev_pm_qos_hide_flags(struct device *dev) {} +static inline int dev_pm_qos_update_flags(struct device *dev, s32 m, bool set) + { return 0; } + +static inline s32 dev_pm_qos_requested_latency(struct device *dev) { return 0; } +static inline s32 dev_pm_qos_requested_flags(struct device *dev) { return 0; } #endif #endif Index: linux/include/linux/pm.h === --- linux.orig/include/linux/pm.h +++ linux/include/linux/pm.h @@ -548,7 +548,6 @@ struct dev_pm_info { unsigned long active_jiffies; unsigned long suspended_jiffies; unsigned long accounting_timestamp; - struct dev_pm_qos_request *pq_req; #endif struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */ struct dev_pm_qos *qos; Index: linux/drivers/base/power/qos.c === --- linux.orig/drivers/base/power/qos.c +++ linux/drivers/base/power/qos.c @@ -40,6 +40,7 @@ #include linux/device.h #include linux/mutex.h #include linux/export.h +#include linux/pm_runtime.h #include power.h @@ -322,6 +323,36 @@ int dev_pm_qos_add_request(struct device EXPORT_SYMBOL_GPL(dev_pm_qos_add_request); /** + * __dev_pm_qos_update_request - Modify an existing device PM QoS request. + * @req : PM QoS request to modify. + * @new_value: New value to request. + */ +int __dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value) +{ + s32 curr_value; + int ret = 0; + + if (!req-dev-power.qos) + return -ENODEV; + + switch(req-type) { + case DEV_PM_QOS_LATENCY: +