* [PATCH] PM: QoS: Invalidate frequency QoS requests after removal
@ 2019-11-20 9:33 Rafael J. Wysocki
2019-11-20 9:38 ` Viresh Kumar
0 siblings, 1 reply; 2+ messages in thread
From: Rafael J. Wysocki @ 2019-11-20 9:33 UTC (permalink / raw)
To: Linux PM
Cc: LKML, Linux ACPI, Viresh Kumar, Doug Smythies, Leonard Crestez,
Srinivas Pandruvada
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Switching cpufreq drivers (or switching operation modes of the
intel_pstate driver from "active" to "passive" and vice versa)
does not work on some x86 systems with ACPI after commit
3000ce3c52f8 ("cpufreq: Use per-policy frequency QoS"), because
the ACPI _PPC and thermal code uses the same frequency QoS request
object for a given CPU every time a cpufreq driver is registered
and freq_qos_remove_request() does not invalidate the request after
removing it from its QoS list, so freq_qos_add_request() complains
and fails when that request is passed to it again.
Fix the issue by modifying freq_qos_remove_request() to clear the qos
and type fields of the frequency request pointed to by its argument
after removing it from its QoS list so as to invalidate it.
Fixes: 3000ce3c52f8 ("cpufreq: Use per-policy frequency QoS")
Reported-and-tested-by: Doug Smythies <dsmythies@telus.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
kernel/power/qos.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
Index: linux-pm/kernel/power/qos.c
===================================================================
--- linux-pm.orig/kernel/power/qos.c
+++ linux-pm/kernel/power/qos.c
@@ -814,6 +814,8 @@ EXPORT_SYMBOL_GPL(freq_qos_update_reques
*/
int freq_qos_remove_request(struct freq_qos_request *req)
{
+ int ret;
+
if (!req)
return -EINVAL;
@@ -821,7 +823,11 @@ int freq_qos_remove_request(struct freq_
"%s() called for unknown object\n", __func__))
return -EINVAL;
- return freq_qos_apply(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE);
+ ret = freq_qos_apply(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE);
+ req->qos = NULL;
+ req->type = 0;
+
+ return ret;
}
EXPORT_SYMBOL_GPL(freq_qos_remove_request);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] PM: QoS: Invalidate frequency QoS requests after removal
2019-11-20 9:33 [PATCH] PM: QoS: Invalidate frequency QoS requests after removal Rafael J. Wysocki
@ 2019-11-20 9:38 ` Viresh Kumar
0 siblings, 0 replies; 2+ messages in thread
From: Viresh Kumar @ 2019-11-20 9:38 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux PM, LKML, Linux ACPI, Doug Smythies, Leonard Crestez,
Srinivas Pandruvada
On 20-11-19, 10:33, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Switching cpufreq drivers (or switching operation modes of the
> intel_pstate driver from "active" to "passive" and vice versa)
> does not work on some x86 systems with ACPI after commit
> 3000ce3c52f8 ("cpufreq: Use per-policy frequency QoS"), because
> the ACPI _PPC and thermal code uses the same frequency QoS request
> object for a given CPU every time a cpufreq driver is registered
> and freq_qos_remove_request() does not invalidate the request after
> removing it from its QoS list, so freq_qos_add_request() complains
> and fails when that request is passed to it again.
>
> Fix the issue by modifying freq_qos_remove_request() to clear the qos
> and type fields of the frequency request pointed to by its argument
> after removing it from its QoS list so as to invalidate it.
>
> Fixes: 3000ce3c52f8 ("cpufreq: Use per-policy frequency QoS")
> Reported-and-tested-by: Doug Smythies <dsmythies@telus.net>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> kernel/power/qos.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> Index: linux-pm/kernel/power/qos.c
> ===================================================================
> --- linux-pm.orig/kernel/power/qos.c
> +++ linux-pm/kernel/power/qos.c
> @@ -814,6 +814,8 @@ EXPORT_SYMBOL_GPL(freq_qos_update_reques
> */
> int freq_qos_remove_request(struct freq_qos_request *req)
> {
> + int ret;
> +
> if (!req)
> return -EINVAL;
>
> @@ -821,7 +823,11 @@ int freq_qos_remove_request(struct freq_
> "%s() called for unknown object\n", __func__))
> return -EINVAL;
>
> - return freq_qos_apply(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE);
> + ret = freq_qos_apply(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE);
> + req->qos = NULL;
> + req->type = 0;
> +
> + return ret;
> }
> EXPORT_SYMBOL_GPL(freq_qos_remove_request);
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-20 9:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-20 9:33 [PATCH] PM: QoS: Invalidate frequency QoS requests after removal Rafael J. Wysocki
2019-11-20 9:38 ` Viresh Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).