* [PATCH v4 0/8] Support Multi-frequency scale for UFS
@ 2025-02-10 10:02 Ziqi Chen
2025-02-10 10:02 ` [PATCH v4 1/8] scsi: ufs: core: Pass target_freq to clk_scale_notify() vop Ziqi Chen
0 siblings, 1 reply; 4+ messages in thread
From: Ziqi Chen @ 2025-02-10 10:02 UTC (permalink / raw)
To: quic_cang, bvanassche, mani, beanhuo, avri.altman, junwoo80.lee,
martin.petersen, quic_ziqichen, quic_nguyenb, quic_nitirawa,
quic_rampraka
Cc: linux-arm-msm, linux-scsi, Neil Armstrong, Matthias Brugger,
AngeloGioacchino Del Regno,
open list:ARM/Mediatek SoC support:Keyword:mediatek,
moderated list:ARM/Mediatek SoC support:Keyword:mediatek,
moderated list:ARM/Mediatek SoC support:Keyword:mediatek
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 3934 bytes --]
With OPP V2 enabled, devfreq can scale clocks amongst multiple frequency
plans. However, the gear speed is only toggled between min and max during
clock scaling. Enable multi-level gear scaling by mapping clock frequencies
to gear speeds, so that when devfreq scales clock frequencies we can put
the UFS link at the appropraite gear speeds accordingly.
This series has been tested on below platforms -
sm8550 mtp + UFS3.1
SM8650 MTP + UFS3.1
SM8750 MTP + UFS4.0
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-HDK
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-HDK
v1 -> v2:
1. Withdraw old patch 8/8 "ARM: dts: msm: Use Operation Points V2 for UFS on SM8650"
2. Add new patch 8/8 "ABI: sysfs-driver-ufs: Add missing UFS sysfs addributes"
3. Modify commit message for "scsi: ufs: core: Pass target_freq to clk_scale_notify() vops" and "scsi: ufs: qcom: Pass target_freq to clk scale pre and post change"
4. In "scsi: ufs: qcom: Pass target_freq to clk scale pre and post change", use common Macro HZ_PER_MHZ in function ufs_qcom_set_core_clk_ctrl()
5. In "scsi: ufs: qcom: Implement the freq_to_gear_speed() vops", print out freq and gear info as debugging message
6. In "scsi: ufs: core: Enable multi-level gear scaling", rename the lable "do_pmc" to "config_pwr_mode"
7. In "scsi: ufs: core: Toggle Write Booster during clock", initialize the local variables "wb_en" as "false"
v2 -> v3:
1. Change 'vops' to 'vop' in all commit message
2. keep the indentation consistent for clk_scale_notify() definition.
3. In "scsi: ufs: core: Add a vop to map clock frequency to gear speed", "scsi: ufs: qcom: Implement the freq_to_gear_speed() vop"
and "scsi: ufs: core: Enable multi-level gear scaling", remove the parameter 'gear' and use it as return result in function freq_to_gear_speed()
4. In "scsi: ufs: qcom: Implement the freq_to_gear_speed(), removed the variable 'ret' in function ufs_qcom_freq_to_gear_speed()
5. In "scsi: ufs: core: Enable multi-level gear scaling", use assignment instead memcpy() in function ufshcd_scale_gear()
6. Improve the grammar of attributes' descriptions in “ABI: sysfs-driver-ufs: Add missing UFS sysfs attributes”
7. Typo fixed for some commit messages.
v3 -> v4:
1. In "scsi: ufs: core: Toggle Write Booster during clock scaling base on gear speed":
a. Add comment for default initialized wb_gear
b. Remove the unnecessary variable “wb_en" in function ufshcd_clock_scaling_unprepare()
2. Typo fixed for commit message of "scsi: ufs: core: Enable multi-level gear scaling"
3. Make the description words are more standardized in "ABI: sysfs-driver-ufs: Add missing UFS sysfs attributes"
Can Guo (6):
scsi: ufs: core: Pass target_freq to clk_scale_notify() vop
scsi: ufs: qcom: Pass target_freq to clk scale pre and post change
scsi: ufs: core: Add a vop to map clock frequency to gear speed
Can Guo (6):
scsi: ufs: core: Pass target_freq to clk_scale_notify() vop
scsi: ufs: qcom: Pass target_freq to clk scale pre and post change
scsi: ufs: core: Add a vop to map clock frequency to gear speed
scsi: ufs: qcom: Implement the freq_to_gear_speed() vop
scsi: ufs: core: Enable multi-level gear scaling
scsi: ufs: core: Toggle Write Booster during clock scaling base on
gear speed
Ziqi Chen (2):
scsi: ufs: core: Check if scaling up is required when disable clkscale
ABI: sysfs-driver-ufs: Add missing UFS sysfs attributes
Documentation/ABI/testing/sysfs-driver-ufs | 33 ++++++++++
drivers/ufs/core/ufshcd-priv.h | 15 ++++-
drivers/ufs/core/ufshcd.c | 71 +++++++++++++++++-----
drivers/ufs/host/ufs-mediatek.c | 1 +
drivers/ufs/host/ufs-qcom.c | 62 ++++++++++++++-----
include/ufs/ufshcd.h | 9 ++-
6 files changed, 156 insertions(+), 35 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v4 1/8] scsi: ufs: core: Pass target_freq to clk_scale_notify() vop 2025-02-10 10:02 [PATCH v4 0/8] Support Multi-frequency scale for UFS Ziqi Chen @ 2025-02-10 10:02 ` Ziqi Chen 2025-02-11 3:52 ` Peter Wang (王信友) 0 siblings, 1 reply; 4+ messages in thread From: Ziqi Chen @ 2025-02-10 10:02 UTC (permalink / raw) To: quic_cang, bvanassche, mani, beanhuo, avri.altman, junwoo80.lee, martin.petersen, quic_ziqichen, quic_nguyenb, quic_nitirawa, quic_rampraka Cc: linux-arm-msm, linux-scsi, Neil Armstrong, Alim Akhtar, James E.J. Bottomley, Peter Wang, Stanley Jhu, Manivannan Sadhasivam, Matthias Brugger, AngeloGioacchino Del Regno, Andrew Halaney, Eric Biggers, Minwoo Im, open list, moderated list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER..., moderated list:ARM/Mediatek SoC support:Keyword:mediatek From: Can Guo <quic_cang@quicinc.com> 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> Reviewed-by: Bean Huo <beanhuo@micron.com> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Tested-by: Neil Armstrong <neil.armstrong@linaro.org> --- v1 -> v2: Modify commit message to make it more clear. v2 -> v3: 1. Change 'vops' to 'vop' in commit message. 2. keep the indentation consistent for clk_scale_notify() definition. --- drivers/ufs/core/ufshcd-priv.h | 7 ++++--- drivers/ufs/core/ufshcd.c | 4 ++-- drivers/ufs/host/ufs-mediatek.c | 1 + drivers/ufs/host/ufs-qcom.c | 5 +++-- include/ufs/ufshcd.h | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index 9ffd94ddf8c7..0549b65f71ed 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -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; } diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index acc3607bbd9c..8d295cc827cc 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -1157,7 +1157,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; @@ -1168,7 +1168,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, diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c index 135cd78109e2..977dd0caaef6 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -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)) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 68040b2ab5f8..b6eef975dc46 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -1333,8 +1333,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; diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index d7aca9e61684..f51d425696e7 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -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 *, -- 2.34.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v4 1/8] scsi: ufs: core: Pass target_freq to clk_scale_notify() vop 2025-02-10 10:02 ` [PATCH v4 1/8] scsi: ufs: core: Pass target_freq to clk_scale_notify() vop Ziqi Chen @ 2025-02-11 3:52 ` Peter Wang (王信友) 2025-02-11 10:04 ` Ziqi Chen 0 siblings, 1 reply; 4+ messages in thread From: Peter Wang (王信友) @ 2025-02-11 3:52 UTC (permalink / raw) To: beanhuo@micron.com, avri.altman@wdc.com, quic_rampraka@quicinc.com, quic_cang@quicinc.com, quic_nguyenb@quicinc.com, quic_nitirawa@quicinc.com, bvanassche@acm.org, quic_ziqichen@quicinc.com, junwoo80.lee@samsung.com, mani@kernel.org, martin.petersen@oracle.com Cc: ahalaney@redhat.com, ebiggers@google.com, neil.armstrong@linaro.org, chu.stanley@gmail.com, linux-scsi@vger.kernel.org, manivannan.sadhasivam@linaro.org, linux-kernel@vger.kernel.org, alim.akhtar@samsung.com, linux-arm-msm@vger.kernel.org, minwoo.im@samsung.com, matthias.bgg@gmail.com, James.Bottomley@HansenPartnership.com, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, AngeloGioacchino Del Regno On Mon, 2025-02-10 at 18:02 +0800, Ziqi Chen wrote: > > diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h > index d7aca9e61684..f51d425696e7 100644 > --- a/include/ufs/ufshcd.h > +++ b/include/ufs/ufshcd.h > @@ -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); > Hi Ziqi, Please keep the identation consistent. Thanks. Peter > int (*setup_clocks)(struct ufs_hba *, bool, > enum ufs_notify_change_status); > int (*hce_enable_notify)(struct ufs_hba *, > -- > 2.34.1 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4 1/8] scsi: ufs: core: Pass target_freq to clk_scale_notify() vop 2025-02-11 3:52 ` Peter Wang (王信友) @ 2025-02-11 10:04 ` Ziqi Chen 0 siblings, 0 replies; 4+ messages in thread From: Ziqi Chen @ 2025-02-11 10:04 UTC (permalink / raw) To: Peter Wang (王信友), beanhuo@micron.com, avri.altman@wdc.com, quic_rampraka@quicinc.com, quic_cang@quicinc.com, quic_nguyenb@quicinc.com, quic_nitirawa@quicinc.com, bvanassche@acm.org, junwoo80.lee@samsung.com, mani@kernel.org, martin.petersen@oracle.com Cc: ahalaney@redhat.com, ebiggers@google.com, neil.armstrong@linaro.org, chu.stanley@gmail.com, linux-scsi@vger.kernel.org, manivannan.sadhasivam@linaro.org, linux-kernel@vger.kernel.org, alim.akhtar@samsung.com, linux-arm-msm@vger.kernel.org, minwoo.im@samsung.com, matthias.bgg@gmail.com, James.Bottomley@HansenPartnership.com, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, AngeloGioacchino Del Regno On 2/11/2025 11:52 AM, Peter Wang (王信友) wrote: > On Mon, 2025-02-10 at 18:02 +0800, Ziqi Chen wrote: >> >> diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h >> index d7aca9e61684..f51d425696e7 100644 >> --- a/include/ufs/ufshcd.h >> +++ b/include/ufs/ufshcd.h >> @@ -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); >> > > Hi Ziqi, > > Please keep the identation consistent. > > Thanks. > Peter Sure, thank Peter. -Ziqi > > > > >> int (*setup_clocks)(struct ufs_hba *, bool, >> enum ufs_notify_change_status); >> int (*hce_enable_notify)(struct ufs_hba *, >> -- >> 2.34.1 >> > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-02-11 10:06 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-02-10 10:02 [PATCH v4 0/8] Support Multi-frequency scale for UFS Ziqi Chen 2025-02-10 10:02 ` [PATCH v4 1/8] scsi: ufs: core: Pass target_freq to clk_scale_notify() vop Ziqi Chen 2025-02-11 3:52 ` Peter Wang (王信友) 2025-02-11 10:04 ` Ziqi Chen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox