Skip to contentSkip to conversation

Add mtk-sd support for ignoring cmd response CRC

PATCH In review Andy-ld Lu 2 participants 4 messages Nov 26, 2024 – Dec 2, 2024

Subsystems (3)
lore
Share & tools
lore

Andy-ld Lu

author
#0 lore raw

v2 cover Add mtk-sd support for ignoring cmd response CRC

Add the process flow in the host driver to handle the R1B cmd response type with ignoring CRC, which comes from mmc_cqe_recovery() in the mmc core. Additionally, the response type 'MMC_RSP_R1B_NO_CRC' is introduced to simplify code.

---
Changes in v2:
- Change mmc_cqe_recovery() to use MMC_RSP_R1B_NO_CRC response type.
- Remove MMC_RSP_R1_NO_CRC in the host driver after it is dropped.

Link to v1:
https://patchwork.kernel.org/patch/13883787

---
Andy-ld Lu (2):
mmc: core: Introduce the MMC_RSP_R1B_NO_CRC response
mmc: mtk-sd: Add support for ignoring cmd response CRC

 drivers/mmc/core/core.c   | 6 ++----
 drivers/mmc/host/mtk-sd.c | 6 ++++--
 include/linux/mmc/core.h  | 2 ++
 3 files changed, 8 insertions(+), 6 deletions(-)
Signature · 1 line
2.46.0
author
#1 lore raw

PATCH v2 1/2 mmc: core: Introduce the MMC_RSP_R1B_NO_CRC response

The R1B response type with ignoring CRC is used in the mmc_cqe_recovery(), introduce the MMC_RSP_R1B_NO_CRC response type to simplify the code.

---
This patch dependents on "mmc: core: Drop the MMC_RSP_R1_NO_CRC response".

https://patchwork.kernel.org/patch/13884886

---
 drivers/mmc/core/core.c  | 6 ++----
 include/linux/mmc/core.h | 2 ++
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/core/core.c +2 -4
index a499f3c59de5..4603224bafb9 100644
@@ -557,8 +557,7 @@ int mmc_cqe_recovery(struct mmc_host *host)
 
 	memset(&cmd, 0, sizeof(cmd));
 	cmd.opcode       = MMC_STOP_TRANSMISSION;
-	cmd.flags        = MMC_RSP_R1B | MMC_CMD_AC;
-	cmd.flags       &= ~MMC_RSP_CRC; /* Ignore CRC */
+	cmd.flags        = MMC_RSP_R1B_NO_CRC | MMC_CMD_AC; /* Ignore CRC */
 	cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT;
 	mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
 
@@ -567,8 +566,7 @@ int mmc_cqe_recovery(struct mmc_host *host)
 	memset(&cmd, 0, sizeof(cmd));
 	cmd.opcode       = MMC_CMDQ_TASK_MGMT;
 	cmd.arg          = 1; /* Discard entire queue */
-	cmd.flags        = MMC_RSP_R1B | MMC_CMD_AC;
-	cmd.flags       &= ~MMC_RSP_CRC; /* Ignore CRC */
+	cmd.flags        = MMC_RSP_R1B_NO_CRC | MMC_CMD_AC; /* Ignore CRC */
 	cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT;
 	err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
 
include/linux/mmc/core.h +2 -0
index e13856ab6ad0..4aeab326ed9d 100644
@@ -64,6 +64,8 @@ struct mmc_command {
 #define MMC_RSP_R6	(MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
 #define MMC_RSP_R7	(MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
 
+#define MMC_RSP_R1B_NO_CRC	(MMC_RSP_PRESENT|MMC_RSP_OPCODE|MMC_RSP_BUSY)
+
 #define mmc_resp_type(cmd)	((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE))
 
 /*
Signature · 1 line
2.46.0
author
#2 lore raw

PATCH v2 2/2 mmc: mtk-sd: Add support for ignoring cmd response CRC

In reply to Andy-ld Lu

The current process flow does not handle MMC requests that are indicated to ignore the command response CRC. For instance, cmd12 and cmd48 from mmc_cqe_recovery() are marked to ignore CRC, but they are not matched to the appropriate response type in msdc_cmd_find_resp(). As a result, they are defaulted to 'MMC_RSP_NONE', which means no response is expected.

This commit applies the flag 'MMC_RSP_R1B_NO_CRC' to fix the response type setting in msdc_cmd_find_resp() and adds the logic to ignore CRC in msdc_cmd_done().

---
 drivers/mmc/host/mtk-sd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/host/mtk-sd.c +4 -2
index efb0d2d5716b..e2c385853eef 100644
@@ -1097,11 +1097,12 @@ static inline u32 msdc_cmd_find_resp(struct msdc_host *host,
 	u32 resp;
 
 	switch (mmc_resp_type(cmd)) {
-		/* Actually, R1, R5, R6, R7 are the same */
+	/* Actually, R1, R5, R6, R7 are the same */
 	case MMC_RSP_R1:
 		resp = 0x1;
 		break;
 	case MMC_RSP_R1B:
+	case MMC_RSP_R1B_NO_CRC:
 		resp = 0x7;
 		break;
 	case MMC_RSP_R2:
@@ -1351,7 +1352,8 @@ static bool msdc_cmd_done(struct msdc_host *host, int events,
 			 * CRC error.
 			 */
 			msdc_reset_hw(host);
-		if (events & MSDC_INT_RSPCRCERR) {
+		if (events & MSDC_INT_RSPCRCERR &&
+		    mmc_resp_type(cmd) != MMC_RSP_R1B_NO_CRC) {
 			cmd->error = -EILSEQ;
 			host->error |= REQ_CMD_EIO;
 		} else if (events & MSDC_INT_CMDTMO) {
Signature · 1 line
2.46.0
#3 lore raw
In reply to Andy-ld Lu
Quoted 19 lines · Andy-ld Lu

Add the process flow in the host driver to handle the R1B cmd response type with ignoring CRC, which comes from mmc_cqe_recovery() in the mmc core. Additionally, the response type 'MMC_RSP_R1B_NO_CRC' is introduced to simplify code.

---
Changes in v2:
- Change mmc_cqe_recovery() to use MMC_RSP_R1B_NO_CRC response type.
- Remove MMC_RSP_R1_NO_CRC in the host driver after it is dropped.

Link to v1:
https://patchwork.kernel.org/patch/13883787

---
Andy-ld Lu (2):
mmc: core: Introduce the MMC_RSP_R1B_NO_CRC response
mmc: mtk-sd: Add support for ignoring cmd response CRC

Quoted 8 lines
 drivers/mmc/core/core.c   | 6 ++----
 drivers/mmc/host/mtk-sd.c | 6 ++++--
 include/linux/mmc/core.h  | 2 ++
 3 files changed, 8 insertions(+), 6 deletions(-)

--
2.46.0

The series applied for next, thanks!

Kind regards
Uffe