diff mbox series

[3/3] drm/sun4i: Fix component unbinding and component master deletion

Message ID 20190418132727.5128-4-paul.kocialkowski@bootlin.com (mailing list archive)
State New, archived
Headers show
Series sun4i/drm: Fixes for removing and re-probing the driver | expand

Commit Message

Paul Kocialkowski April 18, 2019, 1:27 p.m. UTC
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(+)

Comments

Chen-Yu Tsai April 18, 2019, 3:03 p.m. UTC | #1
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.
Paul Kocialkowski April 18, 2019, 5:23 p.m. UTC | #2
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.
diff mbox series

Patch

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;
 }