diff mbox series

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

Message ID 20190906141816.24095-2-peter.ujfalusi@ti.com (mailing list archive)
State RFC
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

Comments

Peter Ujfalusi Sept. 8, 2019, 7:47 a.m. UTC | #1
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?

> +    $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>;
> +    };
> +...
> 

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Vinod Koul Sept. 8, 2019, 12:06 p.m. UTC | #2
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 Koul Sept. 8, 2019, 12:10 p.m. UTC | #3
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..?
Peter Ujfalusi Sept. 9, 2019, 6 a.m. UTC | #4
On 08/09/2019 15.06, Vinod Koul wrote:
> 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...

Sure.

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

I can populate the tree with the main/mcu_udmap and on MCU I can also
add the OSPI node.
The idea is to specify the dma controller to be used for non slave
channels on every device on MAIN/MCU domain.
UDMAPs do not need this property specified, it is needed for clients.

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

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Peter Ujfalusi Sept. 9, 2019, 6:30 a.m. UTC | #5
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 | #6
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.
Peter Ujfalusi Sept. 13, 2019, 7:21 a.m. UTC | #7
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 | #8
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
Peter Ujfalusi Sept. 13, 2019, 12:19 p.m. UTC | #9
Vinod,

On 13/09/2019 13.36, Vinod Koul wrote:
>>> 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!

After some thinking at the end we have two main type of DMA channels:
slave channels: Hw triggered channels
non-slave channels: SW triggered channels w/o DMA request lines

right?

Slave channels must be described in DT as we need to specify the DMA
request number/line/trigger, whatever it is called on different platforms.

non-slave channels on the other hand can be requested from any
controllers which can execute it. Or in the scope of this series, from
the controller which is best suited to service the device or module.

If we really want to move to similar binding structure as interrupts
opposed to what we have atm (gpio, pwm, leds, etc uses the same
principle), then

dma-slave-controller: can point to a dma controller or dma router which
should be used from the node it is presented inherited by it's child
nodes for slave channels.

dma-nonslave-controller: can point to a dma controller which should be
used from the node it is presented inherited by it's child nodes for non
slave channels.

DMA routers have the phandle for the dma controller they are attached
to, so this should be fine, I guess.

Based on the topology of the SoC, these can be added in higher level in
the tree to divert from the higher level controller selection.

>> 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>;
>         ...
> };

Right, similar thing should work, I guess.

/ {
	/* DDR to DDR is used in main_udmap */
	dma-domain-names = "memcpy";
	dma-domains = <&main_udmap>;

	cbass_main {
		/* memcpy is from main_udmap and slaves also */
		dma-domain-names = "slave";
		dma-domains = <&main_udmap>;

		cbass_mcu {
			/* memcpy is from mcu_udmap and slaves also */
			dma-domain-names = "memcpy", "slave";
			dma-domains = <&mcu_udmap>, <&mcu_udmap>;

		};
	};
};

or

/ {
	/* memcpy is from edma and slaves also */
	dma-domain-names = "memcpy", "slave";
	dma-domains = <&edma>, <&edma>;

	edma_xbar1 xbar@0 {
		/*
		 * DMA router on front of edma,
		 * optionally can be explicitly tell the DMA controller
		 * to be used with the router if needed.
		 */

		dma-domain-names = "slave";
		dma-domains = <&main_udmap>;
	};

	mcbsp muxed_dma@0 {
		/* memcpy is from edma and slaves from edma_xbar1 */
		dma-domain-names = "slave";
		dma-domains = <&edma_xbar1>;
	};

	voice muxed_dma@1 {
		/* memcpy is from edma and slaves from edma_xbar1 */
		dma-domain-names = "slave";
		dma-domains = <&edma_xbar1>;
	};

	something not_muxed@0 {
		/* memcpy is from edma and slaves also */
	};
};

Even the DMA router binding can be changed to look for the "slave"
domain it belongs to?

The the dmas can drop the phandle to the controller/router

Internal API wise, things could use
dmaengine_get_slave_domain(struct device *client_dev);
if we get a domain, we know the the binding does not include the phandle
for the controller.

and
dmaengine_get_nonslave_domain(struct device *client_dev);

The DMA routers and drivers might need to be changed, not sure if they
would notice the drop of the first phandle from the binding...

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

