dma: imx-dma: Add oftree support
Subsystems (3)
PATCH 1/1 dma: imx-dma: Add oftree support
Adding devicetree support for imx-dma driver. Use driver name for function 'imx_dma_is_general_purpose' because the devicename for devicetree initialized devices is different.
--- .../devicetree/bindings/dma/fsl-imx-dma.txt | 13 ++++++++++++ drivers/dma/imx-dma.c | 23 ++++++++++++++++++++++ include/linux/platform_data/dma-imx.h | 3 ++- 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/dma/fsl-imx-dma.txt
Documentation/devicetree/bindings/dma/fsl-imx-dma.txt new file +13 -0
@@ -0,0 +1,13 @@ +* Freescale Direct Memory Access (DMA) Controller for i.MX + +Required properties: +- compatible : Should be "fsl,<chip>-dma". chip can be imx1, imx21 or imx27 +- reg : Should contain DMA registers location and length +- interrupts : First item should be DMA interrupt, second one is optional and + should contain DMA Error interrupt + +dma: dma at 10001000 { + compatible = "fsl,imx27-dma"; + reg = <0x10001000 0x1000>; + interrupts = <32 33>; +};
drivers/dma/imx-dma.c +23 -0
@@ -26,6 +26,7 @@#include <linux/clk.h> #include <linux/dmaengine.h> #include <linux/module.h> +#include <linux/of_device.h> #include <asm/irq.h> #include <linux/platform_data/dma-imx.h>
@@ -201,6 +202,22 @@ static struct platform_device_id imx_dma_devtype[] = { };MODULE_DEVICE_TABLE (platform, imx_dma_devtype); +static const struct of_device_id imx_dma_of_dev_id[] = { + { + .compatible ="fsl,imx1-dma" , + .data = &imx_dma_devtype[IMX1_DMA ], + }, { + .compatible ="fsl,imx21-dma" , + .data = &imx_dma_devtype[IMX21_DMA ], + }, { + .compatible ="fsl,imx27-dma" , + .data = &imx_dma_devtype[IMX27_DMA ], + }, { +/* sentinel */ + } +}; +MODULE_DEVICE_TABLE (of, imx_dma_of_dev_id); +static inline int is_imx1_dma (struct imxdma_engine *imxdma) {return imxdma->devtype ==IMX1_DMA ;
@@ -1000,9 +1017,14 @@ static int __init imxdma_probe(struct platform_device *pdev) {struct imxdma_engine *imxdma;struct resource *res; +const struct of_device_id *of_id;int ret, i;int irq, irq_err; + of_id =of_match_device (imx_dma_of_dev_id, &pdev->dev); +if (of_id) + pdev->id_entry = of_id->data; + imxdma =devm_kzalloc (&pdev->dev,sizeof (*imxdma),GFP_KERNEL );if (!imxdma)return -ENOMEM ;
@@ -1159,6 +1181,7 @@ static int __exit imxdma_remove(struct platform_device *pdev)static struct platform_driver imxdma_driver = { .driver = { .name ="imx-dma" , + .of_match_table = imx_dma_of_dev_id, }, .id_table = imx_dma_devtype, .remove =__exit_p (imxdma_remove),
include/linux/platform_data/dma-imx.h +2 -1
@@ -63,7 +63,8 @@ static inline int imx_dma_is_general_purpose(struct dma_chan *chan)return strstr (dev_name (chan->device->dev),"sdma" ) || !strcmp (dev_name (chan->device->dev),"imx1-dma" ) || !strcmp (dev_name (chan->device->dev),"imx21-dma" ) || - !strcmp(dev_name(chan->device->dev), "imx27-dma"); + !strcmp (dev_name (chan->device->dev),"imx27-dma" ) || + !strcmp(chan->device->dev->driver->name, "imx-dma"); }#endif
Signature · 1 line
1.8.1.2
PATCH 1/1 dma: imx-dma: Add oftree support
Quoted 5 lines · Markus Pargmann
Adding devicetree support for imx-dma driver. Use driver name for function '
imx_dma_is_general_purpose' because the devicename for devicetree initialized devices is different.Signed-off-by Markus Pargmann <[email protected]>
Hi Markus,
Please make sure you are following the generic dma binding from Documentation/devicetree/bindings/dma/dma.txt that is getting added in Linux-3.9.
Quoted 5 lines
+++
b/Documentation/devicetree/bindings/dma/fsl-imx-dma.txtDocumentation/devicetree/bindings/dma/fsl-imx-dma.txt new file +3
-0@@ -0,0 +1,13 @@ +* Freescale Direct Memory Access (DMA) Controller for i.MX + +Required properties:
Documentation/devicetree/bindings/dma/fsl-imx-dma.txt line 13
Quoted 10 lines
Documentation/devicetree/bindings/dma/fsl-imx-dma.txt new file +10
-0+- compatible : Should be "fsl,<chip>-dma". chip can be imx1, imx21 or imx27 +- reg : Should contain DMA registers location and length +- interrupts : First item should be DMA interrupt, second one is optional and + should contain DMA Error interrupt + +dma: dma at 10001000 { + compatible = "fsl,imx27-dma"; + reg = <0x10001000 0x1000>; + interrupts = <32 33>; +};
In particular, the "#dma-cells" property is required here, along with dma-channels and dma-requests. You also need to describe the format of the "dmas" property in slave drivers referring to this node. In a lot of cases, you only need a single cell there, which is the request line number.
Arnd
PATCH 1/1 dma: imx-dma: Add oftree support
Hi Arnd,
Quoted 35 lines · Arnd Bergmann
Quoted 5 lines · Markus Pargmann
Adding devicetree support for imx-dma driver. Use driver name for function '
imx_dma_is_general_purpose' because the devicename for devicetree initialized devices is different.Signed-off-by Markus Pargmann <[email protected]>Hi Markus,
Please make sure you are following the generic dma binding from
Documentation/devicetree/bindings/dma/dma.txtthat is getting added in Linux-3.9.Quoted 5 lines
+++
b/Documentation/devicetree/bindings/dma/fsl-imx-dma.txtDocumentation/devicetree/bindings/dma/fsl-imx-dma.txt new file +3
-0@@ -0,0 +1,13 @@ +* Freescale Direct Memory Access (DMA) Controller for i.MX + +Required properties:Documentation/devicetree/bindings/dma/fsl-imx-dma.txt line 13
Quoted 10 lines
Documentation/devicetree/bindings/dma/fsl-imx-dma.txt new file +10
-0+- compatible : Should be "fsl,<chip>-dma". chip can be imx1, imx21 or imx27 +- reg : Should contain DMA registers location and length +- interrupts : First item should be DMA interrupt, second one is optional and + should contain DMA Error interrupt + +dma: dma at 10001000 { + compatible = "fsl,imx27-dma"; + reg = <0x10001000 0x1000>; + interrupts = <32 33>; +};In particular, the "#dma-cells" property is required here, along with dma-channels and dma-requests. You also need to describe the format of the "dmas" property in slave drivers referring to this node. In a lot of cases, you only need a single cell there, which is the request line number.
Quoted 1 line
Arnd
Thanks, I changed the patch to use the generic DMA bindings, see V2. However I couldn't find any information about the number of supported DMA requests.
Markus
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH v2 1/1 dma: imx-dma: Add oftree support
In reply to Markus PargmannAdding devicetree support for imx-dma driver. Use driver name for function 'imx_dma_is_general_purpose' because the devicename for devicetree initialized devices is different.
Changes in V2:
- Change the driver to use generic DMA DT bindings.
- Add a imx-dma filter function that sets the dma request line in private data.
--- .../devicetree/bindings/dma/fsl-imx-dma.txt | 48 ++++++++++++++++ drivers/dma/imx-dma.c | 64 +++++++++++++++++++++- include/linux/platform_data/dma-imx.h | 6 +- 3 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/dma/fsl-imx-dma.txt
Documentation/devicetree/bindings/dma/fsl-imx-dma.txt new file +48 -0
@@ -0,0 +1,48 @@ +* Freescale Direct Memory Access (DMA) Controller for i.MX + +This document will only describe differences to the generic DMA Controller and +DMA request bindings. + +* DMA controller + +Required properties: +- compatible : Should be "fsl,<chip>-dma". chip can be imx1, imx21 or imx27 +- reg : Should contain DMA registers location and length +- interrupts : First item should be DMA interrupt, second one is optional and + should contain DMA Error interrupt +- #dma-cells : Has to be 1. imx-dma does not support anything else. + +Optional properties: +- #dma-channels : Number of DMA channels supported. Should be 16. +- #dma-requests : Number of DMA requests supported. + +Example: + + dma: dma at 10001000 { + compatible = "fsl,imx27-dma"; + reg = <0x10001000 0x1000>; + interrupts = <32 33>; + #dma-cells = <1>; + #dma-channels = <16>; + }; + + +* DMA client + +Clients have to specify the DMA requests with phandles in a list. + +Required properties: +- dmas: List of one or more DMA request specifiers. One DMA request specifier + consists of a phandle to the DMA controller followed by the integer + specifiying the request line. +- dma-names: List of string identifiers for the DMA requests. For the correct + names, have a look at the specific client driver. + +Example: + + sdhci1: sdhci at 10013000 { + ... + dmas = <&dma 7>; + dma-names = "rx-tx"; + ... + };
drivers/dma/imx-dma.c +63 -1
122 lines not on this page · raw message
include/linux/platform_data/dma-imx.h +5 -1
@@ -51,6 +51,9 @@ struct imx_dma_data {int dma_request;/* DMA request line */ enum sdma_peripheral_type peripheral_type;int priority; + +/* Did the controller's filter function allocated this object? */ +bool alloc_ctl_filter; };static inline int imx_dma_is_ipu (struct dma_chan *chan)
@@ -63,7 +66,8 @@ static inline int imx_dma_is_general_purpose(struct dma_chan *chan)return strstr (dev_name (chan->device->dev),"sdma" ) || !strcmp (dev_name (chan->device->dev),"imx1-dma" ) || !strcmp (dev_name (chan->device->dev),"imx21-dma" ) || - !strcmp(dev_name(chan->device->dev), "imx27-dma"); + !strcmp (dev_name (chan->device->dev),"imx27-dma" ) || + !strcmp(chan->device->dev->driver->name, "imx-dma"); }#endif
Signature · 1 line
1.8.1.2
PATCH v2 1/1 dma: imx-dma: Add oftree support
Documentation/devicetree/bindings/dma/fsl-imx-dma.txt line 13
Quoted 6 lines · Markus Pargmann
Documentation/devicetree/bindings/dma/fsl-imx-dma.txt new file +6
-0+Required properties: +- compatible : Should be "fsl,<chip>-dma". chip can be imx1, imx21 or imx27 +- reg : Should contain DMA registers location and length +- interrupts : First item should be DMA interrupt, second one is optional and + should contain DMA Error interrupt +- #dma-cells : Has to be 1. imx-dma does not support anything else.
Hmm, so #dma-cells is 1
Quoted 8 lines
drivers/dma/imx-dma.c +4
-0@@ -996,13 +1020,33 @@ static void imxdma_issue_pending(struct dma_chan *chan)spin_unlock_irqrestore (&imxdma->lock, flags); } +bool imxdma_filter_fn (struct dma_chan *chan,void *param) +{ +struct imx_dma_data *data =kzalloc (sizeof (*data),GFP_KERNEL ); +printk ("%s\n" , __func__);
drivers/dma/imx-dma.c static void imxdma_issue_pending(struct dma_chan *chan) · line 1036
Quoted 10 lines
drivers/dma/imx-dma.c +10
-0+ +if (!data) +return false; + + data->dma_request = *(unsigned *) param; + data->alloc_ctl_filter = true; + chan->private = data; + +return true; +}
which matches the usage here, but
include/linux/platform_data/dma-imx.h struct imx_dma_data { · line 57
Quoted 12 lines
include/linux/platform_data/dma-imx.h +3
-0@@ -51,6 +51,9 @@ struct imx_dma_data {int dma_request;/* DMA request line */ enum sdma_peripheral_type peripheral_type;int priority; + +/* Did the controller's filter function allocated this object? */ +bool alloc_ctl_filter; };
There are actually two more members in the imx_dma_data structure. Shouldn't those be encoded in the dma specifier as well?
include/linux/platform_data/dma-imx.h static inline int imx_dma_is_general_purpose(struct dma_chan *chan) · line 71
Quoted 9 lines
include/linux/platform_data/dma-imx.h +2
-1static inline int imx_dma_is_ipu (struct dma_chan *chan)@@ -63,7 +66,8 @@ static inline int imx_dma_is_general_purpose(struct dma_chan *chan)return strstr (dev_name (chan->device->dev),"sdma" ) || !strcmp (dev_name (chan->device->dev),"imx1-dma" ) || !strcmp (dev_name (chan->device->dev),"imx21-dma" ) || - !strcmp (dev_name (chan->device->dev),"imx27-dma" ); + !strcmp (dev_name (chan->device->dev),"imx27-dma" ) || + !strcmp (chan->device->dev->driver->name,"imx-dma" ); }
Also, your filter function does not actually check imx_dma_is_general_purpose() as the old style filter functions in the slave drivers do, which breaks when you have more than one dma engine in the system.
I think you have to provide your own xlate function, and pass the controller and multiple cells into the filter function, or use no filter at all but instead find a way to get a channel directly.
Arnd
PATCH v2 1/1 dma: imx-dma: Add oftree support
Quoted 32 lines · Arnd Bergmann
Documentation/devicetree/bindings/dma/fsl-imx-dma.txt line 13
Quoted 6 lines · Markus Pargmann
Documentation/devicetree/bindings/dma/fsl-imx-dma.txt new file +6
-0+Required properties: +- compatible : Should be "fsl,<chip>-dma". chip can be imx1, imx21 or imx27 +- reg : Should contain DMA registers location and length +- interrupts : First item should be DMA interrupt, second one is optional and + should contain DMA Error interrupt +- #dma-cells : Has to be 1. imx-dma does not support anything else.Hmm, so #dma-cells is 1
Quoted 8 lines
drivers/dma/imx-dma.c +4
-0@@ -996,13 +1020,33 @@ static void imxdma_issue_pending(struct dma_chan *chan)spin_unlock_irqrestore (&imxdma->lock, flags); } +bool imxdma_filter_fn (struct dma_chan *chan,void *param) +{ +struct imx_dma_data *data =kzalloc (sizeof (*data),GFP_KERNEL ); +printk ("%s\n" , __func__);drivers/dma/imx-dma.c static void imxdma_issue_pending(struct dma_chan *chan) · line 1036
Quoted 10 lines
drivers/dma/imx-dma.c +10
-0+ +if (!data) +return false; + + data->dma_request = *(unsigned *) param; + data->alloc_ctl_filter = true; + chan->private = data; + +return true; +}which matches the usage here, but
Quoted 15 lines
include/linux/platform_data/dma-imx.h struct imx_dma_data { · line 57
Quoted 12 lines
include/linux/platform_data/dma-imx.h +3
-0@@ -51,6 +51,9 @@ struct imx_dma_data {int dma_request;/* DMA request line */ enum sdma_peripheral_type peripheral_type;int priority; + +/* Did the controller's filter function allocated this object? */ +bool alloc_ctl_filter; };There are actually two more members in the
imx_dma_datastructure. Shouldn't those be encoded in the dma specifier as well?
imx_dma_data is used by imx-dma and imx-sdma, but imx-dma does not use peripheral_type and priority. When not loaded from devicetree imx_dma_data is constructed by imx drivers without knowledge about the dma driver. This patch moves the initialization to the driver, so I think there is no need to fill all fields. I didn't want to use a new struct because the imx drivers could still use this old way.
Quoted 15 lines
include/linux/platform_data/dma-imx.h static inline int imx_dma_is_general_purpose(struct dma_chan *chan) · line 71
Quoted 10 lines
include/linux/platform_data/dma-imx.h +2
-1static inline int imx_dma_is_ipu (struct dma_chan *chan)@@ -63,7 +66,8 @@ static inline int imx_dma_is_general_purpose(struct dma_chan *chan)return strstr (dev_name (chan->device->dev),"sdma" ) || !strcmp (dev_name (chan->device->dev),"imx1-dma" ) || !strcmp (dev_name (chan->device->dev),"imx21-dma" ) || - !strcmp (dev_name (chan->device->dev),"imx27-dma" ); + !strcmp (dev_name (chan->device->dev),"imx27-dma" ) || + !strcmp (chan->device->dev->driver->name,"imx-dma" ); }Also, your filter function does not actually check
imx_dma_is_general_purpose()as the old style filter functions in the slave drivers do, which breaks when you have more than one dma engine in the system.
Oh yes, in the filter function should be a device driver comparison. But I would prefer a direct check instead of imx_dma_is_general_purpose because I think the driver should not define a filter function that initializes data for another driver (sdma).
Thanks
Markus
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH v2 1/1 dma: imx-dma: Add oftree support
Quoted 7 lines · Markus Pargmann
Quoted 5 lines · Arnd Bergmann
On Saturday 23 February 2013, Markus Pargmann wrote:
There are actually two more members in the
imx_dma_datastructure. Shouldn't those be encoded in the dma specifier as well?
Quoted 6 lines
imx_dma_datais used by imx-dma and imx-sdma, but imx-dma does not useperipheral_typeand priority. When not loaded from devicetreeimx_dma_datais constructed by imx drivers without knowledge about the dma driver. This patch moves the initialization to the driver, so I think there is no need to fill all fields. I didn't want to use a new struct because the imx drivers could still use this old way.
Ok, got it.
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
static inline int
imx_dma_is_ipu(struct dma_chan *chan)include/linux/platform_data/dma-imx.h +0
-1@@ -63,7 +66,8 @@ static inline int imx_dma_is_general_purpose(struct dma_chan *chan)return strstr (dev_name (chan->device->dev),"sdma" ) || !strcmp (dev_name (chan->device->dev),"imx1-dma" ) || !strcmp(dev_name(chan->device->dev), "imx21-dma") || - !strcmp (dev_name (chan->device->dev),"imx27-dma" );Quoted 8 lines
include/linux/platform_data/dma-imx.h static inline int imx_dma_is_general_purpose(struct dma_chan *chan) · line 71
Quoted 3 lines
include/linux/platform_data/dma-imx.h +2
-0+ !strcmp (dev_name (chan->device->dev),"imx27-dma" ) || + !strcmp (chan->device->dev->driver->name,"imx-dma" ); }Also, your filter function does not actually check
imx_dma_is_general_purpose()as the old style filter functions in the slave drivers do, which breaks when you have more than one dma engine in the system.
Quoted 4 lines
Oh yes, in the filter function should be a device driver comparison. But I would prefer a direct check instead of
imx_dma_is_general_purposebecause I think the driver should not define a filter function that initializes data for another driver (sdma).
Yes, that is also how I did it in the dwdma patches. Basically I have the dma engine object passed into xlate and then from there into the filter, where I can compare it against chan->device.
Arnd
PATCH v3 1/2 dma: imx-dma: Add oftree support
In reply to Markus PargmannAdding devicetree support for imx-dma driver. Use driver name for function 'imx_dma_is_general_purpose' because the devicename for devicetree initialized devices is different.
Changes in V3:
- Create a imxdma translate function to pass the device object into the filter function.
Changes in V2:
- Change the driver to use generic DMA DT bindings.
- Add a imx-dma filter function that sets the dma request line in private data.
--- .../devicetree/bindings/dma/fsl-imx-dma.txt | 48 ++++++++++++ drivers/dma/imx-dma.c | 87 +++++++++++++++++++++- include/linux/platform_data/dma-imx.h | 6 +- 3 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/dma/fsl-imx-dma.txt
Documentation/devicetree/bindings/dma/fsl-imx-dma.txt new file +48 -0
@@ -0,0 +1,48 @@ +* Freescale Direct Memory Access (DMA) Controller for i.MX + +This document will only describe differences to the generic DMA Controller and +DMA request bindings. + +* DMA controller + +Required properties: +- compatible : Should be "fsl,<chip>-dma". chip can be imx1, imx21 or imx27 +- reg : Should contain DMA registers location and length +- interrupts : First item should be DMA interrupt, second one is optional and + should contain DMA Error interrupt +- #dma-cells : Has to be 1. imx-dma does not support anything else. + +Optional properties: +- #dma-channels : Number of DMA channels supported. Should be 16. +- #dma-requests : Number of DMA requests supported. + +Example: + + dma: dma at 10001000 { + compatible = "fsl,imx27-dma"; + reg = <0x10001000 0x1000>; + interrupts = <32 33>; + #dma-cells = <1>; + #dma-channels = <16>; + }; + + +* DMA client + +Clients have to specify the DMA requests with phandles in a list. + +Required properties: +- dmas: List of one or more DMA request specifiers. One DMA request specifier + consists of a phandle to the DMA controller followed by the integer + specifiying the request line. +- dma-names: List of string identifiers for the DMA requests. For the correct + names, have a look at the specific client driver. + +Example: + + sdhci1: sdhci at 10013000 { + ... + dmas = <&dma 7>; + dma-names = "rx-tx"; + ... + };
drivers/dma/imx-dma.c +86 -1
145 lines not on this page · raw message
include/linux/platform_data/dma-imx.h +5 -1
@@ -51,6 +51,9 @@ struct imx_dma_data {int dma_request;/* DMA request line */ enum sdma_peripheral_type peripheral_type;int priority; + +/* Did the controller's filter function allocated this object? */ +bool alloc_ctl_filter; };static inline int imx_dma_is_ipu (struct dma_chan *chan)
@@ -63,7 +66,8 @@ static inline int imx_dma_is_general_purpose(struct dma_chan *chan)return strstr (dev_name (chan->device->dev),"sdma" ) || !strcmp (dev_name (chan->device->dev),"imx1-dma" ) || !strcmp (dev_name (chan->device->dev),"imx21-dma" ) || - !strcmp(dev_name(chan->device->dev), "imx27-dma"); + !strcmp (dev_name (chan->device->dev),"imx27-dma" ) || + !strcmp(chan->device->dev->driver->name, "imx-dma"); }#endif
Signature · 1 line
1.8.1.2
PATCH v3 2/2 DMA: imx-dma: imxdma->dev used uninitialized
imxdma->dev is used for dev_warn before it was set.
--- drivers/dma/imx-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/imx-dma.c +1 -1
@@ -1077,6 +1077,7 @@ static int __init imxdma_probe(struct platform_device *pdev)if (!imxdma)return -ENOMEM ; + imxdma->dev = &pdev->dev; imxdma->devtype = pdev->id_entry->driver_data; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -1181,7 +1182,6 @@ static int __init imxdma_probe(struct platform_device *pdev) &imxdma->dma_device.channels); } - imxdma->dev = &pdev->dev; imxdma->dma_device.dev = &pdev->dev; imxdma->dma_device.device_alloc_chan_resources = imxdma_alloc_chan_resources;
Signature · 1 line
1.8.1.2
PATCH v3 1/2 dma: imx-dma: Add oftree support
In reply to Markus PargmannQuoted 8 lines · Markus Pargmann
Adding devicetree support for imx-dma driver. Use driver name for function '
imx_dma_is_general_purpose' because the devicename for devicetree initialized devices is different.Changes in V3:
- Create a imxdma translate function to pass the device object into the filter function.
Quoted 7 lines
Changes in V2:
- Change the driver to use generic DMA DT bindings.
- Add a imx-dma filter function that sets the dma request line in private data.Signed-off-by Markus Pargmann <[email protected]>Cc Arnd Bergmann <[email protected]>
Looks correct now,
I have one idea for an optimization though:
Quoted 9 lines
drivers/dma/imx-dma.c +9
-0+static bool imxdma_filter_fn (struct dma_chan *chan,void *param) +{ +struct imxdma_filter_data *fdata = param; +struct imx_dma_data *data; + +if (chan->device->dev != fdata->imxdma->dev) +return false; + + data =kzalloc (sizeof (*data),GFP_KERNEL );
drivers/dma/imx-dma.c static void imxdma_issue_pending(struct dma_chan *chan) · line 1045
Quoted 10 lines
drivers/dma/imx-dma.c +10
-0+ +if (!data) +return false; + + data->dma_request = fdata->request; + data->alloc_ctl_filter = true; + chan->private = data; + +return true; +}
There is already a "dma_request" member in "struct imxdma_channel", so you could use that instead of allocating the imx_dma_data here.
Then you don't need to keep track of freeing that memory again, but you might have to change a few other functions that look at data->dma_request rather than chan->dma_request at the moment and change them to use the latter instead. You can copy data->dma_request over in the alloc_chan_resources functions for the legacy case.
Arnd
PATCH v3 1/2 dma: imx-dma: Add oftree support
Quoted 46 lines · Arnd Bergmann
Quoted 8 lines · Markus Pargmann
Adding devicetree support for imx-dma driver. Use driver name for function '
imx_dma_is_general_purpose' because the devicename for devicetree initialized devices is different.Changes in V3:
- Create a imxdma translate function to pass the device object into the filter function.Quoted 7 lines
Changes in V2:
- Change the driver to use generic DMA DT bindings.
- Add a imx-dma filter function that sets the dma request line in private data.Signed-off-by Markus Pargmann <[email protected]>Cc Arnd Bergmann <[email protected]>Looks correct now,
Reviewed-by Arnd Bergmann <[email protected]>I have one idea for an optimization though:
Quoted 9 lines
drivers/dma/imx-dma.c +9
-0+static bool imxdma_filter_fn (struct dma_chan *chan,void *param) +{ +struct imxdma_filter_data *fdata = param; +struct imx_dma_data *data; + +if (chan->device->dev != fdata->imxdma->dev) +return false; + + data =kzalloc (sizeof (*data),GFP_KERNEL );drivers/dma/imx-dma.c static void imxdma_issue_pending(struct dma_chan *chan) · line 1045
Quoted 10 lines
drivers/dma/imx-dma.c +10
-0+ +if (!data) +return false; + + data->dma_request = fdata->request; + data->alloc_ctl_filter = true; + chan->private = data; + +return true; +}There is already a "
dma_request" member in "structimxdma_channel", so you could use that instead of allocating theimx_dma_datahere.
Quoted 5 lines
Then you don't need to keep track of freeing that memory again, but you might have to change a few other functions that look at
data->dma_requestrather thanchan->dma_requestat the moment and change them to use the latter instead. You can copydata->dma_requestover in thealloc_chan_resourcesfunctions for the legacy case.
Thanks, that is much better than the current use of kzalloc. I updated it for v4.
Markus
Quoted 2 lines
Arnd
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH v3 1/2 dma: imx-dma: Add oftree support
In reply to Markus PargmannQuoted 3 lines · Markus Pargmann
Adding devicetree support for imx-dma driver. Use driver name for function '
imx_dma_is_general_purpose' because the devicename for devicetree initialized devices is different.
...
include/linux/platform_data/dma-imx.h static inline int imx_dma_is_general_purpose(struct dma_chan *chan) · line 71
Quoted 8 lines
include/linux/platform_data/dma-imx.h +2
-1@@ -63,7 +66,8 @@ static inline int imx_dma_is_general_purpose(struct dma_chan *chan)return strstr (dev_name (chan->device->dev),"sdma" ) || !strcmp (dev_name (chan->device->dev),"imx1-dma" ) || !strcmp (dev_name (chan->device->dev),"imx21-dma" ) || - !strcmp (dev_name (chan->device->dev),"imx27-dma" ); + !strcmp (dev_name (chan->device->dev),"imx27-dma" ) || + !strcmp (chan->device->dev->driver->name,"imx-dma" ); }
So the function could just look like the following?
static inline int imx_dma_is_general_purpose(struct dma_chan *chan)
{
return !strcmp(chan->device->dev->driver->name, "imx-sdma") ||
!strcmp(chan->device->dev->driver->name, "imx-dma");
}Shawn
PATCH v3 1/2 dma: imx-dma: Add oftree support
Quoted 18 lines · Shawn Guo
Quoted 3 lines · Markus Pargmann
Adding devicetree support for imx-dma driver. Use driver name for function '
imx_dma_is_general_purpose' because the devicename for devicetree initialized devices is different....
include/linux/platform_data/dma-imx.h static inline int imx_dma_is_general_purpose(struct dma_chan *chan) · line 71
Quoted 8 lines
include/linux/platform_data/dma-imx.h +2
-1@@ -63,7 +66,8 @@ static inline int imx_dma_is_general_purpose(struct dma_chan *chan)return strstr (dev_name (chan->device->dev),"sdma" ) || !strcmp (dev_name (chan->device->dev),"imx1-dma" ) || !strcmp (dev_name (chan->device->dev),"imx21-dma" ) || - !strcmp (dev_name (chan->device->dev),"imx27-dma" ); + !strcmp (dev_name (chan->device->dev),"imx27-dma" ) || + !strcmp (chan->device->dev->driver->name,"imx-dma" ); }So the function could just look like the following?
Quoted 5 lines
static inline int
imx_dma_is_general_purpose(struct dma_chan *chan){ return !strcmp(chan->device->dev->driver->name, "imx-sdma") || !strcmp(chan->device->dev->driver->name, "imx-dma"); }
Yes. For imx-dma there is only imx1, imx21 and imx27 that use imx-dma driver. And the devicenames of imx-sdma are imx31-sdma and imx35-sdma, so all devices using imx-sdma match. I will change it for v4. Thanks
Markus
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |