Skip to content

Commit d0bc0c2

Browse files
Christian KönigChristoph Hellwig
authored andcommitted
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: 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 CC: stable@vger.kernel.org Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 23475ad commit d0bc0c2

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
@@ -586,7 +586,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
586586

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

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

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

776779
return NULL;
777780
}

0 commit comments

Comments
 (0)