Skip to content

Commit

Permalink
scsi: ufs: Fix pm_runtime count in reset flow
Browse files Browse the repository at this point in the history
ufshcd_probe_hba() puts pm_runtime all the time. So, during the reset flow,
we need to get one.

pm_runtime_get_sync (1)
ufshcd_async_scan
pm_runtime_get_sync (2)
ufshcd_hold_all
ufshcd_probe_hba
 - pm_runtime_put_sync (1)
 - ufshcd_reset_and_restore
   - ufshcd_detect_device
    - ufshcd_host_reset_and_restore
       - ufshcd_probe_hba
       - pm_runtime_put_sync (0)

ufshcd_release_all
pm_runtime_put_sync (-1)

Bug: 157744625
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I2d5696d6143842790fa25218beda12b71cfcc1d6
Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
Signed-off-by: onettboots <blackcocopet@gmail.com>
  • Loading branch information
Jaegeuk Kim authored and onettboots committed Sep 3, 2024
1 parent 7795cbd commit 51276d6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/scsi/ufs/ufshcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 51276d6

Please sign in to comment.