Skip to contentSkip to conversation

scsi: ufs: runtime pm fixes

PATCH In review Rajendra Nayak 2 participants 5 messages Mar 8, 2019 – Mar 12, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover scsi: ufs: runtime pm fixes

These are some runtime pm fixes I stumbled upon while working on adding support for controlling multiple power domains (needed on qualcomm sdm845 platforms) in the ufshcd-pltfrm driver.

Rajendra Nayak (3):
scsi: ufs: Fix runtime pm handling in ufshcd-pltfrm
scsi: ufs: Add error checks for pm_runtime_get_sync()
scsi: ufs: qcom: Remove unnecessary runtime pm calls

 drivers/scsi/ufs/ufs-qcom.c      | 2 --
 drivers/scsi/ufs/ufshcd-pltfrm.c | 3 +++
 drivers/scsi/ufs/ufshcd.c        | 5 ++++-
 3 files changed, 7 insertions(+), 3 deletions(-)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#1 lore raw

PATCH 1/3 scsi: ufs: Fix runtime pm handling in ufshcd-pltfrm

runtime pm calls as part of ufshcd_init() can trigger a ufshcd_runtime_suspend() which always fails until the point we do a platform_set_drvdata(), setting the devices 'power.runtime_error'

Use pm_runtime_get_noresume()/pm_runtime_put_noidle() to prevent this from happening.

---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/scsi/ufs/ufshcd-pltfrm.c +3 -0
index 895a9b5ac989..974441fa4e75 100644
@@ -340,6 +340,7 @@ int ufshcd_pltfrm_init(struct platform_device *pdev,
 		goto dealloc_host;
 	}
 
+	pm_runtime_get_noresume(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
 
@@ -352,12 +353,14 @@ int ufshcd_pltfrm_init(struct platform_device *pdev,
 	}
 
 	platform_set_drvdata(pdev, hba);
+	pm_runtime_put_noidle(&pdev->dev);
 
 	return 0;
 
 out_disable_rpm:
 	pm_runtime_disable(&pdev->dev);
 	pm_runtime_set_suspended(&pdev->dev);
+	pm_runtime_put_noidle(&pdev->dev);
 dealloc_host:
 	ufshcd_dealloc_host(hba);
 out:
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#2 lore raw

PATCH 2/3 scsi: ufs: Add error checks for pm_runtime_get_sync()

In reply to Rajendra Nayak

Add an error check for pm_runtime_get_sync(), ignoring this can hide issues with the runtime pm handling in the driver.

---
 drivers/scsi/ufs/ufshcd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +4 -1
index 2ddf24466a62..060dc38cc582 100644
@@ -8357,7 +8357,10 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
 	}
 
 	/* Hold auto suspend until async scan completes */
-	pm_runtime_get_sync(dev);
+	err = pm_runtime_get_sync(dev);
+	if (err < 0)
+		goto out_remove_scsi_host;
+
 	atomic_set(&hba->scsi_block_reqs_cnt, 0);
 	/*
 	 * We are assuming that device wasn't put in sleep/power-down
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#3 lore raw

RE: [PATCH 2/3] scsi: ufs: Add error checks for pm_runtime_get_sync()

Hi,

Quoted 3 lines

Add an error check for pm_runtime_get_sync(), ignoring this can hide issues with the runtime pm handling in the driver.

Can you elaborate on those issues?
I guess you've encountered some during your bring-up.

Quoted 22 lines
---
 drivers/scsi/ufs/ufshcd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +4 -1
index 2ddf24466a62..060dc38cc582 100644
@@ -8357,7 +8357,10 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem
 *mmio_base, unsigned int irq)
 	}
 
 	/* Hold auto suspend until async scan completes */
-	pm_runtime_get_sync(dev);
+	err = pm_runtime_get_sync(dev);
+	if (err < 0)
+		goto out_remove_scsi_host;
+
 	atomic_set(&hba->scsi_block_reqs_cnt, 0);
 	/*
Quoted 1 line

* We are assuming that device wasn't put in sleep/power-down

On your first patch you are incrementing the device's usage counter, To avoid any suspend during probe, but this comment above state
some assumption of this very same issue.
Is it still valid?

Thanks,
Avri

#4 lore raw

PATCH 3/3 scsi: ufs: qcom: Remove unnecessary runtime pm calls

In reply to Rajendra Nayak

Doing a runtime pm get/put as part of ufs_qcom_testbus_config() seems completely unnecessary, since this is called only early during ufs_qcom_init() when the runtime operations are not completely setup for ufs runtime suspend/resume to even work.

---
 drivers/scsi/ufs/ufs-qcom.c | 2 --
 1 file changed, 2 deletions(-)
drivers/scsi/ufs/ufs-qcom.c +0 -2
index 3aeadb14aae1..3590741eea2f 100644
@@ -1558,7 +1558,6 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host)
 	}
 	mask <<= offset;
 
-	pm_runtime_get_sync(host->hba->dev);
 	ufshcd_hold(host->hba, false);
 	ufshcd_rmwl(host->hba, TEST_BUS_SEL,
 		    (u32)host->testbus.select_major << 19,
@@ -1573,7 +1572,6 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host)
 	 */
 	mb();
 	ufshcd_release(host->hba);
-	pm_runtime_put_sync(host->hba->dev);
 
 	return 0;
 }
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation