public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Shawn Lin <shawn.lin@linux.dev>
To: Bin Liu <b-liu@ti.com>
Cc: shawn.lin@linux.dev, ulf.hansson@linaro.org, axboe@kernel.dk,
	linux-block@vger.kernel.org, linux-mmc@vger.kernel.org
Subject: Re: [PATCH] mmc: block: use single block write in retry
Date: Tue, 17 Mar 2026 20:46:40 +0800	[thread overview]
Message-ID: <301ff663-7f18-ae12-f0f8-88c4e4375114@linux.dev> (raw)
In-Reply-To: <20260310160408.3976760-1-b-liu@ti.com>

在 2026/03/11 星期三 0:04, Bin Liu 写道:
> 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.

MMC core natively retries single for multi block read. So I assume
what you are trying to do is make it the same for write path. We didn't
resort to upper block layer for help for read case in the past, so  I
think you could still achieve that within the scope of MMC core.

More importantly, what is the failure rate of this issue? If it occurs
frequently, we should consider this a significant hardware defect. In
that case, the host driver could register a multi_io_quirk to apply
certain restrictions on the write path. This approach has been used
previously on TI OMAP platforms.

> 
> [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 \
> 

  parent reply	other threads:[~2026-03-17 12:46 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=301ff663-7f18-ae12-f0f8-88c4e4375114@linux.dev \
    --to=shawn.lin@linux.dev \
    --cc=axboe@kernel.dk \
    --cc=b-liu@ti.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox