From: Ziqi Chen <quic_ziqichen@quicinc.com>
To: Bart Van Assche <bvanassche@acm.org>, <quic_cang@quicinc.com>,
<mani@kernel.org>, <beanhuo@micron.com>, <avri.altman@wdc.com>,
<junwoo80.lee@samsung.com>, <martin.petersen@oracle.com>,
<quic_nguyenb@quicinc.com>, <quic_nitirawa@quicinc.com>,
<quic_rampraka@quicinc.com>, <neil.armstrong@linaro.org>,
<luca.weiss@fairphone.com>, <konrad.dybcio@oss.qualcomm.com>,
<peter.wang@mediatek.com>
Cc: <linux-arm-msm@vger.kernel.org>, <linux-scsi@vger.kernel.org>,
Alim Akhtar <alim.akhtar@samsung.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] scsi: ufs: core: skip UFS clkscale if host asynchronous scan in progress
Date: Fri, 9 May 2025 13:02:46 +0800 [thread overview]
Message-ID: <5748d0cc-a603-4b44-bbfc-d39d684b2ea6@quicinc.com> (raw)
In-Reply-To: <fd13e179-f2d8-4085-86da-c6b0fce2de5b@acm.org>
On 5/9/2025 12:06 AM, Bart Van Assche wrote:
> On 5/8/25 2:38 AM, Ziqi Chen wrote:
>> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
>> index 1c53ccf5a616..04f40677e76a 100644
>> --- a/drivers/ufs/core/ufshcd.c
>> +++ b/drivers/ufs/core/ufshcd.c
>> @@ -1207,6 +1207,9 @@ static bool
>> ufshcd_is_devfreq_scaling_required(struct ufs_hba *hba,
>> if (list_empty(head))
>> return false;
>> + if (hba->host->async_scan)
>> + return false;
>
> Testing a boolean is never a proper way to synchronize code sections.
> As an example, the SCSI core could set hba->host->async_scan after this
> check completed and before the code below is executed. I think we need a
> better solution.
Hi Bart,
I get your point, we have also taken this into consideration. That's why
we move ufshcd_devfreq_init() out of ufshd_add_lus().
Old sequence:
| ufshcd_async_scan()
|ufshcd_add_lus()
|ufshcd_devfreq_init()
| | enable UFS clock scaling
|scsi_scan_host()
|scsi_prep_async_scan()
| | set host->async_scan to '1'
|async_schedule(do_scan_async, data)
With this old sequence , The ufs devfreq monitor started before the
scsi_prep_async_scan(), the SCSI core could set hba->host->async_scan
after this check.
New sequence:
| ufshcd_async_scan()
|ufshcd_add_lus()
| |scsi_scan_host()
| |scsi_prep_async_scan()
| | | set host->async_scan to '1'
| |async_schedule(do_scan_async, data)
|ufshcd_devfreq_init()
| |enable UFS clock scaling
With the new sequence , it is guaranteed that host->async_scan
is set before the UFS clock scaling enabling.
I guess you might be worried about out-of-order execution will
cause this flag not be set before clock scaling enabling with
extremely low probability?
If yes, do you have any suggestion on this ?
BRs,
Ziqi
>
> Bart.
next prev parent reply other threads:[~2025-05-09 5:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-08 9:38 [PATCH v3] scsi: ufs: core: skip UFS clkscale if host asynchronous scan in progress Ziqi Chen
2025-05-08 16:06 ` Bart Van Assche
2025-05-09 5:02 ` Ziqi Chen [this message]
2025-05-12 22:31 ` Bart Van Assche
2025-05-14 7:25 ` Ziqi Chen
2025-05-14 9:05 ` Peter Wang (王信友)
2025-05-21 8:56 ` Ziqi Chen
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=5748d0cc-a603-4b44-bbfc-d39d684b2ea6@quicinc.com \
--to=quic_ziqichen@quicinc.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=junwoo80.lee@samsung.com \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=luca.weiss@fairphone.com \
--cc=mani@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=martin.petersen@oracle.com \
--cc=neil.armstrong@linaro.org \
--cc=peter.wang@mediatek.com \
--cc=quic_cang@quicinc.com \
--cc=quic_nguyenb@quicinc.com \
--cc=quic_nitirawa@quicinc.com \
--cc=quic_rampraka@quicinc.com \
/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