dma-mapping: warn when there is no coherent_dma_mask
authorChristoph Hellwig <hch@lst.de>
Fri, 22 Dec 2017 13:50:47 +0000 (14:50 +0100)
committerChristoph Hellwig <hch@lst.de>
Mon, 15 Jan 2018 08:34:43 +0000 (09:34 +0100)
These days all devices should have a DMA coherent mask, and most dma_ops
implementations rely on that fact.  But just to be sure add an assert to
ring the warning bell if that is not the case.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
include/linux/dma-mapping.h

index d84951865be7207446ad67703513809f54ac802f..16add66d5b68b6fc0e0629574bbe77823290b858 100644 (file)
@@ -513,6 +513,7 @@ static inline void *dma_alloc_attrs(struct device *dev, size_t size,
        void *cpu_addr;
 
        BUG_ON(!ops);
+       WARN_ON_ONCE(dev && !dev->coherent_dma_mask);
 
        if (dma_alloc_from_dev_coherent(dev, size, dma_handle, &cpu_addr))
                return cpu_addr;