Skip to contentSkip to conversation

scsi: ufs: use MASK_EE_STATUS

PATCH Applied [email protected] 3 participants 7 messages Apr 20, 2017 – Apr 26, 2017 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 scsi: ufs: use MASK_EE_STATUS

From: Tomohiro Kusumi <[email protected]>

MASK_EE_STATUS added by 66ec6d59 was unused, but it seems to have been defined to do this.

---
 drivers/scsi/ufs/ufshcd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +2 -2
index 096e95b..9278666 100644
@@ -4717,7 +4717,7 @@ static int ufshcd_disable_ee(struct ufs_hba *hba, u16 mask)
 		goto out;
 
 	val = hba->ee_ctrl_mask & ~mask;
-	val &= 0xFFFF; /* 2 bytes */
+	val &= MASK_EE_STATUS;
 	err = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR,
 			QUERY_ATTR_IDN_EE_CONTROL, 0, 0, &val);
 	if (!err)
@@ -4745,7 +4745,7 @@ static int ufshcd_enable_ee(struct ufs_hba *hba, u16 mask)
 		goto out;
 
 	val = hba->ee_ctrl_mask | mask;
-	val &= 0xFFFF; /* 2 bytes */
+	val &= MASK_EE_STATUS;
 	err = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR,
 			QUERY_ATTR_IDN_EE_CONTROL, 0, 0, &val);
 	if (!err)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 2/2 scsi: ufs: make ufshcd_get_lists_status() register operation obvious

From: Tomohiro Kusumi <[email protected]>

It could be just cmp 0xe instead of >>1 and cmp 0x7, with readable code.

---
 drivers/scsi/ufs/ufshcd.c | 11 +----------
 drivers/scsi/ufs/ufshci.h |  4 ++++
 2 files changed, 5 insertions(+), 10 deletions(-)
drivers/scsi/ufs/ufshcd.c +1 -10
index 9278666..ad9532b 100644
@@ -668,16 +668,7 @@ static inline void ufshcd_outstanding_req_clear(struct ufs_hba *hba, int tag)
  */
 static inline int ufshcd_get_lists_status(u32 reg)
 {
-	/*
-	 * The mask 0xFF is for the following HCS register bits
-	 * Bit		Description
-	 *  0		Device Present
-	 *  1		UTRLRDY
-	 *  2		UTMRLRDY
-	 *  3		UCRDY
-	 * 4-7		reserved
-	 */
-	return ((reg & 0xFF) >> 1) ^ 0x07;
+	return !((reg & UFSHCD_STATUS_READY) == (u32)UFSHCD_STATUS_READY);
 }
 
 /**
drivers/scsi/ufs/ufshci.h +4 -0
index d14e9b9..8cd4f0e 100644
@@ -159,6 +159,10 @@ enum {
 #define DEVICE_ERROR_INDICATOR			UFS_BIT(5)
 #define UIC_POWER_MODE_CHANGE_REQ_STATUS_MASK	UFS_MASK(0x7, 8)
 
+#define UFSHCD_STATUS_READY	(UTP_TRANSFER_REQ_LIST_READY |\
+				UTP_TASK_REQ_LIST_READY |\
+				UIC_COMMAND_READY)
+
 enum {
 	PWR_OK		= 0x0,
 	PWR_LOCAL	= 0x01,
Signature · 1 line
2.9.3
#2 lore raw

Re: [PATCH 2/2] scsi: ufs: make ufshcd_get_lists_status() register operation obvious

Quoted 20 lines · On 2017-04-20 05:01, [email protected] wrote:

From: Tomohiro Kusumi <[email protected]>

It could be just cmp 0xe instead of >>1 and cmp 0x7, with readable code.

---
 drivers/scsi/ufs/ufshcd.c | 11 +----------
 drivers/scsi/ufs/ufshci.h |  4 ++++
 2 files changed, 5 insertions(+), 10 deletions(-)
drivers/scsi/ufs/ufshcd.c +0 -1
index 9278666..ad9532b 100644
@@ -668,16 +668,7 @@ static inline void
 ufshcd_outstanding_req_clear(struct ufs_hba *hba, int tag)
  */
 static inline int ufshcd_get_lists_status(u32 reg)
 {
-	/*

drivers/scsi/ufs/ufshcd.c static inline void · line 672

Quoted 10 lines
drivers/scsi/ufs/ufshcd.c +1 -9
-	 * The mask 0xFF is for the following HCS register bits
-	 * Bit		Description
-	 *  0		Device Present
-	 *  1		UTRLRDY
-	 *  2		UTMRLRDY
-	 *  3		UCRDY
-	 * 4-7		reserved
-	 */
-	return ((reg & 0xFF) >> 1) ^ 0x07;
+	return !((reg & UFSHCD_STATUS_READY) == (u32)UFSHCD_STATUS_READY);

yes, this makes it more readable, but i am not sure why we will have to type cast UFSHCD_STATUS_READY macro to u32 type? i think it is redundant, let me know if you think otherwise.

Quoted 18 lines
drivers/scsi/ufs/ufshcd.c +0 -0
 }
 

