Re: [Freedreno] [PATCH] drm: convert DT component matching to component_match_add_release()

2016-10-21 Thread Russell King - ARM Linux
On Thu, Oct 20, 2016 at 07:15:56PM -0400, Sean Paul wrote:
> On Thu, Oct 20, 2016 at 5:50 PM, Russell King - ARM Linux
>  wrote:
> > On Thu, Oct 20, 2016 at 04:39:04PM -0400, Sean Paul wrote:
> >> On Wed, Oct 19, 2016 at 6:28 AM, Russell King
> >>  wrote:
> >> > Convert DT component matching to use component_match_add_release().
> >> >
> >> > Signed-off-by: Russell King 
> >> > ---
> >> > Can we please get this patch from May merged into the drm-misc or
> >> > whatever trees so that we don't end up with conflicts?  I've no idea
> >> > who looks after drm-misc, as they have _still_ failed to add
> >> > themselves to MAINTAINERS.
> >>
> >> I think Daniel explained pretty clearly why this wasn't happening in
> >> the previous thread.
> >>
> >> Next time you send a v2, can you please mark it as such and include a
> >> "Changes in v2" section?
> >
> > Why - nothing's changed other than a rebase onto 4.9-rc1.  This isn't
> > a "I've changed it in XYZ way, so here's a new copy".
> 
> 
> Changes in v2: None
> 
> Is still useful since:
> a) the diffstat is different from v1, which necessitates me going
> through both versions to see what's changed from the previous reviews
> (only to find out myself that it's been rebased and a function has
> changed names)

Sorry, but I don't track in any fine detail what the changes are
between patches when I bring them forward: I have far too many patches
to do that (I have 300 right now) and I never know whether they're
going to result in a pull request or not.  It means finding some way
to manually attach a change log to each patch I send out, which will
be very time consuming.  I'd rather not send patches out than jump
through hoops like that, especially when the reason is that the
previous version was ignored.

> b) in June, you said you were going to roll a new version with the
> common OF bits extracted. it's nice to know at the outset that this
> has/hasn't happened

Now if you were following the rest of it, rather than just random parts
that suited you, you'd have noticed that I posted the new version, but
that caused more issues, so I publically said I was reverting back to
the original version.

> Also, prefacing the subject with [PATCH v2] or [PATCH RESEND] lets me
> know there is prior history with the change. Reading the previous
> version is helpful to see what reviewer's concerns were, and whether
> they've been addressed.

Yea, I'm very bad at changing the subject line in that way, and I'm
getting worse at it.  Sorry, I try my best, but I can't do better than
that.

> 
> 
> > It's being
> > posted in the hope that someone will finally either comment on it or
> > merge the damn thing, rather than ignoring it was done when it was
> > last posted.
> >
> >> >  drivers/gpu/drm/arm/hdlcd_drv.c |  3 ++-
> >> >  drivers/gpu/drm/arm/malidp_drv.c|  4 +++-
> >> >  drivers/gpu/drm/armada/armada_drv.c |  2 +-
> >> >  drivers/gpu/drm/drm_of.c| 28 
> >> > +++--
> >> >  drivers/gpu/drm/etnaviv/etnaviv_drv.c   |  5 +++--
> >> >  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ---
> >> >  drivers/gpu/drm/mediatek/mtk_drm_drv.c  |  4 +++-
> >> >  drivers/gpu/drm/msm/msm_drv.c   | 12 ++-
> >> >  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |  6 --
> >> >  drivers/gpu/drm/sti/sti_drv.c   |  5 +++--
> >> >  drivers/gpu/drm/sun4i/sun4i_drv.c   |  3 ++-
> >> >  drivers/gpu/drm/tilcdc/tilcdc_external.c|  4 +++-
> >> >  include/drm/drm_of.h| 12 +++
> >> >  13 files changed, 73 insertions(+), 22 deletions(-)
> >> >
> >> > diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c 
> >> > b/drivers/gpu/drm/arm/hdlcd_drv.c
> >> > index fb6a418ce6be..6477d1a65266 100644
> >> > --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> >> > +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> >> > @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
> >> > return -EAGAIN;
> >> > }
> >> >
> >> > -   component_match_add(>dev, , compare_dev, port);
> >> > +   drm_of_component_match_add(>dev, , compare_dev, 
> >> > port);
> >> > +   of_node_put(port);
> >>
> >> There's no mention in your commit message about fixing these node leaks.
> >
> > Isn't that kind-of the whole point of this patch?
> >
> 
> Not according to the commit msg, it isn't.
> 
> You could have just done the of_node_put adds/relocations without
> wrapping component_match_add_release.

