Linux MultiMedia Card development
 help / color / mirror / Atom feed
From: Jyan Chou <jyanchou@realtek.com>
To: <ulf.hansson@linaro.org>, <adrian.hunter@intel.com>,
	<jh80.chung@samsung.com>, <riteshh@codeaurora.org>,
	<robh+dt@kernel.org>, <krzysztof.kozlowski+dt@linaro.org>
Cc: <conor+dt@kernel.org>, <asutoshd@codeaurora.org>,
	<p.zabel@pengutronix.de>, <linux-mmc@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<arnd@arndb.de>, <briannorris@chromium.org>, <doug@schmorgal.com>,
	<tonyhuang.sunplus@gmail.com>, <abel.vesa@linaro.org>,
	<william.qiu@starfivetech.com>, <jyanchou@realtek.com>
Subject: [PATCH v7][1/4] mmc: solve DMA boundary limitation of CQHCI driver
Date: Tue, 21 Nov 2023 17:10:58 +0800	[thread overview]
Message-ID: <20231121091101.5540-2-jyanchou@realtek.com> (raw)
In-Reply-To: <20231121091101.5540-1-jyanchou@realtek.com>

Due to synopsys data book's description, it had a limitation
while using DMA that buffer size and start address must not
exceed 128 MB.

We add an option setup_tran_desc to make tran_desc setting flexible.

Signed-off-by: Jyan Chou <jyanchou@realtek.com>

---
v6 -> v7:
- fix kernel test robot build errors, error: no member named
'setup_tran_desc' in 'struct cqhci_host_ops'

v4 -> v5:
- use EXPORT_SYMBOL_GPL to replace EXPORT_SYMBOL
- Fix kernel test robot build errors, let 'setup_tran_desc' to be a member in
  'const struct cqhci_host_ops'.

v2 -> v3:
- Fix auto test compile warning.

v1 -> v2:
- Export cqhci_set_tran_desc for setting the descriptor's callback function.

v0 -> v1:
- Separate different patch supports into single patch.
---
 drivers/mmc/host/cqhci-core.c | 13 ++++++++++---
 drivers/mmc/host/cqhci.h      |  8 ++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c
index b3d7d6d8d654..b40bd368a955 100644
--- a/drivers/mmc/host/cqhci-core.c
+++ b/drivers/mmc/host/cqhci-core.c
@@ -474,8 +474,7 @@ static int cqhci_dma_map(struct mmc_host *host, struct mmc_request *mrq)
 	return sg_count;
 }
 
-static void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end,
-				bool dma64)
+void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end, bool dma64)
 {
 	__le32 *attr = (__le32 __force *)desc;
 
@@ -495,9 +494,10 @@ static void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end,
 		dataddr[0] = cpu_to_le32(addr);
 	}
 }
+EXPORT_SYMBOL_GPL(cqhci_set_tran_desc);
 
 static int cqhci_prep_tran_desc(struct mmc_request *mrq,
-			       struct cqhci_host *cq_host, int tag)
+				struct cqhci_host *cq_host, int tag)
 {
 	struct mmc_data *data = mrq->data;
 	int i, sg_count, len;
@@ -516,6 +516,13 @@ static int cqhci_prep_tran_desc(struct mmc_request *mrq,
 
 	desc = get_trans_desc(cq_host, tag);
 
+#ifdef CONFIG_MMC_DW_CQE
+	if (cq_host->ops->setup_tran_desc) {
+		cq_host->ops->setup_tran_desc(data, cq_host, desc, sg_count);
+		return 0;
+	}
+#endif
+
 	for_each_sg(data->sg, sg, sg_count, i) {
 		addr = sg_dma_address(sg);
 		len = sg_dma_len(sg);
diff --git a/drivers/mmc/host/cqhci.h b/drivers/mmc/host/cqhci.h
index 1a12e40a02e6..713fc56127df 100644
--- a/drivers/mmc/host/cqhci.h
+++ b/drivers/mmc/host/cqhci.h
@@ -216,6 +216,7 @@ union cqhci_crypto_cfg_entry {
 struct cqhci_host_ops;
 struct mmc_host;
 struct mmc_request;
+struct mmc_data;
 struct cqhci_slot;
 
 struct cqhci_host {
@@ -293,6 +294,11 @@ struct cqhci_host_ops {
 	int (*program_key)(struct cqhci_host *cq_host,
 			   const union cqhci_crypto_cfg_entry *cfg, int slot);
 #endif
+
+#ifdef CONFIG_MMC_DW_CQE
+	void (*setup_tran_desc)(struct mmc_data *data,
+				struct cqhci_host *cq_host, u8 *desc, int sg_count);
+#endif
 };
 
 static inline void cqhci_writel(struct cqhci_host *host, u32 val, int reg)
@@ -322,6 +328,8 @@ static inline int cqhci_suspend(struct mmc_host *mmc)
 {
 	return cqhci_deactivate(mmc);
 }
+
+void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end, bool dma64);
 int cqhci_resume(struct mmc_host *mmc);
 
 #endif
-- 
2.42.0


  reply	other threads:[~2023-11-21  9:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-21  9:10 [PATCH V7][0/4] Add DesignWare Mobile mmc driver Jyan Chou
2023-11-21  9:10 ` Jyan Chou [this message]
2023-11-21  9:10 ` [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver Jyan Chou
2023-11-22  0:20   ` kernel test robot
2023-11-22 14:48   ` kernel test robot
2023-11-27 12:51   ` Philipp Zabel
2023-11-28  7:05     ` Jyan Chou [周芷安]
2023-11-28 10:53     ` Arnd Bergmann
2023-11-27 13:02   ` Christian Loehle
2023-11-28  6:58     ` Jyan Chou [周芷安]
2023-11-28 18:05   ` Adrian Hunter
2023-12-05  9:19     ` Jyan Chou [周芷安]
2023-12-05 11:26       ` Adrian Hunter
2023-12-11 10:37         ` Jyan Chou [周芷安]
2023-12-11 10:45           ` Adrian Hunter
2023-11-21  9:11 ` [PATCH v7][3/4] mmc: Add dw mobile mmc cmdq rtk driver Jyan Chou
2023-11-21  9:11 ` [PATCH v7][4/4] dt-bindings: mmc: Add dt-bindings for realtek mmc driver Jyan Chou
2023-11-21  9:35   ` Krzysztof Kozlowski
2023-11-22  2:54     ` Jyan Chou [周芷安]
2023-11-22  7:36       ` Krzysztof Kozlowski
2023-11-22  8:33         ` Jyan Chou [周芷安]
2023-11-22  8:45           ` Krzysztof Kozlowski

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=20231121091101.5540-2-jyanchou@realtek.com \
    --to=jyanchou@realtek.com \
    --cc=abel.vesa@linaro.org \
    --cc=adrian.hunter@intel.com \
    --cc=arnd@arndb.de \
    --cc=asutoshd@codeaurora.org \
    --cc=briannorris@chromium.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=doug@schmorgal.com \
    --cc=jh80.chung@samsung.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=riteshh@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=tonyhuang.sunplus@gmail.com \
    --cc=ulf.hansson@linaro.org \
    --cc=william.qiu@starfivetech.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