Commit d0bc0c2a authored by Christian König's avatar Christian König Committed by Christoph Hellwig

swiotlb: suppress warning when __GFP_NOWARN is set

TTM tries to allocate coherent memory in chunks of 2MB first to improve
TLB efficiency and falls back to allocating 4K pages if that fails.

Suppress the warning when the 2MB allocations fails since there is a
valid fall back path.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reported-by: default avatarMike Galbraith <efault@gmx.de>
Acked-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104082
CC: stable@vger.kernel.org
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 23475ad4
...@@ -586,7 +586,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, ...@@ -586,7 +586,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
not_found: not_found:
spin_unlock_irqrestore(&io_tlb_lock, flags); spin_unlock_irqrestore(&io_tlb_lock, flags);
if (printk_ratelimit()) if (!(attrs & DMA_ATTR_NO_WARN) && printk_ratelimit())
dev_warn(hwdev, "swiotlb buffer is full (sz: %zd bytes)\n", size); dev_warn(hwdev, "swiotlb buffer is full (sz: %zd bytes)\n", size);
return SWIOTLB_MAP_ERROR; return SWIOTLB_MAP_ERROR;
found: found:
...@@ -713,6 +713,7 @@ void * ...@@ -713,6 +713,7 @@ void *
swiotlb_alloc_coherent(struct device *hwdev, size_t size, swiotlb_alloc_coherent(struct device *hwdev, size_t size,
dma_addr_t *dma_handle, gfp_t flags) dma_addr_t *dma_handle, gfp_t flags)
{ {
bool warn = !(flags & __GFP_NOWARN);
dma_addr_t dev_addr; dma_addr_t dev_addr;
void *ret; void *ret;
int order = get_order(size); int order = get_order(size);
...@@ -738,8 +739,8 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size, ...@@ -738,8 +739,8 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
* GFP_DMA memory; fall back on map_single(), which * GFP_DMA memory; fall back on map_single(), which
* will grab memory from the lowest available address range. * will grab memory from the lowest available address range.
*/ */
phys_addr_t paddr = map_single(hwdev, 0, size, phys_addr_t paddr = map_single(hwdev, 0, size, DMA_FROM_DEVICE,
DMA_FROM_DEVICE, 0); warn ? 0 : DMA_ATTR_NO_WARN);
if (paddr == SWIOTLB_MAP_ERROR) if (paddr == SWIOTLB_MAP_ERROR)
goto err_warn; goto err_warn;
...@@ -769,9 +770,11 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size, ...@@ -769,9 +770,11 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
return ret; return ret;
err_warn: err_warn:
pr_warn("swiotlb: coherent allocation failed for device %s size=%zu\n", if (warn && printk_ratelimit()) {
dev_name(hwdev), size); pr_warn("swiotlb: coherent allocation failed for device %s size=%zu\n",
dump_stack(); dev_name(hwdev), size);
dump_stack();
}
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment