Re: use exact allocation for dma coherent memory

2019-07-08 Thread Christoph Hellwig
On Tue, Jul 02, 2019 at 11:48:44AM +0200, Arend Van Spriel wrote: > You made me look ;-) Actually not touching my drivers so I'm off the hook. > However, I was wondering if drivers could know so I decided to look into > the DMA-API.txt documentation which currently states: > > """ > The flag

Re: use exact allocation for dma coherent memory

2019-07-02 Thread Arend Van Spriel
On 7/1/2019 10:48 AM, Christoph Hellwig wrote: On Fri, Jun 14, 2019 at 03:47:10PM +0200, Christoph Hellwig wrote: Switching to a slightly cleaned up alloc_pages_exact is pretty easy, but it turns out that because we didn't filter valid gfp_t flags on the DMA allocator, a bunch of drivers

Re: use exact allocation for dma coherent memory

2019-07-01 Thread Christoph Hellwig
On Fri, Jun 14, 2019 at 03:47:10PM +0200, Christoph Hellwig wrote: > Switching to a slightly cleaned up alloc_pages_exact is pretty easy, > but it turns out that because we didn't filter valid gfp_t flags > on the DMA allocator, a bunch of drivers were passing __GFP_COMP > to it, which is rather

Re: use exact allocation for dma coherent memory

2019-06-20 Thread Christoph Hellwig
On Wed, Jun 19, 2019 at 01:29:03PM -0300, Jason Gunthorpe wrote: > > Yes. This will blow up badly on many platforms, as sq->queue > > might be vmapped, ioremapped, come from a pool without page backing. > > Gah, this addr gets fed into io_remap_pfn_range/remap_pfn_range too.. > > Potnuri, you

Re: use exact allocation for dma coherent memory

2019-06-19 Thread Jason Gunthorpe
On Mon, Jun 17, 2019 at 10:33:42AM +0200, Christoph Hellwig wrote: > > drivers/infiniband/hw/cxgb4/qp.c > >129 static int alloc_host_sq(struct c4iw_rdev *rdev, struct t4_sq *sq) > >130 { > >131 sq->queue = dma_alloc_coherent(&(rdev->lldi.pdev->dev), > > sq->memsize, > >

Re: use exact allocation for dma coherent memory

2019-06-17 Thread Christoph Hellwig
> drivers/infiniband/hw/cxgb4/qp.c >129 static int alloc_host_sq(struct c4iw_rdev *rdev, struct t4_sq *sq) >130 { >131 sq->queue = dma_alloc_coherent(&(rdev->lldi.pdev->dev), > sq->memsize, >132 &(sq->dma_addr), GFP_KERNEL); >

Re: use exact allocation for dma coherent memory

2019-06-17 Thread Dan Carpenter
I once wrote a Smatch check based on a commit message that said we can't pass dma_alloc_coherent() pointers to virt_to_phys(). But then I never felt like I understood the rules enough to actually report the warnings as bugs. drivers/platform/x86/dcdbas.c:108 smi_data_buf_realloc() error: 'buf'

use exact allocation for dma coherent memory

2019-06-14 Thread Christoph Hellwig
Hi all, various architectures have used exact memory allocations for dma allocations for a long time, but x86 and thus the common code based on it kept using our normal power of two allocator, which tends to waste a lot of memory for certain allocations. Switching to a slightly cleaned up