dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/3] dmaengine: Support for DMA domain controllers
@ 2019-09-06 14:17 Peter Ujfalusi
  2019-09-06 14:17 ` [RFC 1/3] dt-bindings: dma: Add documentation for DMA domains Peter Ujfalusi
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Peter Ujfalusi @ 2019-09-06 14:17 UTC (permalink / raw)
  To: vinod.koul, robh+dt; +Cc: dmaengine, linux-kernel, dan.j.williams, devicetree

Hi,

More and more SoC have more than one DMA controller integrated.

If a device needs none slave DMA channel for operation (block copy from/to
memory mapped regions for example) at the moment when they request a channel it
is going to be taken from the first DMA controller which was registered, but
this might be not optimal for the device.

For example on AM654 we have two DMAs: main_udmap and mcu_udmap.
DDR to DDR memcpy is twice as fast on main_udmap compared to mcu_udmap, while
devices on MCU domain (OSPI for example) are more than twice as fast on
mcu_udmap than with main_udmap.

Because of probing order (mcu_udmap is probing first) modules would use
mcu_udmap instead of the better main_udmap. Currently the only solution is to
make a choice and disable the MEM_TO_MEM functionality on one of them which is
not a great solution.

With the introduction of DMA domain controllers we can utilize the best DMA
controller for the job around the SoC without the need to degrade performance.

If the dma-domain-controller is not present in DT or booted w/o DT the none
slave channel request will work as it does today.

The last patch introduces a new dma_domain_request_chan_by_mask() function and
I have a define for dma_request_chan_by_mask() to avoid breaking users of the
dma_request_chan_by_mask, but looking at the kernel we have small amount of
users:
drivers/gpu/drm/vc4/vc4_dsi.c
drivers/media/platform/omap/omap_vout_vrfb.c
drivers/media/platform/omap3isp/isphist.c
drivers/mtd/spi-nor/cadence-quadspi.c
drivers/spi/spi-ti-qspi.c

If it is acceptable we can modify the parameters of dma_request_chan_by_mask()
to include ther device pointer and at the same time change all of the clients
by giving NULL or in case of the last two their dev.

Regards,
Peter
---
Peter Ujfalusi (3):
  dt-bindings: dma: Add documentation for DMA domains
  dmaengine: of_dma: Function to look up the DMA domain of a client
  dmaengine: Support for requesting channels preferring DMA domain
    controller

 .../devicetree/bindings/dma/dma-domain.yaml   | 59 +++++++++++++++++++
 drivers/dma/dmaengine.c                       | 17 ++++--
 drivers/dma/of-dma.c                          | 42 +++++++++++++
 include/linux/dmaengine.h                     |  9 ++-
 include/linux/of_dma.h                        |  7 +++
 5 files changed, 126 insertions(+), 8 deletions(-)
 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


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

* [RFC 1/3] dt-bindings: dma: Add documentation for DMA domains
  2019-09-06 14:17 [RFC 0/3] dmaengine: Support for DMA domain controllers Peter Ujfalusi
@ 2019-09-06 14:17 ` Peter Ujfalusi
  2019-09-06 14:17 ` [RFC 2/3] dmaengine: of_dma: Function to look up the DMA domain of a client Peter Ujfalusi
  2019-09-06 14:17 ` [RFC 3/3] dmaengine: Support for requesting channels preferring DMA domain controller Peter Ujfalusi
  2 siblings, 0 replies; 9+ messages in thread
From: Peter Ujfalusi @ 2019-09-06 14:17 UTC (permalink / raw)
  To: vinod.koul, robh+dt; +Cc: dmaengine, linux-kernel, dan.j.williams, devicetree

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

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


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

