Skip to contentSkip to conversation

ufshcd quirk cleanup v2

PATCH In review Christoph Hellwig 6 participants 11 messages Feb 21, 2020 – Feb 29, 2020 SCSI

lore
Share & tools
lore
#0 lore raw

Hi all,

this removes lots of dead code from the ufs drivers, an cleans up the quirk handling a little bit.

Changes since v1:
- fix ufshcd_utrl_clear
- minor cleanups

#1 lore raw

PATCH 1/2 ufshcd: remove unused quirks

Remove various quirks that don't have users, as well as the dead code keyed off them.

---
 drivers/scsi/ufs/ufshcd.c | 119 ++++----------------------------------
 drivers/scsi/ufs/ufshcd.h |  22 -------
 2 files changed, 12 insertions(+), 129 deletions(-)
drivers/scsi/ufs/ufshcd.c +12 -107
index abd0e6b05f79..886a8a597e6a 100644
@@ -642,11 +642,7 @@ static inline int ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp)
  */
 static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos)
 {
-	if (hba->quirks & UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR)
-		ufshcd_writel(hba, (1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR);
-	else
-		ufshcd_writel(hba, ~(1 << pos),
-				REG_UTP_TRANSFER_REQ_LIST_CLEAR);
+	ufshcd_writel(hba, ~(1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR);
 }
 
 /**
@@ -656,10 +652,7 @@ static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos)
  */
 static inline void ufshcd_utmrl_clear(struct ufs_hba *hba, u32 pos)
 {
-	if (hba->quirks & UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR)
-		ufshcd_writel(hba, (1 << pos), REG_UTP_TASK_REQ_LIST_CLEAR);
-	else
-		ufshcd_writel(hba, ~(1 << pos), REG_UTP_TASK_REQ_LIST_CLEAR);
+	ufshcd_writel(hba, ~(1 << pos), REG_UTP_TASK_REQ_LIST_CLEAR);
 }
 
 /**
@@ -2093,13 +2086,8 @@ static int ufshcd_map_sg(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 		return sg_segments;
 
 	if (sg_segments) {
-		if (hba->quirks & UFSHCD_QUIRK_PRDT_BYTE_GRAN)
-			lrbp->utr_descriptor_ptr->prd_table_length =
-				cpu_to_le16((u16)(sg_segments *
-					sizeof(struct ufshcd_sg_entry)));
-		else
-			lrbp->utr_descriptor_ptr->prd_table_length =
-				cpu_to_le16((u16) (sg_segments));
+		lrbp->utr_descriptor_ptr->prd_table_length =
+			cpu_to_le16((u16)sg_segments);
 
 		prd_table = (struct ufshcd_sg_entry *)lrbp->ucd_prdt_ptr;
 
@@ -3403,21 +3391,11 @@ static void ufshcd_host_memory_configure(struct ufs_hba *hba)
 				cpu_to_le32(upper_32_bits(cmd_desc_element_addr));
 
 		/* Response upiu and prdt offset should be in double words */
-		if (hba->quirks & UFSHCD_QUIRK_PRDT_BYTE_GRAN) {
-			utrdlp[i].response_upiu_offset =
-				cpu_to_le16(response_offset);
-			utrdlp[i].prd_table_offset =
-				cpu_to_le16(prdt_offset);
-			utrdlp[i].response_upiu_length =
-				cpu_to_le16(ALIGNED_UPIU_SIZE);
-		} else {
-			utrdlp[i].response_upiu_offset =
-				cpu_to_le16((response_offset >> 2));
-			utrdlp[i].prd_table_offset =
-				cpu_to_le16((prdt_offset >> 2));
-			utrdlp[i].response_upiu_length =
-				cpu_to_le16(ALIGNED_UPIU_SIZE >> 2);
-		}
+		utrdlp[i].response_upiu_offset =
+			cpu_to_le16(response_offset >> 2);
+		utrdlp[i].prd_table_offset = cpu_to_le16(prdt_offset >> 2);
+		utrdlp[i].response_upiu_length =
+			cpu_to_le16(ALIGNED_UPIU_SIZE >> 2);
 
 		hba->lrb[i].utr_descriptor_ptr = (utrdlp + i);
 		hba->lrb[i].utrd_dma_addr = hba->utrdl_dma_addr +
@@ -3460,52 +3438,6 @@ static int ufshcd_dme_link_startup(struct ufs_hba *hba)
 			"dme-link-startup: error code %d\n", ret);
 	return ret;
 }
