diff mbox series

[RFC,1/3] dt-bindings: dma: Add documentation for DMA domains

Message ID 20190906141816.24095-2-peter.ujfalusi@ti.com
State New
Headers show
Series dmaengine: Support for DMA domain controllers | expand

Commit Message

Peter Ujfalusi Sept. 6, 2019, 2:18 p.m. UTC
On systems where multiple DMA controllers available, none Slave (for example
memcpy operation) users can not be described in DT as there is no device
involved from the DMA controller's point of view, DMA binding is not usable.
However in these systems still a peripheral might need to be serviced by or
it is better to serviced by specific DMA controller.
When a memcpy is used to/from a memory mapped region for example a DMA in the
same domain can perform better.
For generic software modules doing mem 2 mem operations it also matter that
they will get a channel from a controller which is faster in DDR to DDR mode
rather then from the first controller happen to be loaded.

This property is inherited, so it may be specified in a device node or in any
of its parent nodes.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

---
 .../devicetree/bindings/dma/dma-domain.yaml   | 59 +++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/dma-domain.yaml

-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

Comments

Vinod Koul Sept. 8, 2019, 12:06 p.m. UTC | #1
On 06-09-19, 17:18, Peter Ujfalusi wrote:
> On systems where multiple DMA controllers available, none Slave (for example


On systems with multiple DMA controllers, non Slave...

> memcpy operation) users can not be described in DT as there is no device

> involved from the DMA controller's point of view, DMA binding is not usable.

> However in these systems still a peripheral might need to be serviced by or

> it is better to serviced by specific DMA controller.

> When a memcpy is used to/from a memory mapped region for example a DMA in the

> same domain can perform better.

> For generic software modules doing mem 2 mem operations it also matter that

> they will get a channel from a controller which is faster in DDR to DDR mode

> rather then from the first controller happen to be loaded.

> 

> This property is inherited, so it may be specified in a device node or in any

> of its parent nodes.

> 

> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

> ---

>  .../devicetree/bindings/dma/dma-domain.yaml   | 59 +++++++++++++++++++

>  1 file changed, 59 insertions(+)

>  create mode 100644 Documentation/devicetree/bindings/dma/dma-domain.yaml

> 

> diff --git a/Documentation/devicetree/bindings/dma/dma-domain.yaml b/Documentation/devicetree/bindings/dma/dma-domain.yaml

> new file mode 100644

> index 000000000000..c2f182f30081

> --- /dev/null

> +++ b/Documentation/devicetree/bindings/dma/dma-domain.yaml

> @@ -0,0 +1,59 @@

> +# SPDX-License-Identifier: GPL-2.0

> +%YAML 1.2

> +---

> +$id: http://devicetree.org/schemas/dma/dma-controller.yaml#

> +$schema: http://devicetree.org/meta-schemas/core.yaml#

> +

> +title: DMA Domain Controller Definition

> +

> +maintainers:

> +  - Vinod Koul <vkoul@kernel.org>

> +

> +allOf:

> +  - $ref: "dma-controller.yaml#"

> +

> +description:

> +  On systems where multiple DMA controllers available, none Slave (for example

> +  memcpy operation) users can not be described in DT as there is no device

> +  involved from the DMA controller's point of view, DMA binding is not usable.

> +  However in these systems still a peripheral might need to be serviced by or

> +  it is better to serviced by specific DMA controller.

> +  When a memcpy is used to/from a memory mapped region for example a DMA in the

> +  same domain can perform better.

> +  For generic software modules doing mem 2 mem operations it also matter that

> +  they will get a channel from a controller which is faster in DDR to DDR mode

> +  rather then from the first controller happen to be loaded.

> +

> +  This property is inherited, so it may be specified in a device node or in any

> +  of its parent nodes.

> +

> +properties:

> +  $dma-domain-controller:

> +    $ref: /schemas/types.yaml#definitions/phandle

> +    description:

> +      phande to the DMA controller node which should be used for the device or

