scsi: ufs: fix rpm racing issue
Subsystems (2)
PATCH 1/1 scsi: ufs: fix rpm racing issue
From: Peter Wang <[email protected]>
Device WLun may enter RPM_SUSPENDED and the consumer is RPM_ACTIVE.
The error state is
Device Wlun RPM: status:2, usage_count:0
Consumer: 0:0:0:49476 Link: rpm_active:1, RPM: status:2, usage_count:0
Consumer: 0:0:0:49456 Link: rpm_active:1, RPM: status:2, usage_count:0
Consumer: 0:0:0:0 Link: rpm_active:1, RPM: status:2, usage_count:0
Consumer: 0:0:0:1 Link: rpm_active:1, RPM: status:2, usage_count:0
Consumer: 0:0:0:2 Link: rpm_active:1, RPM: status:0, usage_count:0
Because rpm enable before rpm delay set, scsi_autopm_put_device invoke by scsi_sysfs_add_sdev may cause consumer enter suspend immediately. Thas will always set rpm_active to 1.
If driver_probe_device invoke pm_runtime_get_suppliers just befor previous scsi_autopm_put_device, the rpm_active will change to 1 after pm_runtime_put_suppliers.
Set this delay to avoid scsi_autopm_put_device enter suspend immediately.
--- drivers/scsi/ufs/ufshcd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +6 -2
@@ -5024,10 +5024,14 @@ static int ufshcd_slave_configure(struct scsi_device *sdev)* Block runtime-pm until all consumers are added. * Refer ufshcd_setup_links(). */ -if (is_device_wlun (sdev)) +if (is_device_wlun (sdev)) {pm_runtime_get_noresume (&sdev->sdev_gendev); -else if (ufshcd_is_rpm_autosuspend_allowed (hba)) + }else if (ufshcd_is_rpm_autosuspend_allowed (hba)) { sdev->rpm_autosuspend =1 ; +pm_runtime_set_autosuspend_delay (&sdev->sdev_gendev, +RPM_AUTOSUSPEND_DELAY_MS ); + } +/* * Do not print messages during runtime PM to avoid never-ending cycles * of messages written back to storage by user space causing runtime
Signature · 1 line
2.18.0
Quoted 35 lines
From: Peter Wang <[email protected]>
Device WLun may enter
RPM_SUSPENDEDand the consumer isRPM_ACTIVE.The error state is
Device Wlun RPM: status:2, usage_count:0
Consumer: 0:0:0:49476 Link: rpm_active:1, RPM: status:2, usage_count:0
Consumer: 0:0:0:49456 Link: rpm_active:1, RPM: status:2, usage_count:0
Consumer: 0:0:0:0 Link: rpm_active:1, RPM: status:2, usage_count:0
Consumer: 0:0:0:1 Link: rpm_active:1, RPM: status:2, usage_count:0
Consumer: 0:0:0:2 Link: rpm_active:1, RPM: status:0, usage_count:0Because rpm enable before rpm delay set,
scsi_autopm_put_deviceinvoke byscsi_sysfs_add_sdevmay cause consumer enter suspend immediately.
Thas will always setrpm_activeto 1.
Ifdriver_probe_deviceinvokepm_runtime_get_suppliersjust befor previousscsi_autopm_put_device, therpm_activewill change to 1 afterpm_runtime_put_suppliers.
Set this delay to avoidscsi_autopm_put_deviceenter suspend immediately.Signed-off-by Peter Wang <[email protected]>--- drivers/scsi/ufs/ufshcd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/scsi/ufs/ufshcd.c +0
-0@@ -5024,10 +5024,14 @@ static int ufshcd_slave_configure(struct scsi_device *sdev) * Block runtime-pm until all consumers are added. * Refer ufshcd_setup_links().
drivers/scsi/ufs/ufshcd.c static int ufshcd_slave_configure(struct · line 5034
Quoted 10 lines
drivers/scsi/ufs/ufshcd.c +5
-2*/ -if (is_device_wlun (sdev)) +if (is_device_wlun (sdev)) {pm_runtime_get_noresume (&sdev->sdev_gendev); -else if (ufshcd_is_rpm_autosuspend_allowed (hba)) + }else if (ufshcd_is_rpm_autosuspend_allowed (hba)) { sdev->rpm_autosuspend =1 ; +pm_runtime_set_autosuspend_delay (&sdev->sdev_gendev, +RPM_AUTOSUSPEND_DELAY_MS ); + }
Maybe remove ufshcd_blk_pm_runtime_init from ufshcd_scsi_add_wlus, And call here ufshcd_blk_pm_runtime_init() ?
Thanks,
Avri
Quoted 6 lines
drivers/scsi/ufs/ufshcd.c +1
-0+/* * Do not print messages during runtime PM to avoid never-ending cycles * of messages written back to storage by user space causing runtime
--
2.18.0
Quoted 48 lines · Avri Altman
Quoted 35 lines
From: Peter Wang <[email protected]>
Device WLun may enter
RPM_SUSPENDEDand the consumer isRPM_ACTIVE.The error state is
Device Wlun RPM: status:2, usage_count:0
Consumer: 0:0:0:49476 Link: rpm_active:1, RPM: status:2, usage_count:0
Consumer: 0:0:0:49456 Link: rpm_active:1, RPM: status:2, usage_count:0
Consumer: 0:0:0:0 Link: rpm_active:1, RPM: status:2, usage_count:0
Consumer: 0:0:0:1 Link: rpm_active:1, RPM: status:2, usage_count:0
Consumer: 0:0:0:2 Link: rpm_active:1, RPM: status:0, usage_count:0Because rpm enable before rpm delay set,
scsi_autopm_put_deviceinvoke byscsi_sysfs_add_sdevmay cause consumer enter suspend immediately.
Thas will always setrpm_activeto 1.
Ifdriver_probe_deviceinvokepm_runtime_get_suppliersjust befor previousscsi_autopm_put_device, therpm_activewill change to 1 afterpm_runtime_put_suppliers.
Set this delay to avoidscsi_autopm_put_deviceenter suspend immediately.Signed-off-by Peter Wang <[email protected]>--- drivers/scsi/ufs/ufshcd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/scsi/ufs/ufshcd.c +0
-0@@ -5024,10 +5024,14 @@ static int ufshcd_slave_configure(struct scsi_device *sdev) * Block runtime-pm until all consumers are added. * Refer ufshcd_setup_links().drivers/scsi/ufs/ufshcd.c static int ufshcd_slave_configure(struct · line 5034
Quoted 10 lines
drivers/scsi/ufs/ufshcd.c +5
-2*/ -if (is_device_wlun (sdev)) +if (is_device_wlun (sdev)) {pm_runtime_get_noresume (&sdev->sdev_gendev); -else if (ufshcd_is_rpm_autosuspend_allowed (hba)) + }else if (ufshcd_is_rpm_autosuspend_allowed (hba)) { sdev->rpm_autosuspend =1 ; +pm_runtime_set_autosuspend_delay (&sdev->sdev_gendev, +RPM_AUTOSUSPEND_DELAY_MS ); + }Maybe remove
ufshcd_blk_pm_runtime_initfromufshcd_scsi_add_wlus, And call hereufshcd_blk_pm_runtime_init()?
Quoted 2 lines
Thanks,
Avri
Hi Arvi,
Thanks review, but I need discard this patch because it is not correct.
Sorry for inconvenient.
Thanks
Peter
Quoted 7 lines
Quoted 7 lines
drivers/scsi/ufs/ufshcd.c +1
-0+/* * Do not print messages during runtime PM to avoid never-ending cycles * of messages written back to storage by user space causing runtime
--
2.18.0