* [PATCH v4 1/2] drm/etnaviv: Check for platform_device_register_simple() failure
@ 2018-06-27 13:07 Fabio Estevam
2018-06-27 13:07 ` [PATCH v4 2/2] drm/etnaviv: Fix driver unregistering Fabio Estevam
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Fabio Estevam @ 2018-06-27 13:07 UTC (permalink / raw)
To: airlied
Cc: l.stach, linux, linux+etnaviv, christian.gmeiner, kernel,
etnaviv, dri-devel, p.zabel, Fabio Estevam, stable
From: Fabio Estevam <fabio.estevam@nxp.com>
platform_device_register_simple() may fail, so we should better
check its return value and propagate it in the case of error.
Cc: <stable@vger.kernel.org>
Fixes: 246774d17fc0 ("drm/etnaviv: remove the need for a gpu-subsystem DT node")
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
Changes since v3:
- Only set etnaviv_drm when platform_device_register_simple()
succeeds (Phillip)
drivers/gpu/drm/etnaviv/etnaviv_drv.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index e5013a9..f8d264a 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -631,8 +631,11 @@ static struct platform_driver etnaviv_platform_driver = {
},
};
+static struct platform_device *etnaviv_drm;
+
static int __init etnaviv_init(void)
{
+ struct platform_device *pdev;
int ret;
struct device_node *np;
@@ -644,7 +647,7 @@ static int __init etnaviv_init(void)
ret = platform_driver_register(&etnaviv_platform_driver);
if (ret != 0)
- platform_driver_unregister(&etnaviv_gpu_driver);
+ goto unregister_gpu_driver;
/*
* If the DT contains at least one available GPU device, instantiate
@@ -653,12 +656,24 @@ static int __init etnaviv_init(void)
for_each_compatible_node(np, NULL, "vivante,gc") {
if (!of_device_is_available(np))
continue;
-
- platform_device_register_simple("etnaviv", -1, NULL, 0);
+ pdev = platform_device_register_simple("etnaviv", -1,
+ NULL, 0);
+ if (IS_ERR(pdev)) {
+ ret = PTR_ERR(pdev);
+ of_node_put(np);
+ goto unregister_platform_driver;
+ }
+ etnaviv_drm = pdev;
of_node_put(np);
break;
}
+ return 0;
+
+unregister_platform_driver:
+ platform_driver_unregister(&etnaviv_platform_driver);
+unregister_gpu_driver:
+ platform_driver_unregister(&etnaviv_gpu_driver);
return ret;
}
module_init(etnaviv_init);
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 2/2] drm/etnaviv: Fix driver unregistering
2018-06-27 13:07 [PATCH v4 1/2] drm/etnaviv: Check for platform_device_register_simple() failure Fabio Estevam
@ 2018-06-27 13:07 ` Fabio Estevam
2018-06-27 13:16 ` Philipp Zabel
2018-06-27 13:31 ` Lucas Stach
2 siblings, 0 replies; 6+ messages in thread
From: Fabio Estevam @ 2018-06-27 13:07 UTC (permalink / raw)
To: airlied
Cc: l.stach, linux, linux+etnaviv, christian.gmeiner, kernel,
etnaviv, dri-devel, p.zabel, Fabio Estevam, stable
From: Fabio Estevam <fabio.estevam@nxp.com>
Russell King reported:
"When removing and reloading the etnaviv module, the following splat
occurs:
sysfs: cannot create duplicate filename '/devices/platform/etnaviv'
CPU: 0 PID: 1471 Comm: modprobe Not tainted 4.17.0+ #1608
Hardware name: Marvell Dove (Cubox)
Backtrace:
[<c00157d4>] (dump_backtrace) from [<c0015b8c>] (show_stack+0x18/0x1c)
r6:ef033e38 r5:ee07b340 r4:edb9d000 r3:00000000
[<c0015b74>] (show_stack) from [<c0620784>] (dump_stack+0x20/0x28)
[<c0620764>] (dump_stack) from [<c01bcd24>] (sysfs_warn_dup+0x5c/0x70)
[<c01bccc8>] (sysfs_warn_dup) from [<c01bce14>] (sysfs_create_dir_ns+0x90/0x98)
..."
Commit 246774d17fc0 ("drm/etnaviv: remove the need for a gpu-subsystem
DT node") introduced DRM registration via
platform_device_register_simple(), but missed to call
platform_device_unregister() inside etnaviv_exit().
Fix the problem by calling platform_device_unregister() inside
etnaviv_exit(). While at it, also rearrange the function calls
in the exit path to make them happen in the opposite order of
registration.
Tested on a imx6-sabresd board.
Cc: <stable@vger.kernel.org>
Fixes: 246774d17fc0 ("drm/etnaviv: remove the need for a gpu-subsystem DT node")
Reported-by: Russell King <linux@armlinux.org.uk>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
---
Changes since v3:
- By setting etnaviv_drm only when platform_device_register_simple()
succeeds in the previous patch we can
call platform_device_unregister(etnaviv_drm) unconditionally, which makes
the code simpler (Philipp).
drivers/gpu/drm/etnaviv/etnaviv_drv.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index f8d264a..4a580b0 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -680,8 +680,9 @@ module_init(etnaviv_init);
static void __exit etnaviv_exit(void)
{
- platform_driver_unregister(&etnaviv_gpu_driver);
+ platform_device_unregister(etnaviv_drm);
platform_driver_unregister(&etnaviv_platform_driver);
+ platform_driver_unregister(&etnaviv_gpu_driver);
}
module_exit(etnaviv_exit);
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v4 1/2] drm/etnaviv: Check for platform_device_register_simple() failure
2018-06-27 13:07 [PATCH v4 1/2] drm/etnaviv: Check for platform_device_register_simple() failure Fabio Estevam
@ 2018-06-27 13:16 ` Philipp Zabel
2018-06-27 13:16 ` Philipp Zabel
2018-06-27 13:31 ` Lucas Stach
2 siblings, 0 replies; 6+ messages in thread
From: Philipp Zabel @ 2018-06-27 13:16 UTC (permalink / raw)
To: Fabio Estevam, airlied
Cc: l.stach, linux, linux+etnaviv, christian.gmeiner, kernel,
etnaviv, dri-devel, Fabio Estevam, stable
On Wed, 2018-06-27 at 10:07 -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@nxp.com>
>
> platform_device_register_simple() may fail, so we should better
> check its return value and propagate it in the case of error.
>
> Cc: <stable@vger.kernel.org>
> Fixes: 246774d17fc0 ("drm/etnaviv: remove the need for a gpu-subsystem DT node")
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
regards
Philipp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4 1/2] drm/etnaviv: Check for platform_device_register_simple() failure
@ 2018-06-27 13:16 ` Philipp Zabel
0 siblings, 0 replies; 6+ messages in thread
From: Philipp Zabel @ 2018-06-27 13:16 UTC (permalink / raw)
To: Fabio Estevam, airlied
Cc: etnaviv, dri-devel, linux, stable, kernel, linux+etnaviv, Fabio Estevam
On Wed, 2018-06-27 at 10:07 -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@nxp.com>
>
> platform_device_register_simple() may fail, so we should better
> check its return value and propagate it in the case of error.
>
> Cc: <stable@vger.kernel.org>
> Fixes: 246774d17fc0 ("drm/etnaviv: remove the need for a gpu-subsystem DT node")
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
regards
Philipp
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4 1/2] drm/etnaviv: Check for platform_device_register_simple() failure
2018-06-27 13:07 [PATCH v4 1/2] drm/etnaviv: Check for platform_device_register_simple() failure Fabio Estevam
@ 2018-06-27 13:31 ` Lucas Stach
2018-06-27 13:16 ` Philipp Zabel
2018-06-27 13:31 ` Lucas Stach
2 siblings, 0 replies; 6+ messages in thread
From: Lucas Stach @ 2018-06-27 13:31 UTC (permalink / raw)
To: Fabio Estevam, airlied
Cc: linux, linux+etnaviv, christian.gmeiner, kernel, etnaviv,
dri-devel, p.zabel, Fabio Estevam, stable
Am Mittwoch, den 27.06.2018, 10:07 -0300 schrieb Fabio Estevam:
> > From: Fabio Estevam <fabio.estevam@nxp.com>
>
> platform_device_register_simple() may fail, so we should better
> check its return value and propagate it in the case of error.
>
> > Cc: <stable@vger.kernel.org>
> Fixes: 246774d17fc0 ("drm/etnaviv: remove the need for a gpu-subsystem DT node")
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Thanks Fabio, both applied to etnaviv/fixes.
Regards,
Lucas
> ---
> Changes since v3:
> - Only set etnaviv_drm when platform_device_register_simple()
> succeeds (Phillip)
>
> drivers/gpu/drm/etnaviv/etnaviv_drv.c | 21 ++++++++++++++++++---
> 1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index e5013a9..f8d264a 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -631,8 +631,11 @@ static struct platform_driver etnaviv_platform_driver = {
> > },
> };
>
> +static struct platform_device *etnaviv_drm;
> +
> static int __init etnaviv_init(void)
> {
> > + struct platform_device *pdev;
> > int ret;
> > struct device_node *np;
>
> @@ -644,7 +647,7 @@ static int __init etnaviv_init(void)
>
> > ret = platform_driver_register(&etnaviv_platform_driver);
> > if (ret != 0)
> > - platform_driver_unregister(&etnaviv_gpu_driver);
> > + goto unregister_gpu_driver;
>
> > /*
> > * If the DT contains at least one available GPU device, instantiate
> @@ -653,12 +656,24 @@ static int __init etnaviv_init(void)
> > for_each_compatible_node(np, NULL, "vivante,gc") {
> > if (!of_device_is_available(np))
> > continue;
> -
> > - platform_device_register_simple("etnaviv", -1, NULL, 0);
> > + pdev = platform_device_register_simple("etnaviv", -1,
> > + NULL, 0);
> > + if (IS_ERR(pdev)) {
> > + ret = PTR_ERR(pdev);
> > + of_node_put(np);
> > + goto unregister_platform_driver;
> > + }
> > + etnaviv_drm = pdev;
> > of_node_put(np);
> > break;
> > }
>
> > + return 0;
> +
> +unregister_platform_driver:
> > + platform_driver_unregister(&etnaviv_platform_driver);
> +unregister_gpu_driver:
> > + platform_driver_unregister(&etnaviv_gpu_driver);
> > return ret;
> }
> module_init(etnaviv_init);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4 1/2] drm/etnaviv: Check for platform_device_register_simple() failure
@ 2018-06-27 13:31 ` Lucas Stach
0 siblings, 0 replies; 6+ messages in thread
From: Lucas Stach @ 2018-06-27 13:31 UTC (permalink / raw)
To: Fabio Estevam, airlied
Cc: etnaviv, dri-devel, linux, stable, kernel, linux+etnaviv, Fabio Estevam
Am Mittwoch, den 27.06.2018, 10:07 -0300 schrieb Fabio Estevam:
> > From: Fabio Estevam <fabio.estevam@nxp.com>
>
> platform_device_register_simple() may fail, so we should better
> check its return value and propagate it in the case of error.
>
> > Cc: <stable@vger.kernel.org>
> Fixes: 246774d17fc0 ("drm/etnaviv: remove the need for a gpu-subsystem DT node")
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Thanks Fabio, both applied to etnaviv/fixes.
Regards,
Lucas
> ---
> Changes since v3:
> - Only set etnaviv_drm when platform_device_register_simple()
> succeeds (Phillip)
>
> drivers/gpu/drm/etnaviv/etnaviv_drv.c | 21 ++++++++++++++++++---
> 1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index e5013a9..f8d264a 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -631,8 +631,11 @@ static struct platform_driver etnaviv_platform_driver = {
> > },
> };
>
> +static struct platform_device *etnaviv_drm;
> +
> static int __init etnaviv_init(void)
> {
> > + struct platform_device *pdev;
> > int ret;
> > struct device_node *np;
>
> @@ -644,7 +647,7 @@ static int __init etnaviv_init(void)
>
> > ret = platform_driver_register(&etnaviv_platform_driver);
> > if (ret != 0)
> > - platform_driver_unregister(&etnaviv_gpu_driver);
> > + goto unregister_gpu_driver;
>
> > /*
> > * If the DT contains at least one available GPU device, instantiate
> @@ -653,12 +656,24 @@ static int __init etnaviv_init(void)
> > for_each_compatible_node(np, NULL, "vivante,gc") {
> > if (!of_device_is_available(np))
> > continue;
> -
> > - platform_device_register_simple("etnaviv", -1, NULL, 0);
> > + pdev = platform_device_register_simple("etnaviv", -1,
> > + NULL, 0);
> > + if (IS_ERR(pdev)) {
> > + ret = PTR_ERR(pdev);
> > + of_node_put(np);
> > + goto unregister_platform_driver;
> > + }
> > + etnaviv_drm = pdev;
> > of_node_put(np);
> > break;
> > }
>
> > + return 0;
> +
> +unregister_platform_driver:
> > + platform_driver_unregister(&etnaviv_platform_driver);
> +unregister_gpu_driver:
> > + platform_driver_unregister(&etnaviv_gpu_driver);
> > return ret;
> }
> module_init(etnaviv_init);
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-06-27 13:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-27 13:07 [PATCH v4 1/2] drm/etnaviv: Check for platform_device_register_simple() failure Fabio Estevam
2018-06-27 13:07 ` [PATCH v4 2/2] drm/etnaviv: Fix driver unregistering Fabio Estevam
2018-06-27 13:16 ` [PATCH v4 1/2] drm/etnaviv: Check for platform_device_register_simple() failure Philipp Zabel
2018-06-27 13:16 ` Philipp Zabel
2018-06-27 13:31 ` Lucas Stach
2018-06-27 13:31 ` Lucas Stach
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.