> +      domain.

> +

> +examples:

> +  - |

> +    / {

> +        model = "Texas Instruments K3 AM654 SoC";

> +        compatible = "ti,am654";

> +        interrupt-parent = <&gic500>;

> +        /* For modules without device, DDR to DDR is faster on main UDMAP */

> +        dma-domain-controller = <&main_udmap>;

> +        #address-cells = <2>;

> +        #size-cells = <2>;

> +        ...

> +    };

> +

> +    &cbass_main {

> +        /* For modules within MAIN domain, use main UDMAP */

> +        dma-domain-controller = <&main_udmap>;

> +    };

> +

> +    &cbass_mcu {

> +        /* For modules within MCU domain, use mcu UDMAP */

> +        dma-domain-controller = <&mcu_udmap>;


perhaps add the example of main_udmap and mcu_udmap as well

> +    };

> +...

> -- 

> Peter

> 

> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.

> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


-- 
~Vinod
Peter Ujfalusi Sept. 9, 2019, 6:30 a.m. UTC | #2
On 08/09/2019 15.10, Vinod Koul wrote:
> On 08-09-19, 10:47, Peter Ujfalusi wrote:

>>

>>

>> On 06/09/2019 17.18, Peter Ujfalusi wrote:

>>> On systems where multiple DMA controllers available, none Slave (for example

>>> memcpy operation) users can not be described in DT as there is no device

>>> involved from the DMA controller's point of view, DMA binding is not usable.

>>> However in these systems still a peripheral might need to be serviced by or

>>> it is better to serviced by specific DMA controller.

>>> When a memcpy is used to/from a memory mapped region for example a DMA in the

>>> same domain can perform better.

>>> For generic software modules doing mem 2 mem operations it also matter that

>>> they will get a channel from a controller which is faster in DDR to DDR mode

>>> rather then from the first controller happen to be loaded.

>>>

>>> This property is inherited, so it may be specified in a device node or in any

>>> of its parent nodes.

>>>

>>> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

>>> ---

>>>  .../devicetree/bindings/dma/dma-domain.yaml   | 59 +++++++++++++++++++

>>>  1 file changed, 59 insertions(+)

>>>  create mode 100644 Documentation/devicetree/bindings/dma/dma-domain.yaml

>>>

>>> diff --git a/Documentation/devicetree/bindings/dma/dma-domain.yaml b/Documentation/devicetree/bindings/dma/dma-domain.yaml

>>> new file mode 100644

>>> index 000000000000..c2f182f30081

>>> --- /dev/null

>>> +++ b/Documentation/devicetree/bindings/dma/dma-domain.yaml

>>> @@ -0,0 +1,59 @@

>>> +# SPDX-License-Identifier: GPL-2.0

>>> +%YAML 1.2

>>> +---

>>> +$id: http://devicetree.org/schemas/dma/dma-controller.yaml#

>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#

>>> +

>>> +title: DMA Domain Controller Definition

>>> +

>>> +maintainers:

>>> +  - Vinod Koul <vkoul@kernel.org>

>>> +

>>> +allOf:

>>> +  - $ref: "dma-controller.yaml#"

>>> +

>>> +description:

>>> +  On systems where multiple DMA controllers available, none Slave (for example

>>> +  memcpy operation) users can not be described in DT as there is no device

>>> +  involved from the DMA controller's point of view, DMA binding is not usable.

>>> +  However in these systems still a peripheral might need to be serviced by or

>>> +  it is better to serviced by specific DMA controller.

>>> +  When a memcpy is used to/from a memory mapped region for example a DMA in the

>>> +  same domain can perform better.

>>> +  For generic software modules doing mem 2 mem operations it also matter that

>>> +  they will get a channel from a controller which is faster in DDR to DDR mode

>>> +  rather then from the first controller happen to be loaded.

>>> +

>>> +  This property is inherited, so it may be specified in a device node or in any

>>> +  of its parent nodes.

>>> +

>>> +properties:

>>> +  $dma-domain-controller:

>>

>> or domain-dma-controller?

> 

> I feel dma-domain-controller sounds fine as we are defining domains for

> dmaengine. Another thought which comes here is that why not extend this to

> slave as well and define dma-domain-controller for them as use that for

> filtering, that is what we really need along with slave id in case a

> specific channel is to be used by a peripheral

> 

> Thoughts..?


I have thought about this, we should be able to drop the phandle to the
dma controller from the slave binding just fine.

However we have the dma routers for the slave channels and there is no
clear way to handle them.
They are not needed for non slave channels as there is no trigger to
route. In DRA7 for example we have an event router for EDMA and another
one for sDMA. If a slave device is to be serviced by EDMA, the EDMA
event router needs to be specified, for sDMA clients should use the sDMA
event router.
In DRA7 case we don't really have DMA controllers for domains, but we
use the DMA which can service the peripheral better (sDMA is better to
be used for UART, but can not be used for McASP for example)

Then we have the other type of DMA router for daVinci/am33xx/am43xx
where the crossbar is not for the whole EDMA controller like in DRA7,
but we have small crossbars for some channels.

Other vendors have their own dma router topology..

Too many variables to handle the cases without gotchas, which would need
heavy churn in the core or in drivers.

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Vinod Koul Sept. 12, 2019, 5:03 p.m. UTC | #3
On 09-09-19, 09:30, Peter Ujfalusi wrote:

> >> or domain-dma-controller?

> > 

> > I feel dma-domain-controller sounds fine as we are defining domains for

> > dmaengine. Another thought which comes here is that why not extend this to

> > slave as well and define dma-domain-controller for them as use that for

> > filtering, that is what we really need along with slave id in case a

> > specific channel is to be used by a peripheral

> > 

> > Thoughts..?

> 

> I have thought about this, we should be able to drop the phandle to the

> dma controller from the slave binding just fine.

> 

> However we have the dma routers for the slave channels and there is no

> clear way to handle them.

> They are not needed for non slave channels as there is no trigger to

> route. In DRA7 for example we have an event router for EDMA and another

> one for sDMA. If a slave device is to be serviced by EDMA, the EDMA

> event router needs to be specified, for sDMA clients should use the sDMA

> event router.


So you have dma, xbar and client? And you need to use a specfic xbar,
did i get that right?

> In DRA7 case we don't really have DMA controllers for domains, but we

> use the DMA which can service the peripheral better (sDMA is better to

> be used for UART, but can not be used for McASP for example)

> 

> Then we have the other type of DMA router for daVinci/am33xx/am43xx

> where the crossbar is not for the whole EDMA controller like in DRA7,

> but we have small crossbars for some channels.

> 

> Other vendors have their own dma router topology..

> 

> Too many variables to handle the cases without gotchas, which would need

> heavy churn in the core or in drivers.


-- 
~Vinod
Peter Ujfalusi Sept. 13, 2019, 7:21 a.m. UTC | #4
On 12/09/2019 20.03, Vinod Koul wrote:
> On 09-09-19, 09:30, Peter Ujfalusi wrote:

> 

>>>> or domain-dma-controller?

>>>

>>> I feel dma-domain-controller sounds fine as we are defining domains for

>>> dmaengine. Another thought which comes here is that why not extend this to

>>> slave as well and define dma-domain-controller for them as use that for

>>> filtering, that is what we really need along with slave id in case a

>>> specific channel is to be used by a peripheral

>>>

>>> Thoughts..?

>>

>> I have thought about this, we should be able to drop the phandle to the

>> dma controller from the slave binding just fine.

>>

>> However we have the dma routers for the slave channels and there is no

>> clear way to handle them.

>> They are not needed for non slave channels as there is no trigger to

>> route. In DRA7 for example we have an event router for EDMA and another

>> one for sDMA. If a slave device is to be serviced by EDMA, the EDMA

>> event router needs to be specified, for sDMA clients should use the sDMA

