2022-01-15 08:55:49 +00:00
|
|
|
diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
|
|
|
|
index 18aade195884..6eb8f8ae76da 100644
|
|
|
|
--- a/include/linux/dma-direct.h
|
|
|
|
+++ b/include/linux/dma-direct.h
|
|
|
|
@@ -103,6 +103,10 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size,
|
|
|
|
|
|
|
|
if (addr == DMA_MAPPING_ERROR)
|
|
|
|
return false;
|
|
|
|
+
|
|
|
|
+ if (!dev->dma_mask)
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
if (is_ram && !IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
|
|
|
|
min(addr, end) < phys_to_dma(dev, PFN_PHYS(min_low_pfn)))
|
|
|
|
return false;
|
|
|
|
diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c
|
2022-05-30 18:01:44 +00:00
|
|
|
index 559461a826ba..389fc0faaa47 100644
|
2022-01-15 08:55:49 +00:00
|
|
|
--- a/kernel/dma/mapping.c
|
|
|
|
+++ b/kernel/dma/mapping.c
|
|
|
|
@@ -148,9 +148,6 @@ dma_addr_t dma_map_page_attrs(struct device *dev, struct page *page,
|
|
|
|
|
|
|
|
BUG_ON(!valid_dma_direction(dir));
|
|
|
|
|
|
|
|
- if (WARN_ON_ONCE(!dev->dma_mask))
|
|
|
|
- return DMA_MAPPING_ERROR;
|
|
|
|
-
|
|
|
|
if (dma_map_direct(dev, ops) ||
|
|
|
|
arch_dma_map_page_direct(dev, page_to_phys(page) + offset + size))
|
|
|
|
addr = dma_direct_map_page(dev, page, offset, size, dir, attrs);
|
|
|
|
@@ -185,9 +182,6 @@ static int __dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
|
|
|
|
|
|
|
|
BUG_ON(!valid_dma_direction(dir));
|
|
|
|
|
|
|
|
- if (WARN_ON_ONCE(!dev->dma_mask))
|
|
|
|
- return 0;
|
|
|
|
-
|
|
|
|
if (dma_map_direct(dev, ops) ||
|
|
|
|
arch_dma_map_sg_direct(dev, sg, nents))
|
|
|
|
ents = dma_direct_map_sg(dev, sg, nents, dir, attrs);
|
|
|
|
@@ -293,9 +287,6 @@ dma_addr_t dma_map_resource(struct device *dev, phys_addr_t phys_addr,
|
|
|
|
|
|
|
|
BUG_ON(!valid_dma_direction(dir));
|
|
|
|
|
|
|
|
- if (WARN_ON_ONCE(!dev->dma_mask))
|
|
|
|
- return DMA_MAPPING_ERROR;
|
|
|
|
-
|
2022-05-30 18:01:44 +00:00
|
|
|
if (dma_map_direct(dev, ops))
|
|
|
|
addr = dma_direct_map_resource(dev, phys_addr, size, dir, attrs);
|
|
|
|
else if (ops->map_resource)
|