linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Introduce the request_atomic() for the host
@ 2019-12-26 11:29 Baolin Wang
  2019-12-26 11:29 ` [PATCH 1/3] mmc: host: " Baolin Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Baolin Wang @ 2019-12-26 11:29 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: orsonzhai, zhang.lyra, arnd, linus.walleij, baolin.wang,
	baolin.wang7, linux-mmc, linux-kernel

This patch set introduces a new request_atomic() interface for the
MMC host controller, which is used to submit a request to host in
the atomic context, such as in the irq hard handler, to reduce the
request latency.

This patch set is based on mmc/next_host_sq branch:
https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git/log/?h=next_host_sq

Any comments are welcome. Thanks.

Baolin Wang (3):
  mmc: host: Introduce the request_atomic() for the host
  mmc: host: sdhci-sprd: Implement the request_atomic() API
  mmc: host: hsq: Support request_atomic() API

 drivers/mmc/host/mmc_hsq.c    |    5 ++++-
 drivers/mmc/host/sdhci-sprd.c |   28 ++++++++++++++++++++++++++--
 drivers/mmc/host/sdhci.c      |   27 +++++++++++++++++++--------
 drivers/mmc/host/sdhci.h      |    1 +
 include/linux/mmc/host.h      |    3 +++
 5 files changed, 53 insertions(+), 11 deletions(-)

-- 
1.7.9.5


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

* [PATCH 1/3] mmc: host: Introduce the request_atomic() for the host
  2019-12-26 11:29 [PATCH 0/3] Introduce the request_atomic() for the host Baolin Wang
@ 2019-12-26 11:29 ` Baolin Wang
  2019-12-26 11:29 ` [PATCH 2/3] mmc: host: sdhci-sprd: Implement the request_atomic() API Baolin Wang
  2019-12-26 11:29 ` [PATCH 3/3] mmc: host: hsq: Support " Baolin Wang
  2 siblings, 0 replies; 4+ messages in thread
From: Baolin Wang @ 2019-12-26 11:29 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: orsonzhai, zhang.lyra, arnd, linus.walleij, baolin.wang,
	baolin.wang7, linux-mmc, linux-kernel

The SD host controller can process one request in the atomic context if
the card is nonremovable, which means we can submit next request in the
irq hard handler when using the MMC software queue to reduce the latency.
Thus this patch adds a new API request_atomic() for the host controller
and implement it for the SD host controller.

Suggested-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
---
 drivers/mmc/host/sdhci.c |   27 +++++++++++++++++++--------
 drivers/mmc/host/sdhci.h |    1 +
 include/linux/mmc/host.h |    3 +++
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 64bef96..004f789 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1810,17 +1810,12 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
  *                                                                           *
 \*****************************************************************************/
 
-void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
+static void sdhci_start_request(struct mmc_host *mmc, struct mmc_request *mrq,
+				int present)
 {
-	struct sdhci_host *host;
-	int present;
+	struct sdhci_host *host = mmc_priv(mmc);
 	unsigned long flags;
 
-	host = mmc_priv(mmc);
-
-	/* Firstly check card presence */
-	present = mmc->ops->get_cd(mmc);
-
 	spin_lock_irqsave(&host->lock, flags);
 
 	sdhci_led_activate(host);
@@ -1848,6 +1843,22 @@ void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 
 	spin_unlock_irqrestore(&host->lock, flags);
 }
+
+void sdhci_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq)
+{
+	sdhci_start_request(mmc, mrq, 1);
+}
+EXPORT_SYMBOL_GPL(sdhci_request_atomic);
+
+void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
+{
+	int present;
+
+	/* Firstly check card presence */
+	present = mmc->ops->get_cd(mmc);
+
+	sdhci_start_request(mmc, mrq, present);
+}
 EXPORT_SYMBOL_GPL(sdhci_request);
 
 void sdhci_set_bus_width(struct sdhci_host *host, int width)
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index a73ce89..cecc64b 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -765,6 +765,7 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
 void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode,
 			   unsigned short vdd);
 void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq);
+void sdhci_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq);
 void sdhci_set_bus_width(struct sdhci_host *host, int width);
 void sdhci_reset(struct sdhci_host *host, u8 mask);
 void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing);
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 3931aa3..cc1a79b 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -92,6 +92,9 @@ struct mmc_host_ops {
 			    int err);
 	void	(*pre_req)(struct mmc_host *host, struct mmc_request *req);
 	void	(*request)(struct mmc_host *host, struct mmc_request *req);