* [RFC 2/3] dmaengine: of_dma: Function to look up the DMA domain of a client
  2019-09-06 14:17 [RFC 0/3] dmaengine: Support for DMA domain controllers Peter Ujfalusi
  2019-09-06 14:17 ` [RFC 1/3] dt-bindings: dma: Add documentation for DMA domains Peter Ujfalusi
@ 2019-09-06 14:17 ` Peter Ujfalusi
  2019-09-06 14:17 ` [RFC 3/3] dmaengine: Support for requesting channels preferring DMA domain controller Peter Ujfalusi
  2 siblings, 0 replies; 9+ messages in thread
From: Peter Ujfalusi @ 2019-09-06 14:17 UTC (permalink / raw)
  To: vinod.koul, robh+dt; +Cc: dmaengine, linux-kernel, dan.j.williams, devicetree

Find the DMA domain controller of the client device by iterating up in
device tree looking for the closest 'dma-domain-controller' property.

If the client's node is not provided then check the DT root for the
controller.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/dma/of-dma.c   | 42 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/of_dma.h |  7 +++++++
 2 files changed, 49 insertions(+)

diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c
index c2d779daa4b5..04b5795cd76b 100644
--- a/drivers/dma/of-dma.c
+++ b/drivers/dma/of-dma.c
@@ -18,6 +18,48 @@
 static LIST_HEAD(of_dma_list);
 static DEFINE_MUTEX(of_dma_lock);
 
+/**
+ * of_find_dma_domain - Get the domain DMA controller
+ * @np:		device node of the client device
+ *
+ * Look up the DMA controller of the domain the client device is part of.
+ * Finds the dma-domain controller the client device belongs to. It is used when
+ * requesting non slave channels (like channel for memcpy) to make sure that the
+ * channel can be request from a DMA controller which can service the given
+ * domain best.
+ *
+ * Returns the device_node pointer of the DMA controller or succes or NULL on
+ * error.
+ */
+struct device_node *of_find_dma_domain(struct device_node *np)
+{
+	struct device_node *dma_domain = NULL;
+	phandle dma_phandle;
+
+	/*
+	 * If no device_node is provided look at the root level for system
+	 * default DMA controller for modules.
+	 */
+	if (!np)
+		np = of_root;
+
+	if (!np || !of_node_get(np))
+		return NULL;
+
+	do {
+		if (of_property_read_u32(np, "dma-domain-controller",
+					 &dma_phandle))
+			np = of_get_next_parent(np);
+		else {
+			dma_domain = of_find_node_by_phandle(dma_phandle);
+			of_node_put(np);
+		}
+	} while (!dma_domain && np);
+
+	return dma_domain;
+}
+EXPORT_SYMBOL_GPL(of_find_dma_domain);
+
 /**
  * of_dma_find_controller - Get a DMA controller in DT DMA helpers list
  * @dma_spec:	pointer to DMA specifier as found in the device tree
diff --git a/include/linux/of_dma.h b/include/linux/of_dma.h
index fd706cdf255c..6eab0a8d3335 100644
--- a/include/linux/of_dma.h
+++ b/include/linux/of_dma.h
@@ -32,6 +32,8 @@ struct of_dma_filter_info {
 };
 
 #ifdef CONFIG_DMA_OF
+extern struct device_node *of_find_dma_domain(struct device_node *np);
+
 extern int of_dma_controller_register(struct device_node *np,
 		struct dma_chan *(*of_dma_xlate)
 		(struct of_phandle_args *, struct of_dma *),
@@ -52,6 +54,11 @@ extern struct dma_chan *of_dma_xlate_by_chan_id(struct of_phandle_args *dma_spec
 		struct of_dma *ofdma);
 
 #else
+static inline struct device_node *of_find_dma_domain(struct device_node *np)
+{
+	return NULL;
+}
+
 static inline int of_dma_controller_register(struct device_node *np,
 		struct dma_chan *(*of_dma_xlate)
 		(struct of_phandle_args *, struct of_dma *),
-- 
Peter

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


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

* [RFC 3/3] dmaengine: Support for requesting channels preferring DMA domain controller
  2019-09-06 14:17 [RFC 0/3] dmaengine: Support for DMA domain controllers Peter Ujfalusi
  2019-09-06 14:17 ` [RFC 1/3] dt-bindings: dma: Add documentation for DMA domains Peter Ujfalusi
  2019-09-06 14:17 ` [RFC 2/3] dmaengine: of_dma: Function to look up the DMA domain of a client Peter Ujfalusi
@ 2019-09-06 14:17 ` Peter Ujfalusi
  2 siblings, 0 replies; 9+ messages in thread
From: Peter Ujfalusi @ 2019-09-06 14:17 UTC (permalink / raw)
  To: vinod.koul, robh+dt; +Cc: dmaengine, linux-kernel, dan.j.williams, devicetree

In case the channel is not requested via the slave API, use the
of_find_dma_domain() to see if a system default DMA controller is
specified.

