linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mmc: ingenic: Support bi-directional DMA channel
@ 2021-12-20 19:08 Paul Cercueil
  2021-12-20 19:08 ` [PATCH 1/2] dt-bindings: mmc: ingenic: Support using " Paul Cercueil
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Paul Cercueil @ 2021-12-20 19:08 UTC (permalink / raw)
  To: Ulf Hansson, Rob Herring
  Cc: list, linux-mmc, devicetree, linux-kernel, linux-mips, Paul Cercueil

Hi Ulf,

This patchset adds support for using a single DMA channel for both RX
and TX operations, instead of using separate DMA channels for each
operation.

As some older Ingenic SoCs offer only a handful of DMA channels,
supporting bi-directional channels allow more hardware to use the
channels that would otherwise be used for the MMC/SD operation.

Note that the Device Tree binding for the DMA controller has been
updated in a (already merged) patchset, so that it accepts a 3 cells
(#dma-cells == 3) instead of just 2. It was merged in the DMA tree, so I
am not sure the autobuilders will like this YAML - but it was checked
without errors.

I also removed the descriptions of the "dmas" property in the YAML, as
they really weren't adding anything and were getting in my way.

There are patches touching the driver file merged in the PM tree (the
ones that use the new PM macros) but I expect no problem here, they
touch different parts of the file.

Cheers,
-Paul

Paul Cercueil (2):
  dt-bindings: mmc: ingenic: Support using bi-directional DMA channel
  mmc: jz4740: Support using a bi-directional DMA channel

 .../devicetree/bindings/mmc/ingenic,mmc.yaml  | 37 ++++++++++++++++---
 drivers/mmc/host/jz4740_mmc.c                 | 19 +++++++++-
 2 files changed, 48 insertions(+), 8 deletions(-)

-- 
2.34.1


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

* [PATCH 1/2] dt-bindings: mmc: ingenic: Support using bi-directional DMA channel
  2021-12-20 19:08 [PATCH 0/2] mmc: ingenic: Support bi-directional DMA channel Paul Cercueil
@ 2021-12-20 19:08 ` Paul Cercueil
  2021-12-20 19:08 ` [PATCH 2/2] mmc: jz4740: Support using a " Paul Cercueil
  2021-12-21 13:03 ` [PATCH 0/2] mmc: ingenic: Support " Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Paul Cercueil @ 2021-12-20 19:08 UTC (permalink / raw)
  To: Ulf Hansson, Rob Herring
  Cc: list, linux-mmc, devicetree, linux-kernel, linux-mips, Paul Cercueil

Update the binding documentation and the examples to support
bi-directional DMA channels.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 .../devicetree/bindings/mmc/ingenic,mmc.yaml  | 37 ++++++++++++++++---
 1 file changed, 31 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/mmc/ingenic,mmc.yaml b/Documentation/devicetree/bindings/mmc/ingenic,mmc.yaml
index 01d5c6da0eeb..2d10aedf2e00 100644
--- a/Documentation/devicetree/bindings/mmc/ingenic,mmc.yaml
+++ b/Documentation/devicetree/bindings/mmc/ingenic,mmc.yaml
@@ -39,14 +39,15 @@ properties:
     const: mmc
 
   dmas:
-    items:
-      - description: DMA controller phandle and request line for RX
-      - description: DMA controller phandle and request line for TX
+    minItems: 1
+    maxItems: 2
 
   dma-names:
-    items:
-      - const: rx
-      - const: tx
+    oneOf:
+      - items:
+          - const: rx
+          - const: tx
+      - const: tx-rx
 
 required:
   - compatible
@@ -80,3 +81,27 @@ examples:
              <&dma JZ4780_DMA_MSC0_TX 0xffffffff>;
       dma-names = "rx", "tx";
     };
+  - |
+    #include <dt-bindings/clock/ingenic,jz4780-cgu.h>
+    #include <dt-bindings/dma/jz4780-dma.h>
+    /*
+     * Alternative version of the example above,
+     * but using one single DMA channel for both
+     * TX and RX.
+     */
+    mmc1: mmc@13460000 {
+      compatible = "ingenic,jz4780-mmc";
+      reg = <0x13460000 0x1000>;
+
+      interrupt-parent = <&intc>;
+      interrupts = <36>;
+
+      clocks = <&cgu JZ4780_CLK_MSC1>;
+      clock-names = "mmc";
+
+      cap-sd-highspeed;
+      cap-mmc-highspeed;
+      cap-sdio-irq;
+      dmas = <&dma JZ4780_DMA_MSC1_TX JZ4780_DMA_MSC1_RX 0xffffffff>;
+      dma-names = "tx-rx";
+    };
-- 
2.34.1


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

