scsi: ufs: fix several issues caused by driver reloading
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
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().
--- drivers/scsi/ufs/ufshcd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/ufs/ufshcd.c +3 -3
@@ -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
PATCH 2/3 scsi: ufs: fix unbalanced power.usage_count after reloading driver
In reply to Akinobu MitaOn 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.
--- drivers/scsi/ufs/ufshcd-pltfrm.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/ufs/ufshcd-pltfrm.c +1 -0
@@ -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
PATCH 3/3 scsi: ufs: fix unbalanced power.disable_depth after reloading driver
In reply to Akinobu MitaEvery 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.
--- drivers/scsi/ufs/ufshcd-pltfrm.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/ufs/ufshcd-pltfrm.c +4 -0
@@ -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