* [PATCH 1/8] scsi: ufs: core: Pass target_freq to clk_scale_notify() vops
[not found] <20250116091150.1167739-1-quic_ziqichen@quicinc.com>
@ 2025-01-16 9:11 ` Ziqi Chen
2025-01-19 7:11 ` Manivannan Sadhasivam
2025-01-16 9:11 ` [PATCH 2/8] scsi: ufs: qcom: Pass target_freq to clk scale pre and post change Ziqi Chen
` (2 subsequent siblings)
3 siblings, 1 reply; 23+ messages in thread
From: Ziqi Chen @ 2025-01-16 9:11 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-scsi, Alim Akhtar, James E.J. Bottomley, Peter Wang,
Stanley Jhu, Manivannan Sadhasivam, Matthias Brugger,
AngeloGioacchino Del Regno, Andrew Halaney, Maramaina Naresh,
Eric Biggers, Minwoo Im, open list,
moderated list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER...,
open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER...,
moderated list:ARM/Mediatek SoC support:Keyword:mediatek
From: Can Guo <quic_cang@quicinc.com>
If OPP V2 is used, devfreq clock scaling may scale clock amongst more than
two freqs, so just passing up/down to vops clk_scale_notify() is not enough
to cover the intermediate clock freqs between the min and max freqs. Hence
pass the target_freq to clk_scale_notify() to allow the vops to perform
corresponding configurations with regard to the clock freqs.
Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Can Guo <quic_cang@quicinc.com>
---
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 | 2 +-
5 files changed, 11 insertions(+), 8 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..a4dac897a169 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -344,7 +344,7 @@ 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,
+ 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);
--
2.34.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 1/8] scsi: ufs: core: Pass target_freq to clk_scale_notify() vops
2025-01-16 9:11 ` [PATCH 1/8] scsi: ufs: core: Pass target_freq to clk_scale_notify() vops Ziqi Chen
@ 2025-01-19 7:11 ` Manivannan Sadhasivam
2025-01-20 12:01 ` Ziqi Chen
0 siblings, 1 reply; 23+ messages in thread
From: Manivannan Sadhasivam @ 2025-01-19 7:11 UTC (permalink / raw)
To: Ziqi Chen
Cc: quic_cang, bvanassche, beanhuo, avri.altman, junwoo80.lee,
martin.petersen, quic_nguyenb, quic_nitirawa, quic_rampraka,
linux-scsi, Alim Akhtar, James E.J. Bottomley, Peter Wang,
Stanley Jhu, Manivannan Sadhasivam, Matthias Brugger,
AngeloGioacchino Del Regno, Andrew Halaney, Maramaina Naresh,
Eric Biggers, Minwoo Im, open list,
moderated list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER...,
open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER...,
moderated list:ARM/Mediatek SoC support:Keyword:mediatek
On Thu, Jan 16, 2025 at 05:11:42PM +0800, Ziqi Chen wrote:
> From: Can Guo <quic_cang@quicinc.com>
>
> If OPP V2 is used, devfreq clock scaling may scale clock amongst more than
> two freqs,
'amongst more than two freqs': I couldn't parse this.
> so just passing up/down to vops clk_scale_notify() is not enough
> to cover the intermediate clock freqs between the min and max freqs. Hence
> pass the target_freq to clk_scale_notify() to allow the vops to perform
> corresponding configurations with regard to the clock freqs.
>
Add a note that the 'target_freq' is not used in this commit.
> Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> Signed-off-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by tag order is not correct here. This implies that Ziqi originally
worked on it, then Can took over and submitted. But it seems the reverse.
- Mani
> ---
> 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 | 2 +-
> 5 files changed, 11 insertions(+), 8 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..a4dac897a169 100644
> --- a/include/ufs/ufshcd.h
> +++ b/include/ufs/ufshcd.h
> @@ -344,7 +344,7 @@ 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,
> + 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);
> --
> 2.34.1
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 1/8] scsi: ufs: core: Pass target_freq to clk_scale_notify() vops
2025-01-19 7:11 ` Manivannan Sadhasivam
@ 2025-01-20 12:01 ` Ziqi Chen
2025-01-20 15:36 ` Manivannan Sadhasivam
2025-01-20 15:38 ` Manivannan Sadhasivam
0 siblings, 2 replies; 23+ messages in thread
From: Ziqi Chen @ 2025-01-20 12:01 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: quic_cang, bvanassche, beanhuo, avri.altman, junwoo80.lee,
martin.petersen, quic_nguyenb, quic_nitirawa, quic_rampraka,
linux-scsi, Alim Akhtar, James E.J. Bottomley, Peter Wang,
Stanley Jhu, Manivannan Sadhasivam, Matthias Brugger,
AngeloGioacchino Del Regno, Andrew Halaney, Maramaina Naresh,
Eric Biggers, Minwoo Im, open list,
moderated list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER...,
open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER...,
moderated list:ARM/Mediatek SoC support:Keyword:mediatek
Hi Mani,
Thanks for you review~
On 1/19/2025 3:11 PM, Manivannan Sadhasivam wrote:
> On Thu, Jan 16, 2025 at 05:11:42PM +0800, Ziqi Chen wrote:
>> From: Can Guo <quic_cang@quicinc.com>
>>
>> If OPP V2 is used, devfreq clock scaling may scale clock amongst more than
>> two freqs,
>
> 'amongst more than two freqs': I couldn't parse this.
>
It means that the devfreq framework will tell UFS core driver the
devfreq freq, then UFS core driver will find the recommended freq from
our freq table based on the devfreq freq. For legacy mode , we can only
have 2 frequencies in the table. But if the OPP V2 is used, we can have
3 , 4 or more freq tables. You can refer to my PATCH 8/8.
>> so just passing up/down to vops clk_scale_notify() is not enough
>> to cover the intermediate clock freqs between the min and max freqs. Hence
>> pass the target_freq to clk_scale_notify() to allow the vops to perform
>> corresponding configurations with regard to the clock freqs.
>>
>
> Add a note that the 'target_freq' is not used in this commit.
>
Sorry, I don't very understand this comment, I mentioned the
"target_freq" in the commit message, Could you let me know what note
you want me do add?
>> Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
>> Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
>> Signed-off-by: Can Guo <quic_cang@quicinc.com>
>
> Signed-off-by tag order is not correct here. This implies that Ziqi originally
> worked on it, then Can took over and submitted. But it seems the reverse.
Thanks for your reminder. Is below tag order OK ?
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>
>
> - Mani
-Ziqi
>
>> ---
>> 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 | 2 +-
>> 5 files changed, 11 insertions(+), 8 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..a4dac897a169 100644
>> --- a/include/ufs/ufshcd.h
>> +++ b/include/ufs/ufshcd.h
>> @@ -344,7 +344,7 @@ 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,
>> + 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);
>> --
>> 2.34.1
>>
>
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 1/8] scsi: ufs: core: Pass target_freq to clk_scale_notify() vops
2025-01-20 12:01 ` Ziqi Chen
@ 2025-01-20 15:36 ` Manivannan Sadhasivam
2025-01-21 3:51 ` Ziqi Chen
2025-01-20 15:38 ` Manivannan Sadhasivam
1 sibling, 1 reply; 23+ messages in thread
From: Manivannan Sadhasivam @ 2025-01-20 15:36 UTC (permalink / raw)
To: Ziqi Chen
Cc: Manivannan Sadhasivam, quic_cang, bvanassche, beanhuo,
avri.altman, junwoo80.lee, martin.petersen, quic_nguyenb,
quic_nitirawa, quic_rampraka, linux-scsi, Alim Akhtar,
James E.J. Bottomley, Peter Wang, Stanley Jhu, Matthias Brugger,
AngeloGioacchino Del Regno, Andrew Halaney, Maramaina Naresh,
Eric Biggers, Minwoo Im, open list,
moderated list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER...,
open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER...,
moderated list:ARM/Mediatek SoC support:Keyword:mediatek
On Mon, Jan 20, 2025 at 08:01:03PM +0800, Ziqi Chen wrote:
> Hi Mani,
>
> Thanks for you review~
>
> On 1/19/2025 3:11 PM, Manivannan Sadhasivam wrote:
> > On Thu, Jan 16, 2025 at 05:11:42PM +0800, Ziqi Chen wrote:
> > > From: Can Guo <quic_cang@quicinc.com>
> > >
> > > If OPP V2 is used, devfreq clock scaling may scale clock amongst more than
> > > two freqs,
> >
> > 'amongst more than two freqs': I couldn't parse this.
> >
>
> It means that the devfreq framework will tell UFS core driver the devfreq
> freq, then UFS core driver will find the recommended freq from our freq
> table based on the devfreq freq. For legacy mode , we can only have 2
> frequencies in the table. But if the OPP V2 is used, we can have 3 , 4 or
> more freq tables. You can refer to my PATCH 8/8.
>
I got the motive, but the wording is not correct.
> > > so just passing up/down to vops clk_scale_notify() is not enough
> > > to cover the intermediate clock freqs between the min and max freqs. Hence
> > > pass the target_freq to clk_scale_notify() to allow the vops to perform
> > > corresponding configurations with regard to the clock freqs.
> > >
> >
> > Add a note that the 'target_freq' is not used in this commit.
> >
>
> Sorry, I don't very understand this comment, I mentioned the "target_freq"
> in the commit message, Could you let me know what note you want me do add?
>
This patch is introducing 'target_freq' as a parameter, but it is not used. I
was asking you to mention that it will be used in successive commits.
> > > Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> > > Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> > > Signed-off-by: Can Guo <quic_cang@quicinc.com>
> >
> > Signed-off-by tag order is not correct here. This implies that Ziqi originally
> > worked on it, then Can took over and submitted. But it seems the reverse.
>
> Thanks for your reminder. Is below tag order OK ?
> 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>
> >
> > - Mani
>
> -Ziqi
>
> >
> > > ---
> > > 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 | 2 +-
> > > 5 files changed, 11 insertions(+), 8 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..a4dac897a169 100644
> > > --- a/include/ufs/ufshcd.h
> > > +++ b/include/ufs/ufshcd.h
> > > @@ -344,7 +344,7 @@ 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,
> > > + 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);
> > > --
> > > 2.34.1
> > >
> >
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 1/8] scsi: ufs: core: Pass target_freq to clk_scale_notify() vops
2025-01-20 15:36 ` Manivannan Sadhasivam
@ 2025-01-21 3:51 ` Ziqi Chen
0 siblings, 0 replies; 23+ messages in thread
From: Ziqi Chen @ 2025-01-21 3:51 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: Manivannan Sadhasivam, quic_cang, bvanassche, beanhuo,
avri.altman, junwoo80.lee, martin.petersen, quic_nguyenb,
quic_nitirawa, quic_rampraka, linux-scsi, Alim Akhtar,
James E.J. Bottomley, Peter Wang, Stanley Jhu, Matthias Brugger,
AngeloGioacchino Del Regno, Andrew Halaney, Maramaina Naresh,
Eric Biggers, Minwoo Im, open list,
moderated list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER...,
open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER...,
moderated list:ARM/Mediatek SoC support:Keyword:mediatek
On 1/20/2025 11:36 PM, Manivannan Sadhasivam wrote:
> On Mon, Jan 20, 2025 at 08:01:03PM +0800, Ziqi Chen wrote:
>> Hi Mani,
>>
>> Thanks for you review~
>>
>> On 1/19/2025 3:11 PM, Manivannan Sadhasivam wrote:
>>> On Thu, Jan 16, 2025 at 05:11:42PM +0800, Ziqi Chen wrote:
>>>> From: Can Guo <quic_cang@quicinc.com>
>>>>
>>>> If OPP V2 is used, devfreq clock scaling may scale clock amongst more than
>>>> two freqs,
>>>
>>> 'amongst more than two freqs': I couldn't parse this.
>>>
>>
>> It means that the devfreq framework will tell UFS core driver the devfreq
>> freq, then UFS core driver will find the recommended freq from our freq
>> table based on the devfreq freq. For legacy mode , we can only have 2
>> frequencies in the table. But if the OPP V2 is used, we can have 3 , 4 or
>> more freq tables. You can refer to my PATCH 8/8.
>>
>
> I got the motive, but the wording is not correct.
>
OK , let me express it in another way:
"Instead of only two frequencies, If OPP V2 is used, the UFS devfreq
clock scaling may scale the clock among multiple frequencies."
How about this?
>>>> so just passing up/down to vops clk_scale_notify() is not enough
>>>> to cover the intermediate clock freqs between the min and max freqs. Hence
>>>> pass the target_freq to clk_scale_notify() to allow the vops to perform
>>>> corresponding configurations with regard to the clock freqs.
>>>>
>>>
>>> Add a note that the 'target_freq' is not used in this commit.
>>>
>>
>> Sorry, I don't very understand this comment, I mentioned the "target_freq"
>> in the commit message, Could you let me know what note you want me do add?
>>
>
> This patch is introducing 'target_freq' as a parameter, but it is not used. I
> was asking you to mention that it will be used in successive commits.
>
OK , thank you, I will add this note in next version.
-Ziqi
>>>> Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
>>>> Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
>>>> Signed-off-by: Can Guo <quic_cang@quicinc.com>
>>>
>>> Signed-off-by tag order is not correct here. This implies that Ziqi originally
>>> worked on it, then Can took over and submitted. But it seems the reverse.
>>
>> Thanks for your reminder. Is below tag order OK ?
>> 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>
>>>
>>> - Mani
>>
>> -Ziqi
>>
>>>
>>>> ---
>>>> 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 | 2 +-
>>>> 5 files changed, 11 insertions(+), 8 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..a4dac897a169 100644
>>>> --- a/include/ufs/ufshcd.h
>>>> +++ b/include/ufs/ufshcd.h
>>>> @@ -344,7 +344,7 @@ 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,
>>>> + 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);
>>>> --
>>>> 2.34.1
>>>>
>>>
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/8] scsi: ufs: core: Pass target_freq to clk_scale_notify() vops
2025-01-20 12:01 ` Ziqi Chen
2025-01-20 15:36 ` Manivannan Sadhasivam
@ 2025-01-20 15:38 ` Manivannan Sadhasivam
1 sibling, 0 replies; 23+ messages in thread
From: Manivannan Sadhasivam @ 2025-01-20 15:38 UTC (permalink / raw)
To: Ziqi Chen
Cc: quic_cang, bvanassche, beanhuo, avri.altman, junwoo80.lee,
martin.petersen, quic_nguyenb, quic_nitirawa, quic_rampraka,
linux-scsi, Alim Akhtar, James E.J. Bottomley, Peter Wang,
Stanley Jhu, Manivannan Sadhasivam, Matthias Brugger,
AngeloGioacchino Del Regno, Andrew Halaney, Maramaina Naresh,
Eric Biggers, Minwoo Im, open list,
moderated list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER...,
open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER...,
moderated list:ARM/Mediatek SoC support:Keyword:mediatek
On Mon, Jan 20, 2025 at 08:01:03PM +0800, Ziqi Chen wrote:
> Hi Mani,
>
> Thanks for you review~
>
> On 1/19/2025 3:11 PM, Manivannan Sadhasivam wrote:
> > On Thu, Jan 16, 2025 at 05:11:42PM +0800, Ziqi Chen wrote:
> > > From: Can Guo <quic_cang@quicinc.com>
> > >
> > > If OPP V2 is used, devfreq clock scaling may scale clock amongst more than
> > > two freqs,
> >
> > 'amongst more than two freqs': I couldn't parse this.
> >
>
> It means that the devfreq framework will tell UFS core driver the devfreq
> freq, then UFS core driver will find the recommended freq from our freq
> table based on the devfreq freq. For legacy mode , we can only have 2
> frequencies in the table. But if the OPP V2 is used, we can have 3 , 4 or
> more freq tables. You can refer to my PATCH 8/8.
>
> > > so just passing up/down to vops clk_scale_notify() is not enough
> > > to cover the intermediate clock freqs between the min and max freqs. Hence
> > > pass the target_freq to clk_scale_notify() to allow the vops to perform
> > > corresponding configurations with regard to the clock freqs.
> > >
> >
> > Add a note that the 'target_freq' is not used in this commit.
> >
>
> Sorry, I don't very understand this comment, I mentioned the "target_freq"
> in the commit message, Could you let me know what note you want me do add?
>
> > > Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> > > Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> > > Signed-off-by: Can Guo <quic_cang@quicinc.com>
> >
> > Signed-off-by tag order is not correct here. This implies that Ziqi originally
> > worked on it, then Can took over and submitted. But it seems the reverse.
>
> Thanks for your reminder. Is below tag order OK ?
> Signed-off-by: Can Guo <quic_cang@quicinc.com>
> Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
'Co-developed-by' is not needed unless you also worked on the patch. I guess you
are just sending the patch authored by Can, so you can drop this and keep your
'Signed-off-by' tag.
- Mani
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 2/8] scsi: ufs: qcom: Pass target_freq to clk scale pre and post change
[not found] <20250116091150.1167739-1-quic_ziqichen@quicinc.com>
2025-01-16 9:11 ` [PATCH 1/8] scsi: ufs: core: Pass target_freq to clk_scale_notify() vops Ziqi Chen
@ 2025-01-16 9:11 ` Ziqi Chen
2025-01-19 7:22 ` Manivannan Sadhasivam
2025-01-16 9:11 ` [PATCH 4/8] scsi: ufs: qcom: Implement the freq_to_gear_speed() vops Ziqi Chen
2025-01-16 9:11 ` [PATCH 8/8] ARM: dts: msm: Use Operation Points V2 for UFS on SM8650 Ziqi Chen
3 siblings, 1 reply; 23+ messages in thread
From: Ziqi Chen @ 2025-01-16 9:11 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-scsi, Manivannan Sadhasivam, James E.J. Bottomley,
open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER...,
open list
From: Can Guo <quic_cang@quicinc.com>
If OPP V2 is used, devfreq clock scaling may scale clock amongst more than
two freqs. In the case of scaling up, the devfreq may decide to scale the
clock to an intermidiate freq base on load, but the clock scale up pre
change operation uses settings for the max clock freq unconditionally. Fix
it by passing the target_freq to clock scale up pre change so that the
correct settings for the target_freq can be used.
In the case of scaling down, the clock scale down post change operation
is doing fine, because it reads the actual clock rate to tell freq, but to
keep symmetry with clock scale up pre change operation, just use the
target_freq instead of reading clock rate.
Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Can Guo <quic_cang@quicinc.com>
---
drivers/ufs/host/ufs-qcom.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index b6eef975dc46..1e8a23eb8c13 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -97,7 +97,7 @@ static const struct __ufs_qcom_bw_table {
};
static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host);
-static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, bool is_scale_up);
+static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, unsigned long freq);
static struct ufs_qcom_host *rcdev_to_ufs_host(struct reset_controller_dev *rcd)
{
@@ -524,7 +524,7 @@ static int ufs_qcom_link_startup_notify(struct ufs_hba *hba,
return -EINVAL;
}
- err = ufs_qcom_set_core_clk_ctrl(hba, true);
+ err = ufs_qcom_set_core_clk_ctrl(hba, ULONG_MAX);
if (err)
dev_err(hba->dev, "cfg core clk ctrl failed\n");
/*
@@ -1231,7 +1231,7 @@ static int ufs_qcom_set_clk_40ns_cycles(struct ufs_hba *hba,
return ufshcd_dme_set(hba, UIC_ARG_MIB(PA_VS_CORE_CLK_40NS_CYCLES), reg);
}
-static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, bool is_scale_up)
+static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, unsigned long freq)
{
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
struct list_head *head = &hba->clk_list_head;
@@ -1245,10 +1245,11 @@ static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, bool is_scale_up)
!strcmp(clki->name, "core_clk_unipro")) {
if (!clki->max_freq)
cycles_in_1us = 150; /* default for backwards compatibility */
- else if (is_scale_up)
+ else if (freq == ULONG_MAX)
cycles_in_1us = ceil(clki->max_freq, (1000 * 1000));
else
- cycles_in_1us = ceil(clk_get_rate(clki->clk), (1000 * 1000));
+ cycles_in_1us = ceil(freq, (1000 * 1000));
+
break;
}
}
@@ -1285,7 +1286,7 @@ static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, bool is_scale_up)
return ufs_qcom_set_clk_40ns_cycles(hba, cycles_in_1us);
}
-static int ufs_qcom_clk_scale_up_pre_change(struct ufs_hba *hba)
+static int ufs_qcom_clk_scale_up_pre_change(struct ufs_hba *hba, unsigned long freq)
{
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
struct ufs_pa_layer_attr *attr = &host->dev_req_params;
@@ -1298,7 +1299,7 @@ static int ufs_qcom_clk_scale_up_pre_change(struct ufs_hba *hba)
return ret;
}
/* set unipro core clock attributes and clear clock divider */
- return ufs_qcom_set_core_clk_ctrl(hba, true);
+ return ufs_qcom_set_core_clk_ctrl(hba, freq);
}
static int ufs_qcom_clk_scale_up_post_change(struct ufs_hba *hba)
@@ -1327,10 +1328,10 @@ static int ufs_qcom_clk_scale_down_pre_change(struct ufs_hba *hba)
return err;
}
-static int ufs_qcom_clk_scale_down_post_change(struct ufs_hba *hba)
+static int ufs_qcom_clk_scale_down_post_change(struct ufs_hba *hba, unsigned long freq)
{
/* set unipro core clock attributes and clear clock divider */
- return ufs_qcom_set_core_clk_ctrl(hba, false);
+ return ufs_qcom_set_core_clk_ctrl(hba, freq);
}
static int ufs_qcom_clk_scale_notify(struct ufs_hba *hba, bool scale_up,
@@ -1349,7 +1350,7 @@ static int ufs_qcom_clk_scale_notify(struct ufs_hba *hba, bool scale_up,
if (err)
return err;
if (scale_up)
- err = ufs_qcom_clk_scale_up_pre_change(hba);
+ err = ufs_qcom_clk_scale_up_pre_change(hba, target_freq);
else
err = ufs_qcom_clk_scale_down_pre_change(hba);
@@ -1361,7 +1362,7 @@ static int ufs_qcom_clk_scale_notify(struct ufs_hba *hba, bool scale_up,
if (scale_up)
err = ufs_qcom_clk_scale_up_post_change(hba);
else
- err = ufs_qcom_clk_scale_down_post_change(hba);
+ err = ufs_qcom_clk_scale_down_post_change(hba, target_freq);
if (err) {
--
2.34.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 2/8] scsi: ufs: qcom: Pass target_freq to clk scale pre and post change
2025-01-16 9:11 ` [PATCH 2/8] scsi: ufs: qcom: Pass target_freq to clk scale pre and post change Ziqi Chen
@ 2025-01-19 7:22 ` Manivannan Sadhasivam
2025-01-20 12:02 ` Ziqi Chen
0 siblings, 1 reply; 23+ messages in thread
From: Manivannan Sadhasivam @ 2025-01-19 7:22 UTC (permalink / raw)
To: Ziqi Chen
Cc: quic_cang, bvanassche, beanhuo, avri.altman, junwoo80.lee,
martin.petersen, quic_nguyenb, quic_nitirawa, quic_rampraka,
linux-scsi, Manivannan Sadhasivam, James E.J. Bottomley,
open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER...,
open list
On Thu, Jan 16, 2025 at 05:11:43PM +0800, Ziqi Chen wrote:
> From: Can Guo <quic_cang@quicinc.com>
>
> If OPP V2 is used, devfreq clock scaling may scale clock amongst more than
> two freqs.
Same comment as previous patch.
> In the case of scaling up, the devfreq may decide to scale the
> clock to an intermidiate freq base on load, but the clock scale up pre
> change operation uses settings for the max clock freq unconditionally. Fix
> it by passing the target_freq to clock scale up pre change so that the
> correct settings for the target_freq can be used.
>
> In the case of scaling down, the clock scale down post change operation
> is doing fine, because it reads the actual clock rate to tell freq, but to
> keep symmetry with clock scale up pre change operation, just use the
> target_freq instead of reading clock rate.
>
> Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> Signed-off-by: Can Guo <quic_cang@quicinc.com>
> ---
> drivers/ufs/host/ufs-qcom.c | 23 ++++++++++++-----------
> 1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index b6eef975dc46..1e8a23eb8c13 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -97,7 +97,7 @@ static const struct __ufs_qcom_bw_table {
> };
>
> static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host);
> -static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, bool is_scale_up);
> +static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, unsigned long freq);
>
> static struct ufs_qcom_host *rcdev_to_ufs_host(struct reset_controller_dev *rcd)
> {
> @@ -524,7 +524,7 @@ static int ufs_qcom_link_startup_notify(struct ufs_hba *hba,
> return -EINVAL;
> }
>
> - err = ufs_qcom_set_core_clk_ctrl(hba, true);
> + err = ufs_qcom_set_core_clk_ctrl(hba, ULONG_MAX);
> if (err)
> dev_err(hba->dev, "cfg core clk ctrl failed\n");
> /*
> @@ -1231,7 +1231,7 @@ static int ufs_qcom_set_clk_40ns_cycles(struct ufs_hba *hba,
> return ufshcd_dme_set(hba, UIC_ARG_MIB(PA_VS_CORE_CLK_40NS_CYCLES), reg);
> }
>
> -static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, bool is_scale_up)
> +static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, unsigned long freq)
> {
> struct ufs_qcom_host *host = ufshcd_get_variant(hba);
> struct list_head *head = &hba->clk_list_head;
> @@ -1245,10 +1245,11 @@ static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, bool is_scale_up)
> !strcmp(clki->name, "core_clk_unipro")) {
> if (!clki->max_freq)
> cycles_in_1us = 150; /* default for backwards compatibility */
> - else if (is_scale_up)
> + else if (freq == ULONG_MAX)
> cycles_in_1us = ceil(clki->max_freq, (1000 * 1000));
> else
> - cycles_in_1us = ceil(clk_get_rate(clki->clk), (1000 * 1000));
> + cycles_in_1us = ceil(freq, (1000 * 1000));
Consider switching to HZ_PER_MHZ in a separate patch later.
- Mani
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 2/8] scsi: ufs: qcom: Pass target_freq to clk scale pre and post change
2025-01-19 7:22 ` Manivannan Sadhasivam
@ 2025-01-20 12:02 ` Ziqi Chen
0 siblings, 0 replies; 23+ messages in thread
From: Ziqi Chen @ 2025-01-20 12:02 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: quic_cang, bvanassche, beanhuo, avri.altman, junwoo80.lee,
martin.petersen, quic_nguyenb, quic_nitirawa, quic_rampraka,
linux-scsi, Manivannan Sadhasivam, James E.J. Bottomley,
open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER...,
open list
Hi Mani,
Thanks for you review~
On 1/19/2025 3:22 PM, Manivannan Sadhasivam wrote:
> On Thu, Jan 16, 2025 at 05:11:43PM +0800, Ziqi Chen wrote:
>> From: Can Guo <quic_cang@quicinc.com>
>>
>> If OPP V2 is used, devfreq clock scaling may scale clock amongst more than
>> two freqs.
>
> Same comment as previous patch.
>
please see my response in previous patch.
>> In the case of scaling up, the devfreq may decide to scale the
>> clock to an intermidiate freq base on load, but the clock scale up pre
>> change operation uses settings for the max clock freq unconditionally. Fix
>> it by passing the target_freq to clock scale up pre change so that the
>> correct settings for the target_freq can be used.
>>
>> In the case of scaling down, the clock scale down post change operation
>> is doing fine, because it reads the actual clock rate to tell freq, but to
>> keep symmetry with clock scale up pre change operation, just use the
>> target_freq instead of reading clock rate.
>>
>> Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
>> Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
>> Signed-off-by: Can Guo <quic_cang@quicinc.com>
>> ---
>> drivers/ufs/host/ufs-qcom.c | 23 ++++++++++++-----------
>> 1 file changed, 12 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
>> index b6eef975dc46..1e8a23eb8c13 100644
>> --- a/drivers/ufs/host/ufs-qcom.c
>> +++ b/drivers/ufs/host/ufs-qcom.c
>> @@ -97,7 +97,7 @@ static const struct __ufs_qcom_bw_table {
>> };
>>
>> static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host);
>> -static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, bool is_scale_up);
>> +static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, unsigned long freq);
>>
>> static struct ufs_qcom_host *rcdev_to_ufs_host(struct reset_controller_dev *rcd)
>> {
>> @@ -524,7 +524,7 @@ static int ufs_qcom_link_startup_notify(struct ufs_hba *hba,
>> return -EINVAL;
>> }
>>
>> - err = ufs_qcom_set_core_clk_ctrl(hba, true);
>> + err = ufs_qcom_set_core_clk_ctrl(hba, ULONG_MAX);
>> if (err)
>> dev_err(hba->dev, "cfg core clk ctrl failed\n");
>> /*
>> @@ -1231,7 +1231,7 @@ static int ufs_qcom_set_clk_40ns_cycles(struct ufs_hba *hba,
>> return ufshcd_dme_set(hba, UIC_ARG_MIB(PA_VS_CORE_CLK_40NS_CYCLES), reg);
>> }
>>
>> -static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, bool is_scale_up)
>> +static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, unsigned long freq)
>> {
>> struct ufs_qcom_host *host = ufshcd_get_variant(hba);
>> struct list_head *head = &hba->clk_list_head;
>> @@ -1245,10 +1245,11 @@ static int ufs_qcom_set_core_clk_ctrl(struct ufs_hba *hba, bool is_scale_up)
>> !strcmp(clki->name, "core_clk_unipro")) {
>> if (!clki->max_freq)
>> cycles_in_1us = 150; /* default for backwards compatibility */
>> - else if (is_scale_up)
>> + else if (freq == ULONG_MAX)
>> cycles_in_1us = ceil(clki->max_freq, (1000 * 1000));
>> else
>> - cycles_in_1us = ceil(clk_get_rate(clki->clk), (1000 * 1000));
>> + cycles_in_1us = ceil(freq, (1000 * 1000));
>
> Consider switching to HZ_PER_MHZ in a separate patch later
Sure, Thanks for suggestion, will update in next version.
>
> - Mani
-Ziqi
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 4/8] scsi: ufs: qcom: Implement the freq_to_gear_speed() vops
[not found] <20250116091150.1167739-1-quic_ziqichen@quicinc.com>
2025-01-16 9:11 ` [PATCH 1/8] scsi: ufs: core: Pass target_freq to clk_scale_notify() vops Ziqi Chen
2025-01-16 9:11 ` [PATCH 2/8] scsi: ufs: qcom: Pass target_freq to clk scale pre and post change Ziqi Chen
@ 2025-01-16 9:11 ` Ziqi Chen
2025-01-16 21:40 ` Avri Altman
2025-01-19 7:30 ` Manivannan Sadhasivam
2025-01-16 9:11 ` [PATCH 8/8] ARM: dts: msm: Use Operation Points V2 for UFS on SM8650 Ziqi Chen
3 siblings, 2 replies; 23+ messages in thread
From: Ziqi Chen @ 2025-01-16 9:11 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-scsi, Manivannan Sadhasivam, James E.J. Bottomley,
open list:ARM/QUALCOMM MAILING LIST, open list
From: Can Guo <quic_cang@quicinc.com>
Implement the freq_to_gear_speed() vops to map the unipro core clock
frequency to the corresponding maximum supported gear speed.
Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Signed-off-by: Can Guo <quic_cang@quicinc.com>
---
drivers/ufs/host/ufs-qcom.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index 1e8a23eb8c13..64263fa884f5 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -1803,6 +1803,37 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
return ret;
}
+static int ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq, u32 *gear)
+{
+ int ret = 0;
+
+ switch (freq) {
+ case 403000000:
+ *gear = UFS_HS_G5;
+ break;
+ case 300000000:
+ *gear = UFS_HS_G4;
+ break;
+ case 201500000:
+ *gear = UFS_HS_G3;
+ break;
+ case 150000000:
+ case 100000000:
+ *gear = UFS_HS_G2;
+ break;
+ case 75000000:
+ case 37500000:
+ *gear = UFS_HS_G1;
+ break;
+ default:
+ ret = -EINVAL;
+ dev_err(hba->dev, "Unsupported clock freq\n");
+ break;
+ }
+
+ return ret;
+}
+
/*
* struct ufs_hba_qcom_vops - UFS QCOM specific variant operations
*
@@ -1833,6 +1864,7 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
.op_runtime_config = ufs_qcom_op_runtime_config,
.get_outstanding_cqs = ufs_qcom_get_outstanding_cqs,
.config_esi = ufs_qcom_config_esi,
+ .freq_to_gear_speed = ufs_qcom_freq_to_gear_speed,
};
/**
--
2.34.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* RE: [PATCH 4/8] scsi: ufs: qcom: Implement the freq_to_gear_speed() vops
2025-01-16 9:11 ` [PATCH 4/8] scsi: ufs: qcom: Implement the freq_to_gear_speed() vops Ziqi Chen
@ 2025-01-16 21:40 ` Avri Altman
2025-01-20 12:04 ` Ziqi Chen
2025-01-19 7:30 ` Manivannan Sadhasivam
1 sibling, 1 reply; 23+ messages in thread
From: Avri Altman @ 2025-01-16 21:40 UTC (permalink / raw)
To: Ziqi Chen, quic_cang@quicinc.com, bvanassche@acm.org,
mani@kernel.org, beanhuo@micron.com, junwoo80.lee@samsung.com,
martin.petersen@oracle.com, quic_nguyenb@quicinc.com,
quic_nitirawa@quicinc.com, quic_rampraka@quicinc.com
Cc: linux-scsi@vger.kernel.org, Manivannan Sadhasivam,
James E.J. Bottomley, open list:ARM/QUALCOMM MAILING LIST,
open list
> From: Can Guo <quic_cang@quicinc.com>
>
> Implement the freq_to_gear_speed() vops to map the unipro core clock
> frequency to the corresponding maximum supported gear speed.
>
> Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> Signed-off-by: Can Guo <quic_cang@quicinc.com>
> ---
> drivers/ufs/host/ufs-qcom.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index
> 1e8a23eb8c13..64263fa884f5 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -1803,6 +1803,37 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
> return ret;
> }
>
> +static int ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned
> +long freq, u32 *gear) {
> + int ret = 0;
> +
> + switch (freq) {
Maybe you can use here the UNIPRO_CORE_CLK_FREQ_xx ?
Thanks,
Avri
> + case 403000000:
> + *gear = UFS_HS_G5;
> + break;
> + case 300000000:
> + *gear = UFS_HS_G4;
> + break;
> + case 201500000:
> + *gear = UFS_HS_G3;
> + break;
> + case 150000000:
> + case 100000000:
> + *gear = UFS_HS_G2;
> + break;
> + case 75000000:
> + case 37500000:
> + *gear = UFS_HS_G1;
> + break;
> + default:
> + ret = -EINVAL;
> + dev_err(hba->dev, "Unsupported clock freq\n");
> + break;
> + }
> +
> + return ret;
> +}
> +
> /*
> * struct ufs_hba_qcom_vops - UFS QCOM specific variant operations
> *
> @@ -1833,6 +1864,7 @@ static const struct ufs_hba_variant_ops
> ufs_hba_qcom_vops = {
> .op_runtime_config = ufs_qcom_op_runtime_config,
> .get_outstanding_cqs = ufs_qcom_get_outstanding_cqs,
> .config_esi = ufs_qcom_config_esi,
> + .freq_to_gear_speed = ufs_qcom_freq_to_gear_speed,
> };
>
> /**
> --
> 2.34.1
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 4/8] scsi: ufs: qcom: Implement the freq_to_gear_speed() vops
2025-01-16 21:40 ` Avri Altman
@ 2025-01-20 12:04 ` Ziqi Chen
0 siblings, 0 replies; 23+ messages in thread
From: Ziqi Chen @ 2025-01-20 12:04 UTC (permalink / raw)
To: Avri Altman, quic_cang@quicinc.com, bvanassche@acm.org,
mani@kernel.org, beanhuo@micron.com, junwoo80.lee@samsung.com,
martin.petersen@oracle.com, quic_nguyenb@quicinc.com,
quic_nitirawa@quicinc.com, quic_rampraka@quicinc.com
Cc: linux-scsi@vger.kernel.org, Manivannan Sadhasivam,
James E.J. Bottomley, open list:ARM/QUALCOMM MAILING LIST,
open list
Hi Avri,
Thanks for your review~
On 1/17/2025 5:40 AM, Avri Altman wrote:
>> From: Can Guo <quic_cang@quicinc.com>
>>
>> Implement the freq_to_gear_speed() vops to map the unipro core clock
>> frequency to the corresponding maximum supported gear speed.
>>
>> Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
>> Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
>> Signed-off-by: Can Guo <quic_cang@quicinc.com>
>> ---
>> drivers/ufs/host/ufs-qcom.c | 32 ++++++++++++++++++++++++++++++++
>> 1 file changed, 32 insertions(+)
>>
>> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index
>> 1e8a23eb8c13..64263fa884f5 100644
>> --- a/drivers/ufs/host/ufs-qcom.c
>> +++ b/drivers/ufs/host/ufs-qcom.c
>> @@ -1803,6 +1803,37 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
>> return ret;
>> }
>>
>> +static int ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned
>> +long freq, u32 *gear) {
>> + int ret = 0;
>> +
>> + switch (freq) {
> Maybe you can use here the UNIPRO_CORE_CLK_FREQ_xx
The UNIPRO_CORE_CLK_FREQ_xx is used for "cycles_in_1us" which be handled
by ceil() function. It is not an exact frequency number and is not
appropriate for use here.
>
> Thanks,
> Avri
-Ziqi
>> + case 403000000:
>> + *gear = UFS_HS_G5;
>> + break;
>> + case 300000000:
>> + *gear = UFS_HS_G4;
>> + break;
>> + case 201500000:
>> + *gear = UFS_HS_G3;
>> + break;
>> + case 150000000:
>> + case 100000000:
>> + *gear = UFS_HS_G2;
>> + break;
>> + case 75000000:
>> + case 37500000:
>> + *gear = UFS_HS_G1;
>> + break;
>> + default:
>> + ret = -EINVAL;
>> + dev_err(hba->dev, "Unsupported clock freq\n");
>> + break;
>> + }
>> +
>> + return ret;
>> +}
>> +
>> /*
>> * struct ufs_hba_qcom_vops - UFS QCOM specific variant operations
>> *
>> @@ -1833,6 +1864,7 @@ static const struct ufs_hba_variant_ops
>> ufs_hba_qcom_vops = {
>> .op_runtime_config = ufs_qcom_op_runtime_config,
>> .get_outstanding_cqs = ufs_qcom_get_outstanding_cqs,
>> .config_esi = ufs_qcom_config_esi,
>> + .freq_to_gear_speed = ufs_qcom_freq_to_gear_speed,
>> };
>>
>> /**
>> --
>> 2.34.1
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 4/8] scsi: ufs: qcom: Implement the freq_to_gear_speed() vops
2025-01-16 9:11 ` [PATCH 4/8] scsi: ufs: qcom: Implement the freq_to_gear_speed() vops Ziqi Chen
2025-01-16 21:40 ` Avri Altman
@ 2025-01-19 7:30 ` Manivannan Sadhasivam
2025-01-20 12:07 ` Ziqi Chen
1 sibling, 1 reply; 23+ messages in thread
From: Manivannan Sadhasivam @ 2025-01-19 7:30 UTC (permalink / raw)
To: Ziqi Chen
Cc: quic_cang, bvanassche, beanhuo, avri.altman, junwoo80.lee,
martin.petersen, quic_nguyenb, quic_nitirawa, quic_rampraka,
linux-scsi, Manivannan Sadhasivam, James E.J. Bottomley,
open list:ARM/QUALCOMM MAILING LIST, open list
On Thu, Jan 16, 2025 at 05:11:45PM +0800, Ziqi Chen wrote:
> From: Can Guo <quic_cang@quicinc.com>
>
> Implement the freq_to_gear_speed() vops to map the unipro core clock
> frequency to the corresponding maximum supported gear speed.
>
> Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> Signed-off-by: Can Guo <quic_cang@quicinc.com>
> ---
> drivers/ufs/host/ufs-qcom.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index 1e8a23eb8c13..64263fa884f5 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -1803,6 +1803,37 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
> return ret;
> }
>
> +static int ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq, u32 *gear)
> +{
> + int ret = 0;
Please do not initialize ret with 0. Return the actual value directly.
> +
> + switch (freq) {
> + case 403000000:
> + *gear = UFS_HS_G5;
> + break;
> + case 300000000:
> + *gear = UFS_HS_G4;
> + break;
> + case 201500000:
> + *gear = UFS_HS_G3;
> + break;
> + case 150000000:
> + case 100000000:
> + *gear = UFS_HS_G2;
> + break;
> + case 75000000:
> + case 37500000:
> + *gear = UFS_HS_G1;
> + break;
> + default:
> + ret = -EINVAL;
> + dev_err(hba->dev, "Unsupported clock freq\n");
Print the freq.
- Mani
> + break;
> + }
> +
> + return ret;
> +}
> +
> /*
> * struct ufs_hba_qcom_vops - UFS QCOM specific variant operations
> *
> @@ -1833,6 +1864,7 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
> .op_runtime_config = ufs_qcom_op_runtime_config,
> .get_outstanding_cqs = ufs_qcom_get_outstanding_cqs,
> .config_esi = ufs_qcom_config_esi,
> + .freq_to_gear_speed = ufs_qcom_freq_to_gear_speed,
> };
>
> /**
> --
> 2.34.1
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 4/8] scsi: ufs: qcom: Implement the freq_to_gear_speed() vops
2025-01-19 7:30 ` Manivannan Sadhasivam
@ 2025-01-20 12:07 ` Ziqi Chen
2025-01-20 15:41 ` Manivannan Sadhasivam
0 siblings, 1 reply; 23+ messages in thread
From: Ziqi Chen @ 2025-01-20 12:07 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: quic_cang, bvanassche, beanhuo, avri.altman, junwoo80.lee,
martin.petersen, quic_nguyenb, quic_nitirawa, quic_rampraka,
linux-scsi, Manivannan Sadhasivam, James E.J. Bottomley,
open list:ARM/QUALCOMM MAILING LIST, open list
Hi Mani,
Thanks for your comments~
On 1/19/2025 3:30 PM, Manivannan Sadhasivam wrote:
> On Thu, Jan 16, 2025 at 05:11:45PM +0800, Ziqi Chen wrote:
>> From: Can Guo <quic_cang@quicinc.com>
>>
>> Implement the freq_to_gear_speed() vops to map the unipro core clock
>> frequency to the corresponding maximum supported gear speed.
>>
>> Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
>> Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
>> Signed-off-by: Can Guo <quic_cang@quicinc.com>
>> ---
>> drivers/ufs/host/ufs-qcom.c | 32 ++++++++++++++++++++++++++++++++
>> 1 file changed, 32 insertions(+)
>>
>> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
>> index 1e8a23eb8c13..64263fa884f5 100644
>> --- a/drivers/ufs/host/ufs-qcom.c
>> +++ b/drivers/ufs/host/ufs-qcom.c
>> @@ -1803,6 +1803,37 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
>> return ret;
>> }
>>
>> +static int ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq, u32 *gear)
>> +{
>> + int ret = 0 >
> Please do not initialize ret with 0. Return the actual value directly.
>
If we don't initialize ret here, for the cases of freq matched in the
table, it will return an unknown ret value. It is not make sense, right?
Or you may want to say we don't need “ret” , just need to return gear
value? But we need this "ret" to check whether the freq is invalid.
>> +
>> + switch (freq) {
>> + case 403000000:
>> + *gear = UFS_HS_G5;
>> + break;
>> + case 300000000:
>> + *gear = UFS_HS_G4;
>> + break;
>> + case 201500000:
>> + *gear = UFS_HS_G3;
>> + break;
>> + case 150000000:
>> + case 100000000:
>> + *gear = UFS_HS_G2;
>> + break;
>> + case 75000000:
>> + case 37500000:
>> + *gear = UFS_HS_G1;
>> + break;
>> + default:
>> + ret = -EINVAL;
>> + dev_err(hba->dev, "Unsupported clock freq\n");
>
> Print the freq.
Ok, thank for your suggestion, we can print freq with dev_dbg() in next
version.
>
> - Mani >
-Ziqi
>> + break;
>> + }
>> +
>> + return ret;
>> +}
>> +
>> /*
>> * struct ufs_hba_qcom_vops - UFS QCOM specific variant operations
>> *
>> @@ -1833,6 +1864,7 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
>> .op_runtime_config = ufs_qcom_op_runtime_config,
>> .get_outstanding_cqs = ufs_qcom_get_outstanding_cqs,
>> .config_esi = ufs_qcom_config_esi,
>> + .freq_to_gear_speed = ufs_qcom_freq_to_gear_speed,
>> };
>>
>> /**
>> --
>> 2.34.1
>>
>
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 4/8] scsi: ufs: qcom: Implement the freq_to_gear_speed() vops
2025-01-20 12:07 ` Ziqi Chen
@ 2025-01-20 15:41 ` Manivannan Sadhasivam
2025-01-21 3:52 ` Ziqi Chen
0 siblings, 1 reply; 23+ messages in thread
From: Manivannan Sadhasivam @ 2025-01-20 15:41 UTC (permalink / raw)
To: Ziqi Chen
Cc: quic_cang, bvanassche, beanhuo, avri.altman, junwoo80.lee,
martin.petersen, quic_nguyenb, quic_nitirawa, quic_rampraka,
linux-scsi, Manivannan Sadhasivam, James E.J. Bottomley,
open list:ARM/QUALCOMM MAILING LIST, open list
On Mon, Jan 20, 2025 at 08:07:07PM +0800, Ziqi Chen wrote:
> Hi Mani,
>
> Thanks for your comments~
>
> On 1/19/2025 3:30 PM, Manivannan Sadhasivam wrote:
> > On Thu, Jan 16, 2025 at 05:11:45PM +0800, Ziqi Chen wrote:
> > > From: Can Guo <quic_cang@quicinc.com>
> > >
> > > Implement the freq_to_gear_speed() vops to map the unipro core clock
> > > frequency to the corresponding maximum supported gear speed.
> > >
> > > Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> > > Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> > > Signed-off-by: Can Guo <quic_cang@quicinc.com>
> > > ---
> > > drivers/ufs/host/ufs-qcom.c | 32 ++++++++++++++++++++++++++++++++
> > > 1 file changed, 32 insertions(+)
> > >
> > > diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> > > index 1e8a23eb8c13..64263fa884f5 100644
> > > --- a/drivers/ufs/host/ufs-qcom.c
> > > +++ b/drivers/ufs/host/ufs-qcom.c
> > > @@ -1803,6 +1803,37 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
> > > return ret;
> > > }
> > > +static int ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq, u32 *gear)
> > > +{
> > > + int ret = 0 >
> > Please do not initialize ret with 0. Return the actual value directly.
> >
>
> If we don't initialize ret here, for the cases of freq matched in the table,
> it will return an unknown ret value. It is not make sense, right?
>
> Or you may want to say we don't need “ret” , just need to return gear value?
> But we need this "ret" to check whether the freq is invalid.
>
I meant to say that you can just return 0 directly in success case and -EINVAL
in the case of error.
> > > +
> > > + switch (freq) {
> > > + case 403000000:
> > > + *gear = UFS_HS_G5;
> > > + break;
> > > + case 300000000:
> > > + *gear = UFS_HS_G4;
> > > + break;
> > > + case 201500000:
> > > + *gear = UFS_HS_G3;
> > > + break;
> > > + case 150000000:
> > > + case 100000000:
> > > + *gear = UFS_HS_G2;
> > > + break;
> > > + case 75000000:
> > > + case 37500000:
> > > + *gear = UFS_HS_G1;
> > > + break;
> > > + default:
> > > + ret = -EINVAL;
> > > + dev_err(hba->dev, "Unsupported clock freq\n");
> >
> > Print the freq.
>
> Ok, thank for your suggestion, we can print freq with dev_dbg() in next
> version.
>
No, use dev_err() with the freq.
- Mani
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 4/8] scsi: ufs: qcom: Implement the freq_to_gear_speed() vops
2025-01-20 15:41 ` Manivannan Sadhasivam
@ 2025-01-21 3:52 ` Ziqi Chen
2025-01-24 5:35 ` Manivannan Sadhasivam
0 siblings, 1 reply; 23+ messages in thread
From: Ziqi Chen @ 2025-01-21 3:52 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: quic_cang, bvanassche, beanhuo, avri.altman, junwoo80.lee,
martin.petersen, quic_nguyenb, quic_nitirawa, quic_rampraka,
linux-scsi, Manivannan Sadhasivam, James E.J. Bottomley,
open list:ARM/QUALCOMM MAILING LIST, open list
On 1/20/2025 11:41 PM, Manivannan Sadhasivam wrote:
> On Mon, Jan 20, 2025 at 08:07:07PM +0800, Ziqi Chen wrote:
>> Hi Mani,
>>
>> Thanks for your comments~
>>
>> On 1/19/2025 3:30 PM, Manivannan Sadhasivam wrote:
>>> On Thu, Jan 16, 2025 at 05:11:45PM +0800, Ziqi Chen wrote:
>>>> From: Can Guo <quic_cang@quicinc.com>
>>>>
>>>> Implement the freq_to_gear_speed() vops to map the unipro core clock
>>>> frequency to the corresponding maximum supported gear speed.
>>>>
>>>> Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
>>>> Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
>>>> Signed-off-by: Can Guo <quic_cang@quicinc.com>
>>>> ---
>>>> drivers/ufs/host/ufs-qcom.c | 32 ++++++++++++++++++++++++++++++++
>>>> 1 file changed, 32 insertions(+)
>>>>
>>>> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
>>>> index 1e8a23eb8c13..64263fa884f5 100644
>>>> --- a/drivers/ufs/host/ufs-qcom.c
>>>> +++ b/drivers/ufs/host/ufs-qcom.c
>>>> @@ -1803,6 +1803,37 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
>>>> return ret;
>>>> }
>>>> +static int ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq, u32 *gear)
>>>> +{
>>>> + int ret = 0 >
>>> Please do not initialize ret with 0. Return the actual value directly.
>>>
>>
>> If we don't initialize ret here, for the cases of freq matched in the table,
>> it will return an unknown ret value. It is not make sense, right?
>>
>> Or you may want to say we don't need “ret” , just need to return gear value?
>> But we need this "ret" to check whether the freq is invalid.
>>
>
> I meant to say that you can just return 0 directly in success case and -EINVAL
> in the case of error.
>
Hi Mani,
If we don't print freq here , I think your suggestion is very good. If
we print freq in this function , using "ret" to indicate success case
and failure case and print freq an the end of this function is the way
to avoid code bloat.
How do you think about it?
>>>> +
>>>> + switch (freq) {
>>>> + case 403000000:
>>>> + *gear = UFS_HS_G5;
>>>> + break;
>>>> + case 300000000:
>>>> + *gear = UFS_HS_G4;
>>>> + break;
>>>> + case 201500000:
>>>> + *gear = UFS_HS_G3;
>>>> + break;
>>>> + case 150000000:
>>>> + case 100000000:
>>>> + *gear = UFS_HS_G2;
>>>> + break;
>>>> + case 75000000:
>>>> + case 37500000:
>>>> + *gear = UFS_HS_G1;
>>>> + break;
>>>> + default:
>>>> + ret = -EINVAL;
>>>> + dev_err(hba->dev, "Unsupported clock freq\n");
>>>
>>> Print the freq.
>>
>> Ok, thank for your suggestion, we can print freq with dev_dbg() in next
>> version.
>>
>
> No, use dev_err() with the freq. >
> - Mani
>
I think use dev_err() here does not make sense:
1. This print is not an error message , just an information print. Using
dev_err() reduces the readability of this code.
2. This prints will be print very frequent, I afraid it will increase
the latency of clock scaling.
How do you think ?
-Ziqi
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 4/8] scsi: ufs: qcom: Implement the freq_to_gear_speed() vops
2025-01-21 3:52 ` Ziqi Chen
@ 2025-01-24 5:35 ` Manivannan Sadhasivam
2025-01-24 9:34 ` Ziqi Chen
0 siblings, 1 reply; 23+ messages in thread
From: Manivannan Sadhasivam @ 2025-01-24 5:35 UTC (permalink / raw)
To: Ziqi Chen
Cc: Manivannan Sadhasivam, quic_cang, bvanassche, beanhuo,
avri.altman, junwoo80.lee, martin.petersen, quic_nguyenb,
quic_nitirawa, quic_rampraka, linux-scsi, James E.J. Bottomley,
open list:ARM/QUALCOMM MAILING LIST, open list
On Tue, Jan 21, 2025 at 11:52:42AM +0800, Ziqi Chen wrote:
>
>
> On 1/20/2025 11:41 PM, Manivannan Sadhasivam wrote:
> > On Mon, Jan 20, 2025 at 08:07:07PM +0800, Ziqi Chen wrote:
> > > Hi Mani,
> > >
> > > Thanks for your comments~
> > >
> > > On 1/19/2025 3:30 PM, Manivannan Sadhasivam wrote:
> > > > On Thu, Jan 16, 2025 at 05:11:45PM +0800, Ziqi Chen wrote:
> > > > > From: Can Guo <quic_cang@quicinc.com>
> > > > >
> > > > > Implement the freq_to_gear_speed() vops to map the unipro core clock
> > > > > frequency to the corresponding maximum supported gear speed.
> > > > >
> > > > > Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> > > > > Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
> > > > > Signed-off-by: Can Guo <quic_cang@quicinc.com>
> > > > > ---
> > > > > drivers/ufs/host/ufs-qcom.c | 32 ++++++++++++++++++++++++++++++++
> > > > > 1 file changed, 32 insertions(+)
> > > > >
> > > > > diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> > > > > index 1e8a23eb8c13..64263fa884f5 100644
> > > > > --- a/drivers/ufs/host/ufs-qcom.c
> > > > > +++ b/drivers/ufs/host/ufs-qcom.c
> > > > > @@ -1803,6 +1803,37 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
> > > > > return ret;
> > > > > }
> > > > > +static int ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq, u32 *gear)
> > > > > +{
> > > > > + int ret = 0 >
> > > > Please do not initialize ret with 0. Return the actual value directly.
> > > >
> > >
> > > If we don't initialize ret here, for the cases of freq matched in the table,
> > > it will return an unknown ret value. It is not make sense, right?
> > >
> > > Or you may want to say we don't need “ret” , just need to return gear value?
> > > But we need this "ret" to check whether the freq is invalid.
> > >
> >
> > I meant to say that you can just return 0 directly in success case and -EINVAL
> > in the case of error.
> >
> Hi Mani,
>
> If we don't print freq here , I think your suggestion is very good. If we
> print freq in this function , using "ret" to indicate success case and
> failure case and print freq an the end of this function is the way to avoid
> code bloat.
>
> How do you think about it?
>
I don't understand how code bloat comes into picture here. I'm just asking for
this:
static int ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq, u32 *gear)
{
switch (freq) {
case 403000000:
*gear = UFS_HS_G5;
break;
...
default:
dev_err(hba->dev, "Unsupported clock freq: %ld\n", freq);
return -EINVAL;
}
return 0;
}
> > > > > +
> > > > > + switch (freq) {
> > > > > + case 403000000:
> > > > > + *gear = UFS_HS_G5;
> > > > > + break;
> > > > > + case 300000000:
> > > > > + *gear = UFS_HS_G4;
> > > > > + break;
> > > > > + case 201500000:
> > > > > + *gear = UFS_HS_G3;
> > > > > + break;
> > > > > + case 150000000:
> > > > > + case 100000000:
> > > > > + *gear = UFS_HS_G2;
> > > > > + break;
> > > > > + case 75000000:
> > > > > + case 37500000:
> > > > > + *gear = UFS_HS_G1;
> > > > > + break;
> > > > > + default:
> > > > > + ret = -EINVAL;
> > > > > + dev_err(hba->dev, "Unsupported clock freq\n");
> > > >
> > > > Print the freq.
> > >
> > > Ok, thank for your suggestion, we can print freq with dev_dbg() in next
> > > version.
> > >
> >
> > No, use dev_err() with the freq. >
> > - Mani
> >
> I think use dev_err() here does not make sense:
>
> 1. This print is not an error message , just an information print. Using
> dev_err() reduces the readability of this code.
Then why it was dev_err() in the first place?
> 2. This prints will be print very frequent, I afraid it will increase the
> latency of clock scaling.
>
First you need to decide whether this print should warn user or not. It is
telling users that the OPP table supplied a frequency that doesn't match the
gear speed. This can happen if there is a discrepancy between DT and the driver.
In that case, the users *should* be warned to fix the driver/DT. If you bury it
with dev_dbg(), no one will notice it.
If your concern is with the frequency of logs, then use dev_err_ratelimited().
- Mani
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 4/8] scsi: ufs: qcom: Implement the freq_to_gear_speed() vops
2025-01-24 5:35 ` Manivannan Sadhasivam
@ 2025-01-24 9:34 ` Ziqi Chen
0 siblings, 0 replies; 23+ messages in thread
From: Ziqi Chen @ 2025-01-24 9:34 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: Manivannan Sadhasivam, quic_cang, bvanassche, beanhuo,
avri.altman, junwoo80.lee, martin.petersen, quic_nguyenb,
quic_nitirawa, quic_rampraka, linux-scsi, James E.J. Bottomley,
open list:ARM/QUALCOMM MAILING LIST, open list
On 1/24/2025 1:35 PM, Manivannan Sadhasivam wrote:
> On Tue, Jan 21, 2025 at 11:52:42AM +0800, Ziqi Chen wrote:
>>
>>
>> On 1/20/2025 11:41 PM, Manivannan Sadhasivam wrote:
>>> On Mon, Jan 20, 2025 at 08:07:07PM +0800, Ziqi Chen wrote:
>>>> Hi Mani,
>>>>
>>>> Thanks for your comments~
>>>>
>>>> On 1/19/2025 3:30 PM, Manivannan Sadhasivam wrote:
>>>>> On Thu, Jan 16, 2025 at 05:11:45PM +0800, Ziqi Chen wrote:
>>>>>> From: Can Guo <quic_cang@quicinc.com>
>>>>>>
>>>>>> Implement the freq_to_gear_speed() vops to map the unipro core clock
>>>>>> frequency to the corresponding maximum supported gear speed.
>>>>>>
>>>>>> Co-developed-by: Ziqi Chen <quic_ziqichen@quicinc.com>
>>>>>> Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
>>>>>> Signed-off-by: Can Guo <quic_cang@quicinc.com>
>>>>>> ---
>>>>>> drivers/ufs/host/ufs-qcom.c | 32 ++++++++++++++++++++++++++++++++
>>>>>> 1 file changed, 32 insertions(+)
>>>>>>
>>>>>> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
>>>>>> index 1e8a23eb8c13..64263fa884f5 100644
>>>>>> --- a/drivers/ufs/host/ufs-qcom.c
>>>>>> +++ b/drivers/ufs/host/ufs-qcom.c
>>>>>> @@ -1803,6 +1803,37 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
>>>>>> return ret;
>>>>>> }
>>>>>> +static int ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq, u32 *gear)
>>>>>> +{
>>>>>> + int ret = 0 >
>>>>> Please do not initialize ret with 0. Return the actual value directly.
>>>>>
>>>>
>>>> If we don't initialize ret here, for the cases of freq matched in the table,
>>>> it will return an unknown ret value. It is not make sense, right?
>>>>
>>>> Or you may want to say we don't need “ret” , just need to return gear value?
>>>> But we need this "ret" to check whether the freq is invalid.
>>>>
>>>
>>> I meant to say that you can just return 0 directly in success case and -EINVAL
>>> in the case of error.
>>>
>> Hi Mani,
>>
>> If we don't print freq here , I think your suggestion is very good. If we
>> print freq in this function , using "ret" to indicate success case and
>> failure case and print freq an the end of this function is the way to avoid
>> code bloat.
>>
>> How do you think about it?
>>
>
> I don't understand how code bloat comes into picture here. I'm just asking for
> this:
>
> static int ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq, u32 *gear)
> {
> switch (freq) {
> case 403000000:
> *gear = UFS_HS_G5;
> break;
> ...
>
> default:
> dev_err(hba->dev, "Unsupported clock freq: %ld\n", freq);
> return -EINVAL;
> }
>
> return 0;
> }
>
>>>>>> +
>>>>>> + switch (freq) {
>>>>>> + case 403000000:
>>>>>> + *gear = UFS_HS_G5;
>>>>>> + break;
>>>>>> + case 300000000:
>>>>>> + *gear = UFS_HS_G4;
>>>>>> + break;
>>>>>> + case 201500000:
>>>>>> + *gear = UFS_HS_G3;
>>>>>> + break;
>>>>>> + case 150000000:
>>>>>> + case 100000000:
>>>>>> + *gear = UFS_HS_G2;
>>>>>> + break;
>>>>>> + case 75000000:
>>>>>> + case 37500000:
>>>>>> + *gear = UFS_HS_G1;
>>>>>> + break;
>>>>>> + default:
>>>>>> + ret = -EINVAL;
>>>>>> + dev_err(hba->dev, "Unsupported clock freq\n");
>>>>>
>>>>> Print the freq.
>>>>
>>>> Ok, thank for your suggestion, we can print freq with dev_dbg() in next
>>>> version.
>>>>
>>>
>>> No, use dev_err() with the freq. >
>>> - Mani
>>>
>> I think use dev_err() here does not make sense:
>>
>> 1. This print is not an error message , just an information print. Using
>> dev_err() reduces the readability of this code.
>
> Then why it was dev_err() in the first place?
>
>> 2. This prints will be print very frequent, I afraid it will increase the
>> latency of clock scaling.
>>
>
> First you need to decide whether this print should warn user or not. It is
> telling users that the OPP table supplied a frequency that doesn't match the
> gear speed. This can happen if there is a discrepancy between DT and the driver.
> In that case, the users *should* be warned to fix the driver/DT. If you bury it
> with dev_dbg(), no one will notice it.
>
> If your concern is with the frequency of logs, then use dev_err_ratelimited().
>
> - Mani
>
I misunderstand your point Mani, I thought you want me to print freq for
all cases... if you mean that print failure case, I already added it in
patch V2.
-Ziqi
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 8/8] ARM: dts: msm: Use Operation Points V2 for UFS on SM8650
[not found] <20250116091150.1167739-1-quic_ziqichen@quicinc.com>
` (2 preceding siblings ...)
2025-01-16 9:11 ` [PATCH 4/8] scsi: ufs: qcom: Implement the freq_to_gear_speed() vops Ziqi Chen
@ 2025-01-16 9:11 ` Ziqi Chen
2025-01-16 9:22 ` Krzysztof Kozlowski
2025-01-16 9:24 ` neil.armstrong
3 siblings, 2 replies; 23+ messages in thread
From: Ziqi Chen @ 2025-01-16 9:11 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-scsi, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, open list:ARM/QUALCOMM SUPPORT,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list
Use Operation Points V2 for UFS on SM8650 so that multi-level
clock/gear scaling can be possible.
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>
---
arch/arm64/boot/dts/qcom/sm8650.dtsi | 51 +++++++++++++++++++++++-----
1 file changed, 43 insertions(+), 8 deletions(-)
diff --git a/arch/arm64/boot/dts/qcom/sm8650.dtsi b/arch/arm64/boot/dts/qcom/sm8650.dtsi
index 01ac3769ffa6..5466f1217f64 100644
--- a/arch/arm64/boot/dts/qcom/sm8650.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8650.dtsi
@@ -2557,18 +2557,11 @@ ufs_mem_hc: ufs@1d84000 {
"tx_lane0_sync_clk",
"rx_lane0_sync_clk",
"rx_lane1_sync_clk";
- freq-table-hz = <100000000 403000000>,
- <0 0>,
- <0 0>,
- <100000000 403000000>,
- <100000000 403000000>,
- <0 0>,
- <0 0>,
- <0 0>;
resets = <&gcc GCC_UFS_PHY_BCR>;
reset-names = "rst";
+ operating-points-v2 = <&ufs_opp_table>;
interconnects = <&aggre1_noc MASTER_UFS_MEM QCOM_ICC_TAG_ALWAYS
&mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>,
<&gem_noc MASTER_APPSS_PROC QCOM_ICC_TAG_ALWAYS
@@ -2590,6 +2583,48 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>,
#reset-cells = <1>;
status = "disabled";
+
+ ufs_opp_table: opp-table {
+ compatible = "operating-points-v2";
+ // LOW_SVS
+ opp-100000000 {
+ opp-hz = /bits/ 64 <100000000>,
+ /bits/ 64 <0>,
+ /bits/ 64 <0>,
+ /bits/ 64 <100000000>,
+ /bits/ 64 <0>,
+ /bits/ 64 <0>,
+ /bits/ 64 <0>,
+ /bits/ 64 <0>;
+ required-opps = <&rpmhpd_opp_low_svs>;
+ };
+
+ // SVS
+ opp-201500000 {
+ opp-hz = /bits/ 64 <201500000>,
+ /bits/ 64 <0>,
+ /bits/ 64 <0>,
+ /bits/ 64 <201500000>,
+ /bits/ 64 <0>,
+ /bits/ 64 <0>,
+ /bits/ 64 <0>,
+ /bits/ 64 <0>;
+ required-opps = <&rpmhpd_opp_svs>;
+ };
+
+ // NOM/TURBO
+ opp-403000000 {
+ opp-hz = /bits/ 64 <403000000>,
+ /bits/ 64 <0>,
+ /bits/ 64 <0>,
+ /bits/ 64 <403000000>,
+ /bits/ 64 <0>,
+ /bits/ 64 <0>,
+ /bits/ 64 <0>,
+ /bits/ 64 <0>;
+ required-opps = <&rpmhpd_opp_nom>;
+ };
+ };
};
ice: crypto@1d88000 {
--
2.34.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 8/8] ARM: dts: msm: Use Operation Points V2 for UFS on SM8650
2025-01-16 9:11 ` [PATCH 8/8] ARM: dts: msm: Use Operation Points V2 for UFS on SM8650 Ziqi Chen
@ 2025-01-16 9:22 ` Krzysztof Kozlowski
2025-01-20 12:12 ` Ziqi Chen
2025-01-16 9:24 ` neil.armstrong
1 sibling, 1 reply; 23+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-16 9:22 UTC (permalink / raw)
To: Ziqi Chen, quic_cang, bvanassche, mani, beanhuo, avri.altman,
junwoo80.lee, martin.petersen, quic_nguyenb, quic_nitirawa,
quic_rampraka
Cc: linux-scsi, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, open list:ARM/QUALCOMM SUPPORT,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list
On 16/01/2025 10:11, Ziqi Chen wrote:
> Use Operation Points V2 for UFS on SM8650 so that multi-level
> clock/gear scaling can be possible.
>
> 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>
Please don't send downstream code directly, but fix it first. Actually -
rework it 100%.
Please use subject prefixes matching the subsystem. You can get them for
example with `git log --oneline -- DIRECTORY_OR_FILE` on the directory
your patch is touching. For bindings, the preferred subjects are
explained here:
https://www.kernel.org/doc/html/latest/devicetree/bindings/submitting-patches.html#i-for-patch-submitters
> ---
> arch/arm64/boot/dts/qcom/sm8650.dtsi | 51 +++++++++++++++++++++++-----
> 1 file changed, 43 insertions(+), 8 deletions(-)
>
> diff --git a/arch/arm64/boot/dts/qcom/sm8650.dtsi b/arch/arm64/boot/dts/qcom/sm8650.dtsi
> index 01ac3769ffa6..5466f1217f64 100644
> --- a/arch/arm64/boot/dts/qcom/sm8650.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sm8650.dtsi
> @@ -2557,18 +2557,11 @@ ufs_mem_hc: ufs@1d84000 {
> "tx_lane0_sync_clk",
> "rx_lane0_sync_clk",
> "rx_lane1_sync_clk";
> - freq-table-hz = <100000000 403000000>,
> - <0 0>,
> - <0 0>,
> - <100000000 403000000>,
> - <100000000 403000000>,
> - <0 0>,
> - <0 0>,
> - <0 0>;
>
> resets = <&gcc GCC_UFS_PHY_BCR>;
> reset-names = "rst";
>
> + operating-points-v2 = <&ufs_opp_table>;
> interconnects = <&aggre1_noc MASTER_UFS_MEM QCOM_ICC_TAG_ALWAYS
> &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>,
> <&gem_noc MASTER_APPSS_PROC QCOM_ICC_TAG_ALWAYS
> @@ -2590,6 +2583,48 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>,
> #reset-cells = <1>;
>
> status = "disabled";
> +
> + ufs_opp_table: opp-table {
> + compatible = "operating-points-v2";
Messed indentation.
> + // LOW_SVS
Drop
> + opp-100000000 {
> + opp-hz = /bits/ 64 <100000000>,
> + /bits/ 64 <0>,
Messed alignment.
> + /bits/ 64 <0>,
> + /bits/ 64 <100000000>,
> + /bits/ 64 <0>,
> + /bits/ 64 <0>,
> + /bits/ 64 <0>,
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 8/8] ARM: dts: msm: Use Operation Points V2 for UFS on SM8650
2025-01-16 9:22 ` Krzysztof Kozlowski
@ 2025-01-20 12:12 ` Ziqi Chen
0 siblings, 0 replies; 23+ messages in thread
From: Ziqi Chen @ 2025-01-20 12:12 UTC (permalink / raw)
To: Krzysztof Kozlowski, quic_cang, bvanassche, mani, beanhuo,
avri.altman, junwoo80.lee, martin.petersen, quic_nguyenb,
quic_nitirawa, quic_rampraka
Cc: linux-scsi, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, open list:ARM/QUALCOMM SUPPORT,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list
Hi Krzysztof,
Thanks for review and comments~
As Neil has submitted a similar patch:
https://lore.kernel.org/all/20250115-topic-sm8x50-upstream-dt-icc-update-v1-10-eaa8b10e2af7@linaro.org/
I will withdraw this patch in next version.
-Ziqi
On 1/16/2025 5:22 PM, Krzysztof Kozlowski wrote:
> On 16/01/2025 10:11, Ziqi Chen wrote:
>> Use Operation Points V2 for UFS on SM8650 so that multi-level
>> clock/gear scaling can be possible.
>>
>> 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>
>
> Please don't send downstream code directly, but fix it first. Actually -
> rework it 100%.
>
> Please use subject prefixes matching the subsystem. You can get them for
> example with `git log --oneline -- DIRECTORY_OR_FILE` on the directory
> your patch is touching. For bindings, the preferred subjects are
> explained here:
> https://www.kernel.org/doc/html/latest/devicetree/bindings/submitting-patches.html#i-for-patch-submitters
> >> ---
>> arch/arm64/boot/dts/qcom/sm8650.dtsi | 51 +++++++++++++++++++++++-----
>> 1 file changed, 43 insertions(+), 8 deletions(-)
>>
>> diff --git a/arch/arm64/boot/dts/qcom/sm8650.dtsi b/arch/arm64/boot/dts/qcom/sm8650.dtsi
>> index 01ac3769ffa6..5466f1217f64 100644
>> --- a/arch/arm64/boot/dts/qcom/sm8650.dtsi
>> +++ b/arch/arm64/boot/dts/qcom/sm8650.dtsi
>> @@ -2557,18 +2557,11 @@ ufs_mem_hc: ufs@1d84000 {
>> "tx_lane0_sync_clk",
>> "rx_lane0_sync_clk",
>> "rx_lane1_sync_clk";
>> - freq-table-hz = <100000000 403000000>,
>> - <0 0>,
>> - <0 0>,
>> - <100000000 403000000>,
>> - <100000000 403000000>,
>> - <0 0>,
>> - <0 0>,
>> - <0 0>;
>>
>> resets = <&gcc GCC_UFS_PHY_BCR>;
>> reset-names = "rst";
>>
>> + operating-points-v2 = <&ufs_opp_table>;
>> interconnects = <&aggre1_noc MASTER_UFS_MEM QCOM_ICC_TAG_ALWAYS
>> &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>,
>> <&gem_noc MASTER_APPSS_PROC QCOM_ICC_TAG_ALWAYS
>> @@ -2590,6 +2583,48 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>,
>> #reset-cells = <1>;
>>
>> status = "disabled";
>> +
>> + ufs_opp_table: opp-table {
>> + compatible = "operating-points-v2";
>
>
> Messed indentation.
>
>> + // LOW_SVS
>
>
> Drop
>
>> + opp-100000000 {
>> + opp-hz = /bits/ 64 <100000000>,
>> + /bits/ 64 <0>,
>
> Messed alignment.
>
>> + /bits/ 64 <0>,
>> + /bits/ 64 <100000000>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <0>,
>
>
>
>
> Best regards,
> Krzysztof
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 8/8] ARM: dts: msm: Use Operation Points V2 for UFS on SM8650
2025-01-16 9:11 ` [PATCH 8/8] ARM: dts: msm: Use Operation Points V2 for UFS on SM8650 Ziqi Chen
2025-01-16 9:22 ` Krzysztof Kozlowski
@ 2025-01-16 9:24 ` neil.armstrong
2025-01-20 12:13 ` Ziqi Chen
1 sibling, 1 reply; 23+ messages in thread
From: neil.armstrong @ 2025-01-16 9:24 UTC (permalink / raw)
To: Ziqi Chen, quic_cang, bvanassche, mani, beanhuo, avri.altman,
junwoo80.lee, martin.petersen, quic_nguyenb, quic_nitirawa,
quic_rampraka
Cc: linux-scsi, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, open list:ARM/QUALCOMM SUPPORT,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list
Hi,
On 16/01/2025 10:11, Ziqi Chen wrote:
> Use Operation Points V2 for UFS on SM8650 so that multi-level
> clock/gear scaling can be possible.
I've already sent a similar one at https://lore.kernel.org/all/20250115-topic-sm8x50-upstream-dt-icc-update-v1-10-eaa8b10e2af7@linaro.org/
Neil
>
> 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>
> ---
> arch/arm64/boot/dts/qcom/sm8650.dtsi | 51 +++++++++++++++++++++++-----
> 1 file changed, 43 insertions(+), 8 deletions(-)
>
> diff --git a/arch/arm64/boot/dts/qcom/sm8650.dtsi b/arch/arm64/boot/dts/qcom/sm8650.dtsi
> index 01ac3769ffa6..5466f1217f64 100644
> --- a/arch/arm64/boot/dts/qcom/sm8650.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sm8650.dtsi
> @@ -2557,18 +2557,11 @@ ufs_mem_hc: ufs@1d84000 {
> "tx_lane0_sync_clk",
> "rx_lane0_sync_clk",
> "rx_lane1_sync_clk";
> - freq-table-hz = <100000000 403000000>,
> - <0 0>,
> - <0 0>,
> - <100000000 403000000>,
> - <100000000 403000000>,
> - <0 0>,
> - <0 0>,
> - <0 0>;
>
> resets = <&gcc GCC_UFS_PHY_BCR>;
> reset-names = "rst";
>
> + operating-points-v2 = <&ufs_opp_table>;
> interconnects = <&aggre1_noc MASTER_UFS_MEM QCOM_ICC_TAG_ALWAYS
> &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>,
> <&gem_noc MASTER_APPSS_PROC QCOM_ICC_TAG_ALWAYS
> @@ -2590,6 +2583,48 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>,
> #reset-cells = <1>;
>
> status = "disabled";
> +
> + ufs_opp_table: opp-table {
> + compatible = "operating-points-v2";
> + // LOW_SVS
> + opp-100000000 {
> + opp-hz = /bits/ 64 <100000000>,
> + /bits/ 64 <0>,
> + /bits/ 64 <0>,
> + /bits/ 64 <100000000>,
> + /bits/ 64 <0>,
> + /bits/ 64 <0>,
> + /bits/ 64 <0>,
> + /bits/ 64 <0>;
> + required-opps = <&rpmhpd_opp_low_svs>;
> + };
> +
> + // SVS
> + opp-201500000 {
> + opp-hz = /bits/ 64 <201500000>,
> + /bits/ 64 <0>,
> + /bits/ 64 <0>,
> + /bits/ 64 <201500000>,
> + /bits/ 64 <0>,
> + /bits/ 64 <0>,
> + /bits/ 64 <0>,
> + /bits/ 64 <0>;
> + required-opps = <&rpmhpd_opp_svs>;
> + };
> +
> + // NOM/TURBO
> + opp-403000000 {
> + opp-hz = /bits/ 64 <403000000>,
> + /bits/ 64 <0>,
> + /bits/ 64 <0>,
> + /bits/ 64 <403000000>,
> + /bits/ 64 <0>,
> + /bits/ 64 <0>,
> + /bits/ 64 <0>,
> + /bits/ 64 <0>;
> + required-opps = <&rpmhpd_opp_nom>;
> + };
> + };
> };
>
> ice: crypto@1d88000 {
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 8/8] ARM: dts: msm: Use Operation Points V2 for UFS on SM8650
2025-01-16 9:24 ` neil.armstrong
@ 2025-01-20 12:13 ` Ziqi Chen
0 siblings, 0 replies; 23+ messages in thread
From: Ziqi Chen @ 2025-01-20 12:13 UTC (permalink / raw)
To: neil.armstrong, quic_cang, bvanassche, mani, beanhuo, avri.altman,
junwoo80.lee, martin.petersen, quic_nguyenb, quic_nitirawa,
quic_rampraka
Cc: linux-scsi, Bjorn Andersson, Konrad Dybcio, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, open list:ARM/QUALCOMM SUPPORT,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list
On 1/16/2025 5:24 PM, neil.armstrong@linaro.org wrote:
> Hi,
>
> On 16/01/2025 10:11, Ziqi Chen wrote:
>> Use Operation Points V2 for UFS on SM8650 so that multi-level
>> clock/gear scaling can be possible.
>
>
> I've already sent a similar one at
> https://lore.kernel.org/all/20250115-topic-sm8x50-upstream-dt-icc-update-v1-10-eaa8b10e2af7@linaro.org/
>
> Neil
>
Hi Neil,
Thank you for reminder , I will withdraw this patch in next version.
- Ziqi
>>
>> 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>
>> ---
>> arch/arm64/boot/dts/qcom/sm8650.dtsi | 51 +++++++++++++++++++++++-----
>> 1 file changed, 43 insertions(+), 8 deletions(-)
>>
>> diff --git a/arch/arm64/boot/dts/qcom/sm8650.dtsi
>> b/arch/arm64/boot/dts/qcom/sm8650.dtsi
>> index 01ac3769ffa6..5466f1217f64 100644
>> --- a/arch/arm64/boot/dts/qcom/sm8650.dtsi
>> +++ b/arch/arm64/boot/dts/qcom/sm8650.dtsi
>> @@ -2557,18 +2557,11 @@ ufs_mem_hc: ufs@1d84000 {
>> "tx_lane0_sync_clk",
>> "rx_lane0_sync_clk",
>> "rx_lane1_sync_clk";
>> - freq-table-hz = <100000000 403000000>,
>> - <0 0>,
>> - <0 0>,
>> - <100000000 403000000>,
>> - <100000000 403000000>,
>> - <0 0>,
>> - <0 0>,
>> - <0 0>;
>> resets = <&gcc GCC_UFS_PHY_BCR>;
>> reset-names = "rst";
>> + operating-points-v2 = <&ufs_opp_table>;
>> interconnects = <&aggre1_noc MASTER_UFS_MEM
>> QCOM_ICC_TAG_ALWAYS
>> &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>,
>> <&gem_noc MASTER_APPSS_PROC QCOM_ICC_TAG_ALWAYS
>> @@ -2590,6 +2583,48 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>,
>> #reset-cells = <1>;
>> status = "disabled";
>> +
>> + ufs_opp_table: opp-table {
>> + compatible = "operating-points-v2";
>> + // LOW_SVS
>> + opp-100000000 {
>> + opp-hz = /bits/ 64 <100000000>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <100000000>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <0>;
>> + required-opps = <&rpmhpd_opp_low_svs>;
>> + };
>> +
>> + // SVS
>> + opp-201500000 {
>> + opp-hz = /bits/ 64 <201500000>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <201500000>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <0>;
>> + required-opps = <&rpmhpd_opp_svs>;
>> + };
>> +
>> + // NOM/TURBO
>> + opp-403000000 {
>> + opp-hz = /bits/ 64 <403000000>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <403000000>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <0>,
>> + /bits/ 64 <0>;
>> + required-opps = <&rpmhpd_opp_nom>;
>> + };
>> + };
>> };
>> ice: crypto@1d88000 {
>
^ permalink raw reply [flat|nested] 23+ messages in thread