diff options
| author | Jean Pihet <j-pihet@ti.com> | 2011-08-25 09:35:41 -0400 |
|---|---|---|
| committer | Rafael J. Wysocki <rjw@sisk.pl> | 2011-08-25 09:35:41 -0400 |
| commit | 91ff4cb803df6de9114351b9f2f0f39f397ee03e (patch) | |
| tree | eb24c7df28d0f93557ac1d9e7d72a79fc3556b97 /include/linux | |
| parent | abe98ec2d86279fe821c9051003a0abc43444f15 (diff) | |
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.h | 9 | ||||
| -rw-r--r-- | include/linux/pm_qos.h | 42 |
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 { | |||
| 419 | RPM_REQ_RESUME, | 419 | RPM_REQ_RESUME, |
| 420 | }; | 420 | }; |
| 421 | 421 | ||
| 422 | /* Per-device PM QoS constraints data struct state */ | ||
| 423 | enum dev_pm_qos_state { | ||
| 424 | DEV_PM_QOS_NO_DEVICE, /* No device present */ | ||
| 425 | DEV_PM_QOS_DEVICE_PRESENT, /* Device present, data not allocated */ | ||
| 426 | DEV_PM_QOS_ALLOCATED, /* Device present, data allocated */ | ||
| 427 | }; | ||
| 428 | |||
| 422 | struct wakeup_source; | 429 | struct wakeup_source; |
| 423 | 430 | ||
| 424 | struct pm_domain_data { | 431 | struct pm_domain_data { |
| @@ -480,6 +487,8 @@ struct dev_pm_info { | |||
| 480 | unsigned long accounting_timestamp; | 487 | unsigned long accounting_timestamp; |
| 481 | #endif | 488 | #endif |
| 482 | struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */ | 489 | struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */ |
| 490 | struct pm_qos_constraints *constraints; | ||
| 491 | enum dev_pm_qos_state constraints_state; | ||
| 483 | }; | 492 | }; |
| 484 | 493 | ||
| 485 | extern void update_pm_runtime_accounting(struct device *dev); | 494 | 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 @@ | |||
| 19 | #define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) | 19 | #define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) |
| 20 | #define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) | 20 | #define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) |
| 21 | #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 | 21 | #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 |
| 22 | #define PM_QOS_DEV_LAT_DEFAULT_VALUE 0 | ||
| 22 | 23 | ||
| 23 | struct pm_qos_request { | 24 | struct pm_qos_request { |
| 24 | struct plist_node node; | 25 | struct plist_node node; |
| 25 | int pm_qos_class; | 26 | int pm_qos_class; |
| 26 | }; | 27 | }; |
| 27 | 28 | ||
| 29 | struct dev_pm_qos_request { | ||
| 30 | struct plist_node node; | ||
| 31 | struct device *dev; | ||
| 32 | }; | ||
| 33 | |||
| 28 | enum pm_qos_type { | 34 | enum pm_qos_type { |
| 29 | PM_QOS_UNITIALIZED, | 35 | PM_QOS_UNITIALIZED, |
| 30 | PM_QOS_MAX, /* return the largest value */ | 36 | PM_QOS_MAX, /* return the largest value */ |
| @@ -51,6 +57,11 @@ enum pm_qos_req_action { | |||
| 51 | PM_QOS_REMOVE_REQ /* Remove an existing request */ | 57 | PM_QOS_REMOVE_REQ /* Remove an existing request */ |
| 52 | }; | 58 | }; |
| 53 | 59 | ||
| 60 | static inline int dev_pm_qos_request_active(struct dev_pm_qos_request *req) | ||
| 61 | { | ||
| 62 | return req->dev != 0; | ||
| 63 | } | ||
| 64 | |||
| 54 | #ifdef CONFIG_PM | 65 | #ifdef CONFIG_PM |
| 55 | int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node, | 66 | int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node, |
| 56 | enum pm_qos_req_action action, int value); | 67 | enum pm_qos_req_action action, int value); |
| @@ -64,6 +75,17 @@ int pm_qos_request(int pm_qos_class); | |||
| 64 | int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier); | 75 | int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier); |
| 65 | int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier); | 76 | int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier); |
| 66 | int pm_qos_request_active(struct pm_qos_request *req); | 77 | int pm_qos_request_active(struct pm_qos_request *req); |
| 78 | |||
| 79 | int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, | ||
| 80 | s32 value); | ||
| 81 | int dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value); | ||
| 82 | int dev_pm_qos_remove_request(struct dev_pm_qos_request *req); | ||
| 83 | int dev_pm_qos_add_notifier(struct device *dev, | ||
| 84 | struct notifier_block *notifier); | ||
| 85 | int dev_pm_qos_remove_notifier(struct device *dev, | ||
| 86 | struct notifier_block *notifier); | ||
| 87 | void dev_pm_qos_constraints_init(struct device *dev); | ||
| 88 | void dev_pm_qos_constraints_destroy(struct device *dev); | ||
| 67 | #else | 89 | #else |
| 68 | static inline int pm_qos_update_target(struct pm_qos_constraints *c, | 90 | static inline int pm_qos_update_target(struct pm_qos_constraints *c, |
| 69 | struct plist_node *node, | 91 | struct plist_node *node, |
| @@ -89,6 +111,26 @@ static inline int pm_qos_remove_notifier(int pm_qos_class, | |||
| 89 | { return 0; } | 111 | { return 0; } |
| 90 | static inline int pm_qos_request_active(struct pm_qos_request *req) | 112 | static inline int pm_qos_request_active(struct pm_qos_request *req) |
| 91 | { return 0; } | 113 | { return 0; } |
| 114 | |||
| 115 | static inline int dev_pm_qos_add_request(struct device *dev, | ||
| 116 | struct dev_pm_qos_request *req, | ||
| 117 | s32 value) | ||
| 118 | { return 0; } | ||
| 119 | static inline int dev_pm_qos_update_request(struct dev_pm_qos_request *req, | ||
| 120 | s32 new_value) | ||
| 121 | { return 0; } | ||
| 122 | static inline int dev_pm_qos_remove_request(struct dev_pm_qos_request *req) | ||
| 123 | { return 0; } | ||
| 124 | static inline int dev_pm_qos_add_notifier(struct device *dev, | ||
| 125 | struct notifier_block *notifier) | ||
| 126 | { return 0; } | ||
| 127 | static inline int dev_pm_qos_remove_notifier(struct device *dev, | ||
| 128 | struct notifier_block *notifier) | ||
| 129 | { return 0; } | ||
| 130 | static inline void dev_pm_qos_constraints_init(struct device *dev) | ||
| 131 | { return; } | ||
| 132 | static inline void dev_pm_qos_constraints_destroy(struct device *dev) | ||
| 133 | { return; } | ||
| 92 | #endif | 134 | #endif |
| 93 | 135 | ||
| 94 | #endif | 136 | #endif |
