diff options
author | Julien Grall <julien.grall@citrix.com> | 2015-06-19 12:49:03 -0400 |
---|---|---|
committer | David Vrabel <david.vrabel@citrix.com> | 2015-10-23 09:20:33 -0400 |
commit | 008c320a96d218712043f8db0111d5472697785c (patch) | |
tree | ad1140a3a51567e5bb14b71fe002ba40db3bf681 /drivers/xen | |
parent | 1084b1988d22dc165c9dbbc2b0e057f9248ac4db (diff) |
xen/grant: Introduce helpers to split a page into grant
Currently, a grant is always based on the Xen page granularity (i.e
4KB). When Linux is using a different page granularity, a single page
will be split between multiple grants.
The new helpers will be in charge of splitting the Linux page into grants
and call a function given by the caller on each grant.
Also provide an helper to count the number of grants within a given
contiguous region.
Note that the x86/include/asm/xen/page.h is now including
xen/interface/grant_table.h rather than xen/grant_table.h. It's
necessary because xen/grant_table.h depends on asm/xen/page.h and will
break the compilation. Furthermore, only definition in
interface/grant_table.h is required.
Signed-off-by: Julien Grall <julien.grall@citrix.com>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/grant-table.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index a4b702c9ac68..dbeaa67dec47 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c | |||
@@ -776,6 +776,32 @@ void gnttab_batch_copy(struct gnttab_copy *batch, unsigned count) | |||
776 | } | 776 | } |
777 | EXPORT_SYMBOL_GPL(gnttab_batch_copy); | 777 | EXPORT_SYMBOL_GPL(gnttab_batch_copy); |
778 | 778 | ||
779 | void gnttab_foreach_grant_in_range(struct page *page, | ||
780 | unsigned int offset, | ||
781 | unsigned int len, | ||
782 | xen_grant_fn_t fn, | ||
783 | void *data) | ||
784 | { | ||
785 | unsigned int goffset; | ||
786 | unsigned int glen; | ||
787 | unsigned long xen_pfn; | ||
788 | |||
789 | len = min_t(unsigned int, PAGE_SIZE - offset, len); | ||
790 | goffset = xen_offset_in_page(offset); | ||
791 | |||
792 | xen_pfn = page_to_xen_pfn(page) + XEN_PFN_DOWN(offset); | ||
793 | |||
794 | while (len) { | ||
795 | glen = min_t(unsigned int, XEN_PAGE_SIZE - goffset, len); | ||
796 | fn(pfn_to_gfn(xen_pfn), goffset, glen, data); | ||
797 | |||
798 | goffset = 0; | ||
799 | xen_pfn++; | ||
800 | len -= glen; | ||
801 | } | ||
802 | } | ||
803 | EXPORT_SYMBOL_GPL(gnttab_foreach_grant_in_range); | ||
804 | |||
779 | int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, | 805 | int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, |
780 | struct gnttab_map_grant_ref *kmap_ops, | 806 | struct gnttab_map_grant_ref *kmap_ops, |
781 | struct page **pages, unsigned int count) | 807 | struct page **pages, unsigned int count) |