Skip to content

Commit

Permalink
dma-direct: lift gfp_t manipulation out of__dma_direct_alloc_pages
Browse files Browse the repository at this point in the history
Move the detailed gfp_t setup from __dma_direct_alloc_pages into the
caller to clean things up a little.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Robin Murphy <[email protected]>
  • Loading branch information
Christoph Hellwig committed Sep 11, 2020
1 parent 2f5388a commit 3773dfe
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions kernel/dma/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,14 @@ static inline bool dma_should_free_from_pool(struct device *dev,
}

static struct page *__dma_direct_alloc_pages(struct device *dev, size_t size,
gfp_t gfp, unsigned long attrs)
gfp_t gfp)
{
int node = dev_to_node(dev);
struct page *page = NULL;
u64 phys_limit;

WARN_ON_ONCE(!PAGE_ALIGNED(size));

if (attrs & DMA_ATTR_NO_WARN)
gfp |= __GFP_NOWARN;

/* we always manually zero the memory once we are done: */
gfp &= ~__GFP_ZERO;
gfp |= dma_direct_optimal_gfp_mask(dev, dev->coherent_dma_mask,
&phys_limit);
page = dma_alloc_contiguous(dev, size, gfp);
Expand Down Expand Up @@ -164,6 +159,8 @@ void *dma_direct_alloc(struct device *dev, size_t size,
return arch_dma_alloc(dev, size, dma_handle, gfp, attrs);

size = PAGE_ALIGN(size);
if (attrs & DMA_ATTR_NO_WARN)
gfp |= __GFP_NOWARN;

if (dma_should_alloc_from_pool(dev, gfp, attrs)) {
u64 phys_mask;
Expand All @@ -177,7 +174,8 @@ void *dma_direct_alloc(struct device *dev, size_t size,
goto done;
}

page = __dma_direct_alloc_pages(dev, size, gfp, attrs);
/* we always manually zero the memory once we are done */
page = __dma_direct_alloc_pages(dev, size, gfp & ~__GFP_ZERO);
if (!page)
return NULL;

Expand Down

0 comments on commit 3773dfe

Please sign in to comment.