.. | .. |
---|
11 | 11 | #include <linux/cpu.h> |
---|
12 | 12 | #include <linux/cpuidle.h> |
---|
13 | 13 | #include <linux/mutex.h> |
---|
| 14 | +#include <linux/module.h> |
---|
14 | 15 | #include <linux/pm_qos.h> |
---|
15 | 16 | |
---|
16 | 17 | #include "cpuidle.h" |
---|
17 | 18 | |
---|
| 19 | +char param_governor[CPUIDLE_NAME_LEN]; |
---|
| 20 | + |
---|
18 | 21 | LIST_HEAD(cpuidle_governors); |
---|
19 | 22 | struct cpuidle_governor *cpuidle_curr_governor; |
---|
| 23 | +struct cpuidle_governor *cpuidle_prev_governor; |
---|
20 | 24 | |
---|
21 | 25 | /** |
---|
22 | | - * __cpuidle_find_governor - finds a governor of the specified name |
---|
| 26 | + * cpuidle_find_governor - finds a governor of the specified name |
---|
23 | 27 | * @str: the name |
---|
24 | 28 | * |
---|
25 | 29 | * Must be called with cpuidle_lock acquired. |
---|
26 | 30 | */ |
---|
27 | | -static struct cpuidle_governor * __cpuidle_find_governor(const char *str) |
---|
| 31 | +struct cpuidle_governor *cpuidle_find_governor(const char *str) |
---|
28 | 32 | { |
---|
29 | 33 | struct cpuidle_governor *gov; |
---|
30 | 34 | |
---|
.. | .. |
---|
84 | 88 | return -ENODEV; |
---|
85 | 89 | |
---|
86 | 90 | mutex_lock(&cpuidle_lock); |
---|
87 | | - if (__cpuidle_find_governor(gov->name) == NULL) { |
---|
| 91 | + if (cpuidle_find_governor(gov->name) == NULL) { |
---|
88 | 92 | ret = 0; |
---|
89 | 93 | list_add_tail(&gov->governor_list, &cpuidle_governors); |
---|
90 | 94 | if (!cpuidle_curr_governor || |
---|
91 | | - cpuidle_curr_governor->rating < gov->rating) |
---|
| 95 | + !strncasecmp(param_governor, gov->name, CPUIDLE_NAME_LEN) || |
---|
| 96 | + (cpuidle_curr_governor->rating < gov->rating && |
---|
| 97 | + strncasecmp(param_governor, cpuidle_curr_governor->name, |
---|
| 98 | + CPUIDLE_NAME_LEN))) |
---|
92 | 99 | cpuidle_switch_governor(gov); |
---|
93 | 100 | } |
---|
94 | 101 | mutex_unlock(&cpuidle_lock); |
---|
.. | .. |
---|
101 | 108 | * cpuidle_governor_latency_req - Compute a latency constraint for CPU |
---|
102 | 109 | * @cpu: Target CPU |
---|
103 | 110 | */ |
---|
104 | | -int cpuidle_governor_latency_req(unsigned int cpu) |
---|
| 111 | +s64 cpuidle_governor_latency_req(unsigned int cpu) |
---|
105 | 112 | { |
---|
106 | | - int global_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY); |
---|
107 | 113 | struct device *device = get_cpu_device(cpu); |
---|
108 | | - int device_req = dev_pm_qos_raw_read_value(device); |
---|
| 114 | + int device_req = dev_pm_qos_raw_resume_latency(device); |
---|
| 115 | + int global_req = cpu_latency_qos_limit(); |
---|
109 | 116 | |
---|
110 | | - return device_req < global_req ? device_req : global_req; |
---|
| 117 | + if (device_req > global_req) |
---|
| 118 | + device_req = global_req; |
---|
| 119 | + |
---|
| 120 | + return (s64)device_req * NSEC_PER_USEC; |
---|
111 | 121 | } |
---|
| 122 | +EXPORT_SYMBOL_GPL(cpuidle_governor_latency_req); |
---|