Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: ufs: core: Pass target_freq to clk_scale_notify() vop

Instead of only two frequencies, if OPP V2 is used, the UFS devfreq clock
scaling may scale the clock among multiple frequencies, so just passing
up/down to vop clk_scale_notify() is not enough to cover the intermediate
clock freqs between the min and max freqs. Hence pass the target_freq,
which will be used in successive commits, to clk_scale_notify() to allow
the vop to perform corresponding configurations with regard to the clock
freqs.

Signed-off-by: Can Guo <quic_cang@quicinc.com>
Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Link: https://lore.kernel.org/r/20250213080008.2984807-2-quic_ziqichen@quicinc.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Can Guo and committed by
Martin K. Petersen
5e011fcc 2014c95a

+12 -9
+4 -3
drivers/ufs/core/ufshcd-priv.h
··· 117 117 return ufshcd_readl(hba, REG_UFS_VERSION); 118 118 } 119 119 120 - static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba, 121 - bool up, enum ufs_notify_change_status status) 120 + static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba, bool up, 121 + unsigned long target_freq, 122 + enum ufs_notify_change_status status) 122 123 { 123 124 if (hba->vops && hba->vops->clk_scale_notify) 124 - return hba->vops->clk_scale_notify(hba, up, status); 125 + return hba->vops->clk_scale_notify(hba, up, target_freq, status); 125 126 return 0; 126 127 } 127 128
+2 -2
drivers/ufs/core/ufshcd.c
··· 1162 1162 int ret = 0; 1163 1163 ktime_t start = ktime_get(); 1164 1164 1165 - ret = ufshcd_vops_clk_scale_notify(hba, scale_up, PRE_CHANGE); 1165 + ret = ufshcd_vops_clk_scale_notify(hba, scale_up, freq, PRE_CHANGE); 1166 1166 if (ret) 1167 1167 goto out; 1168 1168 ··· 1173 1173 if (ret) 1174 1174 goto out; 1175 1175 1176 - ret = ufshcd_vops_clk_scale_notify(hba, scale_up, POST_CHANGE); 1176 + ret = ufshcd_vops_clk_scale_notify(hba, scale_up, freq, POST_CHANGE); 1177 1177 if (ret) { 1178 1178 if (hba->use_pm_opp) 1179 1179 ufshcd_opp_set_rate(hba,
+1
drivers/ufs/host/ufs-mediatek.c
··· 1643 1643 } 1644 1644 1645 1645 static int ufs_mtk_clk_scale_notify(struct ufs_hba *hba, bool scale_up, 1646 + unsigned long target_freq, 1646 1647 enum ufs_notify_change_status status) 1647 1648 { 1648 1649 if (!ufshcd_is_clkscaling_supported(hba))
+3 -2
drivers/ufs/host/ufs-qcom.c
··· 1394 1394 return ufs_qcom_set_core_clk_ctrl(hba, false); 1395 1395 } 1396 1396 1397 - static int ufs_qcom_clk_scale_notify(struct ufs_hba *hba, 1398 - bool scale_up, enum ufs_notify_change_status status) 1397 + static int ufs_qcom_clk_scale_notify(struct ufs_hba *hba, bool scale_up, 1398 + unsigned long target_freq, 1399 + enum ufs_notify_change_status status) 1399 1400 { 1400 1401 struct ufs_qcom_host *host = ufshcd_get_variant(hba); 1401 1402 int err;
+2 -2
include/ufs/ufshcd.h
··· 344 344 void (*exit)(struct ufs_hba *); 345 345 u32 (*get_ufs_hci_version)(struct ufs_hba *); 346 346 int (*set_dma_mask)(struct ufs_hba *); 347 - int (*clk_scale_notify)(struct ufs_hba *, bool, 348 - enum ufs_notify_change_status); 347 + int (*clk_scale_notify)(struct ufs_hba *, bool, unsigned long, 348 + enum ufs_notify_change_status); 349 349 int (*setup_clocks)(struct ufs_hba *, bool, 350 350 enum ufs_notify_change_status); 351 351 int (*hce_enable_notify)(struct ufs_hba *,