[RFC PATCH] mmc: core: Disable REQ_FUA if the eMMC supports an internal cache
From: Ulf Hansson
Date: Thu Mar 02 2023 - 09:43:46 EST
REQ_FUA is in general supported for eMMC cards, which translates into so
called "reliable writes". To support these write operations, the CMD23
(MMC_CAP_CMD23), needs to be supported by the mmc host too, which is common
but not always the case.
For some eMMC devices, it has been reported that reliable writes are quite
costly, leading to performance degradations.
In a way to improve the situation, let's avoid announcing REQ_FUA support
if the eMMC supports an internal cache, as that allows us to rely solely on
flush-requests (REQ_OP_FLUSH) instead, which seems to be a lot cheaper.
Note that, those mmc hosts that lacks CMD23 support are already using this
type of configuration, whatever that could mean.
Reported-by: Wenchao Chen <wenchao.chen666@xxxxxxxxx>
Signed-off-by: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
---
Note that, I haven't been able to test this patch myself, but are relying on
Wenchao and others to help out. Sharing some performance number before and
after the patch, would be nice.
Moreover, what is not clear to me (hence the RFC), is whether relying solely on
flush requests are sufficient and as such if it's a good idea after all.
Comments are highly appreciated in this regards.
Kind regards
Ulf Hansson
---
drivers/mmc/core/block.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 672ab90c4b2d..2a49531bf023 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2490,15 +2490,20 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
md->flags |= MMC_BLK_CMD23;
}
- if (md->flags & MMC_BLK_CMD23 &&
- ((card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) ||
- card->ext_csd.rel_sectors)) {
+ /*
+ * REQ_FUA is supported through eMMC reliable writes, which has been
+ * reported to be quite costly for some eMMCs. Therefore, let's rely
+ * on flush requests (REQ_OP_FLUSH), if an internal cache is supported.
+ */
+ if (mmc_cache_enabled(card->host)) {
+ cache_enabled = true;
+ } else if (md->flags & MMC_BLK_CMD23 &&
+ (card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN ||
+ card->ext_csd.rel_sectors)) {
md->flags |= MMC_BLK_REL_WR;
fua_enabled = true;
cache_enabled = true;
}
- if (mmc_cache_enabled(card->host))
- cache_enabled = true;
blk_queue_write_cache(md->queue.queue, cache_enabled, fua_enabled);
--
2.34.1