Add new function which can be used by clients to request channels by mask
from their DMA domain controller if specified.

Client drivers can take advantage of the domain support by moving from
dma_request_chan_by_mask() to dma_domain_request_chan_by_mask()

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/dma/dmaengine.c   | 17 ++++++++++++-----
 include/linux/dmaengine.h |  9 ++++++---
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 6baddf7dcbfd..087450eed68c 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -640,6 +640,10 @@ struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
 	struct dma_device *device, *_d;
 	struct dma_chan *chan = NULL;
 
+	/* If np is not specified, get the default DMA domain controller */
+	if (!np)
+		np = of_find_dma_domain(NULL);
+
 	/* Find a channel */
 	mutex_lock(&dma_list_mutex);
 	list_for_each_entry_safe(device, _d, &dma_device_list, global_node) {
@@ -751,19 +755,22 @@ struct dma_chan *dma_request_slave_channel(struct device *dev,
 EXPORT_SYMBOL_GPL(dma_request_slave_channel);
 
 /**
- * dma_request_chan_by_mask - allocate a channel satisfying certain capabilities
- * @mask: capabilities that the channel must satisfy
+ * dma_domain_request_chan_by_mask - allocate a channel by mask from DMA domain
+ * @dev:	pointer to client device structure
+ * @mask:	capabilities that the channel must satisfy
  *
  * Returns pointer to appropriate DMA channel on success or an error pointer.
  */
-struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask)
+struct dma_chan *dma_domain_request_chan_by_mask(struct device *dev,
+						 const dma_cap_mask_t *mask)
 {
 	struct dma_chan *chan;
 
 	if (!mask)
 		return ERR_PTR(-ENODEV);
 
-	chan = __dma_request_channel(mask, NULL, NULL, NULL);
+	chan = __dma_request_channel(mask, NULL, NULL,
+				     of_find_dma_domain(dev->of_node));
 	if (!chan) {
 		mutex_lock(&dma_list_mutex);
 		if (list_empty(&dma_device_list))
@@ -775,7 +782,7 @@ struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask)
 
 	return chan;
 }
-EXPORT_SYMBOL_GPL(dma_request_chan_by_mask);
+EXPORT_SYMBOL_GPL(dma_domain_request_chan_by_mask);
 
 void dma_release_channel(struct dma_chan *chan)
 {
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 3b2e8e302f6c..9f94df81e83f 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -1438,7 +1438,8 @@ struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
 struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name);
 
 struct dma_chan *dma_request_chan(struct device *dev, const char *name);
-struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask);
+struct dma_chan *dma_domain_request_chan_by_mask(struct device *dev,
+						 const dma_cap_mask_t *mask);
 
 void dma_release_channel(struct dma_chan *chan);
 int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps);
@@ -1475,8 +1476,8 @@ static inline struct dma_chan *dma_request_chan(struct device *dev,
 {
 	return ERR_PTR(-ENODEV);
 }
-static inline struct dma_chan *dma_request_chan_by_mask(
-						const dma_cap_mask_t *mask)
+static inline struct dma_chan *dma_domain_request_chan_by_mask(struct device *dev,
+			const dma_cap_mask_t *mask)
 {
 	return ERR_PTR(-ENODEV);
 }
@@ -1537,6 +1538,8 @@ struct dma_chan *dma_get_any_slave_channel(struct dma_device *device);
 	__dma_request_channel(&(mask), x, y, NULL)
 #define dma_request_slave_channel_compat(mask, x, y, dev, name) \
 	__dma_request_slave_channel_compat(&(mask), x, y, dev, name)
+#define dma_request_chan_by_mask(mask) \
+	dma_domain_request_chan_by_mask(NULL, mask)
 
 static inline struct dma_chan
 *__dma_request_slave_channel_compat(const dma_cap_mask_t *mask,
-- 
Peter

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


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

* Re: [RFC 3/3] dmaengine: Support for requesting channels preferring DMA domain controller
  2019-09-09  5:56     ` Peter Ujfalusi
@ 2019-09-12 16:49       ` Vinod Koul
  0 siblings, 0 replies; 9+ messages in thread
From: Vinod Koul @ 2019-09-12 16:49 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: robh+dt, dmaengine, linux-kernel, dan.j.williams, devicetree

On 09-09-19, 08:56, Peter Ujfalusi wrote:

> >> -struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask)
> >> +struct dma_chan *dma_domain_request_chan_by_mask(struct device *dev,
> >> +						 const dma_cap_mask_t *mask)
> > 
> > should we really use dma_request_chan_by_mask() why not create a new api
> > dma_request_chan_by_domain() and use that, it falls back to
> > dma_request_chan_by_mask() if it doesnt find a valid domain!
> 
> So:
> struct dma_chan *dma_request_chan_by_domain(struct device *dev,
> 					    const dma_cap_mask_t *mask);

Yeah that looks better to me :)

