diff options
69 files changed, 1492 insertions, 1833 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 89cd417651e0..0f71251f12b9 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -1030,6 +1030,10 @@ running once the system is up. | |||
1030 | irqmask=0xMMMM [IA-32] Set a bit mask of IRQs allowed to be assigned | 1030 | irqmask=0xMMMM [IA-32] Set a bit mask of IRQs allowed to be assigned |
1031 | automatically to PCI devices. You can make the kernel | 1031 | automatically to PCI devices. You can make the kernel |
1032 | exclude IRQs of your ISA cards this way. | 1032 | exclude IRQs of your ISA cards this way. |
1033 | pirqaddr=0xAAAAA [IA-32] Specify the physical address | ||
1034 | of the PIRQ table (normally generated | ||
1035 | by the BIOS) if it is outside the | ||
1036 | F0000h-100000h range. | ||
1033 | lastbus=N [IA-32] Scan all buses till bus #N. Can be useful | 1037 | lastbus=N [IA-32] Scan all buses till bus #N. Can be useful |
1034 | if the kernel is unable to find your secondary buses | 1038 | if the kernel is unable to find your secondary buses |
1035 | and you want to tell it explicitly which ones they are. | 1039 | and you want to tell it explicitly which ones they are. |
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c index 9f63ae0f404b..b7808a89d945 100644 --- a/arch/i386/kernel/acpi/boot.c +++ b/arch/i386/kernel/acpi/boot.c | |||
@@ -159,9 +159,15 @@ char *__acpi_map_table(unsigned long phys, unsigned long size) | |||
159 | #endif | 159 | #endif |
160 | 160 | ||
161 | #ifdef CONFIG_PCI_MMCONFIG | 161 | #ifdef CONFIG_PCI_MMCONFIG |
162 | static int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size) | 162 | /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */ |
163 | struct acpi_table_mcfg_config *pci_mmcfg_config; | ||
164 | int pci_mmcfg_config_num; | ||
165 | |||
166 | int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size) | ||
163 | { | 167 | { |
164 | struct acpi_table_mcfg *mcfg; | 168 | struct acpi_table_mcfg *mcfg; |
169 | unsigned long i; | ||
170 | int config_size; | ||
165 | 171 | ||
166 | if (!phys_addr || !size) | 172 | if (!phys_addr || !size) |
167 | return -EINVAL; | 173 | return -EINVAL; |
@@ -172,18 +178,38 @@ static int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size) | |||
172 | return -ENODEV; | 178 | return -ENODEV; |
173 | } | 179 | } |
174 | 180 | ||
175 | if (mcfg->base_reserved) { | 181 | /* how many config structures do we have */ |
176 | printk(KERN_ERR PREFIX "MMCONFIG not in low 4GB of memory\n"); | 182 | pci_mmcfg_config_num = 0; |
183 | i = size - sizeof(struct acpi_table_mcfg); | ||
184 | while (i >= sizeof(struct acpi_table_mcfg_config)) { | ||
185 | ++pci_mmcfg_config_num; | ||
186 | i -= sizeof(struct acpi_table_mcfg_config); | ||
187 | }; | ||
188 | if (pci_mmcfg_config_num == 0) { | ||
189 | printk(KERN_ERR PREFIX "MMCONFIG has no entries\n"); | ||
177 | return -ENODEV; | 190 | return -ENODEV; |
178 | } | 191 | } |
179 | 192 | ||
180 | pci_mmcfg_base_addr = mcfg->base_address; | 193 | config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config); |
194 | pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL); | ||
195 | if (!pci_mmcfg_config) { | ||
196 | printk(KERN_WARNING PREFIX | ||
197 | "No memory for MCFG config tables\n"); | ||
198 | return -ENOMEM; | ||
199 | } | ||
200 | |||
201 | memcpy(pci_mmcfg_config, &mcfg->config, config_size); | ||
202 | for (i = 0; i < pci_mmcfg_config_num; ++i) { | ||
203 | if (mcfg->config[i].base_reserved) { | ||
204 | printk(KERN_ERR PREFIX | ||
205 | "MMCONFIG not in low 4GB of memory\n"); | ||
206 | return -ENODEV; | ||
207 | } | ||
208 | } | ||
181 | 209 | ||
182 | return 0; | 210 | return 0; |
183 | } | 211 | } |
184 | #else | 212 | #endif /* CONFIG_PCI_MMCONFIG */ |
185 | #define acpi_parse_mcfg NULL | ||
186 | #endif /* !CONFIG_PCI_MMCONFIG */ | ||
187 | 213 | ||
188 | #ifdef CONFIG_X86_LOCAL_APIC | 214 | #ifdef CONFIG_X86_LOCAL_APIC |
189 | static int __init | 215 | static int __init |
@@ -507,6 +533,22 @@ acpi_unmap_lsapic(int cpu) | |||
507 | EXPORT_SYMBOL(acpi_unmap_lsapic); | 533 | EXPORT_SYMBOL(acpi_unmap_lsapic); |
508 | #endif /* CONFIG_ACPI_HOTPLUG_CPU */ | 534 | #endif /* CONFIG_ACPI_HOTPLUG_CPU */ |
509 | 535 | ||
536 | int | ||
537 | acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base) | ||
538 | { | ||
539 | /* TBD */ | ||
540 | return -EINVAL; | ||
541 | } | ||
542 | EXPORT_SYMBOL(acpi_register_ioapic); | ||
543 | |||
544 | int | ||
545 | acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base) | ||
546 | { | ||
547 | /* TBD */ | ||
548 | return -EINVAL; | ||
549 | } | ||
550 | EXPORT_SYMBOL(acpi_unregister_ioapic); | ||
551 | |||
510 | static unsigned long __init | 552 | static unsigned long __init |
511 | acpi_scan_rsdp ( | 553 | acpi_scan_rsdp ( |
512 | unsigned long start, | 554 | unsigned long start, |
@@ -1123,7 +1165,6 @@ int __init acpi_boot_init(void) | |||
1123 | acpi_process_madt(); | 1165 | acpi_process_madt(); |
1124 | 1166 | ||
1125 | acpi_table_parse(ACPI_HPET, acpi_parse_hpet); | 1167 | acpi_table_parse(ACPI_HPET, acpi_parse_hpet); |
1126 | acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg); | ||
1127 | 1168 | ||
1128 | return 0; | 1169 | return 0; |
1129 | } | 1170 | } |
diff --git a/arch/i386/pci/common.c b/arch/i386/pci/common.c index 720975e1af50..87325263cd4f 100644 --- a/arch/i386/pci/common.c +++ b/arch/i386/pci/common.c | |||
@@ -25,7 +25,8 @@ unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 | | |||
25 | 25 | ||
26 | int pci_routeirq; | 26 | int pci_routeirq; |
27 | int pcibios_last_bus = -1; | 27 | int pcibios_last_bus = -1; |
28 | struct pci_bus *pci_root_bus = NULL; | 28 | unsigned long pirq_table_addr; |
29 | struct pci_bus *pci_root_bus; | ||
29 | struct pci_raw_ops *raw_pci_ops; | 30 | struct pci_raw_ops *raw_pci_ops; |
30 | 31 | ||
31 | static int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value) | 32 | static int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value) |
@@ -133,7 +134,7 @@ struct pci_bus * __devinit pcibios_scan_root(int busnum) | |||
133 | 134 | ||
134 | printk("PCI: Probing PCI hardware (bus %02x)\n", busnum); | 135 | printk("PCI: Probing PCI hardware (bus %02x)\n", busnum); |
135 | 136 | ||
136 | return pci_scan_bus(busnum, &pci_root_ops, NULL); | 137 | return pci_scan_bus_parented(NULL, busnum, &pci_root_ops, NULL); |
137 | } | 138 | } |
138 | 139 | ||
139 | extern u8 pci_cache_line_size; | 140 | extern u8 pci_cache_line_size; |
@@ -188,6 +189,9 @@ char * __devinit pcibios_setup(char *str) | |||
188 | } else if (!strcmp(str, "biosirq")) { | 189 | } else if (!strcmp(str, "biosirq")) { |
189 | pci_probe |= PCI_BIOS_IRQ_SCAN; | 190 | pci_probe |= PCI_BIOS_IRQ_SCAN; |
190 | return NULL; | 191 | return NULL; |
192 | } else if (!strncmp(str, "pirqaddr=", 9)) { | ||
193 | pirq_table_addr = simple_strtoul(str+9, NULL, 0); | ||
194 | return NULL; | ||
191 | } | 195 | } |
192 | #endif | 196 | #endif |
193 | #ifdef CONFIG_PCI_DIRECT | 197 | #ifdef CONFIG_PCI_DIRECT |
diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c index 83458f81e661..78ca1ecbb907 100644 --- a/arch/i386/pci/irq.c +++ b/arch/i386/pci/irq.c | |||
@@ -58,6 +58,35 @@ struct irq_router_handler { | |||
58 | int (*pcibios_enable_irq)(struct pci_dev *dev) = NULL; | 58 | int (*pcibios_enable_irq)(struct pci_dev *dev) = NULL; |
59 | 59 | ||
60 | /* | 60 | /* |
61 | * Check passed address for the PCI IRQ Routing Table signature | ||
62 | * and perform checksum verification. | ||
63 | */ | ||
64 | |||
65 | static inline struct irq_routing_table * pirq_check_routing_table(u8 *addr) | ||
66 | { | ||
67 | struct irq_routing_table *rt; | ||
68 | int i; | ||
69 | u8 sum; | ||
70 | |||
71 | rt = (struct irq_routing_table *) addr; | ||
72 | if (rt->signature != PIRQ_SIGNATURE || | ||
73 | rt->version != PIRQ_VERSION || | ||
74 | rt->size % 16 || | ||
75 | rt->size < sizeof(struct irq_routing_table)) | ||
76 | return NULL; | ||
77 | sum = 0; | ||
78 | for (i=0; i < rt->size; i++) | ||
79 | sum += addr[i]; | ||
80 | if (!sum) { | ||
81 | DBG("PCI: Interrupt Routing Table found at 0x%p\n", rt); | ||
82 | return rt; | ||
83 | } | ||
84 | return NULL; | ||
85 | } | ||
86 | |||
87 | |||
88 | |||
89 | /* | ||
61 | * Search 0xf0000 -- 0xfffff for the PCI IRQ Routing Table. | 90 | * Search 0xf0000 -- 0xfffff for the PCI IRQ Routing Table. |
62 | */ | 91 | */ |
63 | 92 | ||
@@ -65,23 +94,17 @@ static struct irq_routing_table * __init pirq_find_routing_table(void) | |||
65 | { | 94 | { |
66 | u8 *addr; | 95 | u8 *addr; |
67 | struct irq_routing_table *rt; | 96 | struct irq_routing_table *rt; |
68 | int i; | ||
69 | u8 sum; | ||
70 | 97 | ||
98 | if (pirq_table_addr) { | ||
99 | rt = pirq_check_routing_table((u8 *) __va(pirq_table_addr)); | ||
100 | if (rt) | ||
101 | return rt; | ||
102 | printk(KERN_WARNING "PCI: PIRQ table NOT found at pirqaddr\n"); | ||
103 | } | ||
71 | for(addr = (u8 *) __va(0xf0000); addr < (u8 *) __va(0x100000); addr += 16) { | 104 | for(addr = (u8 *) __va(0xf0000); addr < (u8 *) __va(0x100000); addr += 16) { |
72 | rt = (struct irq_routing_table *) addr; | 105 | rt = pirq_check_routing_table(addr); |
73 | if (rt->signature != PIRQ_SIGNATURE || | 106 | if (rt) |
74 | rt->version != PIRQ_VERSION || | ||
75 | rt->size % 16 || | ||
76 | rt->size < sizeof(struct irq_routing_table)) | ||
77 | continue; | ||
78 | sum = 0; | ||
79 | for(i=0; i<rt->size; i++) | ||
80 | sum += addr[i]; | ||
81 | if (!sum) { | ||
82 | DBG("PCI: Interrupt Routing Table found at 0x%p\n", rt); | ||
83 | return rt; | 107 | return rt; |
84 | } | ||
85 | } | 108 | } |
86 | return NULL; | 109 | return NULL; |
87 | } | 110 | } |
diff --git a/arch/i386/pci/legacy.c b/arch/i386/pci/legacy.c index 1492e3753869..149a9588c256 100644 --- a/arch/i386/pci/legacy.c +++ b/arch/i386/pci/legacy.c | |||
@@ -45,6 +45,8 @@ static int __init pci_legacy_init(void) | |||
45 | 45 | ||
46 | printk("PCI: Probing PCI hardware\n"); | 46 | printk("PCI: Probing PCI hardware\n"); |
47 | pci_root_bus = pcibios_scan_root(0); | 47 | pci_root_bus = pcibios_scan_root(0); |
48 | if (pci_root_bus) | ||
49 | pci_bus_add_devices(pci_root_bus); | ||
48 | 50 | ||
49 | pcibios_fixup_peer_bridges(); | 51 | pcibios_fixup_peer_bridges(); |
50 | 52 | ||
diff --git a/arch/i386/pci/mmconfig.c b/arch/i386/pci/mmconfig.c index 021a50aa51f4..60f0e7a1162a 100644 --- a/arch/i386/pci/mmconfig.c +++ b/arch/i386/pci/mmconfig.c | |||
@@ -11,11 +11,9 @@ | |||
11 | 11 | ||
12 | #include <linux/pci.h> | 12 | #include <linux/pci.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/acpi.h> | ||
14 | #include "pci.h" | 15 | #include "pci.h" |
15 | 16 | ||
16 | /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */ | ||
17 | u32 pci_mmcfg_base_addr; | ||
18 | |||
19 | #define mmcfg_virt_addr ((void __iomem *) fix_to_virt(FIX_PCIE_MCFG)) | 17 | #define mmcfg_virt_addr ((void __iomem *) fix_to_virt(FIX_PCIE_MCFG)) |
20 | 18 | ||
21 | /* The base address of the last MMCONFIG device accessed */ | 19 | /* The base address of the last MMCONFIG device accessed */ |
@@ -24,10 +22,31 @@ static u32 mmcfg_last_accessed_device; | |||
24 | /* | 22 | /* |
25 | * Functions for accessing PCI configuration space with MMCONFIG accesses | 23 | * Functions for accessing PCI configuration space with MMCONFIG accesses |
26 | */ | 24 | */ |
25 | static u32 get_base_addr(unsigned int seg, int bus) | ||
26 | { | ||
27 | int cfg_num = -1; | ||
28 | struct acpi_table_mcfg_config *cfg; | ||
29 | |||
30 | while (1) { | ||
31 | ++cfg_num; | ||
32 | if (cfg_num >= pci_mmcfg_config_num) { | ||
33 | /* something bad is going on, no cfg table is found. */ | ||
34 | /* so we fall back to the old way we used to do this */ | ||
35 | /* and just rely on the first entry to be correct. */ | ||
36 | return pci_mmcfg_config[0].base_address; | ||
37 | } | ||
38 | cfg = &pci_mmcfg_config[cfg_num]; | ||
39 | if (cfg->pci_segment_group_number != seg) | ||
40 | continue; | ||
41 | if ((cfg->start_bus_number <= bus) && | ||
42 | (cfg->end_bus_number >= bus)) | ||
43 | return cfg->base_address; | ||
44 | } | ||
45 | } | ||
27 | 46 | ||
28 | static inline void pci_exp_set_dev_base(int bus, int devfn) | 47 | static inline void pci_exp_set_dev_base(unsigned int seg, int bus, int devfn) |
29 | { | 48 | { |
30 | u32 dev_base = pci_mmcfg_base_addr | (bus << 20) | (devfn << 12); | 49 | u32 dev_base = get_base_addr(seg, bus) | (bus << 20) | (devfn << 12); |
31 | if (dev_base != mmcfg_last_accessed_device) { | 50 | if (dev_base != mmcfg_last_accessed_device) { |
32 | mmcfg_last_accessed_device = dev_base; | 51 | mmcfg_last_accessed_device = dev_base; |
33 | set_fixmap_nocache(FIX_PCIE_MCFG, dev_base); | 52 | set_fixmap_nocache(FIX_PCIE_MCFG, dev_base); |
@@ -44,7 +63,7 @@ static int pci_mmcfg_read(unsigned int seg, unsigned int bus, | |||
44 | 63 | ||
45 | spin_lock_irqsave(&pci_config_lock, flags); | 64 | spin_lock_irqsave(&pci_config_lock, flags); |
46 | 65 | ||
47 | pci_exp_set_dev_base(bus, devfn); | 66 | pci_exp_set_dev_base(seg, bus, devfn); |
48 | 67 | ||
49 | switch (len) { | 68 | switch (len) { |
50 | case 1: | 69 | case 1: |
@@ -73,7 +92,7 @@ static int pci_mmcfg_write(unsigned int seg, unsigned int bus, | |||
73 | 92 | ||
74 | spin_lock_irqsave(&pci_config_lock, flags); | 93 | spin_lock_irqsave(&pci_config_lock, flags); |
75 | 94 | ||
76 | pci_exp_set_dev_base(bus, devfn); | 95 | pci_exp_set_dev_base(seg, bus, devfn); |
77 | 96 | ||
78 | switch (len) { | 97 | switch (len) { |
79 | case 1: | 98 | case 1: |
@@ -101,7 +120,11 @@ static int __init pci_mmcfg_init(void) | |||
101 | { | 120 | { |
102 | if ((pci_probe & PCI_PROBE_MMCONF) == 0) | 121 | if ((pci_probe & PCI_PROBE_MMCONF) == 0) |
103 | goto out; | 122 | goto out; |
104 | if (!pci_mmcfg_base_addr) | 123 | |
124 | acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg); | ||
125 | if ((pci_mmcfg_config_num == 0) || | ||
126 | (pci_mmcfg_config == NULL) || | ||
127 | (pci_mmcfg_config[0].base_address == 0)) | ||
105 | goto out; | 128 | goto out; |
106 | 129 | ||
107 | /* Kludge for now. Don't use mmconfig on AMD systems because | 130 | /* Kludge for now. Don't use mmconfig on AMD systems because |
diff --git a/arch/i386/pci/numa.c b/arch/i386/pci/numa.c index 9e3695461899..adbe17a38f6f 100644 --- a/arch/i386/pci/numa.c +++ b/arch/i386/pci/numa.c | |||
@@ -115,6 +115,8 @@ static int __init pci_numa_init(void) | |||
115 | return 0; | 115 | return 0; |
116 | 116 | ||
117 | pci_root_bus = pcibios_scan_root(0); | 117 | pci_root_bus = pcibios_scan_root(0); |
118 | if (pci_root_bus) | ||
119 | pci_bus_add_devices(pci_root_bus); | ||
118 | if (num_online_nodes() > 1) | 120 | if (num_online_nodes() > 1) |
119 | for_each_online_node(quad) { | 121 | for_each_online_node(quad) { |
120 | if (quad == 0) | 122 | if (quad == 0) |
diff --git a/arch/i386/pci/pci.h b/arch/i386/pci/pci.h index a8fc80ca69f3..a80f0f55ff51 100644 --- a/arch/i386/pci/pci.h +++ b/arch/i386/pci/pci.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #define PCI_ASSIGN_ALL_BUSSES 0x4000 | 27 | #define PCI_ASSIGN_ALL_BUSSES 0x4000 |
28 | 28 | ||
29 | extern unsigned int pci_probe; | 29 | extern unsigned int pci_probe; |
30 | extern unsigned long pirq_table_addr; | ||
30 | 31 | ||
31 | /* pci-i386.c */ | 32 | /* pci-i386.c */ |
32 | 33 | ||
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index 72dfd9e7de0f..cda06f88c66e 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c | |||
@@ -236,9 +236,7 @@ acpi_parse_iosapic (acpi_table_entry_header *header, const unsigned long end) | |||
236 | if (BAD_MADT_ENTRY(iosapic, end)) | 236 | if (BAD_MADT_ENTRY(iosapic, end)) |
237 | return -EINVAL; | 237 | return -EINVAL; |
238 | 238 | ||
239 | iosapic_init(iosapic->address, iosapic->global_irq_base); | 239 | return iosapic_init(iosapic->address, iosapic->global_irq_base); |
240 | |||
241 | return 0; | ||
242 | } | 240 | } |
243 | 241 | ||
244 | 242 | ||
@@ -772,7 +770,7 @@ EXPORT_SYMBOL(acpi_unmap_lsapic); | |||
772 | 770 | ||
773 | 771 | ||
774 | #ifdef CONFIG_ACPI_NUMA | 772 | #ifdef CONFIG_ACPI_NUMA |
775 | acpi_status __init | 773 | acpi_status __devinit |
776 | acpi_map_iosapic (acpi_handle handle, u32 depth, void *context, void **ret) | 774 | acpi_map_iosapic (acpi_handle handle, u32 depth, void *context, void **ret) |
777 | { | 775 | { |
778 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | 776 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; |
@@ -825,4 +823,28 @@ acpi_map_iosapic (acpi_handle handle, u32 depth, void *context, void **ret) | |||
825 | return AE_OK; | 823 | return AE_OK; |
826 | } | 824 | } |
827 | #endif /* CONFIG_NUMA */ | 825 | #endif /* CONFIG_NUMA */ |
826 | |||
827 | int | ||
828 | acpi_register_ioapic (acpi_handle handle, u64 phys_addr, u32 gsi_base) | ||
829 | { | ||
830 | int err; | ||
831 | |||
832 | if ((err = iosapic_init(phys_addr, gsi_base))) | ||
833 | return err; | ||
834 | |||
835 | #if CONFIG_ACPI_NUMA | ||
836 | acpi_map_iosapic(handle, 0, NULL, NULL); | ||
837 | #endif /* CONFIG_ACPI_NUMA */ | ||
838 | |||
839 | return 0; | ||
840 | } | ||
841 | EXPORT_SYMBOL(acpi_register_ioapic); | ||
842 | |||
843 | int | ||
844 | acpi_unregister_ioapic (acpi_handle handle, u32 gsi_base) | ||
845 | { | ||
846 | return iosapic_remove(gsi_base); | ||
847 | } | ||
848 | EXPORT_SYMBOL(acpi_unregister_ioapic); | ||
849 | |||
828 | #endif /* CONFIG_ACPI_BOOT */ | 850 | #endif /* CONFIG_ACPI_BOOT */ |
diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c index 88b014381df5..c170be095ccd 100644 --- a/arch/ia64/kernel/iosapic.c +++ b/arch/ia64/kernel/iosapic.c | |||
@@ -129,14 +129,13 @@ static struct iosapic { | |||
129 | char __iomem *addr; /* base address of IOSAPIC */ | 129 | char __iomem *addr; /* base address of IOSAPIC */ |
130 | unsigned int gsi_base; /* first GSI assigned to this IOSAPIC */ | 130 | unsigned int gsi_base; /* first GSI assigned to this IOSAPIC */ |
131 | unsigned short num_rte; /* number of RTE in this IOSAPIC */ | 131 | unsigned short num_rte; /* number of RTE in this IOSAPIC */ |
132 | int rtes_inuse; /* # of RTEs in use on this IOSAPIC */ | ||
132 | #ifdef CONFIG_NUMA | 133 | #ifdef CONFIG_NUMA |
133 | unsigned short node; /* numa node association via pxm */ | 134 | unsigned short node; /* numa node association via pxm */ |
134 | #endif | 135 | #endif |
135 | } iosapic_lists[NR_IOSAPICS]; | 136 | } iosapic_lists[NR_IOSAPICS]; |
136 | 137 | ||
137 | static int num_iosapic; | 138 | static unsigned char pcat_compat __devinitdata; /* 8259 compatibility flag */ |
138 | |||
139 | static unsigned char pcat_compat __initdata; /* 8259 compatibility flag */ | ||
140 | 139 | ||
141 | static int iosapic_kmalloc_ok; | 140 | static int iosapic_kmalloc_ok; |
142 | static LIST_HEAD(free_rte_list); | 141 | static LIST_HEAD(free_rte_list); |
@@ -149,7 +148,7 @@ find_iosapic (unsigned int gsi) | |||
149 | { | 148 | { |
150 | int i; | 149 | int i; |
151 | 150 | ||
152 | for (i = 0; i < num_iosapic; i++) { | 151 | for (i = 0; i < NR_IOSAPICS; i++) { |
153 | if ((unsigned) (gsi - iosapic_lists[i].gsi_base) < iosapic_lists[i].num_rte) | 152 | if ((unsigned) (gsi - iosapic_lists[i].gsi_base) < iosapic_lists[i].num_rte) |
154 | return i; | 153 | return i; |
155 | } | 154 | } |
@@ -598,6 +597,7 @@ register_intr (unsigned int gsi, int vector, unsigned char delivery, | |||
598 | rte->refcnt++; | 597 | rte->refcnt++; |
599 | list_add_tail(&rte->rte_list, &iosapic_intr_info[vector].rtes); | 598 | list_add_tail(&rte->rte_list, &iosapic_intr_info[vector].rtes); |
600 | iosapic_intr_info[vector].count++; | 599 | iosapic_intr_info[vector].count++; |
600 | iosapic_lists[index].rtes_inuse++; | ||
601 | } | 601 | } |
602 | else if (vector_is_shared(vector)) { | 602 | else if (vector_is_shared(vector)) { |
603 | struct iosapic_intr_info *info = &iosapic_intr_info[vector]; | 603 | struct iosapic_intr_info *info = &iosapic_intr_info[vector]; |
@@ -778,7 +778,7 @@ void | |||
778 | iosapic_unregister_intr (unsigned int gsi) | 778 | iosapic_unregister_intr (unsigned int gsi) |
779 | { | 779 | { |
780 | unsigned long flags; | 780 | unsigned long flags; |
781 | int irq, vector; | 781 | int irq, vector, index; |
782 | irq_desc_t *idesc; | 782 | irq_desc_t *idesc; |
783 | u32 low32; | 783 | u32 low32; |
784 | unsigned long trigger, polarity; | 784 | unsigned long trigger, polarity; |
@@ -819,6 +819,9 @@ iosapic_unregister_intr (unsigned int gsi) | |||
819 | list_del(&rte->rte_list); | 819 | list_del(&rte->rte_list); |
820 | iosapic_intr_info[vector].count--; | 820 | iosapic_intr_info[vector].count--; |
821 | iosapic_free_rte(rte); | 821 | iosapic_free_rte(rte); |
822 | index = find_iosapic(gsi); | ||
823 | iosapic_lists[index].rtes_inuse--; | ||
824 | WARN_ON(iosapic_lists[index].rtes_inuse < 0); | ||
822 | 825 | ||
823 | trigger = iosapic_intr_info[vector].trigger; | 826 | trigger = iosapic_intr_info[vector].trigger; |
824 | polarity = iosapic_intr_info[vector].polarity; | 827 | polarity = iosapic_intr_info[vector].polarity; |
@@ -952,30 +955,86 @@ iosapic_system_init (int system_pcat_compat) | |||
952 | } | 955 | } |
953 | } | 956 | } |
954 | 957 | ||
955 | void __init | 958 | static inline int |
959 | iosapic_alloc (void) | ||
960 | { | ||
961 | int index; | ||
962 | |||
963 | for (index = 0; index < NR_IOSAPICS; index++) | ||
964 | if (!iosapic_lists[index].addr) | ||
965 | return index; | ||
966 | |||
967 | printk(KERN_WARNING "%s: failed to allocate iosapic\n", __FUNCTION__); | ||
968 | return -1; | ||
969 | } | ||
970 | |||
971 | static inline void | ||
972 | iosapic_free (int index) | ||
973 | { | ||
974 | memset(&iosapic_lists[index], 0, sizeof(iosapic_lists[0])); | ||
975 | } | ||
976 | |||
977 | static inline int | ||
978 | iosapic_check_gsi_range (unsigned int gsi_base, unsigned int ver) | ||
979 | { | ||
980 | int index; | ||
981 | unsigned int gsi_end, base, end; | ||
982 | |||
983 | /* check gsi range */ | ||
984 | gsi_end = gsi_base + ((ver >> 16) & 0xff); | ||
985 | for (index = 0; index < NR_IOSAPICS; index++) { | ||
986 | if (!iosapic_lists[index].addr) | ||
987 | continue; | ||
988 | |||
989 | base = iosapic_lists[index].gsi_base; | ||
990 | end = base + iosapic_lists[index].num_rte - 1; | ||
991 | |||
992 | if (gsi_base < base && gsi_end < base) | ||
993 | continue;/* OK */ | ||
994 | |||
995 | if (gsi_base > end && gsi_end > end) | ||
996 | continue; /* OK */ | ||
997 | |||
998 | return -EBUSY; | ||
999 | } | ||
1000 | return 0; | ||
1001 | } | ||
1002 | |||
1003 | int __devinit | ||
956 | iosapic_init (unsigned long phys_addr, unsigned int gsi_base) | 1004 | iosapic_init (unsigned long phys_addr, unsigned int gsi_base) |
957 | { | 1005 | { |
958 | int num_rte; | 1006 | int num_rte, err, index; |
959 | unsigned int isa_irq, ver; | 1007 | unsigned int isa_irq, ver; |
960 | char __iomem *addr; | 1008 | char __iomem *addr; |
1009 | unsigned long flags; | ||
1010 | |||
1011 | spin_lock_irqsave(&iosapic_lock, flags); | ||
1012 | { | ||
1013 | addr = ioremap(phys_addr, 0); | ||
1014 | ver = iosapic_version(addr); | ||
961 | 1015 | ||
962 | addr = ioremap(phys_addr, 0); | 1016 | if ((err = iosapic_check_gsi_range(gsi_base, ver))) { |
963 | ver = iosapic_version(addr); | 1017 | iounmap(addr); |
1018 | spin_unlock_irqrestore(&iosapic_lock, flags); | ||
1019 | return err; | ||
1020 | } | ||
964 | 1021 | ||
965 | /* | 1022 | /* |
966 | * The MAX_REDIR register holds the highest input pin | 1023 | * The MAX_REDIR register holds the highest input pin |
967 | * number (starting from 0). | 1024 | * number (starting from 0). |
968 | * We add 1 so that we can use it for number of pins (= RTEs) | 1025 | * We add 1 so that we can use it for number of pins (= RTEs) |
969 | */ | 1026 | */ |
970 | num_rte = ((ver >> 16) & 0xff) + 1; | 1027 | num_rte = ((ver >> 16) & 0xff) + 1; |
971 | 1028 | ||
972 | iosapic_lists[num_iosapic].addr = addr; | 1029 | index = iosapic_alloc(); |
973 | iosapic_lists[num_iosapic].gsi_base = gsi_base; | 1030 | iosapic_lists[index].addr = addr; |
974 | iosapic_lists[num_iosapic].num_rte = num_rte; | 1031 | iosapic_lists[index].gsi_base = gsi_base; |
1032 | iosapic_lists[index].num_rte = num_rte; | ||
975 | #ifdef CONFIG_NUMA | 1033 | #ifdef CONFIG_NUMA |
976 | iosapic_lists[num_iosapic].node = MAX_NUMNODES; | 1034 | iosapic_lists[index].node = MAX_NUMNODES; |
977 | #endif | 1035 | #endif |
978 | num_iosapic++; | 1036 | } |
1037 | spin_unlock_irqrestore(&iosapic_lock, flags); | ||
979 | 1038 | ||
980 | if ((gsi_base == 0) && pcat_compat) { | 1039 | if ((gsi_base == 0) && pcat_compat) { |
981 | /* | 1040 | /* |
@@ -986,10 +1045,43 @@ iosapic_init (unsigned long phys_addr, unsigned int gsi_base) | |||
986 | for (isa_irq = 0; isa_irq < 16; ++isa_irq) | 1045 | for (isa_irq = 0; isa_irq < 16; ++isa_irq) |
987 | iosapic_override_isa_irq(isa_irq, isa_irq, IOSAPIC_POL_HIGH, IOSAPIC_EDGE); | 1046 | iosapic_override_isa_irq(isa_irq, isa_irq, IOSAPIC_POL_HIGH, IOSAPIC_EDGE); |
988 | } | 1047 | } |
1048 | return 0; | ||
1049 | } | ||
1050 | |||
1051 | #ifdef CONFIG_HOTPLUG | ||
1052 | int | ||
1053 | iosapic_remove (unsigned int gsi_base) | ||
1054 | { | ||
1055 | int index, err = 0; | ||
1056 | unsigned long flags; | ||
1057 | |||
1058 | spin_lock_irqsave(&iosapic_lock, flags); | ||
1059 | { | ||
1060 | index = find_iosapic(gsi_base); | ||
1061 | if (index < 0) { | ||
1062 | printk(KERN_WARNING "%s: No IOSAPIC for GSI base %u\n", | ||
1063 | __FUNCTION__, gsi_base); | ||
1064 | goto out; | ||
1065 | } | ||
1066 | |||
1067 | if (iosapic_lists[index].rtes_inuse) { | ||
1068 | err = -EBUSY; | ||
1069 | printk(KERN_WARNING "%s: IOSAPIC for GSI base %u is busy\n", | ||
1070 | __FUNCTION__, gsi_base); | ||
1071 | goto out; | ||
1072 | } | ||
1073 | |||
1074 | iounmap(iosapic_lists[index].addr); | ||
1075 | iosapic_free(index); | ||
1076 | } | ||
1077 | out: | ||
1078 | spin_unlock_irqrestore(&iosapic_lock, flags); | ||
1079 | return err; | ||
989 | } | 1080 | } |
1081 | #endif /* CONFIG_HOTPLUG */ | ||
990 | 1082 | ||
991 | #ifdef CONFIG_NUMA | 1083 | #ifdef CONFIG_NUMA |
992 | void __init | 1084 | void __devinit |
993 | map_iosapic_to_node(unsigned int gsi_base, int node) | 1085 | map_iosapic_to_node(unsigned int gsi_base, int node) |
994 | { | 1086 | { |
995 | int index; | 1087 | int index; |
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index e3fc4edea113..720a861f88be 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c | |||
@@ -312,7 +312,7 @@ pci_acpi_scan_root(struct acpi_device *device, int domain, int bus) | |||
312 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, add_window, | 312 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, add_window, |
313 | &info); | 313 | &info); |
314 | 314 | ||
315 | pbus = pci_scan_bus(bus, &pci_root_ops, controller); | 315 | pbus = pci_scan_bus_parented(NULL, bus, &pci_root_ops, controller); |
316 | if (pbus) | 316 | if (pbus) |
317 | pcibios_setup_root_windows(pbus, controller); | 317 | pcibios_setup_root_windows(pbus, controller); |
318 | 318 | ||
@@ -373,6 +373,25 @@ void pcibios_bus_to_resource(struct pci_dev *dev, | |||
373 | res->end = region->end + offset; | 373 | res->end = region->end + offset; |
374 | } | 374 | } |
375 | 375 | ||
376 | static int __devinit is_valid_resource(struct pci_dev *dev, int idx) | ||
377 | { | ||
378 | unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM; | ||
379 | struct resource *devr = &dev->resource[idx]; | ||
380 | |||
381 | if (!dev->bus) | ||
382 | return 0; | ||
383 | for (i=0; i<PCI_BUS_NUM_RESOURCES; i++) { | ||
384 | struct resource *busr = dev->bus->resource[i]; | ||
385 | |||
386 | if (!busr || ((busr->flags ^ devr->flags) & type_mask)) | ||
387 | continue; | ||
388 | if ((devr->start) && (devr->start >= busr->start) && | ||
389 | (devr->end <= busr->end)) | ||
390 | return 1; | ||
391 | } | ||
392 | return 0; | ||
393 | } | ||
394 | |||
376 | static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev) | 395 | static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev) |
377 | { | 396 | { |
378 | struct pci_bus_region region; | 397 | struct pci_bus_region region; |
@@ -386,7 +405,8 @@ static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev) | |||
386 | region.start = dev->resource[i].start; | 405 | region.start = dev->resource[i].start; |
387 | region.end = dev->resource[i].end; | 406 | region.end = dev->resource[i].end; |
388 | pcibios_bus_to_resource(dev, &dev->resource[i], ®ion); | 407 | pcibios_bus_to_resource(dev, &dev->resource[i], ®ion); |
389 | pci_claim_resource(dev, i); | 408 | if ((is_valid_resource(dev, i))) |
409 | pci_claim_resource(dev, i); | ||
390 | } | 410 | } |
391 | } | 411 | } |
392 | 412 | ||
@@ -398,6 +418,10 @@ pcibios_fixup_bus (struct pci_bus *b) | |||
398 | { | 418 | { |
399 | struct pci_dev *dev; | 419 | struct pci_dev *dev; |
400 | 420 | ||
421 | if (b->self) { | ||
422 | pci_read_bridge_bases(b); | ||
423 | pcibios_fixup_device_resources(b->self); | ||
424 | } | ||
401 | list_for_each_entry(dev, &b->devices, bus_list) | 425 | list_for_each_entry(dev, &b->devices, bus_list) |
402 | pcibios_fixup_device_resources(dev); | 426 | pcibios_fixup_device_resources(dev); |
403 | 427 | ||
@@ -418,18 +442,24 @@ pcibios_enable_resources (struct pci_dev *dev, int mask) | |||
418 | u16 cmd, old_cmd; | 442 | u16 cmd, old_cmd; |
419 | int idx; | 443 | int idx; |
420 | struct resource *r; | 444 | struct resource *r; |
445 | unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM; | ||
421 | 446 | ||
422 | if (!dev) | 447 | if (!dev) |
423 | return -EINVAL; | 448 | return -EINVAL; |
424 | 449 | ||
425 | pci_read_config_word(dev, PCI_COMMAND, &cmd); | 450 | pci_read_config_word(dev, PCI_COMMAND, &cmd); |
426 | old_cmd = cmd; | 451 | old_cmd = cmd; |
427 | for (idx=0; idx<6; idx++) { | 452 | for (idx=0; idx<PCI_NUM_RESOURCES; idx++) { |
428 | /* Only set up the desired resources. */ | 453 | /* Only set up the desired resources. */ |
429 | if (!(mask & (1 << idx))) | 454 | if (!(mask & (1 << idx))) |
430 | continue; | 455 | continue; |
431 | 456 | ||
432 | r = &dev->resource[idx]; | 457 | r = &dev->resource[idx]; |
458 | if (!(r->flags & type_mask)) | ||
459 | continue; | ||
460 | if ((idx == PCI_ROM_RESOURCE) && | ||
461 | (!(r->flags & IORESOURCE_ROM_ENABLE))) | ||
462 | continue; | ||
433 | if (!r->start && r->end) { | 463 | if (!r->start && r->end) { |
434 | printk(KERN_ERR | 464 | printk(KERN_ERR |
435 | "PCI: Device %s not available because of resource collisions\n", | 465 | "PCI: Device %s not available because of resource collisions\n", |
@@ -441,8 +471,6 @@ pcibios_enable_resources (struct pci_dev *dev, int mask) | |||
441 | if (r->flags & IORESOURCE_MEM) | 471 | if (r->flags & IORESOURCE_MEM) |
442 | cmd |= PCI_COMMAND_MEMORY; | 472 | cmd |= PCI_COMMAND_MEMORY; |
443 | } | 473 | } |
444 | if (dev->resource[PCI_ROM_RESOURCE].start) | ||
445 | cmd |= PCI_COMMAND_MEMORY; | ||
446 | if (cmd != old_cmd) { | 474 | if (cmd != old_cmd) { |
447 | printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd); | 475 | printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd); |
448 | pci_write_config_word(dev, PCI_COMMAND, cmd); | 476 | pci_write_config_word(dev, PCI_COMMAND, cmd); |
diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c index 6d7b92d72458..70cfb6ffd877 100644 --- a/arch/ppc/kernel/pci.c +++ b/arch/ppc/kernel/pci.c | |||
@@ -1495,7 +1495,7 @@ static struct resource *__pci_mmap_make_offset(struct pci_dev *dev, | |||
1495 | *offset += hose->pci_mem_offset; | 1495 | *offset += hose->pci_mem_offset; |
1496 | res_bit = IORESOURCE_MEM; | 1496 | res_bit = IORESOURCE_MEM; |
1497 | } else { | 1497 | } else { |
1498 | io_offset = (unsigned long)hose->io_base_virt; | 1498 | io_offset = hose->io_base_virt - ___IO_BASE; |
1499 | *offset += io_offset; | 1499 | *offset += io_offset; |
1500 | res_bit = IORESOURCE_IO; | 1500 | res_bit = IORESOURCE_IO; |
1501 | } | 1501 | } |
@@ -1522,7 +1522,7 @@ static struct resource *__pci_mmap_make_offset(struct pci_dev *dev, | |||
1522 | 1522 | ||
1523 | /* found it! construct the final physical address */ | 1523 | /* found it! construct the final physical address */ |
1524 | if (mmap_state == pci_mmap_io) | 1524 | if (mmap_state == pci_mmap_io) |
1525 | *offset += hose->io_base_phys - _IO_BASE; | 1525 | *offset += hose->io_base_phys - io_offset; |
1526 | return rp; | 1526 | return rp; |
1527 | } | 1527 | } |
1528 | 1528 | ||
@@ -1739,6 +1739,23 @@ long sys_pciconfig_iobase(long which, unsigned long bus, unsigned long devfn) | |||
1739 | return result; | 1739 | return result; |
1740 | } | 1740 | } |
1741 | 1741 | ||
1742 | void pci_resource_to_user(const struct pci_dev *dev, int bar, | ||
1743 | const struct resource *rsrc, | ||
1744 | u64 *start, u64 *end) | ||
1745 | { | ||
1746 | struct pci_controller *hose = pci_bus_to_hose(dev->bus->number); | ||
1747 | unsigned long offset = 0; | ||
1748 | |||
1749 | if (hose == NULL) | ||
1750 | return; | ||
1751 | |||
1752 | if (rsrc->flags & IORESOURCE_IO) | ||
1753 | offset = ___IO_BASE - hose->io_base_virt + hose->io_base_phys; | ||
1754 | |||
1755 | *start = rsrc->start + offset; | ||
1756 | *end = rsrc->end + offset; | ||
1757 | } | ||
1758 | |||
1742 | void __init | 1759 | void __init |
1743 | pci_init_resource(struct resource *res, unsigned long start, unsigned long end, | 1760 | pci_init_resource(struct resource *res, unsigned long start, unsigned long end, |
1744 | int flags, char *name) | 1761 | int flags, char *name) |
diff --git a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c index 580676f87d23..ae6f579d3fa0 100644 --- a/arch/ppc64/kernel/pci.c +++ b/arch/ppc64/kernel/pci.c | |||
@@ -351,7 +351,7 @@ static struct resource *__pci_mmap_make_offset(struct pci_dev *dev, | |||
351 | *offset += hose->pci_mem_offset; | 351 | *offset += hose->pci_mem_offset; |
352 | res_bit = IORESOURCE_MEM; | 352 | res_bit = IORESOURCE_MEM; |
353 | } else { | 353 | } else { |
354 | io_offset = (unsigned long)hose->io_base_virt; | 354 | io_offset = (unsigned long)hose->io_base_virt - pci_io_base; |
355 | *offset += io_offset; | 355 | *offset += io_offset; |
356 | res_bit = IORESOURCE_IO; | 356 | res_bit = IORESOURCE_IO; |
357 | } | 357 | } |
@@ -378,7 +378,7 @@ static struct resource *__pci_mmap_make_offset(struct pci_dev *dev, | |||
378 | 378 | ||
379 | /* found it! construct the final physical address */ | 379 | /* found it! construct the final physical address */ |
380 | if (mmap_state == pci_mmap_io) | 380 | if (mmap_state == pci_mmap_io) |
381 | *offset += hose->io_base_phys - io_offset; | 381 | *offset += hose->io_base_phys - io_offset; |
382 | return rp; | 382 | return rp; |
383 | } | 383 | } |
384 | 384 | ||
@@ -944,4 +944,22 @@ int pci_read_irq_line(struct pci_dev *pci_dev) | |||
944 | } | 944 | } |
945 | EXPORT_SYMBOL(pci_read_irq_line); | 945 | EXPORT_SYMBOL(pci_read_irq_line); |
946 | 946 | ||
947 | void pci_resource_to_user(const struct pci_dev *dev, int bar, | ||
948 | const struct resource *rsrc, | ||
949 | u64 *start, u64 *end) | ||
950 | { | ||
951 | struct pci_controller *hose = pci_bus_to_host(dev->bus); | ||
952 | unsigned long offset = 0; | ||
953 | |||
954 | if (hose == NULL) | ||
955 | return; | ||
956 | |||
957 | if (rsrc->flags & IORESOURCE_IO) | ||
958 | offset = pci_io_base - (unsigned long)hose->io_base_virt + | ||
959 | hose->io_base_phys; | ||
960 | |||
961 | *start = rsrc->start + offset; | ||
962 | *end = rsrc->end + offset; | ||
963 | } | ||
964 | |||
947 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | 965 | #endif /* CONFIG_PPC_MULTIPLATFORM */ |
diff --git a/arch/x86_64/pci/mmconfig.c b/arch/x86_64/pci/mmconfig.c index b693c232fd07..657e88aa0902 100644 --- a/arch/x86_64/pci/mmconfig.c +++ b/arch/x86_64/pci/mmconfig.c | |||
@@ -7,25 +7,50 @@ | |||
7 | 7 | ||
8 | #include <linux/pci.h> | 8 | #include <linux/pci.h> |
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | #include <linux/acpi.h> | ||
10 | #include "pci.h" | 11 | #include "pci.h" |
11 | 12 | ||
12 | #define MMCONFIG_APER_SIZE (256*1024*1024) | 13 | #define MMCONFIG_APER_SIZE (256*1024*1024) |
13 | 14 | ||
14 | /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */ | ||
15 | u32 pci_mmcfg_base_addr; | ||
16 | |||
17 | /* Static virtual mapping of the MMCONFIG aperture */ | 15 | /* Static virtual mapping of the MMCONFIG aperture */ |
18 | char *pci_mmcfg_virt; | 16 | struct mmcfg_virt { |
17 | struct acpi_table_mcfg_config *cfg; | ||
18 | char *virt; | ||
19 | }; | ||
20 | static struct mmcfg_virt *pci_mmcfg_virt; | ||
19 | 21 | ||
20 | static inline char *pci_dev_base(unsigned int bus, unsigned int devfn) | 22 | static char *get_virt(unsigned int seg, int bus) |
21 | { | 23 | { |
22 | return pci_mmcfg_virt + ((bus << 20) | (devfn << 12)); | 24 | int cfg_num = -1; |
25 | struct acpi_table_mcfg_config *cfg; | ||
26 | |||
27 | while (1) { | ||
28 | ++cfg_num; | ||
29 | if (cfg_num >= pci_mmcfg_config_num) { | ||
30 | /* something bad is going on, no cfg table is found. */ | ||
31 | /* so we fall back to the old way we used to do this */ | ||
32 | /* and just rely on the first entry to be correct. */ | ||
33 | return pci_mmcfg_virt[0].virt; | ||
34 | } | ||
35 | cfg = pci_mmcfg_virt[cfg_num].cfg; | ||
36 | if (cfg->pci_segment_group_number != seg) | ||
37 | continue; | ||
38 | if ((cfg->start_bus_number <= bus) && | ||
39 | (cfg->end_bus_number >= bus)) | ||
40 | return pci_mmcfg_virt[cfg_num].virt; | ||
41 | } | ||
42 | } | ||
43 | |||
44 | static inline char *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn) | ||
45 | { | ||
46 | |||
47 | return get_virt(seg, bus) + ((bus << 20) | (devfn << 12)); | ||
23 | } | 48 | } |
24 | 49 | ||
25 | static int pci_mmcfg_read(unsigned int seg, unsigned int bus, | 50 | static int pci_mmcfg_read(unsigned int seg, unsigned int bus, |
26 | unsigned int devfn, int reg, int len, u32 *value) | 51 | unsigned int devfn, int reg, int len, u32 *value) |
27 | { | 52 | { |
28 | char *addr = pci_dev_base(bus, devfn); | 53 | char *addr = pci_dev_base(seg, bus, devfn); |
29 | 54 | ||
30 | if (unlikely(!value || (bus > 255) || (devfn > 255) || (reg > 4095))) | 55 | if (unlikely(!value || (bus > 255) || (devfn > 255) || (reg > 4095))) |
31 | return -EINVAL; | 56 | return -EINVAL; |
@@ -48,7 +73,7 @@ static int pci_mmcfg_read(unsigned int seg, unsigned int bus, | |||
48 | static int pci_mmcfg_write(unsigned int seg, unsigned int bus, | 73 | static int pci_mmcfg_write(unsigned int seg, unsigned int bus, |
49 | unsigned int devfn, int reg, int len, u32 value) | 74 | unsigned int devfn, int reg, int len, u32 value) |
50 | { | 75 | { |
51 | char *addr = pci_dev_base(bus,devfn); | 76 | char *addr = pci_dev_base(seg, bus, devfn); |
52 | 77 | ||
53 | if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095))) | 78 | if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095))) |
54 | return -EINVAL; | 79 | return -EINVAL; |
@@ -75,9 +100,15 @@ static struct pci_raw_ops pci_mmcfg = { | |||
75 | 100 | ||
76 | static int __init pci_mmcfg_init(void) | 101 | static int __init pci_mmcfg_init(void) |
77 | { | 102 | { |
103 | int i; | ||
104 | |||
78 | if ((pci_probe & PCI_PROBE_MMCONF) == 0) | 105 | if ((pci_probe & PCI_PROBE_MMCONF) == 0) |
79 | return 0; | 106 | return 0; |
80 | if (!pci_mmcfg_base_addr) | 107 | |
108 | acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg); | ||
109 | if ((pci_mmcfg_config_num == 0) || | ||
110 | (pci_mmcfg_config == NULL) || | ||
111 | (pci_mmcfg_config[0].base_address == 0)) | ||
81 | return 0; | 112 | return 0; |
82 | 113 | ||
83 | /* Kludge for now. Don't use mmconfig on AMD systems because | 114 | /* Kludge for now. Don't use mmconfig on AMD systems because |
@@ -88,13 +119,22 @@ static int __init pci_mmcfg_init(void) | |||
88 | return 0; | 119 | return 0; |
89 | 120 | ||
90 | /* RED-PEN i386 doesn't do _nocache right now */ | 121 | /* RED-PEN i386 doesn't do _nocache right now */ |
91 | pci_mmcfg_virt = ioremap_nocache(pci_mmcfg_base_addr, MMCONFIG_APER_SIZE); | 122 | pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL); |
92 | if (!pci_mmcfg_virt) { | 123 | if (pci_mmcfg_virt == NULL) { |
93 | printk("PCI: Cannot map mmconfig aperture\n"); | 124 | printk("PCI: Can not allocate memory for mmconfig structures\n"); |
94 | return 0; | 125 | return 0; |
95 | } | 126 | } |
127 | for (i = 0; i < pci_mmcfg_config_num; ++i) { | ||
128 | pci_mmcfg_virt[i].cfg = &pci_mmcfg_config[i]; | ||
129 | pci_mmcfg_virt[i].virt = ioremap_nocache(pci_mmcfg_config[i].base_address, MMCONFIG_APER_SIZE); | ||
130 | if (!pci_mmcfg_virt[i].virt) { | ||
131 | printk("PCI: Cannot map mmconfig aperture for segment %d\n", | ||
132 | pci_mmcfg_config[i].pci_segment_group_number); | ||
133 | return 0; | ||
134 | } | ||
135 | printk(KERN_INFO "PCI: Using MMCONFIG at %x\n", pci_mmcfg_config[i].base_address); | ||
136 | } | ||
96 | 137 | ||
97 | printk(KERN_INFO "PCI: Using MMCONFIG at %x\n", pci_mmcfg_base_addr); | ||
98 | raw_pci_ops = &pci_mmcfg; | 138 | raw_pci_ops = &pci_mmcfg; |
99 | pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; | 139 | pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; |
100 | 140 | ||
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index 5a0adbf8bc04..97013ddfa202 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c | |||
@@ -153,7 +153,7 @@ container_device_add(struct acpi_device **device, acpi_handle handle) | |||
153 | return_VALUE(-ENODEV); | 153 | return_VALUE(-ENODEV); |
154 | } | 154 | } |
155 | 155 | ||
156 | result = acpi_bus_scan(*device); | 156 | result = acpi_bus_start(*device); |
157 | 157 | ||
158 | return_VALUE(result); | 158 | return_VALUE(result); |
159 | } | 159 | } |
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c index 5d19b39e9e2b..5148f3c10b5c 100644 --- a/drivers/acpi/pci_bind.c +++ b/drivers/acpi/pci_bind.c | |||
@@ -61,15 +61,14 @@ acpi_pci_data_handler ( | |||
61 | 61 | ||
62 | 62 | ||
63 | /** | 63 | /** |
64 | * acpi_os_get_pci_id | 64 | * acpi_get_pci_id |
65 | * ------------------ | 65 | * ------------------ |
66 | * This function is used by the ACPI Interpreter (a.k.a. Core Subsystem) | 66 | * This function is used by the ACPI Interpreter (a.k.a. Core Subsystem) |
67 | * to resolve PCI information for ACPI-PCI devices defined in the namespace. | 67 | * to resolve PCI information for ACPI-PCI devices defined in the namespace. |
68 | * This typically occurs when resolving PCI operation region information. | 68 | * This typically occurs when resolving PCI operation region information. |
69 | */ | 69 | */ |
70 | #ifdef ACPI_FUTURE_USAGE | ||
71 | acpi_status | 70 | acpi_status |
72 | acpi_os_get_pci_id ( | 71 | acpi_get_pci_id ( |
73 | acpi_handle handle, | 72 | acpi_handle handle, |
74 | struct acpi_pci_id *id) | 73 | struct acpi_pci_id *id) |
75 | { | 74 | { |
@@ -78,7 +77,7 @@ acpi_os_get_pci_id ( | |||
78 | struct acpi_device *device = NULL; | 77 | struct acpi_device *device = NULL; |
79 | struct acpi_pci_data *data = NULL; | 78 | struct acpi_pci_data *data = NULL; |
80 | 79 | ||
81 | ACPI_FUNCTION_TRACE("acpi_os_get_pci_id"); | 80 | ACPI_FUNCTION_TRACE("acpi_get_pci_id"); |
82 | 81 | ||
83 | if (!id) | 82 | if (!id) |
84 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 83 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
@@ -92,7 +91,7 @@ acpi_os_get_pci_id ( | |||
92 | } | 91 | } |
93 | 92 | ||
94 | status = acpi_get_data(handle, acpi_pci_data_handler, (void**) &data); | 93 | status = acpi_get_data(handle, acpi_pci_data_handler, (void**) &data); |
95 | if (ACPI_FAILURE(status) || !data || !data->dev) { | 94 | if (ACPI_FAILURE(status) || !data) { |
96 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 95 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
97 | "Invalid ACPI-PCI context for device %s\n", | 96 | "Invalid ACPI-PCI context for device %s\n", |
98 | acpi_device_bid(device))); | 97 | acpi_device_bid(device))); |
@@ -115,7 +114,7 @@ acpi_os_get_pci_id ( | |||
115 | 114 | ||
116 | return_ACPI_STATUS(AE_OK); | 115 | return_ACPI_STATUS(AE_OK); |
117 | } | 116 | } |
118 | #endif /* ACPI_FUTURE_USAGE */ | 117 | EXPORT_SYMBOL(acpi_get_pci_id); |
119 | 118 | ||
120 | 119 | ||
121 | int | 120 | int |
@@ -129,6 +128,8 @@ acpi_pci_bind ( | |||
129 | char *pathname = NULL; | 128 | char *pathname = NULL; |
130 | struct acpi_buffer buffer = {0, NULL}; | 129 | struct acpi_buffer buffer = {0, NULL}; |
131 | acpi_handle handle = NULL; | 130 | acpi_handle handle = NULL; |
131 | struct pci_dev *dev; | ||
132 | struct pci_bus *bus; | ||
132 | 133 | ||
133 | ACPI_FUNCTION_TRACE("acpi_pci_bind"); | 134 | ACPI_FUNCTION_TRACE("acpi_pci_bind"); |
134 | 135 | ||
@@ -193,8 +194,20 @@ acpi_pci_bind ( | |||
193 | * Locate matching device in PCI namespace. If it doesn't exist | 194 | * Locate matching device in PCI namespace. If it doesn't exist |
194 | * this typically means that the device isn't currently inserted | 195 | * this typically means that the device isn't currently inserted |
195 | * (e.g. docking station, port replicator, etc.). | 196 | * (e.g. docking station, port replicator, etc.). |
197 | * We cannot simply search the global pci device list, since | ||
198 | * PCI devices are added to the global pci list when the root | ||
199 | * bridge start ops are run, which may not have happened yet. | ||
196 | */ | 200 | */ |
197 | data->dev = pci_find_slot(data->id.bus, PCI_DEVFN(data->id.device, data->id.function)); | 201 | bus = pci_find_bus(data->id.segment, data->id.bus); |
202 | if (bus) { | ||
203 | list_for_each_entry(dev, &bus->devices, bus_list) { | ||
204 | if (dev->devfn == PCI_DEVFN(data->id.device, | ||
205 | data->id.function)) { | ||
206 | data->dev = dev; | ||
207 | break; | ||
208 | } | ||
209 | } | ||
210 | } | ||
198 | if (!data->dev) { | 211 | if (!data->dev) { |
199 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 212 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
200 | "Device %02x:%02x:%02x.%02x not present in PCI namespace\n", | 213 | "Device %02x:%02x:%02x.%02x not present in PCI namespace\n", |
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 7e6b8e3b2ed4..5d2f77fcd50c 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -46,6 +46,7 @@ ACPI_MODULE_NAME ("pci_root") | |||
46 | 46 | ||
47 | static int acpi_pci_root_add (struct acpi_device *device); | 47 | static int acpi_pci_root_add (struct acpi_device *device); |
48 | static int acpi_pci_root_remove (struct acpi_device *device, int type); | 48 | static int acpi_pci_root_remove (struct acpi_device *device, int type); |
49 | static int acpi_pci_root_start (struct acpi_device *device); | ||
49 | 50 | ||
50 | static struct acpi_driver acpi_pci_root_driver = { | 51 | static struct acpi_driver acpi_pci_root_driver = { |
51 | .name = ACPI_PCI_ROOT_DRIVER_NAME, | 52 | .name = ACPI_PCI_ROOT_DRIVER_NAME, |
@@ -54,6 +55,7 @@ static struct acpi_driver acpi_pci_root_driver = { | |||
54 | .ops = { | 55 | .ops = { |
55 | .add = acpi_pci_root_add, | 56 | .add = acpi_pci_root_add, |
56 | .remove = acpi_pci_root_remove, | 57 | .remove = acpi_pci_root_remove, |
58 | .start = acpi_pci_root_start, | ||
57 | }, | 59 | }, |
58 | }; | 60 | }; |
59 | 61 | ||
@@ -169,6 +171,7 @@ acpi_pci_root_add ( | |||
169 | if (!root) | 171 | if (!root) |
170 | return_VALUE(-ENOMEM); | 172 | return_VALUE(-ENOMEM); |
171 | memset(root, 0, sizeof(struct acpi_pci_root)); | 173 | memset(root, 0, sizeof(struct acpi_pci_root)); |
174 | INIT_LIST_HEAD(&root->node); | ||
172 | 175 | ||
173 | root->handle = device->handle; | 176 | root->handle = device->handle; |
174 | strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME); | 177 | strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME); |
@@ -298,12 +301,31 @@ acpi_pci_root_add ( | |||
298 | root->id.bus); | 301 | root->id.bus); |
299 | 302 | ||
300 | end: | 303 | end: |
301 | if (result) | 304 | if (result) { |
305 | if (!list_empty(&root->node)) | ||
306 | list_del(&root->node); | ||
302 | kfree(root); | 307 | kfree(root); |
308 | } | ||
303 | 309 | ||
304 | return_VALUE(result); | 310 | return_VALUE(result); |
305 | } | 311 | } |
306 | 312 | ||
313 | static int | ||
314 | acpi_pci_root_start ( | ||
315 | struct acpi_device *device) | ||
316 | { | ||
317 | struct acpi_pci_root *root; | ||
318 | |||
319 | ACPI_FUNCTION_TRACE("acpi_pci_root_start"); | ||
320 | |||
321 | list_for_each_entry(root, &acpi_pci_roots, node) { | ||
322 | if (root->handle == device->handle) { | ||
323 | pci_bus_add_devices(root->bus); | ||
324 | return_VALUE(0); | ||
325 | } | ||
326 | } | ||
327 | return_VALUE(-ENODEV); | ||
328 | } | ||
307 | 329 | ||
308 | static int | 330 | static int |
309 | acpi_pci_root_remove ( | 331 | acpi_pci_root_remove ( |
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index f4778747e889..76156ac91bd3 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -723,7 +723,7 @@ int acpi_processor_device_add( | |||
723 | return_VALUE(-ENODEV); | 723 | return_VALUE(-ENODEV); |
724 | } | 724 | } |
725 | 725 | ||
726 | acpi_bus_scan(*device); | 726 | acpi_bus_start(*device); |
727 | 727 | ||
728 | pr = acpi_driver_data(*device); | 728 | pr = acpi_driver_data(*device); |
729 | if (!pr) | 729 | if (!pr) |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index e85885593280..337d49b5564b 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -553,20 +553,29 @@ acpi_bus_driver_init ( | |||
553 | * upon possible configuration and currently allocated resources. | 553 | * upon possible configuration and currently allocated resources. |
554 | */ | 554 | */ |
555 | 555 | ||
556 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Driver successfully bound to device\n")); | ||
557 | return_VALUE(0); | ||
558 | } | ||
559 | |||
560 | int | ||
561 | acpi_start_single_object ( | ||
562 | struct acpi_device *device) | ||
563 | { | ||
564 | int result = 0; | ||
565 | struct acpi_driver *driver; | ||
566 | |||
567 | ACPI_FUNCTION_TRACE("acpi_start_single_object"); | ||
568 | |||
569 | if (!(driver = device->driver)) | ||
570 | return_VALUE(0); | ||
571 | |||
556 | if (driver->ops.start) { | 572 | if (driver->ops.start) { |
557 | result = driver->ops.start(device); | 573 | result = driver->ops.start(device); |
558 | if (result && driver->ops.remove) | 574 | if (result && driver->ops.remove) |
559 | driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); | 575 | driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); |
560 | return_VALUE(result); | ||
561 | } | 576 | } |
562 | 577 | ||
563 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Driver successfully bound to device\n")); | 578 | return_VALUE(result); |
564 | |||
565 | if (driver->ops.scan) { | ||
566 | driver->ops.scan(device); | ||
567 | } | ||
568 | |||
569 | return_VALUE(0); | ||
570 | } | 579 | } |
571 | 580 | ||
572 | static int acpi_driver_attach(struct acpi_driver * drv) | 581 | static int acpi_driver_attach(struct acpi_driver * drv) |
@@ -586,6 +595,7 @@ static int acpi_driver_attach(struct acpi_driver * drv) | |||
586 | 595 | ||
587 | if (!acpi_bus_match(dev, drv)) { | 596 | if (!acpi_bus_match(dev, drv)) { |
588 | if (!acpi_bus_driver_init(dev, drv)) { | 597 | if (!acpi_bus_driver_init(dev, drv)) { |
598 | acpi_start_single_object(dev); | ||
589 | atomic_inc(&drv->references); | 599 | atomic_inc(&drv->references); |
590 | count++; | 600 | count++; |
591 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n", | 601 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n", |
@@ -1009,8 +1019,8 @@ acpi_bus_remove ( | |||
1009 | } | 1019 | } |
1010 | 1020 | ||
1011 | 1021 | ||
1012 | int | 1022 | static int |
1013 | acpi_bus_add ( | 1023 | acpi_add_single_object ( |
1014 | struct acpi_device **child, | 1024 | struct acpi_device **child, |
1015 | struct acpi_device *parent, | 1025 | struct acpi_device *parent, |
1016 | acpi_handle handle, | 1026 | acpi_handle handle, |
@@ -1019,7 +1029,7 @@ acpi_bus_add ( | |||
1019 | int result = 0; | 1029 | int result = 0; |
1020 | struct acpi_device *device = NULL; | 1030 | struct acpi_device *device = NULL; |
1021 | 1031 | ||
1022 | ACPI_FUNCTION_TRACE("acpi_bus_add"); | 1032 | ACPI_FUNCTION_TRACE("acpi_add_single_object"); |
1023 | 1033 | ||
1024 | if (!child) | 1034 | if (!child) |
1025 | return_VALUE(-EINVAL); | 1035 | return_VALUE(-EINVAL); |
@@ -1140,7 +1150,7 @@ acpi_bus_add ( | |||
1140 | * | 1150 | * |
1141 | * TBD: Assumes LDM provides driver hot-plug capability. | 1151 | * TBD: Assumes LDM provides driver hot-plug capability. |
1142 | */ | 1152 | */ |
1143 | acpi_bus_find_driver(device); | 1153 | result = acpi_bus_find_driver(device); |
1144 | 1154 | ||
1145 | end: | 1155 | end: |
1146 | if (!result) | 1156 | if (!result) |
@@ -1153,10 +1163,10 @@ end: | |||
1153 | 1163 | ||
1154 | return_VALUE(result); | 1164 | return_VALUE(result); |
1155 | } | 1165 | } |
1156 | EXPORT_SYMBOL(acpi_bus_add); | ||
1157 | 1166 | ||
1158 | 1167 | ||
1159 | int acpi_bus_scan (struct acpi_device *start) | 1168 | static int acpi_bus_scan (struct acpi_device *start, |
1169 | struct acpi_bus_ops *ops) | ||
1160 | { | 1170 | { |
1161 | acpi_status status = AE_OK; | 1171 | acpi_status status = AE_OK; |
1162 | struct acpi_device *parent = NULL; | 1172 | struct acpi_device *parent = NULL; |
@@ -1229,9 +1239,20 @@ int acpi_bus_scan (struct acpi_device *start) | |||
1229 | continue; | 1239 | continue; |
1230 | } | 1240 | } |
1231 | 1241 | ||
1232 | status = acpi_bus_add(&child, parent, chandle, type); | 1242 | if (ops->acpi_op_add) |
1233 | if (ACPI_FAILURE(status)) | 1243 | status = acpi_add_single_object(&child, parent, |
1234 | continue; | 1244 | chandle, type); |
1245 | else | ||
1246 | status = acpi_bus_get_device(chandle, &child); | ||
1247 | |||
1248 | if (ACPI_FAILURE(status)) | ||
1249 | continue; | ||
1250 | |||
1251 | if (ops->acpi_op_start) { | ||
1252 | status = acpi_start_single_object(child); | ||
1253 | if (ACPI_FAILURE(status)) | ||
1254 | continue; | ||
1255 | } | ||
1235 | 1256 | ||
1236 | /* | 1257 | /* |
1237 | * If the device is present, enabled, and functioning then | 1258 | * If the device is present, enabled, and functioning then |
@@ -1257,8 +1278,50 @@ int acpi_bus_scan (struct acpi_device *start) | |||
1257 | 1278 | ||
1258 | return_VALUE(0); | 1279 | return_VALUE(0); |
1259 | } | 1280 | } |
1260 | EXPORT_SYMBOL(acpi_bus_scan); | ||
1261 | 1281 | ||
1282 | int | ||
1283 | acpi_bus_add ( | ||
1284 | struct acpi_device **child, | ||
1285 | struct acpi_device *parent, | ||
1286 | acpi_handle handle, | ||
1287 | int type) | ||
1288 | { | ||
1289 | int result; | ||
1290 | struct acpi_bus_ops ops; | ||
1291 | |||
1292 | ACPI_FUNCTION_TRACE("acpi_bus_add"); | ||
1293 | |||
1294 | result = acpi_add_single_object(child, parent, handle, type); | ||
1295 | if (!result) { | ||
1296 | memset(&ops, 0, sizeof(ops)); | ||
1297 | ops.acpi_op_add = 1; | ||
1298 | result = acpi_bus_scan(*child, &ops); | ||
1299 | } | ||
1300 | return_VALUE(result); | ||
1301 | } | ||
1302 | EXPORT_SYMBOL(acpi_bus_add); | ||
1303 | |||
1304 | int | ||
1305 | acpi_bus_start ( | ||
1306 | struct acpi_device *device) | ||
1307 | { | ||
1308 | int result; | ||
1309 | struct acpi_bus_ops ops; | ||
1310 | |||
1311 | ACPI_FUNCTION_TRACE("acpi_bus_start"); | ||
1312 | |||
1313 | if (!device) | ||
1314 | return_VALUE(-EINVAL); | ||
1315 | |||
1316 | result = acpi_start_single_object(device); | ||
1317 | if (!result) { | ||
1318 | memset(&ops, 0, sizeof(ops)); | ||
1319 | ops.acpi_op_start = 1; | ||
1320 | result = acpi_bus_scan(device, &ops); | ||
1321 | } | ||
1322 | return_VALUE(result); | ||
1323 | } | ||
1324 | EXPORT_SYMBOL(acpi_bus_start); | ||
1262 | 1325 | ||
1263 | static int | 1326 | static int |
1264 | acpi_bus_trim(struct acpi_device *start, | 1327 | acpi_bus_trim(struct acpi_device *start, |
@@ -1331,13 +1394,19 @@ acpi_bus_scan_fixed ( | |||
1331 | /* | 1394 | /* |
1332 | * Enumerate all fixed-feature devices. | 1395 | * Enumerate all fixed-feature devices. |
1333 | */ | 1396 | */ |
1334 | if (acpi_fadt.pwr_button == 0) | 1397 | if (acpi_fadt.pwr_button == 0) { |
1335 | result = acpi_bus_add(&device, acpi_root, | 1398 | result = acpi_add_single_object(&device, acpi_root, |
1336 | NULL, ACPI_BUS_TYPE_POWER_BUTTON); | 1399 | NULL, ACPI_BUS_TYPE_POWER_BUTTON); |
1400 | if (!result) | ||
1401 | result = acpi_start_single_object(device); | ||
1402 | } | ||
1337 | 1403 | ||
1338 | if (acpi_fadt.sleep_button == 0) | 1404 | if (acpi_fadt.sleep_button == 0) { |
1339 | result = acpi_bus_add(&device, acpi_root, | 1405 | result = acpi_add_single_object(&device, acpi_root, |
1340 | NULL, ACPI_BUS_TYPE_SLEEP_BUTTON); | 1406 | NULL, ACPI_BUS_TYPE_SLEEP_BUTTON); |
1407 | if (!result) | ||
1408 | result = acpi_start_single_object(device); | ||
1409 | } | ||
1341 | 1410 | ||
1342 | return_VALUE(result); | 1411 | return_VALUE(result); |
1343 | } | 1412 | } |
@@ -1346,6 +1415,7 @@ acpi_bus_scan_fixed ( | |||
1346 | static int __init acpi_scan_init(void) | 1415 | static int __init acpi_scan_init(void) |
1347 | { | 1416 | { |
1348 | int result; | 1417 | int result; |
1418 | struct acpi_bus_ops ops; | ||
1349 | 1419 | ||
1350 | ACPI_FUNCTION_TRACE("acpi_scan_init"); | 1420 | ACPI_FUNCTION_TRACE("acpi_scan_init"); |
1351 | 1421 | ||
@@ -1357,17 +1427,23 @@ static int __init acpi_scan_init(void) | |||
1357 | /* | 1427 | /* |
1358 | * Create the root device in the bus's device tree | 1428 | * Create the root device in the bus's device tree |
1359 | */ | 1429 | */ |
1360 | result = acpi_bus_add(&acpi_root, NULL, ACPI_ROOT_OBJECT, | 1430 | result = acpi_add_single_object(&acpi_root, NULL, ACPI_ROOT_OBJECT, |
1361 | ACPI_BUS_TYPE_SYSTEM); | 1431 | ACPI_BUS_TYPE_SYSTEM); |
1362 | if (result) | 1432 | if (result) |
1363 | goto Done; | 1433 | goto Done; |
1364 | 1434 | ||
1435 | result = acpi_start_single_object(acpi_root); | ||
1436 | |||
1365 | /* | 1437 | /* |
1366 | * Enumerate devices in the ACPI namespace. | 1438 | * Enumerate devices in the ACPI namespace. |
1367 | */ | 1439 | */ |
1368 | result = acpi_bus_scan_fixed(acpi_root); | 1440 | result = acpi_bus_scan_fixed(acpi_root); |
1369 | if (!result) | 1441 | if (!result) { |
1370 | result = acpi_bus_scan(acpi_root); | 1442 | memset(&ops, 0, sizeof(ops)); |
1443 | ops.acpi_op_add = 1; | ||
1444 | ops.acpi_op_start = 1; | ||
1445 | result = acpi_bus_scan(acpi_root, &ops); | ||
1446 | } | ||
1371 | 1447 | ||
1372 | if (result) | 1448 | if (result) |
1373 | acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); | 1449 | acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); |
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index 7c24fbe831f8..95f7046ff059 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c | |||
@@ -451,7 +451,7 @@ static int __init moxa_init(void) | |||
451 | int n = (sizeof(moxa_pcibrds) / sizeof(moxa_pcibrds[0])) - 1; | 451 | int n = (sizeof(moxa_pcibrds) / sizeof(moxa_pcibrds[0])) - 1; |
452 | i = 0; | 452 | i = 0; |
453 | while (i < n) { | 453 | while (i < n) { |
454 | while ((p = pci_find_device(moxa_pcibrds[i].vendor, moxa_pcibrds[i].device, p))!=NULL) | 454 | while ((p = pci_get_device(moxa_pcibrds[i].vendor, moxa_pcibrds[i].device, p))!=NULL) |
455 | { | 455 | { |
456 | if (pci_enable_device(p)) | 456 | if (pci_enable_device(p)) |
457 | continue; | 457 | continue; |
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c index 7db3370f4972..d7d484024e2b 100644 --- a/drivers/char/rio/rio_linux.c +++ b/drivers/char/rio/rio_linux.c | |||
@@ -1095,7 +1095,7 @@ static int __init rio_init(void) | |||
1095 | 1095 | ||
1096 | #ifdef CONFIG_PCI | 1096 | #ifdef CONFIG_PCI |
1097 | /* First look for the JET devices: */ | 1097 | /* First look for the JET devices: */ |
1098 | while ((pdev = pci_find_device (PCI_VENDOR_ID_SPECIALIX, | 1098 | while ((pdev = pci_get_device (PCI_VENDOR_ID_SPECIALIX, |
1099 | PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, | 1099 | PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, |
1100 | pdev))) { | 1100 | pdev))) { |
1101 | if (pci_enable_device(pdev)) continue; | 1101 | if (pci_enable_device(pdev)) continue; |
@@ -1169,7 +1169,7 @@ static int __init rio_init(void) | |||
1169 | */ | 1169 | */ |
1170 | 1170 | ||
1171 | /* Then look for the older RIO/PCI devices: */ | 1171 | /* Then look for the older RIO/PCI devices: */ |
1172 | while ((pdev = pci_find_device (PCI_VENDOR_ID_SPECIALIX, | 1172 | while ((pdev = pci_get_device (PCI_VENDOR_ID_SPECIALIX, |
1173 | PCI_DEVICE_ID_SPECIALIX_RIO, | 1173 | PCI_DEVICE_ID_SPECIALIX_RIO, |
1174 | pdev))) { | 1174 | pdev))) { |
1175 | if (pci_enable_device(pdev)) continue; | 1175 | if (pci_enable_device(pdev)) continue; |
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index d8d65397e06e..353deb25e397 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c | |||
@@ -364,9 +364,7 @@ static struct pci_driver mptfc_driver = { | |||
364 | .id_table = mptfc_pci_table, | 364 | .id_table = mptfc_pci_table, |
365 | .probe = mptfc_probe, | 365 | .probe = mptfc_probe, |
366 | .remove = __devexit_p(mptscsih_remove), | 366 | .remove = __devexit_p(mptscsih_remove), |
367 | .driver = { | 367 | .shutdown = mptscsih_shutdown, |
368 | .shutdown = mptscsih_shutdown, | ||
369 | }, | ||
370 | #ifdef CONFIG_PM | 368 | #ifdef CONFIG_PM |
371 | .suspend = mptscsih_suspend, | 369 | .suspend = mptscsih_suspend, |
372 | .resume = mptscsih_resume, | 370 | .resume = mptscsih_resume, |
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index a0078ae5b9b8..4f973a49be4c 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c | |||
@@ -170,7 +170,7 @@ static void mptscsih_fillbuf(char *buffer, int size, int index, int width); | |||
170 | #endif | 170 | #endif |
171 | 171 | ||
172 | void mptscsih_remove(struct pci_dev *); | 172 | void mptscsih_remove(struct pci_dev *); |
173 | void mptscsih_shutdown(struct device *); | 173 | void mptscsih_shutdown(struct pci_dev *); |
174 | #ifdef CONFIG_PM | 174 | #ifdef CONFIG_PM |
175 | int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state); | 175 | int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state); |
176 | int mptscsih_resume(struct pci_dev *pdev); | 176 | int mptscsih_resume(struct pci_dev *pdev); |
@@ -988,7 +988,7 @@ mptscsih_remove(struct pci_dev *pdev) | |||
988 | #endif | 988 | #endif |
989 | #endif | 989 | #endif |
990 | 990 | ||
991 | mptscsih_shutdown(&pdev->dev); | 991 | mptscsih_shutdown(pdev); |
992 | 992 | ||
993 | sz1=0; | 993 | sz1=0; |
994 | 994 | ||
@@ -1026,9 +1026,9 @@ mptscsih_remove(struct pci_dev *pdev) | |||
1026 | * | 1026 | * |
1027 | */ | 1027 | */ |
1028 | void | 1028 | void |
1029 | mptscsih_shutdown(struct device * dev) | 1029 | mptscsih_shutdown(struct pci_dev *pdev) |
1030 | { | 1030 | { |
1031 | MPT_ADAPTER *ioc = pci_get_drvdata(to_pci_dev(dev)); | 1031 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); |
1032 | struct Scsi_Host *host = ioc->sh; | 1032 | struct Scsi_Host *host = ioc->sh; |
1033 | MPT_SCSI_HOST *hd; | 1033 | MPT_SCSI_HOST *hd; |
1034 | 1034 | ||
@@ -1054,7 +1054,7 @@ mptscsih_shutdown(struct device * dev) | |||
1054 | int | 1054 | int |
1055 | mptscsih_suspend(struct pci_dev *pdev, pm_message_t state) | 1055 | mptscsih_suspend(struct pci_dev *pdev, pm_message_t state) |
1056 | { | 1056 | { |
1057 | mptscsih_shutdown(&pdev->dev); | 1057 | mptscsih_shutdown(pdev); |
1058 | return mpt_suspend(pdev,state); | 1058 | return mpt_suspend(pdev,state); |
1059 | } | 1059 | } |
1060 | 1060 | ||
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h index d73aec33e16a..5ea89bf0df19 100644 --- a/drivers/message/fusion/mptscsih.h +++ b/drivers/message/fusion/mptscsih.h | |||
@@ -82,7 +82,7 @@ | |||
82 | #endif | 82 | #endif |
83 | 83 | ||
84 | extern void mptscsih_remove(struct pci_dev *); | 84 | extern void mptscsih_remove(struct pci_dev *); |
85 | extern void mptscsih_shutdown(struct device *); | 85 | extern void mptscsih_shutdown(struct pci_dev *); |
86 | #ifdef CONFIG_PM | 86 | #ifdef CONFIG_PM |
87 | extern int mptscsih_suspend(struct pci_dev *pdev, u32 state); | 87 | extern int mptscsih_suspend(struct pci_dev *pdev, u32 state); |
88 | extern int mptscsih_resume(struct pci_dev *pdev); | 88 | extern int mptscsih_resume(struct pci_dev *pdev); |
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index 5f9a61b85b3b..e0c0ee5bc966 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c | |||
@@ -419,9 +419,7 @@ static struct pci_driver mptspi_driver = { | |||
419 | .id_table = mptspi_pci_table, | 419 | .id_table = mptspi_pci_table, |
420 | .probe = mptspi_probe, | 420 | .probe = mptspi_probe, |
421 | .remove = __devexit_p(mptscsih_remove), | 421 | .remove = __devexit_p(mptscsih_remove), |
422 | .driver = { | 422 | .shutdown = mptscsih_shutdown, |
423 | .shutdown = mptscsih_shutdown, | ||
424 | }, | ||
425 | #ifdef CONFIG_PM | 423 | #ifdef CONFIG_PM |
426 | .suspend = mptscsih_suspend, | 424 | .suspend = mptscsih_suspend, |
427 | .resume = mptscsih_resume, | 425 | .resume = mptscsih_resume, |
diff --git a/drivers/net/e100.c b/drivers/net/e100.c index 1e56c8eea35f..d0fa2448761d 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c | |||
@@ -2447,9 +2447,8 @@ static int e100_resume(struct pci_dev *pdev) | |||
2447 | #endif | 2447 | #endif |
2448 | 2448 | ||
2449 | 2449 | ||
2450 | static void e100_shutdown(struct device *dev) | 2450 | static void e100_shutdown(struct pci_dev *pdev) |
2451 | { | 2451 | { |
2452 | struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); | ||
2453 | struct net_device *netdev = pci_get_drvdata(pdev); | 2452 | struct net_device *netdev = pci_get_drvdata(pdev); |
2454 | struct nic *nic = netdev_priv(netdev); | 2453 | struct nic *nic = netdev_priv(netdev); |
2455 | 2454 | ||
@@ -2470,11 +2469,7 @@ static struct pci_driver e100_driver = { | |||
2470 | .suspend = e100_suspend, | 2469 | .suspend = e100_suspend, |
2471 | .resume = e100_resume, | 2470 | .resume = e100_resume, |
2472 | #endif | 2471 | #endif |
2473 | 2472 | .shutdown = e100_shutdown, | |
2474 | .driver = { | ||
2475 | .shutdown = e100_shutdown, | ||
2476 | } | ||
2477 | |||
2478 | }; | 2473 | }; |
2479 | 2474 | ||
2480 | static int __init e100_init_module(void) | 2475 | static int __init e100_init_module(void) |
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c index be1c1047b9ba..eb0e7bd4dcf8 100644 --- a/drivers/net/via-rhine.c +++ b/drivers/net/via-rhine.c | |||
@@ -507,7 +507,7 @@ static struct net_device_stats *rhine_get_stats(struct net_device *dev); | |||
507 | static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); | 507 | static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); |
508 | static struct ethtool_ops netdev_ethtool_ops; | 508 | static struct ethtool_ops netdev_ethtool_ops; |
509 | static int rhine_close(struct net_device *dev); | 509 | static int rhine_close(struct net_device *dev); |
510 | static void rhine_shutdown (struct device *gdev); | 510 | static void rhine_shutdown (struct pci_dev *pdev); |
511 | 511 | ||
512 | #define RHINE_WAIT_FOR(condition) do { \ | 512 | #define RHINE_WAIT_FOR(condition) do { \ |
513 | int i=1024; \ | 513 | int i=1024; \ |
@@ -1895,9 +1895,8 @@ static void __devexit rhine_remove_one(struct pci_dev *pdev) | |||
1895 | pci_set_drvdata(pdev, NULL); | 1895 | pci_set_drvdata(pdev, NULL); |
1896 | } | 1896 | } |
1897 | 1897 | ||
1898 | static void rhine_shutdown (struct device *gendev) | 1898 | static void rhine_shutdown (struct pci_dev *pdev) |
1899 | { | 1899 | { |
1900 | struct pci_dev *pdev = to_pci_dev(gendev); | ||
1901 | struct net_device *dev = pci_get_drvdata(pdev); | 1900 | struct net_device *dev = pci_get_drvdata(pdev); |
1902 | struct rhine_private *rp = netdev_priv(dev); | 1901 | struct rhine_private *rp = netdev_priv(dev); |
1903 | void __iomem *ioaddr = rp->base; | 1902 | void __iomem *ioaddr = rp->base; |
@@ -1956,7 +1955,7 @@ static int rhine_suspend(struct pci_dev *pdev, pm_message_t state) | |||
1956 | pci_save_state(pdev); | 1955 | pci_save_state(pdev); |
1957 | 1956 | ||
1958 | spin_lock_irqsave(&rp->lock, flags); | 1957 | spin_lock_irqsave(&rp->lock, flags); |
1959 | rhine_shutdown(&pdev->dev); | 1958 | rhine_shutdown(pdev); |
1960 | spin_unlock_irqrestore(&rp->lock, flags); | 1959 | spin_unlock_irqrestore(&rp->lock, flags); |
1961 | 1960 | ||
1962 | free_irq(dev->irq, dev); | 1961 | free_irq(dev->irq, dev); |
@@ -2010,9 +2009,7 @@ static struct pci_driver rhine_driver = { | |||
2010 | .suspend = rhine_suspend, | 2009 | .suspend = rhine_suspend, |
2011 | .resume = rhine_resume, | 2010 | .resume = rhine_resume, |
2012 | #endif /* CONFIG_PM */ | 2011 | #endif /* CONFIG_PM */ |
2013 | .driver = { | 2012 | .shutdown = rhine_shutdown, |
2014 | .shutdown = rhine_shutdown, | ||
2015 | } | ||
2016 | }; | 2013 | }; |
2017 | 2014 | ||
2018 | 2015 | ||
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c index b0d2a73d1d47..2f2dbef2c3b7 100644 --- a/drivers/parisc/dino.c +++ b/drivers/parisc/dino.c | |||
@@ -993,6 +993,7 @@ dino_driver_callback(struct parisc_device *dev) | |||
993 | bus = pci_scan_bus_parented(&dev->dev, dino_current_bus, | 993 | bus = pci_scan_bus_parented(&dev->dev, dino_current_bus, |
994 | &dino_cfg_ops, NULL); | 994 | &dino_cfg_ops, NULL); |
995 | if(bus) { | 995 | if(bus) { |
996 | pci_bus_add_devices(bus); | ||
996 | /* This code *depends* on scanning being single threaded | 997 | /* This code *depends* on scanning being single threaded |
997 | * if it isn't, this global bus number count will fail | 998 | * if it isn't, this global bus number count will fail |
998 | */ | 999 | */ |
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c index dc838804c0dd..7fdd80b7eb47 100644 --- a/drivers/parisc/lba_pci.c +++ b/drivers/parisc/lba_pci.c | |||
@@ -1570,6 +1570,8 @@ lba_driver_probe(struct parisc_device *dev) | |||
1570 | lba_bus = lba_dev->hba.hba_bus = | 1570 | lba_bus = lba_dev->hba.hba_bus = |
1571 | pci_scan_bus_parented(&dev->dev, lba_dev->hba.bus_num.start, | 1571 | pci_scan_bus_parented(&dev->dev, lba_dev->hba.bus_num.start, |
1572 | cfg_ops, NULL); | 1572 | cfg_ops, NULL); |
1573 | if (lba_bus) | ||
1574 | pci_bus_add_devices(lba_bus); | ||
1573 | 1575 | ||
1574 | /* This is in lieu of calling pci_assign_unassigned_resources() */ | 1576 | /* This is in lieu of calling pci_assign_unassigned_resources() */ |
1575 | if (is_pdc_pat()) { | 1577 | if (is_pdc_pat()) { |
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index dbd33605cc10..fedae89d8f7d 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c | |||
@@ -121,10 +121,13 @@ void __devinit pci_bus_add_devices(struct pci_bus *bus) | |||
121 | * If there is an unattached subordinate bus, attach | 121 | * If there is an unattached subordinate bus, attach |
122 | * it and then scan for unattached PCI devices. | 122 | * it and then scan for unattached PCI devices. |
123 | */ | 123 | */ |
124 | if (dev->subordinate && list_empty(&dev->subordinate->node)) { | 124 | if (dev->subordinate) { |
125 | spin_lock(&pci_bus_lock); | 125 | if (list_empty(&dev->subordinate->node)) { |
126 | list_add_tail(&dev->subordinate->node, &dev->bus->children); | 126 | spin_lock(&pci_bus_lock); |
127 | spin_unlock(&pci_bus_lock); | 127 | list_add_tail(&dev->subordinate->node, |
128 | &dev->bus->children); | ||
129 | spin_unlock(&pci_bus_lock); | ||
130 | } | ||
128 | pci_bus_add_devices(dev->subordinate); | 131 | pci_bus_add_devices(dev->subordinate); |
129 | 132 | ||
130 | sysfs_create_link(&dev->subordinate->class_dev.kobj, &dev->dev.kobj, "bridge"); | 133 | sysfs_create_link(&dev->subordinate->class_dev.kobj, &dev->dev.kobj, "bridge"); |
diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile index 93c120ddbd39..3e632ff8c717 100644 --- a/drivers/pci/hotplug/Makefile +++ b/drivers/pci/hotplug/Makefile | |||
@@ -36,9 +36,7 @@ ibmphp-objs := ibmphp_core.o \ | |||
36 | ibmphp_hpc.o | 36 | ibmphp_hpc.o |
37 | 37 | ||
38 | acpiphp-objs := acpiphp_core.o \ | 38 | acpiphp-objs := acpiphp_core.o \ |
39 | acpiphp_glue.o \ | 39 | acpiphp_glue.o |
40 | acpiphp_pci.o \ | ||
41 | acpiphp_res.o | ||
42 | 40 | ||
43 | rpaphp-objs := rpaphp_core.o \ | 41 | rpaphp-objs := rpaphp_core.o \ |
44 | rpaphp_pci.o \ | 42 | rpaphp_pci.o \ |
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h index d9499874c8a9..293603e1b7c3 100644 --- a/drivers/pci/hotplug/acpiphp.h +++ b/drivers/pci/hotplug/acpiphp.h | |||
@@ -7,6 +7,8 @@ | |||
7 | * Copyright (C) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com) | 7 | * Copyright (C) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com) |
8 | * Copyright (C) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com) | 8 | * Copyright (C) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com) |
9 | * Copyright (C) 2002,2003 NEC Corporation | 9 | * Copyright (C) 2002,2003 NEC Corporation |
10 | * Copyright (C) 2003-2005 Matthew Wilcox (matthew.wilcox@hp.com) | ||
11 | * Copyright (C) 2003-2005 Hewlett Packard | ||
10 | * | 12 | * |
11 | * All rights reserved. | 13 | * All rights reserved. |
12 | * | 14 | * |
@@ -52,7 +54,6 @@ | |||
52 | 54 | ||
53 | struct acpiphp_bridge; | 55 | struct acpiphp_bridge; |
54 | struct acpiphp_slot; | 56 | struct acpiphp_slot; |
55 | struct pci_resource; | ||
56 | 57 | ||
57 | /* | 58 | /* |
58 | * struct slot - slot information for each *physical* slot | 59 | * struct slot - slot information for each *physical* slot |
@@ -65,15 +66,6 @@ struct slot { | |||
65 | struct acpiphp_slot *acpi_slot; | 66 | struct acpiphp_slot *acpi_slot; |
66 | }; | 67 | }; |
67 | 68 | ||
68 | /* | ||
69 | * struct pci_resource - describes pci resource (mem, pfmem, io, bus) | ||
70 | */ | ||
71 | struct pci_resource { | ||
72 | struct pci_resource * next; | ||
73 | u64 base; | ||
74 | u32 length; | ||
75 | }; | ||
76 | |||
77 | /** | 69 | /** |
78 | * struct hpp_param - ACPI 2.0 _HPP Hot Plug Parameters | 70 | * struct hpp_param - ACPI 2.0 _HPP Hot Plug Parameters |
79 | * @cache_line_size in DWORD | 71 | * @cache_line_size in DWORD |
@@ -101,10 +93,6 @@ struct acpiphp_bridge { | |||
101 | int type; | 93 | int type; |
102 | int nr_slots; | 94 | int nr_slots; |
103 | 95 | ||
104 | u8 seg; | ||
105 | u8 bus; | ||
106 | u8 sub; | ||
107 | |||
108 | u32 flags; | 96 | u32 flags; |
109 | 97 | ||
110 | /* This bus (host bridge) or Secondary bus (PCI-to-PCI bridge) */ | 98 | /* This bus (host bridge) or Secondary bus (PCI-to-PCI bridge) */ |
@@ -117,12 +105,6 @@ struct acpiphp_bridge { | |||
117 | struct hpp_param hpp; | 105 | struct hpp_param hpp; |
118 | 106 | ||
119 | spinlock_t res_lock; | 107 | spinlock_t res_lock; |
120 | |||
121 | /* available resources on this bus */ | ||
122 | struct pci_resource *mem_head; | ||
123 | struct pci_resource *p_mem_head; | ||
124 | struct pci_resource *io_head; | ||
125 | struct pci_resource *bus_head; | ||
126 | }; | 108 | }; |
127 | 109 | ||
128 | 110 | ||
@@ -163,12 +145,6 @@ struct acpiphp_func { | |||
163 | 145 | ||
164 | u8 function; /* pci function# */ | 146 | u8 function; /* pci function# */ |
165 | u32 flags; /* see below */ | 147 | u32 flags; /* see below */ |
166 | |||
167 | /* resources used for this function */ | ||
168 | struct pci_resource *mem_head; | ||
169 | struct pci_resource *p_mem_head; | ||
170 | struct pci_resource *io_head; | ||
171 | struct pci_resource *bus_head; | ||
172 | }; | 148 | }; |
173 | 149 | ||
174 | /** | 150 | /** |
@@ -243,25 +219,6 @@ extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot); | |||
243 | extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot); | 219 | extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot); |
244 | extern u32 acpiphp_get_address (struct acpiphp_slot *slot); | 220 | extern u32 acpiphp_get_address (struct acpiphp_slot *slot); |
245 | 221 | ||
246 | /* acpiphp_pci.c */ | ||
247 | extern struct pci_dev *acpiphp_allocate_pcidev (struct pci_bus *pbus, int dev, int fn); | ||
248 | extern int acpiphp_configure_slot (struct acpiphp_slot *slot); | ||
249 | extern int acpiphp_configure_function (struct acpiphp_func *func); | ||
250 | extern void acpiphp_unconfigure_function (struct acpiphp_func *func); | ||
251 | extern int acpiphp_detect_pci_resource (struct acpiphp_bridge *bridge); | ||
252 | extern int acpiphp_init_func_resource (struct acpiphp_func *func); | ||
253 | |||
254 | /* acpiphp_res.c */ | ||
255 | extern struct pci_resource *acpiphp_get_io_resource (struct pci_resource **head, u32 size); | ||
256 | extern struct pci_resource *acpiphp_get_resource (struct pci_resource **head, u32 size); | ||
257 | extern struct pci_resource *acpiphp_get_resource_with_base (struct pci_resource **head, u64 base, u32 size); | ||
258 | extern int acpiphp_resource_sort_and_combine (struct pci_resource **head); | ||
259 | extern struct pci_resource *acpiphp_make_resource (u64 base, u32 length); | ||
260 | extern void acpiphp_move_resource (struct pci_resource **from, struct pci_resource **to); | ||
261 | extern void acpiphp_free_resource (struct pci_resource **res); | ||
262 | extern void acpiphp_dump_resource (struct acpiphp_bridge *bridge); /* debug */ | ||
263 | extern void acpiphp_dump_func_resource (struct acpiphp_func *func); /* debug */ | ||
264 | |||
265 | /* variables */ | 222 | /* variables */ |
266 | extern int acpiphp_debug; | 223 | extern int acpiphp_debug; |
267 | 224 | ||
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c index 4539e61a3dc1..60c4c38047a3 100644 --- a/drivers/pci/hotplug/acpiphp_core.c +++ b/drivers/pci/hotplug/acpiphp_core.c | |||
@@ -7,6 +7,8 @@ | |||
7 | * Copyright (C) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com) | 7 | * Copyright (C) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com) |
8 | * Copyright (C) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com) | 8 | * Copyright (C) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com) |
9 | * Copyright (C) 2002,2003 NEC Corporation | 9 | * Copyright (C) 2002,2003 NEC Corporation |
10 | * Copyright (C) 2003-2005 Matthew Wilcox (matthew.wilcox@hp.com) | ||
11 | * Copyright (C) 2003-2005 Hewlett Packard | ||
10 | * | 12 | * |
11 | * All rights reserved. | 13 | * All rights reserved. |
12 | * | 14 | * |
@@ -53,8 +55,8 @@ int acpiphp_debug; | |||
53 | static int num_slots; | 55 | static int num_slots; |
54 | static struct acpiphp_attention_info *attention_info; | 56 | static struct acpiphp_attention_info *attention_info; |
55 | 57 | ||
56 | #define DRIVER_VERSION "0.4" | 58 | #define DRIVER_VERSION "0.5" |
57 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <gregkh@us.ibm.com>, Takayoshi Kochi <t-kochi@bq.jp.nec.com>" | 59 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <gregkh@us.ibm.com>, Takayoshi Kochi <t-kochi@bq.jp.nec.com>, Matthew Wilcox <willy@hp.com>" |
58 | #define DRIVER_DESC "ACPI Hot Plug PCI Controller Driver" | 60 | #define DRIVER_DESC "ACPI Hot Plug PCI Controller Driver" |
59 | 61 | ||
60 | MODULE_AUTHOR(DRIVER_AUTHOR); | 62 | MODULE_AUTHOR(DRIVER_AUTHOR); |
@@ -281,8 +283,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
281 | /** | 283 | /** |
282 | * get_address - get pci address of a slot | 284 | * get_address - get pci address of a slot |
283 | * @hotplug_slot: slot to get status | 285 | * @hotplug_slot: slot to get status |
284 | * @busdev: pointer to struct pci_busdev (seg, bus, dev) | 286 | * @value: pointer to struct pci_busdev (seg, bus, dev) |
285 | * | ||
286 | */ | 287 | */ |
287 | static int get_address(struct hotplug_slot *hotplug_slot, u32 *value) | 288 | static int get_address(struct hotplug_slot *hotplug_slot, u32 *value) |
288 | { | 289 | { |
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index e7f41294f811..424e7de181ae 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -4,6 +4,10 @@ | |||
4 | * Copyright (C) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com) | 4 | * Copyright (C) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com) |
5 | * Copyright (C) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com) | 5 | * Copyright (C) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com) |
6 | * Copyright (C) 2002,2003 NEC Corporation | 6 | * Copyright (C) 2002,2003 NEC Corporation |
7 | * Copyright (C) 2003-2005 Matthew Wilcox (matthew.wilcox@hp.com) | ||
8 | * Copyright (C) 2003-2005 Hewlett Packard | ||
9 | * Copyright (C) 2005 Rajesh Shah (rajesh.shah@intel.com) | ||
10 | * Copyright (C) 2005 Intel Corporation | ||
7 | * | 11 | * |
8 | * All rights reserved. | 12 | * All rights reserved. |
9 | * | 13 | * |
@@ -26,6 +30,16 @@ | |||
26 | * | 30 | * |
27 | */ | 31 | */ |
28 | 32 | ||
33 | /* | ||
34 | * Lifetime rules for pci_dev: | ||
35 | * - The one in acpiphp_func has its refcount elevated by pci_get_slot() | ||
36 | * when the driver is loaded or when an insertion event occurs. It loses | ||
37 | * a refcount when its ejected or the driver unloads. | ||
38 | * - The one in acpiphp_bridge has its refcount elevated by pci_get_slot() | ||
39 | * when the bridge is scanned and it loses a refcount when the bridge | ||
40 | * is removed. | ||
41 | */ | ||
42 | |||
29 | #include <linux/init.h> | 43 | #include <linux/init.h> |
30 | #include <linux/module.h> | 44 | #include <linux/module.h> |
31 | 45 | ||
@@ -178,21 +192,18 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
178 | 192 | ||
179 | bridge->nr_slots++; | 193 | bridge->nr_slots++; |
180 | 194 | ||
181 | dbg("found ACPI PCI Hotplug slot at PCI %02x:%02x Slot:%d\n", | 195 | dbg("found ACPI PCI Hotplug slot %d at PCI %04x:%02x:%02x\n", |
182 | slot->bridge->bus, slot->device, slot->sun); | 196 | slot->sun, pci_domain_nr(bridge->pci_bus), |
197 | bridge->pci_bus->number, slot->device); | ||
183 | } | 198 | } |
184 | 199 | ||
185 | newfunc->slot = slot; | 200 | newfunc->slot = slot; |
186 | list_add_tail(&newfunc->sibling, &slot->funcs); | 201 | list_add_tail(&newfunc->sibling, &slot->funcs); |
187 | 202 | ||
188 | /* associate corresponding pci_dev */ | 203 | /* associate corresponding pci_dev */ |
189 | newfunc->pci_dev = pci_find_slot(bridge->bus, | 204 | newfunc->pci_dev = pci_get_slot(bridge->pci_bus, |
190 | PCI_DEVFN(device, function)); | 205 | PCI_DEVFN(device, function)); |
191 | if (newfunc->pci_dev) { | 206 | if (newfunc->pci_dev) { |
192 | if (acpiphp_init_func_resource(newfunc) < 0) { | ||
193 | kfree(newfunc); | ||
194 | return AE_ERROR; | ||
195 | } | ||
196 | slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); | 207 | slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); |
197 | } | 208 | } |
198 | 209 | ||
@@ -227,62 +238,6 @@ static int detect_ejectable_slots(acpi_handle *bridge_handle) | |||
227 | } | 238 | } |
228 | 239 | ||
229 | 240 | ||
230 | /* decode ACPI _CRS data and convert into our internal resource list | ||
231 | * TBD: _TRA, etc. | ||
232 | */ | ||
233 | static acpi_status | ||
234 | decode_acpi_resource(struct acpi_resource *resource, void *context) | ||
235 | { | ||
236 | struct acpiphp_bridge *bridge = (struct acpiphp_bridge *) context; | ||
237 | struct acpi_resource_address64 address; | ||
238 | struct pci_resource *res; | ||
239 | |||
240 | if (resource->id != ACPI_RSTYPE_ADDRESS16 && | ||
241 | resource->id != ACPI_RSTYPE_ADDRESS32 && | ||
242 | resource->id != ACPI_RSTYPE_ADDRESS64) | ||
243 | return AE_OK; | ||
244 | |||
245 | acpi_resource_to_address64(resource, &address); | ||
246 | |||
247 | if (address.producer_consumer == ACPI_PRODUCER && address.address_length > 0) { | ||
248 | dbg("resource type: %d: 0x%llx - 0x%llx\n", address.resource_type, | ||
249 | (unsigned long long)address.min_address_range, | ||
250 | (unsigned long long)address.max_address_range); | ||
251 | res = acpiphp_make_resource(address.min_address_range, | ||
252 | address.address_length); | ||
253 | if (!res) { | ||
254 | err("out of memory\n"); | ||
255 | return AE_OK; | ||
256 | } | ||
257 | |||
258 | switch (address.resource_type) { | ||
259 | case ACPI_MEMORY_RANGE: | ||
260 | if (address.attribute.memory.cache_attribute == ACPI_PREFETCHABLE_MEMORY) { | ||
261 | res->next = bridge->p_mem_head; | ||
262 | bridge->p_mem_head = res; | ||
263 | } else { | ||
264 | res->next = bridge->mem_head; | ||
265 | bridge->mem_head = res; | ||
266 | } | ||
267 | break; | ||
268 | case ACPI_IO_RANGE: | ||
269 | res->next = bridge->io_head; | ||
270 | bridge->io_head = res; | ||
271 | break; | ||
272 | case ACPI_BUS_NUMBER_RANGE: | ||
273 | res->next = bridge->bus_head; | ||
274 | bridge->bus_head = res; | ||
275 | break; | ||
276 | default: | ||
277 | /* invalid type */ | ||
278 | kfree(res); | ||
279 | break; | ||
280 | } | ||
281 | } | ||
282 | |||
283 | return AE_OK; | ||
284 | } | ||
285 | |||
286 | /* decode ACPI 2.0 _HPP hot plug parameters */ | 241 | /* decode ACPI 2.0 _HPP hot plug parameters */ |
287 | static void decode_hpp(struct acpiphp_bridge *bridge) | 242 | static void decode_hpp(struct acpiphp_bridge *bridge) |
288 | { | 243 | { |
@@ -346,34 +301,29 @@ static void init_bridge_misc(struct acpiphp_bridge *bridge) | |||
346 | /* decode ACPI 2.0 _HPP (hot plug parameters) */ | 301 | /* decode ACPI 2.0 _HPP (hot plug parameters) */ |
347 | decode_hpp(bridge); | 302 | decode_hpp(bridge); |
348 | 303 | ||
349 | /* subtract all resources already allocated */ | ||
350 | acpiphp_detect_pci_resource(bridge); | ||
351 | |||
352 | /* register all slot objects under this bridge */ | 304 | /* register all slot objects under this bridge */ |
353 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge->handle, (u32)1, | 305 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge->handle, (u32)1, |
354 | register_slot, bridge, NULL); | 306 | register_slot, bridge, NULL); |
355 | 307 | ||
356 | /* install notify handler */ | 308 | /* install notify handler */ |
357 | status = acpi_install_notify_handler(bridge->handle, | 309 | if (bridge->type != BRIDGE_TYPE_HOST) { |
310 | status = acpi_install_notify_handler(bridge->handle, | ||
358 | ACPI_SYSTEM_NOTIFY, | 311 | ACPI_SYSTEM_NOTIFY, |
359 | handle_hotplug_event_bridge, | 312 | handle_hotplug_event_bridge, |
360 | bridge); | 313 | bridge); |
361 | 314 | ||
362 | if (ACPI_FAILURE(status)) { | 315 | if (ACPI_FAILURE(status)) { |
363 | err("failed to register interrupt notify handler\n"); | 316 | err("failed to register interrupt notify handler\n"); |
317 | } | ||
364 | } | 318 | } |
365 | 319 | ||
366 | list_add(&bridge->list, &bridge_list); | 320 | list_add(&bridge->list, &bridge_list); |
367 | |||
368 | dbg("Bridge resource:\n"); | ||
369 | acpiphp_dump_resource(bridge); | ||
370 | } | 321 | } |
371 | 322 | ||
372 | 323 | ||
373 | /* allocate and initialize host bridge data structure */ | 324 | /* allocate and initialize host bridge data structure */ |
374 | static void add_host_bridge(acpi_handle *handle, int seg, int bus) | 325 | static void add_host_bridge(acpi_handle *handle, struct pci_bus *pci_bus) |
375 | { | 326 | { |
376 | acpi_status status; | ||
377 | struct acpiphp_bridge *bridge; | 327 | struct acpiphp_bridge *bridge; |
378 | 328 | ||
379 | bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); | 329 | bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); |
@@ -384,52 +334,19 @@ static void add_host_bridge(acpi_handle *handle, int seg, int bus) | |||
384 | 334 | ||
385 | bridge->type = BRIDGE_TYPE_HOST; | 335 | bridge->type = BRIDGE_TYPE_HOST; |
386 | bridge->handle = handle; | 336 | bridge->handle = handle; |
387 | bridge->seg = seg; | ||
388 | bridge->bus = bus; | ||
389 | 337 | ||
390 | bridge->pci_bus = pci_find_bus(seg, bus); | 338 | bridge->pci_bus = pci_bus; |
391 | 339 | ||
392 | spin_lock_init(&bridge->res_lock); | 340 | spin_lock_init(&bridge->res_lock); |
393 | 341 | ||
394 | /* to be overridden when we decode _CRS */ | ||
395 | bridge->sub = bridge->bus; | ||
396 | |||
397 | /* decode resources */ | ||
398 | |||
399 | status = acpi_walk_resources(handle, METHOD_NAME__CRS, | ||
400 | decode_acpi_resource, bridge); | ||
401 | |||
402 | if (ACPI_FAILURE(status)) { | ||
403 | err("failed to decode bridge resources\n"); | ||
404 | kfree(bridge); | ||
405 | return; | ||
406 | } | ||
407 | |||
408 | acpiphp_resource_sort_and_combine(&bridge->io_head); | ||
409 | acpiphp_resource_sort_and_combine(&bridge->mem_head); | ||
410 | acpiphp_resource_sort_and_combine(&bridge->p_mem_head); | ||
411 | acpiphp_resource_sort_and_combine(&bridge->bus_head); | ||
412 | |||
413 | dbg("ACPI _CRS resource:\n"); | ||
414 | acpiphp_dump_resource(bridge); | ||
415 | |||
416 | if (bridge->bus_head) { | ||
417 | bridge->bus = bridge->bus_head->base; | ||
418 | bridge->sub = bridge->bus_head->base + bridge->bus_head->length - 1; | ||
419 | } | ||
420 | |||
421 | init_bridge_misc(bridge); | 342 | init_bridge_misc(bridge); |
422 | } | 343 | } |
423 | 344 | ||
424 | 345 | ||
425 | /* allocate and initialize PCI-to-PCI bridge data structure */ | 346 | /* allocate and initialize PCI-to-PCI bridge data structure */ |
426 | static void add_p2p_bridge(acpi_handle *handle, int seg, int bus, int dev, int fn) | 347 | static void add_p2p_bridge(acpi_handle *handle, struct pci_dev *pci_dev) |
427 | { | 348 | { |
428 | struct acpiphp_bridge *bridge; | 349 | struct acpiphp_bridge *bridge; |
429 | u8 tmp8; | ||
430 | u16 tmp16; | ||
431 | u64 base64, limit64; | ||
432 | u32 base, limit, base32u, limit32u; | ||
433 | 350 | ||
434 | bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); | 351 | bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); |
435 | if (bridge == NULL) { | 352 | if (bridge == NULL) { |
@@ -441,133 +358,22 @@ static void add_p2p_bridge(acpi_handle *handle, int seg, int bus, int dev, int f | |||
441 | 358 | ||
442 | bridge->type = BRIDGE_TYPE_P2P; | 359 | bridge->type = BRIDGE_TYPE_P2P; |
443 | bridge->handle = handle; | 360 | bridge->handle = handle; |
444 | bridge->seg = seg; | ||
445 | |||
446 | bridge->pci_dev = pci_find_slot(bus, PCI_DEVFN(dev, fn)); | ||
447 | if (!bridge->pci_dev) { | ||
448 | err("Can't get pci_dev\n"); | ||
449 | kfree(bridge); | ||
450 | return; | ||
451 | } | ||
452 | 361 | ||
453 | bridge->pci_bus = bridge->pci_dev->subordinate; | 362 | bridge->pci_dev = pci_dev_get(pci_dev); |
363 | bridge->pci_bus = pci_dev->subordinate; | ||
454 | if (!bridge->pci_bus) { | 364 | if (!bridge->pci_bus) { |
455 | err("This is not a PCI-to-PCI bridge!\n"); | 365 | err("This is not a PCI-to-PCI bridge!\n"); |
456 | kfree(bridge); | 366 | goto err; |
457 | return; | ||
458 | } | 367 | } |
459 | 368 | ||
460 | spin_lock_init(&bridge->res_lock); | 369 | spin_lock_init(&bridge->res_lock); |
461 | 370 | ||
462 | bridge->bus = bridge->pci_bus->number; | ||
463 | bridge->sub = bridge->pci_bus->subordinate; | ||
464 | |||
465 | /* | ||
466 | * decode resources under this P2P bridge | ||
467 | */ | ||
468 | |||
469 | /* I/O resources */ | ||
470 | pci_read_config_byte(bridge->pci_dev, PCI_IO_BASE, &tmp8); | ||
471 | base = tmp8; | ||
472 | pci_read_config_byte(bridge->pci_dev, PCI_IO_LIMIT, &tmp8); | ||
473 | limit = tmp8; | ||
474 | |||
475 | switch (base & PCI_IO_RANGE_TYPE_MASK) { | ||
476 | case PCI_IO_RANGE_TYPE_16: | ||
477 | base = (base << 8) & 0xf000; | ||
478 | limit = ((limit << 8) & 0xf000) + 0xfff; | ||
479 | bridge->io_head = acpiphp_make_resource((u64)base, limit - base + 1); | ||
480 | if (!bridge->io_head) { | ||
481 | err("out of memory\n"); | ||
482 | kfree(bridge); | ||
483 | return; | ||
484 | } | ||
485 | dbg("16bit I/O range: %04x-%04x\n", | ||
486 | (u32)bridge->io_head->base, | ||
487 | (u32)(bridge->io_head->base + bridge->io_head->length - 1)); | ||
488 | break; | ||
489 | case PCI_IO_RANGE_TYPE_32: | ||
490 | pci_read_config_word(bridge->pci_dev, PCI_IO_BASE_UPPER16, &tmp16); | ||
491 | base = ((u32)tmp16 << 16) | ((base << 8) & 0xf000); | ||
492 | pci_read_config_word(bridge->pci_dev, PCI_IO_LIMIT_UPPER16, &tmp16); | ||
493 | limit = (((u32)tmp16 << 16) | ((limit << 8) & 0xf000)) + 0xfff; | ||
494 | bridge->io_head = acpiphp_make_resource((u64)base, limit - base + 1); | ||
495 | if (!bridge->io_head) { | ||
496 | err("out of memory\n"); | ||
497 | kfree(bridge); | ||
498 | return; | ||
499 | } | ||
500 | dbg("32bit I/O range: %08x-%08x\n", | ||
501 | (u32)bridge->io_head->base, | ||
502 | (u32)(bridge->io_head->base + bridge->io_head->length - 1)); | ||
503 | break; | ||
504 | case 0x0f: | ||
505 | dbg("I/O space unsupported\n"); | ||
506 | break; | ||
507 | default: | ||
508 | warn("Unknown I/O range type\n"); | ||
509 | } | ||
510 | |||
511 | /* Memory resources (mandatory for P2P bridge) */ | ||
512 | pci_read_config_word(bridge->pci_dev, PCI_MEMORY_BASE, &tmp16); | ||
513 | base = (tmp16 & 0xfff0) << 16; | ||
514 | pci_read_config_word(bridge->pci_dev, PCI_MEMORY_LIMIT, &tmp16); | ||
515 | limit = ((tmp16 & 0xfff0) << 16) | 0xfffff; | ||
516 | bridge->mem_head = acpiphp_make_resource((u64)base, limit - base + 1); | ||
517 | if (!bridge->mem_head) { | ||
518 | err("out of memory\n"); | ||
519 | kfree(bridge); | ||
520 | return; | ||
521 | } | ||
522 | dbg("32bit Memory range: %08x-%08x\n", | ||
523 | (u32)bridge->mem_head->base, | ||
524 | (u32)(bridge->mem_head->base + bridge->mem_head->length-1)); | ||
525 | |||
526 | /* Prefetchable Memory resources (optional) */ | ||
527 | pci_read_config_word(bridge->pci_dev, PCI_PREF_MEMORY_BASE, &tmp16); | ||
528 | base = tmp16; | ||
529 | pci_read_config_word(bridge->pci_dev, PCI_PREF_MEMORY_LIMIT, &tmp16); | ||
530 | limit = tmp16; | ||
531 | |||
532 | switch (base & PCI_MEMORY_RANGE_TYPE_MASK) { | ||
533 | case PCI_PREF_RANGE_TYPE_32: | ||
534 | base = (base & 0xfff0) << 16; | ||
535 | limit = ((limit & 0xfff0) << 16) | 0xfffff; | ||
536 | bridge->p_mem_head = acpiphp_make_resource((u64)base, limit - base + 1); | ||
537 | if (!bridge->p_mem_head) { | ||
538 | err("out of memory\n"); | ||
539 | kfree(bridge); | ||
540 | return; | ||
541 | } | ||
542 | dbg("32bit Prefetchable memory range: %08x-%08x\n", | ||
543 | (u32)bridge->p_mem_head->base, | ||
544 | (u32)(bridge->p_mem_head->base + bridge->p_mem_head->length - 1)); | ||
545 | break; | ||
546 | case PCI_PREF_RANGE_TYPE_64: | ||
547 | pci_read_config_dword(bridge->pci_dev, PCI_PREF_BASE_UPPER32, &base32u); | ||
548 | pci_read_config_dword(bridge->pci_dev, PCI_PREF_LIMIT_UPPER32, &limit32u); | ||
549 | base64 = ((u64)base32u << 32) | ((base & 0xfff0) << 16); | ||
550 | limit64 = (((u64)limit32u << 32) | ((limit & 0xfff0) << 16)) + 0xfffff; | ||
551 | |||
552 | bridge->p_mem_head = acpiphp_make_resource(base64, limit64 - base64 + 1); | ||
553 | if (!bridge->p_mem_head) { | ||
554 | err("out of memory\n"); | ||
555 | kfree(bridge); | ||
556 | return; | ||
557 | } | ||
558 | dbg("64bit Prefetchable memory range: %08x%08x-%08x%08x\n", | ||
559 | (u32)(bridge->p_mem_head->base >> 32), | ||
560 | (u32)(bridge->p_mem_head->base & 0xffffffff), | ||
561 | (u32)((bridge->p_mem_head->base + bridge->p_mem_head->length - 1) >> 32), | ||
562 | (u32)((bridge->p_mem_head->base + bridge->p_mem_head->length - 1) & 0xffffffff)); | ||
563 | break; | ||
564 | case 0x0f: | ||
565 | break; | ||
566 | default: | ||
567 | warn("Unknown prefetchale memory type\n"); | ||
568 | } | ||
569 | |||
570 | init_bridge_misc(bridge); | 371 | init_bridge_misc(bridge); |
372 | return; | ||
373 | err: | ||
374 | pci_dev_put(pci_dev); | ||
375 | kfree(bridge); | ||
376 | return; | ||
571 | } | 377 | } |
572 | 378 | ||
573 | 379 | ||
@@ -577,14 +383,10 @@ find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
577 | { | 383 | { |
578 | acpi_status status; | 384 | acpi_status status; |
579 | acpi_handle dummy_handle; | 385 | acpi_handle dummy_handle; |
580 | unsigned long *segbus = context; | ||
581 | unsigned long tmp; | 386 | unsigned long tmp; |
582 | int seg, bus, device, function; | 387 | int device, function; |
583 | struct pci_dev *dev; | 388 | struct pci_dev *dev; |
584 | 389 | struct pci_bus *pci_bus = context; | |
585 | /* get PCI address */ | ||
586 | seg = (*segbus >> 8) & 0xff; | ||
587 | bus = *segbus & 0xff; | ||
588 | 390 | ||
589 | status = acpi_get_handle(handle, "_ADR", &dummy_handle); | 391 | status = acpi_get_handle(handle, "_ADR", &dummy_handle); |
590 | if (ACPI_FAILURE(status)) | 392 | if (ACPI_FAILURE(status)) |
@@ -599,20 +401,19 @@ find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
599 | device = (tmp >> 16) & 0xffff; | 401 | device = (tmp >> 16) & 0xffff; |
600 | function = tmp & 0xffff; | 402 | function = tmp & 0xffff; |
601 | 403 | ||
602 | dev = pci_find_slot(bus, PCI_DEVFN(device, function)); | 404 | dev = pci_get_slot(pci_bus, PCI_DEVFN(device, function)); |
603 | 405 | ||
604 | if (!dev) | 406 | if (!dev || !dev->subordinate) |
605 | return AE_OK; | 407 | goto out; |
606 | |||
607 | if (!dev->subordinate) | ||
608 | return AE_OK; | ||
609 | 408 | ||
610 | /* check if this bridge has ejectable slots */ | 409 | /* check if this bridge has ejectable slots */ |
611 | if (detect_ejectable_slots(handle) > 0) { | 410 | if (detect_ejectable_slots(handle) > 0) { |
612 | dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev)); | 411 | dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev)); |
613 | add_p2p_bridge(handle, seg, bus, device, function); | 412 | add_p2p_bridge(handle, dev); |
614 | } | 413 | } |
615 | 414 | ||
415 | out: | ||
416 | pci_dev_put(dev); | ||
616 | return AE_OK; | 417 | return AE_OK; |
617 | } | 418 | } |
618 | 419 | ||
@@ -624,6 +425,7 @@ static int add_bridge(acpi_handle handle) | |||
624 | unsigned long tmp; | 425 | unsigned long tmp; |
625 | int seg, bus; | 426 | int seg, bus; |
626 | acpi_handle dummy_handle; | 427 | acpi_handle dummy_handle; |
428 | struct pci_bus *pci_bus; | ||
627 | 429 | ||
628 | /* if the bridge doesn't have _STA, we assume it is always there */ | 430 | /* if the bridge doesn't have _STA, we assume it is always there */ |
629 | status = acpi_get_handle(handle, "_STA", &dummy_handle); | 431 | status = acpi_get_handle(handle, "_STA", &dummy_handle); |
@@ -653,18 +455,22 @@ static int add_bridge(acpi_handle handle) | |||
653 | bus = 0; | 455 | bus = 0; |
654 | } | 456 | } |
655 | 457 | ||
458 | pci_bus = pci_find_bus(seg, bus); | ||
459 | if (!pci_bus) { | ||
460 | err("Can't find bus %04x:%02x\n", seg, bus); | ||
461 | return 0; | ||
462 | } | ||
463 | |||
656 | /* check if this bridge has ejectable slots */ | 464 | /* check if this bridge has ejectable slots */ |
657 | if (detect_ejectable_slots(handle) > 0) { | 465 | if (detect_ejectable_slots(handle) > 0) { |
658 | dbg("found PCI host-bus bridge with hot-pluggable slots\n"); | 466 | dbg("found PCI host-bus bridge with hot-pluggable slots\n"); |
659 | add_host_bridge(handle, seg, bus); | 467 | add_host_bridge(handle, pci_bus); |
660 | return 0; | 468 | return 0; |
661 | } | 469 | } |
662 | 470 | ||
663 | tmp = seg << 8 | bus; | ||
664 | |||
665 | /* search P2P bridges under this host bridge */ | 471 | /* search P2P bridges under this host bridge */ |
666 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, | 472 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, |
667 | find_p2p_bridge, &tmp, NULL); | 473 | find_p2p_bridge, pci_bus, NULL); |
668 | 474 | ||
669 | if (ACPI_FAILURE(status)) | 475 | if (ACPI_FAILURE(status)) |
670 | warn("find_p2p_bridge faied (error code = 0x%x)\n",status); | 476 | warn("find_p2p_bridge faied (error code = 0x%x)\n",status); |
@@ -672,12 +478,205 @@ static int add_bridge(acpi_handle handle) | |||
672 | return 0; | 478 | return 0; |
673 | } | 479 | } |
674 | 480 | ||
481 | static struct acpiphp_bridge *acpiphp_handle_to_bridge(acpi_handle handle) | ||
482 | { | ||
483 | struct list_head *head; | ||
484 | list_for_each(head, &bridge_list) { | ||
485 | struct acpiphp_bridge *bridge = list_entry(head, | ||
486 | struct acpiphp_bridge, list); | ||
487 | if (bridge->handle == handle) | ||
488 | return bridge; | ||
489 | } | ||
490 | |||
491 | return NULL; | ||
492 | } | ||
493 | |||
494 | static void cleanup_bridge(struct acpiphp_bridge *bridge) | ||
495 | { | ||
496 | struct list_head *list, *tmp; | ||
497 | struct acpiphp_slot *slot; | ||
498 | acpi_status status; | ||
499 | acpi_handle handle = bridge->handle; | ||
500 | |||
501 | status = acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
502 | handle_hotplug_event_bridge); | ||
503 | if (ACPI_FAILURE(status)) | ||
504 | err("failed to remove notify handler\n"); | ||
505 | |||
506 | slot = bridge->slots; | ||
507 | while (slot) { | ||
508 | struct acpiphp_slot *next = slot->next; | ||
509 | list_for_each_safe (list, tmp, &slot->funcs) { | ||
510 | struct acpiphp_func *func; | ||
511 | func = list_entry(list, struct acpiphp_func, sibling); | ||
512 | status = acpi_remove_notify_handler(func->handle, | ||
513 | ACPI_SYSTEM_NOTIFY, | ||
514 | handle_hotplug_event_func); | ||
515 | if (ACPI_FAILURE(status)) | ||
516 | err("failed to remove notify handler\n"); | ||
517 | pci_dev_put(func->pci_dev); | ||
518 | list_del(list); | ||
519 | kfree(func); | ||
520 | } | ||
521 | kfree(slot); | ||
522 | slot = next; | ||
523 | } | ||
524 | |||
525 | pci_dev_put(bridge->pci_dev); | ||
526 | list_del(&bridge->list); | ||
527 | kfree(bridge); | ||
528 | } | ||
529 | |||
530 | static acpi_status | ||
531 | cleanup_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
532 | { | ||
533 | struct acpiphp_bridge *bridge; | ||
534 | |||
535 | if (!(bridge = acpiphp_handle_to_bridge(handle))) | ||
536 | return AE_OK; | ||
537 | cleanup_bridge(bridge); | ||
538 | return AE_OK; | ||
539 | } | ||
675 | 540 | ||
676 | static void remove_bridge(acpi_handle handle) | 541 | static void remove_bridge(acpi_handle handle) |
677 | { | 542 | { |
678 | /* No-op for now .. */ | 543 | struct acpiphp_bridge *bridge; |
544 | |||
545 | bridge = acpiphp_handle_to_bridge(handle); | ||
546 | if (bridge) { | ||
547 | cleanup_bridge(bridge); | ||
548 | } else { | ||
549 | /* clean-up p2p bridges under this host bridge */ | ||
550 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, | ||
551 | (u32)1, cleanup_p2p_bridge, NULL, NULL); | ||
552 | } | ||
553 | } | ||
554 | |||
555 | static struct pci_dev * get_apic_pci_info(acpi_handle handle) | ||
556 | { | ||
557 | struct acpi_pci_id id; | ||
558 | struct pci_bus *bus; | ||
559 | struct pci_dev *dev; | ||
560 | |||
561 | if (ACPI_FAILURE(acpi_get_pci_id(handle, &id))) | ||
562 | return NULL; | ||
563 | |||
564 | bus = pci_find_bus(id.segment, id.bus); | ||
565 | if (!bus) | ||
566 | return NULL; | ||
567 | |||
568 | dev = pci_get_slot(bus, PCI_DEVFN(id.device, id.function)); | ||
569 | if (!dev) | ||
570 | return NULL; | ||
571 | |||
572 | if ((dev->class != PCI_CLASS_SYSTEM_PIC_IOAPIC) && | ||
573 | (dev->class != PCI_CLASS_SYSTEM_PIC_IOXAPIC)) | ||
574 | { | ||
575 | pci_dev_put(dev); | ||
576 | return NULL; | ||
577 | } | ||
578 | |||
579 | return dev; | ||
580 | } | ||
581 | |||
582 | static int get_gsi_base(acpi_handle handle, u32 *gsi_base) | ||
583 | { | ||
584 | acpi_status status; | ||
585 | int result = -1; | ||
586 | unsigned long gsb; | ||
587 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
588 | union acpi_object *obj; | ||
589 | void *table; | ||
590 | |||
591 | status = acpi_evaluate_integer(handle, "_GSB", NULL, &gsb); | ||
592 | if (ACPI_SUCCESS(status)) { | ||
593 | *gsi_base = (u32)gsb; | ||
594 | return 0; | ||
595 | } | ||
596 | |||
597 | status = acpi_evaluate_object(handle, "_MAT", NULL, &buffer); | ||
598 | if (ACPI_FAILURE(status) || !buffer.length || !buffer.pointer) | ||
599 | return -1; | ||
600 | |||
601 | obj = buffer.pointer; | ||
602 | if (obj->type != ACPI_TYPE_BUFFER) | ||
603 | goto out; | ||
604 | |||
605 | table = obj->buffer.pointer; | ||
606 | switch (((acpi_table_entry_header *)table)->type) { | ||
607 | case ACPI_MADT_IOSAPIC: | ||
608 | *gsi_base = ((struct acpi_table_iosapic *)table)->global_irq_base; | ||
609 | result = 0; | ||
610 | break; | ||
611 | case ACPI_MADT_IOAPIC: | ||
612 | *gsi_base = ((struct acpi_table_ioapic *)table)->global_irq_base; | ||
613 | result = 0; | ||
614 | break; | ||
615 | default: | ||
616 | break; | ||
617 | } | ||
618 | out: | ||
619 | acpi_os_free(buffer.pointer); | ||
620 | return result; | ||
621 | } | ||
622 | |||
623 | static acpi_status | ||
624 | ioapic_add(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
625 | { | ||
626 | acpi_status status; | ||
627 | unsigned long sta; | ||
628 | acpi_handle tmp; | ||
629 | struct pci_dev *pdev; | ||
630 | u32 gsi_base; | ||
631 | u64 phys_addr; | ||
632 | |||
633 | /* Evaluate _STA if present */ | ||
634 | status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); | ||
635 | if (ACPI_SUCCESS(status) && sta != ACPI_STA_ALL) | ||
636 | return AE_CTRL_DEPTH; | ||
637 | |||
638 | /* Scan only PCI bus scope */ | ||
639 | status = acpi_get_handle(handle, "_HID", &tmp); | ||
640 | if (ACPI_SUCCESS(status)) | ||
641 | return AE_CTRL_DEPTH; | ||
642 | |||
643 | if (get_gsi_base(handle, &gsi_base)) | ||
644 | return AE_OK; | ||
645 | |||
646 | pdev = get_apic_pci_info(handle); | ||
647 | if (!pdev) | ||
648 | return AE_OK; | ||
649 | |||
650 | if (pci_enable_device(pdev)) { | ||
651 | pci_dev_put(pdev); | ||
652 | return AE_OK; | ||
653 | } | ||
654 | |||
655 | pci_set_master(pdev); | ||
656 | |||
657 | if (pci_request_region(pdev, 0, "I/O APIC(acpiphp)")) { | ||
658 | pci_disable_device(pdev); | ||
659 | pci_dev_put(pdev); | ||
660 | return AE_OK; | ||
661 | } | ||
662 | |||
663 | phys_addr = pci_resource_start(pdev, 0); | ||
664 | if (acpi_register_ioapic(handle, phys_addr, gsi_base)) { | ||
665 | pci_release_region(pdev, 0); | ||
666 | pci_disable_device(pdev); | ||
667 | pci_dev_put(pdev); | ||
668 | return AE_OK; | ||
669 | } | ||
670 | |||
671 | return AE_OK; | ||
679 | } | 672 | } |
680 | 673 | ||
674 | static int acpiphp_configure_ioapics(acpi_handle handle) | ||
675 | { | ||
676 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, | ||
677 | ACPI_UINT32_MAX, ioapic_add, NULL, NULL); | ||
678 | return 0; | ||
679 | } | ||
681 | 680 | ||
682 | static int power_on_slot(struct acpiphp_slot *slot) | 681 | static int power_on_slot(struct acpiphp_slot *slot) |
683 | { | 682 | { |
@@ -719,8 +718,6 @@ static int power_off_slot(struct acpiphp_slot *slot) | |||
719 | acpi_status status; | 718 | acpi_status status; |
720 | struct acpiphp_func *func; | 719 | struct acpiphp_func *func; |
721 | struct list_head *l; | 720 | struct list_head *l; |
722 | struct acpi_object_list arg_list; | ||
723 | union acpi_object arg; | ||
724 | 721 | ||
725 | int retval = 0; | 722 | int retval = 0; |
726 | 723 | ||
@@ -731,7 +728,7 @@ static int power_off_slot(struct acpiphp_slot *slot) | |||
731 | list_for_each (l, &slot->funcs) { | 728 | list_for_each (l, &slot->funcs) { |
732 | func = list_entry(l, struct acpiphp_func, sibling); | 729 | func = list_entry(l, struct acpiphp_func, sibling); |
733 | 730 | ||
734 | if (func->pci_dev && (func->flags & FUNC_HAS_PS3)) { | 731 | if (func->flags & FUNC_HAS_PS3) { |
735 | status = acpi_evaluate_object(func->handle, "_PS3", NULL, NULL); | 732 | status = acpi_evaluate_object(func->handle, "_PS3", NULL, NULL); |
736 | if (ACPI_FAILURE(status)) { | 733 | if (ACPI_FAILURE(status)) { |
737 | warn("%s: _PS3 failed\n", __FUNCTION__); | 734 | warn("%s: _PS3 failed\n", __FUNCTION__); |
@@ -742,27 +739,6 @@ static int power_off_slot(struct acpiphp_slot *slot) | |||
742 | } | 739 | } |
743 | } | 740 | } |
744 | 741 | ||
745 | list_for_each (l, &slot->funcs) { | ||
746 | func = list_entry(l, struct acpiphp_func, sibling); | ||
747 | |||
748 | /* We don't want to call _EJ0 on non-existing functions. */ | ||
749 | if (func->pci_dev && (func->flags & FUNC_HAS_EJ0)) { | ||
750 | /* _EJ0 method take one argument */ | ||
751 | arg_list.count = 1; | ||
752 | arg_list.pointer = &arg; | ||
753 | arg.type = ACPI_TYPE_INTEGER; | ||
754 | arg.integer.value = 1; | ||
755 | |||
756 | status = acpi_evaluate_object(func->handle, "_EJ0", &arg_list, NULL); | ||
757 | if (ACPI_FAILURE(status)) { | ||
758 | warn("%s: _EJ0 failed\n", __FUNCTION__); | ||
759 | retval = -1; | ||
760 | goto err_exit; | ||
761 | } else | ||
762 | break; | ||
763 | } | ||
764 | } | ||
765 | |||
766 | /* TBD: evaluate _STA to check if the slot is disabled */ | 742 | /* TBD: evaluate _STA to check if the slot is disabled */ |
767 | 743 | ||
768 | slot->flags &= (~SLOT_POWEREDON); | 744 | slot->flags &= (~SLOT_POWEREDON); |
@@ -782,70 +758,56 @@ static int power_off_slot(struct acpiphp_slot *slot) | |||
782 | */ | 758 | */ |
783 | static int enable_device(struct acpiphp_slot *slot) | 759 | static int enable_device(struct acpiphp_slot *slot) |
784 | { | 760 | { |
785 | u8 bus; | ||
786 | struct pci_dev *dev; | 761 | struct pci_dev *dev; |
787 | struct pci_bus *child; | 762 | struct pci_bus *bus = slot->bridge->pci_bus; |
788 | struct list_head *l; | 763 | struct list_head *l; |
789 | struct acpiphp_func *func; | 764 | struct acpiphp_func *func; |
790 | int retval = 0; | 765 | int retval = 0; |
791 | int num; | 766 | int num, max, pass; |
792 | 767 | ||
793 | if (slot->flags & SLOT_ENABLED) | 768 | if (slot->flags & SLOT_ENABLED) |
794 | goto err_exit; | 769 | goto err_exit; |
795 | 770 | ||
796 | /* sanity check: dev should be NULL when hot-plugged in */ | 771 | /* sanity check: dev should be NULL when hot-plugged in */ |
797 | dev = pci_find_slot(slot->bridge->bus, PCI_DEVFN(slot->device, 0)); | 772 | dev = pci_get_slot(bus, PCI_DEVFN(slot->device, 0)); |
798 | if (dev) { | 773 | if (dev) { |
799 | /* This case shouldn't happen */ | 774 | /* This case shouldn't happen */ |
800 | err("pci_dev structure already exists.\n"); | 775 | err("pci_dev structure already exists.\n"); |
776 | pci_dev_put(dev); | ||
801 | retval = -1; | 777 | retval = -1; |
802 | goto err_exit; | 778 | goto err_exit; |
803 | } | 779 | } |
804 | 780 | ||
805 | /* allocate resources to device */ | 781 | num = pci_scan_slot(bus, PCI_DEVFN(slot->device, 0)); |
806 | retval = acpiphp_configure_slot(slot); | 782 | if (num == 0) { |
807 | if (retval) | ||
808 | goto err_exit; | ||
809 | |||
810 | /* returned `dev' is the *first function* only! */ | ||
811 | num = pci_scan_slot(slot->bridge->pci_bus, PCI_DEVFN(slot->device, 0)); | ||
812 | if (num) | ||
813 | pci_bus_add_devices(slot->bridge->pci_bus); | ||
814 | dev = pci_find_slot(slot->bridge->bus, PCI_DEVFN(slot->device, 0)); | ||
815 | |||
816 | if (!dev) { | ||
817 | err("No new device found\n"); | 783 | err("No new device found\n"); |
818 | retval = -1; | 784 | retval = -1; |
819 | goto err_exit; | 785 | goto err_exit; |
820 | } | 786 | } |
821 | 787 | ||
822 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { | 788 | max = bus->secondary; |
823 | pci_read_config_byte(dev, PCI_SECONDARY_BUS, &bus); | 789 | for (pass = 0; pass < 2; pass++) { |
824 | child = (struct pci_bus*) pci_add_new_bus(dev->bus, dev, bus); | 790 | list_for_each_entry(dev, &bus->devices, bus_list) { |
825 | pci_do_scan_bus(child); | 791 | if (PCI_SLOT(dev->devfn) != slot->device) |
792 | continue; | ||
793 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | ||
794 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) | ||
795 | max = pci_scan_bridge(bus, dev, max, pass); | ||
796 | } | ||
826 | } | 797 | } |
827 | 798 | ||
799 | pci_bus_assign_resources(bus); | ||
800 | pci_bus_add_devices(bus); | ||
801 | |||
828 | /* associate pci_dev to our representation */ | 802 | /* associate pci_dev to our representation */ |
829 | list_for_each (l, &slot->funcs) { | 803 | list_for_each (l, &slot->funcs) { |
830 | func = list_entry(l, struct acpiphp_func, sibling); | 804 | func = list_entry(l, struct acpiphp_func, sibling); |
831 | 805 | func->pci_dev = pci_get_slot(bus, PCI_DEVFN(slot->device, | |
832 | func->pci_dev = pci_find_slot(slot->bridge->bus, | ||
833 | PCI_DEVFN(slot->device, | ||
834 | func->function)); | 806 | func->function)); |
835 | if (!func->pci_dev) | ||
836 | continue; | ||
837 | |||
838 | /* configure device */ | ||
839 | retval = acpiphp_configure_function(func); | ||
840 | if (retval) | ||
841 | goto err_exit; | ||
842 | } | 807 | } |
843 | 808 | ||
844 | slot->flags |= SLOT_ENABLED; | 809 | slot->flags |= SLOT_ENABLED; |
845 | 810 | ||
846 | dbg("Available resources:\n"); | ||
847 | acpiphp_dump_resource(slot->bridge); | ||
848 | |||
849 | err_exit: | 811 | err_exit: |
850 | return retval; | 812 | return retval; |
851 | } | 813 | } |
@@ -866,9 +828,12 @@ static int disable_device(struct acpiphp_slot *slot) | |||
866 | 828 | ||
867 | list_for_each (l, &slot->funcs) { | 829 | list_for_each (l, &slot->funcs) { |
868 | func = list_entry(l, struct acpiphp_func, sibling); | 830 | func = list_entry(l, struct acpiphp_func, sibling); |
831 | if (!func->pci_dev) | ||
832 | continue; | ||
869 | 833 | ||
870 | if (func->pci_dev) | 834 | pci_remove_bus_device(func->pci_dev); |
871 | acpiphp_unconfigure_function(func); | 835 | pci_dev_put(func->pci_dev); |
836 | func->pci_dev = NULL; | ||
872 | } | 837 | } |
873 | 838 | ||
874 | slot->flags &= (~SLOT_ENABLED); | 839 | slot->flags &= (~SLOT_ENABLED); |
@@ -920,6 +885,39 @@ static unsigned int get_slot_status(struct acpiphp_slot *slot) | |||
920 | } | 885 | } |
921 | 886 | ||
922 | /** | 887 | /** |
888 | * acpiphp_eject_slot - physically eject the slot | ||
889 | */ | ||
890 | static int acpiphp_eject_slot(struct acpiphp_slot *slot) | ||
891 | { | ||
892 | acpi_status status; | ||
893 | struct acpiphp_func *func; | ||
894 | struct list_head *l; | ||
895 | struct acpi_object_list arg_list; | ||
896 | union acpi_object arg; | ||
897 | |||
898 | list_for_each (l, &slot->funcs) { | ||
899 | func = list_entry(l, struct acpiphp_func, sibling); | ||
900 | |||
901 | /* We don't want to call _EJ0 on non-existing functions. */ | ||
902 | if ((func->flags & FUNC_HAS_EJ0)) { | ||
903 | /* _EJ0 method take one argument */ | ||
904 | arg_list.count = 1; | ||
905 | arg_list.pointer = &arg; | ||
906 | arg.type = ACPI_TYPE_INTEGER; | ||
907 | arg.integer.value = 1; | ||
908 | |||
909 | status = acpi_evaluate_object(func->handle, "_EJ0", &arg_list, NULL); | ||
910 | if (ACPI_FAILURE(status)) { | ||
911 | warn("%s: _EJ0 failed\n", __FUNCTION__); | ||
912 | return -1; | ||
913 | } else | ||
914 | break; | ||
915 | } | ||
916 | } | ||
917 | return 0; | ||
918 | } | ||
919 | |||
920 | /** | ||
923 | * acpiphp_check_bridge - re-enumerate devices | 921 | * acpiphp_check_bridge - re-enumerate devices |
924 | * | 922 | * |
925 | * Iterate over all slots under this bridge and make sure that if a | 923 | * Iterate over all slots under this bridge and make sure that if a |
@@ -942,6 +940,8 @@ static int acpiphp_check_bridge(struct acpiphp_bridge *bridge) | |||
942 | if (retval) { | 940 | if (retval) { |
943 | err("Error occurred in disabling\n"); | 941 | err("Error occurred in disabling\n"); |
944 | goto err_exit; | 942 | goto err_exit; |
943 | } else { | ||
944 | acpiphp_eject_slot(slot); | ||
945 | } | 945 | } |
946 | disabled++; | 946 | disabled++; |
947 | } else { | 947 | } else { |
@@ -962,6 +962,144 @@ static int acpiphp_check_bridge(struct acpiphp_bridge *bridge) | |||
962 | return retval; | 962 | return retval; |
963 | } | 963 | } |
964 | 964 | ||
965 | static void program_hpp(struct pci_dev *dev, struct acpiphp_bridge *bridge) | ||
966 | { | ||
967 | u16 pci_cmd, pci_bctl; | ||
968 | struct pci_dev *cdev; | ||
969 | |||
970 | /* Program hpp values for this device */ | ||
971 | if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL || | ||
972 | (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE && | ||
973 | (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI))) | ||
974 | return; | ||
975 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, | ||
976 | bridge->hpp.cache_line_size); | ||
977 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, | ||
978 | bridge->hpp.latency_timer); | ||
979 | pci_read_config_word(dev, PCI_COMMAND, &pci_cmd); | ||
980 | if (bridge->hpp.enable_SERR) | ||
981 | pci_cmd |= PCI_COMMAND_SERR; | ||
982 | else | ||
983 | pci_cmd &= ~PCI_COMMAND_SERR; | ||
984 | if (bridge->hpp.enable_PERR) | ||
985 | pci_cmd |= PCI_COMMAND_PARITY; | ||
986 | else | ||
987 | pci_cmd &= ~PCI_COMMAND_PARITY; | ||
988 | pci_write_config_word(dev, PCI_COMMAND, pci_cmd); | ||
989 | |||
990 | /* Program bridge control value and child devices */ | ||
991 | if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) { | ||
992 | pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, | ||
993 | bridge->hpp.latency_timer); | ||
994 | pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl); | ||
995 | if (bridge->hpp.enable_SERR) | ||
996 | pci_bctl |= PCI_BRIDGE_CTL_SERR; | ||
997 | else | ||
998 | pci_bctl &= ~PCI_BRIDGE_CTL_SERR; | ||
999 | if (bridge->hpp.enable_PERR) | ||
1000 | pci_bctl |= PCI_BRIDGE_CTL_PARITY; | ||
1001 | else | ||
1002 | pci_bctl &= ~PCI_BRIDGE_CTL_PARITY; | ||
1003 | pci_write_config_word(dev, PCI_BRIDGE_CONTROL, pci_bctl); | ||
1004 | if (dev->subordinate) { | ||
1005 | list_for_each_entry(cdev, &dev->subordinate->devices, | ||
1006 | bus_list) | ||
1007 | program_hpp(cdev, bridge); | ||
1008 | } | ||
1009 | } | ||
1010 | } | ||
1011 | |||
1012 | static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus) | ||
1013 | { | ||
1014 | struct acpiphp_bridge bridge; | ||
1015 | struct pci_dev *dev; | ||
1016 | |||
1017 | memset(&bridge, 0, sizeof(bridge)); | ||
1018 | bridge.handle = handle; | ||
1019 | decode_hpp(&bridge); | ||
1020 | list_for_each_entry(dev, &bus->devices, bus_list) | ||
1021 | program_hpp(dev, &bridge); | ||
1022 | |||
1023 | } | ||
1024 | |||
1025 | /* | ||
1026 | * Remove devices for which we could not assign resources, call | ||
1027 | * arch specific code to fix-up the bus | ||
1028 | */ | ||
1029 | static void acpiphp_sanitize_bus(struct pci_bus *bus) | ||
1030 | { | ||
1031 | struct pci_dev *dev; | ||
1032 | int i; | ||
1033 | unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM; | ||
1034 | |||
1035 | list_for_each_entry(dev, &bus->devices, bus_list) { | ||
1036 | for (i=0; i<PCI_BRIDGE_RESOURCES; i++) { | ||
1037 | struct resource *res = &dev->resource[i]; | ||
1038 | if ((res->flags & type_mask) && !res->start && | ||
1039 | res->end) { | ||
1040 | /* Could not assign a required resources | ||
1041 | * for this device, remove it */ | ||
1042 | pci_remove_bus_device(dev); | ||
1043 | break; | ||
1044 | } | ||
1045 | } | ||
1046 | } | ||
1047 | } | ||
1048 | |||
1049 | /* Program resources in newly inserted bridge */ | ||
1050 | static int acpiphp_configure_bridge (acpi_handle handle) | ||
1051 | { | ||
1052 | struct acpi_pci_id pci_id; | ||
1053 | struct pci_bus *bus; | ||
1054 | |||
1055 | if (ACPI_FAILURE(acpi_get_pci_id(handle, &pci_id))) { | ||
1056 | err("cannot get PCI domain and bus number for bridge\n"); | ||
1057 | return -EINVAL; | ||
1058 | } | ||
1059 | bus = pci_find_bus(pci_id.segment, pci_id.bus); | ||
1060 | if (!bus) { | ||
1061 | err("cannot find bus %d:%d\n", | ||
1062 | pci_id.segment, pci_id.bus); | ||
1063 | return -EINVAL; | ||
1064 | } | ||
1065 | |||
1066 | pci_bus_size_bridges(bus); | ||
1067 | pci_bus_assign_resources(bus); | ||
1068 | acpiphp_sanitize_bus(bus); | ||
1069 | acpiphp_set_hpp_values(handle, bus); | ||
1070 | pci_enable_bridges(bus); | ||
1071 | acpiphp_configure_ioapics(handle); | ||
1072 | return 0; | ||
1073 | } | ||
1074 | |||
1075 | static void handle_bridge_insertion(acpi_handle handle, u32 type) | ||
1076 | { | ||
1077 | struct acpi_device *device, *pdevice; | ||
1078 | acpi_handle phandle; | ||
1079 | |||
1080 | if ((type != ACPI_NOTIFY_BUS_CHECK) && | ||
1081 | (type != ACPI_NOTIFY_DEVICE_CHECK)) { | ||
1082 | err("unexpected notification type %d\n", type); | ||
1083 | return; | ||
1084 | } | ||
1085 | |||
1086 | acpi_get_parent(handle, &phandle); | ||
1087 | if (acpi_bus_get_device(phandle, &pdevice)) { | ||
1088 | dbg("no parent device, assuming NULL\n"); | ||
1089 | pdevice = NULL; | ||
1090 | } | ||
1091 | if (acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE)) { | ||
1092 | err("cannot add bridge to acpi list\n"); | ||
1093 | return; | ||
1094 | } | ||
1095 | if (!acpiphp_configure_bridge(handle) && | ||
1096 | !acpi_bus_start(device)) | ||
1097 | add_bridge(handle); | ||
1098 | else | ||
1099 | err("cannot configure and start bridge\n"); | ||
1100 | |||
1101 | } | ||
1102 | |||
965 | /* | 1103 | /* |
966 | * ACPI event handlers | 1104 | * ACPI event handlers |
967 | */ | 1105 | */ |
@@ -982,8 +1120,19 @@ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, void *cont | |||
982 | char objname[64]; | 1120 | char objname[64]; |
983 | struct acpi_buffer buffer = { .length = sizeof(objname), | 1121 | struct acpi_buffer buffer = { .length = sizeof(objname), |
984 | .pointer = objname }; | 1122 | .pointer = objname }; |
1123 | struct acpi_device *device; | ||
985 | 1124 | ||
986 | bridge = (struct acpiphp_bridge *)context; | 1125 | if (acpi_bus_get_device(handle, &device)) { |
1126 | /* This bridge must have just been physically inserted */ | ||
1127 | handle_bridge_insertion(handle, type); | ||
1128 | return; | ||
1129 | } | ||
1130 | |||
1131 | bridge = acpiphp_handle_to_bridge(handle); | ||
1132 | if (!bridge) { | ||
1133 | err("cannot get bridge info\n"); | ||
1134 | return; | ||
1135 | } | ||
987 | 1136 | ||
988 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | 1137 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); |
989 | 1138 | ||
@@ -1031,7 +1180,6 @@ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, void *cont | |||
1031 | } | 1180 | } |
1032 | } | 1181 | } |
1033 | 1182 | ||
1034 | |||
1035 | /** | 1183 | /** |
1036 | * handle_hotplug_event_func - handle ACPI event on functions (i.e. slots) | 1184 | * handle_hotplug_event_func - handle ACPI event on functions (i.e. slots) |
1037 | * | 1185 | * |
@@ -1074,7 +1222,8 @@ static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *contex | |||
1074 | case ACPI_NOTIFY_EJECT_REQUEST: | 1222 | case ACPI_NOTIFY_EJECT_REQUEST: |
1075 | /* request device eject */ | 1223 | /* request device eject */ |
1076 | dbg("%s: Device eject notify on %s\n", __FUNCTION__, objname); | 1224 | dbg("%s: Device eject notify on %s\n", __FUNCTION__, objname); |
1077 | acpiphp_disable_slot(func->slot); | 1225 | if (!(acpiphp_disable_slot(func->slot))) |
1226 | acpiphp_eject_slot(func->slot); | ||
1078 | break; | 1227 | break; |
1079 | 1228 | ||
1080 | default: | 1229 | default: |
@@ -1083,6 +1232,47 @@ static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *contex | |||
1083 | } | 1232 | } |
1084 | } | 1233 | } |
1085 | 1234 | ||
1235 | static int is_root_bridge(acpi_handle handle) | ||
1236 | { | ||
1237 | acpi_status status; | ||
1238 | struct acpi_device_info *info; | ||
1239 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
1240 | int i; | ||
1241 | |||
1242 | status = acpi_get_object_info(handle, &buffer); | ||
1243 | if (ACPI_SUCCESS(status)) { | ||
1244 | info = buffer.pointer; | ||
1245 | if ((info->valid & ACPI_VALID_HID) && | ||
1246 | !strcmp(PCI_ROOT_HID_STRING, | ||
1247 | info->hardware_id.value)) { | ||
1248 | acpi_os_free(buffer.pointer); | ||
1249 | return 1; | ||
1250 | } | ||
1251 | if (info->valid & ACPI_VALID_CID) { | ||
1252 | for (i=0; i < info->compatibility_id.count; i++) { | ||
1253 | if (!strcmp(PCI_ROOT_HID_STRING, | ||
1254 | info->compatibility_id.id[i].value)) { | ||
1255 | acpi_os_free(buffer.pointer); | ||
1256 | return 1; | ||
1257 | } | ||
1258 | } | ||
1259 | } | ||
1260 | } | ||
1261 | return 0; | ||
1262 | } | ||
1263 | |||
1264 | static acpi_status | ||
1265 | find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
1266 | { | ||
1267 | int *count = (int *)context; | ||
1268 | |||
1269 | if (is_root_bridge(handle)) { | ||
1270 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
1271 | handle_hotplug_event_bridge, NULL); | ||
1272 | (*count)++; | ||
1273 | } | ||
1274 | return AE_OK ; | ||
1275 | } | ||
1086 | 1276 | ||
1087 | static struct acpi_pci_driver acpi_pci_hp_driver = { | 1277 | static struct acpi_pci_driver acpi_pci_hp_driver = { |
1088 | .add = add_bridge, | 1278 | .add = add_bridge, |
@@ -1095,15 +1285,15 @@ static struct acpi_pci_driver acpi_pci_hp_driver = { | |||
1095 | */ | 1285 | */ |
1096 | int __init acpiphp_glue_init(void) | 1286 | int __init acpiphp_glue_init(void) |
1097 | { | 1287 | { |
1098 | int num; | 1288 | int num = 0; |
1099 | |||
1100 | if (list_empty(&pci_root_buses)) | ||
1101 | return -1; | ||
1102 | 1289 | ||
1103 | num = acpi_pci_register_driver(&acpi_pci_hp_driver); | 1290 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, |
1291 | ACPI_UINT32_MAX, find_root_bridges, &num, NULL); | ||
1104 | 1292 | ||
1105 | if (num <= 0) | 1293 | if (num <= 0) |
1106 | return -1; | 1294 | return -1; |
1295 | else | ||
1296 | acpi_pci_register_driver(&acpi_pci_hp_driver); | ||
1107 | 1297 | ||
1108 | return 0; | 1298 | return 0; |
1109 | } | 1299 | } |
@@ -1116,46 +1306,6 @@ int __init acpiphp_glue_init(void) | |||
1116 | */ | 1306 | */ |
1117 | void __exit acpiphp_glue_exit(void) | 1307 | void __exit acpiphp_glue_exit(void) |
1118 | { | 1308 | { |
1119 | struct list_head *l1, *l2, *n1, *n2; | ||
1120 | struct acpiphp_bridge *bridge; | ||
1121 | struct acpiphp_slot *slot, *next; | ||
1122 | struct acpiphp_func *func; | ||
1123 | acpi_status status; | ||
1124 | |||
1125 | list_for_each_safe (l1, n1, &bridge_list) { | ||
1126 | bridge = (struct acpiphp_bridge *)l1; | ||
1127 | slot = bridge->slots; | ||
1128 | while (slot) { | ||
1129 | next = slot->next; | ||
1130 | list_for_each_safe (l2, n2, &slot->funcs) { | ||
1131 | func = list_entry(l2, struct acpiphp_func, sibling); | ||
1132 | acpiphp_free_resource(&func->io_head); | ||
1133 | acpiphp_free_resource(&func->mem_head); | ||
1134 | acpiphp_free_resource(&func->p_mem_head); | ||
1135 | acpiphp_free_resource(&func->bus_head); | ||
1136 | status = acpi_remove_notify_handler(func->handle, | ||
1137 | ACPI_SYSTEM_NOTIFY, | ||
1138 | handle_hotplug_event_func); | ||
1139 | if (ACPI_FAILURE(status)) | ||
1140 | err("failed to remove notify handler\n"); | ||
1141 | kfree(func); | ||
1142 | } | ||
1143 | kfree(slot); | ||
1144 | slot = next; | ||
1145 | } | ||
1146 | status = acpi_remove_notify_handler(bridge->handle, ACPI_SYSTEM_NOTIFY, | ||
1147 | handle_hotplug_event_bridge); | ||
1148 | if (ACPI_FAILURE(status)) | ||
1149 | err("failed to remove notify handler\n"); | ||
1150 | |||
1151 | acpiphp_free_resource(&bridge->io_head); | ||
1152 | acpiphp_free_resource(&bridge->mem_head); | ||
1153 | acpiphp_free_resource(&bridge->p_mem_head); | ||
1154 | acpiphp_free_resource(&bridge->bus_head); | ||
1155 | |||
1156 | kfree(bridge); | ||
1157 | } | ||
1158 | |||
1159 | acpi_pci_unregister_driver(&acpi_pci_hp_driver); | 1309 | acpi_pci_unregister_driver(&acpi_pci_hp_driver); |
1160 | } | 1310 | } |
1161 | 1311 | ||
@@ -1173,11 +1323,14 @@ int __init acpiphp_get_num_slots(void) | |||
1173 | 1323 | ||
1174 | list_for_each (node, &bridge_list) { | 1324 | list_for_each (node, &bridge_list) { |
1175 | bridge = (struct acpiphp_bridge *)node; | 1325 | bridge = (struct acpiphp_bridge *)node; |
1176 | dbg("Bus%d %dslot(s)\n", bridge->bus, bridge->nr_slots); | 1326 | dbg("Bus %04x:%02x has %d slot%s\n", |
1327 | pci_domain_nr(bridge->pci_bus), | ||
1328 | bridge->pci_bus->number, bridge->nr_slots, | ||
1329 | bridge->nr_slots == 1 ? "" : "s"); | ||
1177 | num_slots += bridge->nr_slots; | 1330 | num_slots += bridge->nr_slots; |
1178 | } | 1331 | } |
1179 | 1332 | ||
1180 | dbg("Total %dslots\n", num_slots); | 1333 | dbg("Total %d slots\n", num_slots); |
1181 | return num_slots; | 1334 | return num_slots; |
1182 | } | 1335 | } |
1183 | 1336 | ||
@@ -1254,7 +1407,6 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot) | |||
1254 | return retval; | 1407 | return retval; |
1255 | } | 1408 | } |
1256 | 1409 | ||
1257 | |||
1258 | /** | 1410 | /** |
1259 | * acpiphp_disable_slot - power off slot | 1411 | * acpiphp_disable_slot - power off slot |
1260 | */ | 1412 | */ |
@@ -1274,13 +1426,6 @@ int acpiphp_disable_slot(struct acpiphp_slot *slot) | |||
1274 | if (retval) | 1426 | if (retval) |
1275 | goto err_exit; | 1427 | goto err_exit; |
1276 | 1428 | ||
1277 | acpiphp_resource_sort_and_combine(&slot->bridge->io_head); | ||
1278 | acpiphp_resource_sort_and_combine(&slot->bridge->mem_head); | ||
1279 | acpiphp_resource_sort_and_combine(&slot->bridge->p_mem_head); | ||
1280 | acpiphp_resource_sort_and_combine(&slot->bridge->bus_head); | ||
1281 | dbg("Available resources:\n"); | ||
1282 | acpiphp_dump_resource(slot->bridge); | ||
1283 | |||
1284 | err_exit: | 1429 | err_exit: |
1285 | up(&slot->crit_sect); | 1430 | up(&slot->crit_sect); |
1286 | return retval; | 1431 | return retval; |
@@ -1293,11 +1438,7 @@ int acpiphp_disable_slot(struct acpiphp_slot *slot) | |||
1293 | */ | 1438 | */ |
1294 | u8 acpiphp_get_power_status(struct acpiphp_slot *slot) | 1439 | u8 acpiphp_get_power_status(struct acpiphp_slot *slot) |
1295 | { | 1440 | { |
1296 | unsigned int sta; | 1441 | return (slot->flags & SLOT_POWEREDON); |
1297 | |||
1298 | sta = get_slot_status(slot); | ||
1299 | |||
1300 | return (sta & ACPI_STA_ENABLED) ? 1 : 0; | ||
1301 | } | 1442 | } |
1302 | 1443 | ||
1303 | 1444 | ||
@@ -1335,9 +1476,10 @@ u8 acpiphp_get_adapter_status(struct acpiphp_slot *slot) | |||
1335 | u32 acpiphp_get_address(struct acpiphp_slot *slot) | 1476 | u32 acpiphp_get_address(struct acpiphp_slot *slot) |
1336 | { | 1477 | { |
1337 | u32 address; | 1478 | u32 address; |
1479 | struct pci_bus *pci_bus = slot->bridge->pci_bus; | ||
1338 | 1480 | ||
1339 | address = ((slot->bridge->seg) << 16) | | 1481 | address = (pci_domain_nr(pci_bus) << 16) | |
1340 | ((slot->bridge->bus) << 8) | | 1482 | (pci_bus->number << 8) | |
1341 | slot->device; | 1483 | slot->device; |
1342 | 1484 | ||
1343 | return address; | 1485 | return address; |
diff --git a/drivers/pci/hotplug/acpiphp_pci.c b/drivers/pci/hotplug/acpiphp_pci.c deleted file mode 100644 index 54d97c9d1dff..000000000000 --- a/drivers/pci/hotplug/acpiphp_pci.c +++ /dev/null | |||
@@ -1,449 +0,0 @@ | |||
1 | /* | ||
2 | * ACPI PCI HotPlug PCI configuration space management | ||
3 | * | ||
4 | * Copyright (C) 1995,2001 Compaq Computer Corporation | ||
5 | * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) | ||
6 | * Copyright (C) 2001,2002 IBM Corp. | ||
7 | * Copyright (C) 2002 Takayoshi Kochi (t-kochi@bq.jp.nec.com) | ||
8 | * Copyright (C) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com) | ||
9 | * Copyright (C) 2002 NEC Corporation | ||
10 | * | ||
11 | * All rights reserved. | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License as published by | ||
15 | * the Free Software Foundation; either version 2 of the License, or (at | ||
16 | * your option) any later version. | ||
17 | * | ||
18 | * This program is distributed in the hope that it will be useful, but | ||
19 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
21 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
22 | * details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
27 | * | ||
28 | * Send feedback to <t-kochi@bq.jp.nec.com> | ||
29 | * | ||
30 | */ | ||
31 | |||
32 | #include <linux/init.h> | ||
33 | #include <linux/module.h> | ||
34 | |||
35 | #include <linux/kernel.h> | ||
36 | #include <linux/pci.h> | ||
37 | #include <linux/acpi.h> | ||
38 | #include "../pci.h" | ||
39 | #include "pci_hotplug.h" | ||
40 | #include "acpiphp.h" | ||
41 | |||
42 | #define MY_NAME "acpiphp_pci" | ||
43 | |||
44 | |||
45 | /* allocate mem/pmem/io resource to a new function */ | ||
46 | static int init_config_space (struct acpiphp_func *func) | ||
47 | { | ||
48 | u32 bar, len; | ||
49 | u32 address[] = { | ||
50 | PCI_BASE_ADDRESS_0, | ||
51 | PCI_BASE_ADDRESS_1, | ||
52 | PCI_BASE_ADDRESS_2, | ||
53 | PCI_BASE_ADDRESS_3, | ||
54 | PCI_BASE_ADDRESS_4, | ||
55 | PCI_BASE_ADDRESS_5, | ||
56 | 0 | ||
57 | }; | ||
58 | int count; | ||
59 | struct acpiphp_bridge *bridge; | ||
60 | struct pci_resource *res; | ||
61 | struct pci_bus *pbus; | ||
62 | int bus, device, function; | ||
63 | unsigned int devfn; | ||
64 | u16 tmp; | ||
65 | |||
66 | bridge = func->slot->bridge; | ||
67 | pbus = bridge->pci_bus; | ||
68 | bus = bridge->bus; | ||
69 | device = func->slot->device; | ||
70 | function = func->function; | ||
71 | devfn = PCI_DEVFN(device, function); | ||
72 | |||
73 | for (count = 0; address[count]; count++) { /* for 6 BARs */ | ||
74 | pci_bus_write_config_dword(pbus, devfn, | ||
75 | address[count], 0xFFFFFFFF); | ||
76 | pci_bus_read_config_dword(pbus, devfn, address[count], &bar); | ||
77 | |||
78 | if (!bar) /* This BAR is not implemented */ | ||
79 | continue; | ||
80 | |||
81 | dbg("Device %02x.%02x BAR %d wants %x\n", device, function, count, bar); | ||
82 | |||
83 | if (bar & PCI_BASE_ADDRESS_SPACE_IO) { | ||
84 | /* This is IO */ | ||
85 | |||
86 | len = bar & (PCI_BASE_ADDRESS_IO_MASK & 0xFFFF); | ||
87 | len = len & ~(len - 1); | ||
88 | |||
89 | dbg("len in IO %x, BAR %d\n", len, count); | ||
90 | |||
91 | spin_lock(&bridge->res_lock); | ||
92 | res = acpiphp_get_io_resource(&bridge->io_head, len); | ||
93 | spin_unlock(&bridge->res_lock); | ||
94 | |||
95 | if (!res) { | ||
96 | err("cannot allocate requested io for %02x:%02x.%d len %x\n", | ||
97 | bus, device, function, len); | ||
98 | return -1; | ||
99 | } | ||
100 | pci_bus_write_config_dword(pbus, devfn, | ||
101 | address[count], | ||
102 | (u32)res->base); | ||
103 | res->next = func->io_head; | ||
104 | func->io_head = res; | ||
105 | |||
106 | } else { | ||
107 | /* This is Memory */ | ||
108 | if (bar & PCI_BASE_ADDRESS_MEM_PREFETCH) { | ||
109 | /* pfmem */ | ||
110 | |||
111 | len = bar & 0xFFFFFFF0; | ||
112 | len = ~len + 1; | ||
113 | |||
114 | dbg("len in PFMEM %x, BAR %d\n", len, count); | ||
115 | |||
116 | spin_lock(&bridge->res_lock); | ||
117 | res = acpiphp_get_resource(&bridge->p_mem_head, len); | ||
118 | spin_unlock(&bridge->res_lock); | ||
119 | |||
120 | if (!res) { | ||
121 | err("cannot allocate requested pfmem for %02x:%02x.%d len %x\n", | ||
122 | bus, device, function, len); | ||
123 | return -1; | ||
124 | } | ||
125 | |||
126 | pci_bus_write_config_dword(pbus, devfn, | ||
127 | address[count], | ||
128 | (u32)res->base); | ||
129 | |||
130 | if (bar & PCI_BASE_ADDRESS_MEM_TYPE_64) { /* takes up another dword */ | ||
131 | dbg("inside the pfmem 64 case, count %d\n", count); | ||
132 | count += 1; | ||
133 | pci_bus_write_config_dword(pbus, devfn, | ||
134 | address[count], | ||
135 | (u32)(res->base >> 32)); | ||
136 | } | ||
137 | |||
138 | res->next = func->p_mem_head; | ||
139 | func->p_mem_head = res; | ||
140 | |||
141 | } else { | ||
142 | /* regular memory */ | ||
143 | |||
144 | len = bar & 0xFFFFFFF0; | ||
145 | len = ~len + 1; | ||
146 | |||
147 | dbg("len in MEM %x, BAR %d\n", len, count); | ||
148 | |||
149 | spin_lock(&bridge->res_lock); | ||
150 | res = acpiphp_get_resource(&bridge->mem_head, len); | ||
151 | spin_unlock(&bridge->res_lock); | ||
152 | |||
153 | if (!res) { | ||
154 | err("cannot allocate requested pfmem for %02x:%02x.%d len %x\n", | ||
155 | bus, device, function, len); | ||
156 | return -1; | ||
157 | } | ||
158 | |||
159 | pci_bus_write_config_dword(pbus, devfn, | ||
160 | address[count], | ||
161 | (u32)res->base); | ||
162 | |||
163 | if (bar & PCI_BASE_ADDRESS_MEM_TYPE_64) { | ||
164 | /* takes up another dword */ | ||
165 | dbg("inside mem 64 case, reg. mem, count %d\n", count); | ||
166 | count += 1; | ||
167 | pci_bus_write_config_dword(pbus, devfn, | ||
168 | address[count], | ||
169 | (u32)(res->base >> 32)); | ||
170 | } | ||
171 | |||
172 | res->next = func->mem_head; | ||
173 | func->mem_head = res; | ||
174 | |||
175 | } | ||
176 | } | ||
177 | } | ||
178 | |||
179 | /* disable expansion rom */ | ||
180 | pci_bus_write_config_dword(pbus, devfn, PCI_ROM_ADDRESS, 0x00000000); | ||
181 | |||
182 | /* set PCI parameters from _HPP */ | ||
183 | pci_bus_write_config_byte(pbus, devfn, PCI_CACHE_LINE_SIZE, | ||
184 | bridge->hpp.cache_line_size); | ||
185 | pci_bus_write_config_byte(pbus, devfn, PCI_LATENCY_TIMER, | ||
186 | bridge->hpp.latency_timer); | ||
187 | |||
188 | pci_bus_read_config_word(pbus, devfn, PCI_COMMAND, &tmp); | ||
189 | if (bridge->hpp.enable_SERR) | ||
190 | tmp |= PCI_COMMAND_SERR; | ||
191 | if (bridge->hpp.enable_PERR) | ||
192 | tmp |= PCI_COMMAND_PARITY; | ||
193 | pci_bus_write_config_word(pbus, devfn, PCI_COMMAND, tmp); | ||
194 | |||
195 | return 0; | ||
196 | } | ||
197 | |||
198 | /* detect_used_resource - subtract resource under dev from bridge */ | ||
199 | static int detect_used_resource (struct acpiphp_bridge *bridge, struct pci_dev *dev) | ||
200 | { | ||
201 | int count; | ||
202 | |||
203 | dbg("Device %s\n", pci_name(dev)); | ||
204 | |||
205 | for (count = 0; count < DEVICE_COUNT_RESOURCE; count++) { | ||
206 | struct pci_resource *res; | ||
207 | struct pci_resource **head; | ||
208 | unsigned long base = dev->resource[count].start; | ||
209 | unsigned long len = dev->resource[count].end - base + 1; | ||
210 | unsigned long flags = dev->resource[count].flags; | ||
211 | |||
212 | if (!flags) | ||
213 | continue; | ||
214 | |||
215 | dbg("BAR[%d] 0x%lx - 0x%lx (0x%lx)\n", count, base, | ||
216 | base + len - 1, flags); | ||
217 | |||
218 | if (flags & IORESOURCE_IO) { | ||
219 | head = &bridge->io_head; | ||
220 | } else if (flags & IORESOURCE_PREFETCH) { | ||
221 | head = &bridge->p_mem_head; | ||
222 | } else { | ||
223 | head = &bridge->mem_head; | ||
224 | } | ||
225 | |||
226 | spin_lock(&bridge->res_lock); | ||
227 | res = acpiphp_get_resource_with_base(head, base, len); | ||
228 | spin_unlock(&bridge->res_lock); | ||
229 | if (res) | ||
230 | kfree(res); | ||
231 | } | ||
232 | |||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | |||
237 | /** | ||
238 | * acpiphp_detect_pci_resource - detect resources under bridge | ||
239 | * @bridge: detect all resources already used under this bridge | ||
240 | * | ||
241 | * collect all resources already allocated for all devices under a bridge. | ||
242 | */ | ||
243 | int acpiphp_detect_pci_resource (struct acpiphp_bridge *bridge) | ||
244 | { | ||
245 | struct list_head *l; | ||
246 | struct pci_dev *dev; | ||
247 | |||
248 | list_for_each (l, &bridge->pci_bus->devices) { | ||
249 | dev = pci_dev_b(l); | ||
250 | detect_used_resource(bridge, dev); | ||
251 | } | ||
252 | |||
253 | return 0; | ||
254 | } | ||
255 | |||
256 | |||
257 | /** | ||
258 | * acpiphp_init_slot_resource - gather resource usage information of a slot | ||
259 | * @slot: ACPI slot object to be checked, should have valid pci_dev member | ||
260 | * | ||
261 | * TBD: PCI-to-PCI bridge case | ||
262 | * use pci_dev->resource[] | ||
263 | */ | ||
264 | int acpiphp_init_func_resource (struct acpiphp_func *func) | ||
265 | { | ||
266 | u64 base; | ||
267 | u32 bar, len; | ||
268 | u32 address[] = { | ||
269 | PCI_BASE_ADDRESS_0, | ||
270 | PCI_BASE_ADDRESS_1, | ||
271 | PCI_BASE_ADDRESS_2, | ||
272 | PCI_BASE_ADDRESS_3, | ||
273 | PCI_BASE_ADDRESS_4, | ||
274 | PCI_BASE_ADDRESS_5, | ||
275 | 0 | ||
276 | }; | ||
277 | int count; | ||
278 | struct pci_resource *res; | ||
279 | struct pci_dev *dev; | ||
280 | |||
281 | dev = func->pci_dev; | ||
282 | dbg("Hot-pluggable device %s\n", pci_name(dev)); | ||
283 | |||
284 | for (count = 0; address[count]; count++) { /* for 6 BARs */ | ||
285 | pci_read_config_dword(dev, address[count], &bar); | ||
286 | |||
287 | if (!bar) /* This BAR is not implemented */ | ||
288 | continue; | ||
289 | |||
290 | pci_write_config_dword(dev, address[count], 0xFFFFFFFF); | ||
291 | pci_read_config_dword(dev, address[count], &len); | ||
292 | |||
293 | if (len & PCI_BASE_ADDRESS_SPACE_IO) { | ||
294 | /* This is IO */ | ||
295 | base = bar & 0xFFFFFFFC; | ||
296 | len = len & (PCI_BASE_ADDRESS_IO_MASK & 0xFFFF); | ||
297 | len = len & ~(len - 1); | ||
298 | |||
299 | dbg("BAR[%d] %08x - %08x (IO)\n", count, (u32)base, (u32)base + len - 1); | ||
300 | |||
301 | res = acpiphp_make_resource(base, len); | ||
302 | if (!res) | ||
303 | goto no_memory; | ||
304 | |||
305 | res->next = func->io_head; | ||
306 | func->io_head = res; | ||
307 | |||
308 | } else { | ||
309 | /* This is Memory */ | ||
310 | base = bar & 0xFFFFFFF0; | ||
311 | if (len & PCI_BASE_ADDRESS_MEM_PREFETCH) { | ||
312 | /* pfmem */ | ||
313 | |||
314 | len &= 0xFFFFFFF0; | ||
315 | len = ~len + 1; | ||
316 | |||
317 | if (len & PCI_BASE_ADDRESS_MEM_TYPE_64) { /* takes up another dword */ | ||
318 | dbg("prefetch mem 64\n"); | ||
319 | count += 1; | ||
320 | } | ||
321 | dbg("BAR[%d] %08x - %08x (PMEM)\n", count, (u32)base, (u32)base + len - 1); | ||
322 | res = acpiphp_make_resource(base, len); | ||
323 | if (!res) | ||
324 | goto no_memory; | ||
325 | |||
326 | res->next = func->p_mem_head; | ||
327 | func->p_mem_head = res; | ||
328 | |||
329 | } else { | ||
330 | /* regular memory */ | ||
331 | |||
332 | len &= 0xFFFFFFF0; | ||
333 | len = ~len + 1; | ||
334 | |||
335 | if (len & PCI_BASE_ADDRESS_MEM_TYPE_64) { | ||
336 | /* takes up another dword */ | ||
337 | dbg("mem 64\n"); | ||
338 | count += 1; | ||
339 | } | ||
340 | dbg("BAR[%d] %08x - %08x (MEM)\n", count, (u32)base, (u32)base + len - 1); | ||
341 | res = acpiphp_make_resource(base, len); | ||
342 | if (!res) | ||
343 | goto no_memory; | ||
344 | |||
345 | res->next = func->mem_head; | ||
346 | func->mem_head = res; | ||
347 | |||
348 | } | ||
349 | } | ||
350 | |||
351 | pci_write_config_dword(dev, address[count], bar); | ||
352 | } | ||
353 | #if 1 | ||
354 | acpiphp_dump_func_resource(func); | ||
355 | #endif | ||
356 | |||
357 | return 0; | ||
358 | |||
359 | no_memory: | ||
360 | err("out of memory\n"); | ||
361 | acpiphp_free_resource(&func->io_head); | ||
362 | acpiphp_free_resource(&func->mem_head); | ||
363 | acpiphp_free_resource(&func->p_mem_head); | ||
364 | |||
365 | return -1; | ||
366 | } | ||
367 | |||
368 | |||
369 | /** | ||
370 | * acpiphp_configure_slot - allocate PCI resources | ||
371 | * @slot: slot to be configured | ||
372 | * | ||
373 | * initializes a PCI functions on a device inserted | ||
374 | * into the slot | ||
375 | * | ||
376 | */ | ||
377 | int acpiphp_configure_slot (struct acpiphp_slot *slot) | ||
378 | { | ||
379 | struct acpiphp_func *func; | ||
380 | struct list_head *l; | ||
381 | u8 hdr; | ||
382 | u32 dvid; | ||
383 | int retval = 0; | ||
384 | int is_multi = 0; | ||
385 | |||
386 | pci_bus_read_config_byte(slot->bridge->pci_bus, | ||
387 | PCI_DEVFN(slot->device, 0), | ||
388 | PCI_HEADER_TYPE, &hdr); | ||
389 | |||
390 | if (hdr & 0x80) | ||
391 | is_multi = 1; | ||
392 | |||
393 | list_for_each (l, &slot->funcs) { | ||
394 | func = list_entry(l, struct acpiphp_func, sibling); | ||
395 | if (is_multi || func->function == 0) { | ||
396 | pci_bus_read_config_dword(slot->bridge->pci_bus, | ||
397 | PCI_DEVFN(slot->device, | ||
398 | func->function), | ||
399 | PCI_VENDOR_ID, &dvid); | ||
400 | if (dvid != 0xffffffff) { | ||
401 | retval = init_config_space(func); | ||
402 | if (retval) | ||
403 | break; | ||
404 | } | ||
405 | } | ||
406 | } | ||
407 | |||
408 | return retval; | ||
409 | } | ||
410 | |||
411 | /** | ||
412 | * acpiphp_configure_function - configure PCI function | ||
413 | * @func: function to be configured | ||
414 | * | ||
415 | * initializes a PCI functions on a device inserted | ||
416 | * into the slot | ||
417 | * | ||
418 | */ | ||
419 | int acpiphp_configure_function (struct acpiphp_func *func) | ||
420 | { | ||
421 | /* all handled by the pci core now */ | ||
422 | return 0; | ||
423 | } | ||
424 | |||
425 | /** | ||
426 | * acpiphp_unconfigure_function - unconfigure PCI function | ||
427 | * @func: function to be unconfigured | ||
428 | * | ||
429 | */ | ||
430 | void acpiphp_unconfigure_function (struct acpiphp_func *func) | ||
431 | { | ||
432 | struct acpiphp_bridge *bridge; | ||
433 | |||
434 | /* if pci_dev is NULL, ignore it */ | ||
435 | if (!func->pci_dev) | ||
436 | return; | ||
437 | |||
438 | pci_remove_bus_device(func->pci_dev); | ||
439 | |||
440 | /* free all resources */ | ||
441 | bridge = func->slot->bridge; | ||
442 | |||
443 | spin_lock(&bridge->res_lock); | ||
444 | acpiphp_move_resource(&func->io_head, &bridge->io_head); | ||
445 | acpiphp_move_resource(&func->mem_head, &bridge->mem_head); | ||
446 | acpiphp_move_resource(&func->p_mem_head, &bridge->p_mem_head); | ||
447 | acpiphp_move_resource(&func->bus_head, &bridge->bus_head); | ||
448 | spin_unlock(&bridge->res_lock); | ||
449 | } | ||
diff --git a/drivers/pci/hotplug/acpiphp_res.c b/drivers/pci/hotplug/acpiphp_res.c deleted file mode 100644 index f54b1fa7b75a..000000000000 --- a/drivers/pci/hotplug/acpiphp_res.c +++ /dev/null | |||
@@ -1,700 +0,0 @@ | |||
1 | /* | ||
2 | * ACPI PCI HotPlug Utility functions | ||
3 | * | ||
4 | * Copyright (C) 1995,2001 Compaq Computer Corporation | ||
5 | * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) | ||
6 | * Copyright (C) 2001 IBM Corp. | ||
7 | * Copyright (C) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com) | ||
8 | * Copyright (C) 2002 Takayoshi Kochi (t-kochi@bq.jp.nec.com) | ||
9 | * Copyright (C) 2002 NEC Corporation | ||
10 | * | ||
11 | * All rights reserved. | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License as published by | ||
15 | * the Free Software Foundation; either version 2 of the License, or (at | ||
16 | * your option) any later version. | ||
17 | * | ||
18 | * This program is distributed in the hope that it will be useful, but | ||
19 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
21 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
22 | * details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
27 | * | ||
28 | * Send feedback to <gregkh@us.ibm.com>, <t-kochi@bq.jp.nec.com> | ||
29 | * | ||
30 | */ | ||
31 | |||
32 | #include <linux/init.h> | ||
33 | #include <linux/module.h> | ||
34 | |||
35 | #include <linux/kernel.h> | ||
36 | #include <linux/types.h> | ||
37 | #include <linux/proc_fs.h> | ||
38 | #include <linux/sysctl.h> | ||
39 | #include <linux/pci.h> | ||
40 | #include <linux/smp.h> | ||
41 | #include <linux/smp_lock.h> | ||
42 | |||
43 | #include <linux/string.h> | ||
44 | #include <linux/mm.h> | ||
45 | #include <linux/errno.h> | ||
46 | #include <linux/ioport.h> | ||
47 | #include <linux/slab.h> | ||
48 | #include <linux/interrupt.h> | ||
49 | #include <linux/timer.h> | ||
50 | |||
51 | #include <linux/ioctl.h> | ||
52 | #include <linux/fcntl.h> | ||
53 | |||
54 | #include <linux/list.h> | ||
55 | |||
56 | #include "pci_hotplug.h" | ||
57 | #include "acpiphp.h" | ||
58 | |||
59 | #define MY_NAME "acpiphp_res" | ||
60 | |||
61 | |||
62 | /* | ||
63 | * sort_by_size - sort nodes by their length, smallest first | ||
64 | */ | ||
65 | static int sort_by_size(struct pci_resource **head) | ||
66 | { | ||
67 | struct pci_resource *current_res; | ||
68 | struct pci_resource *next_res; | ||
69 | int out_of_order = 1; | ||
70 | |||
71 | if (!(*head)) | ||
72 | return 1; | ||
73 | |||
74 | if (!((*head)->next)) | ||
75 | return 0; | ||
76 | |||
77 | while (out_of_order) { | ||
78 | out_of_order = 0; | ||
79 | |||
80 | /* Special case for swapping list head */ | ||
81 | if (((*head)->next) && | ||
82 | ((*head)->length > (*head)->next->length)) { | ||
83 | out_of_order++; | ||
84 | current_res = *head; | ||
85 | *head = (*head)->next; | ||
86 | current_res->next = (*head)->next; | ||
87 | (*head)->next = current_res; | ||
88 | } | ||
89 | |||
90 | current_res = *head; | ||
91 | |||
92 | while (current_res->next && current_res->next->next) { | ||
93 | if (current_res->next->length > current_res->next->next->length) { | ||
94 | out_of_order++; | ||
95 | next_res = current_res->next; | ||
96 | current_res->next = current_res->next->next; | ||
97 | current_res = current_res->next; | ||
98 | next_res->next = current_res->next; | ||
99 | current_res->next = next_res; | ||
100 | } else | ||
101 | current_res = current_res->next; | ||
102 | } | ||
103 | } /* End of out_of_order loop */ | ||
104 | |||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | #if 0 | ||
109 | /* | ||
110 | * sort_by_max_size - sort nodes by their length, largest first | ||
111 | */ | ||
112 | static int sort_by_max_size(struct pci_resource **head) | ||
113 | { | ||
114 | struct pci_resource *current_res; | ||
115 | struct pci_resource *next_res; | ||
116 | int out_of_order = 1; | ||
117 | |||
118 | if (!(*head)) | ||
119 | return 1; | ||
120 | |||
121 | if (!((*head)->next)) | ||
122 | return 0; | ||
123 | |||
124 | while (out_of_order) { | ||
125 | out_of_order = 0; | ||
126 | |||
127 | /* Special case for swapping list head */ | ||
128 | if (((*head)->next) && | ||
129 | ((*head)->length < (*head)->next->length)) { | ||
130 | out_of_order++; | ||
131 | current_res = *head; | ||
132 | *head = (*head)->next; | ||
133 | current_res->next = (*head)->next; | ||
134 | (*head)->next = current_res; | ||
135 | } | ||
136 | |||
137 | current_res = *head; | ||
138 | |||
139 | while (current_res->next && current_res->next->next) { | ||
140 | if (current_res->next->length < current_res->next->next->length) { | ||
141 | out_of_order++; | ||
142 | next_res = current_res->next; | ||
143 | current_res->next = current_res->next->next; | ||
144 | current_res = current_res->next; | ||
145 | next_res->next = current_res->next; | ||
146 | current_res->next = next_res; | ||
147 | } else | ||
148 | current_res = current_res->next; | ||
149 | } | ||
150 | } /* End of out_of_order loop */ | ||
151 | |||
152 | return 0; | ||
153 | } | ||
154 | #endif | ||
155 | |||
156 | /** | ||
157 | * get_io_resource - get resource for I/O ports | ||
158 | * | ||
159 | * this function sorts the resource list by size and then | ||
160 | * returns the first node of "size" length that is not in the | ||
161 | * ISA aliasing window. If it finds a node larger than "size" | ||
162 | * it will split it up. | ||
163 | * | ||
164 | * size must be a power of two. | ||
165 | * | ||
166 | * difference from get_resource is handling of ISA aliasing space. | ||
167 | * | ||
168 | */ | ||
169 | struct pci_resource *acpiphp_get_io_resource (struct pci_resource **head, u32 size) | ||
170 | { | ||
171 | struct pci_resource *prevnode; | ||
172 | struct pci_resource *node; | ||
173 | struct pci_resource *split_node; | ||
174 | u64 temp_qword; | ||
175 | |||
176 | if (!(*head)) | ||
177 | return NULL; | ||
178 | |||
179 | if (acpiphp_resource_sort_and_combine(head)) | ||
180 | return NULL; | ||
181 | |||
182 | if (sort_by_size(head)) | ||
183 | return NULL; | ||
184 | |||
185 | for (node = *head; node; node = node->next) { | ||
186 | if (node->length < size) | ||
187 | continue; | ||
188 | |||
189 | if (node->base & (size - 1)) { | ||
190 | /* this one isn't base aligned properly | ||
191 | so we'll make a new entry and split it up */ | ||
192 | temp_qword = (node->base | (size-1)) + 1; | ||
193 | |||
194 | /* Short circuit if adjusted size is too small */ | ||
195 | if ((node->length - (temp_qword - node->base)) < size) | ||
196 | continue; | ||
197 | |||
198 | split_node = acpiphp_make_resource(node->base, temp_qword - node->base); | ||
199 | |||
200 | if (!split_node) | ||
201 | return NULL; | ||
202 | |||
203 | node->base = temp_qword; | ||
204 | node->length -= split_node->length; | ||
205 | |||
206 | /* Put it in the list */ | ||
207 | split_node->next = node->next; | ||
208 | node->next = split_node; | ||
209 | } /* End of non-aligned base */ | ||
210 | |||
211 | /* Don't need to check if too small since we already did */ | ||
212 | if (node->length > size) { | ||
213 | /* this one is longer than we need | ||
214 | so we'll make a new entry and split it up */ | ||
215 | split_node = acpiphp_make_resource(node->base + size, node->length - size); | ||
216 | |||
217 | if (!split_node) | ||
218 | return NULL; | ||
219 | |||
220 | node->length = size; | ||
221 | |||
222 | /* Put it in the list */ | ||
223 | split_node->next = node->next; | ||
224 | node->next = split_node; | ||
225 | } /* End of too big on top end */ | ||
226 | |||
227 | /* For IO make sure it's not in the ISA aliasing space */ | ||
228 | if ((node->base & 0x300L) && !(node->base & 0xfffff000)) | ||
229 | continue; | ||
230 | |||
231 | /* If we got here, then it is the right size | ||
232 | Now take it out of the list */ | ||
233 | if (*head == node) { | ||
234 | *head = node->next; | ||
235 | } else { | ||
236 | prevnode = *head; | ||
237 | while (prevnode->next != node) | ||
238 | prevnode = prevnode->next; | ||
239 | |||
240 | prevnode->next = node->next; | ||
241 | } | ||
242 | node->next = NULL; | ||
243 | /* Stop looping */ | ||
244 | break; | ||
245 | } | ||
246 | |||
247 | return node; | ||
248 | } | ||
249 | |||
250 | |||
251 | #if 0 | ||
252 | /** | ||
253 | * get_max_resource - get the largest resource | ||
254 | * | ||
255 | * Gets the largest node that is at least "size" big from the | ||
256 | * list pointed to by head. It aligns the node on top and bottom | ||
257 | * to "size" alignment before returning it. | ||
258 | */ | ||
259 | static struct pci_resource *acpiphp_get_max_resource (struct pci_resource **head, u32 size) | ||
260 | { | ||
261 | struct pci_resource *max; | ||
262 | struct pci_resource *temp; | ||
263 | struct pci_resource *split_node; | ||
264 | u64 temp_qword; | ||
265 | |||
266 | if (!(*head)) | ||
267 | return NULL; | ||
268 | |||
269 | if (acpiphp_resource_sort_and_combine(head)) | ||
270 | return NULL; | ||
271 | |||
272 | if (sort_by_max_size(head)) | ||
273 | return NULL; | ||
274 | |||
275 | for (max = *head;max; max = max->next) { | ||
276 | |||
277 | /* If not big enough we could probably just bail, | ||
278 | instead we'll continue to the next. */ | ||
279 | if (max->length < size) | ||
280 | continue; | ||
281 | |||
282 | if (max->base & (size - 1)) { | ||
283 | /* this one isn't base aligned properly | ||
284 | so we'll make a new entry and split it up */ | ||
285 | temp_qword = (max->base | (size-1)) + 1; | ||
286 | |||
287 | /* Short circuit if adjusted size is too small */ | ||
288 | if ((max->length - (temp_qword - max->base)) < size) | ||
289 | continue; | ||
290 | |||
291 | split_node = acpiphp_make_resource(max->base, temp_qword - max->base); | ||
292 | |||
293 | if (!split_node) | ||
294 | return NULL; | ||
295 | |||
296 | max->base = temp_qword; | ||
297 | max->length -= split_node->length; | ||
298 | |||
299 | /* Put it next in the list */ | ||
300 | split_node->next = max->next; | ||
301 | max->next = split_node; | ||
302 | } | ||
303 | |||
304 | if ((max->base + max->length) & (size - 1)) { | ||
305 | /* this one isn't end aligned properly at the top | ||
306 | so we'll make a new entry and split it up */ | ||
307 | temp_qword = ((max->base + max->length) & ~(size - 1)); | ||
308 | |||
309 | split_node = acpiphp_make_resource(temp_qword, | ||
310 | max->length + max->base - temp_qword); | ||
311 | |||
312 | if (!split_node) | ||
313 | return NULL; | ||
314 | |||
315 | max->length -= split_node->length; | ||
316 | |||
317 | /* Put it in the list */ | ||
318 | split_node->next = max->next; | ||
319 | max->next = split_node; | ||
320 | } | ||
321 | |||
322 | /* Make sure it didn't shrink too much when we aligned it */ | ||
323 | if (max->length < size) | ||
324 | continue; | ||
325 | |||
326 | /* Now take it out of the list */ | ||
327 | temp = (struct pci_resource*) *head; | ||
328 | if (temp == max) { | ||
329 | *head = max->next; | ||
330 | } else { | ||
331 | while (temp && temp->next != max) { | ||
332 | temp = temp->next; | ||
333 | } | ||
334 | |||
335 | temp->next = max->next; | ||
336 | } | ||
337 | |||
338 | max->next = NULL; | ||
339 | return max; | ||
340 | } | ||
341 | |||
342 | /* If we get here, we couldn't find one */ | ||
343 | return NULL; | ||
344 | } | ||
345 | #endif | ||
346 | |||
347 | /** | ||
348 | * get_resource - get resource (mem, pfmem) | ||
349 | * | ||
350 | * this function sorts the resource list by size and then | ||
351 | * returns the first node of "size" length. If it finds a node | ||
352 | * larger than "size" it will split it up. | ||
353 | * | ||
354 | * size must be a power of two. | ||
355 | * | ||
356 | */ | ||
357 | struct pci_resource *acpiphp_get_resource (struct pci_resource **head, u32 size) | ||
358 | { | ||
359 | struct pci_resource *prevnode; | ||
360 | struct pci_resource *node; | ||
361 | struct pci_resource *split_node; | ||
362 | u64 temp_qword; | ||
363 | |||
364 | if (!(*head)) | ||
365 | return NULL; | ||
366 | |||
367 | if (acpiphp_resource_sort_and_combine(head)) | ||
368 | return NULL; | ||
369 | |||
370 | if (sort_by_size(head)) | ||
371 | return NULL; | ||
372 | |||
373 | for (node = *head; node; node = node->next) { | ||
374 | dbg("%s: req_size =%x node=%p, base=%x, length=%x\n", | ||
375 | __FUNCTION__, size, node, (u32)node->base, node->length); | ||
376 | if (node->length < size) | ||
377 | continue; | ||
378 | |||
379 | if (node->base & (size - 1)) { | ||
380 | dbg("%s: not aligned\n", __FUNCTION__); | ||
381 | /* this one isn't base aligned properly | ||
382 | so we'll make a new entry and split it up */ | ||
383 | temp_qword = (node->base | (size-1)) + 1; | ||
384 | |||
385 | /* Short circuit if adjusted size is too small */ | ||
386 | if ((node->length - (temp_qword - node->base)) < size) | ||
387 | continue; | ||
388 | |||
389 | split_node = acpiphp_make_resource(node->base, temp_qword - node->base); | ||
390 | |||
391 | if (!split_node) | ||
392 | return NULL; | ||
393 | |||
394 | node->base = temp_qword; | ||
395 | node->length -= split_node->length; | ||
396 | |||
397 | /* Put it in the list */ | ||
398 | split_node->next = node->next; | ||
399 | node->next = split_node; | ||
400 | } /* End of non-aligned base */ | ||
401 | |||
402 | /* Don't need to check if too small since we already did */ | ||
403 | if (node->length > size) { | ||
404 | dbg("%s: too big\n", __FUNCTION__); | ||
405 | /* this one is longer than we need | ||
406 | so we'll make a new entry and split it up */ | ||
407 | split_node = acpiphp_make_resource(node->base + size, node->length - size); | ||
408 | |||
409 | if (!split_node) | ||
410 | return NULL; | ||
411 | |||
412 | node->length = size; | ||
413 | |||
414 | /* Put it in the list */ | ||
415 | split_node->next = node->next; | ||
416 | node->next = split_node; | ||
417 | } /* End of too big on top end */ | ||
418 | |||
419 | dbg("%s: got one!!!\n", __FUNCTION__); | ||
420 | /* If we got here, then it is the right size | ||
421 | Now take it out of the list */ | ||
422 | if (*head == node) { | ||
423 | *head = node->next; | ||
424 | } else { | ||
425 | prevnode = *head; | ||
426 | while (prevnode->next != node) | ||
427 | prevnode = prevnode->next; | ||
428 | |||
429 | prevnode->next = node->next; | ||
430 | } | ||
431 | node->next = NULL; | ||
432 | /* Stop looping */ | ||
433 | break; | ||
434 | } | ||
435 | return node; | ||
436 | } | ||
437 | |||
438 | /** | ||
439 | * get_resource_with_base - get resource with specific base address | ||
440 | * | ||
441 | * this function | ||
442 | * returns the first node of "size" length located at specified base address. | ||
443 | * If it finds a node larger than "size" it will split it up. | ||
444 | * | ||
445 | * size must be a power of two. | ||
446 | * | ||
447 | */ | ||
448 | struct pci_resource *acpiphp_get_resource_with_base (struct pci_resource **head, u64 base, u32 size) | ||
449 | { | ||
450 | struct pci_resource *prevnode; | ||
451 | struct pci_resource *node; | ||
452 | struct pci_resource *split_node; | ||
453 | u64 temp_qword; | ||
454 | |||
455 | if (!(*head)) | ||
456 | return NULL; | ||
457 | |||
458 | if (acpiphp_resource_sort_and_combine(head)) | ||
459 | return NULL; | ||
460 | |||
461 | for (node = *head; node; node = node->next) { | ||
462 | dbg(": 1st req_base=%x req_size =%x node=%p, base=%x, length=%x\n", | ||
463 | (u32)base, size, node, (u32)node->base, node->length); | ||
464 | if (node->base > base) | ||
465 | continue; | ||
466 | |||
467 | if ((node->base + node->length) < (base + size)) | ||
468 | continue; | ||
469 | |||
470 | if (node->base < base) { | ||
471 | dbg(": split 1\n"); | ||
472 | /* this one isn't base aligned properly | ||
473 | so we'll make a new entry and split it up */ | ||
474 | temp_qword = base; | ||
475 | |||
476 | /* Short circuit if adjusted size is too small */ | ||
477 | if ((node->length - (temp_qword - node->base)) < size) | ||
478 | continue; | ||
479 | |||
480 | split_node = acpiphp_make_resource(node->base, temp_qword - node->base); | ||
481 | |||
482 | if (!split_node) | ||
483 | return NULL; | ||
484 | |||
485 | node->base = temp_qword; | ||
486 | node->length -= split_node->length; | ||
487 | |||
488 | /* Put it in the list */ | ||
489 | split_node->next = node->next; | ||
490 | node->next = split_node; | ||
491 | } | ||
492 | |||
493 | dbg(": 2nd req_base=%x req_size =%x node=%p, base=%x, length=%x\n", | ||
494 | (u32)base, size, node, (u32)node->base, node->length); | ||
495 | |||
496 | /* Don't need to check if too small since we already did */ | ||
497 | if (node->length > size) { | ||
498 | dbg(": split 2\n"); | ||
499 | /* this one is longer than we need | ||
500 | so we'll make a new entry and split it up */ | ||
501 | split_node = acpiphp_make_resource(node->base + size, node->length - size); | ||
502 | |||
503 | if (!split_node) | ||
504 | return NULL; | ||
505 | |||
506 | node->length = size; | ||
507 | |||
508 | /* Put it in the list */ | ||
509 | split_node->next = node->next; | ||
510 | node->next = split_node; | ||
511 | } /* End of too big on top end */ | ||
512 | |||
513 | dbg(": got one!!!\n"); | ||
514 | /* If we got here, then it is the right size | ||
515 | Now take it out of the list */ | ||
516 | if (*head == node) { | ||
517 | *head = node->next; | ||
518 | } else { | ||
519 | prevnode = *head; | ||
520 | while (prevnode->next != node) | ||
521 | prevnode = prevnode->next; | ||
522 | |||
523 | prevnode->next = node->next; | ||
524 | } | ||
525 | node->next = NULL; | ||
526 | /* Stop looping */ | ||
527 | break; | ||
528 | } | ||
529 | return node; | ||
530 | } | ||
531 | |||
532 | |||
533 | /** | ||
534 | * acpiphp_resource_sort_and_combine | ||
535 | * | ||
536 | * Sorts all of the nodes in the list in ascending order by | ||
537 | * their base addresses. Also does garbage collection by | ||
538 | * combining adjacent nodes. | ||
539 | * | ||
540 | * returns 0 if success | ||
541 | */ | ||
542 | int acpiphp_resource_sort_and_combine (struct pci_resource **head) | ||
543 | { | ||
544 | struct pci_resource *node1; | ||
545 | struct pci_resource *node2; | ||
546 | int out_of_order = 1; | ||
547 | |||
548 | if (!(*head)) | ||
549 | return 1; | ||
550 | |||
551 | dbg("*head->next = %p\n",(*head)->next); | ||
552 | |||
553 | if (!(*head)->next) | ||
554 | return 0; /* only one item on the list, already sorted! */ | ||
555 | |||
556 | dbg("*head->base = 0x%x\n",(u32)(*head)->base); | ||
557 | dbg("*head->next->base = 0x%x\n", (u32)(*head)->next->base); | ||
558 | while (out_of_order) { | ||
559 | out_of_order = 0; | ||
560 | |||
561 | /* Special case for swapping list head */ | ||
562 | if (((*head)->next) && | ||
563 | ((*head)->base > (*head)->next->base)) { | ||
564 | node1 = *head; | ||
565 | (*head) = (*head)->next; | ||
566 | node1->next = (*head)->next; | ||
567 | (*head)->next = node1; | ||
568 | out_of_order++; | ||
569 | } | ||
570 | |||
571 | node1 = (*head); | ||
572 | |||
573 | while (node1->next && node1->next->next) { | ||
574 | if (node1->next->base > node1->next->next->base) { | ||
575 | out_of_order++; | ||
576 | node2 = node1->next; | ||
577 | node1->next = node1->next->next; | ||
578 | node1 = node1->next; | ||
579 | node2->next = node1->next; | ||
580 | node1->next = node2; | ||
581 | } else | ||
582 | node1 = node1->next; | ||
583 | } | ||
584 | } /* End of out_of_order loop */ | ||
585 | |||
586 | node1 = *head; | ||
587 | |||
588 | while (node1 && node1->next) { | ||
589 | if ((node1->base + node1->length) == node1->next->base) { | ||
590 | /* Combine */ | ||
591 | dbg("8..\n"); | ||
592 | node1->length += node1->next->length; | ||
593 | node2 = node1->next; | ||
594 | node1->next = node1->next->next; | ||
595 | kfree(node2); | ||
596 | } else | ||
597 | node1 = node1->next; | ||
598 | } | ||
599 | |||
600 | return 0; | ||
601 | } | ||
602 | |||
603 | |||
604 | /** | ||
605 | * acpiphp_make_resource - make resource structure | ||
606 | * @base: base address of a resource | ||
607 | * @length: length of a resource | ||
608 | */ | ||
609 | struct pci_resource *acpiphp_make_resource (u64 base, u32 length) | ||
610 | { | ||
611 | struct pci_resource *res; | ||
612 | |||
613 | res = kmalloc(sizeof(struct pci_resource), GFP_KERNEL); | ||
614 | if (res) { | ||
615 | memset(res, 0, sizeof(struct pci_resource)); | ||
616 | res->base = base; | ||
617 | res->length = length; | ||
618 | } | ||
619 | |||
620 | return res; | ||
621 | } | ||
622 | |||
623 | |||
624 | /** | ||
625 | * acpiphp_move_resource - move linked resources from one to another | ||
626 | * @from: head of linked resource list | ||
627 | * @to: head of linked resource list | ||
628 | */ | ||
629 | void acpiphp_move_resource (struct pci_resource **from, struct pci_resource **to) | ||
630 | { | ||
631 | struct pci_resource *tmp; | ||
632 | |||
633 | while (*from) { | ||
634 | tmp = (*from)->next; | ||
635 | (*from)->next = *to; | ||
636 | *to = *from; | ||
637 | *from = tmp; | ||
638 | } | ||
639 | |||
640 | /* *from = NULL is guaranteed */ | ||
641 | } | ||
642 | |||
643 | |||
644 | /** | ||
645 | * acpiphp_free_resource - free all linked resources | ||
646 | * @res: head of linked resource list | ||
647 | */ | ||
648 | void acpiphp_free_resource (struct pci_resource **res) | ||
649 | { | ||
650 | struct pci_resource *tmp; | ||
651 | |||
652 | while (*res) { | ||
653 | tmp = (*res)->next; | ||
654 | kfree(*res); | ||
655 | *res = tmp; | ||
656 | } | ||
657 | |||
658 | /* *res = NULL is guaranteed */ | ||
659 | } | ||
660 | |||
661 | |||
662 | /* debug support functions; will go away sometime :) */ | ||
663 | static void dump_resource(struct pci_resource *head) | ||
664 | { | ||
665 | struct pci_resource *p; | ||
666 | int cnt; | ||
667 | |||
668 | p = head; | ||
669 | cnt = 0; | ||
670 | |||
671 | while (p) { | ||
672 | dbg("[%02d] %08x - %08x\n", | ||
673 | cnt++, (u32)p->base, (u32)p->base + p->length - 1); | ||
674 | p = p->next; | ||
675 | } | ||
676 | } | ||
677 | |||
678 | void acpiphp_dump_resource(struct acpiphp_bridge *bridge) | ||
679 | { | ||
680 | dbg("I/O resource:\n"); | ||
681 | dump_resource(bridge->io_head); | ||
682 | dbg("MEM resource:\n"); | ||
683 | dump_resource(bridge->mem_head); | ||
684 | dbg("PMEM resource:\n"); | ||
685 | dump_resource(bridge->p_mem_head); | ||
686 | dbg("BUS resource:\n"); | ||
687 | dump_resource(bridge->bus_head); | ||
688 | } | ||
689 | |||
690 | void acpiphp_dump_func_resource(struct acpiphp_func *func) | ||
691 | { | ||
692 | dbg("I/O resource:\n"); | ||
693 | dump_resource(func->io_head); | ||
694 | dbg("MEM resource:\n"); | ||
695 | dump_resource(func->mem_head); | ||
696 | dbg("PMEM resource:\n"); | ||
697 | dump_resource(func->p_mem_head); | ||
698 | dbg("BUS resource:\n"); | ||
699 | dump_resource(func->bus_head); | ||
700 | } | ||
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index afbccfa5217d..8c6d3987d461 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c | |||
@@ -60,6 +60,7 @@ static void __iomem *smbios_start; | |||
60 | static void __iomem *cpqhp_rom_start; | 60 | static void __iomem *cpqhp_rom_start; |
61 | static int power_mode; | 61 | static int power_mode; |
62 | static int debug; | 62 | static int debug; |
63 | static int initialized; | ||
63 | 64 | ||
64 | #define DRIVER_VERSION "0.9.8" | 65 | #define DRIVER_VERSION "0.9.8" |
65 | #define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>" | 66 | #define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>" |
@@ -1271,7 +1272,6 @@ static int one_time_init(void) | |||
1271 | { | 1272 | { |
1272 | int loop; | 1273 | int loop; |
1273 | int retval = 0; | 1274 | int retval = 0; |
1274 | static int initialized = 0; | ||
1275 | 1275 | ||
1276 | if (initialized) | 1276 | if (initialized) |
1277 | return 0; | 1277 | return 0; |
@@ -1441,7 +1441,8 @@ static void __exit unload_cpqphpd(void) | |||
1441 | } | 1441 | } |
1442 | 1442 | ||
1443 | // Stop the notification mechanism | 1443 | // Stop the notification mechanism |
1444 | cpqhp_event_stop_thread(); | 1444 | if (initialized) |
1445 | cpqhp_event_stop_thread(); | ||
1445 | 1446 | ||
1446 | //unmap the rom address | 1447 | //unmap the rom address |
1447 | if (cpqhp_rom_start) | 1448 | if (cpqhp_rom_start) |
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 30206ac43c44..b5ab9aa6ff7c 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -28,10 +28,10 @@ static struct msi_desc* msi_desc[NR_IRQS] = { [0 ... NR_IRQS-1] = NULL }; | |||
28 | static kmem_cache_t* msi_cachep; | 28 | static kmem_cache_t* msi_cachep; |
29 | 29 | ||
30 | static int pci_msi_enable = 1; | 30 | static int pci_msi_enable = 1; |
31 | static int last_alloc_vector = 0; | 31 | static int last_alloc_vector; |
32 | static int nr_released_vectors = 0; | 32 | static int nr_released_vectors; |
33 | static int nr_reserved_vectors = NR_HP_RESERVED_VECTORS; | 33 | static int nr_reserved_vectors = NR_HP_RESERVED_VECTORS; |
34 | static int nr_msix_devices = 0; | 34 | static int nr_msix_devices; |
35 | 35 | ||
36 | #ifndef CONFIG_X86_IO_APIC | 36 | #ifndef CONFIG_X86_IO_APIC |
37 | int vector_irq[NR_VECTORS] = { [0 ... NR_VECTORS - 1] = -1}; | 37 | int vector_irq[NR_VECTORS] = { [0 ... NR_VECTORS - 1] = -1}; |
@@ -170,44 +170,30 @@ static unsigned int startup_msi_irq_wo_maskbit(unsigned int vector) | |||
170 | return 0; /* never anything pending */ | 170 | return 0; /* never anything pending */ |
171 | } | 171 | } |
172 | 172 | ||
173 | static void release_msi(unsigned int vector); | 173 | static unsigned int startup_msi_irq_w_maskbit(unsigned int vector) |
174 | static void shutdown_msi_irq(unsigned int vector) | ||
175 | { | ||
176 | release_msi(vector); | ||
177 | } | ||
178 | |||
179 | #define shutdown_msi_irq_wo_maskbit shutdown_msi_irq | ||
180 | static void enable_msi_irq_wo_maskbit(unsigned int vector) {} | ||
181 | static void disable_msi_irq_wo_maskbit(unsigned int vector) {} | ||
182 | static void ack_msi_irq_wo_maskbit(unsigned int vector) {} | ||
183 | static void end_msi_irq_wo_maskbit(unsigned int vector) | ||
184 | { | 174 | { |
185 | move_msi(vector); | 175 | startup_msi_irq_wo_maskbit(vector); |
186 | ack_APIC_irq(); | 176 | unmask_MSI_irq(vector); |
177 | return 0; /* never anything pending */ | ||
187 | } | 178 | } |
188 | 179 | ||
189 | static unsigned int startup_msi_irq_w_maskbit(unsigned int vector) | 180 | static void shutdown_msi_irq(unsigned int vector) |
190 | { | 181 | { |
191 | struct msi_desc *entry; | 182 | struct msi_desc *entry; |
192 | unsigned long flags; | 183 | unsigned long flags; |
193 | 184 | ||
194 | spin_lock_irqsave(&msi_lock, flags); | 185 | spin_lock_irqsave(&msi_lock, flags); |
195 | entry = msi_desc[vector]; | 186 | entry = msi_desc[vector]; |
196 | if (!entry || !entry->dev) { | 187 | if (entry && entry->dev) |
197 | spin_unlock_irqrestore(&msi_lock, flags); | 188 | entry->msi_attrib.state = 0; /* Mark it not active */ |
198 | return 0; | ||
199 | } | ||
200 | entry->msi_attrib.state = 1; /* Mark it active */ | ||
201 | spin_unlock_irqrestore(&msi_lock, flags); | 189 | spin_unlock_irqrestore(&msi_lock, flags); |
202 | |||
203 | unmask_MSI_irq(vector); | ||
204 | return 0; /* never anything pending */ | ||
205 | } | 190 | } |
206 | 191 | ||
207 | #define shutdown_msi_irq_w_maskbit shutdown_msi_irq | 192 | static void end_msi_irq_wo_maskbit(unsigned int vector) |
208 | #define enable_msi_irq_w_maskbit unmask_MSI_irq | 193 | { |
209 | #define disable_msi_irq_w_maskbit mask_MSI_irq | 194 | move_msi(vector); |
210 | #define ack_msi_irq_w_maskbit mask_MSI_irq | 195 | ack_APIC_irq(); |
196 | } | ||
211 | 197 | ||
212 | static void end_msi_irq_w_maskbit(unsigned int vector) | 198 | static void end_msi_irq_w_maskbit(unsigned int vector) |
213 | { | 199 | { |
@@ -216,6 +202,10 @@ static void end_msi_irq_w_maskbit(unsigned int vector) | |||
216 | ack_APIC_irq(); | 202 | ack_APIC_irq(); |
217 | } | 203 | } |
218 | 204 | ||
205 | static void do_nothing(unsigned int vector) | ||
206 | { | ||
207 | } | ||
208 | |||
219 | /* | 209 | /* |
220 | * Interrupt Type for MSI-X PCI/PCI-X/PCI-Express Devices, | 210 | * Interrupt Type for MSI-X PCI/PCI-X/PCI-Express Devices, |
221 | * which implement the MSI-X Capability Structure. | 211 | * which implement the MSI-X Capability Structure. |
@@ -223,10 +213,10 @@ static void end_msi_irq_w_maskbit(unsigned int vector) | |||
223 | static struct hw_interrupt_type msix_irq_type = { | 213 | static struct hw_interrupt_type msix_irq_type = { |
224 | .typename = "PCI-MSI-X", | 214 | .typename = "PCI-MSI-X", |
225 | .startup = startup_msi_irq_w_maskbit, | 215 | .startup = startup_msi_irq_w_maskbit, |
226 | .shutdown = shutdown_msi_irq_w_maskbit, | 216 | .shutdown = shutdown_msi_irq, |
227 | .enable = enable_msi_irq_w_maskbit, | 217 | .enable = unmask_MSI_irq, |
228 | .disable = disable_msi_irq_w_maskbit, | 218 | .disable = mask_MSI_irq, |
229 | .ack = ack_msi_irq_w_maskbit, | 219 | .ack = mask_MSI_irq, |
230 | .end = end_msi_irq_w_maskbit, | 220 | .end = end_msi_irq_w_maskbit, |
231 | .set_affinity = set_msi_irq_affinity | 221 | .set_affinity = set_msi_irq_affinity |
232 | }; | 222 | }; |
@@ -239,10 +229,10 @@ static struct hw_interrupt_type msix_irq_type = { | |||
239 | static struct hw_interrupt_type msi_irq_w_maskbit_type = { | 229 | static struct hw_interrupt_type msi_irq_w_maskbit_type = { |
240 | .typename = "PCI-MSI", | 230 | .typename = "PCI-MSI", |
241 | .startup = startup_msi_irq_w_maskbit, | 231 | .startup = startup_msi_irq_w_maskbit, |
242 | .shutdown = shutdown_msi_irq_w_maskbit, | 232 | .shutdown = shutdown_msi_irq, |
243 | .enable = enable_msi_irq_w_maskbit, | 233 | .enable = unmask_MSI_irq, |
244 | .disable = disable_msi_irq_w_maskbit, | 234 | .disable = mask_MSI_irq, |
245 | .ack = ack_msi_irq_w_maskbit, | 235 | .ack = mask_MSI_irq, |
246 | .end = end_msi_irq_w_maskbit, | 236 | .end = end_msi_irq_w_maskbit, |
247 | .set_affinity = set_msi_irq_affinity | 237 | .set_affinity = set_msi_irq_affinity |
248 | }; | 238 | }; |
@@ -255,10 +245,10 @@ static struct hw_interrupt_type msi_irq_w_maskbit_type = { | |||
255 | static struct hw_interrupt_type msi_irq_wo_maskbit_type = { | 245 | static struct hw_interrupt_type msi_irq_wo_maskbit_type = { |
256 | .typename = "PCI-MSI", | 246 | .typename = "PCI-MSI", |
257 | .startup = startup_msi_irq_wo_maskbit, | 247 | .startup = startup_msi_irq_wo_maskbit, |
258 | .shutdown = shutdown_msi_irq_wo_maskbit, | 248 | .shutdown = shutdown_msi_irq, |
259 | .enable = enable_msi_irq_wo_maskbit, | 249 | .enable = do_nothing, |
260 | .disable = disable_msi_irq_wo_maskbit, | 250 | .disable = do_nothing, |
261 | .ack = ack_msi_irq_wo_maskbit, | 251 | .ack = do_nothing, |
262 | .end = end_msi_irq_wo_maskbit, | 252 | .end = end_msi_irq_wo_maskbit, |
263 | .set_affinity = set_msi_irq_affinity | 253 | .set_affinity = set_msi_irq_affinity |
264 | }; | 254 | }; |
@@ -407,7 +397,7 @@ static struct msi_desc* alloc_msi_entry(void) | |||
407 | { | 397 | { |
408 | struct msi_desc *entry; | 398 | struct msi_desc *entry; |
409 | 399 | ||
410 | entry = (struct msi_desc*) kmem_cache_alloc(msi_cachep, SLAB_KERNEL); | 400 | entry = kmem_cache_alloc(msi_cachep, SLAB_KERNEL); |
411 | if (!entry) | 401 | if (!entry) |
412 | return NULL; | 402 | return NULL; |
413 | 403 | ||
@@ -796,18 +786,6 @@ void pci_disable_msi(struct pci_dev* dev) | |||
796 | } | 786 | } |
797 | } | 787 | } |
798 | 788 | ||
799 | static void release_msi(unsigned int vector) | ||
800 | { | ||
801 | struct msi_desc *entry; | ||
802 | unsigned long flags; | ||
803 | |||
804 | spin_lock_irqsave(&msi_lock, flags); | ||
805 | entry = msi_desc[vector]; | ||
806 | if (entry && entry->dev) | ||
807 | entry->msi_attrib.state = 0; /* Mark it not active */ | ||
808 | spin_unlock_irqrestore(&msi_lock, flags); | ||
809 | } | ||
810 | |||
811 | static int msi_free_vector(struct pci_dev* dev, int vector, int reassign) | 789 | static int msi_free_vector(struct pci_dev* dev, int vector, int reassign) |
812 | { | 790 | { |
813 | struct msi_desc *entry; | 791 | struct msi_desc *entry; |
@@ -924,7 +902,7 @@ static int reroute_msix_table(int head, struct msix_entry *entries, int *nvec) | |||
924 | /** | 902 | /** |
925 | * pci_enable_msix - configure device's MSI-X capability structure | 903 | * pci_enable_msix - configure device's MSI-X capability structure |
926 | * @dev: pointer to the pci_dev data structure of MSI-X device function | 904 | * @dev: pointer to the pci_dev data structure of MSI-X device function |
927 | * @data: pointer to an array of MSI-X entries | 905 | * @entries: pointer to an array of MSI-X entries |
928 | * @nvec: number of MSI-X vectors requested for allocation by device driver | 906 | * @nvec: number of MSI-X vectors requested for allocation by device driver |
929 | * | 907 | * |
930 | * Setup the MSI-X capability structure of device function with the number | 908 | * Setup the MSI-X capability structure of device function with the number |
diff --git a/drivers/pci/msi.h b/drivers/pci/msi.h index bef21ae3cbd0..390f1851c0f1 100644 --- a/drivers/pci/msi.h +++ b/drivers/pci/msi.h | |||
@@ -41,11 +41,11 @@ static inline void move_msi(int vector) {} | |||
41 | #define PCI_MSIX_FLAGS_BIRMASK (7 << 0) | 41 | #define PCI_MSIX_FLAGS_BIRMASK (7 << 0) |
42 | #define PCI_MSIX_FLAGS_BITMASK (1 << 0) | 42 | #define PCI_MSIX_FLAGS_BITMASK (1 << 0) |
43 | 43 | ||
44 | #define PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET 0 | ||
45 | #define PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET 4 | ||
46 | #define PCI_MSIX_ENTRY_DATA_OFFSET 8 | ||
47 | #define PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET 12 | ||
48 | #define PCI_MSIX_ENTRY_SIZE 16 | 44 | #define PCI_MSIX_ENTRY_SIZE 16 |
45 | #define PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET 0 | ||
46 | #define PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET 4 | ||
47 | #define PCI_MSIX_ENTRY_DATA_OFFSET 8 | ||
48 | #define PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET 12 | ||
49 | 49 | ||
50 | #define msi_control_reg(base) (base + PCI_MSI_FLAGS) | 50 | #define msi_control_reg(base) (base + PCI_MSI_FLAGS) |
51 | #define msi_lower_address_reg(base) (base + PCI_MSI_ADDRESS_LO) | 51 | #define msi_lower_address_reg(base) (base + PCI_MSI_ADDRESS_LO) |
@@ -64,7 +64,6 @@ static inline void move_msi(int vector) {} | |||
64 | #define msi_enable(control, num) multi_msi_enable(control, num); \ | 64 | #define msi_enable(control, num) multi_msi_enable(control, num); \ |
65 | control |= PCI_MSI_FLAGS_ENABLE | 65 | control |= PCI_MSI_FLAGS_ENABLE |
66 | 66 | ||
67 | #define msix_control_reg msi_control_reg | ||
68 | #define msix_table_offset_reg(base) (base + 0x04) | 67 | #define msix_table_offset_reg(base) (base + 0x04) |
69 | #define msix_pba_offset_reg(base) (base + 0x08) | 68 | #define msix_pba_offset_reg(base) (base + 0x08) |
70 | #define msix_enable(control) control |= PCI_MSIX_FLAGS_ENABLE | 69 | #define msix_enable(control) control |= PCI_MSIX_FLAGS_ENABLE |
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index a15f94072a6f..cc9d65388e62 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -60,15 +60,18 @@ resource_show(struct device * dev, struct device_attribute *attr, char * buf) | |||
60 | char * str = buf; | 60 | char * str = buf; |
61 | int i; | 61 | int i; |
62 | int max = 7; | 62 | int max = 7; |
63 | u64 start, end; | ||
63 | 64 | ||
64 | if (pci_dev->subordinate) | 65 | if (pci_dev->subordinate) |
65 | max = DEVICE_COUNT_RESOURCE; | 66 | max = DEVICE_COUNT_RESOURCE; |
66 | 67 | ||
67 | for (i = 0; i < max; i++) { | 68 | for (i = 0; i < max; i++) { |
68 | str += sprintf(str,"0x%016lx 0x%016lx 0x%016lx\n", | 69 | struct resource *res = &pci_dev->resource[i]; |
69 | pci_resource_start(pci_dev,i), | 70 | pci_resource_to_user(pci_dev, i, res, &start, &end); |
70 | pci_resource_end(pci_dev,i), | 71 | str += sprintf(str,"0x%016llx 0x%016llx 0x%016llx\n", |
71 | pci_resource_flags(pci_dev,i)); | 72 | (unsigned long long)start, |
73 | (unsigned long long)end, | ||
74 | (unsigned long long)res->flags); | ||
72 | } | 75 | } |
73 | return (str - buf); | 76 | return (str - buf); |
74 | } | 77 | } |
@@ -313,8 +316,21 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, | |||
313 | struct device, kobj)); | 316 | struct device, kobj)); |
314 | struct resource *res = (struct resource *)attr->private; | 317 | struct resource *res = (struct resource *)attr->private; |
315 | enum pci_mmap_state mmap_type; | 318 | enum pci_mmap_state mmap_type; |
319 | u64 start, end; | ||
320 | int i; | ||
316 | 321 | ||
317 | vma->vm_pgoff += res->start >> PAGE_SHIFT; | 322 | for (i = 0; i < PCI_ROM_RESOURCE; i++) |
323 | if (res == &pdev->resource[i]) | ||
324 | break; | ||
325 | if (i >= PCI_ROM_RESOURCE) | ||
326 | return -ENODEV; | ||
327 | |||
328 | /* pci_mmap_page_range() expects the same kind of entry as coming | ||
329 | * from /proc/bus/pci/ which is a "user visible" value. If this is | ||
330 | * different from the resource itself, arch will do necessary fixup. | ||
331 | */ | ||
332 | pci_resource_to_user(pdev, i, res, &start, &end); | ||
333 | vma->vm_pgoff += start >> PAGE_SHIFT; | ||
318 | mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io; | 334 | mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io; |
319 | 335 | ||
320 | return pci_mmap_page_range(pdev, vma, mmap_type, 0); | 336 | return pci_mmap_page_range(pdev, vma, mmap_type, 0); |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index fd48b201eb53..6a0a82f0508b 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -374,8 +374,11 @@ struct pci_bus * __devinit pci_add_new_bus(struct pci_bus *parent, struct pci_de | |||
374 | struct pci_bus *child; | 374 | struct pci_bus *child; |
375 | 375 | ||
376 | child = pci_alloc_child_bus(parent, dev, busnr); | 376 | child = pci_alloc_child_bus(parent, dev, busnr); |
377 | if (child) | 377 | if (child) { |
378 | spin_lock(&pci_bus_lock); | ||
378 | list_add_tail(&child->node, &parent->children); | 379 | list_add_tail(&child->node, &parent->children); |
380 | spin_unlock(&pci_bus_lock); | ||
381 | } | ||
379 | return child; | 382 | return child; |
380 | } | 383 | } |
381 | 384 | ||
@@ -411,7 +414,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
411 | { | 414 | { |
412 | struct pci_bus *child; | 415 | struct pci_bus *child; |
413 | int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS); | 416 | int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS); |
414 | u32 buses; | 417 | u32 buses, i; |
415 | u16 bctl; | 418 | u16 bctl; |
416 | 419 | ||
417 | pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses); | 420 | pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses); |
@@ -447,7 +450,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
447 | return max; | 450 | return max; |
448 | } | 451 | } |
449 | 452 | ||
450 | child = pci_alloc_child_bus(bus, dev, busnr); | 453 | child = pci_add_new_bus(bus, dev, busnr); |
451 | if (!child) | 454 | if (!child) |
452 | return max; | 455 | return max; |
453 | child->primary = buses & 0xFF; | 456 | child->primary = buses & 0xFF; |
@@ -470,7 +473,11 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
470 | /* Clear errors */ | 473 | /* Clear errors */ |
471 | pci_write_config_word(dev, PCI_STATUS, 0xffff); | 474 | pci_write_config_word(dev, PCI_STATUS, 0xffff); |
472 | 475 | ||
473 | child = pci_alloc_child_bus(bus, dev, ++max); | 476 | /* Prevent assigning a bus number that already exists. |
477 | * This can happen when a bridge is hot-plugged */ | ||
478 | if (pci_find_bus(pci_domain_nr(bus), max+1)) | ||
479 | return max; | ||
480 | child = pci_add_new_bus(bus, dev, ++max); | ||
474 | buses = (buses & 0xff000000) | 481 | buses = (buses & 0xff000000) |
475 | | ((unsigned int)(child->primary) << 0) | 482 | | ((unsigned int)(child->primary) << 0) |
476 | | ((unsigned int)(child->secondary) << 8) | 483 | | ((unsigned int)(child->secondary) << 8) |
@@ -501,7 +508,11 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max | |||
501 | * as cards with a PCI-to-PCI bridge can be | 508 | * as cards with a PCI-to-PCI bridge can be |
502 | * inserted later. | 509 | * inserted later. |
503 | */ | 510 | */ |
504 | max += CARDBUS_RESERVE_BUSNR; | 511 | for (i=0; i<CARDBUS_RESERVE_BUSNR; i++) |
512 | if (pci_find_bus(pci_domain_nr(bus), | ||
513 | max+i+1)) | ||
514 | break; | ||
515 | max += i; | ||
505 | } | 516 | } |
506 | /* | 517 | /* |
507 | * Set the subordinate bus number to its real value. | 518 | * Set the subordinate bus number to its real value. |
@@ -757,7 +768,9 @@ pci_scan_single_device(struct pci_bus *bus, int devfn) | |||
757 | * and the bus list for fixup functions, etc. | 768 | * and the bus list for fixup functions, etc. |
758 | */ | 769 | */ |
759 | INIT_LIST_HEAD(&dev->global_list); | 770 | INIT_LIST_HEAD(&dev->global_list); |
771 | spin_lock(&pci_bus_lock); | ||
760 | list_add_tail(&dev->bus_list, &bus->devices); | 772 | list_add_tail(&dev->bus_list, &bus->devices); |
773 | spin_unlock(&pci_bus_lock); | ||
761 | 774 | ||
762 | return dev; | 775 | return dev; |
763 | } | 776 | } |
@@ -878,7 +891,9 @@ struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, int bus, | |||
878 | pr_debug("PCI: Bus %04x:%02x already known\n", pci_domain_nr(b), bus); | 891 | pr_debug("PCI: Bus %04x:%02x already known\n", pci_domain_nr(b), bus); |
879 | goto err_out; | 892 | goto err_out; |
880 | } | 893 | } |
894 | spin_lock(&pci_bus_lock); | ||
881 | list_add_tail(&b->node, &pci_root_buses); | 895 | list_add_tail(&b->node, &pci_root_buses); |
896 | spin_unlock(&pci_bus_lock); | ||
882 | 897 | ||
883 | memset(dev, 0, sizeof(*dev)); | 898 | memset(dev, 0, sizeof(*dev)); |
884 | dev->parent = parent; | 899 | dev->parent = parent; |
@@ -911,8 +926,6 @@ struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, int bus, | |||
911 | 926 | ||
912 | b->subordinate = pci_scan_child_bus(b); | 927 | b->subordinate = pci_scan_child_bus(b); |
913 | 928 | ||
914 | pci_bus_add_devices(b); | ||
915 | |||
916 | return b; | 929 | return b; |
917 | 930 | ||
918 | sys_create_link_err: | 931 | sys_create_link_err: |
@@ -922,7 +935,9 @@ class_dev_create_file_err: | |||
922 | class_dev_reg_err: | 935 | class_dev_reg_err: |
923 | device_unregister(dev); | 936 | device_unregister(dev); |
924 | dev_reg_err: | 937 | dev_reg_err: |
938 | spin_lock(&pci_bus_lock); | ||
925 | list_del(&b->node); | 939 | list_del(&b->node); |
940 | spin_unlock(&pci_bus_lock); | ||
926 | err_out: | 941 | err_out: |
927 | kfree(dev); | 942 | kfree(dev); |
928 | kfree(b); | 943 | kfree(b); |
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index e68bbfb1e7c3..7988fc8df3fd 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c | |||
@@ -355,14 +355,20 @@ static int show_device(struct seq_file *m, void *v) | |||
355 | dev->device, | 355 | dev->device, |
356 | dev->irq); | 356 | dev->irq); |
357 | /* Here should be 7 and not PCI_NUM_RESOURCES as we need to preserve compatibility */ | 357 | /* Here should be 7 and not PCI_NUM_RESOURCES as we need to preserve compatibility */ |
358 | for(i=0; i<7; i++) | 358 | for (i=0; i<7; i++) { |
359 | u64 start, end; | ||
360 | pci_resource_to_user(dev, i, &dev->resource[i], &start, &end); | ||
359 | seq_printf(m, LONG_FORMAT, | 361 | seq_printf(m, LONG_FORMAT, |
360 | dev->resource[i].start | | 362 | ((unsigned long)start) | |
361 | (dev->resource[i].flags & PCI_REGION_FLAG_MASK)); | 363 | (dev->resource[i].flags & PCI_REGION_FLAG_MASK)); |
362 | for(i=0; i<7; i++) | 364 | } |
365 | for (i=0; i<7; i++) { | ||
366 | u64 start, end; | ||
367 | pci_resource_to_user(dev, i, &dev->resource[i], &start, &end); | ||
363 | seq_printf(m, LONG_FORMAT, | 368 | seq_printf(m, LONG_FORMAT, |
364 | dev->resource[i].start < dev->resource[i].end ? | 369 | dev->resource[i].start < dev->resource[i].end ? |
365 | dev->resource[i].end - dev->resource[i].start + 1 : 0); | 370 | (unsigned long)(end - start) + 1 : 0); |
371 | } | ||
366 | seq_putc(m, '\t'); | 372 | seq_putc(m, '\t'); |
367 | if (drv) | 373 | if (drv) |
368 | seq_printf(m, "%s", drv->name); | 374 | seq_printf(m, "%s", drv->name); |
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 96f077f9a659..27a294b6965d 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c | |||
@@ -18,17 +18,21 @@ static void pci_free_resources(struct pci_dev *dev) | |||
18 | 18 | ||
19 | static void pci_destroy_dev(struct pci_dev *dev) | 19 | static void pci_destroy_dev(struct pci_dev *dev) |
20 | { | 20 | { |
21 | pci_proc_detach_device(dev); | 21 | if (!list_empty(&dev->global_list)) { |
22 | pci_remove_sysfs_dev_files(dev); | 22 | pci_proc_detach_device(dev); |
23 | device_unregister(&dev->dev); | 23 | pci_remove_sysfs_dev_files(dev); |
24 | device_unregister(&dev->dev); | ||
25 | spin_lock(&pci_bus_lock); | ||
26 | list_del(&dev->global_list); | ||
27 | dev->global_list.next = dev->global_list.prev = NULL; | ||
28 | spin_unlock(&pci_bus_lock); | ||
29 | } | ||
24 | 30 | ||
25 | /* Remove the device from the device lists, and prevent any further | 31 | /* Remove the device from the device lists, and prevent any further |
26 | * list accesses from this device */ | 32 | * list accesses from this device */ |
27 | spin_lock(&pci_bus_lock); | 33 | spin_lock(&pci_bus_lock); |
28 | list_del(&dev->bus_list); | 34 | list_del(&dev->bus_list); |
29 | list_del(&dev->global_list); | ||
30 | dev->bus_list.next = dev->bus_list.prev = NULL; | 35 | dev->bus_list.next = dev->bus_list.prev = NULL; |
31 | dev->global_list.next = dev->global_list.prev = NULL; | ||
32 | spin_unlock(&pci_bus_lock); | 36 | spin_unlock(&pci_bus_lock); |
33 | 37 | ||
34 | pci_free_resources(dev); | 38 | pci_free_resources(dev); |
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 1ba84be0b4c0..6b628de948af 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -72,7 +72,10 @@ pbus_assign_resources_sorted(struct pci_bus *bus) | |||
72 | for (list = head.next; list;) { | 72 | for (list = head.next; list;) { |
73 | res = list->res; | 73 | res = list->res; |
74 | idx = res - &list->dev->resource[0]; | 74 | idx = res - &list->dev->resource[0]; |
75 | pci_assign_resource(list->dev, idx); | 75 | if (pci_assign_resource(list->dev, idx)) { |
76 | res->start = 0; | ||
77 | res->flags = 0; | ||
78 | } | ||
76 | tmp = list; | 79 | tmp = list; |
77 | list = list->next; | 80 | list = list->next; |
78 | kfree(tmp); | 81 | kfree(tmp); |
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 34dbc37a79d4..bc6e4627c7a1 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c | |||
@@ -1916,9 +1916,9 @@ static void __twa_shutdown(TW_Device_Extension *tw_dev) | |||
1916 | } /* End __twa_shutdown() */ | 1916 | } /* End __twa_shutdown() */ |
1917 | 1917 | ||
1918 | /* Wrapper for __twa_shutdown */ | 1918 | /* Wrapper for __twa_shutdown */ |
1919 | static void twa_shutdown(struct device *dev) | 1919 | static void twa_shutdown(struct pci_dev *pdev) |
1920 | { | 1920 | { |
1921 | struct Scsi_Host *host = pci_get_drvdata(to_pci_dev(dev)); | 1921 | struct Scsi_Host *host = pci_get_drvdata(pdev); |
1922 | TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; | 1922 | TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; |
1923 | 1923 | ||
1924 | __twa_shutdown(tw_dev); | 1924 | __twa_shutdown(tw_dev); |
@@ -2140,9 +2140,7 @@ static struct pci_driver twa_driver = { | |||
2140 | .id_table = twa_pci_tbl, | 2140 | .id_table = twa_pci_tbl, |
2141 | .probe = twa_probe, | 2141 | .probe = twa_probe, |
2142 | .remove = twa_remove, | 2142 | .remove = twa_remove, |
2143 | .driver = { | 2143 | .shutdown = twa_shutdown |
2144 | .shutdown = twa_shutdown | ||
2145 | } | ||
2146 | }; | 2144 | }; |
2147 | 2145 | ||
2148 | /* This function is called on driver initialization */ | 2146 | /* This function is called on driver initialization */ |
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index b6dc576da430..973c51fb0fe2 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c | |||
@@ -2264,9 +2264,9 @@ static void __tw_shutdown(TW_Device_Extension *tw_dev) | |||
2264 | } /* End __tw_shutdown() */ | 2264 | } /* End __tw_shutdown() */ |
2265 | 2265 | ||
2266 | /* Wrapper for __tw_shutdown */ | 2266 | /* Wrapper for __tw_shutdown */ |
2267 | static void tw_shutdown(struct device *dev) | 2267 | static void tw_shutdown(struct pci_dev *pdev) |
2268 | { | 2268 | { |
2269 | struct Scsi_Host *host = pci_get_drvdata(to_pci_dev(dev)); | 2269 | struct Scsi_Host *host = pci_get_drvdata(pdev); |
2270 | TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; | 2270 | TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata; |
2271 | 2271 | ||
2272 | __tw_shutdown(tw_dev); | 2272 | __tw_shutdown(tw_dev); |
@@ -2451,9 +2451,7 @@ static struct pci_driver tw_driver = { | |||
2451 | .id_table = tw_pci_tbl, | 2451 | .id_table = tw_pci_tbl, |
2452 | .probe = tw_probe, | 2452 | .probe = tw_probe, |
2453 | .remove = tw_remove, | 2453 | .remove = tw_remove, |
2454 | .driver = { | 2454 | .shutdown = tw_shutdown, |
2455 | .shutdown = tw_shutdown | ||
2456 | } | ||
2457 | }; | 2455 | }; |
2458 | 2456 | ||
2459 | /* This function is called on driver initialization */ | 2457 | /* This function is called on driver initialization */ |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 80d022625c82..babd48363402 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -6012,7 +6012,7 @@ static int __devinit ipr_probe(struct pci_dev *pdev, | |||
6012 | 6012 | ||
6013 | /** | 6013 | /** |
6014 | * ipr_shutdown - Shutdown handler. | 6014 | * ipr_shutdown - Shutdown handler. |
6015 | * @dev: device struct | 6015 | * @pdev: pci device struct |
6016 | * | 6016 | * |
6017 | * This function is invoked upon system shutdown/reboot. It will issue | 6017 | * This function is invoked upon system shutdown/reboot. It will issue |
6018 | * an adapter shutdown to the adapter to flush the write cache. | 6018 | * an adapter shutdown to the adapter to flush the write cache. |
@@ -6020,9 +6020,9 @@ static int __devinit ipr_probe(struct pci_dev *pdev, | |||
6020 | * Return value: | 6020 | * Return value: |
6021 | * none | 6021 | * none |
6022 | **/ | 6022 | **/ |
6023 | static void ipr_shutdown(struct device *dev) | 6023 | static void ipr_shutdown(struct pci_dev *pdev) |
6024 | { | 6024 | { |
6025 | struct ipr_ioa_cfg *ioa_cfg = pci_get_drvdata(to_pci_dev(dev)); | 6025 | struct ipr_ioa_cfg *ioa_cfg = pci_get_drvdata(pdev); |
6026 | unsigned long lock_flags = 0; | 6026 | unsigned long lock_flags = 0; |
6027 | 6027 | ||
6028 | spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); | 6028 | spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); |
@@ -6068,9 +6068,7 @@ static struct pci_driver ipr_driver = { | |||
6068 | .id_table = ipr_pci_table, | 6068 | .id_table = ipr_pci_table, |
6069 | .probe = ipr_probe, | 6069 | .probe = ipr_probe, |
6070 | .remove = ipr_remove, | 6070 | .remove = ipr_remove, |
6071 | .driver = { | 6071 | .shutdown = ipr_shutdown, |
6072 | .shutdown = ipr_shutdown, | ||
6073 | }, | ||
6074 | }; | 6072 | }; |
6075 | 6073 | ||
6076 | /** | 6074 | /** |
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index ec81532eb845..a70cdf31311c 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c | |||
@@ -5036,9 +5036,9 @@ megaraid_remove_one(struct pci_dev *pdev) | |||
5036 | } | 5036 | } |
5037 | 5037 | ||
5038 | static void | 5038 | static void |
5039 | megaraid_shutdown(struct device *dev) | 5039 | megaraid_shutdown(struct pci_dev *pdev) |
5040 | { | 5040 | { |
5041 | struct Scsi_Host *host = pci_get_drvdata(to_pci_dev(dev)); | 5041 | struct Scsi_Host *host = pci_get_drvdata(pdev); |
5042 | adapter_t *adapter = (adapter_t *)host->hostdata; | 5042 | adapter_t *adapter = (adapter_t *)host->hostdata; |
5043 | 5043 | ||
5044 | __megaraid_shutdown(adapter); | 5044 | __megaraid_shutdown(adapter); |
@@ -5070,9 +5070,7 @@ static struct pci_driver megaraid_pci_driver = { | |||
5070 | .id_table = megaraid_pci_tbl, | 5070 | .id_table = megaraid_pci_tbl, |
5071 | .probe = megaraid_probe_one, | 5071 | .probe = megaraid_probe_one, |
5072 | .remove = __devexit_p(megaraid_remove_one), | 5072 | .remove = __devexit_p(megaraid_remove_one), |
5073 | .driver = { | 5073 | .shutdown = megaraid_shutdown, |
5074 | .shutdown = megaraid_shutdown, | ||
5075 | }, | ||
5076 | }; | 5074 | }; |
5077 | 5075 | ||
5078 | static int __init megaraid_init(void) | 5076 | static int __init megaraid_init(void) |
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index c627bc408a6b..9ad142476f33 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
@@ -108,6 +108,21 @@ typedef int (*acpi_op_unbind) (struct acpi_device *device); | |||
108 | typedef int (*acpi_op_match) (struct acpi_device *device, | 108 | typedef int (*acpi_op_match) (struct acpi_device *device, |
109 | struct acpi_driver *driver); | 109 | struct acpi_driver *driver); |
110 | 110 | ||
111 | struct acpi_bus_ops { | ||
112 | u32 acpi_op_add:1; | ||
113 | u32 acpi_op_remove:1; | ||
114 | u32 acpi_op_lock:1; | ||
115 | u32 acpi_op_start:1; | ||
116 | u32 acpi_op_stop:1; | ||
117 | u32 acpi_op_suspend:1; | ||
118 | u32 acpi_op_resume:1; | ||
119 | u32 acpi_op_scan:1; | ||
120 | u32 acpi_op_bind:1; | ||
121 | u32 acpi_op_unbind:1; | ||
122 | u32 acpi_op_match:1; | ||
123 | u32 reserved:21; | ||
124 | }; | ||
125 | |||
111 | struct acpi_device_ops { | 126 | struct acpi_device_ops { |
112 | acpi_op_add add; | 127 | acpi_op_add add; |
113 | acpi_op_remove remove; | 128 | acpi_op_remove remove; |
@@ -327,9 +342,9 @@ int acpi_bus_generate_event (struct acpi_device *device, u8 type, int data); | |||
327 | int acpi_bus_receive_event (struct acpi_bus_event *event); | 342 | int acpi_bus_receive_event (struct acpi_bus_event *event); |
328 | int acpi_bus_register_driver (struct acpi_driver *driver); | 343 | int acpi_bus_register_driver (struct acpi_driver *driver); |
329 | int acpi_bus_unregister_driver (struct acpi_driver *driver); | 344 | int acpi_bus_unregister_driver (struct acpi_driver *driver); |
330 | int acpi_bus_scan (struct acpi_device *start); | ||
331 | int acpi_bus_add (struct acpi_device **child, struct acpi_device *parent, | 345 | int acpi_bus_add (struct acpi_device **child, struct acpi_device *parent, |
332 | acpi_handle handle, int type); | 346 | acpi_handle handle, int type); |
347 | int acpi_bus_start (struct acpi_device *device); | ||
333 | 348 | ||
334 | 349 | ||
335 | int acpi_match_ids (struct acpi_device *device, char *ids); | 350 | int acpi_match_ids (struct acpi_device *device, char *ids); |
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h index c62e92ec43b2..4ec722d73381 100644 --- a/include/acpi/acpi_drivers.h +++ b/include/acpi/acpi_drivers.h | |||
@@ -68,6 +68,7 @@ void acpi_pci_irq_del_prt (int segment, int bus); | |||
68 | 68 | ||
69 | struct pci_bus; | 69 | struct pci_bus; |
70 | 70 | ||
71 | acpi_status acpi_get_pci_id (acpi_handle handle, struct acpi_pci_id *id); | ||
71 | int acpi_pci_bind (struct acpi_device *device); | 72 | int acpi_pci_bind (struct acpi_device *device); |
72 | int acpi_pci_unbind (struct acpi_device *device); | 73 | int acpi_pci_unbind (struct acpi_device *device); |
73 | int acpi_pci_bind_root (struct acpi_device *device, struct acpi_pci_id *id, struct pci_bus *bus); | 74 | int acpi_pci_bind_root (struct acpi_device *device, struct acpi_pci_id *id, struct pci_bus *bus); |
diff --git a/include/asm-alpha/pci.h b/include/asm-alpha/pci.h index 0c7b57bc043a..b7806aa3785c 100644 --- a/include/asm-alpha/pci.h +++ b/include/asm-alpha/pci.h | |||
@@ -223,6 +223,25 @@ pci_dac_dma_sync_single_for_device(struct pci_dev *pdev, dma64_addr_t dma_addr, | |||
223 | /* Nothing to do. */ | 223 | /* Nothing to do. */ |
224 | } | 224 | } |
225 | 225 | ||
226 | #ifdef CONFIG_PCI | ||
227 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
228 | enum pci_dma_burst_strategy *strat, | ||
229 | unsigned long *strategy_parameter) | ||
230 | { | ||
231 | unsigned long cacheline_size; | ||
232 | u8 byte; | ||
233 | |||
234 | pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &byte); | ||
235 | if (byte == 0) | ||
236 | cacheline_size = 1024; | ||
237 | else | ||
238 | cacheline_size = (int) byte * 4; | ||
239 | |||
240 | *strat = PCI_DMA_BURST_BOUNDARY; | ||
241 | *strategy_parameter = cacheline_size; | ||
242 | } | ||
243 | #endif | ||
244 | |||
226 | /* TODO: integrate with include/asm-generic/pci.h ? */ | 245 | /* TODO: integrate with include/asm-generic/pci.h ? */ |
227 | static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) | 246 | static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) |
228 | { | 247 | { |
diff --git a/include/asm-arm/pci.h b/include/asm-arm/pci.h index 40ffaefbeb1a..e300646fe650 100644 --- a/include/asm-arm/pci.h +++ b/include/asm-arm/pci.h | |||
@@ -42,6 +42,16 @@ static inline void pcibios_penalize_isa_irq(int irq) | |||
42 | #define pci_unmap_len(PTR, LEN_NAME) ((PTR)->LEN_NAME) | 42 | #define pci_unmap_len(PTR, LEN_NAME) ((PTR)->LEN_NAME) |
43 | #define pci_unmap_len_set(PTR, LEN_NAME, VAL) (((PTR)->LEN_NAME) = (VAL)) | 43 | #define pci_unmap_len_set(PTR, LEN_NAME, VAL) (((PTR)->LEN_NAME) = (VAL)) |
44 | 44 | ||
45 | #ifdef CONFIG_PCI | ||
46 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
47 | enum pci_dma_burst_strategy *strat, | ||
48 | unsigned long *strategy_parameter) | ||
49 | { | ||
50 | *strat = PCI_DMA_BURST_INFINITY; | ||
51 | *strategy_parameter = ~0UL; | ||
52 | } | ||
53 | #endif | ||
54 | |||
45 | #define HAVE_PCI_MMAP | 55 | #define HAVE_PCI_MMAP |
46 | extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, | 56 | extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, |
47 | enum pci_mmap_state mmap_state, int write_combine); | 57 | enum pci_mmap_state mmap_state, int write_combine); |
diff --git a/include/asm-frv/pci.h b/include/asm-frv/pci.h index a6a469231f62..b4efe5e3591a 100644 --- a/include/asm-frv/pci.h +++ b/include/asm-frv/pci.h | |||
@@ -57,6 +57,16 @@ extern void pci_free_consistent(struct pci_dev *hwdev, size_t size, | |||
57 | */ | 57 | */ |
58 | #define PCI_DMA_BUS_IS_PHYS (1) | 58 | #define PCI_DMA_BUS_IS_PHYS (1) |
59 | 59 | ||
60 | #ifdef CONFIG_PCI | ||
61 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
62 | enum pci_dma_burst_strategy *strat, | ||
63 | unsigned long *strategy_parameter) | ||
64 | { | ||
65 | *strat = PCI_DMA_BURST_INFINITY; | ||
66 | *strategy_parameter = ~0UL; | ||
67 | } | ||
68 | #endif | ||
69 | |||
60 | /* | 70 | /* |
61 | * These are pretty much arbitary with the CoMEM implementation. | 71 | * These are pretty much arbitary with the CoMEM implementation. |
62 | * We have the whole address space to ourselves. | 72 | * We have the whole address space to ourselves. |
diff --git a/include/asm-i386/pci.h b/include/asm-i386/pci.h index fb749b85a739..3561899eb826 100644 --- a/include/asm-i386/pci.h +++ b/include/asm-i386/pci.h | |||
@@ -99,6 +99,16 @@ static inline void pcibios_add_platform_entries(struct pci_dev *dev) | |||
99 | { | 99 | { |
100 | } | 100 | } |
101 | 101 | ||
102 | #ifdef CONFIG_PCI | ||
103 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
104 | enum pci_dma_burst_strategy *strat, | ||
105 | unsigned long *strategy_parameter) | ||
106 | { | ||
107 | *strat = PCI_DMA_BURST_INFINITY; | ||
108 | *strategy_parameter = ~0UL; | ||
109 | } | ||
110 | #endif | ||
111 | |||
102 | #endif /* __KERNEL__ */ | 112 | #endif /* __KERNEL__ */ |
103 | 113 | ||
104 | /* implement the pci_ DMA API in terms of the generic device dma_ one */ | 114 | /* implement the pci_ DMA API in terms of the generic device dma_ one */ |
diff --git a/include/asm-ia64/iosapic.h b/include/asm-ia64/iosapic.h index 38a7a72791cc..1093f35b3b90 100644 --- a/include/asm-ia64/iosapic.h +++ b/include/asm-ia64/iosapic.h | |||
@@ -71,8 +71,11 @@ static inline void iosapic_eoi(char __iomem *iosapic, u32 vector) | |||
71 | } | 71 | } |
72 | 72 | ||
73 | extern void __init iosapic_system_init (int pcat_compat); | 73 | extern void __init iosapic_system_init (int pcat_compat); |
74 | extern void __init iosapic_init (unsigned long address, | 74 | extern int __devinit iosapic_init (unsigned long address, |
75 | unsigned int gsi_base); | 75 | unsigned int gsi_base); |
76 | #ifdef CONFIG_HOTPLUG | ||
77 | extern int iosapic_remove (unsigned int gsi_base); | ||
78 | #endif /* CONFIG_HOTPLUG */ | ||
76 | extern int gsi_to_vector (unsigned int gsi); | 79 | extern int gsi_to_vector (unsigned int gsi); |
77 | extern int gsi_to_irq (unsigned int gsi); | 80 | extern int gsi_to_irq (unsigned int gsi); |
78 | extern void iosapic_enable_intr (unsigned int vector); | 81 | extern void iosapic_enable_intr (unsigned int vector); |
@@ -94,11 +97,14 @@ extern unsigned int iosapic_version (char __iomem *addr); | |||
94 | 97 | ||
95 | extern void iosapic_pci_fixup (int); | 98 | extern void iosapic_pci_fixup (int); |
96 | #ifdef CONFIG_NUMA | 99 | #ifdef CONFIG_NUMA |
97 | extern void __init map_iosapic_to_node (unsigned int, int); | 100 | extern void __devinit map_iosapic_to_node (unsigned int, int); |
98 | #endif | 101 | #endif |
99 | #else | 102 | #else |
100 | #define iosapic_system_init(pcat_compat) do { } while (0) | 103 | #define iosapic_system_init(pcat_compat) do { } while (0) |
101 | #define iosapic_init(address,gsi_base) do { } while (0) | 104 | #define iosapic_init(address,gsi_base) (-EINVAL) |
105 | #ifdef CONFIG_HOTPLUG | ||
106 | #define iosapic_remove(gsi_base) (-ENODEV) | ||
107 | #endif /* CONFIG_HOTPLUG */ | ||
102 | #define iosapic_register_intr(gsi,polarity,trigger) (gsi) | 108 | #define iosapic_register_intr(gsi,polarity,trigger) (gsi) |
103 | #define iosapic_unregister_intr(irq) do { } while (0) | 109 | #define iosapic_unregister_intr(irq) do { } while (0) |
104 | #define iosapic_override_isa_irq(isa_irq,gsi,polarity,trigger) do { } while (0) | 110 | #define iosapic_override_isa_irq(isa_irq,gsi,polarity,trigger) do { } while (0) |
diff --git a/include/asm-ia64/pci.h b/include/asm-ia64/pci.h index a8314ee4e7d2..0c4c5d801d3f 100644 --- a/include/asm-ia64/pci.h +++ b/include/asm-ia64/pci.h | |||
@@ -82,6 +82,25 @@ extern int pcibios_prep_mwi (struct pci_dev *); | |||
82 | #define sg_dma_len(sg) ((sg)->dma_length) | 82 | #define sg_dma_len(sg) ((sg)->dma_length) |
83 | #define sg_dma_address(sg) ((sg)->dma_address) | 83 | #define sg_dma_address(sg) ((sg)->dma_address) |
84 | 84 | ||
85 | #ifdef CONFIG_PCI | ||
86 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
87 | enum pci_dma_burst_strategy *strat, | ||
88 | unsigned long *strategy_parameter) | ||
89 | { | ||
90 | unsigned long cacheline_size; | ||
91 | u8 byte; | ||
92 | |||
93 | pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &byte); | ||
94 | if (byte == 0) | ||
95 | cacheline_size = 1024; | ||
96 | else | ||
97 | cacheline_size = (int) byte * 4; | ||
98 | |||
99 | *strat = PCI_DMA_BURST_MULTIPLE; | ||
100 | *strategy_parameter = cacheline_size; | ||
101 | } | ||
102 | #endif | ||
103 | |||
85 | #define HAVE_PCI_MMAP | 104 | #define HAVE_PCI_MMAP |
86 | extern int pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma, | 105 | extern int pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma, |
87 | enum pci_mmap_state mmap_state, int write_combine); | 106 | enum pci_mmap_state mmap_state, int write_combine); |
diff --git a/include/asm-mips/pci.h b/include/asm-mips/pci.h index c9c576b48556..2d323b6e147d 100644 --- a/include/asm-mips/pci.h +++ b/include/asm-mips/pci.h | |||
@@ -130,6 +130,16 @@ extern void pci_dac_dma_sync_single_for_cpu(struct pci_dev *pdev, | |||
130 | extern void pci_dac_dma_sync_single_for_device(struct pci_dev *pdev, | 130 | extern void pci_dac_dma_sync_single_for_device(struct pci_dev *pdev, |
131 | dma64_addr_t dma_addr, size_t len, int direction); | 131 | dma64_addr_t dma_addr, size_t len, int direction); |
132 | 132 | ||
133 | #ifdef CONFIG_PCI | ||
134 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
135 | enum pci_dma_burst_strategy *strat, | ||
136 | unsigned long *strategy_parameter) | ||
137 | { | ||
138 | *strat = PCI_DMA_BURST_INFINITY; | ||
139 | *strategy_parameter = ~0UL; | ||
140 | } | ||
141 | #endif | ||
142 | |||
133 | extern void pcibios_resource_to_bus(struct pci_dev *dev, | 143 | extern void pcibios_resource_to_bus(struct pci_dev *dev, |
134 | struct pci_bus_region *region, struct resource *res); | 144 | struct pci_bus_region *region, struct resource *res); |
135 | 145 | ||
diff --git a/include/asm-parisc/pci.h b/include/asm-parisc/pci.h index 0763c2982fb0..ee741c150176 100644 --- a/include/asm-parisc/pci.h +++ b/include/asm-parisc/pci.h | |||
@@ -230,6 +230,25 @@ extern inline void pcibios_register_hba(struct pci_hba_data *x) | |||
230 | /* export the pci_ DMA API in terms of the dma_ one */ | 230 | /* export the pci_ DMA API in terms of the dma_ one */ |
231 | #include <asm-generic/pci-dma-compat.h> | 231 | #include <asm-generic/pci-dma-compat.h> |
232 | 232 | ||
233 | #ifdef CONFIG_PCI | ||
234 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
235 | enum pci_dma_burst_strategy *strat, | ||
236 | unsigned long *strategy_parameter) | ||
237 | { | ||
238 | unsigned long cacheline_size; | ||
239 | u8 byte; | ||
240 | |||
241 | pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &byte); | ||
242 | if (byte == 0) | ||
243 | cacheline_size = 1024; | ||
244 | else | ||
245 | cacheline_size = (int) byte * 4; | ||
246 | |||
247 | *strat = PCI_DMA_BURST_MULTIPLE; | ||
248 | *strategy_parameter = cacheline_size; | ||
249 | } | ||
250 | #endif | ||
251 | |||
233 | extern void | 252 | extern void |
234 | pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, | 253 | pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, |
235 | struct resource *res); | 254 | struct resource *res); |
diff --git a/include/asm-ppc/pci.h b/include/asm-ppc/pci.h index ce5ae6d048f5..db0a2a0ec74d 100644 --- a/include/asm-ppc/pci.h +++ b/include/asm-ppc/pci.h | |||
@@ -69,6 +69,16 @@ extern unsigned long pci_bus_to_phys(unsigned int ba, int busnr); | |||
69 | #define pci_unmap_len(PTR, LEN_NAME) (0) | 69 | #define pci_unmap_len(PTR, LEN_NAME) (0) |
70 | #define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0) | 70 | #define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0) |
71 | 71 | ||
72 | #ifdef CONFIG_PCI | ||
73 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
74 | enum pci_dma_burst_strategy *strat, | ||
75 | unsigned long *strategy_parameter) | ||
76 | { | ||
77 | *strat = PCI_DMA_BURST_INFINITY; | ||
78 | *strategy_parameter = ~0UL; | ||
79 | } | ||
80 | #endif | ||
81 | |||
72 | /* | 82 | /* |
73 | * At present there are very few 32-bit PPC machines that can have | 83 | * At present there are very few 32-bit PPC machines that can have |
74 | * memory above the 4GB point, and we don't support that. | 84 | * memory above the 4GB point, and we don't support that. |
@@ -103,6 +113,12 @@ extern pgprot_t pci_phys_mem_access_prot(struct file *file, | |||
103 | unsigned long size, | 113 | unsigned long size, |
104 | pgprot_t prot); | 114 | pgprot_t prot); |
105 | 115 | ||
116 | #define HAVE_ARCH_PCI_RESOURCE_TO_USER | ||
117 | extern void pci_resource_to_user(const struct pci_dev *dev, int bar, | ||
118 | const struct resource *rsrc, | ||
119 | u64 *start, u64 *end); | ||
120 | |||
121 | |||
106 | #endif /* __KERNEL__ */ | 122 | #endif /* __KERNEL__ */ |
107 | 123 | ||
108 | #endif /* __PPC_PCI_H */ | 124 | #endif /* __PPC_PCI_H */ |
diff --git a/include/asm-ppc64/pci.h b/include/asm-ppc64/pci.h index 6cd593f660a0..d12dfce21e20 100644 --- a/include/asm-ppc64/pci.h +++ b/include/asm-ppc64/pci.h | |||
@@ -78,6 +78,25 @@ static inline int pci_dac_dma_supported(struct pci_dev *hwdev,u64 mask) | |||
78 | return 0; | 78 | return 0; |
79 | } | 79 | } |
80 | 80 | ||
81 | #ifdef CONFIG_PCI | ||
82 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
83 | enum pci_dma_burst_strategy *strat, | ||
84 | unsigned long *strategy_parameter) | ||
85 | { | ||
86 | unsigned long cacheline_size; | ||
87 | u8 byte; | ||
88 | |||
89 | pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &byte); | ||
90 | if (byte == 0) | ||
91 | cacheline_size = 1024; | ||
92 | else | ||
93 | cacheline_size = (int) byte * 4; | ||
94 | |||
95 | *strat = PCI_DMA_BURST_MULTIPLE; | ||
96 | *strategy_parameter = cacheline_size; | ||
97 | } | ||
98 | #endif | ||
99 | |||
81 | extern int pci_domain_nr(struct pci_bus *bus); | 100 | extern int pci_domain_nr(struct pci_bus *bus); |
82 | 101 | ||
83 | /* Decide whether to display the domain number in /proc */ | 102 | /* Decide whether to display the domain number in /proc */ |
@@ -136,6 +155,13 @@ extern pgprot_t pci_phys_mem_access_prot(struct file *file, | |||
136 | unsigned long size, | 155 | unsigned long size, |
137 | pgprot_t prot); | 156 | pgprot_t prot); |
138 | 157 | ||
158 | #ifdef CONFIG_PPC_MULTIPLATFORM | ||
159 | #define HAVE_ARCH_PCI_RESOURCE_TO_USER | ||
160 | extern void pci_resource_to_user(const struct pci_dev *dev, int bar, | ||
161 | const struct resource *rsrc, | ||
162 | u64 *start, u64 *end); | ||
163 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | ||
164 | |||
139 | 165 | ||
140 | #endif /* __KERNEL__ */ | 166 | #endif /* __KERNEL__ */ |
141 | 167 | ||
diff --git a/include/asm-sh/pci.h b/include/asm-sh/pci.h index 9c3b63d0105e..26044889c770 100644 --- a/include/asm-sh/pci.h +++ b/include/asm-sh/pci.h | |||
@@ -96,6 +96,16 @@ static inline void pcibios_penalize_isa_irq(int irq) | |||
96 | #define sg_dma_address(sg) (virt_to_bus((sg)->dma_address)) | 96 | #define sg_dma_address(sg) (virt_to_bus((sg)->dma_address)) |
97 | #define sg_dma_len(sg) ((sg)->length) | 97 | #define sg_dma_len(sg) ((sg)->length) |
98 | 98 | ||
99 | #ifdef CONFIG_PCI | ||
100 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
101 | enum pci_dma_burst_strategy *strat, | ||
102 | unsigned long *strategy_parameter) | ||
103 | { | ||
104 | *strat = PCI_DMA_BURST_INFINITY; | ||
105 | *strategy_parameter = ~0UL; | ||
106 | } | ||
107 | #endif | ||
108 | |||
99 | /* Board-specific fixup routines. */ | 109 | /* Board-specific fixup routines. */ |
100 | extern void pcibios_fixup(void); | 110 | extern void pcibios_fixup(void); |
101 | extern void pcibios_fixup_irqs(void); | 111 | extern void pcibios_fixup_irqs(void); |
diff --git a/include/asm-sh64/pci.h b/include/asm-sh64/pci.h index 8cc14e139750..c68870e02d91 100644 --- a/include/asm-sh64/pci.h +++ b/include/asm-sh64/pci.h | |||
@@ -86,6 +86,16 @@ static inline void pcibios_penalize_isa_irq(int irq) | |||
86 | #define sg_dma_address(sg) ((sg)->dma_address) | 86 | #define sg_dma_address(sg) ((sg)->dma_address) |
87 | #define sg_dma_len(sg) ((sg)->length) | 87 | #define sg_dma_len(sg) ((sg)->length) |
88 | 88 | ||
89 | #ifdef CONFIG_PCI | ||
90 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
91 | enum pci_dma_burst_strategy *strat, | ||
92 | unsigned long *strategy_parameter) | ||
93 | { | ||
94 | *strat = PCI_DMA_BURST_INFINITY; | ||
95 | *strategy_parameter = ~0UL; | ||
96 | } | ||
97 | #endif | ||
98 | |||
89 | /* Board-specific fixup routines. */ | 99 | /* Board-specific fixup routines. */ |
90 | extern void pcibios_fixup(void); | 100 | extern void pcibios_fixup(void); |
91 | extern void pcibios_fixup_irqs(void); | 101 | extern void pcibios_fixup_irqs(void); |
diff --git a/include/asm-sparc/pci.h b/include/asm-sparc/pci.h index d200a25a7373..44bb38758c96 100644 --- a/include/asm-sparc/pci.h +++ b/include/asm-sparc/pci.h | |||
@@ -144,6 +144,16 @@ extern inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask) | |||
144 | 144 | ||
145 | #define pci_dac_dma_supported(dev, mask) (0) | 145 | #define pci_dac_dma_supported(dev, mask) (0) |
146 | 146 | ||
147 | #ifdef CONFIG_PCI | ||
148 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
149 | enum pci_dma_burst_strategy *strat, | ||
150 | unsigned long *strategy_parameter) | ||
151 | { | ||
152 | *strat = PCI_DMA_BURST_INFINITY; | ||
153 | *strategy_parameter = ~0UL; | ||
154 | } | ||
155 | #endif | ||
156 | |||
147 | static inline void pcibios_add_platform_entries(struct pci_dev *dev) | 157 | static inline void pcibios_add_platform_entries(struct pci_dev *dev) |
148 | { | 158 | { |
149 | } | 159 | } |
diff --git a/include/asm-sparc64/pci.h b/include/asm-sparc64/pci.h index 2a0c85cd1c11..84e41c1ef3f8 100644 --- a/include/asm-sparc64/pci.h +++ b/include/asm-sparc64/pci.h | |||
@@ -220,6 +220,25 @@ static inline int pci_dma_mapping_error(dma_addr_t dma_addr) | |||
220 | return (dma_addr == PCI_DMA_ERROR_CODE); | 220 | return (dma_addr == PCI_DMA_ERROR_CODE); |
221 | } | 221 | } |
222 | 222 | ||
223 | #ifdef CONFIG_PCI | ||
224 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
225 | enum pci_dma_burst_strategy *strat, | ||
226 | unsigned long *strategy_parameter) | ||
227 | { | ||
228 | unsigned long cacheline_size; | ||
229 | u8 byte; | ||
230 | |||
231 | pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &byte); | ||
232 | if (byte == 0) | ||
233 | cacheline_size = 1024; | ||
234 | else | ||
235 | cacheline_size = (int) byte * 4; | ||
236 | |||
237 | *strat = PCI_DMA_BURST_BOUNDARY; | ||
238 | *strategy_parameter = cacheline_size; | ||
239 | } | ||
240 | #endif | ||
241 | |||
223 | /* Return the index of the PCI controller for device PDEV. */ | 242 | /* Return the index of the PCI controller for device PDEV. */ |
224 | 243 | ||
225 | extern int pci_domain_nr(struct pci_bus *bus); | 244 | extern int pci_domain_nr(struct pci_bus *bus); |
diff --git a/include/asm-v850/pci.h b/include/asm-v850/pci.h index e41941447b49..8e79be0fe99d 100644 --- a/include/asm-v850/pci.h +++ b/include/asm-v850/pci.h | |||
@@ -81,6 +81,16 @@ extern void | |||
81 | pci_free_consistent (struct pci_dev *pdev, size_t size, void *cpu_addr, | 81 | pci_free_consistent (struct pci_dev *pdev, size_t size, void *cpu_addr, |
82 | dma_addr_t dma_addr); | 82 | dma_addr_t dma_addr); |
83 | 83 | ||
84 | #ifdef CONFIG_PCI | ||
85 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
86 | enum pci_dma_burst_strategy *strat, | ||
87 | unsigned long *strategy_parameter) | ||
88 | { | ||
89 | *strat = PCI_DMA_BURST_INFINITY; | ||
90 | *strategy_parameter = ~0UL; | ||
91 | } | ||
92 | #endif | ||
93 | |||
84 | static inline void pcibios_add_platform_entries(struct pci_dev *dev) | 94 | static inline void pcibios_add_platform_entries(struct pci_dev *dev) |
85 | { | 95 | { |
86 | } | 96 | } |
diff --git a/include/asm-x86_64/pci.h b/include/asm-x86_64/pci.h index 8712520ca47f..c1961db88fac 100644 --- a/include/asm-x86_64/pci.h +++ b/include/asm-x86_64/pci.h | |||
@@ -123,6 +123,16 @@ pci_dac_dma_sync_single_for_device(struct pci_dev *pdev, dma64_addr_t dma_addr, | |||
123 | flush_write_buffers(); | 123 | flush_write_buffers(); |
124 | } | 124 | } |
125 | 125 | ||
126 | #ifdef CONFIG_PCI | ||
127 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, | ||
128 | enum pci_dma_burst_strategy *strat, | ||
129 | unsigned long *strategy_parameter) | ||
130 | { | ||
131 | *strat = PCI_DMA_BURST_INFINITY; | ||
132 | *strategy_parameter = ~0UL; | ||
133 | } | ||
134 | #endif | ||
135 | |||
126 | #define HAVE_PCI_MMAP | 136 | #define HAVE_PCI_MMAP |
127 | extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, | 137 | extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, |
128 | enum pci_mmap_state mmap_state, int write_combine); | 138 | enum pci_mmap_state mmap_state, int write_combine); |
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index b123cc08773d..ef8483673aa3 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
@@ -342,11 +342,19 @@ struct acpi_table_ecdt { | |||
342 | 342 | ||
343 | /* PCI MMCONFIG */ | 343 | /* PCI MMCONFIG */ |
344 | 344 | ||
345 | /* Defined in PCI Firmware Specification 3.0 */ | ||
346 | struct acpi_table_mcfg_config { | ||
347 | u32 base_address; | ||
348 | u32 base_reserved; | ||
349 | u16 pci_segment_group_number; | ||
350 | u8 start_bus_number; | ||
351 | u8 end_bus_number; | ||
352 | u8 reserved[4]; | ||
353 | } __attribute__ ((packed)); | ||
345 | struct acpi_table_mcfg { | 354 | struct acpi_table_mcfg { |
346 | struct acpi_table_header header; | 355 | struct acpi_table_header header; |
347 | u8 reserved[8]; | 356 | u8 reserved[8]; |
348 | u32 base_address; | 357 | struct acpi_table_mcfg_config config[0]; |
349 | u32 base_reserved; | ||
350 | } __attribute__ ((packed)); | 358 | } __attribute__ ((packed)); |
351 | 359 | ||
352 | /* Table Handlers */ | 360 | /* Table Handlers */ |
@@ -391,6 +399,7 @@ int acpi_table_parse (enum acpi_table_id id, acpi_table_handler handler); | |||
391 | int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header); | 399 | int acpi_get_table_header_early (enum acpi_table_id id, struct acpi_table_header **header); |
392 | int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries); | 400 | int acpi_table_parse_madt (enum acpi_madt_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries); |
393 | int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries); | 401 | int acpi_table_parse_srat (enum acpi_srat_entry_id id, acpi_madt_entry_handler handler, unsigned int max_entries); |
402 | int acpi_parse_mcfg (unsigned long phys_addr, unsigned long size); | ||
394 | void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr); | 403 | void acpi_table_print (struct acpi_table_header *header, unsigned long phys_addr); |
395 | void acpi_table_print_madt_entry (acpi_table_entry_header *madt); | 404 | void acpi_table_print_madt_entry (acpi_table_entry_header *madt); |
396 | void acpi_table_print_srat_entry (acpi_table_entry_header *srat); | 405 | void acpi_table_print_srat_entry (acpi_table_entry_header *srat); |
@@ -407,9 +416,13 @@ int acpi_map_lsapic(acpi_handle handle, int *pcpu); | |||
407 | int acpi_unmap_lsapic(int cpu); | 416 | int acpi_unmap_lsapic(int cpu); |
408 | #endif /* CONFIG_ACPI_HOTPLUG_CPU */ | 417 | #endif /* CONFIG_ACPI_HOTPLUG_CPU */ |
409 | 418 | ||
419 | int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base); | ||
420 | int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base); | ||
421 | |||
410 | extern int acpi_mp_config; | 422 | extern int acpi_mp_config; |
411 | 423 | ||
412 | extern u32 pci_mmcfg_base_addr; | 424 | extern struct acpi_table_mcfg_config *pci_mmcfg_config; |
425 | extern int pci_mmcfg_config_num; | ||
413 | 426 | ||
414 | extern int sbf_port ; | 427 | extern int sbf_port ; |
415 | 428 | ||
diff --git a/include/linux/pci.h b/include/linux/pci.h index b5238bd18830..66798b46f308 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -734,16 +734,20 @@ void pcibios_update_irq(struct pci_dev *, int irq); | |||
734 | /* Generic PCI functions used internally */ | 734 | /* Generic PCI functions used internally */ |
735 | 735 | ||
736 | extern struct pci_bus *pci_find_bus(int domain, int busnr); | 736 | extern struct pci_bus *pci_find_bus(int domain, int busnr); |
737 | void pci_bus_add_devices(struct pci_bus *bus); | ||
737 | struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata); | 738 | struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata); |
738 | static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata) | 739 | static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata) |
739 | { | 740 | { |
740 | return pci_scan_bus_parented(NULL, bus, ops, sysdata); | 741 | struct pci_bus *root_bus; |
742 | root_bus = pci_scan_bus_parented(NULL, bus, ops, sysdata); | ||
743 | if (root_bus) | ||
744 | pci_bus_add_devices(root_bus); | ||
745 | return root_bus; | ||
741 | } | 746 | } |
742 | int pci_scan_slot(struct pci_bus *bus, int devfn); | 747 | int pci_scan_slot(struct pci_bus *bus, int devfn); |
743 | struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn); | 748 | struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn); |
744 | unsigned int pci_scan_child_bus(struct pci_bus *bus); | 749 | unsigned int pci_scan_child_bus(struct pci_bus *bus); |
745 | void pci_bus_add_device(struct pci_dev *dev); | 750 | void pci_bus_add_device(struct pci_dev *dev); |
746 | void pci_bus_add_devices(struct pci_bus *bus); | ||
747 | void pci_name_device(struct pci_dev *dev); | 751 | void pci_name_device(struct pci_dev *dev); |
748 | char *pci_class_name(u32 class); | 752 | char *pci_class_name(u32 class); |
749 | void pci_read_bridge_bases(struct pci_bus *child); | 753 | void pci_read_bridge_bases(struct pci_bus *child); |
@@ -870,6 +874,15 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass | |||
870 | #define pci_pool_alloc(pool, flags, handle) dma_pool_alloc(pool, flags, handle) | 874 | #define pci_pool_alloc(pool, flags, handle) dma_pool_alloc(pool, flags, handle) |
871 | #define pci_pool_free(pool, vaddr, addr) dma_pool_free(pool, vaddr, addr) | 875 | #define pci_pool_free(pool, vaddr, addr) dma_pool_free(pool, vaddr, addr) |
872 | 876 | ||
877 | enum pci_dma_burst_strategy { | ||
878 | PCI_DMA_BURST_INFINITY, /* make bursts as large as possible, | ||
879 | strategy_parameter is N/A */ | ||
880 | PCI_DMA_BURST_BOUNDARY, /* disconnect at every strategy_parameter | ||
881 | byte boundaries */ | ||
882 | PCI_DMA_BURST_MULTIPLE, /* disconnect at some multiple of | ||
883 | strategy_parameter byte boundaries */ | ||
884 | }; | ||
885 | |||
873 | #if defined(CONFIG_ISA) || defined(CONFIG_EISA) | 886 | #if defined(CONFIG_ISA) || defined(CONFIG_EISA) |
874 | extern struct pci_dev *isa_bridge; | 887 | extern struct pci_dev *isa_bridge; |
875 | #endif | 888 | #endif |
@@ -972,6 +985,8 @@ static inline int pci_proc_domain(struct pci_bus *bus) | |||
972 | } | 985 | } |
973 | #endif | 986 | #endif |
974 | 987 | ||
988 | #define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0) | ||
989 | |||
975 | #endif /* !CONFIG_PCI */ | 990 | #endif /* !CONFIG_PCI */ |
976 | 991 | ||
977 | /* these helpers provide future and backwards compatibility | 992 | /* these helpers provide future and backwards compatibility |
@@ -1016,6 +1031,20 @@ static inline char *pci_name(struct pci_dev *pdev) | |||
1016 | #define pci_pretty_name(dev) "" | 1031 | #define pci_pretty_name(dev) "" |
1017 | #endif | 1032 | #endif |
1018 | 1033 | ||
1034 | |||
1035 | /* Some archs don't want to expose struct resource to userland as-is | ||
1036 | * in sysfs and /proc | ||
1037 | */ | ||
1038 | #ifndef HAVE_ARCH_PCI_RESOURCE_TO_USER | ||
1039 | static inline void pci_resource_to_user(const struct pci_dev *dev, int bar, | ||
1040 | const struct resource *rsrc, u64 *start, u64 *end) | ||
1041 | { | ||
1042 | *start = rsrc->start; | ||
1043 | *end = rsrc->end; | ||
1044 | } | ||
1045 | #endif /* HAVE_ARCH_PCI_RESOURCE_TO_USER */ | ||
1046 | |||
1047 | |||
1019 | /* | 1048 | /* |
1020 | * The world is not perfect and supplies us with broken PCI devices. | 1049 | * The world is not perfect and supplies us with broken PCI devices. |
1021 | * For at least a part of these bugs we need a work-around, so both | 1050 | * For at least a part of these bugs we need a work-around, so both |
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 1e0bc6a8d653..c3ee1ae4545a 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h | |||
@@ -62,6 +62,8 @@ | |||
62 | 62 | ||
63 | #define PCI_BASE_CLASS_SYSTEM 0x08 | 63 | #define PCI_BASE_CLASS_SYSTEM 0x08 |
64 | #define PCI_CLASS_SYSTEM_PIC 0x0800 | 64 | #define PCI_CLASS_SYSTEM_PIC 0x0800 |
65 | #define PCI_CLASS_SYSTEM_PIC_IOAPIC 0x080010 | ||
66 | #define PCI_CLASS_SYSTEM_PIC_IOXAPIC 0x080020 | ||
65 | #define PCI_CLASS_SYSTEM_DMA 0x0801 | 67 | #define PCI_CLASS_SYSTEM_DMA 0x0801 |
66 | #define PCI_CLASS_SYSTEM_TIMER 0x0802 | 68 | #define PCI_CLASS_SYSTEM_TIMER 0x0802 |
67 | #define PCI_CLASS_SYSTEM_RTC 0x0803 | 69 | #define PCI_CLASS_SYSTEM_RTC 0x0803 |