arch_dma_prep_coherent() has no documentation, and several implementations assumed that the page passed to it always has a kernel linear mapping and used page_address() on it. That is not the case: dma_direct_alloc() and atomic_pool_expand() can get a highmem page from CMA and pass it to arch_dma_prep_coherent() before remapping it, and dma-iommu allocates the pages for non-contiguous buffers with __GFP_HIGHMEM.
Add a kernel-doc comment describing what the hook has to do and stating explicitly that it must accept highmem pages without a permanent kernel mapping. Signed-off-by: Marek Szyprowski <[email protected]> --- include/linux/dma-map-ops.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/dma-map-ops.h b/include/linux/dma-map-ops.h index afaf2c12189b..0c90e205df15 100644 --- a/include/linux/dma-map-ops.h +++ b/include/linux/dma-map-ops.h @@ -371,6 +371,16 @@ static inline void arch_sync_dma_for_cpu_all(void) } #endif /* CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL */ +/** + * arch_dma_prep_coherent - prepare memory for use as a coherent DMA buffer + * @page: first page of the physically contiguous buffer + * @size: size of the buffer in bytes + * + * Called before the buffer is accessed through an uncached alias or handed + * to a non-coherent device. The implementation must write back any dirty + * data cache lines covering the buffer, so no dirty line can be evicted + * later on top of data written through the uncached alias or by the device. + */ #ifdef CONFIG_ARCH_HAS_DMA_PREP_COHERENT void arch_dma_prep_coherent(struct page *page, size_t size); #else -- 2.43.0
