Linux MultiMedia Card development
 help / color / mirror / Atom feed
From: Wenchao Chen <wenchao.chen@unisoc.com>
To: <ulf.hansson@linaro.org>
Cc: <linux-mmc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<wenchao.chen666@gmail.com>, <zhenxiong.lai@unisoc.com>,
	<yuelin.tang@unisoc.com>, Wenchao Chen <wenchao.chen@unisoc.com>
Subject: [PATCH V3 2/2] mmc: hsq: dynamic adjustment of hsq->depth
Date: Tue, 29 Aug 2023 10:04:51 +0800	[thread overview]
Message-ID: <20230829020451.9828-3-wenchao.chen@unisoc.com> (raw)
In-Reply-To: <20230829020451.9828-1-wenchao.chen@unisoc.com>

Increasing hsq_depth improves random write performance.

Signed-off-by: Wenchao Chen <wenchao.chen@unisoc.com>
---
 drivers/mmc/host/mmc_hsq.c | 27 +++++++++++++++++++++++++++
 drivers/mmc/host/mmc_hsq.h |  5 +++++
 2 files changed, 32 insertions(+)

diff --git a/drivers/mmc/host/mmc_hsq.c b/drivers/mmc/host/mmc_hsq.c
index 8556cacb21a1..0984c39108ba 100644
--- a/drivers/mmc/host/mmc_hsq.c
+++ b/drivers/mmc/host/mmc_hsq.c
@@ -21,6 +21,31 @@ static void mmc_hsq_retry_handler(struct work_struct *work)
 	mmc->ops->request(mmc, hsq->mrq);
 }
 
+static void mmc_hsq_modify_threshold(struct mmc_hsq *hsq)
+{
+	struct mmc_host *mmc = hsq->mmc;
+	struct mmc_request *mrq;
+	struct hsq_slot *slot;
+	int need_change = 0;
+	int tag;
+
+	for (tag = 0; tag < HSQ_NUM_SLOTS; tag++) {
+		slot = &hsq->slot[tag];
+		mrq = slot->mrq;
+		if (mrq && mrq->data &&
+			(mrq->data->blksz * mrq->data->blocks == 4096) &&
+			(mrq->data->flags & MMC_DATA_WRITE))
+			need_change++;
+		else
+			break;
+	}
+
+	if (need_change > 1)
+		mmc->hsq_depth = HSQ_PERFORMANCE_DEPTH;
+	else
+		mmc->hsq_depth = HSQ_NORMAL_DEPTH;
+}
+
 static void mmc_hsq_pump_requests(struct mmc_hsq *hsq)
 {
 	struct mmc_host *mmc = hsq->mmc;
@@ -42,6 +67,8 @@ static void mmc_hsq_pump_requests(struct mmc_hsq *hsq)
 		return;
 	}
 
+	mmc_hsq_modify_threshold(hsq);
+
 	slot = &hsq->slot[hsq->next_tag];
 	hsq->mrq = slot->mrq;
 	hsq->qcnt--;
diff --git a/drivers/mmc/host/mmc_hsq.h b/drivers/mmc/host/mmc_hsq.h
index aa5c4543b55f..dd352a6ac32a 100644
--- a/drivers/mmc/host/mmc_hsq.h
+++ b/drivers/mmc/host/mmc_hsq.h
@@ -10,6 +10,11 @@
  * flight to avoid a long latency.
  */
 #define HSQ_NORMAL_DEPTH	2
+/*
+ * For 4k random writes, we allow hsq_depth to increase to 5
+ * for better performance.
+ */
+#define HSQ_PERFORMANCE_DEPTH	5
 
 struct hsq_slot {
 	struct mmc_request *mrq;
-- 
2.17.1


  parent reply	other threads:[~2023-08-29  2:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29  2:04 [PATCH V3 0/2] mmc: hsq: dynamically adjust hsq_depth to improve performance Wenchao Chen
2023-08-29  2:04 ` [PATCH V3 1/2] mmc: queue: replace immediate with hsq->depth Wenchao Chen
2023-08-29  2:04 ` Wenchao Chen [this message]
2023-09-14 12:57   ` [PATCH V3 2/2] mmc: hsq: dynamic adjustment of hsq->depth Ulf Hansson
2023-09-15 11:38     ` Wenchao Chen
  -- strict thread matches above, loose matches on Subject: below --
2023-09-05  2:39 [PATCH V3 0/2 RESEND] mmc: hsq: dynamically adjust hsq_depth to improve performance Wenchao Chen
2023-09-05  2:39 ` [PATCH V3 2/2] mmc: hsq: dynamic adjustment of hsq->depth Wenchao Chen

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=20230829020451.9828-3-wenchao.chen@unisoc.com \
    --to=wenchao.chen@unisoc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=wenchao.chen666@gmail.com \
    --cc=yuelin.tang@unisoc.com \
    --cc=zhenxiong.lai@unisoc.com \
    /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