Messages in this thread | | | Date | Thu, 1 Aug 2019 17:44:12 +0100 | From | Will Deacon <> | Subject | Re: [PATCH] dma-mapping: fix page attributes for dma_mmap_* |
| |
On Thu, Aug 01, 2019 at 06:34:57PM +0200, Christoph Hellwig wrote: > On Thu, Aug 01, 2019 at 05:23:06PM +0100, Will Deacon wrote: > > > - if (!dev_is_dma_coherent(dev) || (attrs & DMA_ATTR_WRITE_COMBINE)) > > > - return pgprot_writecombine(prot); > > > - return prot; > > > + return pgprot_writecombine(prot); > > > } > > > > Seems like a sensible cleanup to me: > > > > Acked-by: Will Deacon <will@kernel.org> > > > > Although arch_dma_mmap_pgprot() is a bit of a misnomer now that it only > > gets involved in the non-coherent case. > > A better name is welcome.
How about arch_dma_noncoherent_mmap_pgprot() ? Too long?
> My other idea would be to just remove it entirely and do something like: > > #ifndef pgprot_dmacoherent > #define pgprot_dmacoherent pgprot_noncached > #endif > > pgprot_t dma_mmap_pgprot(struct device *dev, pgprot_t prot, unsigned long attrs) > { > if (dev_is_dma_coherent(dev) || (attrs & DMA_ATTR_NON_CONSISTENT)) > return prot; > #ifdef pgprot_writecombine > if (attrs & DMA_ATTR_WRITE_COMBINE) > return pgprot_writecombine(prot); > #endif > return pgprot_dmacoherent(prot); > }
Oh, I prefer that!
> But my worry is how this interacts with architectures that have an > uncached segment (mips, nios2, microblaze, extensa) where we'd have > the kernel access DMA_ATTR_WRITE_COMBINE mappigns using the uncached > segment, and userspace mmaps using pgprot_writecombine, which could > lead to aliasing issues. But then again mips already supports > DMA_ATTR_WRITE_COMBINE, so this must be ok somehow. I guess I'll > need to field that question to the relevant parties.
Or it's always been busted and happens to work out in practice...
Will
| |