No, adding the of_node_put() there without the other changes means that
the OF layer can drop the "port" device node, kfree() it, and reallocate
it as a different device node - which means that we can end up matching
some random other device rather than the intended one.  Hence, it is
_fundamentally_ a part of this patch and isn't an independent 

Re: [Freedreno] [PATCH] drm: convert DT component matching to component_match_add_release()

2016-10-20 Thread Russell King - ARM Linux
On Thu, Oct 20, 2016 at 04:39:04PM -0400, Sean Paul wrote:
> On Wed, Oct 19, 2016 at 6:28 AM, Russell King
>  wrote:
> > Convert DT component matching to use component_match_add_release().
> >
> > Signed-off-by: Russell King 
> > ---
> > Can we please get this patch from May merged into the drm-misc or
> > whatever trees so that we don't end up with conflicts?  I've no idea
> > who looks after drm-misc, as they have _still_ failed to add
> > themselves to MAINTAINERS.
> 
> I think Daniel explained pretty clearly why this wasn't happening in
> the previous thread.
> 
> Next time you send a v2, can you please mark it as such and include a
> "Changes in v2" section?

Why - nothing's changed other than a rebase onto 4.9-rc1.  This isn't
a "I've changed it in XYZ way, so here's a new copy".  It's being
posted in the hope that someone will finally either comment on it or
merge the damn thing, rather than ignoring it was done when it was
last posted.

> >  drivers/gpu/drm/arm/hdlcd_drv.c |  3 ++-
> >  drivers/gpu/drm/arm/malidp_drv.c|  4 +++-
> >  drivers/gpu/drm/armada/armada_drv.c |  2 +-
> >  drivers/gpu/drm/drm_of.c| 28 
> > +++--
> >  drivers/gpu/drm/etnaviv/etnaviv_drv.c   |  5 +++--
> >  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ---
> >  drivers/gpu/drm/mediatek/mtk_drm_drv.c  |  4 +++-
> >  drivers/gpu/drm/msm/msm_drv.c   | 12 ++-
> >  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |  6 --
> >  drivers/gpu/drm/sti/sti_drv.c   |  5 +++--
> >  drivers/gpu/drm/sun4i/sun4i_drv.c   |  3 ++-
> >  drivers/gpu/drm/tilcdc/tilcdc_external.c|  4 +++-
> >  include/drm/drm_of.h| 12 +++
> >  13 files changed, 73 insertions(+), 22 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c 
> > b/drivers/gpu/drm/arm/hdlcd_drv.c
> > index fb6a418ce6be..6477d1a65266 100644
> > --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> > +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> > @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
> > return -EAGAIN;
> > }
> >
> > -   component_match_add(>dev, , compare_dev, port);
> > +   drm_of_component_match_add(>dev, , compare_dev, port);
> > +   of_node_put(port);
> 
> There's no mention in your commit message about fixing these node leaks.

Isn't that kind-of the whole point of this patch?

