aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Grall <julien.grall@citrix.com>2015-10-13 12:50:12 -0400
committerDavid Vrabel <david.vrabel@citrix.com>2015-10-23 09:20:46 -0400
commitf73314b28148f9ee9f89a0ae961c8fb36e3269fa (patch)
tree723535d3e14456d2c36d75ebfb97774f74998407
parent9cce2914e2b21339dca12c91dc9f35790366cc4c (diff)
xen/grant-table: Add an helper to iterate over a specific number of grants
With the 64KB page granularity support on ARM64, a Linux page may be split accross multiple grant. Currently we have the helper gnttab_foreach_grant_in_grant to break a Linux page based on an offset and a len, but it doesn't fit when we only have a number of grants in hand. Introduce a new helper which take an array of Linux page and a number of grant and will figure out the address of each grant. Signed-off-by: Julien Grall <julien.grall@citrix.com> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
-rw-r--r--drivers/xen/grant-table.c22
-rw-r--r--include/xen/grant_table.h6
2 files changed, 28 insertions, 0 deletions
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 72d633962095..c49f79ed58c5 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -802,6 +802,28 @@ void gnttab_foreach_grant_in_range(struct page *page,
802} 802}
803EXPORT_SYMBOL_GPL(gnttab_foreach_grant_in_range); 803EXPORT_SYMBOL_GPL(gnttab_foreach_grant_in_range);
804 804
805void gnttab_foreach_grant(struct page **pages,
806 unsigned int nr_grefs,
807 xen_grant_fn_t fn,
808 void *data)
809{
810 unsigned int goffset = 0;
811 unsigned long xen_pfn = 0;
812 unsigned int i;
813
814 for (i = 0; i < nr_grefs; i++) {
815 if ((i % XEN_PFN_PER_PAGE) == 0) {
816 xen_pfn = page_to_xen_pfn(pages[i / XEN_PFN_PER_PAGE]);
817 goffset = 0;
818 }
819
820 fn(pfn_to_gfn(xen_pfn), goffset, XEN_PAGE_SIZE, data);
821
822 goffset += XEN_PAGE_SIZE;
823 xen_pfn++;
824 }
825}
826
805int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, 827int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
806 struct gnttab_map_grant_ref *kmap_ops, 828 struct gnttab_map_grant_ref *kmap_ops,
807 struct page **pages, unsigned int count) 829 struct page **pages, unsigned int count)
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
index e17a4b381a16..34b1379f9777 100644
--- a/include/xen/grant_table.h
+++ b/include/xen/grant_table.h
@@ -264,6 +264,12 @@ static inline void gnttab_for_one_grant(struct page *page, unsigned int offset,
264 gnttab_foreach_grant_in_range(page, offset, len, fn, data); 264 gnttab_foreach_grant_in_range(page, offset, len, fn, data);
265} 265}
266 266
267/* Get @nr_grefs grants from an array of page and call fn for each grant */
268void gnttab_foreach_grant(struct page **pages,
269 unsigned int nr_grefs,
270 xen_grant_fn_t fn,
271 void *data);
272
267/* Get the number of grant in a specified region 273/* Get the number of grant in a specified region
268 * 274 *
269 * start: Offset from the beginning of the first page 275 * start: Offset from the beginning of the first page