Skip to contentSkip to conversation

scsi: ufs: core: Fix mcq mac configuration

PATCH Applied Rohit Ner 5 participants 5 messages Feb 20, 2024 – Mar 10, 2024

Subsystems (2)
lore
Share & tools
lore

Rohit Ner

author
#0 lore raw

PATCH 1/1 scsi: ufs: core: Fix mcq mac configuration

As per JEDEC Standard No. 223E Section 5.9.2,
the max # active commands value programmed by the host sw in MCQConfig.MAC should be one less than the actual value.

---
 drivers/ufs/core/ufs-mcq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ufs/core/ufs-mcq.c +1 -1
index 0787456c2b89..c873fd823942 100644
@@ -94,7 +94,7 @@ void ufshcd_mcq_config_mac(struct ufs_hba *hba, u32 max_active_cmds)
 
 	val = ufshcd_readl(hba, REG_UFS_MCQ_CFG);
 	val &= ~MCQ_CFG_MAC_MASK;
-	val |= FIELD_PREP(MCQ_CFG_MAC_MASK, max_active_cmds);
+	val |= FIELD_PREP(MCQ_CFG_MAC_MASK, max_active_cmds - 1);
 	ufshcd_writel(hba, val, REG_UFS_MCQ_CFG);
 }
 EXPORT_SYMBOL_GPL(ufshcd_mcq_config_mac);
Signature · 1 line
2.44.0.rc0.258.g7320e95886-goog
#1 lore raw
Quoted 14 lines · Rohit Ner

As per JEDEC Standard No. 223E Section 5.9.2,
the max # active commands value programmed by the host sw in MCQConfig.MAC should be one less than the actual value.

---
  drivers/ufs/core/ufs-mcq.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ufs/core/ufs-mcq.c +0 -0
index 0787456c2b89..c873fd823942 100644

drivers/ufs/core/ufs-mcq.c void ufshcd_mcq_config_mac(struct ufs_hba *hba, u32 max_active_cmds) · line 100

Quoted 8 lines
drivers/ufs/core/ufs-mcq.c +1 -1
@@ -94,7 +94,7 @@ void ufshcd_mcq_config_mac(struct ufs_hba *hba, u32 max_active_cmds)
 
  	val = ufshcd_readl(hba, REG_UFS_MCQ_CFG);
  	val &= ~MCQ_CFG_MAC_MASK;
-	val |= FIELD_PREP(MCQ_CFG_MAC_MASK, max_active_cmds);
+	val |= FIELD_PREP(MCQ_CFG_MAC_MASK, max_active_cmds - 1);
  	ufshcd_writel(hba, val, REG_UFS_MCQ_CFG);
  }
  EXPORT_SYMBOL_GPL(ufshcd_mcq_config_mac);

I'd like to hear the feedback from the UFS controller vendors about this patch since the UFSHCI specification of the MaxActiveCommand controller field is ambiguous. While the example shows that 32 should be configured as 1Fh, this is not documented in any other way.

Thanks,

Bart.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Rohit Ner
Quoted 22 lines · Rohit Ner

As per JEDEC Standard No. 223E Section 5.9.2,
the max # active commands value programmed by the host sw in MCQConfig.MAC should be one less than the actual value.

---
 drivers/ufs/core/ufs-mcq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ufs/core/ufs-mcq.c +1 -1
index 0787456c2b89..c873fd823942 100644
@@ -94,7 +94,7 @@ void ufshcd_mcq_config_mac(struct ufs_hba *hba, u32
 max_active_cmds)
 
 	val = ufshcd_readl(hba, REG_UFS_MCQ_CFG);
 	val &= ~MCQ_CFG_MAC_MASK;
-	val |= FIELD_PREP(MCQ_CFG_MAC_MASK, max_active_cmds);
+	val |= FIELD_PREP(MCQ_CFG_MAC_MASK, max_active_cmds - 1);
 	ufshcd_writel(hba, val, REG_UFS_MCQ_CFG);
 }
Quoted 1 line

EXPORT_SYMBOL_GPL(ufshcd_mcq_config_mac);

Meidatek host controller MAC_SUPP_MAC setting is 64, which should config to 0x3F.

Reviewed-by on v1 1/1
#3 lore raw
In reply to Rohit Ner
Quoted 14 lines · Rohit Ner

As per JEDEC Standard No. 223E Section 5.9.2,
the max # active commands value programmed by the host sw in MCQConfig.MAC should be one less than the actual value.

---
  drivers/ufs/core/ufs-mcq.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ufs/core/ufs-mcq.c +0 -0
index 0787456c2b89..c873fd823942 100644

drivers/ufs/core/ufs-mcq.c void ufshcd_mcq_config_mac(struct ufs_hba *hba, u32 max_active_cmds) · line 100

Quoted 8 lines
drivers/ufs/core/ufs-mcq.c +1 -1
@@ -94,7 +94,7 @@ void ufshcd_mcq_config_mac(struct ufs_hba *hba, u32 max_active_cmds)
 
  	val = ufshcd_readl(hba, REG_UFS_MCQ_CFG);
  	val &= ~MCQ_CFG_MAC_MASK;
-	val |= FIELD_PREP(MCQ_CFG_MAC_MASK, max_active_cmds);
+	val |= FIELD_PREP(MCQ_CFG_MAC_MASK, max_active_cmds - 1);
  	ufshcd_writel(hba, val, REG_UFS_MCQ_CFG);
  }
  EXPORT_SYMBOL_GPL(ufshcd_mcq_config_mac);
#4 lore raw
In reply to Rohit Ner

Rohit,

Quoted 3 lines

As per JEDEC Standard No. 223E Section 5.9.2, the max # active commands value programmed by the host sw in MCQConfig.MAC should be one less than the actual value.

Applied to 6.9/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering