All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] scsi: ufs: fix several issues caused by driver reloading
@ 2015-03-27 23:51 Akinobu Mita
  2015-03-27 23:51 ` [PATCH 1/3] scsi: ufs: avoid using hostdata after scsi_host_put() Akinobu Mita
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Akinobu Mita @ 2015-03-27 23:51 UTC (permalink / raw)
  To: linux-scsi; +Cc: Akinobu Mita

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(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] scsi: ufs: avoid using hostdata after scsi_host_put()
  2015-03-27 23:51 [PATCH 0/3] scsi: ufs: fix several issues caused by driver reloading Akinobu Mita
@ 2015-03-27 23:51 ` Akinobu Mita
  2015-03-27 23:51 ` [PATCH 2/3] scsi: ufs: fix unbalanced power.usage_count after reloading driver Akinobu Mita
  2015-03-27 23:51 ` [PATCH 3/3] scsi: ufs: fix unbalanced power.disable_depth " Akinobu Mita
  2 siblings, 0 replies; 4+ messages in thread
From: Akinobu Mita @ 2015-03-27 23:51 UTC (permalink / raw)
  To: linux-scsi
  Cc: Akinobu Mita, Vinayak Holikatti, James E.J. Bottomley,
	Christoph Hellwig, Dolev Raviv, Sujit Reddy Thumma,
	Subhash Jadavani, Hannes Reinecke, Sahitya Tummala

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

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Vinayak Holikatti <vinholikatti@gmail.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dolev Raviv <draviv@codeaurora.org>
Cc: Sujit Reddy Thumma <sthumma@codeaurora.org>
Cc: Subhash Jadavani <subhashj@codeaurora.org>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Sahitya Tummala <stummala@codeaurora.org>
Cc: linux-scsi@vger.kernel.org
---
 drivers/scsi/ufs/ufshcd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 5d60a86..4e4de32 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -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);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] scsi: ufs: fix unbalanced power.usage_count after reloading driver
  2015-03-27 23:51 [PATCH 0/3] scsi: ufs: fix several issues caused by driver reloading Akinobu Mita
  2015-03-27 23:51 ` [PATCH 1/3] scsi: ufs: avoid using hostdata after scsi_host_put() Akinobu Mita
@ 2015-03-27 23:51 ` Akinobu Mita
  2015-03-27 23:51 ` [PATCH 3/3] scsi: ufs: fix unbalanced power.disable_depth " Akinobu Mita
  2 siblings, 0 replies; 4+ messages in thread
From: Akinobu Mita @ 2015-03-27 23:51 UTC (permalink / raw)
  To: linux-scsi
  Cc: Akinobu Mita, Vinayak Holikatti, James E.J. Bottomley,
	Christoph Hellwig, Dolev Raviv, Sujit Reddy Thumma,
	Subhash Jadavani, Maya Erez, Sahitya Tummala, Rafael J. Wysocki

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.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Vinayak Holikatti <vinholikatti@gmail.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dolev Raviv <draviv@codeaurora.org>
Cc: Sujit Reddy Thumma <sthumma@codeaurora.org>
Cc: Subhash Jadavani <subhashj@codeaurora.org>
Cc: Maya Erez <merez@codeaurora.org>
Cc: Sahitya Tummala <stummala@codeaurora.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: linux-scsi@vger.kernel.org
---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 7db9564..4164108 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -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;
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] scsi: ufs: fix unbalanced power.disable_depth after reloading driver
  2015-03-27 23:51 [PATCH 0/3] scsi: ufs: fix several issues caused by driver reloading Akinobu Mita
  2015-03-27 23:51 ` [PATCH 1/3] scsi: ufs: avoid using hostdata after scsi_host_put() Akinobu Mita
  2015-03-27 23:51 ` [PATCH 2/3] scsi: ufs: fix unbalanced power.usage_count after reloading driver Akinobu Mita
@ 2015-03-27 23:51 ` Akinobu Mita
  2 siblings, 0 replies; 4+ messages in thread
From: Akinobu Mita @ 2015-03-27 23:51 UTC (permalink / raw)
  To: linux-scsi
  Cc: Akinobu Mita, Vinayak Holikatti, James E.J. Bottomley,
	Christoph Hellwig, Dolev Raviv, Sujit Reddy Thumma, Maya Erez,
	Raviv Shvili, Sahitya Tummala, Subhash Jadavani,
	Rafael J. Wysocki

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.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Vinayak Holikatti <vinholikatti@gmail.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dolev Raviv <draviv@codeaurora.org>
Cc: Sujit Reddy Thumma <sthumma@codeaurora.org>
Cc: Maya Erez <merez@codeaurora.org>
Cc: Raviv Shvili <rshvili@codeaurora.org>
Cc: Sahitya Tummala <stummala@codeaurora.org>
Cc: Subhash Jadavani <subhashj@codeaurora.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: linux-scsi@vger.kernel.org
---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 4164108..b91cf09c 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -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;
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-27 23:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-27 23:51 [PATCH 0/3] scsi: ufs: fix several issues caused by driver reloading Akinobu Mita
2015-03-27 23:51 ` [PATCH 1/3] scsi: ufs: avoid using hostdata after scsi_host_put() Akinobu Mita
2015-03-27 23:51 ` [PATCH 2/3] scsi: ufs: fix unbalanced power.usage_count after reloading driver Akinobu Mita
2015-03-27 23:51 ` [PATCH 3/3] scsi: ufs: fix unbalanced power.disable_depth " Akinobu Mita

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.