RE: [PATCH] mmc: block: add reset workaround for partition switch failures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear all,
I apologize for the duplicate email sent earlier.
Please disregard the second email

Best Regards,
Guan Wang

-----Original Message-----
From: Guan Wang <guan.wang.jy@xxxxxxxxx> 
Sent: Monday, February 24, 2025 12:59 PM
To: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
Cc: Avri Altman <avri.altman@xxxxxxx>; Adrian Hunter <adrian.hunter@xxxxxxxxx>; Linus Walleij <linus.walleij@xxxxxxxxxx>; Jens Axboe <axboe@xxxxxxxxx>; Guan Wang <guan.wang.jy@xxxxxxxxxxx>; linux-mmc@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
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@xxxxxxxxxxx>
---
 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






[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux