diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/hpet.c | 51 | ||||
-rw-r--r-- | drivers/xen/grant-table.c | 16 |
2 files changed, 17 insertions, 50 deletions
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index 465ad35ed38f..1399971be689 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c | |||
@@ -731,14 +731,14 @@ static unsigned long hpet_calibrate(struct hpets *hpetp) | |||
731 | 731 | ||
732 | int hpet_alloc(struct hpet_data *hdp) | 732 | int hpet_alloc(struct hpet_data *hdp) |
733 | { | 733 | { |
734 | u64 cap, mcfg, hpet_config; | 734 | u64 cap, mcfg; |
735 | struct hpet_dev *devp; | 735 | struct hpet_dev *devp; |
736 | u32 i, ntimer, irq; | 736 | u32 i, ntimer; |
737 | struct hpets *hpetp; | 737 | struct hpets *hpetp; |
738 | size_t siz; | 738 | size_t siz; |
739 | struct hpet __iomem *hpet; | 739 | struct hpet __iomem *hpet; |
740 | static struct hpets *last = NULL; | 740 | static struct hpets *last = NULL; |
741 | unsigned long period, irq_bitmap; | 741 | unsigned long period; |
742 | unsigned long long temp; | 742 | unsigned long long temp; |
743 | 743 | ||
744 | /* | 744 | /* |
@@ -765,47 +765,11 @@ int hpet_alloc(struct hpet_data *hdp) | |||
765 | hpetp->hp_hpet_phys = hdp->hd_phys_address; | 765 | hpetp->hp_hpet_phys = hdp->hd_phys_address; |
766 | 766 | ||
767 | hpetp->hp_ntimer = hdp->hd_nirqs; | 767 | hpetp->hp_ntimer = hdp->hd_nirqs; |
768 | hpet = hpetp->hp_hpet; | ||
769 | |||
770 | /* Assign IRQs statically for legacy devices */ | ||
771 | hpetp->hp_dev[0].hd_hdwirq = hdp->hd_irq[0]; | ||
772 | hpetp->hp_dev[1].hd_hdwirq = hdp->hd_irq[1]; | ||
773 | |||
774 | /* Assign IRQs dynamically for the others */ | ||
775 | for (i = 2, devp = &hpetp->hp_dev[2]; i < hdp->hd_nirqs; i++, devp++) { | ||
776 | struct hpet_timer __iomem *timer; | ||
777 | 768 | ||
778 | timer = &hpet->hpet_timers[devp - hpetp->hp_dev]; | 769 | for (i = 0; i < hdp->hd_nirqs; i++) |
770 | hpetp->hp_dev[i].hd_hdwirq = hdp->hd_irq[i]; | ||
779 | 771 | ||
780 | /* Check if there's already an IRQ assigned to the timer */ | 772 | hpet = hpetp->hp_hpet; |
781 | if (hdp->hd_irq[i]) { | ||
782 | hpetp->hp_dev[i].hd_hdwirq = hdp->hd_irq[i]; | ||
783 | continue; | ||
784 | } | ||
785 | |||
786 | hpet_config = readq(&timer->hpet_config); | ||
787 | irq_bitmap = (hpet_config & Tn_INT_ROUTE_CAP_MASK) | ||
788 | >> Tn_INT_ROUTE_CAP_SHIFT; | ||
789 | if (!irq_bitmap) | ||
790 | irq = 0; /* No valid IRQ Assignable */ | ||
791 | else { | ||
792 | irq = find_first_bit(&irq_bitmap, 32); | ||
793 | do { | ||
794 | hpet_config |= irq << Tn_INT_ROUTE_CNF_SHIFT; | ||
795 | writeq(hpet_config, &timer->hpet_config); | ||
796 | |||
797 | /* | ||
798 | * Verify whether we have written a valid | ||
799 | * IRQ number by reading it back again | ||
800 | */ | ||
801 | hpet_config = readq(&timer->hpet_config); | ||
802 | if (irq == (hpet_config & Tn_INT_ROUTE_CNF_MASK) | ||
803 | >> Tn_INT_ROUTE_CNF_SHIFT) | ||
804 | break; /* Success */ | ||
805 | } while ((irq = (find_next_bit(&irq_bitmap, 32, irq)))); | ||
806 | } | ||
807 | hpetp->hp_dev[i].hd_hdwirq = irq; | ||
808 | } | ||
809 | 773 | ||
810 | cap = readq(&hpet->hpet_cap); | 774 | cap = readq(&hpet->hpet_cap); |
811 | 775 | ||
@@ -836,8 +800,7 @@ int hpet_alloc(struct hpet_data *hdp) | |||
836 | hpetp->hp_which, hdp->hd_phys_address, | 800 | hpetp->hp_which, hdp->hd_phys_address, |
837 | hpetp->hp_ntimer > 1 ? "s" : ""); | 801 | hpetp->hp_ntimer > 1 ? "s" : ""); |
838 | for (i = 0; i < hpetp->hp_ntimer; i++) | 802 | for (i = 0; i < hpetp->hp_ntimer; i++) |
839 | printk("%s %d", i > 0 ? "," : "", | 803 | printk("%s %d", i > 0 ? "," : "", hdp->hd_irq[i]); |
840 | hpetp->hp_dev[i].hd_hdwirq); | ||
841 | printk("\n"); | 804 | printk("\n"); |
842 | 805 | ||
843 | printk(KERN_INFO "hpet%u: %u %d-bit timers, %Lu Hz\n", | 806 | printk(KERN_INFO "hpet%u: %u %d-bit timers, %Lu Hz\n", |
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; |