linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] sun4i/drm: Fixes for removing and re-probing the driver
@ 2019-04-18 13:27 Paul Kocialkowski
  2019-04-18 13:27 ` [PATCH 1/3] drm/sun4i: Add missing drm_atomic_helper_shutdown at driver unbind Paul Kocialkowski
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Paul Kocialkowski @ 2019-04-18 13:27 UTC (permalink / raw)
  To: dri-devel, linux-arm-kernel, linux-kernel, linux-sunxi
  Cc: Maxime Ripard, David Airlie, Daniel Vetter, Chen-Yu Tsai,
	Thomas Petazzoni, Paul Kocialkowski

This series brings-in some fixes that are necessary to be able to
remove the driver at run-time (when built as a module) and properly
re-probe it afterwards.

Cheers,

Paul

Paul Kocialkowski (3):
  drm/sun4i: Add missing drm_atomic_helper_shutdown at driver unbind
  drm/sun4i: Set device driver data at bind time for use in unbind
  drm/sun4i: Fix component unbinding and component master deletion

 drivers/gpu/drm/sun4i/sun4i_drv.c | 8 ++++++++
 1 file changed, 8 insertions(+)

-- 
2.21.0


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

* [PATCH 1/3] drm/sun4i: Add missing drm_atomic_helper_shutdown at driver unbind
  2019-04-18 13:27 [PATCH 0/3] sun4i/drm: Fixes for removing and re-probing the driver Paul Kocialkowski
@ 2019-04-18 13:27 ` Paul Kocialkowski
  2019-04-18 13:27 ` [PATCH 2/3] drm/sun4i: Set device driver data at bind time for use in unbind Paul Kocialkowski
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Paul Kocialkowski @ 2019-04-18 13:27 UTC (permalink / raw)
  To: dri-devel, linux-arm-kernel, linux-kernel, linux-sunxi
  Cc: Maxime Ripard, David Airlie, Daniel Vetter, Chen-Yu Tsai,
	Thomas Petazzoni, Paul Kocialkowski

A call to drm_atomic_helper_shutdown is required to properly release
the internal references taken by the core and avoid warnings about
leaking objects. Add it since it was missing.

Fixes: 9026e0d122ac ("drm: Add Allwinner A10 Display Engine support")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 drivers/gpu/drm/sun4i/sun4i_drv.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index c8c0ab3da972..ef38ea0a748d 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -16,6 +16,7 @@
 #include <linux/of_reserved_mem.h>
 
 #include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_gem_cma_helper.h>
@@ -130,6 +131,7 @@ static void sun4i_drv_unbind(struct device *dev)
 
 	drm_dev_unregister(drm);
 	drm_kms_helper_poll_fini(drm);
+	drm_atomic_helper_shutdown(drm);
 	drm_mode_config_cleanup(drm);
 	of_reserved_mem_device_release(dev);
 	drm_dev_put(drm);
-- 
2.21.0


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

* [PATCH 2/3] drm/sun4i: Set device driver data at bind time for use in unbind
  2019-04-18 13:27 [PATCH 0/3] sun4i/drm: Fixes for removing and re-probing the driver Paul Kocialkowski
  2019-04-18 13:27 ` [PATCH 1/3] drm/sun4i: Add missing drm_atomic_helper_shutdown at driver unbind Paul Kocialkowski
@ 2019-04-18 13:27 ` Paul Kocialkowski
  2019-04-18 13:27 ` [PATCH 3/3] drm/sun4i: Fix component unbinding and component master deletion Paul Kocialkowski
  2019-04-18 14:27 ` [PATCH 0/3] sun4i/drm: Fixes for removing and re-probing the driver Maxime Ripard
  3 siblings, 0 replies; 7+ messages in thread
From: Paul Kocialkowski @ 2019-04-18 13:27 UTC (permalink / raw)
  To: dri-devel, linux-arm-kernel, linux-kernel, linux-sunxi
  Cc: Maxime Ripard, David Airlie, Daniel Vetter, Chen-Yu Tsai,
	Thomas Petazzoni, Paul Kocialkowski

Our sun4i_drv_unbind gets the drm device using dev_get_drvdata.
However, that driver data is never set in sun4i_drv_bind.

Set it there to avoid getting a NULL pointer at unbind time.

Fixes: 9026e0d122ac ("drm: Add Allwinner A10 Display Engine support")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 drivers/gpu/drm/sun4i/sun4i_drv.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index ef38ea0a748d..af07291544a4 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -72,6 +72,8 @@ static int sun4i_drv_bind(struct device *dev)
 		ret = -ENOMEM;
 		goto free_drm;
 	}
+
+	dev_set_drvdata(dev, drm);
 	drm->dev_private = drv;
 	INIT_LIST_HEAD(&drv->frontend_list);
 	INIT_LIST_HEAD(&drv->engine_list);
-- 
2.21.0


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

* [PATCH 3/3] drm/sun4i: Fix component unbinding and component master deletion
  2019-04-18 13:27 [PATCH 0/3] sun4i/drm: Fixes for removing and re-probing the driver Paul Kocialkowski
  2019-04-18 13:27 ` [PATCH 1/3] drm/sun4i: Add missing drm_atomic_helper_shutdown at driver unbind Paul Kocialkowski
  2019-04-18 13:27 ` [PATCH 2/3] drm/sun4i: Set device driver data at bind time for use in unbind Paul Kocialkowski
@ 2019-04-18 13:27 ` Paul Kocialkowski
  2019-04-18 15:03   ` [linux-sunxi] " Chen-Yu Tsai
  2019-04-18 14:27 ` [PATCH 0/3] sun4i/drm: Fixes for removing and re-probing the driver Maxime Ripard
  3 siblings, 1 reply; 7+ messages in thread