> >
> > return component_master_add_with_match(>dev, 
> > _master_ops,
> >match);
> > diff --git a/drivers/gpu/drm/arm/malidp_drv.c 
> > b/drivers/gpu/drm/arm/malidp_drv.c
> > index 9280358b8f15..9f4739452a25 100644
> > --- a/drivers/gpu/drm/arm/malidp_drv.c
> > +++ b/drivers/gpu/drm/arm/malidp_drv.c
> > @@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device 
> > *pdev)
> > return -EAGAIN;
> > }
> >
> > -   component_match_add(>dev, , malidp_compare_dev, port);
> > +   drm_of_component_match_add(>dev, , malidp_compare_dev,
> > +  port);
> > +   of_node_put(port);
> > return component_master_add_with_match(>dev, 
> > _master_ops,
> >match);
> >  }
> > diff --git a/drivers/gpu/drm/armada/armada_drv.c 
> > b/drivers/gpu/drm/armada/armada_drv.c
> > index 1e0e68f608e4..94e46da9a758 100644
> > --- a/drivers/gpu/drm/armada/armada_drv.c
> > +++ b/drivers/gpu/drm/armada/armada_drv.c
> > @@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
> > continue;
> > }
> >
> > -   component_match_add(dev, match, compare_of, remote);
> > +   drm_of_component_match_add(dev, match, compare_of, remote);
> > of_node_put(remote);
> > }
> >  }
> > diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> > index bc98bb94264d..47848ed8ca48 100644
> > --- a/drivers/gpu/drm/drm_of.c
> > +++ b/drivers/gpu/drm/drm_of.c
> > @@ -6,6 +6,11 @@
> >  #include 
> >  #include 
> >
> > +static void drm_release_of(struct device *dev, void *data)
> > +{
> > +   of_node_put(data);
> > +}
> > +
> >  /**
> >   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
> >   * @dev: DRM device
> > @@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device 
> > *dev,
> >  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
> >
> >  /**
> > + * drm_of_component_match_add - Add a component helper OF node match rule
> > + * @master: master device
> > + * @matchptr: component match pointer
> > + * @compare: compare function used for matching component
> > + * @node: of_node
> > + */
> > +void drm_of_component_match_add(struct device *master,
> > +   struct 

Re: [Freedreno] [PATCH] drm: convert DT component matching to component_match_add_release()

2016-10-20 Thread Sean Paul
On Wed, Oct 19, 2016 at 6:28 AM, Russell King
 wrote:
> Convert DT component matching to use component_match_add_release().
>
> Signed-off-by: Russell King 
> ---
> Can we please get this patch from May merged into the drm-misc or
> whatever trees so that we don't end up with conflicts?  I've no idea
> who looks after drm-misc, as they have _still_ failed to add
> themselves to MAINTAINERS.

I think Daniel explained pretty clearly why this wasn't happening in
the previous thread.

Next time you send a v2, can you please mark it as such and include a
"Changes in v2" section?

>
>  drivers/gpu/drm/arm/hdlcd_drv.c |  3 ++-
>  drivers/gpu/drm/arm/malidp_drv.c|  4 +++-
>  drivers/gpu/drm/armada/armada_drv.c |  2 +-
>  drivers/gpu/drm/drm_of.c| 28 
> +++--
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c   |  5 +++--
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c  |  4 +++-
>  drivers/gpu/drm/msm/msm_drv.c   | 12 ++-
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |  6 --
>  drivers/gpu/drm/sti/sti_drv.c   |  5 +++--
>  drivers/gpu/drm/sun4i/sun4i_drv.c   |  3 ++-
>  drivers/gpu/drm/tilcdc/tilcdc_external.c|  4 +++-
>  include/drm/drm_of.h| 12 +++
>  13 files changed, 73 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index fb6a418ce6be..6477d1a65266 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
> return -EAGAIN;
> }
>
> -   component_match_add(>dev, , compare_dev, port);
> +   drm_of_component_match_add(>dev, , compare_dev, port);
> +   of_node_put(port);

There's no mention in your commit message about fixing these node leaks.

