Linux-ARM-MSM Archive on lore.kernel.org
 help / color / Atom feed
* [<PATCH v1> 1/1] scsi: ufs: Resume ufs host before accessing ufs device
@ 2020-03-24 21:48 Asutosh Das
  2020-03-25 10:35 ` Avri Altman
  2020-03-27  2:11 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Asutosh Das @ 2020-03-24 21:48 UTC (permalink / raw)
  To: cang, martin.petersen, linux-scsi
  Cc: Nitin Rawat, linux-arm-msm, Asutosh Das, Alim Akhtar,
	Avri Altman, James E.J. Bottomley, Stanley Chu, Bean Huo,
	Tomas Winkler, open list

From: Nitin Rawat <nitirawa@codeaurora.org>

As a part of sysfs reading of descriptors/attributes/flags,
query commands should only be executed when hba's
power runtime status is active.
To guarantee this, add pm_runtime_get/put_sync()
to those paths where query commands are sent.

Signed-off-by: Nitin Rawat <nitirawa@codeaurora.org>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
---
 drivers/scsi/ufs/ufs-sysfs.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
index dbdf8b0..92a63ee 100644
--- a/drivers/scsi/ufs/ufs-sysfs.c
+++ b/drivers/scsi/ufs/ufs-sysfs.c
@@ -210,8 +210,10 @@ static ssize_t ufs_sysfs_read_desc_param(struct ufs_hba *hba,
 	if (param_size > 8)
 		return -EINVAL;
 
+	pm_runtime_get_sync(hba->dev);
 	ret = ufshcd_read_desc_param(hba, desc_id, desc_index,
 				param_offset, desc_buf, param_size);
+	pm_runtime_put_sync(hba->dev);
 	if (ret)
 		return -EINVAL;
 	switch (param_size) {
@@ -558,6 +560,7 @@ static ssize_t _name##_show(struct device *dev,				\
 	desc_buf = kzalloc(QUERY_DESC_MAX_SIZE, GFP_ATOMIC);		\
 	if (!desc_buf)                                                  \
 		return -ENOMEM;                                         \
+	pm_runtime_get_sync(hba->dev);					\
 	ret = ufshcd_query_descriptor_retry(hba,			\
 		UPIU_QUERY_OPCODE_READ_DESC, QUERY_DESC_IDN_DEVICE,	\
 		0, 0, desc_buf, &desc_len);				\
@@ -574,6 +577,7 @@ static ssize_t _name##_show(struct device *dev,				\
 		goto out;						\
 	ret = snprintf(buf, PAGE_SIZE, "%s\n", desc_buf);		\
 out:									\
+	pm_runtime_put_sync(hba->dev);					\
 	kfree(desc_buf);						\
 	return ret;							\
 }									\
@@ -604,9 +608,13 @@ static ssize_t _name##_show(struct device *dev,				\
 	struct device_attribute *attr, char *buf)			\
 {									\
 	bool flag;							\
+	int ret;							\
 	struct ufs_hba *hba = dev_get_drvdata(dev);			\
-	if (ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG,		\
-		QUERY_FLAG_IDN##_uname, &flag))				\
+	pm_runtime_get_sync(hba->dev);					\
+	ret = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG,	\
+		QUERY_FLAG_IDN##_uname, &flag);				\
+	pm_runtime_put_sync(hba->dev);					\
+	if (ret)							\
 		return -EINVAL;						\
 	return sprintf(buf, "%s\n", flag ? "true" : "false");		\
 }									\
@@ -644,8 +652,12 @@ static ssize_t _name##_show(struct device *dev,				\
 {									\
 	struct ufs_hba *hba = dev_get_drvdata(dev);			\
 	u32 value;							\
-	if (ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR,		\
-		QUERY_ATTR_IDN##_uname, 0, 0, &value))			\
+	int ret;							\
+	pm_runtime_get_sync(hba->dev);					\
+	ret = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR,	\
+		QUERY_ATTR_IDN##_uname, 0, 0, &value);			\
+	pm_runtime_put_sync(hba->dev);					\
+	if (ret)							\
 		return -EINVAL;						\
 	return sprintf(buf, "0x%08X\n", value);				\
 }									\
@@ -766,9 +778,13 @@ static ssize_t dyn_cap_needed_attribute_show(struct device *dev,
 	struct scsi_device *sdev = to_scsi_device(dev);
 	struct ufs_hba *hba = shost_priv(sdev->host);
 	u8 lun = ufshcd_scsi_to_upiu_lun(sdev->lun);
+	int ret;
 
-	if (ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR,
-		QUERY_ATTR_IDN_DYN_CAP_NEEDED, lun, 0, &value))
+	pm_runtime_get_sync(hba->dev);
+	ret = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR,
+		QUERY_ATTR_IDN_DYN_CAP_NEEDED, lun, 0, &value);
+	pm_runtime_put_sync(hba->dev);
+	if (ret)
 		return -EINVAL;
 	return sprintf(buf, "0x%08X\n", value);
 }
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.


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

* RE: [<PATCH v1> 1/1] scsi: ufs: Resume ufs host before accessing ufs device
  2020-03-24 21:48 [<PATCH v1> 1/1] scsi: ufs: Resume ufs host before accessing ufs device Asutosh Das
@ 2020-03-25 10:35 ` Avri Altman
  2020-03-27  2:11 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Avri Altman @ 2020-03-25 10:35 UTC (permalink / raw)
  To: Asutosh Das, cang, martin.petersen, linux-scsi
  Cc: Nitin Rawat, linux-arm-msm, Alim Akhtar, James E.J. Bottomley,
	Stanley Chu, Bean Huo, Tomas Winkler, open list

> 
> From: Nitin Rawat <nitirawa@codeaurora.org>
> 
> As a part of sysfs reading of descriptors/attributes/flags,
> query commands should only be executed when hba's
> power runtime status is active.
> To guarantee this, add pm_runtime_get/put_sync()
> to those paths where query commands are sent.
> 
> Signed-off-by: Nitin Rawat <nitirawa@codeaurora.org>
> Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>


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

* Re: [<PATCH v1> 1/1] scsi: ufs: Resume ufs host before accessing ufs device
  2020-03-24 21:48 [<PATCH v1> 1/1] scsi: ufs: Resume ufs host before accessing ufs device Asutosh Das
  2020-03-25 10:35 ` Avri Altman
@ 2020-03-27  2:11 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2020-03-27  2:11 UTC (permalink / raw)
  To: Asutosh Das
  Cc: cang, martin.petersen, linux-scsi, Nitin Rawat, linux-arm-msm,
	Alim Akhtar, Avri Altman, James E.J. Bottomley, Stanley Chu,
	Bean Huo, Tomas Winkler, open list


Asutosh,

> As a part of sysfs reading of descriptors/attributes/flags, query
> commands should only be executed when hba's power runtime status is
> active.  To guarantee this, add pm_runtime_get/put_sync() to those
> paths where query commands are sent.

Applied to 5.7/scsi-queue, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-24 21:48 [<PATCH v1> 1/1] scsi: ufs: Resume ufs host before accessing ufs device Asutosh Das
2020-03-25 10:35 ` Avri Altman
2020-03-27  2:11 ` Martin K. Petersen

Linux-ARM-MSM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-msm/0 linux-arm-msm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-msm linux-arm-msm/ https://lore.kernel.org/linux-arm-msm \
		linux-arm-msm@vger.kernel.org
	public-inbox-index linux-arm-msm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-arm-msm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git