Message ID | 20250203081109.1614395-4-quic_ziqichen@quicinc.com |
---|---|
State | Superseded |
Headers | show |
Series | Support Multi-frequency scale for UFS | expand |
On Mon, 2025-02-03 at 16:11 +0800, Ziqi Chen wrote: > From: Can Guo <quic_cang@quicinc.com> > > Add a vop to map UFS host controller clock frequencies to the maximum > supported UFS high speed gear speeds.
On 2/3/25 12:11 AM, Ziqi Chen wrote: > Add a vop to map UFS host controller clock frequencies to the maximum > supported UFS high speed gear speeds. During clock scaling, we can map the > target clock frequency, demanded by devfreq, to the maximum supported gear > speed, so that devfreq can scale the gear to the highest gear speed > supported at the target clock frequency, instead of just scaling up/down > the gear between the min and max gear speeds. Reviewed-by: Bart Van Assche <bvanassche@acm.org>
On 2/3/2025 8:55 PM, Bean Huo wrote: > On Mon, 2025-02-03 at 16:11 +0800, Ziqi Chen wrote: >> From: Can Guo <quic_cang@quicinc.com> >> >> Add a vop to map UFS host controller clock frequencies to the maximum >> supported UFS high speed gear speeds. > > From the code, seems it is not "maximum" gear, it is corresponding UFS > Gear. > Hi Bean, Thank you for comment. Let me explain for you that why it is "maximum supported" gear. For example, the freq 201500000 supports G1 G2 G3, this VOP will maps to G3 which is the "maximum supported" gear. Maybe we can change it to "corresponding maximum supported" gear would be more make sense. Let me change it in next version. -Ziqi >> During clock scaling, we canmap thetarget clock frequency, demanded >> by devfreq, to the maximum supported gear >> speed, so that devfreq can scale the gear to the highest gear speed >> supported at the target clock frequency, instead of just scaling >> up/down >> the gear between the min and max gear speeds. >> >> 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> > > Reveiwed-by: Bean Huo <beanhuo@micron.com>
diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index 0549b65f71ed..4da3e65c6735 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -277,6 +277,14 @@ static inline int ufshcd_mcq_vops_config_esi(struct ufs_hba *hba) return -EOPNOTSUPP; } +static inline int ufshcd_vops_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq) +{ + if (hba->vops && hba->vops->freq_to_gear_speed) + return hba->vops->freq_to_gear_speed(hba, freq); + + return -EOPNOTSUPP; +} + extern const struct ufs_pm_lvl_states ufs_pm_lvl_states[]; /** diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index f51d425696e7..cdb853f5b871 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -336,6 +336,7 @@ struct ufs_pwr_mode_info { * @get_outstanding_cqs: called to get outstanding completion queues * @config_esi: called to config Event Specific Interrupt * @config_scsi_dev: called to configure SCSI device parameters + * @freq_to_gear_speed: called to map clock frequency to the max supported gear speed */ struct ufs_hba_variant_ops { const char *name; @@ -387,6 +388,7 @@ struct ufs_hba_variant_ops { unsigned long *ocqs); int (*config_esi)(struct ufs_hba *hba); void (*config_scsi_dev)(struct scsi_device *sdev); + int (*freq_to_gear_speed)(struct ufs_hba *hba, unsigned long freq); }; /* clock gating state */