[PATCH] scsi: ufs: preventing bus hang crash during emergency power off
Bart Van Assche
bvanassche at acm.org
Mon Jul 7 09:14:36 PDT 2025
On 5/19/25 12:38 AM, Bo Ye wrote:
> The root cause is that scsi_device_quiesce and blk_mq_freeze_queue
> only drain the requests in the request queue but don't guarantee that
> all requests have been dispatched to the UFS host and completed.
> Requests may remain pending in the hardware dispatch queue and be
> rescheduled later.
The above is confusing. scsi_device_quiesce() drains both the request
queue and the hardware queues for all commands associated with a single
logical unit. The problem that you are encountering is probably that
scsi_device_quiesce() is only called for the WLUN but not for the other
logical units and hence that there still may be commands being processed
for other logical units after scsi_device_quiesce() has returned.
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 7735421e3991..a1013aea8e90 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -10262,6 +10262,7 @@ static void ufshcd_wl_shutdown(struct device *dev)
> scsi_device_set_state(sdev, SDEV_OFFLINE);
> mutex_unlock(&sdev->state_mutex);
> }
> + ufshcd_wait_for_doorbell_clr(hba, 5 * USEC_PER_SEC);
> __ufshcd_wl_suspend(hba, UFS_SHUTDOWN_PM);
>
> /*
The name of the ufshcd_wait_for_doorbell_clr() function is confusing
since "doorbell" refers to a legacy single doorbell mode concept while
the function supports both legacy mode and MCQ. After this patch has
been queued I plan to submit a patch that renames this function.
If the patch description of this patch is improved I will add my
Reviewed-by to this patch.
Thanks,
Bart.
More information about the Linux-mediatek
mailing list