Is this big change worth to push for?


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

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Vinod Koul Sept. 13, 2019, 1:33 p.m. UTC | #10
On 13-09-19, 15:19, Peter Ujfalusi wrote:
> Vinod,
> 
> On 13/09/2019 13.36, Vinod Koul wrote:
> >>> 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!
> 
> After some thinking at the end we have two main type of DMA channels:
> slave channels: Hw triggered channels
> non-slave channels: SW triggered channels w/o DMA request lines
> 
> right?

yes and no

You are correct in saying this but I would like to move away from the
two concepts and generalize them a bit, it is long overdue.

So from domain point of view, we have channels (memcpy/slave) specifying
one or more domains to use or no domain (memcpy, any channel)

> Slave channels must be described in DT as we need to specify the DMA
> request number/line/trigger, whatever it is called on different platforms.

So in the cases where a specific channel/request/trigger is required, we
would be required to specify that in DT as we do currently, but more
modern controllers which uses muxes wont need this to be specified,
pointing to domain (which can be controller/xbar) would do the trick!


> non-slave channels on the other hand can be requested from any
> controllers which can execute it. Or in the scope of this series, from
> the controller which is best suited to service the device or module.

Right which takes care of your new requirement as well as older ones

> If we really want to move to similar binding structure as interrupts
> opposed to what we have atm (gpio, pwm, leds, etc uses the same
> principle), then
> 
> dma-slave-controller: can point to a dma controller or dma router which
> should be used from the node it is presented inherited by it's child
> nodes for slave channels.
> 
> dma-nonslave-controller: can point to a dma controller which should be
> used from the node it is presented inherited by it's child nodes for non
> slave channels.
> 
> DMA routers have the phandle for the dma controller they are attached
> to, so this should be fine, I guess.
> 
> Based on the topology of the SoC, these can be added in higher level in
> the tree to divert from the higher level controller selection.

Looks interesting to me and doable. But as I said earlier, lets do a bit
more generalization in concepts please

> >> 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>;
> >         ...
> > };
> 
> Right, similar thing should work, I guess.
> 
> / {
> 	/* DDR to DDR is used in main_udmap */
> 	dma-domain-names = "memcpy";
> 	dma-domains = <&main_udmap>;
> 
> 	cbass_main {
> 		/* memcpy is from main_udmap and slaves also */
> 		dma-domain-names = "slave";
> 		dma-domains = <&main_udmap>;
> 
> 		cbass_mcu {
> 			/* memcpy is from mcu_udmap and slaves also */
> 			dma-domain-names = "memcpy", "slave";
> 			dma-domains = <&mcu_udmap>, <&mcu_udmap>;
> 
> 		};
> 	};
> };
> 
> or
> 
> / {
> 	/* memcpy is from edma and slaves also */
> 	dma-domain-names = "memcpy", "slave";
> 	dma-domains = <&edma>, <&edma>;
> 
> 	edma_xbar1 xbar@0 {
> 		/*
> 		 * DMA router on front of edma,
> 		 * optionally can be explicitly tell the DMA controller
> 		 * to be used with the router if needed.
> 		 */
> 
> 		dma-domain-names = "slave";
> 		dma-domains = <&main_udmap>;
> 	};
> 
> 	mcbsp muxed_dma@0 {
> 		/* memcpy is from edma and slaves from edma_xbar1 */
> 		dma-domain-names = "slave";
> 		dma-domains = <&edma_xbar1>;
> 	};
> 
> 	voice muxed_dma@1 {
> 		/* memcpy is from edma and slaves from edma_xbar1 */
> 		dma-domain-names = "slave";
> 		dma-domains = <&edma_xbar1>;
> 	};
> 
> 	something not_muxed@0 {
> 		/* memcpy is from edma and slaves also */
> 	};
> };
> 
> Even the DMA router binding can be changed to look for the "slave"
> domain it belongs to?
> 
> The the dmas can drop the phandle to the controller/router
> 
> Internal API wise, things could use
> dmaengine_get_slave_domain(struct device *client_dev);
> if we get a domain, we know the the binding does not include the phandle
> for the controller.
> 
> and
> dmaengine_get_nonslave_domain(struct device *client_dev);
> 
> The DMA routers and drivers might need to be changed, not sure if they
> would notice the drop of the first phandle from the binding...
> 
> >>
> >> 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.
> 
> Is this big change worth to push for?
> 
> 
> >> - 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
> > 
> 
> - Péter
> 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
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>;
+    };
+...