From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org,
Hans Verkuil <hans.verkuil@cisco.com>,
Sakari Ailus <sakari.ailus@iki.fi>,
Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
Florian Echtler <floe@butterbrot.org>,
Federico Vaga <federico.vaga@gmail.com>,
"Lad, Prabhakar" <prabhakar.csengg@gmail.com>,
Scott Jiang <scott.jiang.linux@gmail.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Fabien Dessenne <fabien.dessenne@st.com>,
Benoit Parrot <bparrot@ti.com>,
Mikhail Ulyanov <mikhail.ulyanov@cogentembedded.com>,
Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
Javier Martin <javier.martin@vista-silicon.com>,
Jonathan Corbet <corbet@lwn.net>,
Ludovic Desroches <ludovic.desroches@atmel.com>,
Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
Sylwester Nawrocki <s.nawrocki@samsung.com>
Subject: Re: [PATCHv3 01/12] vb2: add a dev field to use for the default allocation context
Date: Mon, 25 Apr 2016 17:03:21 +0300 [thread overview]
Message-ID: <2233231.mOPctrYVgM@avalon> (raw)
In-Reply-To: <571DC685.1040901@xs4all.nl>
Hi Hans,
On Monday 25 Apr 2016 09:25:57 Hans Verkuil wrote:
> On 04/24/2016 11:51 PM, Laurent Pinchart wrote:
> > On Saturday 23 Apr 2016 12:37:10 Hans Verkuil wrote:
> >> On 04/23/2016 02:14 AM, Laurent Pinchart wrote:
> >>> On Friday 22 Apr 2016 10:38:08 Hans Verkuil wrote:
> >>>> From: Hans Verkuil <hans.verkuil@cisco.com>
> >>>>
> >>>> The allocation context is nothing more than a per-plane device pointer
> >>>> to use when allocating buffers. So just provide a dev pointer in
> >>>> vb2_queue for that purpose and drivers can skip
> >>>> allocating/releasing/filling in the allocation context unless they
> >>>> require different per-plane device pointers as used by some Samsung
> >>>> SoCs.
> >>>>
> >>>> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> >>>> Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
> >>>> Cc: Sakari Ailus <sakari.ailus@iki.fi>
> >>>> Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> >>>> Cc: Florian Echtler <floe@butterbrot.org>
> >>>> Cc: Federico Vaga <federico.vaga@gmail.com>
> >>>> Cc: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
> >>>> Cc: Scott Jiang <scott.jiang.linux@gmail.com>
> >>>> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> >>>> Cc: Fabien Dessenne <fabien.dessenne@st.com>
> >>>> Cc: Benoit Parrot <bparrot@ti.com>
> >>>> Cc: Mikhail Ulyanov <mikhail.ulyanov@cogentembedded.com>
> >>>> Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> >>>> Cc: Javier Martin <javier.martin@vista-silicon.com>
> >>>> Cc: Jonathan Corbet <corbet@lwn.net>
> >>>> Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
> >>>> Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
> >>>> Cc: Kyungmin Park <kyungmin.park@samsung.com>
> >>>> Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
> >>>> ---
> >>>>
> >>>> drivers/media/v4l2-core/videobuf2-core.c | 16 +++++++++-------
> >>>> include/media/videobuf2-core.h | 3 +++
> >>>> 2 files changed, 12 insertions(+), 7 deletions(-)
> >>>>
> >>>> diff --git a/drivers/media/v4l2-core/videobuf2-core.c
> >>>> b/drivers/media/v4l2-core/videobuf2-core.c index 5d016f4..88b5e48
> >>>> 100644
> >>>> --- a/drivers/media/v4l2-core/videobuf2-core.c
> >>>> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> >>>> @@ -206,8 +206,9 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer
> >>>> *vb)
> >>>>
> >>>> for (plane = 0; plane < vb->num_planes; ++plane) {
> >>>>
> >>>> unsigned long size = PAGE_ALIGN(vb->planes[plane].length);
> >>>>
> >>>> - mem_priv = call_ptr_memop(vb, alloc, q->alloc_ctx[plane],
> >>>> - size, dma_dir, q->gfp_flags);
> >>>> + mem_priv = call_ptr_memop(vb, alloc,
> >>>> + q->alloc_ctx[plane] ? : &q->dev,
> >>>> + size, dma_dir, q->gfp_flags);
> >>>
> >>> While the videobuf2-dma-sg allocation context indeed only contains a
> >>> pointer to the device, the videobuf2-dma-contig context also contains a
> >>> dma_attrs. This patch will break the videobuf2-dma-contig alloc
> >>> implementation.
> >>
> >> Good point. I fixed this in the last patch, but that would mean
> >> dma-contig would be broken for the patches in between.
> >>
> >> I'm moving dma_attrs to struct vb2_queue as the first patch, then the
> >> rest will work fine.
> >
> > Couldn't a driver require different dma attributes per plane ? Would it
> > make sense to keep the allocation context structure, and use the struct
> > device and dma attributes stored in the queue when no allocation context
> > is provided ?
>
> I kept the dma_attrs part simple for two reasons:
>
> 1) No driver in the kernel uses it.
> 2) I really can't think of any scenario where you get different DMA attrs
> per plane. Perhaps if we make it possible to have a variable number of
> planes, but all that is in the future and I rather take care of it when we
> actually know what we need.
>
> The 'allocation context' idea was simply a bad one: you're stuck with void
> pointers (I hate those) and always having to check for ENOMEM when
> allocating them. When all you need in almost all cases is just a device
> pointer.
Fair enough, we can add support for different DMA attributes later if we end
up needed that.
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2016-04-25 14:03 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-22 8:38 [PATCHv3 00/12] vb2: replace allocation context by device pointer Hans Verkuil
2016-04-22 8:38 ` [PATCHv3 01/12] vb2: add a dev field to use for the default allocation context Hans Verkuil
2016-04-22 8:54 ` Philipp Zabel
2016-04-23 0:14 ` Laurent Pinchart
2016-04-23 10:37 ` Hans Verkuil
2016-04-24 21:51 ` Laurent Pinchart
2016-04-25 7:25 ` Hans Verkuil
2016-04-25 14:03 ` Laurent Pinchart [this message]
2016-04-22 8:38 ` [PATCHv3 02/12] v4l2-pci-skeleton: set q->dev instead of allocating a context Hans Verkuil
2016-04-22 8:38 ` [PATCHv3 03/12] sur40: " Hans Verkuil
2016-04-22 8:38 ` [PATCHv3 04/12] media/pci: convert drivers to use the new vb2_queue dev field Hans Verkuil
2016-04-22 8:38 ` [PATCHv3 05/12] staging/media: " Hans Verkuil
2016-04-23 0:17 ` Laurent Pinchart
2016-04-24 20:59 ` Lad, Prabhakar
2016-04-22 8:38 ` [PATCHv3 06/12] media/platform: " Hans Verkuil
2016-04-22 8:54 ` Philipp Zabel
2016-04-22 8:38 ` [PATCHv3 07/12] " Hans Verkuil
2016-04-23 0:20 ` Laurent Pinchart
2016-04-22 8:38 ` [PATCHv3 08/12] " Hans Verkuil
2016-04-23 0:23 ` Laurent Pinchart
2016-04-22 8:38 ` [PATCHv3 09/12] media/.../soc-camera: " Hans Verkuil
2016-04-22 8:38 ` [PATCHv3 10/12] media/platform: " Hans Verkuil
2016-04-22 8:38 ` [PATCHv3 11/12] " Hans Verkuil
2016-04-22 8:38 ` [PATCHv3 12/12] vb2: replace void *alloc_ctxs by struct device *alloc_devs Hans Verkuil
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=2233231.mOPctrYVgM@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=bparrot@ti.com \
--cc=corbet@lwn.net \
--cc=fabien.dessenne@st.com \
--cc=federico.vaga@gmail.com \
--cc=floe@butterbrot.org \
--cc=g.liakhovetski@gmx.de \
--cc=hans.verkuil@cisco.com \
--cc=hverkuil@xs4all.nl \
--cc=javier.martin@vista-silicon.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-media@vger.kernel.org \
--cc=ludovic.desroches@atmel.com \
--cc=mchehab@osg.samsung.com \
--cc=mikhail.ulyanov@cogentembedded.com \
--cc=p.zabel@pengutronix.de \
--cc=prabhakar.csengg@gmail.com \
--cc=s.nawrocki@samsung.com \
--cc=sakari.ailus@iki.fi \
--cc=scott.jiang.linux@gmail.com \
--cc=sergei.shtylyov@cogentembedded.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).