mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
scsi: ufs: core: Report the current clock frequency to devfreq
When a driver does not provide a ->get_cur_freq() callback, the cur_freq sysfs attribute shows devfreq->previous_freq, which only tracks the scaling that the governor itself did. The UFS controller is also scaled outside the governor. The clearest example is writing 0 to clkscale_enable: ufshcd_clkscale_enable_store() sets the clocks to max_freq through ufshcd_devfreq_scale() and suspends the governor, so devfreq_set_target() is never called. After that, cur_freq keeps showing the last frequency the governor chose instead of the one the controller runs at, and it does so as long as clock scaling stays disabled. Add ufshcd_devfreq_get_cur_freq(). It reports clk_scaling.target_freq when OPPs are used and the first clock's curr_freq otherwise, the same values that ufshcd_devfreq_get_dev_status() reports. Signed-off-by: Bean Huo <beanhuo@micron.com> Reviewed-by: Avri Altman <avri.altman@sandisk.com> Reviewed-by: Stanley Jhu <stanleyjhu@google.com> Link: https://patch.msgid.link/20260907192140.2701755-5-beanhuo@iokpp.de Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
This commit is contained in:
parent
20ae446921
commit
55ad5deeea
|
|
@ -1711,6 +1711,26 @@ static int ufshcd_devfreq_get_dev_status(struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ufshcd_devfreq_get_cur_freq(struct device *dev, unsigned long *freq)
|
||||
{
|
||||
struct ufs_hba *hba = dev_get_drvdata(dev);
|
||||
|
||||
if (!ufshcd_is_clkscaling_supported(hba))
|
||||
return -EINVAL;
|
||||
|
||||
if (hba->use_pm_opp) {
|
||||
*freq = hba->clk_scaling.target_freq;
|
||||
} else {
|
||||
struct ufs_clk_info *clki;
|
||||
|
||||
clki = list_first_entry(&hba->clk_list_head,
|
||||
struct ufs_clk_info, list);
|
||||
*freq = clki->curr_freq;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ufshcd_devfreq_init(struct ufs_hba *hba)
|
||||
{
|
||||
struct list_head *clk_list = &hba->clk_list_head;
|
||||
|
|
@ -9616,6 +9636,7 @@ static struct ufs_hba_variant_params ufs_hba_vps = {
|
|||
.devfreq_profile.polling_ms = 100,
|
||||
.devfreq_profile.target = ufshcd_devfreq_target,
|
||||
.devfreq_profile.get_dev_status = ufshcd_devfreq_get_dev_status,
|
||||
.devfreq_profile.get_cur_freq = ufshcd_devfreq_get_cur_freq,
|
||||
.ondemand_data.upthreshold = 70,
|
||||
.ondemand_data.downdifferential = 5,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user