[RFC, v2, 10/11] vb2: dma-contig: Let drivers decide DMA attrs of MMAP and USERPTR bufs
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Fri Apr 7 11:42:46 UTC 2017
Hi Ricky,
On Monday 26 Dec 2016 15:58:07 Ricky Liang wrote:
> On Fri, Dec 16, 2016 at 9:24 AM, Laurent Pinchart wrote:
> > From: Sakari Ailus <sakari.ailus at linux.intel.com>
> >
> > The desirable DMA attributes are not generic for all devices using
> > Videobuf2 contiguous DMA ops. Let the drivers decide.
> >
> > This change also results in MMAP buffers always having an sg_table
> > (dma_sgt field).
> >
> > Also arrange the header files alphabetically.
> >
> > As a result, also the DMA-BUF exporter must provide ops for synchronising
> > the cache. This adds begin_cpu_access and end_cpu_access ops to
> > vb2_dc_dmabuf_ops.
> >
> > Signed-off-by: Sakari Ailus <sakari.ailus at linux.intel.com>
> > ---
> >
> > drivers/media/v4l2-core/videobuf2-dma-contig.c | 66 +++++++++++++++++----
> > 1 file changed, 56 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c
> > b/drivers/media/v4l2-core/videobuf2-dma-contig.c index
> > d503647ea522..a0e88ad93f07 100644
> > --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
> > +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
[snip]
> > @@ -115,8 +115,11 @@ static void vb2_dc_prepare(void *buf_priv)
> > struct vb2_dc_buf *buf = buf_priv;
> > struct sg_table *sgt = buf->dma_sgt;
> >
> > - /* DMABUF exporter will flush the cache for us */
> > - if (!buf->vec)
> > + /*
> > + * DMABUF exporter will flush the cache for us; only USERPTR
> > + * and MMAP buffers with non-coherent memory will be flushed.
> > + */
> > + if (!(buf->attrs & DMA_ATTR_NON_CONSISTENT))
>
> Should here be "if (!buf->vec || !(buf->attrs & DMA_ATTR_NON_CONSISTENT))" ?
I don't think so. buf->vec indicates that the buffer is using USERPTR. The
check would thus return immediately for everything that is not USERPTR. What
we want to do is return for DMABUF, and for MMAP and USERPTR buffers that
don't have the DMA_ATTR_NON_CONSISTENT attribute set. As DMABUF buffers never
have that attribute set (because attrs is set in vb2_dc_alloc, which is not
called for DMABUF buffers), we can check the flag only.
> > return;
> >
> > dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->orig_nents,
--
Regards,
Laurent Pinchart
More information about the dri-devel
mailing list