mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
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 <[email protected]> Reviewed-by: David Vrabel <[email protected]> Reviewed-by: Stefano Stabellini <[email protected]> Signed-off-by: David Vrabel <[email protected]>
This commit is contained in:
parent
1084b1988d
commit
008c320a96
3 changed files with 69 additions and 1 deletions
|
|
@ -776,6 +776,32 @@ void gnttab_batch_copy(struct gnttab_copy *batch, unsigned count)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(gnttab_batch_copy);
|
||||
|
||||
void gnttab_foreach_grant_in_range(struct page *page,
|
||||
unsigned int offset,
|
||||
unsigned int len,
|
||||
xen_grant_fn_t fn,
|
||||
void *data)
|
||||
{
|
||||
unsigned int goffset;
|
||||
unsigned int glen;
|
||||
unsigned long xen_pfn;
|
||||
|
||||
len = min_t(unsigned int, PAGE_SIZE - offset, len);
|
||||
goffset = xen_offset_in_page(offset);
|
||||
|
||||
xen_pfn = page_to_xen_pfn(page) + XEN_PFN_DOWN(offset);
|
||||
|
||||
while (len) {
|
||||
glen = min_t(unsigned int, XEN_PAGE_SIZE - goffset, len);
|
||||
fn(pfn_to_gfn(xen_pfn), goffset, glen, data);
|
||||
|
||||
goffset = 0;
|
||||
xen_pfn++;
|
||||
len -= glen;
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(gnttab_foreach_grant_in_range);
|
||||
|
||||
int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
|
||||
struct gnttab_map_grant_ref *kmap_ops,
|
||||
struct page **pages, unsigned int count)
|
||||
|
|
|
|||
Loading…
Reference in a new issue