From: Paul Kocialkowski @ 2019-04-18 13:27 UTC (permalink / raw)
  To: dri-devel, linux-arm-kernel, linux-kernel, linux-sunxi
  Cc: Maxime Ripard, David Airlie, Daniel Vetter, Chen-Yu Tsai,
	Thomas Petazzoni, Paul Kocialkowski

For our component-backed driver to be properly removed, we need to
delete the component master in sun4i_drv_remove and make sure to call
component_unbind_all in the master's unbind so that all components are
unbound when the master is.

Fixes: 9026e0d122ac ("drm: Add Allwinner A10 Display Engine support")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 drivers/gpu/drm/sun4i/sun4i_drv.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index af07291544a4..0ea365e54de1 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -137,6 +137,8 @@ static void sun4i_drv_unbind(struct device *dev)
 	drm_mode_config_cleanup(drm);
 	of_reserved_mem_device_release(dev);
 	drm_dev_put(drm);
+
+	component_unbind_all(dev, NULL);
 }
 
 static const struct component_master_ops sun4i_drv_master_ops = {
@@ -385,6 +387,8 @@ static int sun4i_drv_probe(struct platform_device *pdev)
 
 static int sun4i_drv_remove(struct platform_device *pdev)
 {
+	component_master_del(&pdev->dev, &sun4i_drv_master_ops);
+
 	return 0;
 }
 
-- 
2.21.0


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

* Re: [PATCH 0/3] sun4i/drm: Fixes for removing and re-probing the driver
  2019-04-18 13:27 [PATCH 0/3] sun4i/drm: Fixes for removing and re-probing the driver Paul Kocialkowski
                   ` (2 preceding siblings ...)
  2019-04-18 13:27 ` [PATCH 3/3] drm/sun4i: Fix component unbinding and component master deletion Paul Kocialkowski
@ 2019-04-18 14:27 ` Maxime Ripard
  3 siblings, 0 replies; 7+ messages in thread
From: Maxime Ripard @ 2019-04-18 14:27 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: dri-devel, linux-arm-kernel, linux-kernel, linux-sunxi,
	David Airlie, Daniel Vetter, Chen-Yu Tsai, Thomas Petazzoni

[-- Attachment #1: Type: text/plain, Size: 350 bytes --]

On Thu, Apr 18, 2019 at 03:27:24PM +0200, Paul Kocialkowski wrote:
> This series brings-in some fixes that are necessary to be able to
> remove the driver at run-time (when built as a module) and properly
> re-probe it afterwards.

Applied all three, thanks
Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [linux-sunxi] [PATCH 3/3] drm/sun4i: Fix component unbinding and component master deletion
  2019-04-18 13:27 ` [PATCH 3/3] drm/sun4i: Fix component unbinding and component master deletion Paul Kocialkowski
@ 2019-04-18 15:03   ` Chen-Yu Tsai
  2019-04-18 17:23     ` Paul Kocialkowski
  0 siblings, 1 reply; 7+ messages in thread
From: Chen-Yu Tsai @ 2019-04-18 15:03 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: dri-devel, linux-arm-kernel, linux-kernel, linux-sunxi,
	Maxime Ripard, David Airlie, Daniel Vetter, Thomas Petazzoni

On Thu, Apr 18, 2019 at 6:27 AM Paul Kocialkowski
<paul.kocialkowski@bootlin.com> wrote:
>
> For our component-backed driver to be properly removed, we need to
> delete the component master in sun4i_drv_remove and make sure to call
> component_unbind_all in the master's unbind so that all components are
> unbound when the master is.
>
> Fixes: 9026e0d122ac ("drm: Add Allwinner A10 Display Engine support")
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> ---
>  drivers/gpu/drm/sun4i/sun4i_drv.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> index af07291544a4..0ea365e54de1 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> @@ -137,6 +137,8 @@ static void sun4i_drv_unbind(struct device *dev)
>         drm_mode_config_cleanup(drm);
>         of_reserved_mem_device_release(dev);
>         drm_dev_put(drm);
> +
> +       component_unbind_all(dev, NULL);

Shouldn't this be before drm_dev_put? Everything being in reverse order
of the complement calls in the bind function and all. The component
drivers might still be using the drm dev before they are unbound.

ChenYu

>  }
>
>  static const struct component_master_ops sun4i_drv_master_ops = {
> @@ -385,6 +387,8 @@ static int sun4i_drv_probe(struct platform_device *pdev)
>
>  static int sun4i_drv_remove(struct platform_device *pdev)
>  {
> +       component_master_del(&pdev->dev, &sun4i_drv_master_ops);
> +
>         return 0;
>  }
>
> --
> 2.21.0
>
> --
> You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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

* Re: [linux-sunxi] [PATCH 3/3] drm/sun4i: Fix component unbinding and component master deletion
  2019-04-18 15:03   ` [linux-sunxi] " Chen-Yu Tsai
@ 2019-04-18 17:23     ` Paul Kocialkowski
  0 siblings, 0 replies; 7+ messages in thread
From: Paul Kocialkowski @ 2019-04-18 17:23 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: dri-devel, linux-arm-kernel, linux-kernel, linux-sunxi,
	Maxime Ripard, David Airlie, Daniel Vetter, Thomas Petazzoni

Hi,

Le jeudi 18 avril 2019 à 08:03 -0700, Chen-Yu Tsai a écrit :
> On Thu, Apr 18, 2019 at 6:27 AM Paul Kocialkowski
> <paul.kocialkowski@bootlin.com> wrote:
> > For our component-backed driver to be properly removed, we need to
> > delete the component master in sun4i_drv_remove and make sure to call
> > component_unbind_all in the master's unbind so that all components are
> > unbound when the master is.
> > 
> > Fixes: 9026e0d122ac ("drm: Add Allwinner A10 Display Engine support")
> > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > ---
> >  drivers/gpu/drm/sun4i/sun4i_drv.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> > index af07291544a4..0ea365e54de1 100644
> > --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> > +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> > @@ -137,6 +137,8 @@ static void sun4i_drv_unbind(struct device *dev)
> >         drm_mode_config_cleanup(drm);
> >         of_reserved_mem_device_release(dev);
> >         drm_dev_put(drm);
> > +
> > +       component_unbind_all(dev, NULL);
> 
> Shouldn't this be before drm_dev_put? Everything being in reverse order
> of the complement calls in the bind function and all. The component
> drivers might still be using the drm dev before they are unbound.

Mhh, yes that's a valid concern, thanks for pointing it out. I'll send
out a fix for it tomorrow.

Cheers,

Paul

> ChenYu
> 
> >  }
> > 
> >  static const struct component_master_ops sun4i_drv_master_ops = {
> > @@ -385,6 +387,8 @@ static int sun4i_drv_probe(struct platform_device *pdev)
> > 
> >  static int sun4i_drv_remove(struct platform_device *pdev)
> >  {
> > +       component_master_del(&pdev->dev, &sun4i_drv_master_ops);
> > +
> >         return 0;
> >  }
> > 
> > --
> > 2.21.0
> > 
> > --
> > You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.


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

end of thread, other threads:[~2019-04-18 17:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-18 13:27 [PATCH 0/3] sun4i/drm: Fixes for removing and re-probing the driver Paul Kocialkowski
2019-04-18 13:27 ` [PATCH 1/3] drm/sun4i: Add missing drm_atomic_helper_shutdown at driver unbind Paul Kocialkowski
2019-04-18 13:27 ` [PATCH 2/3] drm/sun4i: Set device driver data at bind time for use in unbind Paul Kocialkowski
2019-04-18 13:27 ` [PATCH 3/3] drm/sun4i: Fix component unbinding and component master deletion Paul Kocialkowski
2019-04-18 15:03   ` [linux-sunxi] " Chen-Yu Tsai
2019-04-18 17:23     ` Paul Kocialkowski
2019-04-18 14:27 ` [PATCH 0/3] sun4i/drm: Fixes for removing and re-probing the driver Maxime Ripard

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