summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorJean Pihet <j-pihet@ti.com>2011-08-25 17:35:41 +0400
committerRafael J. Wysocki <rjw@sisk.pl>2011-08-25 17:35:41 +0400
commit91ff4cb803df6de9114351b9f2f0f39f397ee03e (patch)
treeeb24c7df28d0f93557ac1d9e7d72a79fc3556b97 /include/linux
parentabe98ec2d86279fe821c9051003a0abc43444f15 (diff)
downloadlinux-91ff4cb803df6de9114351b9f2f0f39f397ee03e.tar.xz
PM QoS: Implement per-device PM QoS constraints
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. A global mutex protects the constraints users from the data being allocated and free'd. Signed-off-by: Jean Pihet <j-pihet@ti.com> Reviewed-by: Kevin Hilman <khilman@ti.com> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/pm.h9
-rw-r--r--include/linux/pm_qos.h42
2 files changed, 51 insertions, 0 deletions
diff --git a/include/linux/pm.h b/include/linux/pm.h
index ed10f24d5259..d78187e9ca99 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -419,6 +419,13 @@ enum rpm_request {
RPM_REQ_RESUME,
};
+/* 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 wakeup_source;
struct pm_domain_data {
@@ -480,6 +487,8 @@ struct dev_pm_info {
unsigned long accounting_timestamp;
#endif
struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */
+ struct pm_qos_constraints *constraints;
+ enum dev_pm_qos_state constraints_state;
};
extern void update_pm_runtime_accounting(struct device *dev);
diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h
index 84aa15089896..f75f74dd9b90 100644
--- a/include/linux/pm_qos.h
+++ b/include/linux/pm_qos.h
@@ -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 0
struct 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 */
@@ -51,6 +57,11 @@ enum pm_qos_req_action {
PM_QOS_REMOVE_REQ /* Remove an existing request */
};
+static inline int dev_pm_qos_request_active(struct dev_pm_qos_request *req)
+{
+ return req->dev != 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);
@@ -64,6 +75,17 @@ 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_add_request(struct device *dev, struct dev_pm_qos_request *req,
+ s32 value);
+int dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value);
+int 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 +111,26 @@ 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_add_request(struct device *dev,
+ struct dev_pm_qos_request *req,
+ s32 value)
+ { return 0; }
+static inline int dev_pm_qos_update_request(struct dev_pm_qos_request *req,
+ s32 new_value)
+ { return 0; }
+static inline int dev_pm_qos_remove_request(struct dev_pm_qos_request *req)
+ { return 0; }
+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