Re: [PATCH v1 1/1] ufs: core: set SDEV_OFFLINE when ufs shutdown.

Bart Van Assche
2024-09-23T17:41:45Z

On 8/29/24 2:39 AM, Seunghwan Baek wrote:
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index a6f818cdef0e..4ac1492787c2 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -10215,7 +10215,9 @@ static void ufshcd_wl_shutdown(struct device *dev)
> shost_for_each_device(sdev, hba->host) {
> if (sdev == hba->ufs_device_wlun)
> continue;
> - scsi_device_quiesce(sdev);
> + mutex_lock(&sdev->state_mutex);
> + scsi_device_set_state(sdev, SDEV_OFFLINE);
> + mutex_unlock(&sdev->state_mutex);
> }
> __ufshcd_wl_suspend(hba, UFS_SHUTDOWN_PM);

Why to keep one scsi_device_quiesce() call and convert the other call?
Please consider something like this change:

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index e808350c6774..914770dff18f 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -10134,11 +10134,10 @@ static void ufshcd_wl_shutdown(struct device *dev)

/* Turn on everything while shutting down */
ufshcd_rpm_get_sync(hba);
- scsi_device_quiesce(sdev);
shost_for_each_device(sdev, hba->host) {
- if (sdev == hba->ufs_device_wlun)
- continue;
- scsi_device_quiesce(sdev);
+ mutex_lock(&sdev->state_mutex);
+ scsi_device_set_state(sdev, SDEV_OFFLINE);
+ mutex_unlock(&sdev->state_mutex);
}
__ufshcd_wl_suspend(hba, UFS_SHUTDOWN_PM);

Thanks,

Bart.