public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] mmc: core: Disable REQ_FUA if the eMMC supports an internal cache
@ 2023-03-02 14:43 Ulf Hansson
  2023-03-02 15:02 ` Bean Huo
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Ulf Hansson @ 2023-03-02 14:43 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson, Jens Axboe
  Cc: Wenchao Chen, Adrian Hunter, Avri Altman, Christian Lohle,
	linux-block, linux-kernel

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@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---

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


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

end of thread, other threads:[~2023-03-16 12:45 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-02 14:43 [RFC PATCH] mmc: core: Disable REQ_FUA if the eMMC supports an internal cache Ulf Hansson
2023-03-02 15:02 ` Bean Huo
2023-03-03  9:39   ` Avri Altman
2023-03-03 11:03     ` Ulf Hansson
2023-03-03 11:37       ` Avri Altman
2023-03-02 15:07 ` Christian Löhle
2023-03-03 11:40   ` Christian Löhle
2023-03-03 12:01     ` Ulf Hansson
2023-03-03 14:41       ` Adrian Hunter
2023-03-06 16:09         ` Ulf Hansson
2023-03-07 13:15           ` Adrian Hunter
2023-03-10 13:43 ` Christian Löhle
2023-03-10 14:53   ` Ulf Hansson
2023-03-10 17:06     ` Christian Löhle
2023-03-13 16:56       ` Adrian Hunter
2023-03-14  7:56         ` Ulf Hansson
2023-03-14  8:57           ` Adrian Hunter
2023-03-16 12:12             ` Ulf Hansson
2023-03-16 12:44               ` Adrian Hunter
2023-03-11  8:30   ` Avri Altman

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