* [PATCH v2] PM: QoS: Restore support for default value on frequency QoS
@ 2023-06-27 7:17 Chungkai Yang
2023-06-29 8:59 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Chungkai Yang @ 2023-06-27 7:17 UTC (permalink / raw)
To: rafael, len.brown, pavel; +Cc: linux-pm, linux-kernel, Chung-kai.Yang, ccj.yeh
PM_QOS_DEFAULT_VALUE case is not covered.
Commit 8d36694245f2 ("PM: QoS: Add check to make sure CPU freq is
non-negative") makes sure CPU freq is non-negative to avoid negative
value converting to unsigned data type. However, when the value is
PM_QOS_DEFAULT_VALUE, pm_qos_update_target specifically uses
c->default_value which is set to FREQ_QOS_MIN/MAX_DEFAULT_VALUE when
cpufreq_policy_alloc is executed, for this case handling.
Adding check for PM_QOS_DEFAULT_VALUE to let default setting work will
fix this problem.
Signed-off-by: Chungkai Yang <Chung-kai.Yang@mediatek.com>
---
V1 -> V2: Check both freq_qos_add/update_request.
Link:
https://lore.kernel.org/lkml/20230626035144.19717-1-Chung-kai.Yang@mediatek.com/
---
kernel/power/qos.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index af51ed6d45ef..260aca45c681 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -531,7 +531,7 @@ int freq_qos_add_request(struct freq_constraints *qos,
{
int ret;
- if (IS_ERR_OR_NULL(qos) || !req || value < 0)
+ if (IS_ERR_OR_NULL(qos) || !req || (value < 0 && value != PM_QOS_DEFAULT_VALUE))
return -EINVAL;
if (WARN(freq_qos_request_active(req),
@@ -563,7 +563,7 @@ EXPORT_SYMBOL_GPL(freq_qos_add_request);
*/
int freq_qos_update_request(struct freq_qos_request *req, s32 new_value)
{
- if (!req || new_value < 0)
+ if (!req || (new_value < 0 && new_value != PM_QOS_DEFAULT_VALUE))
return -EINVAL;
if (WARN(!freq_qos_request_active(req),
--
2.18.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] PM: QoS: Restore support for default value on frequency QoS
2023-06-27 7:17 [PATCH v2] PM: QoS: Restore support for default value on frequency QoS Chungkai Yang
@ 2023-06-29 8:59 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2023-06-29 8:59 UTC (permalink / raw)
To: Chungkai Yang; +Cc: rafael, len.brown, pavel, linux-pm, linux-kernel, ccj.yeh
On Tue, Jun 27, 2023 at 9:18 AM Chungkai Yang
<Chung-kai.Yang@mediatek.com> wrote:
>
> PM_QOS_DEFAULT_VALUE case is not covered.
>
> Commit 8d36694245f2 ("PM: QoS: Add check to make sure CPU freq is
> non-negative") makes sure CPU freq is non-negative to avoid negative
> value converting to unsigned data type. However, when the value is
> PM_QOS_DEFAULT_VALUE, pm_qos_update_target specifically uses
> c->default_value which is set to FREQ_QOS_MIN/MAX_DEFAULT_VALUE when
> cpufreq_policy_alloc is executed, for this case handling.
>
> Adding check for PM_QOS_DEFAULT_VALUE to let default setting work will
> fix this problem.
>
> Signed-off-by: Chungkai Yang <Chung-kai.Yang@mediatek.com>
>
> ---
> V1 -> V2: Check both freq_qos_add/update_request.
>
> Link:
> https://lore.kernel.org/lkml/20230626035144.19717-1-Chung-kai.Yang@mediatek.com/
> ---
> kernel/power/qos.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/power/qos.c b/kernel/power/qos.c
> index af51ed6d45ef..260aca45c681 100644
> --- a/kernel/power/qos.c
> +++ b/kernel/power/qos.c
> @@ -531,7 +531,7 @@ int freq_qos_add_request(struct freq_constraints *qos,
> {
> int ret;
>
> - if (IS_ERR_OR_NULL(qos) || !req || value < 0)
> + if (IS_ERR_OR_NULL(qos) || !req || (value < 0 && value != PM_QOS_DEFAULT_VALUE))
> return -EINVAL;
>
> if (WARN(freq_qos_request_active(req),
> @@ -563,7 +563,7 @@ EXPORT_SYMBOL_GPL(freq_qos_add_request);
> */
> int freq_qos_update_request(struct freq_qos_request *req, s32 new_value)
> {
> - if (!req || new_value < 0)
> + if (!req || (new_value < 0 && new_value != PM_QOS_DEFAULT_VALUE))
This is functionally correct, but it's better to avoid duplicating the
value check, so please add a helper for it, for example:
static bool freq_qos_value_invalid(s32 value)
{
return value < 0 && value != PM_QOS_DEFAULT_VALUE;
}
and call it in both places.
> return -EINVAL;
>
> if (WARN(!freq_qos_request_active(req),
> --
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-29 9:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-27 7:17 [PATCH v2] PM: QoS: Restore support for default value on frequency QoS Chungkai Yang
2023-06-29 8:59 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®