Skip to contentSkip to conversation

mmc:sdhci:Fix the SD tuning issue that the SDHCI_TRANSFER_MODE is cleared incorrectly

PATCH Superseded Charl Liu 2 participants 2 messages Nov 4, 2022

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Charl Liu

author
#0 lore raw

PATCH v2 1/1 mmc:sdhci:Fix the SD tuning issue that the SDHCI_TRANSFER_MODE is cleared incorrectly

When cmd->opcode == MMC_SEND_TUNING_BLOCK, the SDHCI_TRANSFER_MODE should also be kept

---
change in V1:
Keeping the SDHCI_TRANSFER_MODE when cmd->opcode == MMC_END_TUNING_BLOCK

change in V2:
add the mmc_op_tuning interface to judge if the opcode is tuning CMD

---
 drivers/mmc/host/sdhci.c | 2 +-
 include/linux/mmc/mmc.h  | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +1 -1
index 22152029e14c..9388628215ca 100644
@@ -1430,7 +1430,7 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host,
 		if (host->quirks2 &
 			SDHCI_QUIRK2_CLEAR_TRANSFERMODE_REG_BEFORE_CMD) {
 			/* must not clear SDHCI_TRANSFER_MODE when tuning */
-			if (cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200)
+			if (!mmc_op_tuning(cmd->opcode))
 				sdhci_writew(host, 0x0, SDHCI_TRANSFER_MODE);
 		} else {
 		/* clear Auto CMD settings for no data CMDs */
include/linux/mmc/mmc.h +6 -0
index d9a65c6a8816..d809bdfcc59b 100644
@@ -99,6 +99,12 @@ static inline bool mmc_op_multi(u32 opcode)
 	       opcode == MMC_READ_MULTIPLE_BLOCK;
 }
 
+static inline bool mmc_op_tuning(u32 opcode)
+{
+	return opcode == MMC_SEND_TUNING_BLOCK ||
+	       opcode == MMC_SEND_TUNING_BLOCK_HS200;
+}
+
 /*
  * MMC_SWITCH argument format:
  *
Signature · 1 line
2.32.0
maintainer
#1 lore raw
Quoted 33 lines · Charl Liu

When cmd->opcode == MMC_SEND_TUNING_BLOCK, the SDHCI_TRANSFER_MODE should also be kept

---
change in V1:
Keeping the SDHCI_TRANSFER_MODE when cmd->opcode == MMC_END_TUNING_BLOCK

change in V2:
add the mmc_op_tuning interface to judge if the opcode is tuning CMD

---
 drivers/mmc/host/sdhci.c | 2 +-
 include/linux/mmc/mmc.h  | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +1 -1
index 22152029e14c..9388628215ca 100644
@@ -1430,7 +1430,7 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host,
 		if (host->quirks2 &
 			SDHCI_QUIRK2_CLEAR_TRANSFERMODE_REG_BEFORE_CMD) {
 			/* must not clear SDHCI_TRANSFER_MODE when tuning */
-			if (cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200)
+			if (!mmc_op_tuning(cmd->opcode))
 				sdhci_writew(host, 0x0, SDHCI_TRANSFER_MODE);
 		} else {
 		/* clear Auto CMD settings for no data CMDs */
include/linux/mmc/mmc.h +0 -0
index d9a65c6a8816..d809bdfcc59b 100644

include/linux/mmc/mmc.h static inline bool mmc_op_multi(u32 opcode) · line 107

Quoted 9 lines
include/linux/mmc/mmc.h +6 -0
@@ -99,6 +99,12 @@ static inline bool mmc_op_multi(u32 opcode)
 	       opcode == MMC_READ_MULTIPLE_BLOCK;
 }
 
+static inline bool mmc_op_tuning(u32 opcode)
+{
+	return opcode == MMC_SEND_TUNING_BLOCK ||
+	       opcode == MMC_SEND_TUNING_BLOCK_HS200;
+}
+

Patches for mmc should be based on Ulf's next branch:

https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git/log/?h=next

which already has mmc_op_tuning()

Quoted 3 lines
include/linux/mmc/mmc.h +0 -0
 /*
  * MMC_SWITCH argument format:
  *