>> event router.

> 

> So you have dma, xbar and client? And you need to use a specfic xbar,

> did i get that right?


At the end yes.
EDMA have dedicated crossbar
sDMA have dedicated crossbar

Slave devices must use the crossbar to request channel from the DMA
controllers. Non slave request are directed to the controllers directly
(no DT binding).

At minimum we would need a new property for DMA routers.
dma-domain-router perhaps which is pointing to the xbar.

A slave channel request would first look for dma-domain-router, if it is
there, the request goes via that.
If not then look for dma-domain-controller and use it for the request.
The DMA binding can drop the phandle to the xbar/dma.

Request for not slave channel would only look for dma-domain-controller.

But...

- If we have one dedicated memcpy DMA and one for slave usage.
In top we declare dma-domain-controller = <&m2m_dma>;

Then you have  a slave client somewhere
client1: peripheral@42 {
	dma-domain-controller = <&slave_dma>;
	dmas = <6>, <7>;
	dma-names = "tx", "rx";
};

This is fine I guess. But what would we do if the driver for client1
needs additional memcpy channel? By the definition of the binding the
non slave channel should be taken from the closest dma-domain-controller
which is not what we want. We want the channel from m2m_dma.

And no, we can not start looking for the dma-domain-controller starting
from the root as in most cases the dma-domain-controller closer to the
client is what we really want and not the globally best controller.

- How to handle the transition?
If neither dma-domain-controller/router is found, assume that the first
argument in the binding is a phandle to the dma/router?
We need to carry the support for what we have today for a long time. The
kernel must boot with old DT blob.

- Will it make things cleaner? Atm it is pretty easy to see which
controller/router is used for which device.

- Also to note that the EDMA and sDMA bindings are different, so we can
not just swap dma-domain-controller/router underneath, we also need to
modify the client's dmas line as well.

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Vinod Koul Sept. 13, 2019, 10:36 a.m. UTC | #5
On 13-09-19, 10:21, Peter Ujfalusi wrote:
> 

> 

> On 12/09/2019 20.03, Vinod Koul wrote:

> > On 09-09-19, 09:30, Peter Ujfalusi wrote:

> > 

> >>>> or domain-dma-controller?

> >>>

> >>> I feel dma-domain-controller sounds fine as we are defining domains for

> >>> dmaengine. Another thought which comes here is that why not extend this to

> >>> slave as well and define dma-domain-controller for them as use that for

> >>> filtering, that is what we really need along with slave id in case a

> >>> specific channel is to be used by a peripheral

> >>>

> >>> Thoughts..?

> >>

> >> I have thought about this, we should be able to drop the phandle to the

> >> dma controller from the slave binding just fine.

> >>

> >> However we have the dma routers for the slave channels and there is no

> >> clear way to handle them.

> >> They are not needed for non slave channels as there is no trigger to

> >> route. In DRA7 for example we have an event router for EDMA and another

> >> one for sDMA. If a slave device is to be serviced by EDMA, the EDMA

> >> event router needs to be specified, for sDMA clients should use the sDMA

> >> event router.

> > 

> > So you have dma, xbar and client? And you need to use a specfic xbar,

> > did i get that right?

> 

> At the end yes.


:)

> EDMA have dedicated crossbar

> sDMA have dedicated crossbar


So the domain mapping should point to crossbar.

> Slave devices must use the crossbar to request channel from the DMA

> controllers. Non slave request are directed to the controllers directly

> (no DT binding).


The clients for these are different right, if so slave clients will
point to domain xbar and non slave will point to domain controller (to
make everyone use domains). Non domain get any channel ... (fallback as
well)


> At minimum we would need a new property for DMA routers.

> dma-domain-router perhaps which is pointing to the xbar.


Precisely!

> A slave channel request would first look for dma-domain-router, if it is

> there, the request goes via that.

> If not then look for dma-domain-controller and use it for the request.

> The DMA binding can drop the phandle to the xbar/dma.

> Request for not slave channel would only look for dma-domain-controller.

>

> 

> But...

> 

> - If we have one dedicated memcpy DMA and one for slave usage.

> In top we declare dma-domain-controller = <&m2m_dma>;

> 

> Then you have  a slave client somewhere

> client1: peripheral@42 {

> 	dma-domain-controller = <&slave_dma>;

> 	dmas = <6>, <7>;

> 	dma-names = "tx", "rx";

> };

> 

> This is fine I guess. But what would we do if the driver for client1

> needs additional memcpy channel? By the definition of the binding the

> non slave channel should be taken from the closest dma-domain-controller

> which is not what we want. We want the channel from m2m_dma.


I would not envision same controller needs both memcpy or slave
channels. If so, that should be represented as something like dma-names
and represent two sets of dmas one for domain1 and another for domain2.

I would generalize it and not call it memcpy/slave but just domains and
have a controller use multiple domains (if we have a super controller
which can do that :D)

client1: peripheral@42 {
        dma-domain-names = "memcpy", "slave";
        dma-domains = <&mem_dma>, <&slave_dma>;
        ...
};


> 

> And no, we can not start looking for the dma-domain-controller starting

> from the root as in most cases the dma-domain-controller closer to the

> client is what we really want and not the globally best controller.

> 

> - How to handle the transition?

>

> If neither dma-domain-controller/router is found, assume that the first

> argument in the binding is a phandle to the dma/router?

> We need to carry the support for what we have today for a long time. The

> kernel must boot with old DT blob.

> 

> - Will it make things cleaner? Atm it is pretty easy to see which

> controller/router is used for which device.

> 

> - Also to note that the EDMA and sDMA bindings are different, so we can

> not just swap dma-domain-controller/router underneath, we also need to

> modify the client's dmas line as well.

> 

> - Péter

> 

> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.

> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


-- 
~Vinod
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/dma/dma-domain.yaml b/Documentation/devicetree/bindings/dma/dma-domain.yaml
new file mode 100644
index 000000000000..c2f182f30081
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/dma-domain.yaml
@@ -0,0 +1,59 @@ 
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/dma-controller.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: DMA Domain Controller Definition
+
+maintainers:
+  - Vinod Koul <vkoul@kernel.org>
+
+allOf:
+  - $ref: "dma-controller.yaml#"
+
+description:
+  On systems where multiple DMA controllers available, none Slave (for example
+  memcpy operation) users can not be described in DT as there is no device
+  involved from the DMA controller's point of view, DMA binding is not usable.
+  However in these systems still a peripheral might need to be serviced by or
+  it is better to serviced by specific DMA controller.
+  When a memcpy is used to/from a memory mapped region for example a DMA in the
+  same domain can perform better.
+  For generic software modules doing mem 2 mem operations it also matter that
+  they will get a channel from a controller which is faster in DDR to DDR mode
+  rather then from the first controller happen to be loaded.
+
+  This property is inherited, so it may be specified in a device node or in any
+  of its parent nodes.
+
+properties:
+  $dma-domain-controller:
+    $ref: /schemas/types.yaml#definitions/phandle
+    description:
+      phande to the DMA controller node which should be used for the device or
+      domain.
+
+examples:
+  - |
+    / {
+        model = "Texas Instruments K3 AM654 SoC";
+        compatible = "ti,am654";
+        interrupt-parent = <&gic500>;
+        /* For modules without device, DDR to DDR is faster on main UDMAP */
+        dma-domain-controller = <&main_udmap>;
+        #address-cells = <2>;
+        #size-cells = <2>;
+        ...
+    };
+
+    &cbass_main {
+        /* For modules within MAIN domain, use main UDMAP */
+        dma-domain-controller = <&main_udmap>;
+    };
+
+    &cbass_mcu {
+        /* For modules within MCU domain, use mcu UDMAP */
+        dma-domain-controller = <&mcu_udmap>;
+    };
+...