-/**
- * ufshcd_dme_reset - UIC command for DME_RESET
- * @hba: per adapter instance
- *
- * DME_RESET command is issued in order to reset UniPro stack.
- * This function now deal with cold reset.
- *
- * Returns 0 on success, non-zero value on failure
- */
-static int ufshcd_dme_reset(struct ufs_hba *hba)
-{
-	struct uic_command uic_cmd = {0};
-	int ret;
-
-	uic_cmd.command = UIC_CMD_DME_RESET;
-
-	ret = ufshcd_send_uic_cmd(hba, &uic_cmd);
-	if (ret)
-		dev_err(hba->dev,
-			"dme-reset: error code %d\n", ret);
-
-	return ret;
-}
-
-/**
- * ufshcd_dme_enable - UIC command for DME_ENABLE
- * @hba: per adapter instance
- *
- * DME_ENABLE command is issued in order to enable UniPro stack.
- *
- * Returns 0 on success, non-zero value on failure
- */
-static int ufshcd_dme_enable(struct ufs_hba *hba)
-{
-	struct uic_command uic_cmd = {0};
-	int ret;
-
-	uic_cmd.command = UIC_CMD_DME_ENABLE;
-
-	ret = ufshcd_send_uic_cmd(hba, &uic_cmd);
-	if (ret)
-		dev_err(hba->dev,
-			"dme-reset: error code %d\n", ret);
-
-	return ret;
-}
 
 static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba)
 {
@@ -4217,7 +4149,7 @@ static inline void ufshcd_hba_stop(struct ufs_hba *hba, bool can_sleep)
 }
 
 /**
- * ufshcd_hba_execute_hce - initialize the controller
+ * ufshcd_hba_enable - initialize the controller
  * @hba: per adapter instance
  *
  * The controller resets itself and controller firmware initialization
@@ -4226,7 +4158,7 @@ static inline void ufshcd_hba_stop(struct ufs_hba *hba, bool can_sleep)
  *
  * Returns 0 on success, non-zero value on failure
  */
-static int ufshcd_hba_execute_hce(struct ufs_hba *hba)
+int ufshcd_hba_enable(struct ufs_hba *hba)
 {
 	int retry;
 
@@ -4274,32 +4206,6 @@ static int ufshcd_hba_execute_hce(struct ufs_hba *hba)
 
 	return 0;
 }
-
-int ufshcd_hba_enable(struct ufs_hba *hba)
-{
-	int ret;
-
-	if (hba->quirks & UFSHCI_QUIRK_BROKEN_HCE) {
-		ufshcd_set_link_off(hba);
-		ufshcd_vops_hce_enable_notify(hba, PRE_CHANGE);
-
-		/* enable UIC related interrupts */
-		ufshcd_enable_intr(hba, UFSHCD_UIC_MASK);
-		ret = ufshcd_dme_reset(hba);
-		if (!ret) {
-			ret = ufshcd_dme_enable(hba);
-			if (!ret)
-				ufshcd_vops_hce_enable_notify(hba, POST_CHANGE);
-			if (ret)
-				dev_err(hba->dev,
-					"Host controller enable failed with non-hce\n");
-		}
-	} else {
-		ret = ufshcd_hba_execute_hce(hba);
-	}
-
-	return ret;
-}
 EXPORT_SYMBOL_GPL(ufshcd_hba_enable);
 
 static int ufshcd_disable_tx_lcc(struct ufs_hba *hba, bool peer)
@@ -4869,8 +4775,7 @@ static irqreturn_t ufshcd_transfer_req_compl(struct ufs_hba *hba)
 	 * false interrupt if device completes another request after resetting
 	 * aggregation and before reading the DB.
 	 */
-	if (ufshcd_is_intr_aggr_allowed(hba) &&
-	    !(hba->quirks & UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR))
+	if (ufshcd_is_intr_aggr_allowed(hba))
 		ufshcd_reset_intr_aggr(hba);
 
 	tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
drivers/scsi/ufs/ufshcd.h +0 -22
index 2ae6c7c8528c..9c2b80f87b9f 100644
@@ -612,28 +612,6 @@ struct ufs_hba {
 	 */
 	#define UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION		0x20
 
-	/*
-	 * This quirk needs to be enabled if the host contoller regards
-	 * resolution of the values of PRDTO and PRDTL in UTRD as byte.
-	 */
-	#define UFSHCD_QUIRK_PRDT_BYTE_GRAN			0x80
-
-	/*
-	 * Clear handling for transfer/task request list is just opposite.
-	 */
-	#define UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR		0x100
-
-	/*
-	 * This quirk needs to be enabled if host controller doesn't allow
-	 * that the interrupt aggregation timer and counter are reset by s/w.
-	 */
-	#define UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR		0x200
-
-	/*
-	 * This quirks needs to be enabled if host controller cannot be
-	 * enabled via HCE register.
-	 */
-	#define UFSHCI_QUIRK_BROKEN_HCE				0x400
 	unsigned int quirks;	/* Deviations from standard UFSHCI spec. */
 
 	/* Device deviations from standard UFS device spec. */
Signature · 1 line
2.24.1
#3 lore raw

Re: [PATCH 1/2] ufshcd: remove unused quirks

In reply to Christoph Hellwig
Quoted 5 lines · Christoph Hellwig

Remove various quirks that don't have users, as well as the dead code keyed off them.

This does not make sense to remove it now and revert the patch a few week later. Martin / Avri your thought please.

Quoted 227 lines
---
 drivers/scsi/ufs/ufshcd.c | 119 ++++----------------------------------
 drivers/scsi/ufs/ufshcd.h |  22 -------
 2 files changed, 12 insertions(+), 129 deletions(-)
drivers/scsi/ufs/ufshcd.c +12 -107
index abd0e6b05f79..886a8a597e6a 100644
@@ -642,11 +642,7 @@ static inline int ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp)
  */
 static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos)
 {
-       if (hba->quirks & UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR)
-               ufshcd_writel(hba, (1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR);
-       else
-               ufshcd_writel(hba, ~(1 << pos),
-                               REG_UTP_TRANSFER_REQ_LIST_CLEAR);
+       ufshcd_writel(hba, ~(1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR);
 }
 
 /**
@@ -656,10 +652,7 @@ static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos)
  */
 static inline void ufshcd_utmrl_clear(struct ufs_hba *hba, u32 pos)
 {
-       if (hba->quirks & UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR)
-               ufshcd_writel(hba, (1 << pos), REG_UTP_TASK_REQ_LIST_CLEAR);
-       else
-               ufshcd_writel(hba, ~(1 << pos), REG_UTP_TASK_REQ_LIST_CLEAR);
+       ufshcd_writel(hba, ~(1 << pos), REG_UTP_TASK_REQ_LIST_CLEAR);
 }
 
 /**
@@ -2093,13 +2086,8 @@ static int ufshcd_map_sg(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
                return sg_segments;
 
        if (sg_segments) {
-               if (hba->quirks & UFSHCD_QUIRK_PRDT_BYTE_GRAN)
-                       lrbp->utr_descriptor_ptr->prd_table_length =
-                               cpu_to_le16((u16)(sg_segments *
-                                       sizeof(struct ufshcd_sg_entry)));
-               else
-                       lrbp->utr_descriptor_ptr->prd_table_length =
-                               cpu_to_le16((u16) (sg_segments));
+               lrbp->utr_descriptor_ptr->prd_table_length =
+                       cpu_to_le16((u16)sg_segments);
 
                prd_table = (struct ufshcd_sg_entry *)lrbp->ucd_prdt_ptr;
 
@@ -3403,21 +3391,11 @@ static void ufshcd_host_memory_configure(struct ufs_hba *hba)
                                cpu_to_le32(upper_32_bits(cmd_desc_element_addr));
 
                /* Response upiu and prdt offset should be in double words */
-               if (hba->quirks & UFSHCD_QUIRK_PRDT_BYTE_GRAN) {
-                       utrdlp[i].response_upiu_offset =
-                               cpu_to_le16(response_offset);
-                       utrdlp[i].prd_table_offset =
-                               cpu_to_le16(prdt_offset);
-                       utrdlp[i].response_upiu_length =
-                               cpu_to_le16(ALIGNED_UPIU_SIZE);
-               } else {
-                       utrdlp[i].response_upiu_offset =
-                               cpu_to_le16((response_offset >> 2));
-                       utrdlp[i].prd_table_offset =
-                               cpu_to_le16((prdt_offset >> 2));
-                       utrdlp[i].response_upiu_length =
-                               cpu_to_le16(ALIGNED_UPIU_SIZE >> 2);
-               }
+               utrdlp[i].response_upiu_offset =
+                       cpu_to_le16(response_offset >> 2);
+               utrdlp[i].prd_table_offset = cpu_to_le16(prdt_offset >> 2);
+               utrdlp[i].response_upiu_length =
+                       cpu_to_le16(ALIGNED_UPIU_SIZE >> 2);
 
                hba->lrb[i].utr_descriptor_ptr = (utrdlp + i);
                hba->lrb[i].utrd_dma_addr = hba->utrdl_dma_addr +
@@ -3460,52 +3438,6 @@ static int ufshcd_dme_link_startup(struct ufs_hba *hba)
                        "dme-link-startup: error code %d\n", ret);
        return ret;
 }
-/**
- * ufshcd_dme_reset - UIC command for DME_RESET
- * @hba: per adapter instance
- *
- * DME_RESET command is issued in order to reset UniPro stack.
- * This function now deal with cold reset.
- *
- * Returns 0 on success, non-zero value on failure
- */
-static int ufshcd_dme_reset(struct ufs_hba *hba)
-{
-       struct uic_command uic_cmd = {0};
-       int ret;
-
-       uic_cmd.command = UIC_CMD_DME_RESET;
-
-       ret = ufshcd_send_uic_cmd(hba, &uic_cmd);
-       if (ret)
-               dev_err(hba->dev,
-                       "dme-reset: error code %d\n", ret);
-
-       return ret;
-}
-
-/**
- * ufshcd_dme_enable - UIC command for DME_ENABLE
- * @hba: per adapter instance
- *
- * DME_ENABLE command is issued in order to enable UniPro stack.
- *
- * Returns 0 on success, non-zero value on failure
- */
-static int ufshcd_dme_enable(struct ufs_hba *hba)
-{
-       struct uic_command uic_cmd = {0};
-       int ret;
-
-       uic_cmd.command = UIC_CMD_DME_ENABLE;
-
-       ret = ufshcd_send_uic_cmd(hba, &uic_cmd);
-       if (ret)
-               dev_err(hba->dev,
-                       "dme-reset: error code %d\n", ret);
-
-       return ret;
-}
 
 static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba)
 {
@@ -4217,7 +4149,7 @@ static inline void ufshcd_hba_stop(struct ufs_hba *hba, bool can_sleep)
 }
 
 /**
- * ufshcd_hba_execute_hce - initialize the controller
+ * ufshcd_hba_enable - initialize the controller
  * @hba: per adapter instance
  *
  * The controller resets itself and controller firmware initialization
@@ -4226,7 +4158,7 @@ static inline void ufshcd_hba_stop(struct ufs_hba *hba, bool can_sleep)
  *
  * Returns 0 on success, non-zero value on failure
  */
-static int ufshcd_hba_execute_hce(struct ufs_hba *hba)
+int ufshcd_hba_enable(struct ufs_hba *hba)
 {
        int retry;
 
@@ -4274,32 +4206,6 @@ static int ufshcd_hba_execute_hce(struct ufs_hba *hba)
 
        return 0;
 }
-
-int ufshcd_hba_enable(struct ufs_hba *hba)
-{
-       int ret;
-
-       if (hba->quirks & UFSHCI_QUIRK_BROKEN_HCE) {
-               ufshcd_set_link_off(hba);
-               ufshcd_vops_hce_enable_notify(hba, PRE_CHANGE);
-
-               /* enable UIC related interrupts */
-               ufshcd_enable_intr(hba, UFSHCD_UIC_MASK);
-               ret = ufshcd_dme_reset(hba);
-               if (!ret) {
-                       ret = ufshcd_dme_enable(hba);
-                       if (!ret)
-                               ufshcd_vops_hce_enable_notify(hba, POST_CHANGE);
-                       if (ret)
-                               dev_err(hba->dev,
-                                       "Host controller enable failed with non-hce\n");
-               }
-       } else {
-               ret = ufshcd_hba_execute_hce(hba);
-       }
-
-       return ret;
-}
 EXPORT_SYMBOL_GPL(ufshcd_hba_enable);
 
 static int ufshcd_disable_tx_lcc(struct ufs_hba *hba, bool peer)