+	/* Submit one request to host in atomic context. */
+	void	(*request_atomic)(struct mmc_host *host,
+				  struct mmc_request *req);
 
 	/*
 	 * Avoid calling the next three functions too often or in a "fast
-- 
1.7.9.5


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

* [PATCH 2/3] mmc: host: sdhci-sprd: Implement the request_atomic() API
  2019-12-26 11:29 [PATCH 0/3] Introduce the request_atomic() for the host Baolin Wang
  2019-12-26 11:29 ` [PATCH 1/3] mmc: host: " Baolin Wang
@ 2019-12-26 11:29 ` Baolin Wang
  2019-12-26 11:29 ` [PATCH 3/3] mmc: host: hsq: Support " Baolin Wang
  2 siblings, 0 replies; 4+ messages in thread
From: Baolin Wang @ 2019-12-26 11:29 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: orsonzhai, zhang.lyra, arnd, linus.walleij, baolin.wang,
	baolin.wang7, linux-mmc, linux-kernel

Implement the request_atomic() API for nonremovable cards, that means
we can submit next request in the irq hard handler context to reduce
latency.

Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
---
 drivers/mmc/host/sdhci-sprd.c |   28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index d346223..ae9acb8 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -426,6 +426,27 @@ static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq)
 	sdhci_request(mmc, mrq);
 }
 
+static void sdhci_sprd_request_atomic(struct mmc_host *mmc,
+				      struct mmc_request *mrq)
+{
+	struct sdhci_host *host = mmc_priv(mmc);
+	struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host);
+
+	host->flags |= sprd_host->flags & SDHCI_AUTO_CMD23;
+
+	/*
+	 * From version 4.10 onward, ARGUMENT2 register is also as 32-bit
+	 * block count register which doesn't support stuff bits of
+	 * CMD23 argument on Spreadtrum's sd host controller.
+	 */
+	if (host->version >= SDHCI_SPEC_410 &&
+	    mrq->sbc && (mrq->sbc->arg & SDHCI_SPRD_ARG2_STUFF) &&
+	    (host->flags & SDHCI_AUTO_CMD23))
+		host->flags &= ~SDHCI_AUTO_CMD23;
+
+	sdhci_request_atomic(mmc, mrq);
+}
+
 static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
 {
 	struct sdhci_host *host = mmc_priv(mmc);
@@ -561,6 +582,11 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
 	if (ret)
 		goto pltfm_free;
 
+	if (!mmc_card_is_removable(host->mmc))
+		host->mmc_host_ops.request_atomic = sdhci_sprd_request_atomic;
+	else
+		host->always_defer_done = true;
+
 	sprd_host = TO_SPRD_HOST(host);
 	sdhci_sprd_phy_param_parse(sprd_host, pdev->dev.of_node);
 
@@ -654,8 +680,6 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_cleanup_host;
 
-	host->always_defer_done = true;
-
 	ret = __sdhci_add_host(host);
 	if (ret)
 		goto err_cleanup_host;
-- 
1.7.9.5


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

* [PATCH 3/3] mmc: host: hsq: Support request_atomic() API
  2019-12-26 11:29 [PATCH 0/3] Introduce the request_atomic() for the host Baolin Wang
  2019-12-26 11:29 ` [PATCH 1/3] mmc: host: " Baolin Wang
  2019-12-26 11:29 ` [PATCH 2/3] mmc: host: sdhci-sprd: Implement the request_atomic() API Baolin Wang
@ 2019-12-26 11:29 ` Baolin Wang
  2 siblings, 0 replies; 4+ messages in thread
From: Baolin Wang @ 2019-12-26 11:29 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: orsonzhai, zhang.lyra, arnd, linus.walleij, baolin.wang,
	baolin.wang7, linux-mmc, linux-kernel

Add support to submit a request by request_atomic() API.

Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
---
 drivers/mmc/host/mmc_hsq.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/mmc_hsq.c b/drivers/mmc/host/mmc_hsq.c
index f5a4f93..6a6bdd0 100644
--- a/drivers/mmc/host/mmc_hsq.c
+++ b/drivers/mmc/host/mmc_hsq.c
@@ -40,7 +40,10 @@ static void mmc_hsq_pump_requests(struct mmc_hsq *hsq)
 
 	spin_unlock_irqrestore(&hsq->lock, flags);
 
-	mmc->ops->request(mmc, hsq->mrq);
+	if (mmc->ops->request_atomic)
+		mmc->ops->request_atomic(mmc, hsq->mrq);
+	else
+		mmc->ops->request(mmc, hsq->mrq);
 }
 
 static void mmc_hsq_update_next_tag(struct mmc_hsq *hsq, int remains)
-- 
1.7.9.5


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

end of thread, other threads:[~2019-12-26 11:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-26 11:29 [PATCH 0/3] Introduce the request_atomic() for the host Baolin Wang
2019-12-26 11:29 ` [PATCH 1/3] mmc: host: " Baolin Wang
2019-12-26 11:29 ` [PATCH 2/3] mmc: host: sdhci-sprd: Implement the request_atomic() API Baolin Wang
2019-12-26 11:29 ` [PATCH 3/3] mmc: host: hsq: Support " Baolin Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).