[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250224045918.3321394-2-guan.wang.jy@renesas.com>
Date: Mon, 24 Feb 2025 12:59:18 +0800
From: Guan Wang <guan.wang.jy@...il.com>
To: Ulf Hansson <ulf.hansson@...aro.org>
Cc: Avri Altman <avri.altman@....com>,
Adrian Hunter <adrian.hunter@...el.com>,
Linus Walleij <linus.walleij@...aro.org>,
Jens Axboe <axboe@...nel.dk>,
guan.wang.jy@...esas.com,
linux-mmc@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] mmc: block: add reset workaround for partition switch failures
Some eMMC devices (e.g., BGSD4R and AIM20F) may enter an unresponsive state
after encountering CRC errors during RPMB writes (CMD25). This prevents the
device from switching back to the main partition via CMD6, blocking further
I/O operations.
The root cause is suspected to be a firmware/hardware issue in specific
eMMC models. A workaround is to perform a hardware reset via mmc_hw_reset()
when the partition switch fails, followed by a retry.
Add a workaround that:
1. If initial partition switch fails after rpmb access
2. Performs mmc card reset using mmc_hw_reset()
3. Retries switching to main partition
This helps resolve cases where the device becomes unresponsive after
RPMB operations.
Signed-off-by: Guan Wang <guan.wang.jy@...esas.com>
---
drivers/mmc/core/block.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 4830628510e6..29388786624c 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -1174,8 +1174,24 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
break;
}
/* Always switch back to main area after RPMB access */
- if (rpmb_ioctl)
- mmc_blk_part_switch(card, 0);
+ if (rpmb_ioctl) {
+ if (mmc_blk_part_switch(card, 0)) {
+ pr_warn("%s: failed to switch back to main area, will reset and switch again\n",
+ md->disk->disk_name);
+
+ /*
+ * Reset eMMC device if partition switch fails.
+ * Some eMMC devices may get stuck by write CRC error in RPMB,
+ * preventing switch back to main partition. This workaround
+ * helps recover from this error state.
+ */
+ mmc_hw_reset(card);
+
+ if (mmc_blk_part_switch(card, 0))
+ pr_err("%s: failed to switch back to main area even after reset\n",
+ md->disk->disk_name);
+ }
+ }
else if (card->reenable_cmdq && !card->ext_csd.cmdq_en)
mmc_cmdq_enable(card);
break;
--
2.25.1
Powered by blists - more mailing lists