diff options
author | Bob Liu <bob.liu@oracle.com> | 2015-04-03 02:42:59 -0400 |
---|---|---|
committer | David Vrabel <david.vrabel@citrix.com> | 2015-04-27 06:41:12 -0400 |
commit | b44166cd46e28dd608d5baa5873047a40f32919c (patch) | |
tree | 799b236c472067869782b2cf937d9d0d87852fc4 /drivers/xen/gntdev.c | |
parent | 325d73bf8fea8af2227240b7305253fb052d3a68 (diff) |
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 <bob.liu@oracle.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Diffstat (limited to 'drivers/xen/gntdev.c')
-rw-r--r-- | drivers/xen/gntdev.c | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index d5bb1a33d0a3..89274850741b 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c | |||
@@ -327,30 +327,10 @@ static int map_grant_pages(struct grant_map *map) | |||
327 | return err; | 327 | return err; |
328 | } | 328 | } |
329 | 329 | ||
330 | struct unmap_grant_pages_callback_data | ||
331 | { | ||
332 | struct completion completion; | ||
333 | int result; | ||
334 | }; | ||
335 | |||
336 | static void unmap_grant_callback(int result, | ||
337 | struct gntab_unmap_queue_data *data) | ||
338 | { | ||
339 | struct unmap_grant_pages_callback_data* d = data->data; | ||
340 | |||
341 | d->result = result; | ||
342 | complete(&d->completion); | ||
343 | } | ||
344 | |||
345 | static int __unmap_grant_pages(struct grant_map *map, int offset, int pages) | 330 | static int __unmap_grant_pages(struct grant_map *map, int offset, int pages) |
346 | { | 331 | { |
347 | int i, err = 0; | 332 | int i, err = 0; |
348 | struct gntab_unmap_queue_data unmap_data; | 333 | struct gntab_unmap_queue_data unmap_data; |
349 | struct unmap_grant_pages_callback_data data; | ||
350 | |||
351 | init_completion(&data.completion); | ||
352 | unmap_data.data = &data; | ||
353 | unmap_data.done= &unmap_grant_callback; | ||
354 | 334 | ||
355 | if (map->notify.flags & UNMAP_NOTIFY_CLEAR_BYTE) { | 335 | if (map->notify.flags & UNMAP_NOTIFY_CLEAR_BYTE) { |
356 | int pgno = (map->notify.addr >> PAGE_SHIFT); | 336 | int pgno = (map->notify.addr >> PAGE_SHIFT); |
@@ -367,11 +347,9 @@ static int __unmap_grant_pages(struct grant_map *map, int offset, int pages) | |||
367 | unmap_data.pages = map->pages + offset; | 347 | unmap_data.pages = map->pages + offset; |
368 | unmap_data.count = pages; | 348 | unmap_data.count = pages; |
369 | 349 | ||
370 | gnttab_unmap_refs_async(&unmap_data); | 350 | err = gnttab_unmap_refs_sync(&unmap_data); |
371 | 351 | if (err) | |
372 | wait_for_completion(&data.completion); | 352 | return err; |
373 | if (data.result) | ||
374 | return data.result; | ||
375 | 353 | ||
376 | for (i = 0; i < pages; i++) { | 354 | for (i = 0; i < pages; i++) { |
377 | if (map->unmap_ops[offset+i].status) | 355 | if (map->unmap_ops[offset+i].status) |