* [PATCH v2] scsi: ufs: Fix imprecise time in devfreq window
@ 2020-06-09 15:40 Stanley Chu
2020-06-10 11:43 ` Avri Altman
0 siblings, 1 reply; 3+ messages in thread
From: Stanley Chu @ 2020-06-09 15:40 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb, asutoshd
Cc: beanhuo, cang, matthias.bgg, bvanassche, linux-mediatek,
linux-arm-kernel, linux-kernel, kuohong.wang, peter.wang,
chun-hung.wu, andy.teng, Stanley Chu
Promise precision of devfreq windows by
1. Align time base of both devfreq_dev_status.total_time and
devfreq_dev_status.busy_time to ktime-based time.
2. Align below timelines,
- The beginning of devfreq window
- The beginning of busy time in new window
- The end of busy time in current window
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/scsi/ufs/ufshcd.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index ad4fc829cbb2..04b79ca66fdf 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1314,6 +1314,7 @@ static int ufshcd_devfreq_get_dev_status(struct device *dev,
unsigned long flags;
struct list_head *clk_list = &hba->clk_list_head;
struct ufs_clk_info *clki;
+ ktime_t curr_t;
if (!ufshcd_is_clkscaling_supported(hba))
return -EINVAL;
@@ -1321,6 +1322,7 @@ static int ufshcd_devfreq_get_dev_status(struct device *dev,
memset(stat, 0, sizeof(*stat));
spin_lock_irqsave(hba->host->host_lock, flags);
+ curr_t = ktime_get();
if (!scaling->window_start_t)
goto start_window;
@@ -1332,18 +1334,17 @@ static int ufshcd_devfreq_get_dev_status(struct device *dev,
*/
stat->current_frequency = clki->curr_freq;
if (scaling->is_busy_started)
- scaling->tot_busy_t += ktime_to_us(ktime_sub(ktime_get(),
+ scaling->tot_busy_t += ktime_to_us(ktime_sub(curr_t,
scaling->busy_start_t));
- stat->total_time = jiffies_to_usecs((long)jiffies -
- (long)scaling->window_start_t);
+ stat->total_time = ktime_to_us(curr_t) - scaling->window_start_t;
stat->busy_time = scaling->tot_busy_t;
start_window:
- scaling->window_start_t = jiffies;
+ scaling->window_start_t = ktime_to_us(curr_t);
scaling->tot_busy_t = 0;
if (hba->outstanding_reqs) {
- scaling->busy_start_t = ktime_get();
+ scaling->busy_start_t = curr_t;
scaling->is_busy_started = true;
} else {
scaling->busy_start_t = 0;
--
2.18.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH v2] scsi: ufs: Fix imprecise time in devfreq window
2020-06-09 15:40 [PATCH v2] scsi: ufs: Fix imprecise time in devfreq window Stanley Chu
@ 2020-06-10 11:43 ` Avri Altman
2020-06-10 14:43 ` Stanley Chu
0 siblings, 1 reply; 3+ messages in thread
From: Avri Altman @ 2020-06-10 11:43 UTC (permalink / raw)
To: Stanley Chu, linux-scsi, martin.petersen, alim.akhtar, jejb, asutoshd
Cc: beanhuo, cang, matthias.bgg, bvanassche, linux-mediatek,
linux-arm-kernel, linux-kernel, kuohong.wang, peter.wang,
chun-hung.wu, andy.teng
Hi Stanley,
>
>
> Promise precision of devfreq windows by
Promise -> guarantee / assure / verify that the?
Can you please also elaborate why the current window isn't accurate enough?
And add a fixes tag?
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v2] scsi: ufs: Fix imprecise time in devfreq window
2020-06-10 11:43 ` Avri Altman
@ 2020-06-10 14:43 ` Stanley Chu
0 siblings, 0 replies; 3+ messages in thread
From: Stanley Chu @ 2020-06-10 14:43 UTC (permalink / raw)
To: Avri Altman
Cc: linux-scsi, martin.petersen, alim.akhtar, jejb, asutoshd,
bvanassche, andy.teng, chun-hung.wu, kuohong.wang, linux-kernel,
cang, linux-mediatek, peter.wang, matthias.bgg, linux-arm-kernel,
beanhuo
Hi Avri,
On Wed, 2020-06-10 at 11:43 +0000, Avri Altman wrote:
> Hi Stanley,
>
> >
> >
> > Promise precision of devfreq windows by
> Promise -> guarantee / assure / verify that the?
> Can you please also elaborate why the current window isn't accurate enough?
> And add a fixes tag?
OK! I will fix all of them in next version.
Thanks,
Stanley Chu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-10 14:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-09 15:40 [PATCH v2] scsi: ufs: Fix imprecise time in devfreq window Stanley Chu
2020-06-10 11:43 ` Avri Altman
2020-06-10 14:43 ` Stanley Chu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).