/**

drivers/scsi/ufs/ufshci.h +4 -0
index d14e9b9..8cd4f0e 100644
@@ -159,6 +159,10 @@ enum {
 #define DEVICE_ERROR_INDICATOR			UFS_BIT(5)
 #define UIC_POWER_MODE_CHANGE_REQ_STATUS_MASK	UFS_MASK(0x7, 8)
 
+#define UFSHCD_STATUS_READY	(UTP_TRANSFER_REQ_LIST_READY |\
+				UTP_TASK_REQ_LIST_READY |\
+				UIC_COMMAND_READY)
+
 enum {
 	PWR_OK		= 0x0,
 	PWR_LOCAL	= 0x01,
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#3 lore raw

Re: [PATCH 2/2] scsi: ufs: make ufshcd_get_lists_status() register operation obvious

Hi,
Thanks for your review.

Quoted 1 line

yes, this makes it more readable, but i am not sure why we will have to type cast UFSHCD_STATUS_READY macro to u32 type? i think it is redundant, let me know if you think otherwise.

Sorry, nothing really.
I'll resend without u32 cast in short (i.e. change to below).

return !((reg & UFSHCD_STATUS_READY) == UFSHCD_STATUS_READY);

2017-04-26 19:49 GMT+03:00 Subhash Jadavani <[email protected]>:

Quoted 61 lines · On 2017-04-20 05:01, [email protected] wrote:
Quoted 21 lines

From: Tomohiro Kusumi <[email protected]>

It could be just cmp 0xe instead of >>1 and cmp 0x7, with readable code.

---
 drivers/scsi/ufs/ufshcd.c | 11 +----------
 drivers/scsi/ufs/ufshci.h |  4 ++++
 2 files changed, 5 insertions(+), 10 deletions(-)
drivers/scsi/ufs/ufshcd.c +0 -1
index 9278666..ad9532b 100644
@@ -668,16 +668,7 @@ static inline void
 ufshcd_outstanding_req_clear(struct ufs_hba *hba, int tag)
  */
 static inline int ufshcd_get_lists_status(u32 reg)
 {
-       /*

drivers/scsi/ufs/ufshcd.c static inline void · line 672

Quoted 10 lines
drivers/scsi/ufs/ufshcd.c +1 -9
-        * The mask 0xFF is for the following HCS register bits
-        * Bit          Description
-        *  0           Device Present
-        *  1           UTRLRDY
-        *  2           UTMRLRDY
-        *  3           UCRDY
-        * 4-7          reserved
-        */
-       return ((reg & 0xFF) >> 1) ^ 0x07;
+       return !((reg & UFSHCD_STATUS_READY) == (u32)UFSHCD_STATUS_READY);

yes, this makes it more readable, but i am not sure why we will have to type cast UFSHCD_STATUS_READY macro to u32 type? i think it is redundant, let me know if you think otherwise.

Quoted 8 lines
drivers/scsi/ufs/ufshcd.c +0 -0
 }
 

/**

drivers/scsi/ufs/ufshci.h +0 -0
index d14e9b9..8cd4f0e 100644

drivers/scsi/ufs/ufshci.h enum { · line 168

Quoted 10 lines
drivers/scsi/ufs/ufshci.h +4 -0
@@ -159,6 +159,10 @@ enum {
 #define DEVICE_ERROR_INDICATOR                 UFS_BIT(5)
 #define UIC_POWER_MODE_CHANGE_REQ_STATUS_MASK  UFS_MASK(0x7, 8)
 
+#define UFSHCD_STATUS_READY    (UTP_TRANSFER_REQ_LIST_READY |\
+                               UTP_TASK_REQ_LIST_READY |\
+                               UIC_COMMAND_READY)
+
 enum {
        PWR_OK          = 0x0,
        PWR_LOCAL       = 0x01,

--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

Reviewed-by on v1 1/2
#5 lore raw
In reply to [email protected]
Quoted 33 lines · On 2017-04-20 05:01, [email protected] wrote:

From: Tomohiro Kusumi <[email protected]>

MASK_EE_STATUS added by 66ec6d59 was unused, but it seems to have been defined to do this.

---
 drivers/scsi/ufs/ufshcd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +1 -1
index 096e95b..9278666 100644
@@ -4717,7 +4717,7 @@ static int ufshcd_disable_ee(struct ufs_hba
 *hba, u16 mask)
 		goto out;
 
 	val = hba->ee_ctrl_mask & ~mask;
-	val &= 0xFFFF; /* 2 bytes */
+	val &= MASK_EE_STATUS;
 	err = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR,
 			QUERY_ATTR_IDN_EE_CONTROL, 0, 0, &val);
drivers/scsi/ufs/ufshcd.c +1 -1
 	if (!err)
@@ -4745,7 +4745,7 @@ static int ufshcd_enable_ee(struct ufs_hba *hba, 
 u16 mask)
 		goto out;
 
 	val = hba->ee_ctrl_mask | mask;
-	val &= 0xFFFF; /* 2 bytes */
+	val &= MASK_EE_STATUS;
 	err = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR,
 			QUERY_ATTR_IDN_EE_CONTROL, 0, 0, &val);
Quoted 1 line

if (!err)

Looks good to me.

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#6 lore raw
In reply to [email protected]
Quoted 3 lines

MASK_EE_STATUS added by 66ec6d59 was unused, but it seems to have been defined to do this.

Applied to 4.12/scsi-queue. Thank you!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering