scsi: ufs: Fix race condition in rls_work and ufshcd_resume
In some rare scenario, race condition is observed between
rls_work handler and ufshcd_resume operation.
Sequence of events:
1.rls_work is scheduled due to UIC error.
2.ufshcd_rls_handler sets host_self_blocked to 1 and then
invokes pm_runtime_get_sync
3. pm_runtime_get_sync is not yet completed because
runtime_status was RPM_RESUMING.
4.pm_runtime_work schedules at almost same time of rls_work.
Here ufshcd_resume schedules out as host_self_blocked
was set to 1 by rls_work.
Call stacks:
-006|wait_for_completion_io(?)
-007|blk_execute_rq()
-008|scsi_execute()
-009|scsi_execute_req_flags()
-010|ufshcd_set_dev_pwr_mode()
-011|ufshcd_resume()
-012|ufshcd_runtime_resume(hba)
-013|ufshcd_pltfrm_runtime_resume(?)
-014|pm_generic_runtime_resume(?)
-015|__rpm_callback(inline)
-003|schedule()
-004|spin_lock_irq(inline)
-004|rpm_resume()
-005|__pm_runtime_resume()
-006|ufshcd_rls_handler()
Fix this by calling pm_runtime_get_sync before setting
host_self_blocked to 1 during rls_work.
Change-Id: I69f23c169ac8a9eb59062b461302f5521cd57ebc
Signed-off-by:
Sayali Lokhande <sayalil@codeaurora.org>
Loading
Please register or sign in to comment