diff options
author | Christoph Hellwig <hch@lst.de> | 2019-07-26 03:26:40 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2019-08-10 13:52:45 -0400 |
commit | 33dcb37cef741294b481f4d889a465b8091f11bf (patch) | |
tree | 129f9cde5b52cd77e04382c99ff0421aa862354b /arch/arm/mm/dma-mapping.c | |
parent | d8ad55538abe443919e20e0bb996561bca9cad84 (diff) |
dma-mapping: fix page attributes for dma_mmap_*
All the way back to introducing dma_common_mmap we've defaulted to mark
the pages as uncached. But this is wrong for DMA coherent devices.
Later on DMA_ATTR_WRITE_COMBINE also got incorrect treatment as that
flag is only treated special on the alloc side for non-coherent devices.
Introduce a new dma_pgprot helper that deals with the check for coherent
devices so that only the remapping cases ever reach arch_dma_mmap_pgprot
and we thus ensure no aliasing of page attributes happens, which makes
the powerpc version of arch_dma_mmap_pgprot obsolete and simplifies the
remaining ones.
Note that this means arch_dma_mmap_pgprot is a bit misnamed now, but
we'll phase it out soon.
Fixes: 64ccc9c033c6 ("common: dma-mapping: add support for generic dma_mmap_* calls")
Reported-by: Shawn Anastasio <shawn@anastas.io>
Reported-by: Gavin Li <git@thegavinli.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Catalin Marinas <catalin.marinas@arm.com> # arm64
Diffstat (limited to 'arch/arm/mm/dma-mapping.c')
-rw-r--r-- | arch/arm/mm/dma-mapping.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 6774b03aa405..d42557ee69c2 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
@@ -2405,9 +2405,7 @@ long arch_dma_coherent_to_pfn(struct device *dev, void *cpu_addr, | |||
2405 | pgprot_t arch_dma_mmap_pgprot(struct device *dev, pgprot_t prot, | 2405 | pgprot_t arch_dma_mmap_pgprot(struct device *dev, pgprot_t prot, |
2406 | unsigned long attrs) | 2406 | unsigned long attrs) |
2407 | { | 2407 | { |
2408 | if (!dev_is_dma_coherent(dev)) | 2408 | return __get_dma_pgprot(attrs, prot); |
2409 | return __get_dma_pgprot(attrs, prot); | ||
2410 | return prot; | ||
2411 | } | 2409 | } |
2412 | 2410 | ||
2413 | void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, | 2411 | void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, |