[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190801163457.GB26588@lst.de>
Date: Thu, 1 Aug 2019 18:34:57 +0200
From: Christoph Hellwig <hch@....de>
To: Will Deacon <will@...nel.org>
Cc: Christoph Hellwig <hch@....de>, iommu@...ts.linux-foundation.org,
Shawn Anastasio <shawn@...stas.io>,
Michael Ellerman <mpe@...erman.id.au>,
Russell King <linux@...linux.org.uk>,
Catalin Marinas <catalin.marinas@....com>,
Robin Murphy <robin.murphy@....com>,
linuxppc-dev@...ts.ozlabs.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] dma-mapping: fix page attributes for dma_mmap_*
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@...nel.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. 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);
}
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.
Powered by blists - more mailing lists