Skip to content

Commit 7990da7

Browse files
tomeuvrafaeljw
authored andcommitted
PM / QoS: Add PM_QOS_MEMORY_BANDWIDTH class
Also adds a class type PM_QOS_SUM that aggregates the values by summing them. It can be used by memory controllers to calculate the optimum clock frequency based on the bandwidth needs of the different memory clients. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 0f33be0 commit 7990da7

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

‎Documentation/power/pm_qos_interface.txt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ performance expectations by drivers, subsystems and user space applications on
55
one of the parameters.
66

77
Two different PM QoS frameworks are available:
8-
1. PM QoS classes for cpu_dma_latency, network_latency, network_throughput.
8+
1. PM QoS classes for cpu_dma_latency, network_latency, network_throughput,
9+
memory_bandwidth.
910
2. the per-device PM QoS framework provides the API to manage the per-device latency
1011
constraints and PM QoS flags.
1112

1213
Each parameters have defined units:
1314
* latency: usec
1415
* timeout: usec
1516
* throughput: kbs (kilo bit / sec)
17+
* memory bandwidth: mbs (mega bit / sec)
1618

1719

1820
1. PM QoS framework

‎include/linux/pm_qos.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ enum {
1515
PM_QOS_CPU_DMA_LATENCY,
1616
PM_QOS_NETWORK_LATENCY,
1717
PM_QOS_NETWORK_THROUGHPUT,
18+
PM_QOS_MEMORY_BANDWIDTH,
1819

1920
/* insert new class ID */
2021
PM_QOS_NUM_CLASSES,
@@ -32,6 +33,7 @@ enum pm_qos_flags_status {
3233
#define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
3334
#define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
3435
#define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0
36+
#define PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE 0
3537
#define PM_QOS_RESUME_LATENCY_DEFAULT_VALUE 0
3638
#define PM_QOS_LATENCY_TOLERANCE_DEFAULT_VALUE 0
3739
#define PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT (-1)
@@ -69,7 +71,8 @@ struct dev_pm_qos_request {
6971
enum pm_qos_type {
7072
PM_QOS_UNITIALIZED,
7173
PM_QOS_MAX, /* return the largest value */
72-
PM_QOS_MIN /* return the smallest value */
74+
PM_QOS_MIN, /* return the smallest value */
75+
PM_QOS_SUM /* return the sum */
7376
};
7477

7578
/*

‎kernel/power/qos.c‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,27 @@ static struct pm_qos_object network_throughput_pm_qos = {
105105
};
106106

107107

108+
static BLOCKING_NOTIFIER_HEAD(memory_bandwidth_notifier);
109+
static struct pm_qos_constraints memory_bw_constraints = {
110+
.list = PLIST_HEAD_INIT(memory_bw_constraints.list),
111+
.target_value = PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
112+
.default_value = PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
113+
.no_constraint_value = PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE,
114+
.type = PM_QOS_SUM,
115+
.notifiers = &memory_bandwidth_notifier,
116+
};
117+
static struct pm_qos_object memory_bandwidth_pm_qos = {
118+
.constraints = &memory_bw_constraints,
119+
.name = "memory_bandwidth",
120+
};
121+
122+
108123
static struct pm_qos_object *pm_qos_array[] = {
109124
&null_pm_qos,
110125
&cpu_dma_pm_qos,
111126
&network_lat_pm_qos,
112-
&network_throughput_pm_qos
127+
&network_throughput_pm_qos,
128+
&memory_bandwidth_pm_qos,
113129
};
114130

115131
static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
@@ -130,6 +146,9 @@ static const struct file_operations pm_qos_power_fops = {
130146
/* unlocked internal variant */
131147
static inline int pm_qos_get_value(struct pm_qos_constraints *c)
132148
{
149+
struct plist_node *node;
150+
int total_value = 0;
151+
133152
if (plist_head_empty(&c->list))
134153
return c->no_constraint_value;
135154

@@ -140,6 +159,12 @@ static inline int pm_qos_get_value(struct pm_qos_constraints *c)
140159
case PM_QOS_MAX:
141160
return plist_last(&c->list)->prio;
142161

162+
case PM_QOS_SUM:
163+
plist_for_each(node, &c->list)
164+
total_value += node->prio;
165+
166+
return total_value;
167+
143168
default:
144169
/* runtime check for not using enum */
145170
BUG();

0 commit comments

Comments
 (0)