Skip to content

Commit 37efa60

Browse files
Christian Königgregkh
authored andcommitted
swiotlb: suppress warning when __GFP_NOWARN is set
commit d0bc0c2 upstream. 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: Christian König <christian.koenig@amd.com> Reported-by: Mike Galbraith <efault@gmx.de> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104082 Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8e56a93 commit 37efa60

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

‎lib/swiotlb.c‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
585585

586586
not_found:
587587
spin_unlock_irqrestore(&io_tlb_lock, flags);
588-
if (printk_ratelimit())
588+
if (!(attrs & DMA_ATTR_NO_WARN) && printk_ratelimit())
589589
dev_warn(hwdev, "swiotlb buffer is full (sz: %zd bytes)\n", size);
590590
return SWIOTLB_MAP_ERROR;
591591
found:
@@ -712,6 +712,7 @@ void *
712712
swiotlb_alloc_coherent(struct device *hwdev, size_t size,
713713
dma_addr_t *dma_handle, gfp_t flags)
714714
{
715+
bool warn = !(flags & __GFP_NOWARN);
715716
dma_addr_t dev_addr;
716717
void *ret;
717718
int order = get_order(size);
@@ -737,8 +738,8 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
737738
* GFP_DMA memory; fall back on map_single(), which
738739
* will grab memory from the lowest available address range.
739740
*/
740-
phys_addr_t paddr = map_single(hwdev, 0, size,
741-
DMA_FROM_DEVICE, 0);
741+
phys_addr_t paddr = map_single(hwdev, 0, size, DMA_FROM_DEVICE,
742+
warn ? 0 : DMA_ATTR_NO_WARN);
742743
if (paddr == SWIOTLB_MAP_ERROR)
743744
goto err_warn;
744745

@@ -768,9 +769,11 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
768769
return ret;
769770

770771
err_warn:
771-
pr_warn("swiotlb: coherent allocation failed for device %s size=%zu\n",
772-
dev_name(hwdev), size);
773-
dump_stack();
772+
if (warn && printk_ratelimit()) {
773+
pr_warn("swiotlb: coherent allocation failed for device %s size=%zu\n",
774+
dev_name(hwdev), size);
775+
dump_stack();
776+
}
774777

775778
return NULL;
776779
}

0 commit comments

Comments
 (0)