>From 2b9aae51ac5b1f1b13fdab5570dceefbbdc9682b Mon Sep 17 00:00:00 2001 From: Adrian Hunter Date: Fri, 23 Apr 2021 08:56:18 +0300 Subject: [PATCH 2/2] instrumentation to reproduce issue Signed-off-by: Adrian Hunter --- drivers/scsi/ufs/ufshcd.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 5be5b2472db0..32fc4e3991ff 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5834,12 +5834,14 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba) static void ufshcd_err_handling_unprepare(struct ufs_hba *hba) { + pr_err("%s: start\n", __func__); ufshcd_scsi_unblock_requests(hba); ufshcd_release(hba); if (ufshcd_is_clkscaling_supported(hba)) ufshcd_clk_scaling_suspend(hba, false); ufshcd_clear_ua_wluns(hba); ufshcd_rpm_put(hba); + pr_err("%s: finish\n", __func__); } static inline bool ufshcd_err_handling_should_stop(struct ufs_hba *hba) @@ -5919,11 +5921,14 @@ static void ufshcd_err_handler(struct work_struct *work) int tag; bool needs_reset = false, needs_restore = false; + pr_err("%s: start\n", __func__); + hba = container_of(work, struct ufs_hba, eh_work); down(&hba->host_sem); + pr_err("%s: got sem\n", __func__); spin_lock_irqsave(hba->host->host_lock, flags); - if (ufshcd_err_handling_should_stop(hba)) { + if (0 && ufshcd_err_handling_should_stop(hba)) { if (hba->ufshcd_state != UFSHCD_STATE_ERROR) hba->ufshcd_state = UFSHCD_STATE_OPERATIONAL; spin_unlock_irqrestore(hba->host->host_lock, flags); @@ -6095,6 +6100,7 @@ static void ufshcd_err_handler(struct work_struct *work) ufshcd_clear_eh_in_progress(hba); spin_unlock_irqrestore(hba->host->host_lock, flags); ufshcd_err_handling_unprepare(hba); + pr_err("%s: finish\n", __func__); up(&hba->host_sem); } @@ -7872,12 +7878,15 @@ static int ufshcd_clear_ua_wluns(struct ufs_hba *hba) { int ret = 0; - if (!hba->wlun_dev_clr_ua) + if (0 && !hba->wlun_dev_clr_ua) goto out; ret = ufshcd_clear_ua_wlun(hba, UFS_UPIU_UFS_DEVICE_WLUN); - if (!ret) + if (!ret) { + pr_err("%s: before ufshcd_clear_ua_wlun(hba, UFS_UPIU_RPMB_WLUN)\n", __func__); ret = ufshcd_clear_ua_wlun(hba, UFS_UPIU_RPMB_WLUN); + pr_err("%s: after ufshcd_clear_ua_wlun(hba, UFS_UPIU_RPMB_WLUN), ret %d\n", __func__, ret); + } if (!ret) hba->wlun_dev_clr_ua = false; out: @@ -8983,7 +8992,16 @@ static int ufshcd_wl_suspend(struct device *dev) ktime_t start = ktime_get(); hba = shost_priv(sdev->host); - down(&hba->host_sem); + pr_err("%s: doing ufshcd_schedule_eh_work\n", __func__); + ufshcd_schedule_eh_work(hba); + pr_err("%s: sleeping 1000 ms\n", __func__); + msleep(1000); + pr_err("%s: trying to get sem\n", __func__); + if (down_timeout(&hba->host_sem, msecs_to_jiffies(5000))) { + pr_err("%s: failed to get sem\n", __func__); + return -EINVAL; + } + pr_err("%s: got sem\n", __func__); if (pm_runtime_suspended(dev)) goto out; -- 2.25.1