Skip to contentSkip to conversation

scsi: ufs: core: Flush exception handling work when RPM level is zero

PATCH Applied Thomas Yen 3 participants 3 messages Jan 26 – Feb 4

Subsystems (2)

v1 of 4 Applied Latest is v4 →

lore
Share & tools
lore

Thomas Yen

author
#0 lore raw

PATCH 1/1 scsi: ufs: core: Flush exception handling work when RPM level is zero

Ensure that the exception event handling work (&hba->eeh_work) is explicitly flushed during suspend when the runtime power management level (rpm_lvl) is set to UFS_PM_LVL_0.

When the RPM level is zero, the device power mode remains active and the link remains in an active state. In this specific configuration, the UFS core driver previously bypassed the flushing of exception event handling jobs. This created a race condition where the driver could attempt to access the host controller to handle an exception after the system had already entered a deep power-down state, leading to a system crash.

By explicitly flushing this work before the suspend callback proceeds, pending exception handling tasks are guaranteed to complete, preventing illegal hardware access during the power-down sequence.

---
 drivers/ufs/core/ufshcd.c | 1 +
 1 file changed, 1 insertion(+)
drivers/ufs/core/ufshcd.c +1 -0
index 0369043ca010..3a0e6c9ba86a 100644
@@ -9997,6 +9997,7 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 
 	if (req_dev_pwr_mode == UFS_ACTIVE_PWR_MODE &&
 			req_link_state == UIC_LINK_ACTIVE_STATE) {
+		flush_work(&hba->eeh_work);
 		goto vops_suspend;
 	}
 

base-commit: a48ca06cf343423faa01c573aeafba9fa5f92577

Signature · 1 line
2.52.0.457.g6b5491de43-goog
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Thomas Yen

Ensure that the exception event handling work (&hba->eeh_work) is explicitly flushed during suspend when the runtime power management level (rpm_lvl) is set to UFS_PM_LVL_0.

When the RPM level is zero, the device power mode remains active and the link remains in an active state. In this specific configuration, the UFS core driver previously bypassed the flushing of exception event handling jobs. This created a race condition where the driver could attempt to access the host controller to handle an exception after the system had already entered a deep power-down state, leading to a system crash.

By explicitly flushing this work before the suspend callback proceeds, pending exception handling tasks are guaranteed to complete, preventing illegal hardware access during the power-down sequence.

---
  drivers/ufs/core/ufshcd.c | 1 +
  1 file changed, 1 insertion(+)
drivers/ufs/core/ufshcd.c +0 -0
index 0369043ca010..3a0e6c9ba86a 100644

drivers/ufs/core/ufshcd.c static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) · line 10002

Quoted 6 lines
drivers/ufs/core/ufshcd.c +1 -0
@@ -9997,6 +9997,7 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 
  	if (req_dev_pwr_mode == UFS_ACTIVE_PWR_MODE &&
  			req_link_state == UIC_LINK_ACTIVE_STATE) {
+		flush_work(&hba->eeh_work);
  		goto vops_suspend;
  	}

A "Cc: stable" tag is missing. Since otherwise this patch looks good to me:

#2 lore raw
In reply to Thomas Yen

Thomas,

Quoted 3 lines

Ensure that the exception event handling work (&hba->eeh_work) is explicitly flushed during suspend when the runtime power management level (rpm_lvl) is set to UFS_PM_LVL_0.

Applied to 6.20/scsi-staging (with stable tag), thanks!

Signature · 1 line
Martin K. Petersen