]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blobdiff - arch/x86/kernel/pci-dma.c
x86: Deinline dma_alloc_attrs()
[mirror_ubuntu-hirsute-kernel.git] / arch / x86 / kernel / pci-dma.c
index a25e202bb319caf87ce147831f6a1a47ed03e254..f9f7656e1d415cbd8b4ddb59920aab7c5c908f67 100644 (file)
@@ -140,6 +140,34 @@ void dma_generic_free_coherent(struct device *dev, size_t size, void *vaddr,
                free_pages((unsigned long)vaddr, get_order(size));
 }
 
+void *dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
+                     gfp_t gfp, struct dma_attrs *attrs)
+{
+       struct dma_map_ops *ops = get_dma_ops(dev);
+       void *memory;
+
+       gfp &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);
+
+       if (dma_alloc_from_coherent(dev, size, dma_handle, &memory))
+               return memory;
+
+       if (!dev)
+               dev = &x86_dma_fallback_dev;
+
+       if (!is_device_dma_capable(dev))
+               return NULL;
+
+       if (!ops->alloc)
+               return NULL;
+
+       memory = ops->alloc(dev, size, dma_handle,
+                           dma_alloc_coherent_gfp_flags(dev, gfp), attrs);
+       debug_dma_alloc_coherent(dev, size, *dma_handle, memory);
+
+       return memory;
+}
+EXPORT_SYMBOL(dma_alloc_attrs);
+
 /*
  * See <Documentation/x86/x86_64/boot-options.txt> for the iommu kernel
  * parameter documentation.