scsi: ufs: core: Check if scaling up is required when disable clkscale

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.

Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Co-developed-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Link: https://lore.kernel.org/r/20250213080008.2984807-7-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>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Ziqi Chen 2025-02-13 16:00:06 +08:00 committed by Martin K. Petersen
parent 129b44c27c
commit eff26ad4c3

View File

@ -1767,6 +1767,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",