summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorNicolin Chen <nicoleotsuka@gmail.com>2019-05-23 21:06:32 -0700
committerChristoph Hellwig <hch@lst.de>2019-06-03 16:00:07 +0200
commitb1d2dc009dece4cd7e629419b52266ba51960a6b (patch)
treea31a473e64a10c54420e767337fd288753b7d6e3 /drivers
parent1b961423158caaae49d3900b7c9c37477bbfa9b3 (diff)
downloadlwn-b1d2dc009dece4cd7e629419b52266ba51960a6b.tar.gz
lwn-b1d2dc009dece4cd7e629419b52266ba51960a6b.zip
dma-contiguous: add dma_{alloc,free}_contiguous() helpers
Both dma_alloc_from_contiguous() and dma_release_from_contiguous() are very simply implemented, but requiring callers to pass certain parameters like count and align, and taking a boolean parameter to check __GFP_NOWARN in the allocation flags. So every function call duplicates similar work: unsigned long order = get_order(size); size_t count = size >> PAGE_SHIFT; page = dma_alloc_from_contiguous(dev, count, order, gfp & __GFP_NOWARN); [...] dma_release_from_contiguous(dev, page, size >> PAGE_SHIFT); Additionally, as CMA can be used only in the context which permits sleeping, most of callers do a gfpflags_allow_blocking() check and a corresponding fallback allocation of normal pages upon any false result: if (gfpflags_allow_blocking(flag)) page = dma_alloc_from_contiguous(); if (!page) page = alloc_pages(); [...] if (!dma_release_from_contiguous(dev, page, count)) __free_pages(page, get_order(size)); So this patch simplifies those function calls by abstracting these operations into the two new functions: dma_{alloc,free}_contiguous. As some callers of dma_{alloc,release}_from_contiguous() might be complicated, this patch just implements these two new functions to kernel/dma/direct.c only as an initial step. Suggested-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com> Tested-by: dann frazier <dann.frazier@canonical.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers')
0 files changed, 0 insertions, 0 deletions