@@ -4869,8 +4775,7 @@ static irqreturn_t ufshcd_transfer_req_compl(struct ufs_hba *hba)
         * false interrupt if device completes another request after resetting
         * aggregation and before reading the DB.
         */
-       if (ufshcd_is_intr_aggr_allowed(hba) &&
-           !(hba->quirks & UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR))
+       if (ufshcd_is_intr_aggr_allowed(hba))
                ufshcd_reset_intr_aggr(hba);
 
        tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
drivers/scsi/ufs/ufshcd.h +0 -23
index 2ae6c7c8528c..9c2b80f87b9f 100644
@@ -612,28 +612,6 @@ struct ufs_hba {
         */
        #define UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION             0x20
 
-       /*
-        * This quirk needs to be enabled if the host contoller regards
-        * resolution of the values of PRDTO and PRDTL in UTRD as byte.
-        */
-       #define UFSHCD_QUIRK_PRDT_BYTE_GRAN                     0x80
-
-       /*
-        * Clear handling for transfer/task request list is just opposite.
-        */
-       #define UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR                0x100
-
-       /*
-        * This quirk needs to be enabled if host controller doesn't allow
-        * that the interrupt aggregation timer and counter are reset by s/w.
-        */
-       #define UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR               0x200
-
-       /*
-        * This quirks needs to be enabled if host controller cannot be
-        * enabled via HCE register.
-        */
-       #define UFSHCI_QUIRK_BROKEN_HCE                         0x400
        unsigned int quirks;    /* Deviations from standard UFSHCI spec. */
 
        /* Device deviations from standard UFS device spec. */
--

2.24.1

Signature · 2 lines
Regards,
Alim
#4 lore raw

RE: [PATCH 1/2] ufshcd: remove unused quirks

Quoted 7 lines · Christoph Hellwig
Quoted 4 lines

Remove various quirks that don't have users, as well as the dead code keyed off them.

Quoted 6 lines
Quoted 1 line

This does not make sense to remove it now and revert the patch a few week later.
Martin / Avri your thought please.

Yeah - I agree with you, provided that indeed it is just few weeks.

Thanks,
Avri

#5 lore raw

PATCH 2/2 ufshcd: use an enum for quirks

In reply to Christoph Hellwig

Use an enum to specify the various quirks instead of #defines inside the structure definition.

---
 drivers/scsi/ufs/ufshcd.h | 82 ++++++++++++++++++++-------------------
 1 file changed, 42 insertions(+), 40 deletions(-)
drivers/scsi/ufs/ufshcd.h +42 -40
index 9c2b80f87b9f..f68b3cd2e465 100644
@@ -469,6 +469,48 @@ struct ufs_stats {
 	struct ufs_err_reg_hist task_abort;
 };
 
+enum ufshcd_quirks {
+	/* Interrupt aggregation support is broken */
+	UFSHCD_QUIRK_BROKEN_INTR_AGGR			= 1 << 0,
+
+	/*
+	 * delay before each dme command is required as the unipro
+	 * layer has shown instabilities
+	 */
+	UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS		= 1 << 1,
+
+	/*
+	 * If UFS host controller is having issue in processing LCC (Line
+	 * Control Command) coming from device then enable this quirk.
+	 * When this quirk is enabled, host controller driver should disable
+	 * the LCC transmission on UFS device (by clearing TX_LCC_ENABLE
+	 * attribute of device to 0).
+	 */
+	UFSHCD_QUIRK_BROKEN_LCC				= 1 << 2,
+
+	/*
+	 * The attribute PA_RXHSUNTERMCAP specifies whether or not the
+	 * inbound Link supports unterminated line in HS mode. Setting this
+	 * attribute to 1 fixes moving to HS gear.
+	 */
+	UFSHCD_QUIRK_BROKEN_PA_RXHSUNTERMCAP		= 1 << 3,
+
+	/*
+	 * This quirk needs to be enabled if the host contoller only allows
+	 * accessing the peer dme attributes in AUTO mode (FAST AUTO or
+	 * SLOW AUTO).
+	 */
+	UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE		= 1 << 4,
+
+	/*
+	 * This quirk needs to be enabled if the host contoller doesn't
+	 * advertise the correct version in UFS_VER register. If this quirk
+	 * is enabled, standard UFS host driver will call the vendor specific
+	 * ops (get_ufs_hci_version) to get the correct version.
+	 */
+	UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION		= 1 << 5,
+};
+
 /**
  * struct ufs_hba - per adapter private structure
  * @mmio_base: UFSHCI base register address
@@ -572,46 +614,6 @@ struct ufs_hba {
 	bool is_irq_enabled;
 	enum ufs_ref_clk_freq dev_ref_clk_freq;
 
-	/* Interrupt aggregation support is broken */
-	#define UFSHCD_QUIRK_BROKEN_INTR_AGGR			0x1
-
-	/*
-	 * delay before each dme command is required as the unipro
-	 * layer has shown instabilities
-	 */
-	#define UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS		0x2
-
-	/*
-	 * If UFS host controller is having issue in processing LCC (Line
-	 * Control Command) coming from device then enable this quirk.
-	 * When this quirk is enabled, host controller driver should disable
-	 * the LCC transmission on UFS device (by clearing TX_LCC_ENABLE
-	 * attribute of device to 0).
-	 */
-	#define UFSHCD_QUIRK_BROKEN_LCC				0x4
-
-	/*
-	 * The attribute PA_RXHSUNTERMCAP specifies whether or not the
-	 * inbound Link supports unterminated line in HS mode. Setting this
-	 * attribute to 1 fixes moving to HS gear.
-	 */
-	#define UFSHCD_QUIRK_BROKEN_PA_RXHSUNTERMCAP		0x8
-
-	/*
-	 * This quirk needs to be enabled if the host contoller only allows
-	 * accessing the peer dme attributes in AUTO mode (FAST AUTO or
-	 * SLOW AUTO).
-	 */
-	#define UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE		0x10
-
-	/*
-	 * This quirk needs to be enabled if the host contoller doesn't
-	 * advertise the correct version in UFS_VER register. If this quirk
-	 * is enabled, standard UFS host driver will call the vendor specific
-	 * ops (get_ufs_hci_version) to get the correct version.
-	 */
-	#define UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION		0x20
-
 	unsigned int quirks;	/* Deviations from standard UFSHCI spec. */
 
 	/* Device deviations from standard UFS device spec. */
Signature · 1 line
2.24.1
#6 lore raw

Re: [PATCH 2/2] ufshcd: use an enum for quirks

Hi Christoph

Quoted 13 lines · Christoph Hellwig

Use an enum to specify the various quirks instead of #defines inside the structure definition.

---
  drivers/scsi/ufs/ufshcd.h | 82 ++++++++++++++++++++-------------------
  1 file changed, 42 insertions(+), 40 deletions(-)
drivers/scsi/ufs/ufshcd.h +0 -0
index 9c2b80f87b9f..f68b3cd2e465 100644

drivers/scsi/ufs/ufshcd.h struct ufs_stats { · line 475

Quoted 7 lines
drivers/scsi/ufs/ufshcd.h +4 -0
@@ -469,6 +469,48 @@ struct ufs_stats {
  	struct ufs_err_reg_hist task_abort;
  };
 
+enum ufshcd_quirks {
+	/* Interrupt aggregation support is broken */
+	UFSHCD_QUIRK_BROKEN_INTR_AGGR			= 1 << 0,
+

How about using BIT() here?

Quoted 79 lines
drivers/scsi/ufs/ufshcd.h +38 -33
+	/*
+	 * delay before each dme command is required as the unipro
+	 * layer has shown instabilities
+	 */
+	UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS		= 1 << 1,
+
+	/*
+	 * If UFS host controller is having issue in processing LCC (Line
+	 * Control Command) coming from device then enable this quirk.
+	 * When this quirk is enabled, host controller driver should disable
+	 * the LCC transmission on UFS device (by clearing TX_LCC_ENABLE
+	 * attribute of device to 0).
+	 */
+	UFSHCD_QUIRK_BROKEN_LCC				= 1 << 2,
+
+	/*
+	 * The attribute PA_RXHSUNTERMCAP specifies whether or not the
+	 * inbound Link supports unterminated line in HS mode. Setting this
+	 * attribute to 1 fixes moving to HS gear.
+	 */
+	UFSHCD_QUIRK_BROKEN_PA_RXHSUNTERMCAP		= 1 << 3,
+
+	/*
+	 * This quirk needs to be enabled if the host contoller only allows
+	 * accessing the peer dme attributes in AUTO mode (FAST AUTO or
+	 * SLOW AUTO).
+	 */
+	UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE		= 1 << 4,
+
+	/*
+	 * This quirk needs to be enabled if the host contoller doesn't
+	 * advertise the correct version in UFS_VER register. If this quirk
+	 * is enabled, standard UFS host driver will call the vendor specific
+	 * ops (get_ufs_hci_version) to get the correct version.
+	 */
+	UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION		= 1 << 5,
+};
+
  /**
   * struct ufs_hba - per adapter private structure
   * @mmio_base: UFSHCI base register address
@@ -572,46 +614,6 @@ struct ufs_hba {
  	bool is_irq_enabled;
  	enum ufs_ref_clk_freq dev_ref_clk_freq;
 
-	/* Interrupt aggregation support is broken */
-	#define UFSHCD_QUIRK_BROKEN_INTR_AGGR			0x1
-
-	/*
-	 * delay before each dme command is required as the unipro
-	 * layer has shown instabilities
-	 */
-	#define UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS		0x2
-
-	/*
-	 * If UFS host controller is having issue in processing LCC (Line
-	 * Control Command) coming from device then enable this quirk.
-	 * When this quirk is enabled, host controller driver should disable
-	 * the LCC transmission on UFS device (by clearing TX_LCC_ENABLE
-	 * attribute of device to 0).
-	 */
-	#define UFSHCD_QUIRK_BROKEN_LCC				0x4
-
-	/*
-	 * The attribute PA_RXHSUNTERMCAP specifies whether or not the
-	 * inbound Link supports unterminated line in HS mode. Setting this
-	 * attribute to 1 fixes moving to HS gear.
-	 */
-	#define UFSHCD_QUIRK_BROKEN_PA_RXHSUNTERMCAP		0x8
-
-	/*
-	 * This quirk needs to be enabled if the host contoller only allows
-	 * accessing the peer dme attributes in AUTO mode (FAST AUTO or
-	 * SLOW AUTO).
-	 */
-	#define UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE		0x10
-
-	/*

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

Quoted 10 lines
drivers/scsi/ufs/ufshcd.h +0 -7
-	 * This quirk needs to be enabled if the host contoller doesn't
-	 * advertise the correct version in UFS_VER register. If this quirk
-	 * is enabled, standard UFS host driver will call the vendor specific
-	 * ops (get_ufs_hci_version) to get the correct version.
-	 */
-	#define UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION		0x20
-
  	unsigned int quirks;	/* Deviations from standard UFSHCI spec. */
 
  	/* Device deviations from standard UFS device spec. */

-asd

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

Re: [PATCH 2/2] ufshcd: use an enum for quirks

Quoted 6 lines · Asutosh Das (asd)
Quoted 3 lines · Christoph Hellwig

+    /* Interrupt aggregation support is broken */ +    UFSHCD_QUIRK_BROKEN_INTR_AGGR            = 1 << 0, +

How about using BIT() here?

Not everyone is convinced that using BIT() improves code readability.

Bart.

#8 lore raw

Re: [PATCH 2/2] ufshcd: use an enum for quirks

Quoted 9 lines · Bart Van Assche
Quoted 6 lines · Asutosh Das (asd)
Quoted 3 lines · Christoph Hellwig

+    /* Interrupt aggregation support is broken */ +    UFSHCD_QUIRK_BROKEN_INTR_AGGR            = 1 << 0, +

How about using BIT() here?

Not everyone is convinced that using BIT() improves code readability.

I for one am not. 1 << N shoud be obvious to anyone with a basic understanding of C code, BIT() needs to be looked up. And it isn't actually any shorter.

#10 lore raw
In reply to Christoph Hellwig

Christoph,

Quoted 2 lines

this removes lots of dead code from the ufs drivers, an cleans up the quirk handling a little bit.

Applied to 5.7/scsi-queue, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering