Nicolin Chen
b1d2dc009d
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 >
2019-06-03 16:00:07 +02:00
..
2019-05-07 19:43:05 +02:00
2019-05-16 11:05:11 -07:00
2019-05-24 17:27:12 +02:00
2019-05-16 09:19:14 -07:00
2019-05-11 10:54:43 -04:00
2019-05-15 18:50:40 -07:00
2019-05-19 10:58:45 -07:00
2019-05-24 17:36:45 +02:00
2019-05-15 18:21:43 -07:00
2019-05-24 17:36:45 +02:00
2019-05-20 08:21:07 -07:00
2019-05-24 17:39:00 +02:00
2019-05-24 17:39:00 +02:00
2019-05-21 11:28:39 +02:00
2019-05-24 17:27:13 +02:00
2019-05-24 17:36:45 +02:00
2019-05-21 11:28:40 +02:00
2019-05-14 19:52:52 -07:00
2019-05-19 10:58:45 -07:00
2019-05-15 18:21:43 -07:00
2019-05-14 10:30:10 -07:00
2019-05-24 17:27:12 +02:00
2019-05-24 17:39:02 +02:00
2019-05-09 00:41:00 -05:00
2019-05-24 17:27:11 +02:00
2019-05-24 17:27:11 +02:00
2019-05-24 17:27:11 +02:00
2019-05-24 17:27:11 +02:00
2019-05-24 17:27:11 +02:00
2019-05-21 11:28:46 +02:00
2019-05-24 17:37:52 +02:00
2019-05-24 17:37:52 +02:00
2019-05-14 09:47:48 -07:00
2019-05-14 19:52:50 -07:00
2019-05-23 10:25:26 -06:00
2019-05-14 19:52:49 -07:00
2019-05-23 10:25:26 -06:00
2019-05-23 10:25:26 -06:00
2019-05-24 17:36:45 +02:00
2019-05-14 10:47:29 -07:00
2019-05-15 13:21:37 -07:00
2019-05-14 19:52:48 -07:00
2019-05-09 15:25:13 -04:00
2019-05-18 15:52:26 -07:00
2019-05-24 17:27:11 +02:00
2019-05-14 07:57:29 -07:00
2019-05-10 12:20:36 +02:00
2019-05-10 05:29:27 -07:00
2019-05-14 19:52:50 -07:00
2019-05-24 17:27:11 +02:00
2019-05-20 15:02:08 -07:00
2019-05-24 17:27:11 +02:00
2019-05-07 21:28:04 -07:00
2019-05-09 14:50:09 -07:00
2019-05-24 17:37:52 +02:00
2019-06-03 16:00:07 +02:00
2019-05-27 17:31:12 +02:00
2019-05-21 11:28:40 +02:00
2019-05-15 17:35:54 +01:00
2019-05-24 17:37:53 +02:00
2019-05-08 21:23:11 -07:00
2019-05-07 22:03:58 -07:00
2019-05-24 17:36:45 +02:00
2019-05-24 17:27:11 +02:00
2019-05-24 17:27:11 +02:00
2019-05-07 21:12:44 -07:00
2019-05-12 18:16:31 -04:00
2019-05-24 17:27:12 +02:00
2019-05-13 15:08:16 -07:00
2019-05-13 15:08:16 -07:00
2019-05-15 16:05:47 -07:00
2019-05-14 09:47:47 -07:00
2019-05-14 09:47:48 -07:00
2019-05-21 11:28:39 +02:00
2019-05-14 09:47:44 -07:00
2019-05-14 09:47:48 -07:00
2019-05-24 17:36:45 +02:00
2019-05-24 17:36:45 +02:00
2019-05-21 11:28:39 +02:00
2019-05-21 11:28:39 +02:00
2019-05-21 11:28:39 +02:00
2019-05-21 11:28:39 +02:00
2019-05-21 11:28:39 +02:00
2019-05-14 19:52:52 -07:00
2019-05-24 17:36:45 +02:00
2019-05-24 17:37:52 +02:00
2019-05-14 19:52:49 -07:00
2019-05-07 18:48:09 -07:00
2019-05-24 17:27:11 +02:00
2019-05-24 17:27:11 +02:00
2019-05-24 17:36:45 +02:00
2019-05-24 17:36:45 +02:00
2019-05-14 19:52:48 -07:00
2019-05-15 23:39:38 +02:00
2019-05-14 19:52:49 -07:00
2019-05-21 11:28:46 +02:00
2019-05-24 17:39:02 +02:00
2019-05-14 19:52:49 -07:00
2019-05-16 15:55:48 -07:00
2019-05-21 11:28:45 +02:00
2019-05-24 17:37:53 +02:00
2019-05-07 20:17:51 -07:00
2019-05-13 09:23:18 -04:00
2019-05-14 09:47:50 -07:00
2019-05-14 19:52:53 -07:00
2019-05-14 09:47:50 -07:00
2019-05-14 09:47:49 -07:00
2019-05-21 11:28:45 +02:00
2019-05-14 09:47:46 -07:00
2019-05-14 19:52:48 -07:00
2019-05-14 19:52:48 -07:00
2019-05-14 09:47:49 -07:00
2019-05-14 19:52:48 -07:00
2019-05-14 10:55:54 -07:00
2019-05-24 17:27:10 +02:00
2019-05-19 10:58:45 -07:00
2019-05-14 17:19:47 +02:00
2019-05-19 10:35:20 -07:00
2019-05-24 17:27:11 +02:00
2019-05-16 10:29:00 -07:00
2019-05-14 09:47:51 -07:00
2019-05-14 10:30:10 -07:00
2019-05-21 10:50:45 +02:00
2019-05-17 10:33:30 -07:00
2019-05-21 11:28:45 +02:00
2019-05-13 10:51:31 +02:00
2019-05-24 17:36:45 +02:00
2019-05-14 19:52:48 -07:00
2019-05-24 17:36:45 +02:00
2019-05-24 17:36:45 +02:00
2019-05-24 17:36:45 +02:00
2019-05-14 19:52:51 -07:00
2019-05-14 19:52:48 -07:00
2019-05-14 19:52:48 -07:00
2019-05-24 17:36:45 +02:00
2019-05-24 17:36:45 +02:00
2019-05-14 19:52:48 -07:00
2019-05-17 10:08:59 -07:00
2019-05-14 19:52:51 -07:00
2019-05-16 09:45:20 -07:00
2019-05-08 22:14:36 +02:00
2019-05-21 11:28:46 +02:00
2019-05-21 11:28:46 +02:00
2019-05-07 12:47:47 -03:00
2019-05-14 19:52:48 -07:00
2019-05-24 17:39:00 +02:00
2019-05-07 20:17:51 -07:00
2019-05-16 12:17:50 -07:00
2019-05-16 15:51:55 -07:00
2019-05-24 17:36:45 +02:00
2019-05-21 11:28:46 +02:00
2019-05-16 16:16:18 -07:00
2019-05-24 17:39:02 +02:00
2019-05-08 10:03:52 -07:00
2019-05-14 09:47:45 -07:00
2019-05-24 17:27:11 +02:00
2019-05-24 17:27:13 +02:00
2019-05-24 17:27:13 +02:00
2019-05-12 13:11:36 -04:00
2019-05-24 17:39:00 +02:00
2019-05-18 15:52:26 -07:00
2019-05-14 09:47:45 -07:00
2019-05-15 17:35:54 +01:00
2019-05-24 17:36:47 +02:00