dma-mapping: don't BUG when calling dma_map_resource on RAM

Use WARN_ON_ONCE to print a stack trace and return a proper error
code instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
This commit is contained in:
Christoph Hellwig 2019-01-04 17:17:53 +01:00
parent cfced78696
commit 645386dfe6
1 changed files with 2 additions and 1 deletions

View File

@ -353,7 +353,8 @@ static inline dma_addr_t dma_map_resource(struct device *dev,
BUG_ON(!valid_dma_direction(dir)); BUG_ON(!valid_dma_direction(dir));
/* Don't allow RAM to be mapped */ /* Don't allow RAM to be mapped */
BUG_ON(pfn_valid(PHYS_PFN(phys_addr))); if (WARN_ON_ONCE(pfn_valid(PHYS_PFN(phys_addr))))
return DMA_MAPPING_ERROR;
if (dma_is_direct(ops)) if (dma_is_direct(ops))
addr = dma_direct_map_resource(dev, phys_addr, size, dir, attrs); addr = dma_direct_map_resource(dev, phys_addr, size, dir, attrs);