Skip to content

Commit d9765e4

Browse files
Nicolas Saenz JulienneChristoph Hellwig
authored andcommitted
dma-pool: do not allocate pool memory from CMA
There is no guarantee to CMA's placement, so allocating a zone specific atomic pool from CMA might return memory from a completely different memory zone. So stop using it. Fixes: c84dc6e ("dma-pool: add additional coherent pools to map to gfp mask") Reported-by: Jeremy Linton <[email protected]> Signed-off-by: Nicolas Saenz Julienne <[email protected]> Tested-by: Jeremy Linton <[email protected]> Acked-by: David Rientjes <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 81e9d89 commit d9765e4

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

kernel/dma/pool.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <linux/debugfs.h>
77
#include <linux/dma-direct.h>
88
#include <linux/dma-noncoherent.h>
9-
#include <linux/dma-contiguous.h>
109
#include <linux/init.h>
1110
#include <linux/genalloc.h>
1211
#include <linux/set_memory.h>
@@ -69,12 +68,7 @@ static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size,
6968

7069
do {
7170
pool_size = 1 << (PAGE_SHIFT + order);
72-
73-
if (dev_get_cma_area(NULL))
74-
page = dma_alloc_from_contiguous(NULL, 1 << order,
75-
order, false);
76-
else
77-
page = alloc_pages(gfp, order);
71+
page = alloc_pages(gfp, order);
7872
} while (!page && order-- > 0);
7973
if (!page)
8074
goto out;
@@ -118,8 +112,7 @@ static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size,
118112
dma_common_free_remap(addr, pool_size);
119113
#endif
120114
free_page: __maybe_unused
121-
if (!dma_release_from_contiguous(NULL, page, 1 << order))
122-
__free_pages(page, order);
115+
__free_pages(page, order);
123116
out:
124117
return ret;
125118
}

0 commit comments

Comments
 (0)