mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
xen/grant: introduce func gnttab_unmap_refs_sync()
There are several place using gnttab async unmap and wait for completion, so move the common code to a function gnttab_unmap_refs_sync(). Signed-off-by: Bob Liu <[email protected]> Acked-by: Roger Pau Monné <[email protected]> Acked-by: Konrad Rzeszutek Wilk <[email protected]> Signed-off-by: David Vrabel <[email protected]>
This commit is contained in:
parent
325d73bf8f
commit
b44166cd46
4 changed files with 35 additions and 53 deletions
|
|
@ -327,30 +327,10 @@ static int map_grant_pages(struct grant_map *map)
|
|||
return err;
|
||||
}
|
||||
|
||||
struct unmap_grant_pages_callback_data
|
||||
{
|
||||
struct completion completion;
|
||||
int result;
|
||||
};
|
||||
|
||||
static void unmap_grant_callback(int result,
|
||||
struct gntab_unmap_queue_data *data)
|
||||
{
|
||||
struct unmap_grant_pages_callback_data* d = data->data;
|
||||
|
||||
d->result = result;
|
||||
complete(&d->completion);
|
||||
}
|
||||
|
||||
static int __unmap_grant_pages(struct grant_map *map, int offset, int pages)
|
||||
{
|
||||
int i, err = 0;
|
||||
struct gntab_unmap_queue_data unmap_data;
|
||||
struct unmap_grant_pages_callback_data data;
|
||||
|
||||
init_completion(&data.completion);
|
||||
unmap_data.data = &data;
|
||||
unmap_data.done= &unmap_grant_callback;
|
||||
|
||||
if (map->notify.flags & UNMAP_NOTIFY_CLEAR_BYTE) {
|
||||
int pgno = (map->notify.addr >> PAGE_SHIFT);
|
||||
|
|
@ -367,11 +347,9 @@ static int __unmap_grant_pages(struct grant_map *map, int offset, int pages)
|
|||
unmap_data.pages = map->pages + offset;
|
||||
unmap_data.count = pages;
|
||||
|
||||
gnttab_unmap_refs_async(&unmap_data);
|
||||
|
||||
wait_for_completion(&data.completion);
|
||||
if (data.result)
|
||||
return data.result;
|
||||
err = gnttab_unmap_refs_sync(&unmap_data);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
for (i = 0; i < pages; i++) {
|
||||
if (map->unmap_ops[offset+i].status)
|
||||
|
|
|
|||
|
|
@ -123,6 +123,11 @@ struct gnttab_ops {
|
|||
int (*query_foreign_access)(grant_ref_t ref);
|
||||
};
|
||||
|
||||
struct unmap_refs_callback_data {
|
||||
struct completion completion;
|
||||
int result;
|
||||
};
|
||||
|
||||
static struct gnttab_ops *gnttab_interface;
|
||||
|
||||
static int grant_table_version;
|
||||
|
|
@ -863,6 +868,29 @@ void gnttab_unmap_refs_async(struct gntab_unmap_queue_data* item)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(gnttab_unmap_refs_async);
|
||||
|
||||
static void unmap_refs_callback(int result,
|
||||
struct gntab_unmap_queue_data *data)
|
||||
{
|
||||
struct unmap_refs_callback_data *d = data->data;
|
||||
|
||||
d->result = result;
|
||||
complete(&d->completion);
|
||||
}
|
||||
|
||||
int gnttab_unmap_refs_sync(struct gntab_unmap_queue_data *item)
|
||||
{
|
||||
struct unmap_refs_callback_data data;
|
||||
|
||||
init_completion(&data.completion);
|
||||
item->data = &data;
|
||||
item->done = &unmap_refs_callback;
|
||||
gnttab_unmap_refs_async(item);
|
||||
wait_for_completion(&data.completion);
|
||||
|
||||
return data.result;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(gnttab_unmap_refs_sync);
|
||||
|
||||
static int gnttab_map_frames_v1(xen_pfn_t *frames, unsigned int nr_gframes)
|
||||
{
|
||||
int rc;
|
||||
|
|
|
|||
Loading…
Reference in a new issue