linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH v5 1/2] dmaengine: mxs: use platform_driver_register
@ 2022-08-20  8:44 Dario Binacchi
  2022-08-20  8:45 ` [RESEND PATCH v5 2/2] dmaengine: mxs: fix section mismatch Dario Binacchi
  0 siblings, 1 reply; 5+ messages in thread
From: Dario Binacchi @ 2022-08-20  8:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-amarula, Michael Trimarchi, Dario Binacchi, stable,
	Fabio Estevam, NXP Linux Team, Pengutronix Kernel Team,
	Sascha Hauer, Shawn Guo, Vinod Koul, dmaengine, linux-arm-kernel

Driver registration fails on SOC imx8mn as its supplier, the clock
control module, is probed later than subsys initcall level. This driver
uses platform_driver_probe which is not compatible with deferred probing
and won't be probed again later if probe function fails due to clock not
being available at that time.

This patch replaces the use of platform_driver_probe with
platform_driver_register which will allow probing the driver later again
when the clock control module will be available.

Fixes: a580b8c5429a ("dmaengine: mxs-dma: add dma support for i.MX23/28")
Co-developed-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Cc: stable@vger.kernel.org

---

Changes in v5:
- Update the commit message.
- Add the patch "dmaengine: mxs: fix section mismatch" to remove the
  warning raised by this patch.

Changes in v4:
- Restore __init in front of mxs_dma_probe() definition.
- Rename the mxs_dma_driver variable to mxs_dma_driver_probe.
- Update the commit message.
- Use builtin_platform_driver() instead of module_platform_driver().

Changes in v3:
- Restore __init in front of mxs_dma_init() definition.

Changes in v2:
- Add the tag "Cc: stable@vger.kernel.org" in the sign-off area.

 drivers/dma/mxs-dma.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index 994fc4d2aca4..18f8154b859b 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -839,10 +839,6 @@ static struct platform_driver mxs_dma_driver = {
 		.name	= "mxs-dma",
 		.of_match_table = mxs_dma_dt_ids,
 	},
+	.probe = mxs_dma_probe,
 };
-
-static int __init mxs_dma_module_init(void)
-{
-	return platform_driver_probe(&mxs_dma_driver, mxs_dma_probe);
-}
-subsys_initcall(mxs_dma_module_init);
+builtin_platform_driver(mxs_dma_driver);
-- 
2.32.0


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

* [RESEND PATCH v5 2/2] dmaengine: mxs: fix section mismatch
  2022-08-20  8:44 [RESEND PATCH v5 1/2] dmaengine: mxs: use platform_driver_register Dario Binacchi
@ 2022-08-20  8:45 ` Dario Binacchi
  0 siblings, 0 replies; 5+ messages in thread
From: Dario Binacchi @ 2022-08-20  8:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-amarula, Michael Trimarchi, Dario Binacchi, stable,
	Fabio Estevam, NXP Linux Team, Pengutronix Kernel Team,
	Sascha Hauer, Shawn Guo, Vinod Koul, dmaengine, linux-arm-kernel

The patch was suggested by the following modpost warning:

WARNING: modpost: vmlinux.o(.data+0xa3900): Section mismatch in reference from the variable mxs_dma_driver to the function .init.text:mxs_dma_probe()
The variable mxs_dma_driver references
the function __init mxs_dma_probe()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

Co-developed-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Cc: stable@vger.kernel.org
---

