From: Clive Lin <clive.lin@mediatek.com>
To: <rafael@kernel.org>, <pavel@ucw.cz>, <len.brown@intel.com>
Cc: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<chung-kai.yang@mediatek.com>, <ccj.yeh@mediatek.com>,
<clive.lin@mediatek.com>, <ching-hao.hsu@mediatek.com>
Subject: [PATCH] PM: QoS: Add check to make sure CPU latency is non-negative
Date: Mon, 31 Jul 2023 14:03:54 +0800 [thread overview]
Message-ID: <20230731060354.4802-1-clive.lin@mediatek.com> (raw)
CPU latency should never be negative, which will be incorrectly high
when converted to unsigned data type. Commit 8d36694245f2 ("PM: QoS:
Add check to make sure CPU freq is non-negative") makes sure CPU freq
is non-negative to fix incorrect behavior in freq_qos. Adding a check
to make sure CPU latency is non-negative can prevent this problem
from happening in cpu_latency_qos.
Signed-off-by: Clive Lin <clive.lin@mediatek.com>
---
kernel/power/qos.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index 782d3b41c1f3..4244b069442e 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -220,6 +220,11 @@ static struct pm_qos_constraints cpu_latency_constraints = {
.type = PM_QOS_MIN,
};
+static inline bool cpu_latency_qos_value_invalid(s32 value)
+{
+ return value < 0 && value != PM_QOS_DEFAULT_VALUE;
+}
+
/**
* cpu_latency_qos_limit - Return current system-wide CPU latency QoS limit.
*/
@@ -263,7 +268,7 @@ static void cpu_latency_qos_apply(struct pm_qos_request *req,
*/
void cpu_latency_qos_add_request(struct pm_qos_request *req, s32 value)
{
- if (!req)
+ if (!req || cpu_latency_qos_value_invalid(value))
return;
if (cpu_latency_qos_request_active(req)) {
@@ -289,7 +294,7 @@ EXPORT_SYMBOL_GPL(cpu_latency_qos_add_request);
*/
void cpu_latency_qos_update_request(struct pm_qos_request *req, s32 new_value)
{
- if (!req)
+ if (!req || cpu_latency_qos_value_invalid(new_value))
return;
if (!cpu_latency_qos_request_active(req)) {
--
2.18.0
next reply other threads:[~2023-07-31 6:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-31 6:03 Clive Lin [this message]
2023-08-22 19:39 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230731060354.4802-1-clive.lin@mediatek.com \
--to=clive.lin@mediatek.com \
--cc=ccj.yeh@mediatek.com \
--cc=ching-hao.hsu@mediatek.com \
--cc=chung-kai.yang@mediatek.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®