lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 1 Dec 2020 12:36:58 +0900
From:   Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
To:     Christoph Hellwig <hch@....de>
Cc:     Ricardo Ribalda <ribalda@...omium.org>,
        Marek Szyprowski <m.szyprowski@...sung.com>,
        Robin Murphy <robin.murphy@....com>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        IOMMU DRIVERS <iommu@...ts.linux-foundation.org>,
        Joerg Roedel <joro@...tes.org>,
        Linux Doc Mailing List <linux-doc@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Linux Media Mailing List <linux-media@...r.kernel.org>,
        Tomasz Figa <tfiga@...omium.org>,
        Sergey Senozhatsky <senozhatsky@...gle.com>
Subject: Re: [PATCH v3 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API

On (20/11/30 09:34), Christoph Hellwig wrote:
> 
> > +	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;
> > +	}
> 
> 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.

Not that I have any sound experience in this area, but the helper
probably won't hurt. Do you also plan to add vmap() to that helper
or dma_alloc_noncontiguous()/sg_alloc_table_from_pages() only?

	helper()
	{
		dma_alloc_noncontiguous();
		sg_alloc_table_from_pages();

		if ((dma_attrs & DMA_ATTR_NO_KERNEL_MAPPING) == 0)
			vmap();
	}

videobuf2-dma-contig still has to carry around two versions: one that
deals with the noncontig pages and sgt (new API); and the current one.
But if the helper will include fallback to coherent allocations then
this may change, depending on the helper implementation.

	-ss

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