From: Jie Zhan <zhanjie9@hisilicon.com>
To: Yaxiong Tian <tianyaxiong@kylinos.cn>, <myungjoo.ham@samsung.com>,
<kyungmin.park@samsung.com>, <cw00.choi@samsung.com>, <nm@ti.com>
Cc: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RESEND 3/4] PM / devfreq: Fix governor_store() failing when device has no current governor
Date: Tue, 31 Mar 2026 15:16:40 +0800 [thread overview]
Message-ID: <5ac69894-aa0d-475f-8950-a0ff98f9fa2e@hisilicon.com> (raw)
In-Reply-To: <20260319091710.1006814-1-tianyaxiong@kylinos.cn>
On 3/19/2026 5:17 PM, Yaxiong Tian wrote:
> Since devfreq_remove_governor() may clear the device's current governor
> in certain situations, while governors actually exist independently
> of the device, directly returning EINVAL in this case is inaccurate.
>
> To fix this issue, remove this check and add relevant logic for when
> df->governor is NULL.
>
> Fixes: 483d557ee9a3 ("PM / devfreq: Clean up the devfreq instance name in sysfs attr")
> Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
> ---
> drivers/devfreq/devfreq.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 0bf320123e3a..4a312f3c2421 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -1425,9 +1425,6 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr,
> char str_governor[DEVFREQ_NAME_LEN + 1];
> const struct devfreq_governor *governor, *prev_governor;
>
> - if (!df->governor)
> - return -EINVAL;
> -
> ret = sscanf(buf, "%" __stringify(DEVFREQ_NAME_LEN) "s", str_governor);
> if (ret != 1)
> return -EINVAL;
> @@ -1438,6 +1435,18 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr,
> ret = PTR_ERR(governor);
> goto out;
> }
> +
> + if (!df->governor) {
> + df->governor = governor;
> + ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL);
> + if (ret) {
> + dev_warn(dev, "%s: Governor %s not started(%d)\n",
> + __func__, df->governor->name, ret);
> + df->governor = NULL;
> + }
> + goto out;
> + }
> +
The sequence that starts the governor, and stops, and then re-starts looks
quite weird.
Can you do a NULL pointer check before the IMMUTABLE flag check and
stopping governor, rather than this?
> if (df->governor == governor) {
> ret = 0;
> goto out;
next prev parent reply other threads:[~2026-03-31 7:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 9:14 [PATCH RESEND 0/4] Fix some errors in the devfreq core layer when governor is NULL Yaxiong Tian
2026-03-19 9:16 ` [PATCH RESEND 1/4] PM / devfreq: Fix possible null pointer issue in devfreq_add_governor() Yaxiong Tian
2026-03-31 7:04 ` Jie Zhan
2026-03-31 7:49 ` Yaxiong Tian
2026-03-31 8:49 ` Jie Zhan
2026-03-31 9:17 ` Yaxiong Tian
2026-03-31 9:28 ` Jie Zhan
2026-03-19 9:17 ` [PATCH RESEND 2/4] PM / devfreq: Fix available_governors_show() when no governor is set Yaxiong Tian
2026-03-31 7:08 ` Jie Zhan
2026-03-19 9:17 ` [PATCH RESEND 3/4] PM / devfreq: Fix governor_store() failing when device has no current governor Yaxiong Tian
2026-03-31 7:16 ` Jie Zhan [this message]
2026-03-31 8:02 ` Yaxiong Tian
2026-03-31 8:53 ` Jie Zhan
2026-03-31 9:30 ` Yaxiong Tian
2026-03-31 9:37 ` Jie Zhan
2026-03-31 9:54 ` Yaxiong Tian
2026-03-31 10:12 ` Yaxiong Tian
2026-03-19 9:17 ` [PATCH RESEND 4/4] PM / devfreq: Optimize error return value of governor_show() Yaxiong Tian
2026-03-31 7:21 ` Jie Zhan
2026-03-31 8:03 ` Yaxiong Tian
2026-03-25 10:06 ` [PATCH RESEND 0/4] Fix some errors in the devfreq core layer when governor is NULL Jie Zhan
[not found] ` <1774486650723160.85.seg@mailgw.kylinos.cn>
2026-03-27 1:55 ` Yaxiong Tian
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=5ac69894-aa0d-475f-8950-a0ff98f9fa2e@hisilicon.com \
--to=zhanjie9@hisilicon.com \
--cc=cw00.choi@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=nm@ti.com \
--cc=tianyaxiong@kylinos.cn \
/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