]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scsi: ufs: core: Pass target_freq to clk_scale_notify() vop
authorCan Guo <quic_cang@quicinc.com>
Thu, 13 Feb 2025 08:00:01 +0000 (16:00 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 21 Feb 2025 02:53:49 +0000 (21:53 -0500)
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>
drivers/ufs/core/ufshcd-priv.h
drivers/ufs/core/ufshcd.c
drivers/ufs/host/ufs-mediatek.c
drivers/ufs/host/ufs-qcom.c
include/ufs/ufshcd.h

index 786f20ef22386be20c0f014543fa6930a19ec1fe..dbdcf5219f2672ed8e831d3709770b7f3c8b0730 100644 (file)
@@ -117,11 +117,12 @@ static inline u32 ufshcd_vops_get_ufs_hci_version(struct ufs_hba *hba)
        return ufshcd_readl(hba, REG_UFS_VERSION);
 }
 
-static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba,
-                       bool up, enum ufs_notify_change_status status)
+static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba, bool up,
+                                              unsigned long target_freq,
+                                              enum ufs_notify_change_status status)
 {
        if (hba->vops && hba->vops->clk_scale_notify)
-               return hba->vops->clk_scale_notify(hba, up, status);
+               return hba->vops->clk_scale_notify(hba, up, target_freq, status);
        return 0;
 }
 
index cd404ade48dcf907f13d1d7a6511723542a9e4d5..329cae156f68e15a6a6bb98c8199794dc29b98c6 100644 (file)
@@ -1162,7 +1162,7 @@ static int ufshcd_scale_clks(struct ufs_hba *hba, unsigned long freq,
        int ret = 0;
        ktime_t start = ktime_get();
 
-       ret = ufshcd_vops_clk_scale_notify(hba, scale_up, PRE_CHANGE);
+       ret = ufshcd_vops_clk_scale_notify(hba, scale_up, freq, PRE_CHANGE);
        if (ret)
                goto out;
 
@@ -1173,7 +1173,7 @@ static int ufshcd_scale_clks(struct ufs_hba *hba, unsigned long freq,
        if (ret)
                goto out;
 
-       ret = ufshcd_vops_clk_scale_notify(hba, scale_up, POST_CHANGE);
+       ret = ufshcd_vops_clk_scale_notify(hba, scale_up, freq, POST_CHANGE);
        if (ret) {
                if (hba->use_pm_opp)
                        ufshcd_opp_set_rate(hba,
index 135cd78109e24e47e3bfab78434650ae90de4376..977dd0caaef6117da21b9c6329a9d3a1bd6a0aaa 100644 (file)
@@ -1643,6 +1643,7 @@ static void ufs_mtk_clk_scale(struct ufs_hba *hba, bool scale_up)
 }
 
 static int ufs_mtk_clk_scale_notify(struct ufs_hba *hba, bool scale_up,
+                                   unsigned long target_freq,
                                    enum ufs_notify_change_status status)
 {
        if (!ufshcd_is_clkscaling_supported(hba))
index 23b9f6efa0475ea9d3da9c0ae2722ff422bf74e3..c292fabc360937690c5137f214bc4e99af4ecb9f 100644 (file)
@@ -1394,8 +1394,9 @@ static int ufs_qcom_clk_scale_down_post_change(struct ufs_hba *hba)
        return ufs_qcom_set_core_clk_ctrl(hba, false);
 }
 
-static int ufs_qcom_clk_scale_notify(struct ufs_hba *hba,
-               bool scale_up, enum ufs_notify_change_status status)
+static int ufs_qcom_clk_scale_notify(struct ufs_hba *hba, bool scale_up,
+                                    unsigned long target_freq,
+                                    enum ufs_notify_change_status status)
 {
        struct ufs_qcom_host *host = ufshcd_get_variant(hba);
        int err;
index 650ff238cd74e8d48e5a36348eb06a0c31d365d6..e069fc6bc35caa5fa2d89d8243771b1bf4899fe6 100644 (file)
@@ -344,8 +344,8 @@ struct ufs_hba_variant_ops {
        void    (*exit)(struct ufs_hba *);
        u32     (*get_ufs_hci_version)(struct ufs_hba *);
        int     (*set_dma_mask)(struct ufs_hba *);
-       int     (*clk_scale_notify)(struct ufs_hba *, bool,
-                                   enum ufs_notify_change_status);
+       int     (*clk_scale_notify)(struct ufs_hba *, bool, unsigned long,
+                               enum ufs_notify_change_status);
        int     (*setup_clocks)(struct ufs_hba *, bool,
                                enum ufs_notify_change_status);
        int     (*hce_enable_notify)(struct ufs_hba *,