From: sashiko-bot@kernel.org
To: "Bean Huo" <beanhuo@iokpp.de>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2 3/4] scsi: ufs: core: Record the frequency the controller starts at
Date: Mon, 07 Sep 2026 19:41:06 +0000 [thread overview]
Message-ID: <20260907194106.BBF131F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260907192140.2701755-4-beanhuo@iokpp.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Unprotected concurrent modification of the globally shared `ufs_hba_vps` structure during asynchronous probe.
--
commit d1d1b66402811c53b2fbc0d56ed07cd4f77540ee
Author: Bean Huo <beanhuo@micron.com>
scsi: ufs: core: Record the frequency the controller starts at
This commit records the maximum frequency during ufshcd_devfreq_init(),
preventing devfreq from reporting an initial 0 Hz frequency. It avoids
an unnecessary governor scale that resets the same frequency and gear.
It addresses the issue for both modes with and without OPPs.
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 2ba244cf40ac7..351c76094b9ff 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
[ ... ]
> @@ -1727,12 +1722,21 @@ static int ufshcd_devfreq_init(struct ufs_hba *hba)
> if (list_empty(clk_list))
> return 0;
>
> + clki = list_first_entry(clk_list, struct ufs_clk_info, list);
> +
> if (!hba->use_pm_opp) {
> - clki = list_first_entry(clk_list, struct ufs_clk_info, list);
> dev_pm_opp_add(hba->dev, clki->min_freq, 0);
> dev_pm_opp_add(hba->dev, clki->max_freq, 0);
> }
>
> + /*
> + * ufshcd_init_clocks() has already set the clocks to the highest
> + * frequency, and nothing has changed them since. Save that frequency,
> + * so that devfreq and the clock scaling code know where we start.
> + */
> + hba->clk_scaling.target_freq = clki->max_freq;
> + hba->vps->devfreq_profile.initial_freq = clki->max_freq;
[Severity: Medium]
Could this introduce a data race during asynchronous probe?
Because ufs_hba_vps is a globally shared static structure assigned to all UFS
host controllers by default (hba->vps = &ufs_hba_vps), writing directly to
hba->vps->devfreq_profile.initial_freq mutates this shared state.
If multiple controllers probe concurrently during system initialization
(e.g. via ufshcd_async_scan), they will race to overwrite this field.
If the controllers have different maximum frequencies, they might overwrite
each other's initial devfreq settings, causing devfreq to start with an
incorrect frequency on one or more controllers.
> +
> ufshcd_vops_config_scaling_param(hba, &hba->vps->devfreq_profile,
> &hba->vps->ondemand_data);
> devfreq = devfreq_add_device(hba->dev,
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260907192140.2701755-1-beanhuo@iokpp.de?part=3
next prev parent reply other threads:[~2026-09-07 19:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 19:21 [PATCH v2 0/4] devfreq: check the get_cur_freq() return value and use it in ufshcd Bean Huo
2026-09-07 19:21 ` [PATCH v2 1/4] PM / devfreq: Fall back to previous_freq when get_cur_freq() fails Bean Huo
2026-09-07 19:33 ` sashiko-bot
2026-09-07 20:29 ` Bean Huo
2026-09-07 19:21 ` [PATCH v2 2/4] PM / devfreq: Add more details to the get_cur_freq() comment Bean Huo
2026-09-07 19:21 ` [PATCH v2 3/4] scsi: ufs: core: Record the frequency the controller starts at Bean Huo
2026-09-07 19:41 ` sashiko-bot [this message]
2026-09-07 20:50 ` Bean Huo
2026-09-07 19:21 ` [PATCH v2 4/4] scsi: ufs: core: Report the current clock frequency to devfreq Bean Huo
2026-09-07 19:35 ` sashiko-bot
2026-09-07 20:23 ` Bean Huo
2026-09-08 1:34 ` [PATCH v2 0/4] devfreq: check the get_cur_freq() return value and use it in ufshcd Stanley Jhu
2026-09-10 2:28 ` Martin K. Petersen (Oracle)
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=20260907194106.BBF131F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=beanhuo@iokpp.de \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.