>
> return component_master_add_with_match(>dev, _master_ops,
>match);
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c 
> b/drivers/gpu/drm/arm/malidp_drv.c
> index 9280358b8f15..9f4739452a25 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device 
> *pdev)
> return -EAGAIN;
> }
>
> -   component_match_add(>dev, , malidp_compare_dev, port);
> +   drm_of_component_match_add(>dev, , malidp_compare_dev,
> +  port);
> +   of_node_put(port);
> return component_master_add_with_match(>dev, _master_ops,
>match);
>  }
> diff --git a/drivers/gpu/drm/armada/armada_drv.c 
> b/drivers/gpu/drm/armada/armada_drv.c
> index 1e0e68f608e4..94e46da9a758 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
> continue;
> }
>
> -   component_match_add(dev, match, compare_of, remote);
> +   drm_of_component_match_add(dev, match, compare_of, remote);
> of_node_put(remote);
> }
>  }
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..47848ed8ca48 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -6,6 +6,11 @@
>  #include 
>  #include 
>
> +static void drm_release_of(struct device *dev, void *data)
> +{
> +   of_node_put(data);
> +}
> +
>  /**
>   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>   * @dev: DRM device
> @@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
>
>  /**
> + * drm_of_component_match_add - Add a component helper OF node match rule
> + * @master: master device
> + * @matchptr: component match pointer
> + * @compare: compare function used for matching component
> + * @node: of_node
> + */
> +void drm_of_component_match_add(struct device *master,
> +   struct component_match **matchptr,
> +   int (*compare)(struct device *, void *),
> +   struct device_node *node)
> +{
> +   of_node_get(node);
> +   component_match_add_release(master, matchptr, drm_release_of,
> +   compare, node);
> +}
> +EXPORT_SYMBOL_GPL(drm_of_component_match_add);
> +
> +/**
>   * drm_of_component_probe - Generic probe function for a component based 
> master
>   * @dev: master device containing the OF node
>   * @compare_of: compare function used for matching components
> @@ -101,7 +124,7 @@ int 

Re: [Freedreno] [PATCH] drm: convert DT component matching to component_match_add_release()

2016-10-20 Thread Daniel Vetter
On Wed, Oct 19, 2016 at 11:28:27AM +0100, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
> 
> Signed-off-by: Russell King 
> ---
> Can we please get this patch from May merged into the drm-misc or
> whatever trees so that we don't end up with conflicts?  I've no idea
> who looks after drm-misc, as they have _still_ failed to add
> themselves to MAINTAINERS.

Can pick, once someone from the arm world smashes at least an ack on this.
But I have no clue about of/DT, so won't just merge it.

And yes drm-misc will get a MAINTAINERS entry, after ks, because there's
some things to discuss about what that one needs to look like.
-Daniel

> 
>  drivers/gpu/drm/arm/hdlcd_drv.c |  3 ++-
>  drivers/gpu/drm/arm/malidp_drv.c|  4 +++-
>  drivers/gpu/drm/armada/armada_drv.c |  2 +-
>  drivers/gpu/drm/drm_of.c| 28 
> +++--
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c   |  5 +++--
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c  |  4 +++-
>  drivers/gpu/drm/msm/msm_drv.c   | 12 ++-
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |  6 --
>  drivers/gpu/drm/sti/sti_drv.c   |  5 +++--
>  drivers/gpu/drm/sun4i/sun4i_drv.c   |  3 ++-
>  drivers/gpu/drm/tilcdc/tilcdc_external.c|  4 +++-
>  include/drm/drm_of.h| 12 +++
>  13 files changed, 73 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index fb6a418ce6be..6477d1a65266 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>   return -EAGAIN;
>   }
>  
> - component_match_add(>dev, , compare_dev, port);
> + drm_of_component_match_add(>dev, , compare_dev, port);
> + of_node_put(port);
>  
>   return component_master_add_with_match(>dev, _master_ops,
>  match);
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c 
> b/drivers/gpu/drm/arm/malidp_drv.c
> index 9280358b8f15..9f4739452a25 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device 
> *pdev)
>   return -EAGAIN;
>   }
>  
> - component_match_add(>dev, , malidp_compare_dev, port);
> + drm_of_component_match_add(>dev, , malidp_compare_dev,
> +port);
> + of_node_put(port);
>   return component_master_add_with_match(>dev, _master_ops,
>  match);
>  }
> diff --git a/drivers/gpu/drm/armada/armada_drv.c 
> b/drivers/gpu/drm/armada/armada_drv.c
> index 1e0e68f608e4..94e46da9a758 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
>   continue;
>   }
>  
> - component_match_add(dev, match, compare_of, remote);
> + drm_of_component_match_add(dev, match, compare_of, remote);
>   of_node_put(remote);
>   }
>  }
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..47848ed8ca48 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -6,6 +6,11 @@
>  #include 
>  #include 
>  
> +static void drm_release_of(struct device *dev, void *data)
> +{
> + of_node_put(data);
> +}
> +
>  /**
>   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>   * @dev: DRM device
> @@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
>  
>  /**
> + * drm_of_component_match_add - Add a component helper OF node match rule
> + * @master: master device
> + * @matchptr: component match pointer
> + * @compare: compare function used for matching component
> + * @node: of_node
> + */
> +void drm_of_component_match_add(struct device *master,
> + struct component_match **matchptr,
> + int (*compare)(struct device *, void *),
> + struct device_node *node)
> +{
> + of_node_get(node);
> + component_match_add_release(master, matchptr, drm_release_of,
> + compare, node);
> +}
> +EXPORT_SYMBOL_GPL(drm_of_component_match_add);
> +
> +/**
>   * drm_of_component_probe - Generic probe function for a component based 
> master
>   * @dev: master device containing the OF node
>   * @compare_of: compare function used for matching components
> @@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
>