From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
dri-devel@lists.freedesktop.org,
linux-renesas-soc@vger.kernel.org, Yu Kuai <yukuai3@huawei.com>,
yi.zhang@huawei.com
Subject: Re: [PATCH] drm: rcar-du: Put reference to VSP device
Date: Thu, 17 Sep 2020 03:43:45 +0300 [thread overview]
Message-ID: <20200917004345.GO3853@pendragon.ideasonboard.com> (raw)
In-Reply-To: <1deb9fc0-7f87-ed4a-d719-401e08ad83ca@ideasonboard.com>
Hi Kieran,
On Wed, Sep 16, 2020 at 11:26:36AM +0100, Kieran Bingham wrote:
> On 16/09/2020 00:38, Laurent Pinchart wrote:
> > The reference to the VSP device acquired with of_find_device_by_node()
> > in rcar_du_vsp_init() is never released. Fix it with a drmm action,
> > which gets run both in the probe error path and in the remove path.
> >
> > Fixes: 6d62ef3ac30b ("drm: rcar-du: Expose the VSP1 compositor through KMS planes")
> > Reported-by: Yu Kuai <yukuai3@huawei.com>
> > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
>
> Looks nice and clean!
>
> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>
> > ---
> > drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> > index f1a81c9b184d..fa09b3ae8b9d 100644
> > --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> > +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> > @@ -13,6 +13,7 @@
> > #include <drm/drm_fourcc.h>
> > #include <drm/drm_gem_cma_helper.h>
> > #include <drm/drm_gem_framebuffer_helper.h>
> > +#include <drm/drm_managed.h>
> > #include <drm/drm_plane_helper.h>
> > #include <drm/drm_vblank.h>
> >
> > @@ -341,6 +342,13 @@ static const struct drm_plane_funcs rcar_du_vsp_plane_funcs = {
> > .atomic_destroy_state = rcar_du_vsp_plane_atomic_destroy_state,
> > };
> >
> > +static void rcar_du_vsp_cleanup(struct drm_device *dev, void *res)
> > +{
> > + struct rcar_du_vsp *vsp = res;
> > +
> > + put_device(vsp->vsp);
>
> Ugh the asymmetry of the put_device is a bit annoying, because it's not
> initially clear that the of_find_device_by_node() call 'gets' a reference.
>
> (Or at least not until you find:
> https://lore.kernel.org/patchwork/patch/731284/)
>
> It is stated in the commit message though so that's fine, and although I
> thought perhaps a comment here might be useful to declare that it
> releases the reference taken by of_find_device_by_node(), I'm not sure
> it even adds that much value ... so either way.
I think that the fact that drmm_add_action() is called right after
of_find_device_by_node() makes this explicit enough.
> > +}
> > +
> > int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np,
> > unsigned int crtcs)
> > {
> > @@ -357,6 +365,10 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np,
> >
> > vsp->vsp = &pdev->dev;
> >
> > + ret = drmm_add_action(rcdu->ddev, rcar_du_vsp_cleanup, vsp);
> > + if (ret < 0)
> > + return ret;
> > +
> > ret = vsp1_du_init(vsp->vsp);
> > if (ret < 0)
> > return ret;
> >
>
--
Regards,
Laurent Pinchart
prev parent reply other threads:[~2020-09-17 0:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-10 13:23 [PATCH] drm: rcar-du: add missing put_device() call in rcar_du_vsp_init() Yu Kuai
2020-09-15 23:30 ` Laurent Pinchart
2020-09-15 23:38 ` [PATCH] drm: rcar-du: Put reference to VSP device Laurent Pinchart
2020-09-16 10:26 ` Kieran Bingham
2020-09-17 0:43 ` Laurent Pinchart [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200917004345.GO3853@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kieran.bingham+renesas@ideasonboard.com \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).