.. | .. |
---|
56 | 56 | { |
---|
57 | 57 | acpi_status status = 0; |
---|
58 | 58 | unsigned long long ppc = 0; |
---|
| 59 | + s32 qos_value; |
---|
| 60 | + int index; |
---|
59 | 61 | int ret; |
---|
60 | 62 | |
---|
61 | 63 | if (!pr) |
---|
.. | .. |
---|
75 | 77 | return -ENODEV; |
---|
76 | 78 | } |
---|
77 | 79 | |
---|
78 | | - pr_debug("CPU %d: _PPC is %d - frequency %s limited\n", pr->id, |
---|
79 | | - (int)ppc, ppc ? "" : "not"); |
---|
| 80 | + index = ppc; |
---|
80 | 81 | |
---|
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) |
---|
85 | 84 | return 0; |
---|
86 | 85 | |
---|
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); |
---|
89 | 104 | if (ret < 0) { |
---|
90 | 105 | pr_warn("Failed to update perflib freq constraint: CPU%d (%d)\n", |
---|
91 | 106 | pr->id, ret); |
---|
.. | .. |
---|
168 | 183 | if (!pr) |
---|
169 | 184 | continue; |
---|
170 | 185 | |
---|
| 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 | + |
---|
171 | 193 | 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); |
---|
174 | 196 | if (ret < 0) |
---|
175 | 197 | pr_err("Failed to add freq constraint for CPU%d (%d)\n", |
---|
176 | 198 | cpu, ret); |
---|