diff options
author | Christoph Hellwig <hch@lst.de> | 2019-06-14 10:06:10 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2019-06-25 02:14:43 -0400 |
commit | 4b85faed211ccfbcc7f3adf1cd62f0b00d1a172b (patch) | |
tree | dcc65552dd34f276ac4e20104f2f981da996bdc6 /kernel/dma | |
parent | 961729bfc73e698be19305834805592227bd09e3 (diff) |
dma-mapping: add a dma_alloc_need_uncached helper
Check if we need to allocate uncached memory for a device given the
allocation flags. Switch over the uncached segment check to this helper
to deal with architectures that do not support the dma_cache_sync
operation and thus should not returned cacheable memory for
DMA_ATTR_NON_CONSISTENT allocations.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'kernel/dma')
-rw-r--r-- | kernel/dma/direct.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index b67f0aa08aa3..c2893713bf80 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c | |||
@@ -160,7 +160,7 @@ void *dma_direct_alloc_pages(struct device *dev, size_t size, | |||
160 | memset(ret, 0, size); | 160 | memset(ret, 0, size); |
161 | 161 | ||
162 | if (IS_ENABLED(CONFIG_ARCH_HAS_UNCACHED_SEGMENT) && | 162 | if (IS_ENABLED(CONFIG_ARCH_HAS_UNCACHED_SEGMENT) && |
163 | !dev_is_dma_coherent(dev) && !(attrs & DMA_ATTR_NON_CONSISTENT)) { | 163 | dma_alloc_need_uncached(dev, attrs)) { |
164 | arch_dma_prep_coherent(page, size); | 164 | arch_dma_prep_coherent(page, size); |
165 | ret = uncached_kernel_address(ret); | 165 | ret = uncached_kernel_address(ret); |
166 | } | 166 | } |
@@ -182,7 +182,7 @@ void dma_direct_free_pages(struct device *dev, size_t size, void *cpu_addr, | |||
182 | set_memory_encrypted((unsigned long)cpu_addr, 1 << page_order); | 182 | set_memory_encrypted((unsigned long)cpu_addr, 1 << page_order); |
183 | 183 | ||
184 | if (IS_ENABLED(CONFIG_ARCH_HAS_UNCACHED_SEGMENT) && | 184 | if (IS_ENABLED(CONFIG_ARCH_HAS_UNCACHED_SEGMENT) && |
185 | !dev_is_dma_coherent(dev) && !(attrs & DMA_ATTR_NON_CONSISTENT)) | 185 | dma_alloc_need_uncached(dev, attrs)) |
186 | cpu_addr = cached_kernel_address(cpu_addr); | 186 | cpu_addr = cached_kernel_address(cpu_addr); |
187 | __dma_direct_free_pages(dev, size, virt_to_page(cpu_addr)); | 187 | __dma_direct_free_pages(dev, size, virt_to_page(cpu_addr)); |
188 | } | 188 | } |