Skip to content

Commit 999a5d1

Browse files
author
Christoph Hellwig
committed
dma-direct: provide a arch_dma_clear_uncached hook
This allows the arch code to reset the page tables to cached access when freeing a dma coherent allocation that was set to uncached using arch_dma_set_uncached. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Robin Murphy <[email protected]>
1 parent fa7e224 commit 999a5d1

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

arch/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@ config ARCH_HAS_SET_DIRECT_MAP
255255
config ARCH_HAS_DMA_SET_UNCACHED
256256
bool
257257

258+
#
259+
# Select if the architectures provides the arch_dma_clear_uncached symbol
260+
# to undo an in-place page table remap for uncached access.
261+
#
262+
config ARCH_HAS_DMA_CLEAR_UNCACHED
263+
bool
264+
258265
# Select if arch init_task must go in the __init_task_data section
259266
config ARCH_TASK_STRUCT_ON_STACK
260267
bool

include/linux/dma-noncoherent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,6 @@ static inline void arch_dma_prep_coherent(struct page *page, size_t size)
109109
#endif /* CONFIG_ARCH_HAS_DMA_PREP_COHERENT */
110110

111111
void *arch_dma_set_uncached(void *addr, size_t size);
112+
void arch_dma_clear_uncached(void *addr, size_t size);
112113

113114
#endif /* _LINUX_DMA_NONCOHERENT_H */

kernel/dma/direct.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ void dma_direct_free_pages(struct device *dev, size_t size, void *cpu_addr,
231231

232232
if (IS_ENABLED(CONFIG_DMA_REMAP) && is_vmalloc_addr(cpu_addr))
233233
vunmap(cpu_addr);
234+
else if (IS_ENABLED(CONFIG_ARCH_HAS_DMA_CLEAR_UNCACHED))
235+
arch_dma_clear_uncached(cpu_addr, size);
234236

235237
dma_free_contiguous(dev, dma_direct_to_page(dev, dma_addr), size);
236238
}

0 commit comments

Comments
 (0)