diff options
Diffstat (limited to 'arch/x86/pci/common.c')
-rw-r--r-- | arch/x86/pci/common.c | 128 |
1 files changed, 16 insertions, 112 deletions
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 981c2dbd72cc..d491deddebae 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c | |||
@@ -456,19 +456,25 @@ void __init dmi_check_pciprobe(void) | |||
456 | dmi_check_system(pciprobe_dmi_table); | 456 | dmi_check_system(pciprobe_dmi_table); |
457 | } | 457 | } |
458 | 458 | ||
459 | struct pci_bus *pcibios_scan_root(int busnum) | 459 | void pcibios_scan_root(int busnum) |
460 | { | 460 | { |
461 | struct pci_bus *bus = NULL; | 461 | struct pci_bus *bus; |
462 | struct pci_sysdata *sd; | ||
463 | LIST_HEAD(resources); | ||
462 | 464 | ||
463 | while ((bus = pci_find_next_bus(bus)) != NULL) { | 465 | sd = kzalloc(sizeof(*sd), GFP_KERNEL); |
464 | if (bus->number == busnum) { | 466 | if (!sd) { |
465 | /* Already scanned */ | 467 | printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busnum); |
466 | return bus; | 468 | return; |
467 | } | 469 | } |
470 | sd->node = x86_pci_root_bus_node(busnum); | ||
471 | x86_pci_root_bus_resources(busnum, &resources); | ||
472 | printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum); | ||
473 | bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources); | ||
474 | if (!bus) { | ||
475 | pci_free_resource_list(&resources); | ||
476 | kfree(sd); | ||
468 | } | 477 | } |
469 | |||
470 | return pci_scan_bus_on_node(busnum, &pci_root_ops, | ||
471 | get_mp_bus_to_node(busnum)); | ||
472 | } | 478 | } |
473 | 479 | ||
474 | void __init pcibios_set_cache_line_size(void) | 480 | void __init pcibios_set_cache_line_size(void) |
@@ -677,105 +683,3 @@ int pci_ext_cfg_avail(void) | |||
677 | else | 683 | else |
678 | return 0; | 684 | return 0; |
679 | } | 685 | } |
680 | |||
681 | struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node) | ||
682 | { | ||
683 | LIST_HEAD(resources); | ||
684 | struct pci_bus *bus = NULL; | ||
685 | struct pci_sysdata *sd; | ||
686 | |||
687 | /* | ||
688 | * Allocate per-root-bus (not per bus) arch-specific data. | ||
689 | * TODO: leak; this memory is never freed. | ||
690 | * It's arguable whether it's worth the trouble to care. | ||
691 | */ | ||
692 | sd = kzalloc(sizeof(*sd), GFP_KERNEL); | ||
693 | if (!sd) { | ||
694 | printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busno); | ||
695 | return NULL; | ||
696 | } | ||
697 | sd->node = node; | ||
698 | x86_pci_root_bus_resources(busno, &resources); | ||
699 | printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busno); | ||
700 | bus = pci_scan_root_bus(NULL, busno, ops, sd, &resources); | ||
701 | if (!bus) { | ||
702 | pci_free_resource_list(&resources); | ||
703 | kfree(sd); | ||
704 | } | ||
705 | |||
706 | return bus; | ||
707 | } | ||
708 | |||
709 | struct pci_bus *pci_scan_bus_with_sysdata(int busno) | ||
710 | { | ||
711 | return pci_scan_bus_on_node(busno, &pci_root_ops, -1); | ||
712 | } | ||
713 | |||
714 | /* | ||
715 | * NUMA info for PCI busses | ||
716 | * | ||
717 | * Early arch code is responsible for filling in reasonable values here. | ||
718 | * A node id of "-1" means "use current node". In other words, if a bus | ||
719 | * has a -1 node id, it's not tightly coupled to any particular chunk | ||
720 | * of memory (as is the case on some Nehalem systems). | ||
721 | */ | ||
722 | #ifdef CONFIG_NUMA | ||
723 | |||
724 | #define BUS_NR 256 | ||
725 | |||
726 | #ifdef CONFIG_X86_64 | ||
727 | |||
728 | static int mp_bus_to_node[BUS_NR] = { | ||
729 | [0 ... BUS_NR - 1] = -1 | ||
730 | }; | ||
731 | |||
732 | void set_mp_bus_to_node(int busnum, int node) | ||
733 | { | ||
734 | if (busnum >= 0 && busnum < BUS_NR) | ||
735 | mp_bus_to_node[busnum] = node; | ||
736 | } | ||
737 | |||
738 | int get_mp_bus_to_node(int busnum) | ||
739 | { | ||
740 | int node = -1; | ||
741 | |||
742 | if (busnum < 0 || busnum > (BUS_NR - 1)) | ||
743 | return node; | ||
744 | |||
745 | node = mp_bus_to_node[busnum]; | ||
746 | |||
747 | /* | ||
748 | * let numa_node_id to decide it later in dma_alloc_pages | ||
749 | * if there is no ram on that node | ||
750 | */ | ||
751 | if (node != -1 && !node_online(node)) | ||
752 | node = -1; | ||
753 | |||
754 | return node; | ||
755 | } | ||
756 | |||
757 | #else /* CONFIG_X86_32 */ | ||
758 | |||
759 | static int mp_bus_to_node[BUS_NR] = { | ||
760 | [0 ... BUS_NR - 1] = -1 | ||
761 | }; | ||
762 | |||
763 | void set_mp_bus_to_node(int busnum, int node) | ||
764 | { | ||
765 | if (busnum >= 0 && busnum < BUS_NR) | ||
766 | mp_bus_to_node[busnum] = (unsigned char) node; | ||
767 | } | ||
768 | |||
769 | int get_mp_bus_to_node(int busnum) | ||
770 | { | ||
771 | int node; | ||
772 | |||
773 | if (busnum < 0 || busnum > (BUS_NR - 1)) | ||
774 | return 0; | ||
775 | node = mp_bus_to_node[busnum]; | ||
776 | return node; | ||
777 | } | ||
778 | |||
779 | #endif /* CONFIG_X86_32 */ | ||
780 | |||
781 | #endif /* CONFIG_NUMA */ | ||