public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: block: use single block write in retry
@ 2026-03-10 16:04 Bin Liu
  2026-03-16 15:01 ` Ulf Hansson
                   ` (2 more replies)
  0 siblings, 3 replies; 30+ messages in thread
From: Bin Liu @ 2026-03-10 16:04 UTC (permalink / raw)
  To: linux-block, linux-mmc; +Cc: ulf.hansson, axboe

Due to errata i2493[0], multi-block write would still fail in retries.

This patch reuses recovery_mode flag, and switches to single-block
write in retry when multi-block write fails. It covers both CQE and
non-CQE cases.

[0] https://www.ti.com/lit/pdf/sprz582
Signed-off-by: Bin Liu <b-liu@ti.com>
---
 block/blk-mq-debugfs.c   |  1 +
 drivers/mmc/core/block.c | 12 ++++++++++--
 include/linux/blk-mq.h   |  3 +++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 28167c9baa55..5f97d07fa3c8 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -243,6 +243,7 @@ static const char *const rqf_name[] = {
 	RQF_NAME(ZONE_WRITE_PLUGGING),
 	RQF_NAME(TIMED_OUT),
 	RQF_NAME(RESV),
+	RQF_NAME(XFER_SINGLE_BLK),
 };
 #undef RQF_NAME
 
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 05ee76cb0a08..00016584d70d 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -1401,6 +1401,9 @@ static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq,
 		    rq_data_dir(req) == WRITE &&
 		    (md->flags & MMC_BLK_REL_WR);
 
+	if (req->rq_flags & RQF_XFER_SINGLE_BLK)
+		recovery_mode = 1;
+
 	memset(brq, 0, sizeof(struct mmc_blk_request));
 
 	mmc_crypto_prepare_req(mqrq);
@@ -1540,10 +1543,13 @@ static void mmc_blk_cqe_complete_rq(struct mmc_queue *mq, struct request *req)
 		err = 0;
 
 	if (err) {
-		if (mqrq->retries++ < MMC_CQE_RETRIES)
+		if (mqrq->retries++ < MMC_CQE_RETRIES) {
+			if (rq_data_dir(req) == WRITE)
+				req->rq_flags |= RQF_XFER_SINGLE_BLK;
 			blk_mq_requeue_request(req, true);
-		else
+		} else {
 			blk_mq_end_request(req, BLK_STS_IOERR);
+		}
 	} else if (mrq->data) {
 		if (blk_update_request(req, BLK_STS_OK, mrq->data->bytes_xfered))
 			blk_mq_requeue_request(req, true);
@@ -2085,6 +2091,8 @@ static void mmc_blk_mq_complete_rq(struct mmc_queue *mq, struct request *req)
 	} else if (!blk_rq_bytes(req)) {
 		__blk_mq_end_request(req, BLK_STS_IOERR);
 	} else if (mqrq->retries++ < MMC_MAX_RETRIES) {
+		if (rq_data_dir(req) == WRITE)
+			req->rq_flags |= RQF_XFER_SINGLE_BLK;
 		blk_mq_requeue_request(req, true);
 	} else {
 		if (mmc_card_removed(mq->card))
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 18a2388ba581..06b6e1c4fca3 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -64,6 +64,7 @@ enum rqf_flags {
 	/* ->timeout has been called, don't expire again */
 	__RQF_TIMED_OUT,
 	__RQF_RESV,
+	__RQF_XFER_SINGLE_BLK,
 	__RQF_BITS
 };
 
@@ -85,6 +86,8 @@ enum rqf_flags {
 			((__force req_flags_t)(1 << __RQF_ZONE_WRITE_PLUGGING))
 #define RQF_TIMED_OUT		((__force req_flags_t)(1 << __RQF_TIMED_OUT))
 #define RQF_RESV		((__force req_flags_t)(1 << __RQF_RESV))
+#define RQF_XFER_SINGLE_BLK	\
+			((__force req_flags_t)(1 << __RQF_XFER_SINGLE_BLK))
 
 /* flags that prevent us from merging requests: */
 #define RQF_NOMERGE_FLAGS \
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2026-03-26 13:41 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-10 16:04 [PATCH] mmc: block: use single block write in retry Bin Liu
2026-03-16 15:01 ` Ulf Hansson
2026-03-16 16:22   ` Bin Liu
2026-03-24 12:44     ` Ulf Hansson
2026-03-17 12:46 ` Shawn Lin
2026-03-17 13:24   ` Bin Liu
2026-03-18  1:43     ` Shawn Lin
2026-03-18 14:55       ` Bin Liu
2026-03-18 15:10         ` Bin Liu
2026-03-18 15:17       ` Bin Liu
2026-03-23 13:05         ` Bin Liu
2026-03-24  7:34           ` Shawn Lin
2026-03-24 14:34 ` [PATCH v2 0/2] " Bin Liu
2026-03-24 14:34   ` [PATCH v2 1/2] block: define new rqf_flags RQF_XFER_SINGLE_BLK Bin Liu
2026-03-24 18:48     ` Jens Axboe
2026-03-24 19:11       ` Bin Liu
2026-03-24 19:16         ` Jens Axboe
2026-03-24 20:41           ` Bin Liu
2026-03-24 14:34   ` [PATCH v2 2/2] mmc: block: use single block write in retry Bin Liu
2026-03-24 14:57   ` [PATCH v2 0/2] " Ulf Hansson
2026-03-24 19:17     ` Jens Axboe
2026-03-25 13:49   ` [PATCH v3] " Bin Liu
2026-03-25 14:12     ` Jens Axboe
2026-03-25 14:21       ` Bin Liu
2026-03-25 14:23         ` Jens Axboe
2026-03-25 14:27           ` Bin Liu
2026-03-25 15:22             ` Ulf Hansson
2026-03-25 15:29               ` Bin Liu
2026-03-26 12:33     ` Ulf Hansson
2026-03-26 13:41       ` Bin Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox