public inbox for linux-rockchip@lists.infradead.org
 help / color / mirror / Atom feed
From: Ezequiel Garcia <ezequiel@collabora.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>,
	 linux-media@vger.kernel.org, helen.koike@collabora.com,
	hverkuil@xs4all.nl, kernel@collabora.com, dafna3@gmail.com,
	sakari.ailus@linux.intel.com,
	 linux-rockchip@lists.infradead.org, mchehab@kernel.org,
	tfiga@chromium.org
Subject: Re: [PATCH 2/2] media: rkisp1: cap: initialize dma buf address in 'buf_init' cb
Date: Mon, 28 Jun 2021 09:13:45 -0300	[thread overview]
Message-ID: <ccd40da84dba10f13f5d385850afaa7470b72105.camel@collabora.com> (raw)
In-Reply-To: <YNl3TPzoNhUTpkDO@pendragon.ideasonboard.com>

On Mon, 2021-06-28 at 10:16 +0300, Laurent Pinchart wrote:
> On Fri, Jun 25, 2021 at 10:08:44PM -0300, Ezequiel Garcia wrote:
> > On Fri, 2021-06-25 at 11:23 +0300, Dafna Hirschfeld wrote:
> > > Initializing the dma addresses of the capture buffers can
> > > move to the 'buf_init' callback, since it is enough to do
> > > it once for each buffer and not every time it is queued.
> > 
> > Are you able to measure any impact with this change?
> > 
> > > Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
> > > ---
> > >  .../media/platform/rockchip/rkisp1/rkisp1-capture.c  | 12 +++++++++++-
> > >  1 file changed, 11 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c
> > > index 60cd2200e7ae..41988eb0ec0a 100644
> > > --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c
> > > +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c
> > > @@ -750,7 +750,7 @@ static int rkisp1_vb2_queue_setup(struct vb2_queue *queue,
> > >         return 0;
> > >  }
> > >  
> > > -static void rkisp1_vb2_buf_queue(struct vb2_buffer *vb)
> > > +static int rkisp1_vb2_buf_init(struct vb2_buffer *vb)
> > >  {
> > >         struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
> > >         struct rkisp1_buffer *ispbuf =
> > 
> > Since you are interested at these kind of cleanups, you can
> > do something like:
> > 
> > +enum rkisp1_plane {
> > +       RKISP1_PLANE_Y  = 0,
> > +       RKISP1_PLANE_CB = 1,
> > +       RKISP1_PLANE_CR = 2,
> > +       RKISP1_NUM_PLANES = 3
> > +};
> > +
> >  /*
> >   * struct rkisp1_buffer - A container for the vb2 buffers used by the video devices:
> >   *                       params, stats, mainpath, selfpath
> > @@ -160,7 +167,7 @@ struct rkisp1_vdev_node {
> >  struct rkisp1_buffer {
> >         struct vb2_v4l2_buffer vb;
> >         struct list_head queue;
> > -       u32 buff_addr[VIDEO_MAX_PLANES];
> > +       u32 buff_addr[RKISP1_NUM_PLANES];
> >  };
> > 
> > And then you can get rid of the memset, and rely on
> > vb2_dma_contig_plane_dma_addr returning NULL.
> > 
> > @@ -759,8 +753,7 @@ static void rkisp1_vb2_buf_queue(struct vb2_buffer *vb)
> >         const struct v4l2_pix_format_mplane *pixm = &cap->pix.fmt;
> >         unsigned int i;
> >  
> > -       memset(ispbuf->buff_addr, 0, sizeof(ispbuf->buff_addr));
> > -       for (i = 0; i < pixm->num_planes; i++)
> > +       for (i = 0; i < RKISP1_NUM_PLANES; i++)
> 
> This should use ARRAY_SIZE().
> 
> >                 ispbuf->buff_addr[i] = vb2_dma_contig_plane_dma_addr(vb, i);
> 
> But will vb2_dma_contig_plane_dma_addr() be happy when i is larger than
> the number of planes ?
> 

Well, vb2_plane_cookie handles it. TBH, not sure it's a behavior we should
rely on, but it's there.
-- 
Kindly,
Ezequiel


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

  reply	other threads:[~2021-06-28 12:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-25  8:23 [PATCH 0/2] rkisp1: Two small fixes Dafna Hirschfeld
2021-06-25  8:23 ` [PATCH 1/2] media: rkisp1: remove field 'vaddr' from 'rkisp1_buffer' Dafna Hirschfeld
2021-06-26  0:51   ` Ezequiel Garcia
2021-06-25  8:23 ` [PATCH 2/2] media: rkisp1: cap: initialize dma buf address in 'buf_init' cb Dafna Hirschfeld
2021-06-26  1:08   ` Ezequiel Garcia
2021-06-28  7:16     ` Laurent Pinchart
2021-06-28 12:13       ` Ezequiel Garcia [this message]
2021-07-12 13:21     ` Dafna Hirschfeld
2021-06-28  5:46 ` [PATCH 0/2] rkisp1: Two small fixes Tomasz Figa

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=ccd40da84dba10f13f5d385850afaa7470b72105.camel@collabora.com \
    --to=ezequiel@collabora.com \
    --cc=dafna.hirschfeld@collabora.com \
    --cc=dafna3@gmail.com \
    --cc=helen.koike@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=kernel@collabora.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tfiga@chromium.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox