History

dma-direct: lift gfp_t manipulation out of__dma_direct_alloc_pages

Move the detailed gfp_t setup from __dma_direct_alloc_pages into the caller to clean things up a little.

Christoph Hellwig committed 6 years ago

Commit 3773dfe1 parent 2f5388a1 file · +5 −7Browse files

Unified · Split

kernel/dma/direct.c+5−7
@@ -108,7 +108,7 @@ static inline bool dma_should_free_from_pool(struct device *dev, · 107 unmodified lines
108108 }
109109
110110 static struct page *__dma_direct_alloc_pages(struct device *dev, size_t size,
111− gfp_t gfp, unsigned long attrs)
111+ gfp_t gfp)
112112 {
113113 int node = dev_to_node(dev);
114114 struct page *page = NULL;
@@ -116,11 +116,6 @@ static struct page *__dma_direct_alloc_pages(struct device *dev, size_t size, · 1 unmodified line
116116
117117 WARN_ON_ONCE(!PAGE_ALIGNED(size));
118118
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;
124119 gfp |= dma_direct_optimal_gfp_mask(dev, dev->coherent_dma_mask,
125120 &phys_limit);
126121 page = dma_alloc_contiguous(dev, size, gfp);
@@ -164,6 +159,8 @@ void *dma_direct_alloc(struct device *dev, size_t size, · 37 unmodified lines
164159 return arch_dma_alloc(dev, size, dma_handle, gfp, attrs);
165160
166161 size = PAGE_ALIGN(size);
162+ if (attrs & DMA_ATTR_NO_WARN)
163+ gfp |= __GFP_NOWARN;
167164
168165 if (dma_should_alloc_from_pool(dev, gfp, attrs)) {
169166 u64 phys_mask;
@@ -177,7 +174,8 @@ void *dma_direct_alloc(struct device *dev, size_t size, · 7 unmodified lines
177174 goto done;
178175 }
179176
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);
181179 if (!page)
182180 return NULL;
183181

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t