* [PATCH 2/2] mmc: jz4740: Support using a bi-directional DMA channel
  2021-12-20 19:08 [PATCH 0/2] mmc: ingenic: Support bi-directional DMA channel Paul Cercueil
  2021-12-20 19:08 ` [PATCH 1/2] dt-bindings: mmc: ingenic: Support using " Paul Cercueil
@ 2021-12-20 19:08 ` Paul Cercueil
  2021-12-21 13:03 ` [PATCH 0/2] mmc: ingenic: Support " Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Paul Cercueil @ 2021-12-20 19:08 UTC (permalink / raw)
  To: Ulf Hansson, Rob Herring
  Cc: list, linux-mmc, devicetree, linux-kernel, linux-mips, Paul Cercueil

Since the MMC/SD controller in Ingenic SoCs work in half-duplex, it is
possible to use one single DMA channel for both TX and RX operations,
instead of using separate channels.

As some older Ingenic SoCs offer only a handful of DMA channels,
supporting bi-directional channels allow more hardware to use the
channels that would otherwise be used for the MMC/SD operation.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/mmc/host/jz4740_mmc.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
index 80a2c270d502..a0b94f61ddcf 100644
--- a/drivers/mmc/host/jz4740_mmc.c
+++ b/drivers/mmc/host/jz4740_mmc.c
@@ -217,11 +217,23 @@ static void jz4740_mmc_release_dma_channels(struct jz4740_mmc_host *host)
 		return;
 
 	dma_release_channel(host->dma_tx);
-	dma_release_channel(host->dma_rx);
+	if (host->dma_rx)
+		dma_release_channel(host->dma_rx);
 }
 
 static int jz4740_mmc_acquire_dma_channels(struct jz4740_mmc_host *host)
 {
+	struct device *dev = mmc_dev(host->mmc);
+
+	host->dma_tx = dma_request_chan(dev, "tx-rx");
+	if (!IS_ERR(host->dma_tx))
+		return 0;
+
+	if (PTR_ERR(host->dma_tx) != -ENODEV) {
+		dev_err(dev, "Failed to get dma tx-rx channel\n");
+		return PTR_ERR(host->dma_tx);
+	}
+
 	host->dma_tx = dma_request_chan(mmc_dev(host->mmc), "tx");
 	if (IS_ERR(host->dma_tx)) {
 		dev_err(mmc_dev(host->mmc), "Failed to get dma_tx channel\n");
@@ -241,7 +253,10 @@ static int jz4740_mmc_acquire_dma_channels(struct jz4740_mmc_host *host)
 static inline struct dma_chan *jz4740_mmc_get_dma_chan(struct jz4740_mmc_host *host,
 						       struct mmc_data *data)
 {
-	return (data->flags & MMC_DATA_READ) ? host->dma_rx : host->dma_tx;
+	if ((data->flags & MMC_DATA_READ) && host->dma_rx)
+		return host->dma_rx;
+	else
+		return host->dma_tx;
 }
 
 static void jz4740_mmc_dma_unmap(struct jz4740_mmc_host *host,
-- 
2.34.1


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

* Re: [PATCH 0/2] mmc: ingenic: Support bi-directional DMA channel
  2021-12-20 19:08 [PATCH 0/2] mmc: ingenic: Support bi-directional DMA channel Paul Cercueil
  2021-12-20 19:08 ` [PATCH 1/2] dt-bindings: mmc: ingenic: Support using " Paul Cercueil
  2021-12-20 19:08 ` [PATCH 2/2] mmc: jz4740: Support using a " Paul Cercueil
@ 2021-12-21 13:03 ` Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2021-12-21 13:03 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Rob Herring, list, linux-mmc, devicetree, linux-kernel, linux-mips

On Mon, 20 Dec 2021 at 20:08, Paul Cercueil <paul@crapouillou.net> wrote:
>
> Hi Ulf,
>
> This patchset adds support for using a single DMA channel for both RX
> and TX operations, instead of using separate DMA channels for each
> operation.
>
> As some older Ingenic SoCs offer only a handful of DMA channels,
> supporting bi-directional channels allow more hardware to use the
> channels that would otherwise be used for the MMC/SD operation.
>
> Note that the Device Tree binding for the DMA controller has been
> updated in a (already merged) patchset, so that it accepts a 3 cells
> (#dma-cells == 3) instead of just 2. It was merged in the DMA tree, so I
> am not sure the autobuilders will like this YAML - but it was checked
> without errors.
>
> I also removed the descriptions of the "dmas" property in the YAML, as
> they really weren't adding anything and were getting in my way.
>
> There are patches touching the driver file merged in the PM tree (the
> ones that use the new PM macros) but I expect no problem here, they
> touch different parts of the file.
>
> Cheers,
> -Paul
>
> Paul Cercueil (2):
>   dt-bindings: mmc: ingenic: Support using bi-directional DMA channel
>   mmc: jz4740: Support using a bi-directional DMA channel
>
>  .../devicetree/bindings/mmc/ingenic,mmc.yaml  | 37 ++++++++++++++++---
>  drivers/mmc/host/jz4740_mmc.c                 | 19 +++++++++-
>  2 files changed, 48 insertions(+), 8 deletions(-)
>

Applied for next, thanks!

Let's see how this goes when the changes hit linux-next. I will have
to drop them, if we encounter any problems.

Kind regards
Uffe

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

end of thread, other threads:[~2021-12-21 13:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20 19:08 [PATCH 0/2] mmc: ingenic: Support bi-directional DMA channel Paul Cercueil
2021-12-20 19:08 ` [PATCH 1/2] dt-bindings: mmc: ingenic: Support using " Paul Cercueil
2021-12-20 19:08 ` [PATCH 2/2] mmc: jz4740: Support using a " Paul Cercueil
2021-12-21 13:03 ` [PATCH 0/2] mmc: ingenic: Support " Ulf Hansson

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).