Move the detailed gfp_t setup from __dma_direct_alloc_pages into the caller to clean things up a little.
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -108,7 +108,7 @@ static inline bool dma_should_free_from_pool(struct device *dev, · 107 unmodified lines | ||
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | static struct page *__dma_direct_alloc_pages(struct device *dev, size_t size, |
| 111 | − gfp_t gfp, unsigned long attrs) | |
| 111 | + gfp_t gfp) | |
| 112 | 112 | { |
| 113 | 113 | int node = dev_to_node(dev); |
| 114 | 114 | struct page *page = NULL; |
| @@ -116,11 +116,6 @@ static struct page *__dma_direct_alloc_pages(struct device *dev, size_t size, · 1 unmodified line | ||
| 116 | 116 | |
| 117 | 117 | WARN_ON_ONCE(!PAGE_ALIGNED(size)); |
| 118 | 118 | |
| 119 | − if (attrs & DMA_ATTR_NO_WARN) | |
| 120 | − gfp |= __GFP_NOWARN; | |
| 121 | − | |
| 122 | − /* we always manually zero the memory once we are done: */ | |
| 123 | − gfp &= ~__GFP_ZERO; | |
| 124 | 119 | gfp |= dma_direct_optimal_gfp_mask(dev, dev->coherent_dma_mask, |
| 125 | 120 | &phys_limit); |
| 126 | 121 | page = dma_alloc_contiguous(dev, size, gfp); |
| @@ -164,6 +159,8 @@ void *dma_direct_alloc(struct device *dev, size_t size, · 37 unmodified lines | ||
| 164 | 159 | return arch_dma_alloc(dev, size, dma_handle, gfp, attrs); |
| 165 | 160 | |
| 166 | 161 | size = PAGE_ALIGN(size); |
| 162 | + if (attrs & DMA_ATTR_NO_WARN) | |
| 163 | + gfp |= __GFP_NOWARN; | |
| 167 | 164 | |
| 168 | 165 | if (dma_should_alloc_from_pool(dev, gfp, attrs)) { |
| 169 | 166 | u64 phys_mask; |
| @@ -177,7 +174,8 @@ void *dma_direct_alloc(struct device *dev, size_t size, · 7 unmodified lines | ||
| 177 | 174 | goto done; |
| 178 | 175 | } |
| 179 | 176 | |
| 180 | − page = __dma_direct_alloc_pages(dev, size, gfp, attrs); | |
| 177 | + /* we always manually zero the memory once we are done */ | |
| 178 | + page = __dma_direct_alloc_pages(dev, size, gfp & ~__GFP_ZERO); | |
| 181 | 179 | if (!page) |
| 182 | 180 | return NULL; |
| 183 | 181 | |