hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/cpuidle/governor.c
....@@ -11,20 +11,24 @@
1111 #include <linux/cpu.h>
1212 #include <linux/cpuidle.h>
1313 #include <linux/mutex.h>
14
+#include <linux/module.h>
1415 #include <linux/pm_qos.h>
1516
1617 #include "cpuidle.h"
1718
19
+char param_governor[CPUIDLE_NAME_LEN];
20
+
1821 LIST_HEAD(cpuidle_governors);
1922 struct cpuidle_governor *cpuidle_curr_governor;
23
+struct cpuidle_governor *cpuidle_prev_governor;
2024
2125 /**
22
- * __cpuidle_find_governor - finds a governor of the specified name
26
+ * cpuidle_find_governor - finds a governor of the specified name
2327 * @str: the name
2428 *
2529 * Must be called with cpuidle_lock acquired.
2630 */
27
-static struct cpuidle_governor * __cpuidle_find_governor(const char *str)
31
+struct cpuidle_governor *cpuidle_find_governor(const char *str)
2832 {
2933 struct cpuidle_governor *gov;
3034
....@@ -84,11 +88,14 @@
8488 return -ENODEV;
8589
8690 mutex_lock(&cpuidle_lock);
87
- if (__cpuidle_find_governor(gov->name) == NULL) {
91
+ if (cpuidle_find_governor(gov->name) == NULL) {
8892 ret = 0;
8993 list_add_tail(&gov->governor_list, &cpuidle_governors);
9094 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)))
9299 cpuidle_switch_governor(gov);
93100 }
94101 mutex_unlock(&cpuidle_lock);
....@@ -101,11 +108,15 @@
101108 * cpuidle_governor_latency_req - Compute a latency constraint for CPU
102109 * @cpu: Target CPU
103110 */
104
-int cpuidle_governor_latency_req(unsigned int cpu)
111
+s64 cpuidle_governor_latency_req(unsigned int cpu)
105112 {
106
- int global_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY);
107113 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();
109116
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;
111121 }
122
+EXPORT_SYMBOL_GPL(cpuidle_governor_latency_req);