Re: [PATCH v3] mmc: Add quirk MMC_QUIRK_BROKEN_CACHE_FLUSH for Micron eMMC Q2J54A

From: Francesco Dolcini
Date: Fri Sep 22 2023 - 13:01:23 EST


On Thu, Sep 21, 2023 at 10:34:26PM +0200, Bean Huo wrote:
> From: Bean Huo <beanhuo@xxxxxxxxxx>
>
> Micron MTFC4GACAJCN eMMC supports cache but requires that flush cache
> operation be allowed only after a write has occurred. Otherwise, the
> cache flush command or subsequent commands will time out.
>
> Signed-off-by: Bean Huo <beanhuo@xxxxxxxxxx>
> Co-developed-by: Rafael Beims <rafael.beims@xxxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> ---
> Changelog:
>
> v2--v3:
> 1. Set card->written_flag in mmc_blk_mq_issue_rq().
> v1--v2:
> 1. Add Rafael's test-tag, and Co-developed-by.
> 2. Check host->card whether NULL or not in __mmc_start_request() before asserting host->card->->quirks
> ---
> drivers/mmc/core/block.c | 4 ++++
> drivers/mmc/core/mmc.c | 5 +++++
> drivers/mmc/core/quirks.h | 7 ++++---
> include/linux/mmc/card.h | 2 ++
> 4 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index 3a8f27c3e310..14d0dc7942de 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -2387,6 +2387,10 @@ enum mmc_issued mmc_blk_mq_issue_rq(struct mmc_queue *mq, struct request *req)
> ret = mmc_blk_cqe_issue_rw_rq(mq, req);
> else
> ret = mmc_blk_mq_issue_rw_rq(mq, req);
> +
> + if (host->card->quirks & MMC_QUIRK_BROKEN_CACHE_FLUSH &&
> + !host->card->written_flag && !ret)
> + host->card->written_flag = true;

>From what I can see this branch is followed for both REQ_OP_READ and
REQ_OP_WRITE, and I would say we want to set this flag only for
REQ_OP_WRITE.

Am I wrong?

Francesco