diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 091364aff502..f5bf344f9557 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -7972,8 +7972,12 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) ufshcd_set_clk_freq(hba, true); err = ufshcd_hba_enable(hba); - if (err) + if (err) { + /* ufshcd_probe_hba() will put it */ + if (!ufshcd_eh_in_progress(hba) && !hba->pm_op_in_progress) + pm_runtime_put_sync(hba->dev); goto out; + } /* Establish the link again and restore the device */ err = ufshcd_probe_hba(hba); @@ -8024,6 +8028,8 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba) ufshcd_enable_irq(hba); do { + if (!ufshcd_eh_in_progress(hba) && !hba->pm_op_in_progress) + pm_runtime_get_sync(hba->dev); err = ufshcd_detect_device(hba); } while (err && --retries);