-- 
~Vinod

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

* Re: [RFC 3/3] dmaengine: Support for requesting channels preferring DMA domain controller
  2019-09-08 12:15   ` Vinod Koul
@ 2019-09-09  5:56     ` Peter Ujfalusi
  2019-09-12 16:49       ` Vinod Koul
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Ujfalusi @ 2019-09-09  5:56 UTC (permalink / raw)
  To: Vinod Koul; +Cc: robh+dt, dmaengine, linux-kernel, dan.j.williams, devicetree



On 08/09/2019 15.15, Vinod Koul wrote:
> On 06-09-19, 17:18, Peter Ujfalusi wrote:
>> In case the channel is not requested via the slave API, use the
>> of_find_dma_domain() to see if a system default DMA controller is
>> specified.
>>
>> Add new function which can be used by clients to request channels by mask
>> from their DMA domain controller if specified.
>>
>> Client drivers can take advantage of the domain support by moving from
>> dma_request_chan_by_mask() to dma_domain_request_chan_by_mask()
>>
>> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
>> ---
>>  drivers/dma/dmaengine.c   | 17 ++++++++++++-----
>>  include/linux/dmaengine.h |  9 ++++++---
>>  2 files changed, 18 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
>> index 6baddf7dcbfd..087450eed68c 100644
>> --- a/drivers/dma/dmaengine.c
>> +++ b/drivers/dma/dmaengine.c
>> @@ -640,6 +640,10 @@ struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
>>  	struct dma_device *device, *_d;
>>  	struct dma_chan *chan = NULL;
>>  
>> +	/* If np is not specified, get the default DMA domain controller */
>> +	if (!np)
>> +		np = of_find_dma_domain(NULL);
>> +
>>  	/* Find a channel */
>>  	mutex_lock(&dma_list_mutex);
>>  	list_for_each_entry_safe(device, _d, &dma_device_list, global_node) {
>> @@ -751,19 +755,22 @@ struct dma_chan *dma_request_slave_channel(struct device *dev,
>>  EXPORT_SYMBOL_GPL(dma_request_slave_channel);
>>  
>>  /**
>> - * dma_request_chan_by_mask - allocate a channel satisfying certain capabilities
>> - * @mask: capabilities that the channel must satisfy
>> + * dma_domain_request_chan_by_mask - allocate a channel by mask from DMA domain
>> + * @dev:	pointer to client device structure
>> + * @mask:	capabilities that the channel must satisfy
>>   *
>>   * Returns pointer to appropriate DMA channel on success or an error pointer.
>>   */
>> -struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask)
>> +struct dma_chan *dma_domain_request_chan_by_mask(struct device *dev,
>> +						 const dma_cap_mask_t *mask)
> 
> should we really use dma_request_chan_by_mask() why not create a new api
> dma_request_chan_by_domain() and use that, it falls back to
> dma_request_chan_by_mask() if it doesnt find a valid domain!

So:
struct dma_chan *dma_request_chan_by_domain(struct device *dev,
					    const dma_cap_mask_t *mask);

?

- Péter

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

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

* Re: [RFC 3/3] dmaengine: Support for requesting channels preferring DMA domain controller
  2019-09-06 14:18 ` [RFC 3/3] dmaengine: Support for requesting channels preferring DMA domain controller Peter Ujfalusi
  2019-09-08  7:46   ` Peter Ujfalusi
@ 2019-09-08 12:15   ` Vinod Koul
  2019-09-09  5:56     ` Peter Ujfalusi
  1 sibling, 1 reply; 9+ messages in thread
From: Vinod Koul @ 2019-09-08 12:15 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: robh+dt, dmaengine, linux-kernel, dan.j.williams, devicetree

On 06-09-19, 17:18, Peter Ujfalusi wrote:
> In case the channel is not requested via the slave API, use the
> of_find_dma_domain() to see if a system default DMA controller is
> specified.
> 
> Add new function which can be used by clients to request channels by mask
> from their DMA domain controller if specified.
> 
> Client drivers can take advantage of the domain support by moving from
> dma_request_chan_by_mask() to dma_domain_request_chan_by_mask()
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---
>  drivers/dma/dmaengine.c   | 17 ++++++++++++-----
>  include/linux/dmaengine.h |  9 ++++++---
>  2 files changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> index 6baddf7dcbfd..087450eed68c 100644
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
> @@ -640,6 +640,10 @@ struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
>  	struct dma_device *device, *_d;
>  	struct dma_chan *chan = NULL;
>  
> +	/* If np is not specified, get the default DMA domain controller */
> +	if (!np)
> +		np = of_find_dma_domain(NULL);
> +
>  	/* Find a channel */
>  	mutex_lock(&dma_list_mutex);
>  	list_for_each_entry_safe(device, _d, &dma_device_list, global_node) {
> @@ -751,19 +755,22 @@ struct dma_chan *dma_request_slave_channel(struct device *dev,
>  EXPORT_SYMBOL_GPL(dma_request_slave_channel);
>  
>  /**
> - * dma_request_chan_by_mask - allocate a channel satisfying certain capabilities
> - * @mask: capabilities that the channel must satisfy
> + * dma_domain_request_chan_by_mask - allocate a channel by mask from DMA domain
> + * @dev:	pointer to client device structure
> + * @mask:	capabilities that the channel must satisfy
>   *
>   * Returns pointer to appropriate DMA channel on success or an error pointer.
>   */
> -struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask)
> +struct dma_chan *dma_domain_request_chan_by_mask(struct device *dev,
> +						 const dma_cap_mask_t *mask)

should we really use dma_request_chan_by_mask() why not create a new api
dma_request_chan_by_domain() and use that, it falls back to
dma_request_chan_by_mask() if it doesnt find a valid domain!

-- 
~Vinod

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

* Re: [RFC 3/3] dmaengine: Support for requesting channels preferring DMA domain controller
  2019-09-06 14:18 ` [RFC 3/3] dmaengine: Support for requesting channels preferring DMA domain controller Peter Ujfalusi
