summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/ufs/ufs-mediatek.c
diff options
context:
space:
mode:
authorStanley Chu <stanley.chu@mediatek.com>2020-06-01 12:46:42 +0200
committerMartin K. Petersen <martin.petersen@oracle.com>2020-06-16 05:06:39 +0200
commitfb43337cd4cff6639b174e3b6766e6eade523836 (patch)
treeec6de8d7d90a652bc3eef23cebb94f867df4b2c6 /drivers/scsi/ufs/ufs-mediatek.c
parentscsi: ufs: ufs-exynos: Add UFS host support for Exynos SoCs (diff)
downloadlinux-fb43337cd4cff6639b174e3b6766e6eade523836.tar.xz
linux-fb43337cd4cff6639b174e3b6766e6eade523836.zip
scsi: ufs-mediatek: Fix imprecise waiting time for ref-clk control
Currently ref-clk control timeout is implemented by jiffies. However jiffies is not accurate enough thus "false timeout" may happen. Use more accurate delay mechanism instead, i.e. ktime. Link: https://lore.kernel.org/r/20200601104646.15436-2-stanley.chu@mediatek.com Reviewed-by: Andy Teng <andy.teng@mediatek.com> Reviewed-by: Avri Altman <avri.altman@wdc.com> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/ufs/ufs-mediatek.c')
-rw-r--r--drivers/scsi/ufs/ufs-mediatek.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index d56ce8d97d4e..523ee5573921 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -120,7 +120,7 @@ static int ufs_mtk_setup_ref_clk(struct ufs_hba *hba, bool on)
{
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
struct arm_smccc_res res;
- unsigned long timeout;
+ ktime_t timeout, time_checked;
u32 value;
if (host->ref_clk_enabled == on)
@@ -135,8 +135,9 @@ static int ufs_mtk_setup_ref_clk(struct ufs_hba *hba, bool on)
}
/* Wait for ack */
- timeout = jiffies + msecs_to_jiffies(REFCLK_REQ_TIMEOUT_MS);
+ timeout = ktime_add_us(ktime_get(), REFCLK_REQ_TIMEOUT_US);
do {
+ time_checked = ktime_get();
value = ufshcd_readl(hba, REG_UFS_REFCLK_CTRL);
/* Wait until ack bit equals to req bit */
@@ -144,7 +145,7 @@ static int ufs_mtk_setup_ref_clk(struct ufs_hba *hba, bool on)
goto out;
usleep_range(100, 200);
- } while (time_before(jiffies, timeout));
+ } while (ktime_before(time_checked, timeout));
dev_err(hba->dev, "missing ack of refclk req, reg: 0x%x\n", value);