Skip to contentSkip to conversation

ufs: introduce UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR quirk

PATCH Superseded Kiwoong Kim 3 participants 5 messages Nov 16, 2016 – Nov 17, 2016 SCSI

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ufs: introduce UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR quirk

Some UFS host controllers may clear a transfer request slot by setting an associated bit in UTRLCLR/UTMRLCLR to 1, not 0. That's opposite to what UFS spec describes.

---
 drivers/scsi/ufs/ufshcd.c | 28 ++++++++++++++++++++++++++--
 drivers/scsi/ufs/ufshcd.h |  7 +++++++
 2 files changed, 33 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +26 -2
index d6e3112..c9cf011 100644
@@ -392,7 +392,31 @@ static inline void ufshcd_put_tm_slot(struct ufs_hba *hba, int slot)
  */
 static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos)
 {
-	ufshcd_writel(hba, ~(1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR);
+	u32 clear;
+
+	if (hba->quirks & UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR)
+		clear = (1 << pos);
+	else
+		clear = ~(1 << pos);
+
+	ufshcd_writel(hba, clear, REG_UTP_TRANSFER_REQ_LIST_CLEAR);
+}
+
+/**
+ * ufshcd_utmrl_clear - Clear a bit in UTRMLCLR register
+ * @hba: per adapter instance
+ * @pos: position of the bit to be cleared
+ */
+static inline void ufshcd_utmrl_clear(struct ufs_hba *hba, u32 pos)
+{
+	u32 clear;
+
+	if (hba->quirks & UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR)
+		clear = (1 << pos);
+	else
+		clear = ~(1 << pos);
+
+	ufshcd_writel(hba, clear, REG_UTP_TASK_REQ_LIST_CLEAR);
 }
 
 /**
@@ -4312,7 +4336,7 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag)
 		goto out;
 
 	spin_lock_irqsave(hba->host->host_lock, flags);
-	ufshcd_writel(hba, ~(1 << tag), REG_UTP_TASK_REQ_LIST_CLEAR);
+	ufshcd_utmrl_clear(hba, tag);
 	spin_unlock_irqrestore(hba->host->host_lock, flags);
 
 	/* poll for max. 1 sec to clear door bell register by h/w */
drivers/scsi/ufs/ufshcd.h +7 -0
index 7d9ff22..9838598 100644
@@ -491,6 +491,13 @@ struct ufs_hba {
 	 */
 	#define UFSHCD_QUIRK_PRDT_BYTE_GRAN			UFS_BIT(7)
 
+	/*
+	 * This quirk needs to be enabled if the host contoller has to set
+	 * the bit corresponding the slot to be cleared to 1, not 0 as
+	 * described in UFS spec.
+	 */
+	#define UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR                UFS_BIT(8)
+
 	unsigned int quirks;	/* Deviations from standard UFSHCI spec. */
 
 	/* Device deviations from standard UFS device spec. */
Signature · 1 line
2.1.4
Reviewed-by on v3 1/1
#1 lore raw
Quoted 4 lines · Kiwoong Kim

Some UFS host controllers may clear a transfer request slot by setting an associated bit in UTRLCLR/UTMRLCLR to 1, not 0. That's opposite to what UFS spec describes.

This was the comment on v2: "As Martin mentioned in other email, please separate this version history from commit text with line having "----" before the start of version history."
So i would have expected the patch version to be still v2 and just add the version history separator added before version history. But you posted v3 and removed the version history altogether. As far as patch contents are concerned, it looks good to me hence i am adding by reviewed-by. But please make sure to keep the version history intact for fewer patches.

Quoted 72 lines
---
 drivers/scsi/ufs/ufshcd.c | 28 ++++++++++++++++++++++++++--
 drivers/scsi/ufs/ufshcd.h |  7 +++++++
 2 files changed, 33 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +25 -1
index d6e3112..c9cf011 100644
@@ -392,7 +392,31 @@ static inline void ufshcd_put_tm_slot(struct
 ufs_hba *hba, int slot)
  */
 static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos)
 {
-	ufshcd_writel(hba, ~(1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR);
+	u32 clear;
+
+	if (hba->quirks & UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR)
+		clear = (1 << pos);
+	else
+		clear = ~(1 << pos);
+
+	ufshcd_writel(hba, clear, REG_UTP_TRANSFER_REQ_LIST_CLEAR);
+}
+
+/**
+ * ufshcd_utmrl_clear - Clear a bit in UTRMLCLR register
+ * @hba: per adapter instance
+ * @pos: position of the bit to be cleared
+ */
+static inline void ufshcd_utmrl_clear(struct ufs_hba *hba, u32 pos)
+{
+	u32 clear;
+
+	if (hba->quirks & UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR)
+		clear = (1 << pos);
+	else
+		clear = ~(1 << pos);
+
+	ufshcd_writel(hba, clear, REG_UTP_TASK_REQ_LIST_CLEAR);
 }
 

/**

drivers/scsi/ufs/ufshcd.c +1 -1
@@ -4312,7 +4336,7 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba
 *hba, int tag)
 		goto out;
 
 	spin_lock_irqsave(hba->host->host_lock, flags);
-	ufshcd_writel(hba, ~(1 << tag), REG_UTP_TASK_REQ_LIST_CLEAR);
+	ufshcd_utmrl_clear(hba, tag);
 	spin_unlock_irqrestore(hba->host->host_lock, flags);
 
drivers/scsi/ufs/ufshcd.c +0 -0
 	/* poll for max. 1 sec to clear door bell register by h/w */
drivers/scsi/ufs/ufshcd.h +7 -0
index 7d9ff22..9838598 100644
@@ -491,6 +491,13 @@ struct ufs_hba {
 	 */
 	#define UFSHCD_QUIRK_PRDT_BYTE_GRAN			UFS_BIT(7)
 
+	/*
+	 * This quirk needs to be enabled if the host contoller has to set
+	 * the bit corresponding the slot to be cleared to 1, not 0 as
+	 * described in UFS spec.
+	 */
+	#define UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR                UFS_BIT(8)
+
 	unsigned int quirks;	/* Deviations from standard UFSHCI spec. */
 
 	/* Device deviations from standard UFS device spec. */
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#4 lore raw
In reply to Kiwoong Kim
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Kiwoong" == Kiwoong Kim <[email protected]> writes:

Hi Kiwoong,

Kiwoong> Some UFS host controllers may clear a transfer request slot by Kiwoong> setting an associated bit in UTRLCLR/UTMRLCLR to 1, not 0. Kiwoong> That's opposite to what UFS spec describes.

These don't apply cleanly to 4.10/scsi-queue. Please send a v4, ideally as a series.

Thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#2 lore raw
In reply to Subhash Jadavani
Quoted 11 lines · Kiwoong Kim
Quoted 4 lines

Some UFS host controllers may clear a transfer request slot by setting an associated bit in UTRLCLR/UTMRLCLR to 1, not 0. That's opposite to what UFS spec describes.

This was the comment on v2: "As Martin mentioned in other email, please separate this version history from commit text with line having "----" before the start of version history."
So i would have expected the patch version to be still v2 and just add the version history separator added before version history. But you

Okay. You mean re-sending it with moving the separator to another line, don't you? I knew that I should update version even if there is a change of commit message and version history. Thank you for your information.

Quoted 4 lines

posted v3 and removed the version history altogether. As far as patch contents are concerned, it looks good to me hence i am adding by reviewed-by. But please make sure to keep the version history intact for fewer patches.

I have one question.
If I would update v4 of this patch as Martin asked, which one should I choose?
1) adding changes from v1~v4
2) adding just something like 'version update' Because there is no difference between v3 and v4.

Quoted 85 lines
Quoted 60 lines
---
 drivers/scsi/ufs/ufshcd.c | 28 ++++++++++++++++++++++++++--
 drivers/scsi/ufs/ufshcd.h |  7 +++++++
 2 files changed, 33 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +25 -1
index d6e3112..c9cf011 100644
@@ -392,7 +392,31 @@ static inline void ufshcd_put_tm_slot(struct
 ufs_hba *hba, int slot)
  */
 static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos)
 {
-	ufshcd_writel(hba, ~(1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR);
+	u32 clear;
+
+	if (hba->quirks & UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR)
+		clear = (1 << pos);
+	else
+		clear = ~(1 << pos);
+
+	ufshcd_writel(hba, clear, REG_UTP_TRANSFER_REQ_LIST_CLEAR);
+}
+
+/**
+ * ufshcd_utmrl_clear - Clear a bit in UTRMLCLR register
+ * @hba: per adapter instance
+ * @pos: position of the bit to be cleared
+ */
+static inline void ufshcd_utmrl_clear(struct ufs_hba *hba, u32 pos)
+{
+	u32 clear;
+
+	if (hba->quirks & UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR)
+		clear = (1 << pos);
+	else
+		clear = ~(1 << pos);
+
+	ufshcd_writel(hba, clear, REG_UTP_TASK_REQ_LIST_CLEAR);
 }
 

/**

drivers/scsi/ufs/ufshcd.c +1 -1
@@ -4312,7 +4336,7 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba
 *hba, int tag)
 		goto out;
 
 	spin_lock_irqsave(hba->host->host_lock, flags);
-	ufshcd_writel(hba, ~(1 << tag), REG_UTP_TASK_REQ_LIST_CLEAR);
+	ufshcd_utmrl_clear(hba, tag);
 	spin_unlock_irqrestore(hba->host->host_lock, flags);
 
drivers/scsi/ufs/ufshcd.c +0 -0
 	/* poll for max. 1 sec to clear door bell register by h/w */
drivers/scsi/ufs/ufshcd.h +0 -0
index 7d9ff22..9838598 100644
@@ -491,6 +491,13 @@ struct ufs_hba {
 	 */

drivers/scsi/ufs/ufshcd.h struct ufs_hba { · line 501

Quoted 10 lines
drivers/scsi/ufs/ufshcd.h +7 -0
 	#define UFSHCD_QUIRK_PRDT_BYTE_GRAN			UFS_BIT(7)
 
+	/*
+	 * This quirk needs to be enabled if the host contoller has to set
+	 * the bit corresponding the slot to be cleared to 1, not 0 as
+	 * described in UFS spec.
+	 */
+	#define UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR                UFS_BIT(8)
+
 	unsigned int quirks;	/* Deviations from standard UFSHCI spec.

*/

drivers/scsi/ufs/ufshcd.h struct ufs_hba { · line 503

Quoted 2 lines
drivers/scsi/ufs/ufshcd.h +0 -0
 	/* Device deviations from standard UFS device spec. */

--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 21 lines · Kiwoong Kim
Quoted 11 lines · Kiwoong Kim
Quoted 4 lines

Some UFS host controllers may clear a transfer request slot by setting an associated bit in UTRLCLR/UTMRLCLR to 1, not 0. That's opposite to what UFS spec describes.

This was the comment on v2: "As Martin mentioned in other email, please separate this version history from commit text with line having "----" before the start of version history."
So i would have expected the patch version to be still v2 and just add the version history separator added before version history. But you

Okay. You mean re-sending it with moving the separator to another line, don't you? I knew that I should update version even if there is a change of commit message and version history. Thank you for your information.

Quoted 4 lines

posted v3 and removed the version history altogether. As far as patch contents are concerned, it looks good to me hence i am adding by reviewed-by. But please make sure to keep the version history intact for fewer patches.

Quoted 6 lines

I have one question.
If I would update v4 of this patch as Martin asked, which one should I choose?
1) adding changes from v1~v4
2) adding just something like 'version update' Because there is no difference between v3 and v4.

You should keep the all the previous version history intact and then add v4 history saying "rebased to 4.10/scsi-queue tip".

Quoted 86 lines
Quoted 86 lines
Quoted 60 lines
---
 drivers/scsi/ufs/ufshcd.c | 28 ++++++++++++++++++++++++++--
 drivers/scsi/ufs/ufshcd.h |  7 +++++++
 2 files changed, 33 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +25 -1
index d6e3112..c9cf011 100644
@@ -392,7 +392,31 @@ static inline void ufshcd_put_tm_slot(struct
 ufs_hba *hba, int slot)
  */
 static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos)
 {
-	ufshcd_writel(hba, ~(1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR);
+	u32 clear;
+
+	if (hba->quirks & UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR)
+		clear = (1 << pos);
+	else
+		clear = ~(1 << pos);
+
+	ufshcd_writel(hba, clear, REG_UTP_TRANSFER_REQ_LIST_CLEAR);
+}
+
+/**
+ * ufshcd_utmrl_clear - Clear a bit in UTRMLCLR register
+ * @hba: per adapter instance
+ * @pos: position of the bit to be cleared
+ */
+static inline void ufshcd_utmrl_clear(struct ufs_hba *hba, u32 pos)
+{
+	u32 clear;
+
+	if (hba->quirks & UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR)
+		clear = (1 << pos);
+	else
+		clear = ~(1 << pos);
+
+	ufshcd_writel(hba, clear, REG_UTP_TASK_REQ_LIST_CLEAR);
 }
 

/**

drivers/scsi/ufs/ufshcd.c +1 -1
@@ -4312,7 +4336,7 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba
 *hba, int tag)
 		goto out;
 
 	spin_lock_irqsave(hba->host->host_lock, flags);
-	ufshcd_writel(hba, ~(1 << tag), REG_UTP_TASK_REQ_LIST_CLEAR);
+	ufshcd_utmrl_clear(hba, tag);
 	spin_unlock_irqrestore(hba->host->host_lock, flags);
 
drivers/scsi/ufs/ufshcd.c +0 -0
 	/* poll for max. 1 sec to clear door bell register by h/w */
drivers/scsi/ufs/ufshcd.h +0 -0
index 7d9ff22..9838598 100644
@@ -491,6 +491,13 @@ struct ufs_hba {
 	 */

drivers/scsi/ufs/ufshcd.h struct ufs_hba { · line 501

Quoted 10 lines
drivers/scsi/ufs/ufshcd.h +7 -0
 	#define UFSHCD_QUIRK_PRDT_BYTE_GRAN			UFS_BIT(7)
 
+	/*
+	 * This quirk needs to be enabled if the host contoller has to set
+	 * the bit corresponding the slot to be cleared to 1, not 0 as
+	 * described in UFS spec.
+	 */
+	#define UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR                UFS_BIT(8)
+
 	unsigned int quirks;	/* Deviations from standard UFSHCI spec.

*/

drivers/scsi/ufs/ufshcd.h struct ufs_hba { · line 503

Quoted 2 lines
drivers/scsi/ufs/ufshcd.h +0 -0
 	/* Device deviations from standard UFS device spec. */

--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project