diff options
author | Marek Szyprowski <m.szyprowski@samsung.com> | 2018-08-17 18:49:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-17 19:20:32 -0400 |
commit | d834c5ab83febf9624ad3b16c3c348aa1e02014c (patch) | |
tree | 9482d8c63427faf708dde2e4c7eafc81183a5cec | |
parent | 6518202970c1052148daaef9a8096711775e43a2 (diff) |
kernel/dma: remove unsupported gfp_mask parameter from dma_alloc_from_contiguous()
The CMA memory allocator doesn't support standard gfp flags for memory
allocation, so there is no point having it as a parameter for
dma_alloc_from_contiguous() function. Replace it by a boolean no_warn
argument, which covers all the underlaying cma_alloc() function
supports.
This will help to avoid giving false feeling that this function supports
standard gfp flags and callers can pass __GFP_ZERO to get zeroed buffer,
what has already been an issue: see commit dd65a941f6ba ("arm64:
dma-mapping: clear buffers allocated with FORCE_CONTIGUOUS flag").
Link: http://lkml.kernel.org/r/20180709122020eucas1p21a71b092975cb4a3b9954ffc63f699d1~-sqUFoa-h2939329393eucas1p2Y@eucas1p2.samsung.com
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: MichaĆ Nazarewicz <mina86@mina86.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Laura Abbott <labbott@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Joonsoo Kim <js1304@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/arm/mm/dma-mapping.c | 5 | ||||
-rw-r--r-- | arch/arm64/mm/dma-mapping.c | 4 | ||||
-rw-r--r-- | arch/xtensa/kernel/pci-dma.c | 2 | ||||
-rw-r--r-- | drivers/iommu/amd_iommu.c | 2 | ||||
-rw-r--r-- | drivers/iommu/intel-iommu.c | 3 | ||||
-rw-r--r-- | include/linux/dma-contiguous.h | 4 | ||||
-rw-r--r-- | kernel/dma/contiguous.c | 7 | ||||
-rw-r--r-- | kernel/dma/direct.c | 3 |
8 files changed, 16 insertions, 14 deletions
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index ba0e786c952e..66566472c153 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
@@ -594,7 +594,7 @@ static void *__alloc_from_contiguous(struct device *dev, size_t size, | |||
594 | struct page *page; | 594 | struct page *page; |
595 | void *ptr = NULL; | 595 | void *ptr = NULL; |
596 | 596 | ||
597 | page = dma_alloc_from_contiguous(dev, count, order, gfp); | 597 | page = dma_alloc_from_contiguous(dev, count, order, gfp & __GFP_NOWARN); |
598 | if (!page) | 598 | if (!page) |
599 | return NULL; | 599 | return NULL; |
600 | 600 | ||
@@ -1299,7 +1299,8 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size, | |||
1299 | unsigned long order = get_order(size); | 1299 | unsigned long order = get_order(size); |
1300 | struct page *page; | 1300 | struct page *page; |
1301 | 1301 | ||
1302 | page = dma_alloc_from_contiguous(dev, count, order, gfp); | 1302 | page = dma_alloc_from_contiguous(dev, count, order, |
1303 | gfp & __GFP_NOWARN); | ||
1303 | if (!page) | 1304 | if (!page) |
1304 | goto error; | 1305 | goto error; |
1305 | 1306 | ||
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 61e93f0b5482..072c51fb07d7 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c | |||
@@ -355,7 +355,7 @@ static int __init atomic_pool_init(void) | |||
355 | 355 | ||
356 | if (dev_get_cma_area(NULL)) | 356 | if (dev_get_cma_area(NULL)) |
357 | page = dma_alloc_from_contiguous(NULL, nr_pages, | 357 | page = dma_alloc_from_contiguous(NULL, nr_pages, |
358 | pool_size_order, GFP_KERNEL); | 358 | pool_size_order, false); |
359 | else | 359 | else |
360 | page = alloc_pages(GFP_DMA32, pool_size_order); | 360 | page = alloc_pages(GFP_DMA32, pool_size_order); |
361 | 361 | ||
@@ -573,7 +573,7 @@ static void *__iommu_alloc_attrs(struct device *dev, size_t size, | |||
573 | struct page *page; | 573 | struct page *page; |
574 | 574 | ||
575 | page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT, | 575 | page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT, |
576 | get_order(size), gfp); | 576 | get_order(size), gfp & __GFP_NOWARN); |
577 | if (!page) | 577 | if (!page) |
578 | return NULL; | 578 | return NULL; |
579 | 579 | ||
diff --git a/arch/xtensa/kernel/pci-dma.c b/arch/xtensa/kernel/pci-dma.c index 392b4a80ebc2..a02dc563d290 100644 --- a/arch/xtensa/kernel/pci-dma.c +++ b/arch/xtensa/kernel/pci-dma.c | |||
@@ -137,7 +137,7 @@ static void *xtensa_dma_alloc(struct device *dev, size_t size, | |||
137 | 137 | ||
138 | if (gfpflags_allow_blocking(flag)) | 138 | if (gfpflags_allow_blocking(flag)) |
139 | page = dma_alloc_from_contiguous(dev, count, get_order(size), | 139 | page = dma_alloc_from_contiguous(dev, count, get_order(size), |
140 | flag); | 140 | flag & __GFP_NOWARN); |
141 | 141 | ||
142 | if (!page) | 142 | if (!page) |
143 | page = alloc_pages(flag, get_order(size)); | 143 | page = alloc_pages(flag, get_order(size)); |
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 596b95c50051..60b2eab29cd8 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c | |||
@@ -2620,7 +2620,7 @@ static void *alloc_coherent(struct device *dev, size_t size, | |||
2620 | return NULL; | 2620 | return NULL; |
2621 | 2621 | ||
2622 | page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT, | 2622 | page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT, |
2623 | get_order(size), flag); | 2623 | get_order(size), flag & __GFP_NOWARN); |
2624 | if (!page) | 2624 | if (!page) |
2625 | return NULL; | 2625 | return NULL; |
2626 | } | 2626 | } |
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 115ff26e9ced..6a237d18fabf 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c | |||
@@ -3758,7 +3758,8 @@ static void *intel_alloc_coherent(struct device *dev, size_t size, | |||
3758 | if (gfpflags_allow_blocking(flags)) { | 3758 | if (gfpflags_allow_blocking(flags)) { |
3759 | unsigned int count = size >> PAGE_SHIFT; | 3759 | unsigned int count = size >> PAGE_SHIFT; |
3760 | 3760 | ||
3761 | page = dma_alloc_from_contiguous(dev, count, order, flags); | 3761 | page = dma_alloc_from_contiguous(dev, count, order, |
3762 | flags & __GFP_NOWARN); | ||
3762 | if (page && iommu_no_mapping(dev) && | 3763 | if (page && iommu_no_mapping(dev) && |
3763 | page_to_phys(page) + size > dev->coherent_dma_mask) { | 3764 | page_to_phys(page) + size > dev->coherent_dma_mask) { |
3764 | dma_release_from_contiguous(dev, page, count); | 3765 | dma_release_from_contiguous(dev, page, count); |
diff --git a/include/linux/dma-contiguous.h b/include/linux/dma-contiguous.h index 3c5a4cb3eb95..f247e8aa5e3d 100644 --- a/include/linux/dma-contiguous.h +++ b/include/linux/dma-contiguous.h | |||
@@ -112,7 +112,7 @@ static inline int dma_declare_contiguous(struct device *dev, phys_addr_t size, | |||
112 | } | 112 | } |
113 | 113 | ||
114 | struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, | 114 | struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, |
115 | unsigned int order, gfp_t gfp_mask); | 115 | unsigned int order, bool no_warn); |
116 | bool dma_release_from_contiguous(struct device *dev, struct page *pages, | 116 | bool dma_release_from_contiguous(struct device *dev, struct page *pages, |
117 | int count); | 117 | int count); |
118 | 118 | ||
@@ -145,7 +145,7 @@ int dma_declare_contiguous(struct device *dev, phys_addr_t size, | |||
145 | 145 | ||
146 | static inline | 146 | static inline |
147 | struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, | 147 | struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, |
148 | unsigned int order, gfp_t gfp_mask) | 148 | unsigned int order, bool no_warn) |
149 | { | 149 | { |
150 | return NULL; | 150 | return NULL; |
151 | } | 151 | } |
diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c index 19ea5d70150c..286d82329eb0 100644 --- a/kernel/dma/contiguous.c +++ b/kernel/dma/contiguous.c | |||
@@ -178,7 +178,7 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base, | |||
178 | * @dev: Pointer to device for which the allocation is performed. | 178 | * @dev: Pointer to device for which the allocation is performed. |
179 | * @count: Requested number of pages. | 179 | * @count: Requested number of pages. |
180 | * @align: Requested alignment of pages (in PAGE_SIZE order). | 180 | * @align: Requested alignment of pages (in PAGE_SIZE order). |
181 | * @gfp_mask: GFP flags to use for this allocation. | 181 | * @no_warn: Avoid printing message about failed allocation. |
182 | * | 182 | * |
183 | * This function allocates memory buffer for specified device. It uses | 183 | * This function allocates memory buffer for specified device. It uses |
184 | * device specific contiguous memory area if available or the default | 184 | * device specific contiguous memory area if available or the default |
@@ -186,13 +186,12 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base, | |||
186 | * function. | 186 | * function. |
187 | */ | 187 | */ |
188 | struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, | 188 | struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, |
189 | unsigned int align, gfp_t gfp_mask) | 189 | unsigned int align, bool no_warn) |
190 | { | 190 | { |
191 | if (align > CONFIG_CMA_ALIGNMENT) | 191 | if (align > CONFIG_CMA_ALIGNMENT) |
192 | align = CONFIG_CMA_ALIGNMENT; | 192 | align = CONFIG_CMA_ALIGNMENT; |
193 | 193 | ||
194 | return cma_alloc(dev_get_cma_area(dev), count, align, | 194 | return cma_alloc(dev_get_cma_area(dev), count, align, no_warn); |
195 | gfp_mask & __GFP_NOWARN); | ||
196 | } | 195 | } |
197 | 196 | ||
198 | /** | 197 | /** |
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index c2860c5a9e96..1c35b7b945d0 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c | |||
@@ -78,7 +78,8 @@ void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, | |||
78 | again: | 78 | again: |
79 | /* CMA can be used only in the context which permits sleeping */ | 79 | /* CMA can be used only in the context which permits sleeping */ |
80 | if (gfpflags_allow_blocking(gfp)) { | 80 | if (gfpflags_allow_blocking(gfp)) { |
81 | page = dma_alloc_from_contiguous(dev, count, page_order, gfp); | 81 | page = dma_alloc_from_contiguous(dev, count, page_order, |
82 | gfp & __GFP_NOWARN); | ||
82 | if (page && !dma_coherent_ok(dev, page_to_phys(page), size)) { | 83 | if (page && !dma_coherent_ok(dev, page_to_phys(page), size)) { |
83 | dma_release_from_contiguous(dev, page, count); | 84 | dma_release_from_contiguous(dev, page, count); |
84 | page = NULL; | 85 | page = NULL; |