(no changes since v1)

 drivers/dma/mxs-dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index 18f8154b859b..a01953e06048 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -834,7 +834,7 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static struct platform_driver mxs_dma_driver = {
+static struct platform_driver mxs_dma_driver __initdata = {
 	.driver		= {
 		.name	= "mxs-dma",
 		.of_match_table = mxs_dma_dt_ids,
-- 
2.32.0


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

* Re: [RESEND PATCH v5 2/2] dmaengine: mxs: fix section mismatch
  2022-09-04 14:10 ` [RESEND PATCH v5 2/2] dmaengine: mxs: fix section mismatch Dario Binacchi
@ 2022-09-21  9:35   ` Robin Murphy
  0 siblings, 0 replies; 5+ messages in thread
From: Robin Murphy @ 2022-09-21  9:35 UTC (permalink / raw)
  To: Dario Binacchi, linux-kernel
  Cc: linux-amarula, Michael Trimarchi, stable, Fabio Estevam,
	NXP Linux Team, Pengutronix Kernel Team, Sascha Hauer, Shawn Guo,
	Vinod Koul, dmaengine, linux-arm-kernel

On 2022-09-04 15:10, Dario Binacchi wrote:
> The patch was suggested by the following modpost warning:
> 
> WARNING: modpost: vmlinux.o(.data+0xa3900): Section mismatch in reference from the variable mxs_dma_driver to the function .init.text:mxs_dma_probe()
> The variable mxs_dma_driver references
> the function __init mxs_dma_probe()
> If the reference is valid then annotate the
> variable with __init* or __refdata (see linux/init.h) or name the variable:
> *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

This is very wrong - even *with* platform_driver_probe(), the driver may 
remain registered beyond init, so when the driver core walks the list 
trying to match a driver for some other device later it can access freed 
data and crash. Which is absolutely no fun to debug...

The correct fix is to remove the __init annotation from the probe 
routine. If you want to support deferred probe, consider that even your 
own probe call might potentially be delayed until after initdata is freed.

Thanks,
Robin.

> Co-developed-by: Michael Trimarchi <michael@amarulasolutions.com>
> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
> Cc: stable@vger.kernel.org
> ---
> 
> (no changes since v1)
> 
>   drivers/dma/mxs-dma.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> index 18f8154b859b..a01953e06048 100644
> --- a/drivers/dma/mxs-dma.c
> +++ b/drivers/dma/mxs-dma.c
> @@ -834,7 +834,7 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
>   	return 0;
>   }
>   
> -static struct platform_driver mxs_dma_driver = {
> +static struct platform_driver mxs_dma_driver __initdata = {
>   	.driver		= {
>   		.name	= "mxs-dma",
>   		.of_match_table = mxs_dma_dt_ids,

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

* [RESEND PATCH v5 2/2] dmaengine: mxs: fix section mismatch
  2022-09-04 14:10 [RESEND PATCH v5 1/2] dmaengine: mxs: use platform_driver_register Dario Binacchi
@ 2022-09-04 14:10 ` Dario Binacchi
  2022-09-21  9:35   ` Robin Murphy
  0 siblings, 1 reply; 5+ messages in thread
From: Dario Binacchi @ 2022-09-04 14:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-amarula, Michael Trimarchi, Dario Binacchi, stable,
	Fabio Estevam, NXP Linux Team, Pengutronix Kernel Team,
	Sascha Hauer, Shawn Guo, Vinod Koul, dmaengine, linux-arm-kernel

The patch was suggested by the following modpost warning:

WARNING: modpost: vmlinux.o(.data+0xa3900): Section mismatch in reference from the variable mxs_dma_driver to the function .init.text:mxs_dma_probe()
The variable mxs_dma_driver references
the function __init mxs_dma_probe()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

Co-developed-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Cc: stable@vger.kernel.org
---

(no changes since v1)

 drivers/dma/mxs-dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index 18f8154b859b..a01953e06048 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -834,7 +834,7 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static struct platform_driver mxs_dma_driver = {
+static struct platform_driver mxs_dma_driver __initdata = {
 	.driver		= {
 		.name	= "mxs-dma",
 		.of_match_table = mxs_dma_dt_ids,
-- 
2.32.0


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

* [RESEND PATCH v5 2/2] dmaengine: mxs: fix section mismatch
  2022-07-28  6:18 [RESEND PATCH v5 1/2] dmaengine: mxs: use platform_driver_register Dario Binacchi
@ 2022-07-28  6:18 ` Dario Binacchi
  0 siblings, 0 replies; 5+ messages in thread
From: Dario Binacchi @ 2022-07-28  6:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: Michael Trimarchi, linux-amarula, Dario Binacchi, stable,
	Fabio Estevam, NXP Linux Team, Pengutronix Kernel Team,
	Sascha Hauer, Shawn Guo, Vinod Koul, dmaengine, linux-arm-kernel

The patch was suggested by the following modpost warning:

WARNING: modpost: vmlinux.o(.data+0xa3900): Section mismatch in reference from the variable mxs_dma_driver to the function .init.text:mxs_dma_probe()
The variable mxs_dma_driver references
the function __init mxs_dma_probe()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

Co-developed-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Cc: stable@vger.kernel.org
---

(no changes since v1)

 drivers/dma/mxs-dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index 18f8154b859b..a01953e06048 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -834,7 +834,7 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static struct platform_driver mxs_dma_driver = {
+static struct platform_driver mxs_dma_driver __initdata = {
 	.driver		= {
 		.name	= "mxs-dma",
 		.of_match_table = mxs_dma_dt_ids,
-- 
2.32.0


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

end of thread, other threads:[~2022-09-21  9:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-20  8:44 [RESEND PATCH v5 1/2] dmaengine: mxs: use platform_driver_register Dario Binacchi
2022-08-20  8:45 ` [RESEND PATCH v5 2/2] dmaengine: mxs: fix section mismatch Dario Binacchi
  -- strict thread matches above, loose matches on Subject: below --
2022-09-04 14:10 [RESEND PATCH v5 1/2] dmaengine: mxs: use platform_driver_register Dario Binacchi
2022-09-04 14:10 ` [RESEND PATCH v5 2/2] dmaengine: mxs: fix section mismatch Dario Binacchi
2022-09-21  9:35   ` Robin Murphy
2022-07-28  6:18 [RESEND PATCH v5 1/2] dmaengine: mxs: use platform_driver_register Dario Binacchi
2022-07-28  6:18 ` [RESEND PATCH v5 2/2] dmaengine: mxs: fix section mismatch Dario Binacchi

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