Home Home > GIT Browse > SLE15-SP1
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Tesarik <ptesarik@suse.cz>2019-07-19 16:50:46 +0200
committerPetr Tesarik <ptesarik@suse.cz>2019-07-19 16:50:46 +0200
commit5bcdbb755b330efd6dd748b97c2bf1bd72f3dfab (patch)
treed9c99bd91c2fbfa40d09ff21c3d10b8d749f4f2d
parent3ee1bbd3fc6643dd9a34b934ff0a773063e794ac (diff)
- dma-direct: add support for allocation from ZONE_DMA and
ZONE_DMA32 (jsc#SLE-6197 FATE#327012 bsc#1140559 LTC#173150). - Refresh patches.suse/dma-direct-retry-allocations-using-gfp_dma-for-small-masks. suse-commit: 1da6c6520d26ac382857c88983bcaefbb445f81b
-rw-r--r--lib/dma-noop.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/dma-noop.c b/lib/dma-noop.c
index 0bd49cf0cb33..c16a805a70a1 100644
--- a/lib/dma-noop.c
+++ b/lib/dma-noop.c
@@ -8,6 +8,14 @@
#include <linux/dma-direct.h>
#include <linux/scatterlist.h>
+/*
+ * Most architectures use ZONE_DMA for the first 16 Megabytes, but
+ * some use it for entirely different regions:
+ */
+#ifndef ARCH_ZONE_DMA_BITS
+#define ARCH_ZONE_DMA_BITS 24
+#endif
+
static bool dma_coherent_ok(struct device *dev, phys_addr_t phys, size_t size)
{
return phys_to_dma(dev, phys) + size - 1 <= dev->coherent_dma_mask;
@@ -19,6 +27,12 @@ static void *dma_noop_alloc(struct device *dev, size_t size,
{
void *ret;
+ /* GFP_DMA32 and GFP_DMA are no ops without the corresponding zones: */
+ if (dev->coherent_dma_mask <= DMA_BIT_MASK(ARCH_ZONE_DMA_BITS))
+ gfp |= GFP_DMA;
+ if (dev->coherent_dma_mask <= DMA_BIT_MASK(32) && !(gfp & GFP_DMA))
+ gfp |= GFP_DMA32;
+
again:
ret = (void *)__get_free_pages(gfp, get_order(size));
if (ret && !dma_coherent_ok(dev, virt_to_phys(ret), size)) {