Skip to contentSkip to conversation

scsi: ufs: fix several issues caused by driver reloading

PATCH Superseded Akinobu Mita 1 participant 4 messages Mar 27, 2015 SCSI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover scsi: ufs: fix several issues caused by driver reloading

This patch set addresses several issues caused by driver reloading in ufs driver, although the first patch also fixes error path in driver probe.

Akinobu Mita (3):
scsi: ufs: avoid using hostdata after scsi_host_put()
scsi: ufs: fix unbalanced power.usage_count after reloading driver
scsi: ufs: fix unbalanced power.disable_depth after reloading driver

 drivers/scsi/ufs/ufshcd-pltfrm.c | 5 +++++
 drivers/scsi/ufs/ufshcd.c        | 6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/3 scsi: ufs: avoid using hostdata after scsi_host_put()

The hostdata array, which is denoted by 'hba' in ufs driver, should not be accessed after calling scsi_host_put().

Cc Vinayak Holikatti <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Dolev Raviv <[email protected]>
Cc Sujit Reddy Thumma <[email protected]>
Cc Subhash Jadavani <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Sahitya Tummala <[email protected]>
---
 drivers/scsi/ufs/ufshcd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/ufs/ufshcd.c +3 -3
index 5d60a86..4e4de32 100644
@@ -5239,12 +5239,12 @@ void ufshcd_remove(struct ufs_hba *hba)
 	ufshcd_disable_intr(hba, hba->intr_mask);
 	ufshcd_hba_stop(hba);
 
-	scsi_host_put(hba->host);
-
 	ufshcd_exit_clk_gating(hba);
 	if (ufshcd_is_clkscaling_enabled(hba))
 		devfreq_remove_device(hba->devfreq);
 	ufshcd_hba_exit(hba);
+
+	scsi_host_put(hba->host);
 }
 EXPORT_SYMBOL_GPL(ufshcd_remove);
 
@@ -5547,9 +5547,9 @@ exit_gating:
 	ufshcd_exit_clk_gating(hba);
 out_disable:
 	hba->is_irq_enabled = false;
-	scsi_host_put(host);
 	ufshcd_hba_exit(hba);
 out_error:
+	scsi_host_put(host);
 	return err;
 }
 EXPORT_SYMBOL_GPL(ufshcd_init);
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/3 scsi: ufs: fix unbalanced power.usage_count after reloading driver

In reply to Akinobu Mita

On driver removal, pm_runtime_get_sync() is called, but pm_runtime_put_sync() is missed. So once the driver is reloaded, the device's power.usage_count is unbalanced and the idle callback for the device will never be called.

Cc Vinayak Holikatti <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Dolev Raviv <[email protected]>
Cc Sujit Reddy Thumma <[email protected]>
Cc Subhash Jadavani <[email protected]>
Cc Maya Erez <[email protected]>
Cc Sahitya Tummala <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/ufs/ufshcd-pltfrm.c +1 -0
index 7db9564..4164108 100644
@@ -368,6 +368,7 @@ static int ufshcd_pltfrm_remove(struct platform_device *pdev)
 
 	pm_runtime_get_sync(&(pdev)->dev);
 	ufshcd_remove(hba);
+	pm_runtime_put_sync(&pdev->dev);
 	return 0;
 }
 
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/3 scsi: ufs: fix unbalanced power.disable_depth after reloading driver

In reply to Akinobu Mita

Every time the driver is reloaded, the warning message "Unbalanced pm_runtime_enable!" is triggered due to unbalanced power.disable_depth. This is because pm_runtime_enable() is called during driver probe but pm_runtime_disable() is missed on driver remove.

This also restores the device's runtime PM status to 'suspended' on driver remove as it was set to 'active' during driver probe.

Cc Vinayak Holikatti <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Dolev Raviv <[email protected]>
Cc Sujit Reddy Thumma <[email protected]>
Cc Maya Erez <[email protected]>
Cc Raviv Shvili <[email protected]>
Cc Sahitya Tummala <[email protected]>
Cc Subhash Jadavani <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/scsi/ufs/ufshcd-pltfrm.c +4 -0
index 4164108..b91cf09c 100644
@@ -369,6 +369,10 @@ static int ufshcd_pltfrm_remove(struct platform_device *pdev)
 	pm_runtime_get_sync(&(pdev)->dev);
 	ufshcd_remove(hba);
 	pm_runtime_put_sync(&pdev->dev);
+
+	pm_runtime_disable(&pdev->dev);
+	pm_runtime_set_suspended(&pdev->dev);
+
 	return 0;
 }
 
Signature · 1 line
1.9.1