hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/acpi/processor_perflib.c
....@@ -56,6 +56,8 @@
5656 {
5757 acpi_status status = 0;
5858 unsigned long long ppc = 0;
59
+ s32 qos_value;
60
+ int index;
5961 int ret;
6062
6163 if (!pr)
....@@ -75,17 +77,30 @@
7577 return -ENODEV;
7678 }
7779
78
- pr_debug("CPU %d: _PPC is %d - frequency %s limited\n", pr->id,
79
- (int)ppc, ppc ? "" : "not");
80
+ index = ppc;
8081
81
- pr->performance_platform_limit = (int)ppc;
82
-
83
- if (ppc >= pr->performance->state_count ||
84
- unlikely(!freq_qos_request_active(&pr->perflib_req)))
82
+ if (pr->performance_platform_limit == index ||
83
+ ppc >= pr->performance->state_count)
8584 return 0;
8685
87
- ret = freq_qos_update_request(&pr->perflib_req,
88
- pr->performance->states[ppc].core_frequency * 1000);
86
+ pr_debug("CPU %d: _PPC is %d - frequency %s limited\n", pr->id,
87
+ index, index ? "is" : "is not");
88
+
89
+ pr->performance_platform_limit = index;
90
+
91
+ if (unlikely(!freq_qos_request_active(&pr->perflib_req)))
92
+ return 0;
93
+
94
+ /*
95
+ * If _PPC returns 0, it means that all of the available states can be
96
+ * used ("no limit").
97
+ */
98
+ if (index == 0)
99
+ qos_value = FREQ_QOS_MAX_DEFAULT_VALUE;
100
+ else
101
+ qos_value = pr->performance->states[index].core_frequency * 1000;
102
+
103
+ ret = freq_qos_update_request(&pr->perflib_req, qos_value);
89104 if (ret < 0) {
90105 pr_warn("Failed to update perflib freq constraint: CPU%d (%d)\n",
91106 pr->id, ret);
....@@ -168,9 +183,16 @@
168183 if (!pr)
169184 continue;
170185
186
+ /*
187
+ * Reset performance_platform_limit in case there is a stale
188
+ * value in it, so as to make it match the "no limit" QoS value
189
+ * below.
190
+ */
191
+ pr->performance_platform_limit = 0;
192
+
171193 ret = freq_qos_add_request(&policy->constraints,
172
- &pr->perflib_req,
173
- FREQ_QOS_MAX, INT_MAX);
194
+ &pr->perflib_req, FREQ_QOS_MAX,
195
+ FREQ_QOS_MAX_DEFAULT_VALUE);
174196 if (ret < 0)
175197 pr_err("Failed to add freq constraint for CPU%d (%d)\n",
176198 cpu, ret);