Unconditional registering EMDA platform devices
Subsystems (2)
Hi Matt
I've had a report of a Debian kernel running on a Marvell XP system giving warnings:
[ 0.114771] edma-dma-engine edma-dma-engine.0: Can't allocate PaRAM dummy slot [ 0.114794] edma-dma-engine: probe of edma-dma-engine.0 failed with error -5
These seem to be coming from drivers/dma/emda.c
That driver has a subsys_initcall(edma_init);
and the edma_init function is unconditionally registering a driver and a platform device. For a multiarch kernel, this is not a good idea.
Please could you make this conditionally. Maybe look into the DT and see if the DMA is needed on the platform?
Thanks
Andrew
Quoted 10 lines · On Friday 24 October 2014 16:29:04 Andrew Lunn wrote:
Hi Matt
I've had a report of a Debian kernel running on a Marvell XP system giving warnings:
[ 0.114771] edma-dma-engine edma-dma-engine.0: Can't allocate PaRAM dummy slot [ 0.114794] edma-dma-engine: probe of edma-dma-engine.0 failed with error -5These seem to be coming from
drivers/dma/emda.c
Quoted 7 lines
That driver has a
subsys_initcall(edma_init);and the
edma_initfunction is unconditionally registering a driver and a platform device. For a multiarch kernel, this is not a good idea.Please could you make this conditionally. Maybe look into the DT and see if the DMA is needed on the platform?
I just looked at that code an I'm completely confused about how that even works today. I do see that the driver is used on ATAGS based davinci machines, which means we can't just look into the DT.
The main problem seems to stem from arch/arm/common/edma.c being half the driver that provides interfaces to both drivers/dma/edma.c and to sound/soc/davinci/davinci-pcm.c, while drivers/dma/edma.c is not really a driver by itself. My preferred solution to this would be to move arch/arm/common/edma.c into drivers/dma/edma.c and still have it export its private API, but I assume that the dmaengine maintainers have already NAKed that approach.
Would the approach below work?
Arnd
8<-------
Subject: dma: edma: move device registration to platform code
The horrible split between the low-level part of the edma support and the dmaengine front-end driver causes problems on multiplatform kernels. This is an attempt to improve the situation slightly by only registering the dmaengine devices that are actually present.
arch/arm/common/edma.c +8 -0
@@ -1623,6 +1623,11 @@ static int edma_probe(struct platform_device *pdev)struct device_node *node = pdev->dev.of_node;struct device *dev = &pdev->dev;int ret; +struct platform_device_info edma_dev_info = { + .name ="edma-dma-engine" , + .dma_mask =DMA_BIT_MASK (32 ), + .parent = &pdev->dev, + };if (node) {/* Check if this is a second instance registered */
@@ -1793,6 +1798,9 @@ static int edma_probe(struct platform_device *pdev)edma_write_array (j,EDMA_QRAE , i,0x0 ); } arch_num_cc++; + + edma_dev_info.id = j; +platform_device_register_full (&edma_dev_info); }return 0 ;
drivers/dma/edma.c +1 -39
@@ -1107,52 +1107,14 @@ bool edma_filter_fn(struct dma_chan *chan, void *param) }EXPORT_SYMBOL (edma_filter_fn); -static struct platform_device *pdev0, *pdev1; - -static const struct platform_device_info edma_dev_info0 = { - .name ="edma-dma-engine" , - .id =0 , - .dma_mask =DMA_BIT_MASK (32 ), -}; - -static const struct platform_device_info edma_dev_info1 = { - .name ="edma-dma-engine" , - .id =1 , - .dma_mask =DMA_BIT_MASK (32 ), -}; -static int edma_init (void ) { -int ret =platform_driver_register (&edma_driver); - -if (ret ==0 ) { - pdev0 =platform_device_register_full (&edma_dev_info0); -if (IS_ERR (pdev0)) { -platform_driver_unregister (&edma_driver); - ret =PTR_ERR (pdev0); - goto out; - } - } - -if (!of_have_populated_dt () &&EDMA_CTLRS ==2 ) { - pdev1 =platform_device_register_full (&edma_dev_info1); -if (IS_ERR (pdev1)) { -platform_driver_unregister (&edma_driver); -platform_device_unregister (pdev0); - ret =PTR_ERR (pdev1); - } - } - -out: -return ret; +return platform_driver_register (&edma_driver); }subsys_initcall (edma_init); static void __exit edma_exit(void) { -platform_device_unregister (pdev0); -if (pdev1) -platform_device_unregister (pdev1);platform_driver_unregister (&edma_driver); }module_exit (edma_exit);
Hello Arnd,
Quoted 4 lines · Arnd Bergmann
Quoted 3 lines · On Friday 24 October 2014 16:29:04 Andrew Lunn wrote:
Hi Matt
I've had a report of a Debian kernel running on a Marvell XP system
Not really relevant, but it's a Armada 370, not XP system.
Quoted 19 lines
Quoted 7 lines
giving warnings:
[ 0.114771] edma-dma-engine edma-dma-engine.0: Can't allocate PaRAM dummy slot [ 0.114794] edma-dma-engine: probe of edma-dma-engine.0 failed with error -5These seem to be coming from
drivers/dma/emda.cQuoted 7 lines
That driver has a
subsys_initcall(edma_init);and the
edma_initfunction is unconditionally registering a driver and a platform device. For a multiarch kernel, this is not a good idea.Please could you make this conditionally. Maybe look into the DT and see if the DMA is needed on the platform?
I just looked at that code an I'm completely confused about how that even works today. I do see that the driver is used on ATAGS based davinci machines, which means we can't just look into the DT.
Quoted 7 lines
The main problem seems to stem from
arch/arm/common/edma.cbeing half the driver that provides interfaces to bothdrivers/dma/edma.cand tosound/soc/davinci/davinci-pcm.c, whiledrivers/dma/edma.cis not really a driver by itself. My preferred solution to this would be to movearch/arm/common/edma.cintodrivers/dma/edma.cand still have it export its private API, but I assume that the dmaengine maintainers have already NAKed that approach.
Isn't the preferred solution that sound/soc/davinci/davinci-pcm.c only uses dmaengine stuff and the private API goes away?
Quoted 1 line
Would the approach below work?
I didn't test it yet, but I assume it makes the warning disappear on machines without an "edma" platform device. So it would solve my problem.
drivers/dma/edma.c
Quoted 15 lines
8<-------
Subject: dma: edma: move device registration to platform codeThe horrible split between the low-level part of the edma support and the dmaengine front-end driver causes problems on multiplatform kernels. This is an attempt to improve the situation slightly by only registering the dmaengine devices that are actually present.
Signed-off-by Arnd Bergmann <[email protected]>[...]drivers/dma/edma.c +0
-0
There is a comment in drivers/dma/edma.c reading:
/*
* This will go away when the private EDMA API is folded
* into this driver and the platform device(s) are
* instantiated in the arch code. We can only get away
* with this simplification because DA8XX may not be built
* in the same kernel image with other DaVinci parts. This
* avoids having to sprinkle dmaengine driver platform devices
* and data throughout all the existing board files. */
Just looking into arch/arm/mach-davinci/Kconfig it seems wrong that DA8XX may not be enabled with other DaVinci parts. So probably there is really more broken here ...
Best regards
Uwe
Quoted 28 lines · On Saturday 25 October 2014 20:48:54 Uwe Kleine-K?nig wrote:
Quoted 20 lines · Arnd Bergmann
Quoted 7 lines · On Friday 24 October 2014 16:29:04 Andrew Lunn wrote:
giving warnings:
[ 0.114771] edma-dma-engine edma-dma-engine.0: Can't allocate PaRAM dummy slot [ 0.114794] edma-dma-engine: probe of edma-dma-engine.0 failed with error -5These seem to be coming from
drivers/dma/emda.cQuoted 7 lines
That driver has a
subsys_initcall(edma_init);and the
edma_initfunction is unconditionally registering a driver and a platform device. For a multiarch kernel, this is not a good idea.Please could you make this conditionally. Maybe look into the DT and see if the DMA is needed on the platform?
I just looked at that code an I'm completely confused about how that even works today. I do see that the driver is used on ATAGS based davinci machines, which means we can't just look into the DT.
Quoted 7 lines
The main problem seems to stem from
arch/arm/common/edma.cbeing half the driver that provides interfaces to bothdrivers/dma/edma.cand tosound/soc/davinci/davinci-pcm.c, whiledrivers/dma/edma.cis not really a driver by itself. My preferred solution to this would be to movearch/arm/common/edma.cintodrivers/dma/edma.cand still have it export its private API, but I assume that the dmaengine maintainers have already NAKed that approach.
Quoted 2 lines
Isn't the preferred solution that
sound/soc/davinci/davinci-pcm.conly uses dmaengine stuff and the private API goes away?
Absolutely, yes. I believe all other drivers have been converted already, and it's on somebody's TODO list.
Quoted 27 lines
drivers/dma/edma.c
Quoted 15 lines
8<-------
Subject: dma: edma: move device registration to platform codeThe horrible split between the low-level part of the edma support and the dmaengine front-end driver causes problems on multiplatform kernels. This is an attempt to improve the situation slightly by only registering the dmaengine devices that are actually present.
Signed-off-by Arnd Bergmann <[email protected]>[...]drivers/dma/edma.c +0
-0There is a comment in
drivers/dma/edma.creading:/*
* This will go away when the private EDMA API is folded
* into this driver and the platform device(s) are
* instantiated in the arch code. We can only get away
* with this simplification because DA8XX may not be built
* in the same kernel image with other DaVinci parts. This
* avoids having to sprinkle dmaengine driver platform devices
* and data throughout all the existing board files. */
Quoted 3 lines
Just looking into
arch/arm/mach-davinci/Kconfigit seems wrong that DA8XX may not be enabled with other DaVinci parts. So probably there is really more broken here ...
Right, and it also seems that this would be fairly simple to fix as a follow-up patch. I already eliminated the only use of EDMA_CTLRS, and the da8xx type could be derived from the device identifier.
Arnd
+ Peter, Vinod
Quoted 29 lines · Arnd Bergmann
Quoted 28 lines · On Saturday 25 October 2014 20:48:54 Uwe Kleine-K?nig wrote:
Quoted 27 lines · Arnd Bergmann
Quoted 7 lines · On Friday 24 October 2014 16:29:04 Andrew Lunn wrote:
giving warnings:
[ 0.114771] edma-dma-engine edma-dma-engine.0: Can't allocate PaRAM dummy slot [ 0.114794] edma-dma-engine: probe of edma-dma-engine.0 failed with error -5These seem to be coming from
drivers/dma/emda.cQuoted 7 lines
That driver has a
subsys_initcall(edma_init);and the
edma_initfunction is unconditionally registering a driver and a platform device. For a multiarch kernel, this is not a good idea.Please could you make this conditionally. Maybe look into the DT and see if the DMA is needed on the platform?
I just looked at that code an I'm completely confused about how that even works today. I do see that the driver is used on ATAGS based davinci machines, which means we can't just look into the DT.
The main problem seems to stem from
arch/arm/common/edma.cbeing half the driver that provides interfaces to bothdrivers/dma/edma.cand tosound/soc/davinci/davinci-pcm.c, whiledrivers/dma/edma.cis not really a driver by itself. My preferred solution to this would be to movearch/arm/common/edma.cintodrivers/dma/edma.cand still have it export its private API, but I assume that the dmaengine maintainers have already NAKed that approach.
Quoted 5 lines
Quoted 2 lines
Isn't the preferred solution that
sound/soc/davinci/davinci-pcm.conly uses dmaengine stuff and the private API goes away?Absolutely, yes. I believe all other drivers have been converted already, and it's on somebody's TODO list.
Yes, Peter was looking at removing the usage of private DMA API from davinci-pcm.
https://lkml.org/lkml/2014/8/11/85
It is still on his TODO.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
8<-------
Subject: dma: edma: move device registration to platform codeThe horrible split between the low-level part of the edma support and the dmaengine front-end driver causes problems on multiplatform kernels. This is an attempt to improve the situation slightly by only registering the dmaengine devices that are actually present.
Signed-off-by Arnd Bergmann <[email protected]>
I tested this patch on DA850 using MMC/SD as EDMA client and it worked fine. I think it will serve well as intermediate solution while Peter works on folding in arch/arm/common/edma.c into drivers/dma/edma.c
I had to add the following patch on top to get DMA_BIT_MASK defined in edma.c
---8<---
arch/arm/common/edma.c +1 -0
@@ -31,6 +31,7 @@#include <linux/of_dma.h> #include <linux/of_irq.h> #include <linux/pm_runtime.h> +#include <linux/dma-mapping.h> #include <linux/platform_data/edma.h> ---8<---
In the same patch you can probably get rid of EDMA_CTLRS definition too as you noted below.
If you decide to post it formally for Vinod to pick, you can add:
Quoted 17 lines
Quoted 17 lines
drivers/dma/edma.c
Quoted 5 lines
[...]
drivers/dma/edma.c +0
-0There is a comment in
drivers/dma/edma.creading:/*
* This will go away when the private EDMA API is folded
* into this driver and the platform device(s) are
* instantiated in the arch code. We can only get away
* with this simplification because DA8XX may not be built
* in the same kernel image with other DaVinci parts. This
* avoids having to sprinkle dmaengine driver platform devices
* and data throughout all the existing board files. */
Quoted 3 lines
Quoted 3 lines
Just looking into
arch/arm/mach-davinci/Kconfigit seems wrong that DA8XX may not be enabled with other DaVinci parts. So probably there is really more broken here ...
This was true when the comment was written. We have since moved to AUTO_ZRELADDR and a single config builds all DaVinci boards now.
Thanks,
Sekhar