Skip to contentSkip to conversation

dmaengine: at_xdmac: use module_platform_driver

PATCH Superseded Clément Léger 2 participants 5 messages Jun 25, 2021 – Jul 28, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: at_xdmac: use module_platform_driver

The driver was previously probed with platform_driver_probe. This does not allow the driver to be probed again later if probe function returns -EPROBE_DEFER. This patch replace the use of platform_driver_probe with module_platform_driver which allows that.

---
 drivers/dma/at_xdmac.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/dma/at_xdmac.c +1 -5
index 64a52bf4d737..109a4c0895f4 100644
@@ -2238,11 +2238,7 @@ static struct platform_driver at_xdmac_driver = {
 	}
 };
 
-static int __init at_xdmac_init(void)
-{
-	return platform_driver_probe(&at_xdmac_driver, at_xdmac_probe);
-}
-subsys_initcall(at_xdmac_init);
+module_platform_driver(at_xdmac_driver);
 
 MODULE_DESCRIPTION("Atmel Extended DMA Controller driver");
 MODULE_AUTHOR("Ludovic Desroches <[email protected]>");
Signature · 1 line
2.32.0
maintainer
#1 lore raw
Quoted 15 lines · Clément Léger

The driver was previously probed with platform_driver_probe. This does not allow the driver to be probed again later if probe function returns -EPROBE_DEFER. This patch replace the use of platform_driver_probe with module_platform_driver which allows that.

---
 drivers/dma/at_xdmac.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/dma/at_xdmac.c +0 -0
index 64a52bf4d737..109a4c0895f4 100644

drivers/dma/at_xdmac.c static struct platform_driver at_xdmac_driver = { · line 2241

Quoted 9 lines
drivers/dma/at_xdmac.c +1 -5
@@ -2238,11 +2238,7 @@ static struct platform_driver at_xdmac_driver = {
 	}
 };
 
-static int __init at_xdmac_init(void)
-{
-	return platform_driver_probe(&at_xdmac_driver, at_xdmac_probe);
-}
-subsys_initcall(at_xdmac_init);
+module_platform_driver(at_xdmac_driver);

You are also changing the init call here, there is a reason why dmaengine drivers are subsys_initcall.. have you tested this?

Signature · 1 line
~Vinod
#2 lore raw
Quoted 19 lines · Vinod Koul
Quoted 18 lines · Clément Léger

The driver was previously probed with platform_driver_probe. This does not allow the driver to be probed again later if probe function returns -EPROBE_DEFER. This patch replace the use of platform_driver_probe with module_platform_driver which allows that.

---
 drivers/dma/at_xdmac.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/dma/at_xdmac.c +0 -0
index 64a52bf4d737..109a4c0895f4 100644
@@ -2238,11 +2238,7 @@ static struct platform_driver
 at_xdmac_driver = { }
 };
 
Quoted 10 lines

drivers/dma/at_xdmac.c static struct platform_driver at_xdmac_driver = { · line 2241

Quoted 6 lines
drivers/dma/at_xdmac.c +1 -4
-static int __init at_xdmac_init(void)
-{
-	return platform_driver_probe(&at_xdmac_driver,
 at_xdmac_probe); -}
-subsys_initcall(at_xdmac_init);
+module_platform_driver(at_xdmac_driver);  

You are also changing the init call here, there is a reason why dmaengine drivers are subsys_initcall.. have you tested this?

I understood that the subsys initcall was there to probe the DMA driver earlier than other drivers (at least I guess this was the reason). I also tested it and can confirm you this works as expected on my platform (sama5d2_xplained and sama5d27_som1).

In my configuration, the clocks are provided using SCMI and the SCMI driver probes them later than other drivers.

With the current subsys_initcall, platform_driver_probe calls __platform_driver_probe which will eventually calls platform_probe. This one will fails because SCMI clocks are not available at this time. And as said in the kernel doc, __platform_driver_probe is incompatible with deferred probing. This leads to failure of all drivers that needs DMA channels provbided by at_xdmac.

With module_platform_driver, the at_xdmac driver is correctly probed again later and all drivers that depends on DMA channels provided by this one are also correctly probed. The deferred probing mechanism seems to do its job correctly (at least in my case).

maintainer
#3 lore raw
Quoted 33 lines · Clément Léger
Quoted 19 lines · Vinod Koul
Quoted 18 lines · Clément Léger

The driver was previously probed with platform_driver_probe. This does not allow the driver to be probed again later if probe function returns -EPROBE_DEFER. This patch replace the use of platform_driver_probe with module_platform_driver which allows that.

---
 drivers/dma/at_xdmac.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/dma/at_xdmac.c +0 -0
index 64a52bf4d737..109a4c0895f4 100644
@@ -2238,11 +2238,7 @@ static struct platform_driver
 at_xdmac_driver = { }
 };
 