@ 2019-09-08  7:46   ` Peter Ujfalusi
  2019-09-08 12:15   ` Vinod Koul
  1 sibling, 0 replies; 9+ messages in thread
From: Peter Ujfalusi @ 2019-09-08  7:46 UTC (permalink / raw)
  To: vkoul, robh+dt; +Cc: dmaengine, linux-kernel, dan.j.williams, devicetree



On 06/09/2019 17.18, Peter Ujfalusi wrote:
> In case the channel is not requested via the slave API, use the
> of_find_dma_domain() to see if a system default DMA controller is
> specified.
> 
> Add new function which can be used by clients to request channels by mask
> from their DMA domain controller if specified.
> 
> Client drivers can take advantage of the domain support by moving from
> dma_request_chan_by_mask() to dma_domain_request_chan_by_mask()
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---
>  drivers/dma/dmaengine.c   | 17 ++++++++++++-----
>  include/linux/dmaengine.h |  9 ++++++---
>  2 files changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> index 6baddf7dcbfd..087450eed68c 100644
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
> @@ -640,6 +640,10 @@ struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
>  	struct dma_device *device, *_d;
>  	struct dma_chan *chan = NULL;
>  
> +	/* If np is not specified, get the default DMA domain controller */
> +	if (!np)
> +		np = of_find_dma_domain(NULL);
> +
>  	/* Find a channel */
>  	mutex_lock(&dma_list_mutex);
>  	list_for_each_entry_safe(device, _d, &dma_device_list, global_node) {
> @@ -751,19 +755,22 @@ struct dma_chan *dma_request_slave_channel(struct device *dev,
>  EXPORT_SYMBOL_GPL(dma_request_slave_channel);
>  
>  /**
> - * dma_request_chan_by_mask - allocate a channel satisfying certain capabilities
> - * @mask: capabilities that the channel must satisfy
> + * dma_domain_request_chan_by_mask - allocate a channel by mask from DMA domain
> + * @dev:	pointer to client device structure
> + * @mask:	capabilities that the channel must satisfy
>   *
>   * Returns pointer to appropriate DMA channel on success or an error pointer.
>   */
> -struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask)
> +struct dma_chan *dma_domain_request_chan_by_mask(struct device *dev,
> +						 const dma_cap_mask_t *mask)
>  {
>  	struct dma_chan *chan;
>  
>  	if (!mask)
>  		return ERR_PTR(-ENODEV);
>  
> -	chan = __dma_request_channel(mask, NULL, NULL, NULL);

if (dev)
> +	chan = __dma_request_channel(mask, NULL, NULL,
> +				     of_find_dma_domain(dev->of_node));else
	chan = __dma_request_channel(mask, NULL, NULL, NULL);

>  	if (!chan) {
>  		mutex_lock(&dma_list_mutex);
>  		if (list_empty(&dma_device_list))
> @@ -775,7 +782,7 @@ struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask)
>  
>  	return chan;
>  }
> -EXPORT_SYMBOL_GPL(dma_request_chan_by_mask);
> +EXPORT_SYMBOL_GPL(dma_domain_request_chan_by_mask);
>  
>  void dma_release_channel(struct dma_chan *chan)
>  {
> diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
> index 3b2e8e302f6c..9f94df81e83f 100644
> --- a/include/linux/dmaengine.h
> +++ b/include/linux/dmaengine.h
> @@ -1438,7 +1438,8 @@ struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
>  struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name);
>  
>  struct dma_chan *dma_request_chan(struct device *dev, const char *name);
> -struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask);
> +struct dma_chan *dma_domain_request_chan_by_mask(struct device *dev,
> +						 const dma_cap_mask_t *mask);
>  
>  void dma_release_channel(struct dma_chan *chan);
>  int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps);
> @@ -1475,8 +1476,8 @@ static inline struct dma_chan *dma_request_chan(struct device *dev,
>  {
>  	return ERR_PTR(-ENODEV);
>  }
> -static inline struct dma_chan *dma_request_chan_by_mask(
> -						const dma_cap_mask_t *mask)
> +static inline struct dma_chan *dma_domain_request_chan_by_mask(struct device *dev,
> +			const dma_cap_mask_t *mask)
>  {
>  	return ERR_PTR(-ENODEV);
>  }
> @@ -1537,6 +1538,8 @@ struct dma_chan *dma_get_any_slave_channel(struct dma_device *device);
>  	__dma_request_channel(&(mask), x, y, NULL)
>  #define dma_request_slave_channel_compat(mask, x, y, dev, name) \
>  	__dma_request_slave_channel_compat(&(mask), x, y, dev, name)
> +#define dma_request_chan_by_mask(mask) \
> +	dma_domain_request_chan_by_mask(NULL, mask)
>  
>  static inline struct dma_chan
>  *__dma_request_slave_channel_compat(const dma_cap_mask_t *mask,
> 

- Péter

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

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

* [RFC 3/3] dmaengine: Support for requesting channels preferring DMA domain controller
  2019-09-06 14:18 [RFC 0/3] dmaengine: Support for DMA domain controllers Peter Ujfalusi
@ 2019-09-06 14:18 ` Peter Ujfalusi
  2019-09-08  7:46   ` Peter Ujfalusi
  2019-09-08 12:15   ` Vinod Koul
  0 siblings, 2 replies; 9+ messages in thread
From: Peter Ujfalusi @ 2019-09-06 14:18 UTC (permalink / raw)
  To: vkoul, robh+dt; +Cc: dmaengine, linux-kernel, dan.j.williams, devicetree

In case the channel is not requested via the slave API, use the
of_find_dma_domain() to see if a system default DMA controller is
specified.

Add new function which can be used by clients to request channels by mask
from their DMA domain controller if specified.

Client drivers can take advantage of the domain support by moving from
dma_request_chan_by_mask() to dma_domain_request_chan_by_mask()

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/dma/dmaengine.c   | 17 ++++++++++++-----
 include/linux/dmaengine.h |  9 ++++++---
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 6baddf7dcbfd..087450eed68c 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -640,6 +640,10 @@ struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
 	struct dma_device *device, *_d;
 	struct dma_chan *chan = NULL;
 
+	/* If np is not specified, get the default DMA domain controller */
+	if (!np)
+		np = of_find_dma_domain(NULL);
+
 	/* Find a channel */
 	mutex_lock(&dma_list_mutex);
 	list_for_each_entry_safe(device, _d, &dma_device_list, global_node) {
@@ -751,19 +755,22 @@ struct dma_chan *dma_request_slave_channel(struct device *dev,
 EXPORT_SYMBOL_GPL(dma_request_slave_channel);
 
 /**
- * dma_request_chan_by_mask - allocate a channel satisfying certain capabilities
- * @mask: capabilities that the channel must satisfy
+ * dma_domain_request_chan_by_mask - allocate a channel by mask from DMA domain
+ * @dev:	pointer to client device structure
+ * @mask:	capabilities that the channel must satisfy
  *
  * Returns pointer to appropriate DMA channel on success or an error pointer.
  */
-struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask)
+struct dma_chan *dma_domain_request_chan_by_mask(struct device *dev,
+						 const dma_cap_mask_t *mask)
 {
 	struct dma_chan *chan;
 
 	if (!mask)
 		return ERR_PTR(-ENODEV);
 
-	chan = __dma_request_channel(mask, NULL, NULL, NULL);
+	chan = __dma_request_channel(mask, NULL, NULL,
+				     of_find_dma_domain(dev->of_node));
 	if (!chan) {
 		mutex_lock(&dma_list_mutex);
 		if (list_empty(&dma_device_list))
@@ -775,7 +782,7 @@ struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask)
 
 	return chan;
 }
-EXPORT_SYMBOL_GPL(dma_request_chan_by_mask);
+EXPORT_SYMBOL_GPL(dma_domain_request_chan_by_mask);
 
 void dma_release_channel(struct dma_chan *chan)
 {
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 3b2e8e302f6c..9f94df81e83f 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -1438,7 +1438,8 @@ struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
 struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name);
 
 struct dma_chan *dma_request_chan(struct device *dev, const char *name);
-struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask);
+struct dma_chan *dma_domain_request_chan_by_mask(struct device *dev,
+						 const dma_cap_mask_t *mask);
 
 void dma_release_channel(struct dma_chan *chan);
 int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps);
@@ -1475,8 +1476,8 @@ static inline struct dma_chan *dma_request_chan(struct device *dev,
 {
 	return ERR_PTR(-ENODEV);
 }
-static inline struct dma_chan *dma_request_chan_by_mask(
-						const dma_cap_mask_t *mask)
+static inline struct dma_chan *dma_domain_request_chan_by_mask(struct device *dev,
+			const dma_cap_mask_t *mask)
 {
 	return ERR_PTR(-ENODEV);
 }
@@ -1537,6 +1538,8 @@ struct dma_chan *dma_get_any_slave_channel(struct dma_device *device);
 	__dma_request_channel(&(mask), x, y, NULL)
 #define dma_request_slave_channel_compat(mask, x, y, dev, name) \
 	__dma_request_slave_channel_compat(&(mask), x, y, dev, name)
+#define dma_request_chan_by_mask(mask) \
+	dma_domain_request_chan_by_mask(NULL, mask)
 
 static inline struct dma_chan
 *__dma_request_slave_channel_compat(const dma_cap_mask_t *mask,
-- 
Peter

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


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

end of thread, other threads:[~2019-09-12 16:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-06 14:17 [RFC 0/3] dmaengine: Support for DMA domain controllers Peter Ujfalusi
2019-09-06 14:17 ` [RFC 1/3] dt-bindings: dma: Add documentation for DMA domains Peter Ujfalusi
2019-09-06 14:17 ` [RFC 2/3] dmaengine: of_dma: Function to look up the DMA domain of a client Peter Ujfalusi
2019-09-06 14:17 ` [RFC 3/3] dmaengine: Support for requesting channels preferring DMA domain controller Peter Ujfalusi
2019-09-06 14:18 [RFC 0/3] dmaengine: Support for DMA domain controllers Peter Ujfalusi
2019-09-06 14:18 ` [RFC 3/3] dmaengine: Support for requesting channels preferring DMA domain controller Peter Ujfalusi
2019-09-08  7:46   ` Peter Ujfalusi
2019-09-08 12:15   ` Vinod Koul
2019-09-09  5:56     ` Peter Ujfalusi
2019-09-12 16:49       ` Vinod Koul

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