]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - lib/swiotlb.c
lib/ubsan.c: don't mark __ubsan_handle_builtin_unreachable as noreturn
[mirror_ubuntu-bionic-kernel.git] / lib / swiotlb.c
index cea19aaf303c9f3c558dd8246205ed39f38dcc46..0d7f46fb993aa3d9f9a55d1332da5d0d20ca48b3 100644 (file)
@@ -586,7 +586,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
 
 not_found:
        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);
        return SWIOTLB_MAP_ERROR;
 found:
@@ -713,6 +713,7 @@ void *
 swiotlb_alloc_coherent(struct device *hwdev, size_t size,
                       dma_addr_t *dma_handle, gfp_t flags)
 {
+       bool warn = !(flags & __GFP_NOWARN);
        dma_addr_t dev_addr;
        void *ret;
        int order = get_order(size);
@@ -738,8 +739,8 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
                 * GFP_DMA memory; fall back on map_single(), which
                 * will grab memory from the lowest available address range.
                 */
-               phys_addr_t paddr = map_single(hwdev, 0, size,
-                                              DMA_FROM_DEVICE, 0);
+               phys_addr_t paddr = map_single(hwdev, 0, size, DMA_FROM_DEVICE,
+                                              warn ? 0 : DMA_ATTR_NO_WARN);
                if (paddr == SWIOTLB_MAP_ERROR)
                        goto err_warn;
 
@@ -769,9 +770,11 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
        return ret;
 
 err_warn:
-       pr_warn("swiotlb: coherent allocation failed for device %s size=%zu\n",
-               dev_name(hwdev), size);
-       dump_stack();
+       if (warn && printk_ratelimit()) {
+               pr_warn("swiotlb: coherent allocation failed for device %s size=%zu\n",
+                       dev_name(hwdev), size);
+               dump_stack();
+       }
 
        return NULL;
 }