diff mbox series

[v4,6/8] scsi: ufs: core: Check if scaling up is required when disable clkscale

Message ID 20250210100212.855127-7-quic_ziqichen@quicinc.com (mailing list archive)
State Superseded
Headers show
Series Support Multi-frequency scale for UFS | expand

Commit Message

Ziqi Chen Feb. 10, 2025, 10:02 a.m. UTC
When disabling clkscale via the clkscale_enable sysfs entry, UFS driver
shall perform scaling up once regardless. Check if scaling up is required
or not first to avoid repetitive work.

Co-developed-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 drivers/ufs/core/ufshcd.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Bean Huo Feb. 10, 2025, 6:17 p.m. UTC | #1
On Mon, 2025-02-10 at 18:02 +0800, Ziqi Chen wrote:
> When disabling clkscale via the clkscale_enable sysfs entry, UFS
> driver
> shall perform scaling up once regardless. Check if scaling up is
> required
> or not first to avoid repetitive work.
> 
> Co-developed-by: Can Guo <quic_cang@quicinc.com>
> Signed-off-by: Can Guo <quic_cang@quicinc.com>
> Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
> Tested-by: Neil Armstrong <neil.armstrong@linaro.org>

Reviewed-by: Bean Huo <beanhuo@micron.com>
Peter Wang (王信友) Feb. 11, 2025, 12:58 p.m. UTC | #2
On Mon, 2025-02-10 at 18:02 +0800, Ziqi Chen wrote:
> 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> When disabling clkscale via the clkscale_enable sysfs entry, UFS
> driver
> shall perform scaling up once regardless. Check if scaling up is
> required
> or not first to avoid repetitive work.
> 
> Co-developed-by: Can Guo <quic_cang@quicinc.com>
> Signed-off-by: Can Guo <quic_cang@quicinc.com>
> Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
> Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
>  drivers/ufs/core/ufshcd.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index ebab897080a6..bd93119a177d 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -1777,6 +1777,10 @@ static ssize_t
> ufshcd_clkscale_enable_store(struct device *dev,
>         freq = clki->max_freq;
> 
>         ufshcd_suspend_clkscaling(hba);
> +
> +       if (!ufshcd_is_devfreq_scaling_required(hba, freq, true))
> +               goto out_rel;
> +
>         err = ufshcd_devfreq_scale(hba, freq, true);
>         if (err)
>                 dev_err(hba->dev, "%s: failed to scale clocks up
> %d\n",
> --
> 2.34.1
> 

Reviewed-by: Peter Wang <peter.wang@mediatek.com>
diff mbox series

Patch

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index ebab897080a6..bd93119a177d 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -1777,6 +1777,10 @@  static ssize_t ufshcd_clkscale_enable_store(struct device *dev,
 	freq = clki->max_freq;
 
 	ufshcd_suspend_clkscaling(hba);
+
+	if (!ufshcd_is_devfreq_scaling_required(hba, freq, true))
+		goto out_rel;
+
 	err = ufshcd_devfreq_scale(hba, freq, true);
 	if (err)
 		dev_err(hba->dev, "%s: failed to scale clocks up %d\n",