@@ -344,6 +344,7 @@ static inline void arch_dma_mark_clean(phys_addr_t paddr, size_t size)
}
#endif /* ARCH_HAS_DMA_MARK_CLEAN */
+bool arch_can_dma_alloc_coherent(void);
void *arch_dma_set_uncached(void *addr, size_t size);
void arch_dma_clear_uncached(void *addr, size_t size);
@@ -20,6 +20,9 @@ config DMA_OPS
config DMA_OPS_BYPASS
bool
+config ARCH_HAS_CAN_DMA_ALLOC_COHERENT
+ bool
+
# Lets platform IOMMU driver choose between bypass and IOMMU
config ARCH_HAS_DMA_MAP_DIRECT
bool
@@ -232,6 +232,10 @@ void *dma_direct_alloc(struct device *dev, size_t size,
return arch_dma_alloc(dev, size, dma_handle, gfp,
attrs);
+ if (IS_ENABLED(CONFIG_ARCH_HAS_CAN_DMA_ALLOC_COHERENT) &&
+ !arch_can_dma_alloc_coherent())
+ return NULL;
+
/*
* If there is a global pool, always allocate from it for
* non-coherent devices.
This hook allows an architecture to reject coherent DMA allocations entirely if they can't be supported. This will be useful to convert parisc and m68knommu to the generic dma-direct code. Signed-off-by: Christoph Hellwig <hch@lst.de> --- include/linux/dma-map-ops.h | 1 + kernel/dma/Kconfig | 3 +++ kernel/dma/direct.c | 4 ++++ 3 files changed, 8 insertions(+)