Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1603706

[RFC PATCHv2 02/21] cma: Introduce cma_for_each_area

From Laura Abbott <labbott@redhat.com>
Newsgroups linux.kernel
Subject [RFC PATCHv2 02/21] cma: Introduce cma_for_each_area
Date 2017-03-18 02:50 +0100
Message-ID <tmbFf-7g0-7@gated-at.bofh.it> (permalink)
References <tmb2y-6Yb-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Frameworks (e.g. Ion) may want to iterate over each possible CMA area to
allow for enumeration. Introduce a function to allow a callback.

Signed-off-by: Laura Abbott <labbott@redhat.com>
---
 include/linux/cma.h |  2 ++
 mm/cma.c            | 14 ++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/include/linux/cma.h b/include/linux/cma.h
index d41d1f8..3e8fbf5 100644
--- a/include/linux/cma.h
+++ b/include/linux/cma.h
@@ -34,4 +34,6 @@ extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
 extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
 			      gfp_t gfp_mask);
 extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count);
+
+extern int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data);
 #endif
diff --git a/mm/cma.c b/mm/cma.c
index 0d187b1..9a040e1 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -498,3 +498,17 @@ bool cma_release(struct cma *cma, const struct page *pages, unsigned int count)
 
 	return true;
 }
+
+int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data)
+{
+	int i;
+
+	for (i = 0; i < cma_area_count; i++) {
+		int ret = it(&cma_areas[i], data);
+
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCHv2 00/21] Ion clean in preparation for moving out of staging Laura Abbott <labbott@redhat.com> - 2017-03-18 02:20 +0100
  [RFC PATCHv2 18/21] staging: android: ion: Rework heap registration/enumeration Laura Abbott <labbott@redhat.com> - 2017-03-18 02:30 +0100
  [RFC PATCHv2 14/21] staging: android: ion: Stop butchering the DMA address Laura Abbott <labbott@redhat.com> - 2017-03-18 02:30 +0100
  [RFC PATCHv2 02/21] cma: Introduce cma_for_each_area Laura Abbott <labbott@redhat.com> - 2017-03-18 02:50 +0100
  [RFC PATCHv2 11/21] staging: android: ion: Remove duplicate ION_IOC_MAP Laura Abbott <labbott@redhat.com> - 2017-03-18 03:10 +0100
  [RFC PATCHv2 20/21] staging: android: ion: Remove ion_handle and ion_client Laura Abbott <labbott@redhat.com> - 2017-03-18 03:10 +0100
  [RFC PATCHv2 07/21] staging: android: ion: Remove page faulting support Laura Abbott <labbott@redhat.com> - 2017-03-18 03:50 +0100
  [RFC PATCHv2 10/21] staging: android: ion: Remove import interface Laura Abbott <labbott@redhat.com> - 2017-03-18 04:00 +0100
  [RFC PATCHv2 03/21] staging: android: ion: Remove dmap_cnt Laura Abbott <labbott@redhat.com> - 2017-03-18 04:00 +0100
  [RFC PATCHv2 15/21] staging: android: ion: Break the ABI in the name of forward progress Laura Abbott <labbott@redhat.com> - 2017-03-18 04:10 +0100
  [RFC PATCHv2 21/21] staging: android: ion: Set query return value Laura Abbott <labbott@redhat.com> - 2017-03-18 04:40 +0100
  [RFC PATCHv2 04/21] staging: android: ion: Remove alignment from allocation field Laura Abbott <labbott@redhat.com> - 2017-03-18 05:00 +0100
  [RFC PATCHv2 06/21] staging: android: ion: Call dma_map_sg for syncing and mapping Laura Abbott <labbott@redhat.com> - 2017-03-18 15:50 +0100

csiph-web