Skip to content

Commit b50d9c2

Browse files
ptr324martinkpetersen
authored andcommitted
scsi: ufs: core: Fix abnormal scale up after scale down
When no active_reqs, devfreq_monitor (thread A) will suspend clock scaling. But it may have racing with clk_scaling.suspend_work (thread B) and actually not suspend clock scaling (requeue after suspend). Next time after polling_ms, devfreq_monitor read clk_scaling.window_start_t = 0 then scale up clock abnormal. Below is racing step: devfreq->work (Thread A) devfreq_monitor update_devfreq ..... ufshcd_devfreq_target queue_work(hba->clk_scaling.workq, 1 &hba->clk_scaling.suspend_work) ..... 5 queue_delayed_work(devfreq_wq, &devfreq->work, msecs_to_jiffies(devfreq->profile->polling_ms)); 2 hba->clk_scaling.suspend_work (Thread B) ufshcd_clk_scaling_suspend_work __ufshcd_suspend_clkscaling devfreq_suspend_device(hba->devfreq); 3 cancel_delayed_work_sync(&devfreq->work); 4 hba->clk_scaling.window_start_t = 0; ..... Signed-off-by: Peter Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 6fd53da commit b50d9c2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,13 @@ static int ufshcd_devfreq_target(struct device *dev,
14021402
return 0;
14031403
}
14041404

1405+
/* Skip scaling clock when clock scaling is suspended */
1406+
if (hba->clk_scaling.is_suspended) {
1407+
spin_unlock_irqrestore(hba->host->host_lock, irq_flags);
1408+
dev_warn(hba->dev, "clock scaling is suspended, skip");
1409+
return 0;
1410+
}
1411+
14051412
if (!hba->clk_scaling.active_reqs)
14061413
sched_clk_scaling_suspend_work = true;
14071414

0 commit comments

Comments
 (0)