summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/dma-contiguous.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/include/linux/dma-contiguous.h b/include/linux/dma-contiguous.h
index 428f3b7b1c42..c05d4e661489 100644
--- a/include/linux/dma-contiguous.h
+++ b/include/linux/dma-contiguous.h
@@ -50,6 +50,7 @@
#ifdef __KERNEL__
#include <linux/device.h>
+#include <linux/mm.h>
struct cma;
struct page;
@@ -155,15 +156,20 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages,
return false;
}
+/* Use fallback alloc() and free() when CONFIG_DMA_CMA=n */
static inline struct page *dma_alloc_contiguous(struct device *dev, size_t size,
gfp_t gfp)
{
- return NULL;
+ int node = dev ? dev_to_node(dev) : NUMA_NO_NODE;
+ size_t align = get_order(PAGE_ALIGN(size));
+
+ return alloc_pages_node(node, gfp, align);
}
static inline void dma_free_contiguous(struct device *dev, struct page *page,
size_t size)
{
+ __free_pages(page, get_order(size));
}
#endif
OpenPOWER on IntegriCloud