From: Shiji Yang Date: Fri, 13 Jun 2025 20:12:55 +0800 Subject: [PATCH 2/3] mmc: mtk-sd: disable auto CMD23 support for mt7620 MT7628 ProgrammingGuide indicates that the host controller version 3.0 and later support auto CMD23 function. However, it doesn't define SD command register BIT[29](Auto CMD23 enable bit). I guess the legacy MIPS MT762x series SoCs don't support this feature at all. The experiment on JDCloud RE-SP-01B(MT7621 + 128 GiB EMMC) shows that disabling auto CMD23 can fix the following IO errors: [ 143.344604] mtk-msdc 1e130000.mmc: msdc_track_cmd_data: cmd=6 arg=03B30101; host->error=0x00000002 [ 143.353661] mtk-msdc 1e130000.mmc: msdc_track_cmd_data: cmd=6 arg=03B30101; host->error=0x00000002 [ 143.362662] mtk-msdc 1e130000.mmc: msdc_track_cmd_data: cmd=6 arg=03B30101; host->error=0x00000002 [ 143.371684] mtk-msdc 1e130000.mmc: msdc_track_cmd_data: cmd=6 arg=03B30101; host->error=0x00000002 [ 143.380684] I/O error, dev mmcblk0boot0, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 4 prio class 0 [ 143.390414] mtk-msdc 1e130000.mmc: msdc_track_cmd_data: cmd=6 arg=03B30101; host->error=0x00000002 [ 143.399468] mtk-msdc 1e130000.mmc: msdc_track_cmd_data: cmd=6 arg=03B30101; host->error=0x00000002 [ 143.408516] mtk-msdc 1e130000.mmc: msdc_track_cmd_data: cmd=6 arg=03B30101; host->error=0x00000002 [ 143.417556] mtk-msdc 1e130000.mmc: msdc_track_cmd_data: cmd=6 arg=03B30101; host->error=0x00000002 [ 143.426590] I/O error, dev mmcblk0boot0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0 [ 143.435585] Buffer I/O error on dev mmcblk0boot0, logical block 0, async page read Signed-off-by: Shiji Yang --- drivers/mmc/host/mtk-sd.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) --- a/drivers/mmc/host/mtk-sd.c +++ b/drivers/mmc/host/mtk-sd.c @@ -412,6 +412,7 @@ struct mtk_mmc_compatible { bool stop_clk_fix; bool enhance_rx; bool support_64g; + bool support_cmd23; bool use_internal_cd; bool mips_mt762x; }; @@ -501,6 +502,7 @@ static const struct mtk_mmc_compatible m .stop_clk_fix = false, .enhance_rx = false, .support_64g = false, + .support_cmd23 = true, }; static const struct mtk_mmc_compatible mt2712_compat = { @@ -514,6 +516,7 @@ static const struct mtk_mmc_compatible m .stop_clk_fix = true, .enhance_rx = true, .support_64g = true, + .support_cmd23 = true, }; static const struct mtk_mmc_compatible mt6779_compat = { @@ -527,6 +530,7 @@ static const struct mtk_mmc_compatible m .stop_clk_fix = true, .enhance_rx = true, .support_64g = true, + .support_cmd23 = true, }; static const struct mtk_mmc_compatible mt6795_compat = { @@ -540,6 +544,7 @@ static const struct mtk_mmc_compatible m .stop_clk_fix = false, .enhance_rx = false, .support_64g = false, + .support_cmd23 = true, }; static const struct mtk_mmc_compatible mt7620_compat = { @@ -552,6 +557,7 @@ static const struct mtk_mmc_compatible m .busy_check = false, .stop_clk_fix = false, .enhance_rx = false, + .support_cmd23 = false, .use_internal_cd = true, .mips_mt762x = true, }; @@ -567,6 +573,7 @@ static const struct mtk_mmc_compatible m .stop_clk_fix = true, .enhance_rx = true, .support_64g = false, + .support_cmd23 = true, }; static const struct mtk_mmc_compatible mt7986_compat = { @@ -580,6 +587,7 @@ static const struct mtk_mmc_compatible m .stop_clk_fix = true, .enhance_rx = true, .support_64g = true, + .support_cmd23 = true, }; static const struct mtk_mmc_compatible mt8135_compat = { @@ -593,6 +601,7 @@ static const struct mtk_mmc_compatible m .stop_clk_fix = false, .enhance_rx = false, .support_64g = false, + .support_cmd23 = true, }; static const struct mtk_mmc_compatible mt8173_compat = { @@ -606,6 +615,7 @@ static const struct mtk_mmc_compatible m .stop_clk_fix = false, .enhance_rx = false, .support_64g = false, + .support_cmd23 = true, }; static const struct mtk_mmc_compatible mt8183_compat = { @@ -619,6 +629,7 @@ static const struct mtk_mmc_compatible m .stop_clk_fix = true, .enhance_rx = true, .support_64g = true, + .support_cmd23 = true, }; static const struct mtk_mmc_compatible mt8516_compat = { @@ -630,6 +641,7 @@ static const struct mtk_mmc_compatible m .data_tune = true, .busy_check = true, .stop_clk_fix = true, + .support_cmd23 = true, }; static const struct of_device_id msdc_of_ids[] = { @@ -2913,7 +2925,9 @@ static int msdc_drv_probe(struct platfor if (mmc->caps & MMC_CAP_SDIO_IRQ) mmc->caps2 |= MMC_CAP2_SDIO_IRQ_NOTHREAD; - mmc->caps |= MMC_CAP_CMD23; + if (host->dev_comp->support_cmd23) + mmc->caps |= MMC_CAP_CMD23; + if (host->cqhci) mmc->caps2 |= MMC_CAP2_CQE | MMC_CAP2_CQE_DCMD; /* MMC core transfer sizes tunable parameters */