Skip to content

Commit 24e2e7a

Browse files
Stanley Chumartinkpetersen
authored andcommitted
scsi: ufs: Avoid runtime suspend possibly being blocked forever
UFS runtime suspend can be triggered after pm_runtime_enable() is invoked in ufshcd_pltfrm_init(). However if the first runtime suspend is triggered before binding ufs_hba structure to ufs device structure via platform_set_drvdata(), then UFS runtime suspend will be no longer triggered in the future because its dev->power.runtime_error was set in the first triggering and does not have any chance to be cleared. To be more clear, dev->power.runtime_error is set if hba is NULL in ufshcd_runtime_suspend() which returns -EINVAL to rpm_callback() where dev->power.runtime_error is set as -EINVAL. In this case, any future rpm_suspend() for UFS device fails because rpm_check_suspend_allowed() fails due to non-zero dev->power.runtime_error. To resolve this issue, make sure the first UFS runtime suspend get valid "hba" in ufshcd_runtime_suspend(): Enable UFS runtime PM only after hba is successfully bound to UFS device structure. Fixes: 6269473 ([SCSI] ufs: Add runtime PM support for UFS host controller driver) Cc: [email protected] Signed-off-by: Stanley Chu <[email protected]> Reviewed-by: Avri Altman <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 8cf4c54 commit 24e2e7a

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

drivers/scsi/ufs/ufshcd-pltfrm.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,24 +430,21 @@ int ufshcd_pltfrm_init(struct platform_device *pdev,
430430
goto dealloc_host;
431431
}
432432

433-
pm_runtime_set_active(&pdev->dev);
434-
pm_runtime_enable(&pdev->dev);
435-
436433
ufshcd_init_lanes_per_dir(hba);
437434

438435
err = ufshcd_init(hba, mmio_base, irq);
439436
if (err) {
440437
dev_err(dev, "Initialization failed\n");
441-
goto out_disable_rpm;
438+
goto dealloc_host;
442439
}
443440

444441
platform_set_drvdata(pdev, hba);
445442

443+
pm_runtime_set_active(&pdev->dev);
444+
pm_runtime_enable(&pdev->dev);
445+
446446
return 0;
447447

448-
out_disable_rpm:
449-
pm_runtime_disable(&pdev->dev);
450-
pm_runtime_set_suspended(&pdev->dev);
451448
dealloc_host:
452449
ufshcd_dealloc_host(hba);
453450
out:

0 commit comments

Comments
 (0)