Quoted 10 lines

drivers/dma/at_xdmac.c static struct platform_driver at_xdmac_driver = { · line 2241

Quoted 6 lines
drivers/dma/at_xdmac.c +1 -4
-static int __init at_xdmac_init(void)
-{
-	return platform_driver_probe(&at_xdmac_driver,
 at_xdmac_probe); -}
-subsys_initcall(at_xdmac_init);
+module_platform_driver(at_xdmac_driver);  

You are also changing the init call here, there is a reason why dmaengine drivers are subsys_initcall.. have you tested this?

Quoted 2 lines

I understood that the subsys initcall was there to probe the DMA driver earlier than other drivers (at least I guess this was the reason). I

That is correct

Quoted 5 lines

also tested it and can confirm you this works as expected on my platform (sama5d2_xplained and sama5d27_som1).

In my configuration, the clocks are provided using SCMI and the SCMI driver probes them later than other drivers.

Heh, clocks should get probed even earlier

Quoted 11 lines

With the current subsys_initcall, platform_driver_probe calls __platform_driver_probe which will eventually calls platform_probe. This one will fails because SCMI clocks are not available at this time. And as said in the kernel doc, __platform_driver_probe is incompatible with deferred probing. This leads to failure of all drivers that needs DMA channels provbided by at_xdmac.

With module_platform_driver, the at_xdmac driver is correctly probed again later and all drivers that depends on DMA channels provided by this one are also correctly probed. The deferred probing mechanism seems to do its job correctly (at least in my case).

OK would then recommend making it like module_platform_driver ie remove platform_driver_probe, so the defer probe would work, but keep the init at subsys level. That should work for you while keeping this sane for folks that dont need this

Signature · 1 line
~Vinod
#4 lore raw
Quoted 41 lines · Vinod Koul
Quoted 34 lines · Clément Léger
Quoted 20 lines · Vinod Koul
Quoted 19 lines · Clément Léger

The driver was previously probed with platform_driver_probe. This does not allow the driver to be probed again later if probe function returns -EPROBE_DEFER. This patch replace the use of platform_driver_probe with module_platform_driver which allows that.

---
 drivers/dma/at_xdmac.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/dma/at_xdmac.c +0 -0
index 64a52bf4d737..109a4c0895f4 100644
@@ -2238,11 +2238,7 @@ static struct platform_driver
 at_xdmac_driver = { }
 };
 
Quoted 10 lines

drivers/dma/at_xdmac.c static struct platform_driver at_xdmac_driver = { · line 2241

Quoted 6 lines
drivers/dma/at_xdmac.c +1 -4
-static int __init at_xdmac_init(void)
-{
-	return platform_driver_probe(&at_xdmac_driver,
 at_xdmac_probe); -}
-subsys_initcall(at_xdmac_init);
+module_platform_driver(at_xdmac_driver);    

You are also changing the init call here, there is a reason why dmaengine drivers are subsys_initcall.. have you tested this?

Quoted 3 lines

I understood that the subsys initcall was there to probe the DMA driver earlier than other drivers (at least I guess this was the reason). I

That is correct

Quoted 7 lines
Quoted 5 lines

also tested it and can confirm you this works as expected on my platform (sama5d2_xplained and sama5d27_som1).

In my configuration, the clocks are provided using SCMI and the SCMI driver probes them later than other drivers.

Heh, clocks should get probed even earlier

Yes, even clocksources might need them... But that's another story.

Quoted 13 lines
Quoted 8 lines

With the current subsys_initcall, platform_driver_probe calls __platform_driver_probe which will eventually calls platform_probe. This one will fails because SCMI clocks are not available at this time. And as said in the kernel doc, __platform_driver_probe is incompatible with deferred probing. This leads to failure of all drivers that needs DMA channels provbided by at_xdmac.

Quoted 4 lines

With module_platform_driver, the at_xdmac driver is correctly probed again later and all drivers that depends on DMA channels provided by this one are also correctly probed. The deferred probing mechanism seems to do its job correctly (at least in my case).

Quoted 5 lines

OK would then recommend making it like module_platform_driver ie remove platform_driver_probe, so the defer probe would work, but keep the init at subsys level. That should work for you while keeping this sane for folks that dont need this

Ok, I'll modify it this way, thanks.

Signature · 3 lines
Clément Léger,
Embedded Linux and Kernel engineer at Bootlin
https://bootlin.com