From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: kieran.bingham@ideasonboard.com
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
dri-devel@lists.freedesktop.org,
linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH v2 5/5] drm: rcar-du: Map memory through the VSP device
Date: Mon, 22 May 2017 15:24:22 +0300 [thread overview]
Message-ID: <9845041.8ItKJssoTO@avalon> (raw)
In-Reply-To: <b21c3600-ae8e-f384-08f7-cb4229064259@ideasonboard.com>
Hi Kieran,
On Monday 22 May 2017 13:16:11 Kieran Bingham wrote:
> On 17/05/17 00:20, Laurent Pinchart wrote:
> > For planes handled by a VSP instance, map the framebuffer memory through
> > the VSP to ensure proper IOMMU handling.
> >
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
>
> Looks good except for a small unsigned int comparison causing an infinite
> loop on fail case.
>
> With the loop fixed:
>
> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>
> > ---
> >
> > drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 74 +++++++++++++++++++++++++++---
> > drivers/gpu/drm/rcar-du/rcar_du_vsp.h | 2 +
> > 2 files changed, 70 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> > b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c index b0ff304ce3dc..1b874cfd40f3
> > 100644
> > --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> > +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
[snip]
> > @@ -187,6 +186,67 @@ static void rcar_du_vsp_plane_setup(struct
> > rcar_du_vsp_plane *plane)
> > vsp1_du_atomic_update(plane->vsp->vsp, plane->index, &cfg);
> > }
> >
> > +static int rcar_du_vsp_plane_prepare_fb(struct drm_plane *plane,
> > + struct drm_plane_state *state)
> > +{
> > + struct rcar_du_vsp_plane_state *rstate =
to_rcar_vsp_plane_state(state);
> > + struct rcar_du_vsp *vsp = to_rcar_vsp_plane(plane)->vsp;
> > + struct rcar_du_device *rcdu = vsp->dev;
> > + unsigned int i;
>
> Unsigned here..
>
> > + int ret;
> > +
> > + if (!state->fb)
> > + return 0;
> > +
> > + for (i = 0; i < rstate->format->planes; ++i) {
> > + struct drm_gem_cma_object *gem =
> > + drm_fb_cma_get_gem_obj(state->fb, i);
> > + struct sg_table *sgt = &rstate->sg_tables[i];
> > +
> > + ret = dma_get_sgtable(rcdu->dev, sgt, gem->vaddr, gem->paddr,
> > + gem->base.size);
> > + if (ret)
> > + goto fail;
> > +
> > + ret = vsp1_du_map_sg(vsp->vsp, sgt);
> > + if (!ret) {
> > + sg_free_table(sgt);
> > + ret = -ENOMEM;
> > + goto fail;
> > + }
> > + }
> > +
> > + return 0;
> > +
> > +fail:
> > + for (i--; i >= 0; i--) {
>
> Means that this loop will never exit; i will always be >= 0;
>
> I'd propose just making signed for this usage.
>
> I've checked the i values for the breakouts - so they are good, and we need
> to use i == 0 to unmap the last table.
>
> > + struct sg_table *sgt = &rstate->sg_tables[i];
How about keep i unsigned and using
for (; i > 0; i--) {
struct sg_table *sgt = &rstate->sg_tables[i-1];
...
}
If you want to fix while applying, you can pick your favourite version.
> > +
> > + vsp1_du_unmap_sg(vsp->vsp, sgt);
> > + sg_free_table(sgt);
> > + }
> > +
> > + return ret;
> > +}
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2017-05-22 12:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-16 23:20 [PATCH v2 0/5] R-Car DU: Fix IOMMU operation when connected to VSP Laurent Pinchart
2017-05-16 23:20 ` [PATCH v2 1/5] v4l: rcar-fcp: Don't get/put module reference Laurent Pinchart
2017-05-16 23:20 ` Laurent Pinchart
2017-05-22 11:36 ` Kieran Bingham
2017-05-16 23:20 ` [PATCH v2 2/5] v4l: rcar-fcp: Add an API to retrieve the FCP device Laurent Pinchart
2017-05-22 11:44 ` Kieran Bingham
2017-05-16 23:20 ` [PATCH v2 3/5] v4l: vsp1: Map the DL and video buffers through the proper bus master Laurent Pinchart
2017-05-22 11:47 ` Kieran Bingham
2017-05-16 23:20 ` [PATCH v2 4/5] v4l: vsp1: Add API to map and unmap DRM buffers through the VSP Laurent Pinchart
2017-05-22 11:52 ` Kieran Bingham
2017-05-16 23:20 ` [PATCH v2 5/5] drm: rcar-du: Map memory through the VSP device Laurent Pinchart
2017-05-22 12:15 ` Kieran Bingham
2017-05-22 12:16 ` Kieran Bingham
2017-05-22 12:24 ` Laurent Pinchart [this message]
2017-05-22 12:52 ` Kieran Bingham
2017-05-22 13:00 ` Geert Uytterhoeven
2017-05-22 13:23 ` Laurent Pinchart
2017-05-22 13:40 ` Kieran Bingham
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=9845041.8ItKJssoTO@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kieran.bingham@ideasonboard.com \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linux-renesas-soc@vger.kernel.org \
/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 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.