lkml.org 
[lkml]   [2020]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API
Hi Christoph

On Mon, Nov 30, 2020 at 9:34 AM Christoph Hellwig <hch@lst.de> wrote:
>
> > +#ifndef CONFIG_DMA_NONCOHERENT
>
> I think you need to drop this ifdef. This code should work just fine
> on noncoherent mips and sh platforms.
>
> > + uvc_urb->pages = dma_alloc_noncontiguous(dma_dev, stream->urb_size,
> > + &uvc_urb->dma,
> > + gfp_flags | __GFP_NOWARN, 0);
> > + if (!uvc_urb->pages)
> > + return false;
> > +
> > + uvc_urb->buffer = vmap(uvc_urb->pages,
> > + PAGE_ALIGN(stream->urb_size) >> PAGE_SHIFT,
> > + VM_DMA_COHERENT, PAGE_KERNEL);
> > + if (!uvc_urb->buffer) {
> > + dma_free_noncontiguous(dma_dev, stream->urb_size,
> > + uvc_urb->pages, uvc_urb->dma);
> > + return false;
> > + }
> > +
> > + if (sg_alloc_table_from_pages(&uvc_urb->sgt, uvc_urb->pages,
> > + PAGE_ALIGN(stream->urb_size) >> PAGE_SHIFT, 0,
> > + stream->urb_size, GFP_KERNEL)) {
> > + vunmap(uvc_urb->buffer);
> > + dma_free_noncontiguous(dma_dev, stream->urb_size,
> > + uvc_urb->pages, uvc_urb->dma);
> > + return false;
> > + }
> > +
> > + return true;
> > +}
>
> I wonder if we should lift this into a helper. On the one hand I had
> proliferating struct scatterlist usage, on the other hand it is all over
> the media and drm code anyway, and duplicating this doesn't help anyone.
>
> Possibly including the fallback to the coherent allocating.

Probably Sergey has best opinion of this than mine. I only had to look
into one driver, he has been working with the vb2, which uses the API
much more.



--
Ricardo Ribalda

\
 
 \ /
  Last update: 2020-11-30 11:51    [W:0.153 / U:0.392 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site