diff options
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/grant-table.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index ea94dbabf9a9..d85dc6d41c2a 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c | |||
@@ -381,11 +381,15 @@ EXPORT_SYMBOL_GPL(gnttab_cancel_free_callback); | |||
381 | static int grow_gnttab_list(unsigned int more_frames) | 381 | static int grow_gnttab_list(unsigned int more_frames) |
382 | { | 382 | { |
383 | unsigned int new_nr_grant_frames, extra_entries, i; | 383 | unsigned int new_nr_grant_frames, extra_entries, i; |
384 | unsigned int nr_glist_frames, new_nr_glist_frames; | ||
384 | 385 | ||
385 | new_nr_grant_frames = nr_grant_frames + more_frames; | 386 | new_nr_grant_frames = nr_grant_frames + more_frames; |
386 | extra_entries = more_frames * GREFS_PER_GRANT_FRAME; | 387 | extra_entries = more_frames * GREFS_PER_GRANT_FRAME; |
387 | 388 | ||
388 | for (i = nr_grant_frames; i < new_nr_grant_frames; i++) { | 389 | nr_glist_frames = (nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP; |
390 | new_nr_glist_frames = | ||
391 | (new_nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP; | ||
392 | for (i = nr_glist_frames; i < new_nr_glist_frames; i++) { | ||
389 | gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_ATOMIC); | 393 | gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_ATOMIC); |
390 | if (!gnttab_list[i]) | 394 | if (!gnttab_list[i]) |
391 | goto grow_nomem; | 395 | goto grow_nomem; |
@@ -407,7 +411,7 @@ static int grow_gnttab_list(unsigned int more_frames) | |||
407 | return 0; | 411 | return 0; |
408 | 412 | ||
409 | grow_nomem: | 413 | grow_nomem: |
410 | for ( ; i >= nr_grant_frames; i--) | 414 | for ( ; i >= nr_glist_frames; i--) |
411 | free_page((unsigned long) gnttab_list[i]); | 415 | free_page((unsigned long) gnttab_list[i]); |
412 | return -ENOMEM; | 416 | return -ENOMEM; |
413 | } | 417 | } |
@@ -530,7 +534,7 @@ static int gnttab_expand(unsigned int req_entries) | |||
530 | static int __devinit gnttab_init(void) | 534 | static int __devinit gnttab_init(void) |
531 | { | 535 | { |
532 | int i; | 536 | int i; |
533 | unsigned int max_nr_glist_frames; | 537 | unsigned int max_nr_glist_frames, nr_glist_frames; |
534 | unsigned int nr_init_grefs; | 538 | unsigned int nr_init_grefs; |
535 | 539 | ||
536 | if (!is_running_on_xen()) | 540 | if (!is_running_on_xen()) |
@@ -543,15 +547,15 @@ static int __devinit gnttab_init(void) | |||
543 | * grant reference free list on the current hypervisor. | 547 | * grant reference free list on the current hypervisor. |
544 | */ | 548 | */ |
545 | max_nr_glist_frames = (boot_max_nr_grant_frames * | 549 | max_nr_glist_frames = (boot_max_nr_grant_frames * |
546 | GREFS_PER_GRANT_FRAME / | 550 | GREFS_PER_GRANT_FRAME / RPP); |
547 | (PAGE_SIZE / sizeof(grant_ref_t))); | ||
548 | 551 | ||
549 | gnttab_list = kmalloc(max_nr_glist_frames * sizeof(grant_ref_t *), | 552 | gnttab_list = kmalloc(max_nr_glist_frames * sizeof(grant_ref_t *), |
550 | GFP_KERNEL); | 553 | GFP_KERNEL); |
551 | if (gnttab_list == NULL) | 554 | if (gnttab_list == NULL) |
552 | return -ENOMEM; | 555 | return -ENOMEM; |
553 | 556 | ||
554 | for (i = 0; i < nr_grant_frames; i++) { | 557 | nr_glist_frames = (nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP; |
558 | for (i = 0; i < nr_glist_frames; i++) { | ||
555 | gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_KERNEL); | 559 | gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_KERNEL); |
556 | if (gnttab_list[i] == NULL) | 560 | if (gnttab_list[i] == NULL) |
557 | goto ini_nomem; | 561 | goto ini_nomem; |