mmc: core: Allow dynamical updates of the number of requests for hsq
authorWenchao Chen <wenchao.chen@unisoc.com>
Tue, 19 Sep 2023 07:47:06 +0000 (15:47 +0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Wed, 27 Sep 2023 10:13:18 +0000 (12:13 +0200)
To allow dynamical updates of the current number of used in-flight
requests, let's move away from using a hard-coded value to a use a
corresponding variable in the struct mmc_host.

This can be valuable when optimizing for certain I/O request sequences, as
shown by subsequent changes.

Signed-off-by: Wenchao Chen <wenchao.chen@unisoc.com>
Link: https://lore.kernel.org/r/20230919074707.25517-2-wenchao.chen@unisoc.com
[Ulf: Re-wrote the commitmsg to clarify the change]
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/queue.c
drivers/mmc/host/mmc_hsq.c
drivers/mmc/host/mmc_hsq.h
include/linux/mmc/host.h

index b396e39007177cc3ac22c7a783bd6e3bf46159bc..a0a2412f62a7304278220a9f72e0ea84d4e2a508 100644 (file)
@@ -260,11 +260,7 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
                }
                break;
        case MMC_ISSUE_ASYNC:
-               /*
-                * For MMC host software queue, we only allow 2 requests in
-                * flight to avoid a long latency.
-                */
-               if (host->hsq_enabled && mq->in_flight[issue_type] > 2) {
+               if (host->hsq_enabled && mq->in_flight[issue_type] > host->hsq_depth) {
                        spin_unlock_irq(&mq->lock);
                        return BLK_STS_RESOURCE;
                }
index 424dc7b07858f658b2c49685895a6027d03409de..8556cacb21a1b4971c99144edd8531ef65771307 100644 (file)
@@ -337,6 +337,7 @@ int mmc_hsq_init(struct mmc_hsq *hsq, struct mmc_host *mmc)
        hsq->mmc = mmc;
        hsq->mmc->cqe_private = hsq;
        mmc->cqe_ops = &mmc_hsq_ops;
+       mmc->hsq_depth = HSQ_NORMAL_DEPTH;
 
        for (i = 0; i < HSQ_NUM_SLOTS; i++)
                hsq->tag_slot[i] = HSQ_INVALID_TAG;
index 1808024fc6c5d696e9feb3f85954565356a16576..aa5c4543b55f89a554d518f517304e80f0481914 100644 (file)
@@ -5,6 +5,12 @@
 #define HSQ_NUM_SLOTS  64
 #define HSQ_INVALID_TAG        HSQ_NUM_SLOTS
 
+/*
+ * For MMC host software queue, we only allow 2 requests in
+ * flight to avoid a long latency.
+ */
+#define HSQ_NORMAL_DEPTH       2
+
 struct hsq_slot {
        struct mmc_request *mrq;
 };
index 62a6847a3b6f00efab0c9129806ebd75e18a0af0..2f445c651742e679ee4311d5f62a3b6e1632d08d 100644 (file)
@@ -526,6 +526,7 @@ struct mmc_host {
 
        /* Host Software Queue support */
        bool                    hsq_enabled;
+       int                     hsq_depth;
 
        u32                     err_stats[MMC_ERR_MAX];
        unsigned long           private[] ____cacheline_aligned;