diff options
51 files changed, 889 insertions, 1212 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 363e348bff9b..dd80599559a5 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -2227,6 +2227,21 @@ bytes respectively. Such letter suffixes can also be entirely omitted. | |||
2227 | This sorting is done to get a device | 2227 | This sorting is done to get a device |
2228 | order compatible with older (<= 2.4) kernels. | 2228 | order compatible with older (<= 2.4) kernels. |
2229 | nobfsort Don't sort PCI devices into breadth-first order. | 2229 | nobfsort Don't sort PCI devices into breadth-first order. |
2230 | pcie_bus_tune_off Disable PCIe MPS (Max Payload Size) | ||
2231 | tuning and use the BIOS-configured MPS defaults. | ||
2232 | pcie_bus_safe Set every device's MPS to the largest value | ||
2233 | supported by all devices below the root complex. | ||
2234 | pcie_bus_perf Set device MPS to the largest allowable MPS | ||
2235 | based on its parent bus. Also set MRRS (Max | ||
2236 | Read Request Size) to the largest supported | ||
2237 | value (no larger than the MPS that the device | ||
2238 | or bus can support) for best performance. | ||
2239 | pcie_bus_peer2peer Set every device's MPS to 128B, which | ||
2240 | every device is guaranteed to support. This | ||
2241 | configuration allows peer-to-peer DMA between | ||
2242 | any pair of devices, possibly at the cost of | ||
2243 | reduced performance. This also guarantees | ||
2244 | that hot-added devices will work. | ||
2230 | cbiosize=nn[KMG] The fixed amount of bus space which is | 2245 | cbiosize=nn[KMG] The fixed amount of bus space which is |
2231 | reserved for the CardBus bridge's IO window. | 2246 | reserved for the CardBus bridge's IO window. |
2232 | The default value is 256 bytes. | 2247 | The default value is 256 bytes. |
@@ -2248,6 +2263,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted. | |||
2248 | the default. | 2263 | the default. |
2249 | off: Turn ECRC off | 2264 | off: Turn ECRC off |
2250 | on: Turn ECRC on. | 2265 | on: Turn ECRC on. |
2266 | hpiosize=nn[KMG] The fixed amount of bus space which is | ||
2267 | reserved for hotplug bridge's IO window. | ||
2268 | Default size is 256 bytes. | ||
2269 | hpmemsize=nn[KMG] The fixed amount of bus space which is | ||
2270 | reserved for hotplug bridge's memory window. | ||
2271 | Default size is 2 megabytes. | ||
2251 | realloc= Enable/disable reallocating PCI bridge resources | 2272 | realloc= Enable/disable reallocating PCI bridge resources |
2252 | if allocations done by BIOS are too small to | 2273 | if allocations done by BIOS are too small to |
2253 | accommodate resources required by all child | 2274 | accommodate resources required by all child |
diff --git a/arch/frv/mb93090-mb00/pci-frv.h b/arch/frv/mb93090-mb00/pci-frv.h index 089eeba4f3bc..76c4e73d643d 100644 --- a/arch/frv/mb93090-mb00/pci-frv.h +++ b/arch/frv/mb93090-mb00/pci-frv.h | |||
@@ -31,7 +31,6 @@ void pcibios_resource_survey(void); | |||
31 | /* pci-vdk.c */ | 31 | /* pci-vdk.c */ |
32 | 32 | ||
33 | extern int __nongpreldata pcibios_last_bus; | 33 | extern int __nongpreldata pcibios_last_bus; |
34 | extern struct pci_bus *__nongpreldata pci_root_bus; | ||
35 | extern struct pci_ops *__nongpreldata pci_root_ops; | 34 | extern struct pci_ops *__nongpreldata pci_root_ops; |
36 | 35 | ||
37 | /* pci-irq.c */ | 36 | /* pci-irq.c */ |
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c index 71e9bcf58105..1152a1e3cabb 100644 --- a/arch/frv/mb93090-mb00/pci-vdk.c +++ b/arch/frv/mb93090-mb00/pci-vdk.c | |||
@@ -26,7 +26,6 @@ | |||
26 | unsigned int __nongpreldata pci_probe = 1; | 26 | unsigned int __nongpreldata pci_probe = 1; |
27 | 27 | ||
28 | int __nongpreldata pcibios_last_bus = -1; | 28 | int __nongpreldata pcibios_last_bus = -1; |
29 | struct pci_bus *__nongpreldata pci_root_bus; | ||
30 | struct pci_ops *__nongpreldata pci_root_ops; | 29 | struct pci_ops *__nongpreldata pci_root_ops; |
31 | 30 | ||
32 | /* | 31 | /* |
@@ -416,8 +415,7 @@ int __init pcibios_init(void) | |||
416 | printk("PCI: Probing PCI hardware\n"); | 415 | printk("PCI: Probing PCI hardware\n"); |
417 | pci_add_resource(&resources, &pci_ioport_resource); | 416 | pci_add_resource(&resources, &pci_ioport_resource); |
418 | pci_add_resource(&resources, &pci_iomem_resource); | 417 | pci_add_resource(&resources, &pci_iomem_resource); |
419 | pci_root_bus = pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, | 418 | pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources); |
420 | &resources); | ||
421 | 419 | ||
422 | pcibios_irq_init(); | 420 | pcibios_irq_init(); |
423 | pcibios_fixup_peer_bridges(); | 421 | pcibios_fixup_peer_bridges(); |
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 5faa66c5c2a8..00e59c7ad3c0 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c | |||
@@ -396,6 +396,14 @@ out1: | |||
396 | return NULL; | 396 | return NULL; |
397 | } | 397 | } |
398 | 398 | ||
399 | int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) | ||
400 | { | ||
401 | struct pci_controller *controller = bridge->bus->sysdata; | ||
402 | |||
403 | ACPI_HANDLE_SET(&bridge->dev, controller->acpi_handle); | ||
404 | return 0; | ||
405 | } | ||
406 | |||
399 | static int __devinit is_valid_resource(struct pci_dev *dev, int idx) | 407 | static int __devinit is_valid_resource(struct pci_dev *dev, int idx) |
400 | { | 408 | { |
401 | unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM; | 409 | unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM; |
diff --git a/arch/mn10300/unit-asb2305/pci-asb2305.h b/arch/mn10300/unit-asb2305/pci-asb2305.h index 1194fe486b01..7fa66a0e4624 100644 --- a/arch/mn10300/unit-asb2305/pci-asb2305.h +++ b/arch/mn10300/unit-asb2305/pci-asb2305.h | |||
@@ -36,7 +36,6 @@ extern void pcibios_resource_survey(void); | |||
36 | /* pci.c */ | 36 | /* pci.c */ |
37 | 37 | ||
38 | extern int pcibios_last_bus; | 38 | extern int pcibios_last_bus; |
39 | extern struct pci_bus *pci_root_bus; | ||
40 | extern struct pci_ops *pci_root_ops; | 39 | extern struct pci_ops *pci_root_ops; |
41 | 40 | ||
42 | extern struct irq_routing_table *pcibios_get_irq_routing_table(void); | 41 | extern struct irq_routing_table *pcibios_get_irq_routing_table(void); |
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c index e2059486d3f8..426bf51605f3 100644 --- a/arch/mn10300/unit-asb2305/pci.c +++ b/arch/mn10300/unit-asb2305/pci.c | |||
@@ -24,7 +24,6 @@ | |||
24 | unsigned int pci_probe = 1; | 24 | unsigned int pci_probe = 1; |
25 | 25 | ||
26 | int pcibios_last_bus = -1; | 26 | int pcibios_last_bus = -1; |
27 | struct pci_bus *pci_root_bus; | ||
28 | struct pci_ops *pci_root_ops; | 27 | struct pci_ops *pci_root_ops; |
29 | 28 | ||
30 | /* | 29 | /* |
@@ -377,8 +376,7 @@ static int __init pcibios_init(void) | |||
377 | 376 | ||
378 | pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset); | 377 | pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset); |
379 | pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset); | 378 | pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset); |
380 | pci_root_bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, | 379 | pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources); |
381 | &resources); | ||
382 | 380 | ||
383 | pcibios_irq_init(); | 381 | pcibios_irq_init(); |
384 | pcibios_fixup_irqs(); | 382 | pcibios_fixup_irqs(); |
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h index dba7805176bf..9f437e97e9e8 100644 --- a/arch/x86/include/asm/pci.h +++ b/arch/x86/include/asm/pci.h | |||
@@ -14,6 +14,9 @@ | |||
14 | struct pci_sysdata { | 14 | struct pci_sysdata { |
15 | int domain; /* PCI domain */ | 15 | int domain; /* PCI domain */ |
16 | int node; /* NUMA node */ | 16 | int node; /* NUMA node */ |
17 | #ifdef CONFIG_ACPI | ||
18 | void *acpi; /* ACPI-specific data */ | ||
19 | #endif | ||
17 | #ifdef CONFIG_X86_64 | 20 | #ifdef CONFIG_X86_64 |
18 | void *iommu; /* IOMMU private data */ | 21 | void *iommu; /* IOMMU private data */ |
19 | #endif | 22 | #endif |
diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h index 73e8eeff22ee..0126f104f0a5 100644 --- a/arch/x86/include/asm/pci_x86.h +++ b/arch/x86/include/asm/pci_x86.h | |||
@@ -54,7 +54,6 @@ void pcibios_set_cache_line_size(void); | |||
54 | /* pci-pc.c */ | 54 | /* pci-pc.c */ |
55 | 55 | ||
56 | extern int pcibios_last_bus; | 56 | extern int pcibios_last_bus; |
57 | extern struct pci_bus *pci_root_bus; | ||
58 | extern struct pci_ops pci_root_ops; | 57 | extern struct pci_ops pci_root_ops; |
59 | 58 | ||
60 | void pcibios_scan_specific_bus(int busn); | 59 | void pcibios_scan_specific_bus(int busn); |
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index 0c01261fe5a8..3d49094ed3e8 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c | |||
@@ -522,6 +522,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root) | |||
522 | sd = &info->sd; | 522 | sd = &info->sd; |
523 | sd->domain = domain; | 523 | sd->domain = domain; |
524 | sd->node = node; | 524 | sd->node = node; |
525 | sd->acpi = device->handle; | ||
525 | /* | 526 | /* |
526 | * Maybe the desired pci bus has been already scanned. In such case | 527 | * Maybe the desired pci bus has been already scanned. In such case |
527 | * it is unnecessary to scan the pci bus with the given domain,busnum. | 528 | * it is unnecessary to scan the pci bus with the given domain,busnum. |
@@ -593,6 +594,14 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root) | |||
593 | return bus; | 594 | return bus; |
594 | } | 595 | } |
595 | 596 | ||
597 | int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) | ||
598 | { | ||
599 | struct pci_sysdata *sd = bridge->bus->sysdata; | ||
600 | |||
601 | ACPI_HANDLE_SET(&bridge->dev, sd->acpi); | ||
602 | return 0; | ||
603 | } | ||
604 | |||
596 | int __init pci_acpi_init(void) | 605 | int __init pci_acpi_init(void) |
597 | { | 606 | { |
598 | struct pci_dev *dev = NULL; | 607 | struct pci_dev *dev = NULL; |
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 412e1286d1fc..505731b139f4 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c | |||
@@ -34,7 +34,6 @@ int noioapicreroute = 1; | |||
34 | #endif | 34 | #endif |
35 | int pcibios_last_bus = -1; | 35 | int pcibios_last_bus = -1; |
36 | unsigned long pirq_table_addr; | 36 | unsigned long pirq_table_addr; |
37 | struct pci_bus *pci_root_bus; | ||
38 | const struct pci_raw_ops *__read_mostly raw_pci_ops; | 37 | const struct pci_raw_ops *__read_mostly raw_pci_ops; |
39 | const struct pci_raw_ops *__read_mostly raw_pci_ext_ops; | 38 | const struct pci_raw_ops *__read_mostly raw_pci_ext_ops; |
40 | 39 | ||
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index dd8ca6f7223b..94919e307f8e 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c | |||
@@ -51,6 +51,7 @@ struct pcibios_fwaddrmap { | |||
51 | 51 | ||
52 | static LIST_HEAD(pcibios_fwaddrmappings); | 52 | static LIST_HEAD(pcibios_fwaddrmappings); |
53 | static DEFINE_SPINLOCK(pcibios_fwaddrmap_lock); | 53 | static DEFINE_SPINLOCK(pcibios_fwaddrmap_lock); |
54 | static bool pcibios_fw_addr_done; | ||
54 | 55 | ||
55 | /* Must be called with 'pcibios_fwaddrmap_lock' lock held. */ | 56 | /* Must be called with 'pcibios_fwaddrmap_lock' lock held. */ |
56 | static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup(struct pci_dev *dev) | 57 | static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup(struct pci_dev *dev) |
@@ -72,6 +73,9 @@ pcibios_save_fw_addr(struct pci_dev *dev, int idx, resource_size_t fw_addr) | |||
72 | unsigned long flags; | 73 | unsigned long flags; |
73 | struct pcibios_fwaddrmap *map; | 74 | struct pcibios_fwaddrmap *map; |
74 | 75 | ||
76 | if (pcibios_fw_addr_done) | ||
77 | return; | ||
78 | |||
75 | spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags); | 79 | spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags); |
76 | map = pcibios_fwaddrmap_lookup(dev); | 80 | map = pcibios_fwaddrmap_lookup(dev); |
77 | if (!map) { | 81 | if (!map) { |
@@ -97,6 +101,9 @@ resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx) | |||
97 | struct pcibios_fwaddrmap *map; | 101 | struct pcibios_fwaddrmap *map; |
98 | resource_size_t fw_addr = 0; | 102 | resource_size_t fw_addr = 0; |
99 | 103 | ||
104 | if (pcibios_fw_addr_done) | ||
105 | return 0; | ||
106 | |||
100 | spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags); | 107 | spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags); |
101 | map = pcibios_fwaddrmap_lookup(dev); | 108 | map = pcibios_fwaddrmap_lookup(dev); |
102 | if (map) | 109 | if (map) |
@@ -106,7 +113,7 @@ resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx) | |||
106 | return fw_addr; | 113 | return fw_addr; |
107 | } | 114 | } |
108 | 115 | ||
109 | static void pcibios_fw_addr_list_del(void) | 116 | static void __init pcibios_fw_addr_list_del(void) |
110 | { | 117 | { |
111 | unsigned long flags; | 118 | unsigned long flags; |
112 | struct pcibios_fwaddrmap *entry, *next; | 119 | struct pcibios_fwaddrmap *entry, *next; |
@@ -118,6 +125,7 @@ static void pcibios_fw_addr_list_del(void) | |||
118 | kfree(entry); | 125 | kfree(entry); |
119 | } | 126 | } |
120 | spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags); | 127 | spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags); |
128 | pcibios_fw_addr_done = true; | ||
121 | } | 129 | } |
122 | 130 | ||
123 | static int | 131 | static int |
@@ -193,46 +201,46 @@ EXPORT_SYMBOL(pcibios_align_resource); | |||
193 | * as well. | 201 | * as well. |
194 | */ | 202 | */ |
195 | 203 | ||
196 | static void __init pcibios_allocate_bus_resources(struct list_head *bus_list) | 204 | static void pcibios_allocate_bridge_resources(struct pci_dev *dev) |
197 | { | 205 | { |
198 | struct pci_bus *bus; | ||
199 | struct pci_dev *dev; | ||
200 | int idx; | 206 | int idx; |
201 | struct resource *r; | 207 | struct resource *r; |
202 | 208 | ||
203 | /* Depth-First Search on bus tree */ | 209 | for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) { |
204 | list_for_each_entry(bus, bus_list, node) { | 210 | r = &dev->resource[idx]; |
205 | if ((dev = bus->self)) { | 211 | if (!r->flags) |
206 | for (idx = PCI_BRIDGE_RESOURCES; | 212 | continue; |
207 | idx < PCI_NUM_RESOURCES; idx++) { | 213 | if (!r->start || pci_claim_resource(dev, idx) < 0) { |
208 | r = &dev->resource[idx]; | 214 | /* |
209 | if (!r->flags) | 215 | * Something is wrong with the region. |
210 | continue; | 216 | * Invalidate the resource to prevent |
211 | if (!r->start || | 217 | * child resource allocations in this |
212 | pci_claim_resource(dev, idx) < 0) { | 218 | * range. |
213 | /* | 219 | */ |
214 | * Something is wrong with the region. | 220 | r->start = r->end = 0; |
215 | * Invalidate the resource to prevent | 221 | r->flags = 0; |
216 | * child resource allocations in this | ||
217 | * range. | ||
218 | */ | ||
219 | r->start = r->end = 0; | ||
220 | r->flags = 0; | ||
221 | } | ||
222 | } | ||
223 | } | 222 | } |
224 | pcibios_allocate_bus_resources(&bus->children); | ||
225 | } | 223 | } |
226 | } | 224 | } |
227 | 225 | ||
226 | static void pcibios_allocate_bus_resources(struct pci_bus *bus) | ||
227 | { | ||
228 | struct pci_bus *child; | ||
229 | |||
230 | /* Depth-First Search on bus tree */ | ||
231 | if (bus->self) | ||
232 | pcibios_allocate_bridge_resources(bus->self); | ||
233 | list_for_each_entry(child, &bus->children, node) | ||
234 | pcibios_allocate_bus_resources(child); | ||
235 | } | ||
236 | |||
228 | struct pci_check_idx_range { | 237 | struct pci_check_idx_range { |
229 | int start; | 238 | int start; |
230 | int end; | 239 | int end; |
231 | }; | 240 | }; |
232 | 241 | ||
233 | static void __init pcibios_allocate_resources(int pass) | 242 | static void pcibios_allocate_dev_resources(struct pci_dev *dev, int pass) |
234 | { | 243 | { |
235 | struct pci_dev *dev = NULL; | ||
236 | int idx, disabled, i; | 244 | int idx, disabled, i; |
237 | u16 command; | 245 | u16 command; |
238 | struct resource *r; | 246 | struct resource *r; |
@@ -244,14 +252,13 @@ static void __init pcibios_allocate_resources(int pass) | |||
244 | #endif | 252 | #endif |
245 | }; | 253 | }; |
246 | 254 | ||
247 | for_each_pci_dev(dev) { | 255 | pci_read_config_word(dev, PCI_COMMAND, &command); |
248 | pci_read_config_word(dev, PCI_COMMAND, &command); | 256 | for (i = 0; i < ARRAY_SIZE(idx_range); i++) |
249 | for (i = 0; i < ARRAY_SIZE(idx_range); i++) | ||
250 | for (idx = idx_range[i].start; idx <= idx_range[i].end; idx++) { | 257 | for (idx = idx_range[i].start; idx <= idx_range[i].end; idx++) { |
251 | r = &dev->resource[idx]; | 258 | r = &dev->resource[idx]; |
252 | if (r->parent) /* Already allocated */ | 259 | if (r->parent) /* Already allocated */ |
253 | continue; | 260 | continue; |
254 | if (!r->start) /* Address not assigned at all */ | 261 | if (!r->start) /* Address not assigned at all */ |
255 | continue; | 262 | continue; |
256 | if (r->flags & IORESOURCE_IO) | 263 | if (r->flags & IORESOURCE_IO) |
257 | disabled = !(command & PCI_COMMAND_IO); | 264 | disabled = !(command & PCI_COMMAND_IO); |
@@ -270,44 +277,74 @@ static void __init pcibios_allocate_resources(int pass) | |||
270 | } | 277 | } |
271 | } | 278 | } |
272 | } | 279 | } |
273 | if (!pass) { | 280 | if (!pass) { |
274 | r = &dev->resource[PCI_ROM_RESOURCE]; | 281 | r = &dev->resource[PCI_ROM_RESOURCE]; |
275 | if (r->flags & IORESOURCE_ROM_ENABLE) { | 282 | if (r->flags & IORESOURCE_ROM_ENABLE) { |
276 | /* Turn the ROM off, leave the resource region, | 283 | /* Turn the ROM off, leave the resource region, |
277 | * but keep it unregistered. */ | 284 | * but keep it unregistered. */ |
278 | u32 reg; | 285 | u32 reg; |
279 | dev_dbg(&dev->dev, "disabling ROM %pR\n", r); | 286 | dev_dbg(&dev->dev, "disabling ROM %pR\n", r); |
280 | r->flags &= ~IORESOURCE_ROM_ENABLE; | 287 | r->flags &= ~IORESOURCE_ROM_ENABLE; |
281 | pci_read_config_dword(dev, | 288 | pci_read_config_dword(dev, dev->rom_base_reg, ®); |
282 | dev->rom_base_reg, ®); | 289 | pci_write_config_dword(dev, dev->rom_base_reg, |
283 | pci_write_config_dword(dev, dev->rom_base_reg, | ||
284 | reg & ~PCI_ROM_ADDRESS_ENABLE); | 290 | reg & ~PCI_ROM_ADDRESS_ENABLE); |
285 | } | ||
286 | } | 291 | } |
287 | } | 292 | } |
288 | } | 293 | } |
289 | 294 | ||
290 | static int __init pcibios_assign_resources(void) | 295 | static void pcibios_allocate_resources(struct pci_bus *bus, int pass) |
296 | { | ||
297 | struct pci_dev *dev; | ||
298 | struct pci_bus *child; | ||
299 | |||
300 | list_for_each_entry(dev, &bus->devices, bus_list) { | ||
301 | pcibios_allocate_dev_resources(dev, pass); | ||
302 | |||
303 | child = dev->subordinate; | ||
304 | if (child) | ||
305 | pcibios_allocate_resources(child, pass); | ||
306 | } | ||
307 | } | ||
308 | |||
309 | static void pcibios_allocate_dev_rom_resource(struct pci_dev *dev) | ||
291 | { | 310 | { |
292 | struct pci_dev *dev = NULL; | ||
293 | struct resource *r; | 311 | struct resource *r; |
294 | 312 | ||
295 | if (!(pci_probe & PCI_ASSIGN_ROMS)) { | 313 | /* |
296 | /* | 314 | * Try to use BIOS settings for ROMs, otherwise let |
297 | * Try to use BIOS settings for ROMs, otherwise let | 315 | * pci_assign_unassigned_resources() allocate the new |
298 | * pci_assign_unassigned_resources() allocate the new | 316 | * addresses. |
299 | * addresses. | 317 | */ |
300 | */ | 318 | r = &dev->resource[PCI_ROM_RESOURCE]; |
301 | for_each_pci_dev(dev) { | 319 | if (!r->flags || !r->start) |
302 | r = &dev->resource[PCI_ROM_RESOURCE]; | 320 | return; |
303 | if (!r->flags || !r->start) | 321 | |
304 | continue; | 322 | if (pci_claim_resource(dev, PCI_ROM_RESOURCE) < 0) { |
305 | if (pci_claim_resource(dev, PCI_ROM_RESOURCE) < 0) { | 323 | r->end -= r->start; |
306 | r->end -= r->start; | 324 | r->start = 0; |
307 | r->start = 0; | ||
308 | } | ||
309 | } | ||
310 | } | 325 | } |
326 | } | ||
327 | static void pcibios_allocate_rom_resources(struct pci_bus *bus) | ||
328 | { | ||
329 | struct pci_dev *dev; | ||
330 | struct pci_bus *child; | ||
331 | |||
332 | list_for_each_entry(dev, &bus->devices, bus_list) { | ||
333 | pcibios_allocate_dev_rom_resource(dev); | ||
334 | |||
335 | child = dev->subordinate; | ||
336 | if (child) | ||
337 | pcibios_allocate_rom_resources(child); | ||
338 | } | ||
339 | } | ||
340 | |||
341 | static int __init pcibios_assign_resources(void) | ||
342 | { | ||
343 | struct pci_bus *bus; | ||
344 | |||
345 | if (!(pci_probe & PCI_ASSIGN_ROMS)) | ||
346 | list_for_each_entry(bus, &pci_root_buses, node) | ||
347 | pcibios_allocate_rom_resources(bus); | ||
311 | 348 | ||
312 | pci_assign_unassigned_resources(); | 349 | pci_assign_unassigned_resources(); |
313 | pcibios_fw_addr_list_del(); | 350 | pcibios_fw_addr_list_del(); |
@@ -315,12 +352,32 @@ static int __init pcibios_assign_resources(void) | |||
315 | return 0; | 352 | return 0; |
316 | } | 353 | } |
317 | 354 | ||
355 | void pcibios_resource_survey_bus(struct pci_bus *bus) | ||
356 | { | ||
357 | dev_printk(KERN_DEBUG, &bus->dev, "Allocating resources\n"); | ||
358 | |||
359 | pcibios_allocate_bus_resources(bus); | ||
360 | |||
361 | pcibios_allocate_resources(bus, 0); | ||
362 | pcibios_allocate_resources(bus, 1); | ||
363 | |||
364 | if (!(pci_probe & PCI_ASSIGN_ROMS)) | ||
365 | pcibios_allocate_rom_resources(bus); | ||
366 | } | ||
367 | |||
318 | void __init pcibios_resource_survey(void) | 368 | void __init pcibios_resource_survey(void) |
319 | { | 369 | { |
370 | struct pci_bus *bus; | ||
371 | |||
320 | DBG("PCI: Allocating resources\n"); | 372 | DBG("PCI: Allocating resources\n"); |
321 | pcibios_allocate_bus_resources(&pci_root_buses); | 373 | |
322 | pcibios_allocate_resources(0); | 374 | list_for_each_entry(bus, &pci_root_buses, node) |
323 | pcibios_allocate_resources(1); | 375 | pcibios_allocate_bus_resources(bus); |
376 | |||
377 | list_for_each_entry(bus, &pci_root_buses, node) | ||
378 | pcibios_allocate_resources(bus, 0); | ||
379 | list_for_each_entry(bus, &pci_root_buses, node) | ||
380 | pcibios_allocate_resources(bus, 1); | ||
324 | 381 | ||
325 | e820_reserve_resources_late(); | 382 | e820_reserve_resources_late(); |
326 | /* | 383 | /* |
diff --git a/arch/x86/pci/legacy.c b/arch/x86/pci/legacy.c index a1df191129d3..a9e83083fb85 100644 --- a/arch/x86/pci/legacy.c +++ b/arch/x86/pci/legacy.c | |||
@@ -30,7 +30,7 @@ int __init pci_legacy_init(void) | |||
30 | } | 30 | } |
31 | 31 | ||
32 | printk("PCI: Probing PCI hardware\n"); | 32 | printk("PCI: Probing PCI hardware\n"); |
33 | pci_root_bus = pcibios_scan_root(0); | 33 | pcibios_scan_root(0); |
34 | return 0; | 34 | return 0; |
35 | } | 35 | } |
36 | 36 | ||
diff --git a/arch/x86/pci/numaq_32.c b/arch/x86/pci/numaq_32.c index 83e125b95ca6..00edfe652b72 100644 --- a/arch/x86/pci/numaq_32.c +++ b/arch/x86/pci/numaq_32.c | |||
@@ -152,7 +152,7 @@ int __init pci_numaq_init(void) | |||
152 | 152 | ||
153 | raw_pci_ops = &pci_direct_conf1_mq; | 153 | raw_pci_ops = &pci_direct_conf1_mq; |
154 | 154 | ||
155 | pci_root_bus = pcibios_scan_root(0); | 155 | pcibios_scan_root(0); |
156 | if (num_online_nodes() > 1) | 156 | if (num_online_nodes() > 1) |
157 | for_each_online_node(quad) { | 157 | for_each_online_node(quad) { |
158 | if (quad == 0) | 158 | if (quad == 0) |
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 2a4502becd13..4ee2e753306a 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -37,7 +37,7 @@ acpi-y += resource.o | |||
37 | acpi-y += processor_core.o | 37 | acpi-y += processor_core.o |
38 | acpi-y += ec.o | 38 | acpi-y += ec.o |
39 | acpi-$(CONFIG_ACPI_DOCK) += dock.o | 39 | acpi-$(CONFIG_ACPI_DOCK) += dock.o |
40 | acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o | 40 | acpi-y += pci_root.o pci_link.o pci_irq.o |
41 | acpi-y += acpi_platform.o | 41 | acpi-y += acpi_platform.o |
42 | acpi-y += power.o | 42 | acpi-y += power.o |
43 | acpi-y += event.o | 43 | acpi-y += event.o |
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index eb30e5ab4cab..15ea22fc1f5e 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c | |||
@@ -157,38 +157,26 @@ static int | |||
157 | acpi_memory_get_device(acpi_handle handle, | 157 | acpi_memory_get_device(acpi_handle handle, |
158 | struct acpi_memory_device **mem_device) | 158 | struct acpi_memory_device **mem_device) |
159 | { | 159 | { |
160 | acpi_status status; | ||
161 | acpi_handle phandle; | ||
162 | struct acpi_device *device = NULL; | 160 | struct acpi_device *device = NULL; |
163 | struct acpi_device *pdevice = NULL; | ||
164 | int result; | 161 | int result; |
165 | 162 | ||
166 | |||
167 | if (!acpi_bus_get_device(handle, &device) && device) | 163 | if (!acpi_bus_get_device(handle, &device) && device) |
168 | goto end; | 164 | goto end; |
169 | 165 | ||
170 | status = acpi_get_parent(handle, &phandle); | ||
171 | if (ACPI_FAILURE(status)) { | ||
172 | ACPI_EXCEPTION((AE_INFO, status, "Cannot find acpi parent")); | ||
173 | return -EINVAL; | ||
174 | } | ||
175 | |||
176 | /* Get the parent device */ | ||
177 | result = acpi_bus_get_device(phandle, &pdevice); | ||
178 | if (result) { | ||
179 | acpi_handle_warn(phandle, "Cannot get acpi bus device\n"); | ||
180 | return -EINVAL; | ||
181 | } | ||
182 | |||
183 | /* | 166 | /* |
184 | * Now add the notified device. This creates the acpi_device | 167 | * Now add the notified device. This creates the acpi_device |
185 | * and invokes .add function | 168 | * and invokes .add function |
186 | */ | 169 | */ |
187 | result = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE); | 170 | result = acpi_bus_scan(handle); |
188 | if (result) { | 171 | if (result) { |
189 | acpi_handle_warn(handle, "Cannot add acpi bus\n"); | 172 | acpi_handle_warn(handle, "Cannot add acpi bus\n"); |
190 | return -EINVAL; | 173 | return -EINVAL; |
191 | } | 174 | } |
175 | result = acpi_bus_get_device(handle, &device); | ||
176 | if (result) { | ||
177 | acpi_handle_warn(handle, "Missing device object\n"); | ||
178 | return -EINVAL; | ||
179 | } | ||
192 | 180 | ||
193 | end: | 181 | end: |
194 | *mem_device = acpi_driver_data(device); | 182 | *mem_device = acpi_driver_data(device); |
@@ -373,7 +361,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) | |||
373 | break; | 361 | break; |
374 | } | 362 | } |
375 | 363 | ||
376 | ej_event->handle = handle; | 364 | ej_event->device = device; |
377 | ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; | 365 | ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; |
378 | acpi_os_hotplug_execute(acpi_bus_hot_remove_device, | 366 | acpi_os_hotplug_execute(acpi_bus_hot_remove_device, |
379 | (void *)ej_event); | 367 | (void *)ej_event); |
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index 811910b50b75..cc79d3e53a39 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c | |||
@@ -135,30 +135,6 @@ static int acpi_container_remove(struct acpi_device *device, int type) | |||
135 | return status; | 135 | return status; |
136 | } | 136 | } |
137 | 137 | ||
138 | static int container_device_add(struct acpi_device **device, acpi_handle handle) | ||
139 | { | ||
140 | acpi_handle phandle; | ||
141 | struct acpi_device *pdev; | ||
142 | int result; | ||
143 | |||
144 | |||
145 | if (acpi_get_parent(handle, &phandle)) { | ||
146 | return -ENODEV; | ||
147 | } | ||
148 | |||
149 | if (acpi_bus_get_device(phandle, &pdev)) { | ||
150 | return -ENODEV; | ||
151 | } | ||
152 | |||
153 | if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE)) { | ||
154 | return -ENODEV; | ||
155 | } | ||
156 | |||
157 | result = acpi_bus_start(*device); | ||
158 | |||
159 | return result; | ||
160 | } | ||
161 | |||
162 | static void container_notify_cb(acpi_handle handle, u32 type, void *context) | 138 | static void container_notify_cb(acpi_handle handle, u32 type, void *context) |
163 | { | 139 | { |
164 | struct acpi_device *device = NULL; | 140 | struct acpi_device *device = NULL; |
@@ -190,11 +166,16 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context) | |||
190 | if (!ACPI_FAILURE(status) || device) | 166 | if (!ACPI_FAILURE(status) || device) |
191 | break; | 167 | break; |
192 | 168 | ||
193 | result = container_device_add(&device, handle); | 169 | result = acpi_bus_scan(handle); |
194 | if (result) { | 170 | if (result) { |
195 | acpi_handle_warn(handle, "Failed to add container\n"); | 171 | acpi_handle_warn(handle, "Failed to add container\n"); |
196 | break; | 172 | break; |
197 | } | 173 | } |
174 | result = acpi_bus_get_device(handle, &device); | ||
175 | if (result) { | ||
176 | acpi_handle_warn(handle, "Missing device object\n"); | ||
177 | break; | ||
178 | } | ||
198 | 179 | ||
199 | kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); | 180 | kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); |
200 | ost_code = ACPI_OST_SC_SUCCESS; | 181 | ost_code = ACPI_OST_SC_SUCCESS; |
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index f09dc987cf17..e4f6ac95595c 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c | |||
@@ -353,7 +353,7 @@ int acpi_pm_device_sleep_wake(struct device *dev, bool enable) | |||
353 | * acpi_dev_pm_get_node - Get ACPI device node for the given physical device. | 353 | * acpi_dev_pm_get_node - Get ACPI device node for the given physical device. |
354 | * @dev: Device to get the ACPI node for. | 354 | * @dev: Device to get the ACPI node for. |
355 | */ | 355 | */ |
356 | static struct acpi_device *acpi_dev_pm_get_node(struct device *dev) | 356 | struct acpi_device *acpi_dev_pm_get_node(struct device *dev) |
357 | { | 357 | { |
358 | acpi_handle handle = DEVICE_ACPI_HANDLE(dev); | 358 | acpi_handle handle = DEVICE_ACPI_HANDLE(dev); |
359 | struct acpi_device *adev; | 359 | struct acpi_device *adev; |
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index f32bd47b35e0..420d24fc9388 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c | |||
@@ -310,8 +310,6 @@ static int dock_present(struct dock_station *ds) | |||
310 | static struct acpi_device * dock_create_acpi_device(acpi_handle handle) | 310 | static struct acpi_device * dock_create_acpi_device(acpi_handle handle) |
311 | { | 311 | { |
312 | struct acpi_device *device; | 312 | struct acpi_device *device; |
313 | struct acpi_device *parent_device; | ||
314 | acpi_handle parent; | ||
315 | int ret; | 313 | int ret; |
316 | 314 | ||
317 | if (acpi_bus_get_device(handle, &device)) { | 315 | if (acpi_bus_get_device(handle, &device)) { |
@@ -319,16 +317,11 @@ static struct acpi_device * dock_create_acpi_device(acpi_handle handle) | |||
319 | * no device created for this object, | 317 | * no device created for this object, |
320 | * so we should create one. | 318 | * so we should create one. |
321 | */ | 319 | */ |
322 | acpi_get_parent(handle, &parent); | 320 | ret = acpi_bus_scan(handle); |
323 | if (acpi_bus_get_device(parent, &parent_device)) | 321 | if (ret) |
324 | parent_device = NULL; | ||
325 | |||
326 | ret = acpi_bus_add(&device, parent_device, handle, | ||
327 | ACPI_BUS_TYPE_DEVICE); | ||
328 | if (ret) { | ||
329 | pr_debug("error adding bus, %x\n", -ret); | 322 | pr_debug("error adding bus, %x\n", -ret); |
330 | return NULL; | 323 | |
331 | } | 324 | acpi_bus_get_device(handle, &device); |
332 | } | 325 | } |
333 | return device; | 326 | return device; |
334 | } | 327 | } |
@@ -346,7 +339,7 @@ static void dock_remove_acpi_device(acpi_handle handle) | |||
346 | int ret; | 339 | int ret; |
347 | 340 | ||
348 | if (!acpi_bus_get_device(handle, &device)) { | 341 | if (!acpi_bus_get_device(handle, &device)) { |
349 | ret = acpi_bus_trim(device, 1); | 342 | ret = acpi_bus_trim(device); |
350 | if (ret) | 343 | if (ret) |
351 | pr_debug("error removing bus, %x\n", -ret); | 344 | pr_debug("error removing bus, %x\n", -ret); |
352 | } | 345 | } |
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 01551840d236..ac00b882e75d 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
@@ -63,6 +63,9 @@ static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type) | |||
63 | { | 63 | { |
64 | struct acpi_bus_type *tmp, *ret = NULL; | 64 | struct acpi_bus_type *tmp, *ret = NULL; |
65 | 65 | ||
66 | if (!type) | ||
67 | return NULL; | ||
68 | |||
66 | down_read(&bus_type_sem); | 69 | down_read(&bus_type_sem); |
67 | list_for_each_entry(tmp, &bus_type_list, list) { | 70 | list_for_each_entry(tmp, &bus_type_list, list) { |
68 | if (tmp->bus == type) { | 71 | if (tmp->bus == type) { |
@@ -264,28 +267,39 @@ static int acpi_platform_notify(struct device *dev) | |||
264 | { | 267 | { |
265 | struct acpi_bus_type *type; | 268 | struct acpi_bus_type *type; |
266 | acpi_handle handle; | 269 | acpi_handle handle; |
267 | int ret = -EINVAL; | 270 | int ret; |
268 | 271 | ||
269 | ret = acpi_bind_one(dev, NULL); | 272 | ret = acpi_bind_one(dev, NULL); |
270 | if (!ret) | 273 | if (ret && (!dev->bus || !dev->parent)) { |
271 | goto out; | ||
272 | |||
273 | if (!dev->bus || !dev->parent) { | ||
274 | /* bridge devices genernally haven't bus or parent */ | 274 | /* bridge devices genernally haven't bus or parent */ |
275 | ret = acpi_find_bridge_device(dev, &handle); | 275 | ret = acpi_find_bridge_device(dev, &handle); |
276 | goto end; | 276 | if (!ret) { |
277 | ret = acpi_bind_one(dev, handle); | ||
278 | if (ret) | ||
279 | goto out; | ||
280 | } | ||
277 | } | 281 | } |
282 | |||
278 | type = acpi_get_bus_type(dev->bus); | 283 | type = acpi_get_bus_type(dev->bus); |
279 | if (!type) { | 284 | if (ret) { |
280 | DBG("No ACPI bus support for %s\n", dev_name(dev)); | 285 | if (!type || !type->find_device) { |
281 | ret = -EINVAL; | 286 | DBG("No ACPI bus support for %s\n", dev_name(dev)); |
282 | goto end; | 287 | ret = -EINVAL; |
288 | goto out; | ||
289 | } | ||
290 | |||
291 | ret = type->find_device(dev, &handle); | ||
292 | if (ret) { | ||
293 | DBG("Unable to get handle for %s\n", dev_name(dev)); | ||
294 | goto out; | ||
295 | } | ||
296 | ret = acpi_bind_one(dev, handle); | ||
297 | if (ret) | ||
298 | goto out; | ||
283 | } | 299 | } |
284 | if ((ret = type->find_device(dev, &handle)) != 0) | 300 | |
285 | DBG("Can't get handler for %s\n", dev_name(dev)); | 301 | if (type && type->setup) |
286 | end: | 302 | type->setup(dev); |
287 | if (!ret) | ||
288 | acpi_bind_one(dev, handle); | ||
289 | 303 | ||
290 | out: | 304 | out: |
291 | #if ACPI_GLUE_DEBUG | 305 | #if ACPI_GLUE_DEBUG |
@@ -304,6 +318,12 @@ static int acpi_platform_notify(struct device *dev) | |||
304 | 318 | ||
305 | static int acpi_platform_notify_remove(struct device *dev) | 319 | static int acpi_platform_notify_remove(struct device *dev) |
306 | { | 320 | { |
321 | struct acpi_bus_type *type; | ||
322 | |||
323 | type = acpi_get_bus_type(dev->bus); | ||
324 | if (type && type->cleanup) | ||
325 | type->cleanup(dev); | ||
326 | |||
307 | acpi_unbind_one(dev); | 327 | acpi_unbind_one(dev); |
308 | return 0; | 328 | return 0; |
309 | } | 329 | } |
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 3c407cdc1ec1..0f24148a2b2a 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h | |||
@@ -67,6 +67,8 @@ struct acpi_ec { | |||
67 | 67 | ||
68 | extern struct acpi_ec *first_ec; | 68 | extern struct acpi_ec *first_ec; |
69 | 69 | ||
70 | int acpi_pci_root_init(void); | ||
71 | void acpi_pci_root_hp_init(void); | ||
70 | int acpi_ec_init(void); | 72 | int acpi_ec_init(void); |
71 | int acpi_ec_ecdt_probe(void); | 73 | int acpi_ec_ecdt_probe(void); |
72 | int acpi_boot_ec_enable(void); | 74 | int acpi_boot_ec_enable(void); |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 3ff267861541..59ec5f52e849 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -84,8 +84,7 @@ static acpi_osd_handler acpi_irq_handler; | |||
84 | static void *acpi_irq_context; | 84 | static void *acpi_irq_context; |
85 | static struct workqueue_struct *kacpid_wq; | 85 | static struct workqueue_struct *kacpid_wq; |
86 | static struct workqueue_struct *kacpi_notify_wq; | 86 | static struct workqueue_struct *kacpi_notify_wq; |
87 | struct workqueue_struct *kacpi_hotplug_wq; | 87 | static struct workqueue_struct *kacpi_hotplug_wq; |
88 | EXPORT_SYMBOL(kacpi_hotplug_wq); | ||
89 | 88 | ||
90 | /* | 89 | /* |
91 | * This list of permanent mappings is for memory that may be accessed from | 90 | * This list of permanent mappings is for memory that may be accessed from |
@@ -1778,3 +1777,24 @@ void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, | |||
1778 | { | 1777 | { |
1779 | __acpi_os_prepare_sleep = func; | 1778 | __acpi_os_prepare_sleep = func; |
1780 | } | 1779 | } |
1780 | |||
1781 | void alloc_acpi_hp_work(acpi_handle handle, u32 type, void *context, | ||
1782 | void (*func)(struct work_struct *work)) | ||
1783 | { | ||
1784 | struct acpi_hp_work *hp_work; | ||
1785 | int ret; | ||
1786 | |||
1787 | hp_work = kmalloc(sizeof(*hp_work), GFP_KERNEL); | ||
1788 | if (!hp_work) | ||
1789 | return; | ||
1790 | |||
1791 | hp_work->handle = handle; | ||
1792 | hp_work->type = type; | ||
1793 | hp_work->context = context; | ||
1794 | |||
1795 | INIT_WORK(&hp_work->work, func); | ||
1796 | ret = queue_work(kacpi_hotplug_wq, &hp_work->work); | ||
1797 | if (!ret) | ||
1798 | kfree(hp_work); | ||
1799 | } | ||
1800 | EXPORT_SYMBOL_GPL(alloc_acpi_hp_work); | ||
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c deleted file mode 100644 index a1dee29beed3..000000000000 --- a/drivers/acpi/pci_bind.c +++ /dev/null | |||
@@ -1,122 +0,0 @@ | |||
1 | /* | ||
2 | * pci_bind.c - ACPI PCI Device Binding ($Revision: 2 $) | ||
3 | * | ||
4 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> | ||
5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | ||
6 | * | ||
7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or (at | ||
12 | * your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
21 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | * | ||
23 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
24 | */ | ||
25 | |||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/types.h> | ||
28 | #include <linux/pci.h> | ||
29 | #include <linux/pci-acpi.h> | ||
30 | #include <linux/acpi.h> | ||
31 | #include <linux/pm_runtime.h> | ||
32 | #include <acpi/acpi_bus.h> | ||
33 | #include <acpi/acpi_drivers.h> | ||
34 | |||
35 | #define _COMPONENT ACPI_PCI_COMPONENT | ||
36 | ACPI_MODULE_NAME("pci_bind"); | ||
37 | |||
38 | static int acpi_pci_unbind(struct acpi_device *device) | ||
39 | { | ||
40 | struct pci_dev *dev; | ||
41 | |||
42 | dev = acpi_get_pci_dev(device->handle); | ||
43 | if (!dev) | ||
44 | goto out; | ||
45 | |||
46 | device_set_run_wake(&dev->dev, false); | ||
47 | pci_acpi_remove_pm_notifier(device); | ||
48 | acpi_power_resource_unregister_device(&dev->dev, device->handle); | ||
49 | |||
50 | if (!dev->subordinate) | ||
51 | goto out; | ||
52 | |||
53 | acpi_pci_irq_del_prt(pci_domain_nr(dev->bus), dev->subordinate->number); | ||
54 | |||
55 | device->ops.bind = NULL; | ||
56 | device->ops.unbind = NULL; | ||
57 | |||
58 | out: | ||
59 | pci_dev_put(dev); | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | static int acpi_pci_bind(struct acpi_device *device) | ||
64 | { | ||
65 | acpi_status status; | ||
66 | acpi_handle handle; | ||
67 | unsigned char bus; | ||
68 | struct pci_dev *dev; | ||
69 | |||
70 | dev = acpi_get_pci_dev(device->handle); | ||
71 | if (!dev) | ||
72 | return 0; | ||
73 | |||
74 | pci_acpi_add_pm_notifier(device, dev); | ||
75 | acpi_power_resource_register_device(&dev->dev, device->handle); | ||
76 | if (device->wakeup.flags.run_wake) | ||
77 | device_set_run_wake(&dev->dev, true); | ||
78 | |||
79 | /* | ||
80 | * Install the 'bind' function to facilitate callbacks for | ||
81 | * children of the P2P bridge. | ||
82 | */ | ||
83 | if (dev->subordinate) { | ||
84 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
85 | "Device %04x:%02x:%02x.%d is a PCI bridge\n", | ||
86 | pci_domain_nr(dev->bus), dev->bus->number, | ||
87 | PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn))); | ||
88 | device->ops.bind = acpi_pci_bind; | ||
89 | device->ops.unbind = acpi_pci_unbind; | ||
90 | } | ||
91 | |||
92 | /* | ||
93 | * Evaluate and parse _PRT, if exists. This code allows parsing of | ||
94 | * _PRT objects within the scope of non-bridge devices. Note that | ||
95 | * _PRTs within the scope of a PCI bridge assume the bridge's | ||
96 | * subordinate bus number. | ||
97 | * | ||
98 | * TBD: Can _PRTs exist within the scope of non-bridge PCI devices? | ||
99 | */ | ||
100 | status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); | ||
101 | if (ACPI_FAILURE(status)) | ||
102 | goto out; | ||
103 | |||
104 | if (dev->subordinate) | ||
105 | bus = dev->subordinate->number; | ||
106 | else | ||
107 | bus = dev->bus->number; | ||
108 | |||
109 | acpi_pci_irq_add_prt(device->handle, pci_domain_nr(dev->bus), bus); | ||
110 | |||
111 | out: | ||
112 | pci_dev_put(dev); | ||
113 | return 0; | ||
114 | } | ||
115 | |||
116 | int acpi_pci_bind_root(struct acpi_device *device) | ||
117 | { | ||
118 | device->ops.bind = acpi_pci_bind; | ||
119 | device->ops.unbind = acpi_pci_unbind; | ||
120 | |||
121 | return 0; | ||
122 | } | ||
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 7928d4dc7056..417487a201fb 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -47,7 +47,6 @@ ACPI_MODULE_NAME("pci_root"); | |||
47 | #define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" | 47 | #define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" |
48 | static int acpi_pci_root_add(struct acpi_device *device); | 48 | static int acpi_pci_root_add(struct acpi_device *device); |
49 | static int acpi_pci_root_remove(struct acpi_device *device, int type); | 49 | static int acpi_pci_root_remove(struct acpi_device *device, int type); |
50 | static int acpi_pci_root_start(struct acpi_device *device); | ||
51 | 50 | ||
52 | #define ACPI_PCIE_REQ_SUPPORT (OSC_EXT_PCI_CONFIG_SUPPORT \ | 51 | #define ACPI_PCIE_REQ_SUPPORT (OSC_EXT_PCI_CONFIG_SUPPORT \ |
53 | | OSC_ACTIVE_STATE_PWR_SUPPORT \ | 52 | | OSC_ACTIVE_STATE_PWR_SUPPORT \ |
@@ -67,7 +66,6 @@ static struct acpi_driver acpi_pci_root_driver = { | |||
67 | .ops = { | 66 | .ops = { |
68 | .add = acpi_pci_root_add, | 67 | .add = acpi_pci_root_add, |
69 | .remove = acpi_pci_root_remove, | 68 | .remove = acpi_pci_root_remove, |
70 | .start = acpi_pci_root_start, | ||
71 | }, | 69 | }, |
72 | }; | 70 | }; |
73 | 71 | ||
@@ -109,24 +107,6 @@ void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) | |||
109 | } | 107 | } |
110 | EXPORT_SYMBOL(acpi_pci_unregister_driver); | 108 | EXPORT_SYMBOL(acpi_pci_unregister_driver); |
111 | 109 | ||
112 | acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus) | ||
113 | { | ||
114 | struct acpi_pci_root *root; | ||
115 | acpi_handle handle = NULL; | ||
116 | |||
117 | mutex_lock(&acpi_pci_root_lock); | ||
118 | list_for_each_entry(root, &acpi_pci_roots, node) | ||
119 | if ((root->segment == (u16) seg) && | ||
120 | (root->secondary.start == (u16) bus)) { | ||
121 | handle = root->device->handle; | ||
122 | break; | ||
123 | } | ||
124 | mutex_unlock(&acpi_pci_root_lock); | ||
125 | return handle; | ||
126 | } | ||
127 | |||
128 | EXPORT_SYMBOL_GPL(acpi_get_pci_rootbridge_handle); | ||
129 | |||
130 | /** | 110 | /** |
131 | * acpi_is_root_bridge - determine whether an ACPI CA node is a PCI root bridge | 111 | * acpi_is_root_bridge - determine whether an ACPI CA node is a PCI root bridge |
132 | * @handle - the ACPI CA node in question. | 112 | * @handle - the ACPI CA node in question. |
@@ -188,21 +168,6 @@ static acpi_status try_get_root_bridge_busnr(acpi_handle handle, | |||
188 | return AE_OK; | 168 | return AE_OK; |
189 | } | 169 | } |
190 | 170 | ||
191 | static void acpi_pci_bridge_scan(struct acpi_device *device) | ||
192 | { | ||
193 | int status; | ||
194 | struct acpi_device *child = NULL; | ||
195 | |||
196 | if (device->flags.bus_address) | ||
197 | if (device->parent && device->parent->ops.bind) { | ||
198 | status = device->parent->ops.bind(device); | ||
199 | if (!status) { | ||
200 | list_for_each_entry(child, &device->children, node) | ||
201 | acpi_pci_bridge_scan(child); | ||
202 | } | ||
203 | } | ||
204 | } | ||
205 | |||
206 | static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766"; | 171 | static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766"; |
207 | 172 | ||
208 | static acpi_status acpi_pci_run_osc(acpi_handle handle, | 173 | static acpi_status acpi_pci_run_osc(acpi_handle handle, |
@@ -452,7 +417,7 @@ static int acpi_pci_root_add(struct acpi_device *device) | |||
452 | int result; | 417 | int result; |
453 | struct acpi_pci_root *root; | 418 | struct acpi_pci_root *root; |
454 | acpi_handle handle; | 419 | acpi_handle handle; |
455 | struct acpi_device *child; | 420 | struct acpi_pci_driver *driver; |
456 | u32 flags, base_flags; | 421 | u32 flags, base_flags; |
457 | bool is_osc_granted = false; | 422 | bool is_osc_granted = false; |
458 | 423 | ||
@@ -603,21 +568,6 @@ static int acpi_pci_root_add(struct acpi_device *device) | |||
603 | goto out_del_root; | 568 | goto out_del_root; |
604 | } | 569 | } |
605 | 570 | ||
606 | /* | ||
607 | * Attach ACPI-PCI Context | ||
608 | * ----------------------- | ||
609 | * Thus binding the ACPI and PCI devices. | ||
610 | */ | ||
611 | result = acpi_pci_bind_root(device); | ||
612 | if (result) | ||
613 | goto out_del_root; | ||
614 | |||
615 | /* | ||
616 | * Scan and bind all _ADR-Based Devices | ||
617 | */ | ||
618 | list_for_each_entry(child, &device->children, node) | ||
619 | acpi_pci_bridge_scan(child); | ||
620 | |||
621 | /* ASPM setting */ | 571 | /* ASPM setting */ |
622 | if (is_osc_granted) { | 572 | if (is_osc_granted) { |
623 | if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) | 573 | if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) |
@@ -632,26 +582,10 @@ static int acpi_pci_root_add(struct acpi_device *device) | |||
632 | if (device->wakeup.flags.run_wake) | 582 | if (device->wakeup.flags.run_wake) |
633 | device_set_run_wake(root->bus->bridge, true); | 583 | device_set_run_wake(root->bus->bridge, true); |
634 | 584 | ||
635 | return 0; | 585 | if (system_state != SYSTEM_BOOTING) { |
636 | 586 | pcibios_resource_survey_bus(root->bus); | |
637 | out_del_root: | ||
638 | mutex_lock(&acpi_pci_root_lock); | ||
639 | list_del(&root->node); | ||
640 | mutex_unlock(&acpi_pci_root_lock); | ||
641 | |||
642 | acpi_pci_irq_del_prt(root->segment, root->secondary.start); | ||
643 | end: | ||
644 | kfree(root); | ||
645 | return result; | ||
646 | } | ||
647 | |||
648 | static int acpi_pci_root_start(struct acpi_device *device) | ||
649 | { | ||
650 | struct acpi_pci_root *root = acpi_driver_data(device); | ||
651 | struct acpi_pci_driver *driver; | ||
652 | |||
653 | if (system_state != SYSTEM_BOOTING) | ||
654 | pci_assign_unassigned_bus_resources(root->bus); | 587 | pci_assign_unassigned_bus_resources(root->bus); |
588 | } | ||
655 | 589 | ||
656 | mutex_lock(&acpi_pci_root_lock); | 590 | mutex_lock(&acpi_pci_root_lock); |
657 | list_for_each_entry(driver, &acpi_pci_drivers, node) | 591 | list_for_each_entry(driver, &acpi_pci_drivers, node) |
@@ -664,8 +598,17 @@ static int acpi_pci_root_start(struct acpi_device *device) | |||
664 | pci_enable_bridges(root->bus); | 598 | pci_enable_bridges(root->bus); |
665 | 599 | ||
666 | pci_bus_add_devices(root->bus); | 600 | pci_bus_add_devices(root->bus); |
667 | |||
668 | return 0; | 601 | return 0; |
602 | |||
603 | out_del_root: | ||
604 | mutex_lock(&acpi_pci_root_lock); | ||
605 | list_del(&root->node); | ||
606 | mutex_unlock(&acpi_pci_root_lock); | ||
607 | |||
608 | acpi_pci_irq_del_prt(root->segment, root->secondary.start); | ||
609 | end: | ||
610 | kfree(root); | ||
611 | return result; | ||
669 | } | 612 | } |
670 | 613 | ||
671 | static int acpi_pci_root_remove(struct acpi_device *device, int type) | 614 | static int acpi_pci_root_remove(struct acpi_device *device, int type) |
@@ -699,7 +642,7 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type) | |||
699 | return 0; | 642 | return 0; |
700 | } | 643 | } |
701 | 644 | ||
702 | static int __init acpi_pci_root_init(void) | 645 | int __init acpi_pci_root_init(void) |
703 | { | 646 | { |
704 | acpi_hest_init(); | 647 | acpi_hest_init(); |
705 | 648 | ||
@@ -712,5 +655,133 @@ static int __init acpi_pci_root_init(void) | |||
712 | 655 | ||
713 | return 0; | 656 | return 0; |
714 | } | 657 | } |
658 | /* Support root bridge hotplug */ | ||
659 | |||
660 | static void handle_root_bridge_insertion(acpi_handle handle) | ||
661 | { | ||
662 | struct acpi_device *device; | ||
663 | |||
664 | if (!acpi_bus_get_device(handle, &device)) { | ||
665 | printk(KERN_DEBUG "acpi device exists...\n"); | ||
666 | return; | ||
667 | } | ||
668 | |||
669 | if (acpi_bus_scan(handle)) | ||
670 | printk(KERN_ERR "cannot add bridge to acpi list\n"); | ||
671 | } | ||
672 | |||
673 | static void handle_root_bridge_removal(struct acpi_device *device) | ||
674 | { | ||
675 | struct acpi_eject_event *ej_event; | ||
676 | |||
677 | ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL); | ||
678 | if (!ej_event) { | ||
679 | /* Inform firmware the hot-remove operation has error */ | ||
680 | (void) acpi_evaluate_hotplug_ost(device->handle, | ||
681 | ACPI_NOTIFY_EJECT_REQUEST, | ||
682 | ACPI_OST_SC_NON_SPECIFIC_FAILURE, | ||
683 | NULL); | ||
684 | return; | ||
685 | } | ||
686 | |||
687 | ej_event->device = device; | ||
688 | ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; | ||
689 | |||
690 | acpi_bus_hot_remove_device(ej_event); | ||
691 | } | ||
692 | |||
693 | static void _handle_hotplug_event_root(struct work_struct *work) | ||
694 | { | ||
695 | struct acpi_pci_root *root; | ||
696 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER }; | ||
697 | struct acpi_hp_work *hp_work; | ||
698 | acpi_handle handle; | ||
699 | u32 type; | ||
700 | |||
701 | hp_work = container_of(work, struct acpi_hp_work, work); | ||
702 | handle = hp_work->handle; | ||
703 | type = hp_work->type; | ||
715 | 704 | ||
716 | subsys_initcall(acpi_pci_root_init); | 705 | root = acpi_pci_find_root(handle); |
706 | |||
707 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | ||
708 | |||
709 | switch (type) { | ||
710 | case ACPI_NOTIFY_BUS_CHECK: | ||
711 | /* bus enumerate */ | ||
712 | printk(KERN_DEBUG "%s: Bus check notify on %s\n", __func__, | ||
713 | (char *)buffer.pointer); | ||
714 | if (!root) | ||
715 | handle_root_bridge_insertion(handle); | ||
716 | |||
717 | break; | ||
718 | |||
719 | case ACPI_NOTIFY_DEVICE_CHECK: | ||
720 | /* device check */ | ||
721 | printk(KERN_DEBUG "%s: Device check notify on %s\n", __func__, | ||
722 | (char *)buffer.pointer); | ||
723 | if (!root) | ||
724 | handle_root_bridge_insertion(handle); | ||
725 | break; | ||
726 | |||
727 | case ACPI_NOTIFY_EJECT_REQUEST: | ||
728 | /* request device eject */ | ||
729 | printk(KERN_DEBUG "%s: Device eject notify on %s\n", __func__, | ||
730 | (char *)buffer.pointer); | ||
731 | if (root) | ||
732 | handle_root_bridge_removal(root->device); | ||
733 | break; | ||
734 | default: | ||
735 | printk(KERN_WARNING "notify_handler: unknown event type 0x%x for %s\n", | ||
736 | type, (char *)buffer.pointer); | ||
737 | break; | ||
738 | } | ||
739 | |||
740 | kfree(hp_work); /* allocated in handle_hotplug_event_bridge */ | ||
741 | kfree(buffer.pointer); | ||
742 | } | ||
743 | |||
744 | static void handle_hotplug_event_root(acpi_handle handle, u32 type, | ||
745 | void *context) | ||
746 | { | ||
747 | alloc_acpi_hp_work(handle, type, context, | ||
748 | _handle_hotplug_event_root); | ||
749 | } | ||
750 | |||
751 | static acpi_status __init | ||
752 | find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
753 | { | ||
754 | acpi_status status; | ||
755 | char objname[64]; | ||
756 | struct acpi_buffer buffer = { .length = sizeof(objname), | ||
757 | .pointer = objname }; | ||
758 | int *count = (int *)context; | ||
759 | |||
760 | if (!acpi_is_root_bridge(handle)) | ||
761 | return AE_OK; | ||
762 | |||
763 | (*count)++; | ||
764 | |||
765 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | ||
766 | |||
767 | status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
768 | handle_hotplug_event_root, NULL); | ||
769 | if (ACPI_FAILURE(status)) | ||
770 | printk(KERN_DEBUG "acpi root: %s notify handler is not installed, exit status: %u\n", | ||
771 | objname, (unsigned int)status); | ||
772 | else | ||
773 | printk(KERN_DEBUG "acpi root: %s notify handler is installed\n", | ||
774 | objname); | ||
775 | |||
776 | return AE_OK; | ||
777 | } | ||
778 | |||
779 | void __init acpi_pci_root_hp_init(void) | ||
780 | { | ||
781 | int num = 0; | ||
782 | |||
783 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
784 | ACPI_UINT32_MAX, find_root_bridges, NULL, &num, NULL); | ||
785 | |||
786 | printk(KERN_DEBUG "Found %d acpi root devices\n", num); | ||
787 | } | ||
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index e83311bf1ebd..9c5929a17d3a 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c | |||
@@ -677,28 +677,6 @@ static int is_processor_present(acpi_handle handle) | |||
677 | return 0; | 677 | return 0; |
678 | } | 678 | } |
679 | 679 | ||
680 | static | ||
681 | int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device) | ||
682 | { | ||
683 | acpi_handle phandle; | ||
684 | struct acpi_device *pdev; | ||
685 | |||
686 | |||
687 | if (acpi_get_parent(handle, &phandle)) { | ||
688 | return -ENODEV; | ||
689 | } | ||
690 | |||
691 | if (acpi_bus_get_device(phandle, &pdev)) { | ||
692 | return -ENODEV; | ||
693 | } | ||
694 | |||
695 | if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) { | ||
696 | return -ENODEV; | ||
697 | } | ||
698 | |||
699 | return 0; | ||
700 | } | ||
701 | |||
702 | static void acpi_processor_hotplug_notify(acpi_handle handle, | 680 | static void acpi_processor_hotplug_notify(acpi_handle handle, |
703 | u32 event, void *data) | 681 | u32 event, void *data) |
704 | { | 682 | { |
@@ -721,12 +699,16 @@ static void acpi_processor_hotplug_notify(acpi_handle handle, | |||
721 | if (!acpi_bus_get_device(handle, &device)) | 699 | if (!acpi_bus_get_device(handle, &device)) |
722 | break; | 700 | break; |
723 | 701 | ||
724 | result = acpi_processor_device_add(handle, &device); | 702 | result = acpi_bus_scan(handle); |
725 | if (result) { | 703 | if (result) { |
726 | acpi_handle_err(handle, "Unable to add the device\n"); | 704 | acpi_handle_err(handle, "Unable to add the device\n"); |
727 | break; | 705 | break; |
728 | } | 706 | } |
729 | 707 | result = acpi_bus_get_device(handle, &device); | |
708 | if (result) { | ||
709 | acpi_handle_err(handle, "Missing device object\n"); | ||
710 | break; | ||
711 | } | ||
730 | ost_code = ACPI_OST_SC_SUCCESS; | 712 | ost_code = ACPI_OST_SC_SUCCESS; |
731 | break; | 713 | break; |
732 | 714 | ||
@@ -751,7 +733,7 @@ static void acpi_processor_hotplug_notify(acpi_handle handle, | |||
751 | break; | 733 | break; |
752 | } | 734 | } |
753 | 735 | ||
754 | ej_event->handle = handle; | 736 | ej_event->device = device; |
755 | ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; | 737 | ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; |
756 | acpi_os_hotplug_execute(acpi_bus_hot_remove_device, | 738 | acpi_os_hotplug_execute(acpi_bus_hot_remove_device, |
757 | (void *)ej_event); | 739 | (void *)ej_event); |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 53502d1bbf26..bc2f33790e83 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -116,24 +116,18 @@ static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); | |||
116 | void acpi_bus_hot_remove_device(void *context) | 116 | void acpi_bus_hot_remove_device(void *context) |
117 | { | 117 | { |
118 | struct acpi_eject_event *ej_event = (struct acpi_eject_event *) context; | 118 | struct acpi_eject_event *ej_event = (struct acpi_eject_event *) context; |
119 | struct acpi_device *device; | 119 | struct acpi_device *device = ej_event->device; |
120 | acpi_handle handle = ej_event->handle; | 120 | acpi_handle handle = device->handle; |
121 | acpi_handle temp; | 121 | acpi_handle temp; |
122 | struct acpi_object_list arg_list; | 122 | struct acpi_object_list arg_list; |
123 | union acpi_object arg; | 123 | union acpi_object arg; |
124 | acpi_status status = AE_OK; | 124 | acpi_status status = AE_OK; |
125 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ | 125 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ |
126 | 126 | ||
127 | if (acpi_bus_get_device(handle, &device)) | ||
128 | goto err_out; | ||
129 | |||
130 | if (!device) | ||
131 | goto err_out; | ||
132 | |||
133 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 127 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
134 | "Hot-removing device %s...\n", dev_name(&device->dev))); | 128 | "Hot-removing device %s...\n", dev_name(&device->dev))); |
135 | 129 | ||
136 | if (acpi_bus_trim(device, 1)) { | 130 | if (acpi_bus_trim(device)) { |
137 | printk(KERN_ERR PREFIX | 131 | printk(KERN_ERR PREFIX |
138 | "Removing device failed\n"); | 132 | "Removing device failed\n"); |
139 | goto err_out; | 133 | goto err_out; |
@@ -215,7 +209,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr, | |||
215 | goto err; | 209 | goto err; |
216 | } | 210 | } |
217 | 211 | ||
218 | ej_event->handle = acpi_device->handle; | 212 | ej_event->device = acpi_device; |
219 | if (acpi_device->flags.eject_pending) { | 213 | if (acpi_device->flags.eject_pending) { |
220 | /* event originated from ACPI eject notification */ | 214 | /* event originated from ACPI eject notification */ |
221 | ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; | 215 | ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; |
@@ -223,7 +217,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr, | |||
223 | } else { | 217 | } else { |
224 | /* event originated from user */ | 218 | /* event originated from user */ |
225 | ej_event->event = ACPI_OST_EC_OSPM_EJECT; | 219 | ej_event->event = ACPI_OST_EC_OSPM_EJECT; |
226 | (void) acpi_evaluate_hotplug_ost(ej_event->handle, | 220 | (void) acpi_evaluate_hotplug_ost(acpi_device->handle, |
227 | ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); | 221 | ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); |
228 | } | 222 | } |
229 | 223 | ||
@@ -494,7 +488,8 @@ static int acpi_bus_match(struct device *dev, struct device_driver *drv) | |||
494 | struct acpi_device *acpi_dev = to_acpi_device(dev); | 488 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
495 | struct acpi_driver *acpi_drv = to_acpi_driver(drv); | 489 | struct acpi_driver *acpi_drv = to_acpi_driver(drv); |
496 | 490 | ||
497 | return !acpi_match_device_ids(acpi_dev, acpi_drv->ids); | 491 | return acpi_dev->flags.match_driver |
492 | && !acpi_match_device_ids(acpi_dev, acpi_drv->ids); | ||
498 | } | 493 | } |
499 | 494 | ||
500 | static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env) | 495 | static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env) |
@@ -570,7 +565,6 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device) | |||
570 | } | 565 | } |
571 | 566 | ||
572 | static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *); | 567 | static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *); |
573 | static int acpi_start_single_object(struct acpi_device *); | ||
574 | static int acpi_device_probe(struct device * dev) | 568 | static int acpi_device_probe(struct device * dev) |
575 | { | 569 | { |
576 | struct acpi_device *acpi_dev = to_acpi_device(dev); | 570 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
@@ -579,9 +573,6 @@ static int acpi_device_probe(struct device * dev) | |||
579 | 573 | ||
580 | ret = acpi_bus_driver_init(acpi_dev, acpi_drv); | 574 | ret = acpi_bus_driver_init(acpi_dev, acpi_drv); |
581 | if (!ret) { | 575 | if (!ret) { |
582 | if (acpi_dev->bus_ops.acpi_op_start) | ||
583 | acpi_start_single_object(acpi_dev); | ||
584 | |||
585 | if (acpi_drv->ops.notify) { | 576 | if (acpi_drv->ops.notify) { |
586 | ret = acpi_device_install_notify_handler(acpi_dev); | 577 | ret = acpi_device_install_notify_handler(acpi_dev); |
587 | if (ret) { | 578 | if (ret) { |
@@ -704,7 +695,7 @@ end: | |||
704 | return result; | 695 | return result; |
705 | } | 696 | } |
706 | 697 | ||
707 | static void acpi_device_unregister(struct acpi_device *device, int type) | 698 | static void acpi_device_unregister(struct acpi_device *device) |
708 | { | 699 | { |
709 | mutex_lock(&acpi_device_lock); | 700 | mutex_lock(&acpi_device_lock); |
710 | if (device->parent) | 701 | if (device->parent) |
@@ -760,24 +751,6 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver) | |||
760 | return 0; | 751 | return 0; |
761 | } | 752 | } |
762 | 753 | ||
763 | static int acpi_start_single_object(struct acpi_device *device) | ||
764 | { | ||
765 | int result = 0; | ||
766 | struct acpi_driver *driver; | ||
767 | |||
768 | |||
769 | if (!(driver = device->driver)) | ||
770 | return 0; | ||
771 | |||
772 | if (driver->ops.start) { | ||
773 | result = driver->ops.start(device); | ||
774 | if (result && driver->ops.remove) | ||
775 | driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); | ||
776 | } | ||
777 | |||
778 | return result; | ||
779 | } | ||
780 | |||
781 | /** | 754 | /** |
782 | * acpi_bus_register_driver - register a driver with the ACPI bus | 755 | * acpi_bus_register_driver - register a driver with the ACPI bus |
783 | * @driver: driver being registered | 756 | * @driver: driver being registered |
@@ -1395,33 +1368,9 @@ static int acpi_device_set_context(struct acpi_device *device) | |||
1395 | return -ENODEV; | 1368 | return -ENODEV; |
1396 | } | 1369 | } |
1397 | 1370 | ||
1398 | static int acpi_bus_remove(struct acpi_device *dev, int rmdevice) | ||
1399 | { | ||
1400 | if (!dev) | ||
1401 | return -EINVAL; | ||
1402 | |||
1403 | dev->removal_type = ACPI_BUS_REMOVAL_EJECT; | ||
1404 | device_release_driver(&dev->dev); | ||
1405 | |||
1406 | if (!rmdevice) | ||
1407 | return 0; | ||
1408 | |||
1409 | /* | ||
1410 | * unbind _ADR-Based Devices when hot removal | ||
1411 | */ | ||
1412 | if (dev->flags.bus_address) { | ||
1413 | if ((dev->parent) && (dev->parent->ops.unbind)) | ||
1414 | dev->parent->ops.unbind(dev); | ||
1415 | } | ||
1416 | acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT); | ||
1417 | |||
1418 | return 0; | ||
1419 | } | ||
1420 | |||
1421 | static int acpi_add_single_object(struct acpi_device **child, | 1371 | static int acpi_add_single_object(struct acpi_device **child, |
1422 | acpi_handle handle, int type, | 1372 | acpi_handle handle, int type, |
1423 | unsigned long long sta, | 1373 | unsigned long long sta, bool match_driver) |
1424 | struct acpi_bus_ops *ops) | ||
1425 | { | 1374 | { |
1426 | int result; | 1375 | int result; |
1427 | struct acpi_device *device; | 1376 | struct acpi_device *device; |
@@ -1437,7 +1386,6 @@ static int acpi_add_single_object(struct acpi_device **child, | |||
1437 | device->device_type = type; | 1386 | device->device_type = type; |
1438 | device->handle = handle; | 1387 | device->handle = handle; |
1439 | device->parent = acpi_bus_get_parent(handle); | 1388 | device->parent = acpi_bus_get_parent(handle); |
1440 | device->bus_ops = *ops; /* workround for not call .start */ | ||
1441 | STRUCT_TO_INT(device->status) = sta; | 1389 | STRUCT_TO_INT(device->status) = sta; |
1442 | 1390 | ||
1443 | acpi_device_get_busid(device); | 1391 | acpi_device_get_busid(device); |
@@ -1488,16 +1436,9 @@ static int acpi_add_single_object(struct acpi_device **child, | |||
1488 | if ((result = acpi_device_set_context(device))) | 1436 | if ((result = acpi_device_set_context(device))) |
1489 | goto end; | 1437 | goto end; |
1490 | 1438 | ||
1439 | device->flags.match_driver = match_driver; | ||
1491 | result = acpi_device_register(device); | 1440 | result = acpi_device_register(device); |
1492 | 1441 | ||
1493 | /* | ||
1494 | * Bind _ADR-Based Devices when hot add | ||
1495 | */ | ||
1496 | if (device->flags.bus_address) { | ||
1497 | if (device->parent && device->parent->ops.bind) | ||
1498 | device->parent->ops.bind(device); | ||
1499 | } | ||
1500 | |||
1501 | end: | 1442 | end: |
1502 | if (!result) { | 1443 | if (!result) { |
1503 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | 1444 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); |
@@ -1519,16 +1460,12 @@ end: | |||
1519 | 1460 | ||
1520 | static void acpi_bus_add_power_resource(acpi_handle handle) | 1461 | static void acpi_bus_add_power_resource(acpi_handle handle) |
1521 | { | 1462 | { |
1522 | struct acpi_bus_ops ops = { | ||
1523 | .acpi_op_add = 1, | ||
1524 | .acpi_op_start = 1, | ||
1525 | }; | ||
1526 | struct acpi_device *device = NULL; | 1463 | struct acpi_device *device = NULL; |
1527 | 1464 | ||
1528 | acpi_bus_get_device(handle, &device); | 1465 | acpi_bus_get_device(handle, &device); |
1529 | if (!device) | 1466 | if (!device) |
1530 | acpi_add_single_object(&device, handle, ACPI_BUS_TYPE_POWER, | 1467 | acpi_add_single_object(&device, handle, ACPI_BUS_TYPE_POWER, |
1531 | ACPI_STA_DEFAULT, &ops); | 1468 | ACPI_STA_DEFAULT, true); |
1532 | } | 1469 | } |
1533 | 1470 | ||
1534 | static int acpi_bus_type_and_status(acpi_handle handle, int *type, | 1471 | static int acpi_bus_type_and_status(acpi_handle handle, int *type, |
@@ -1570,16 +1507,19 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type, | |||
1570 | return 0; | 1507 | return 0; |
1571 | } | 1508 | } |
1572 | 1509 | ||
1573 | static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl, | 1510 | static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, |
1574 | void *context, void **return_value) | 1511 | void *not_used, void **return_value) |
1575 | { | 1512 | { |
1576 | struct acpi_bus_ops *ops = context; | 1513 | struct acpi_device *device = NULL; |
1577 | int type; | 1514 | int type; |
1578 | unsigned long long sta; | 1515 | unsigned long long sta; |
1579 | struct acpi_device *device; | ||
1580 | acpi_status status; | 1516 | acpi_status status; |
1581 | int result; | 1517 | int result; |
1582 | 1518 | ||
1519 | acpi_bus_get_device(handle, &device); | ||
1520 | if (device) | ||
1521 | goto out; | ||
1522 | |||
1583 | result = acpi_bus_type_and_status(handle, &type, &sta); | 1523 | result = acpi_bus_type_and_status(handle, &type, &sta); |
1584 | if (result) | 1524 | if (result) |
1585 | return AE_OK; | 1525 | return AE_OK; |
@@ -1596,150 +1536,118 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl, | |||
1596 | return AE_CTRL_DEPTH; | 1536 | return AE_CTRL_DEPTH; |
1597 | } | 1537 | } |
1598 | 1538 | ||
1599 | /* | 1539 | acpi_add_single_object(&device, handle, type, sta, |
1600 | * We may already have an acpi_device from a previous enumeration. If | 1540 | type == ACPI_BUS_TYPE_POWER); |
1601 | * so, we needn't add it again, but we may still have to start it. | ||
1602 | */ | ||
1603 | device = NULL; | ||
1604 | acpi_bus_get_device(handle, &device); | ||
1605 | if (ops->acpi_op_add && !device) { | ||
1606 | acpi_add_single_object(&device, handle, type, sta, ops); | ||
1607 | /* Is the device a known good platform device? */ | ||
1608 | if (device | ||
1609 | && !acpi_match_device_ids(device, acpi_platform_device_ids)) | ||
1610 | acpi_create_platform_device(device); | ||
1611 | } | ||
1612 | |||
1613 | if (!device) | 1541 | if (!device) |
1614 | return AE_CTRL_DEPTH; | 1542 | return AE_CTRL_DEPTH; |
1615 | 1543 | ||
1616 | if (ops->acpi_op_start && !(ops->acpi_op_add)) { | 1544 | device->flags.match_driver = true; |
1617 | status = acpi_start_single_object(device); | ||
1618 | if (ACPI_FAILURE(status)) | ||
1619 | return AE_CTRL_DEPTH; | ||
1620 | } | ||
1621 | 1545 | ||
1546 | out: | ||
1622 | if (!*return_value) | 1547 | if (!*return_value) |
1623 | *return_value = device; | 1548 | *return_value = device; |
1549 | |||
1624 | return AE_OK; | 1550 | return AE_OK; |
1625 | } | 1551 | } |
1626 | 1552 | ||
1627 | static int acpi_bus_scan(acpi_handle handle, struct acpi_bus_ops *ops, | 1553 | static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used, |
1628 | struct acpi_device **child) | 1554 | void *not_used, void **ret_not_used) |
1629 | { | 1555 | { |
1630 | acpi_status status; | 1556 | acpi_status status = AE_OK; |
1631 | void *device = NULL; | 1557 | struct acpi_device *device; |
1558 | unsigned long long sta_not_used; | ||
1559 | int type_not_used; | ||
1632 | 1560 | ||
1633 | status = acpi_bus_check_add(handle, 0, ops, &device); | 1561 | /* |
1634 | if (ACPI_SUCCESS(status)) | 1562 | * Ignore errors ignored by acpi_bus_check_add() to avoid terminating |
1635 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, | 1563 | * namespace walks prematurely. |
1636 | acpi_bus_check_add, NULL, ops, &device); | 1564 | */ |
1565 | if (acpi_bus_type_and_status(handle, &type_not_used, &sta_not_used)) | ||
1566 | return AE_OK; | ||
1637 | 1567 | ||
1638 | if (child) | 1568 | if (acpi_bus_get_device(handle, &device)) |
1639 | *child = device; | 1569 | return AE_CTRL_DEPTH; |
1640 | 1570 | ||
1641 | if (device) | 1571 | if (!acpi_match_device_ids(device, acpi_platform_device_ids)) { |
1642 | return 0; | 1572 | /* This is a known good platform device. */ |
1643 | else | 1573 | acpi_create_platform_device(device); |
1644 | return -ENODEV; | 1574 | } else if (device_attach(&device->dev) < 0) { |
1575 | status = AE_CTRL_DEPTH; | ||
1576 | } | ||
1577 | return status; | ||
1645 | } | 1578 | } |
1646 | 1579 | ||
1647 | /* | 1580 | /** |
1648 | * acpi_bus_add and acpi_bus_start | 1581 | * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. |
1582 | * @handle: Root of the namespace scope to scan. | ||
1649 | * | 1583 | * |
1650 | * scan a given ACPI tree and (probably recently hot-plugged) | 1584 | * Scan a given ACPI tree (probably recently hot-plugged) and create and add |
1651 | * create and add or starts found devices. | 1585 | * found devices. |
1652 | * | 1586 | * |
1653 | * If no devices were found -ENODEV is returned which does not | 1587 | * If no devices were found, -ENODEV is returned, but it does not mean that |
1654 | * mean that this is a real error, there just have been no suitable | 1588 | * there has been a real error. There just have been no suitable ACPI objects |
1655 | * ACPI objects in the table trunk from which the kernel could create | 1589 | * in the table trunk from which the kernel could create a device and add an |
1656 | * a device and add/start an appropriate driver. | 1590 | * appropriate driver. |
1657 | */ | 1591 | */ |
1658 | 1592 | int acpi_bus_scan(acpi_handle handle) | |
1659 | int | ||
1660 | acpi_bus_add(struct acpi_device **child, | ||
1661 | struct acpi_device *parent, acpi_handle handle, int type) | ||
1662 | { | 1593 | { |
1663 | struct acpi_bus_ops ops; | 1594 | void *device = NULL; |
1664 | |||
1665 | memset(&ops, 0, sizeof(ops)); | ||
1666 | ops.acpi_op_add = 1; | ||
1667 | |||
1668 | return acpi_bus_scan(handle, &ops, child); | ||
1669 | } | ||
1670 | EXPORT_SYMBOL(acpi_bus_add); | ||
1671 | 1595 | ||
1672 | int acpi_bus_start(struct acpi_device *device) | 1596 | if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device))) |
1673 | { | 1597 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, |
1674 | struct acpi_bus_ops ops; | 1598 | acpi_bus_check_add, NULL, NULL, &device); |
1675 | int result; | ||
1676 | 1599 | ||
1677 | if (!device) | 1600 | if (!device) |
1678 | return -EINVAL; | 1601 | return -ENODEV; |
1679 | 1602 | ||
1680 | memset(&ops, 0, sizeof(ops)); | 1603 | if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL))) |
1681 | ops.acpi_op_start = 1; | 1604 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, |
1605 | acpi_bus_device_attach, NULL, NULL, NULL); | ||
1682 | 1606 | ||
1683 | result = acpi_bus_scan(device->handle, &ops, NULL); | 1607 | return 0; |
1608 | } | ||
1609 | EXPORT_SYMBOL(acpi_bus_scan); | ||
1684 | 1610 | ||
1685 | acpi_update_all_gpes(); | 1611 | static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used, |
1612 | void *not_used, void **ret_not_used) | ||
1613 | { | ||
1614 | struct acpi_device *device = NULL; | ||
1686 | 1615 | ||
1687 | return result; | 1616 | if (!acpi_bus_get_device(handle, &device)) { |
1617 | device->removal_type = ACPI_BUS_REMOVAL_EJECT; | ||
1618 | device_release_driver(&device->dev); | ||
1619 | } | ||
1620 | return AE_OK; | ||
1688 | } | 1621 | } |
1689 | EXPORT_SYMBOL(acpi_bus_start); | ||
1690 | 1622 | ||
1691 | int acpi_bus_trim(struct acpi_device *start, int rmdevice) | 1623 | static acpi_status acpi_bus_remove(acpi_handle handle, u32 lvl_not_used, |
1624 | void *not_used, void **ret_not_used) | ||
1692 | { | 1625 | { |
1693 | acpi_status status; | 1626 | struct acpi_device *device = NULL; |
1694 | struct acpi_device *parent, *child; | ||
1695 | acpi_handle phandle, chandle; | ||
1696 | acpi_object_type type; | ||
1697 | u32 level = 1; | ||
1698 | int err = 0; | ||
1699 | |||
1700 | parent = start; | ||
1701 | phandle = start->handle; | ||
1702 | child = chandle = NULL; | ||
1703 | 1627 | ||
1704 | while ((level > 0) && parent && (!err)) { | 1628 | if (!acpi_bus_get_device(handle, &device)) |
1705 | status = acpi_get_next_object(ACPI_TYPE_ANY, phandle, | 1629 | acpi_device_unregister(device); |
1706 | chandle, &chandle); | ||
1707 | 1630 | ||
1708 | /* | 1631 | return AE_OK; |
1709 | * If this scope is exhausted then move our way back up. | 1632 | } |
1710 | */ | ||
1711 | if (ACPI_FAILURE(status)) { | ||
1712 | level--; | ||
1713 | chandle = phandle; | ||
1714 | acpi_get_parent(phandle, &phandle); | ||
1715 | child = parent; | ||
1716 | parent = parent->parent; | ||
1717 | |||
1718 | if (level == 0) | ||
1719 | err = acpi_bus_remove(child, rmdevice); | ||
1720 | else | ||
1721 | err = acpi_bus_remove(child, 1); | ||
1722 | |||
1723 | continue; | ||
1724 | } | ||
1725 | 1633 | ||
1726 | status = acpi_get_type(chandle, &type); | 1634 | int acpi_bus_trim(struct acpi_device *start) |
1727 | if (ACPI_FAILURE(status)) { | 1635 | { |
1728 | continue; | 1636 | /* |
1729 | } | 1637 | * Execute acpi_bus_device_detach() as a post-order callback to detach |
1730 | /* | 1638 | * all ACPI drivers from the device nodes being removed. |
1731 | * If there is a device corresponding to chandle then | 1639 | */ |
1732 | * parse it (depth-first). | 1640 | acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL, |
1733 | */ | 1641 | acpi_bus_device_detach, NULL, NULL); |
1734 | if (acpi_bus_get_device(chandle, &child) == 0) { | 1642 | acpi_bus_device_detach(start->handle, 0, NULL, NULL); |
1735 | level++; | 1643 | /* |
1736 | phandle = chandle; | 1644 | * Execute acpi_bus_remove() as a post-order callback to remove device |
1737 | chandle = NULL; | 1645 | * nodes in the given namespace scope. |
1738 | parent = child; | 1646 | */ |
1739 | } | 1647 | acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL, |
1740 | continue; | 1648 | acpi_bus_remove, NULL, NULL); |
1741 | } | 1649 | acpi_bus_remove(start->handle, 0, NULL, NULL); |
1742 | return err; | 1650 | return 0; |
1743 | } | 1651 | } |
1744 | EXPORT_SYMBOL_GPL(acpi_bus_trim); | 1652 | EXPORT_SYMBOL_GPL(acpi_bus_trim); |
1745 | 1653 | ||
@@ -1747,11 +1655,6 @@ static int acpi_bus_scan_fixed(void) | |||
1747 | { | 1655 | { |
1748 | int result = 0; | 1656 | int result = 0; |
1749 | struct acpi_device *device = NULL; | 1657 | struct acpi_device *device = NULL; |
1750 | struct acpi_bus_ops ops; | ||
1751 | |||
1752 | memset(&ops, 0, sizeof(ops)); | ||
1753 | ops.acpi_op_add = 1; | ||
1754 | ops.acpi_op_start = 1; | ||
1755 | 1658 | ||
1756 | /* | 1659 | /* |
1757 | * Enumerate all fixed-feature devices. | 1660 | * Enumerate all fixed-feature devices. |
@@ -1759,16 +1662,14 @@ static int acpi_bus_scan_fixed(void) | |||
1759 | if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) { | 1662 | if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) { |
1760 | result = acpi_add_single_object(&device, NULL, | 1663 | result = acpi_add_single_object(&device, NULL, |
1761 | ACPI_BUS_TYPE_POWER_BUTTON, | 1664 | ACPI_BUS_TYPE_POWER_BUTTON, |
1762 | ACPI_STA_DEFAULT, | 1665 | ACPI_STA_DEFAULT, true); |
1763 | &ops); | ||
1764 | device_init_wakeup(&device->dev, true); | 1666 | device_init_wakeup(&device->dev, true); |
1765 | } | 1667 | } |
1766 | 1668 | ||
1767 | if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) { | 1669 | if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) { |
1768 | result = acpi_add_single_object(&device, NULL, | 1670 | result = acpi_add_single_object(&device, NULL, |
1769 | ACPI_BUS_TYPE_SLEEP_BUTTON, | 1671 | ACPI_BUS_TYPE_SLEEP_BUTTON, |
1770 | ACPI_STA_DEFAULT, | 1672 | ACPI_STA_DEFAULT, true); |
1771 | &ops); | ||
1772 | } | 1673 | } |
1773 | 1674 | ||
1774 | return result; | 1675 | return result; |
@@ -1777,11 +1678,6 @@ static int acpi_bus_scan_fixed(void) | |||
1777 | int __init acpi_scan_init(void) | 1678 | int __init acpi_scan_init(void) |
1778 | { | 1679 | { |
1779 | int result; | 1680 | int result; |
1780 | struct acpi_bus_ops ops; | ||
1781 | |||
1782 | memset(&ops, 0, sizeof(ops)); | ||
1783 | ops.acpi_op_add = 1; | ||
1784 | ops.acpi_op_start = 1; | ||
1785 | 1681 | ||
1786 | result = bus_register(&acpi_bus_type); | 1682 | result = bus_register(&acpi_bus_type); |
1787 | if (result) { | 1683 | if (result) { |
@@ -1790,19 +1686,28 @@ int __init acpi_scan_init(void) | |||
1790 | } | 1686 | } |
1791 | 1687 | ||
1792 | acpi_power_init(); | 1688 | acpi_power_init(); |
1689 | acpi_pci_root_init(); | ||
1793 | 1690 | ||
1794 | /* | 1691 | /* |
1795 | * Enumerate devices in the ACPI namespace. | 1692 | * Enumerate devices in the ACPI namespace. |
1796 | */ | 1693 | */ |
1797 | result = acpi_bus_scan(ACPI_ROOT_OBJECT, &ops, &acpi_root); | 1694 | result = acpi_bus_scan(ACPI_ROOT_OBJECT); |
1798 | 1695 | if (result) | |
1799 | if (!result) | 1696 | return result; |
1800 | result = acpi_bus_scan_fixed(); | ||
1801 | 1697 | ||
1698 | result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root); | ||
1802 | if (result) | 1699 | if (result) |
1803 | acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); | 1700 | return result; |
1804 | else | ||
1805 | acpi_update_all_gpes(); | ||
1806 | 1701 | ||
1807 | return result; | 1702 | result = acpi_bus_scan_fixed(); |
1703 | if (result) { | ||
1704 | acpi_device_unregister(acpi_root); | ||
1705 | return result; | ||
1706 | } | ||
1707 | |||
1708 | acpi_update_all_gpes(); | ||
1709 | |||
1710 | acpi_pci_root_hp_init(); | ||
1711 | |||
1712 | return 0; | ||
1808 | } | 1713 | } |
diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 3af0478c057b..5278ac692cbf 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c | |||
@@ -472,7 +472,7 @@ EXPORT_SYMBOL_GPL(pci_cfg_access_unlock); | |||
472 | 472 | ||
473 | static inline int pcie_cap_version(const struct pci_dev *dev) | 473 | static inline int pcie_cap_version(const struct pci_dev *dev) |
474 | { | 474 | { |
475 | return dev->pcie_flags_reg & PCI_EXP_FLAGS_VERS; | 475 | return pcie_caps_reg(dev) & PCI_EXP_FLAGS_VERS; |
476 | } | 476 | } |
477 | 477 | ||
478 | static inline bool pcie_cap_has_devctl(const struct pci_dev *dev) | 478 | static inline bool pcie_cap_has_devctl(const struct pci_dev *dev) |
@@ -497,7 +497,7 @@ static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev) | |||
497 | return pcie_cap_version(dev) > 1 || | 497 | return pcie_cap_version(dev) > 1 || |
498 | type == PCI_EXP_TYPE_ROOT_PORT || | 498 | type == PCI_EXP_TYPE_ROOT_PORT || |
499 | (type == PCI_EXP_TYPE_DOWNSTREAM && | 499 | (type == PCI_EXP_TYPE_DOWNSTREAM && |
500 | dev->pcie_flags_reg & PCI_EXP_FLAGS_SLOT); | 500 | pcie_caps_reg(dev) & PCI_EXP_FLAGS_SLOT); |
501 | } | 501 | } |
502 | 502 | ||
503 | static inline bool pcie_cap_has_rtctl(const struct pci_dev *dev) | 503 | static inline bool pcie_cap_has_rtctl(const struct pci_dev *dev) |
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index ad6a8b635692..8647dc6f52d0 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c | |||
@@ -158,69 +158,38 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, | |||
158 | return ret; | 158 | return ret; |
159 | } | 159 | } |
160 | 160 | ||
161 | void __weak pcibios_resource_survey_bus(struct pci_bus *bus) { } | ||
162 | |||
161 | /** | 163 | /** |
162 | * pci_bus_add_device - add a single device | 164 | * pci_bus_add_device - start driver for a single device |
163 | * @dev: device to add | 165 | * @dev: device to add |
164 | * | 166 | * |
165 | * This adds a single pci device to the global | 167 | * This adds add sysfs entries and start device drivers |
166 | * device list and adds sysfs and procfs entries | ||
167 | */ | 168 | */ |
168 | int pci_bus_add_device(struct pci_dev *dev) | 169 | int pci_bus_add_device(struct pci_dev *dev) |
169 | { | 170 | { |
170 | int retval; | 171 | int retval; |
171 | 172 | ||
172 | pci_fixup_device(pci_fixup_final, dev); | 173 | /* |
173 | 174 | * Can not put in pci_device_add yet because resources | |
174 | retval = pcibios_add_device(dev); | 175 | * are not assigned yet for some devices. |
175 | if (retval) | 176 | */ |
176 | return retval; | ||
177 | |||
178 | retval = device_add(&dev->dev); | ||
179 | if (retval) | ||
180 | return retval; | ||
181 | |||
182 | dev->is_added = 1; | ||
183 | pci_proc_attach_device(dev); | ||
184 | pci_create_sysfs_dev_files(dev); | 177 | pci_create_sysfs_dev_files(dev); |
185 | return 0; | ||
186 | } | ||
187 | |||
188 | /** | ||
189 | * pci_bus_add_child - add a child bus | ||
190 | * @bus: bus to add | ||
191 | * | ||
192 | * This adds sysfs entries for a single bus | ||
193 | */ | ||
194 | int pci_bus_add_child(struct pci_bus *bus) | ||
195 | { | ||
196 | int retval; | ||
197 | |||
198 | if (bus->bridge) | ||
199 | bus->dev.parent = bus->bridge; | ||
200 | 178 | ||
201 | retval = device_register(&bus->dev); | 179 | dev->match_driver = true; |
202 | if (retval) | 180 | retval = device_attach(&dev->dev); |
203 | return retval; | 181 | WARN_ON(retval < 0); |
204 | 182 | ||
205 | bus->is_added = 1; | 183 | dev->is_added = 1; |
206 | |||
207 | /* Create legacy_io and legacy_mem files for this bus */ | ||
208 | pci_create_legacy_files(bus); | ||
209 | 184 | ||
210 | return retval; | 185 | return 0; |
211 | } | 186 | } |
212 | 187 | ||
213 | /** | 188 | /** |
214 | * pci_bus_add_devices - insert newly discovered PCI devices | 189 | * pci_bus_add_devices - start driver for PCI devices |
215 | * @bus: bus to check for new devices | 190 | * @bus: bus to check for new devices |
216 | * | 191 | * |
217 | * Add newly discovered PCI devices (which are on the bus->devices | 192 | * Start driver for PCI devices and add some sysfs entries. |
218 | * list) to the global PCI device list, add the sysfs and procfs | ||
219 | * entries. Where a bridge is found, add the discovered bus to | ||
220 | * the parents list of child buses, and recurse (breadth-first | ||
221 | * to be compatible with 2.4) | ||
222 | * | ||
223 | * Call hotplug for each new devices. | ||
224 | */ | 193 | */ |
225 | void pci_bus_add_devices(const struct pci_bus *bus) | 194 | void pci_bus_add_devices(const struct pci_bus *bus) |
226 | { | 195 | { |
@@ -233,36 +202,20 @@ void pci_bus_add_devices(const struct pci_bus *bus) | |||
233 | if (dev->is_added) | 202 | if (dev->is_added) |
234 | continue; | 203 | continue; |
235 | retval = pci_bus_add_device(dev); | 204 | retval = pci_bus_add_device(dev); |
236 | if (retval) | ||
237 | dev_err(&dev->dev, "Error adding device, continuing\n"); | ||
238 | } | 205 | } |
239 | 206 | ||
240 | list_for_each_entry(dev, &bus->devices, bus_list) { | 207 | list_for_each_entry(dev, &bus->devices, bus_list) { |
241 | BUG_ON(!dev->is_added); | 208 | BUG_ON(!dev->is_added); |
242 | 209 | ||
243 | child = dev->subordinate; | 210 | child = dev->subordinate; |
244 | /* | 211 | |
245 | * If there is an unattached subordinate bus, attach | ||
246 | * it and then scan for unattached PCI devices. | ||
247 | */ | ||
248 | if (!child) | 212 | if (!child) |
249 | continue; | 213 | continue; |
250 | if (list_empty(&child->node)) { | ||
251 | down_write(&pci_bus_sem); | ||
252 | list_add_tail(&child->node, &dev->bus->children); | ||
253 | up_write(&pci_bus_sem); | ||
254 | } | ||
255 | pci_bus_add_devices(child); | 214 | pci_bus_add_devices(child); |
256 | 215 | ||
257 | /* | ||
258 | * register the bus with sysfs as the parent is now | ||
259 | * properly registered. | ||
260 | */ | ||
261 | if (child->is_added) | 216 | if (child->is_added) |
262 | continue; | 217 | continue; |
263 | retval = pci_bus_add_child(child); | 218 | child->is_added = 1; |
264 | if (retval) | ||
265 | dev_err(&dev->dev, "Error adding bus, continuing\n"); | ||
266 | } | 219 | } |
267 | } | 220 | } |
268 | 221 | ||
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h index a1afb5b39ad4..b70ac00a117e 100644 --- a/drivers/pci/hotplug/acpiphp.h +++ b/drivers/pci/hotplug/acpiphp.h | |||
@@ -79,7 +79,6 @@ struct acpiphp_bridge { | |||
79 | /* Ejectable PCI-to-PCI bridge (PCI bridge and PCI function) */ | 79 | /* Ejectable PCI-to-PCI bridge (PCI bridge and PCI function) */ |
80 | struct acpiphp_func *func; | 80 | struct acpiphp_func *func; |
81 | 81 | ||
82 | int type; | ||
83 | int nr_slots; | 82 | int nr_slots; |
84 | 83 | ||
85 | u32 flags; | 84 | u32 flags; |
@@ -146,10 +145,6 @@ struct acpiphp_attention_info | |||
146 | /* PCI bus bridge HID */ | 145 | /* PCI bus bridge HID */ |
147 | #define ACPI_PCI_HOST_HID "PNP0A03" | 146 | #define ACPI_PCI_HOST_HID "PNP0A03" |
148 | 147 | ||
149 | /* PCI BRIDGE type */ | ||
150 | #define BRIDGE_TYPE_HOST 0 | ||
151 | #define BRIDGE_TYPE_P2P 1 | ||
152 | |||
153 | /* ACPI _STA method value (ignore bit 4; battery present) */ | 148 | /* ACPI _STA method value (ignore bit 4; battery present) */ |
154 | #define ACPI_STA_PRESENT (0x00000001) | 149 | #define ACPI_STA_PRESENT (0x00000001) |
155 | #define ACPI_STA_ENABLED (0x00000002) | 150 | #define ACPI_STA_ENABLED (0x00000002) |
@@ -158,13 +153,7 @@ struct acpiphp_attention_info | |||
158 | #define ACPI_STA_ALL (0x0000000f) | 153 | #define ACPI_STA_ALL (0x0000000f) |
159 | 154 | ||
160 | /* bridge flags */ | 155 | /* bridge flags */ |
161 | #define BRIDGE_HAS_STA (0x00000001) | 156 | #define BRIDGE_HAS_EJ0 (0x00000001) |
162 | #define BRIDGE_HAS_EJ0 (0x00000002) | ||
163 | #define BRIDGE_HAS_HPP (0x00000004) | ||
164 | #define BRIDGE_HAS_PS0 (0x00000010) | ||
165 | #define BRIDGE_HAS_PS1 (0x00000020) | ||
166 | #define BRIDGE_HAS_PS2 (0x00000040) | ||
167 | #define BRIDGE_HAS_PS3 (0x00000080) | ||
168 | 157 | ||
169 | /* slot flags */ | 158 | /* slot flags */ |
170 | 159 | ||
@@ -193,7 +182,6 @@ extern void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot); | |||
193 | /* acpiphp_glue.c */ | 182 | /* acpiphp_glue.c */ |
194 | extern int acpiphp_glue_init (void); | 183 | extern int acpiphp_glue_init (void); |
195 | extern void acpiphp_glue_exit (void); | 184 | extern void acpiphp_glue_exit (void); |
196 | extern int acpiphp_get_num_slots (void); | ||
197 | typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data); | 185 | typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data); |
198 | 186 | ||
199 | extern int acpiphp_enable_slot (struct acpiphp_slot *slot); | 187 | extern int acpiphp_enable_slot (struct acpiphp_slot *slot); |
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c index 96316b74969f..c2fd3095701f 100644 --- a/drivers/pci/hotplug/acpiphp_core.c +++ b/drivers/pci/hotplug/acpiphp_core.c | |||
@@ -50,7 +50,6 @@ | |||
50 | bool acpiphp_debug; | 50 | bool acpiphp_debug; |
51 | 51 | ||
52 | /* local variables */ | 52 | /* local variables */ |
53 | static int num_slots; | ||
54 | static struct acpiphp_attention_info *attention_info; | 53 | static struct acpiphp_attention_info *attention_info; |
55 | 54 | ||
56 | #define DRIVER_VERSION "0.5" | 55 | #define DRIVER_VERSION "0.5" |
@@ -272,25 +271,6 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) | |||
272 | return 0; | 271 | return 0; |
273 | } | 272 | } |
274 | 273 | ||
275 | static int __init init_acpi(void) | ||
276 | { | ||
277 | int retval; | ||
278 | |||
279 | /* initialize internal data structure etc. */ | ||
280 | retval = acpiphp_glue_init(); | ||
281 | |||
282 | /* read initial number of slots */ | ||
283 | if (!retval) { | ||
284 | num_slots = acpiphp_get_num_slots(); | ||
285 | if (num_slots == 0) { | ||
286 | acpiphp_glue_exit(); | ||
287 | retval = -ENODEV; | ||
288 | } | ||
289 | } | ||
290 | |||
291 | return retval; | ||
292 | } | ||
293 | |||
294 | /** | 274 | /** |
295 | * release_slot - free up the memory used by a slot | 275 | * release_slot - free up the memory used by a slot |
296 | * @hotplug_slot: slot to free | 276 | * @hotplug_slot: slot to free |
@@ -379,7 +359,8 @@ static int __init acpiphp_init(void) | |||
379 | return 0; | 359 | return 0; |
380 | 360 | ||
381 | /* read all the ACPI info from the system */ | 361 | /* read all the ACPI info from the system */ |
382 | return init_acpi(); | 362 | /* initialize internal data structure etc. */ |
363 | return acpiphp_glue_init(); | ||
383 | } | 364 | } |
384 | 365 | ||
385 | 366 | ||
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 3d6d4fd1e3c5..4681d2c9b1dd 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -325,8 +325,8 @@ static void init_bridge_misc(struct acpiphp_bridge *bridge) | |||
325 | return; | 325 | return; |
326 | } | 326 | } |
327 | 327 | ||
328 | /* install notify handler */ | 328 | /* install notify handler for P2P bridges */ |
329 | if (bridge->type != BRIDGE_TYPE_HOST) { | 329 | if (!pci_is_root_bus(bridge->pci_bus)) { |
330 | if ((bridge->flags & BRIDGE_HAS_EJ0) && bridge->func) { | 330 | if ((bridge->flags & BRIDGE_HAS_EJ0) && bridge->func) { |
331 | status = acpi_remove_notify_handler(bridge->func->handle, | 331 | status = acpi_remove_notify_handler(bridge->func->handle, |
332 | ACPI_SYSTEM_NOTIFY, | 332 | ACPI_SYSTEM_NOTIFY, |
@@ -369,27 +369,12 @@ static struct acpiphp_func *acpiphp_bridge_handle_to_function(acpi_handle handle | |||
369 | static inline void config_p2p_bridge_flags(struct acpiphp_bridge *bridge) | 369 | static inline void config_p2p_bridge_flags(struct acpiphp_bridge *bridge) |
370 | { | 370 | { |
371 | acpi_handle dummy_handle; | 371 | acpi_handle dummy_handle; |
372 | struct acpiphp_func *func; | ||
372 | 373 | ||
373 | if (ACPI_SUCCESS(acpi_get_handle(bridge->handle, | 374 | if (ACPI_SUCCESS(acpi_get_handle(bridge->handle, |
374 | "_STA", &dummy_handle))) | 375 | "_EJ0", &dummy_handle))) { |
375 | bridge->flags |= BRIDGE_HAS_STA; | ||
376 | |||
377 | if (ACPI_SUCCESS(acpi_get_handle(bridge->handle, | ||
378 | "_EJ0", &dummy_handle))) | ||
379 | bridge->flags |= BRIDGE_HAS_EJ0; | 376 | bridge->flags |= BRIDGE_HAS_EJ0; |
380 | 377 | ||
381 | if (ACPI_SUCCESS(acpi_get_handle(bridge->handle, | ||
382 | "_PS0", &dummy_handle))) | ||
383 | bridge->flags |= BRIDGE_HAS_PS0; | ||
384 | |||
385 | if (ACPI_SUCCESS(acpi_get_handle(bridge->handle, | ||
386 | "_PS3", &dummy_handle))) | ||
387 | bridge->flags |= BRIDGE_HAS_PS3; | ||
388 | |||
389 | /* is this ejectable p2p bridge? */ | ||
390 | if (bridge->flags & BRIDGE_HAS_EJ0) { | ||
391 | struct acpiphp_func *func; | ||
392 | |||
393 | dbg("found ejectable p2p bridge\n"); | 378 | dbg("found ejectable p2p bridge\n"); |
394 | 379 | ||
395 | /* make link between PCI bridge and PCI function */ | 380 | /* make link between PCI bridge and PCI function */ |
@@ -412,7 +397,6 @@ static void add_host_bridge(struct acpi_pci_root *root) | |||
412 | if (bridge == NULL) | 397 | if (bridge == NULL) |
413 | return; | 398 | return; |
414 | 399 | ||
415 | bridge->type = BRIDGE_TYPE_HOST; | ||
416 | bridge->handle = handle; | 400 | bridge->handle = handle; |
417 | 401 | ||
418 | bridge->pci_bus = root->bus; | 402 | bridge->pci_bus = root->bus; |
@@ -432,7 +416,6 @@ static void add_p2p_bridge(acpi_handle *handle) | |||
432 | return; | 416 | return; |
433 | } | 417 | } |
434 | 418 | ||
435 | bridge->type = BRIDGE_TYPE_P2P; | ||
436 | bridge->handle = handle; | 419 | bridge->handle = handle; |
437 | config_p2p_bridge_flags(bridge); | 420 | config_p2p_bridge_flags(bridge); |
438 | 421 | ||
@@ -543,13 +526,15 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge) | |||
543 | acpi_status status; | 526 | acpi_status status; |
544 | acpi_handle handle = bridge->handle; | 527 | acpi_handle handle = bridge->handle; |
545 | 528 | ||
546 | status = acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | 529 | if (!pci_is_root_bus(bridge->pci_bus)) { |
530 | status = acpi_remove_notify_handler(handle, | ||
531 | ACPI_SYSTEM_NOTIFY, | ||
547 | handle_hotplug_event_bridge); | 532 | handle_hotplug_event_bridge); |
548 | if (ACPI_FAILURE(status)) | 533 | if (ACPI_FAILURE(status)) |
549 | err("failed to remove notify handler\n"); | 534 | err("failed to remove notify handler\n"); |
535 | } | ||
550 | 536 | ||
551 | if ((bridge->type != BRIDGE_TYPE_HOST) && | 537 | if ((bridge->flags & BRIDGE_HAS_EJ0) && bridge->func) { |
552 | ((bridge->flags & BRIDGE_HAS_EJ0) && bridge->func)) { | ||
553 | status = acpi_install_notify_handler(bridge->func->handle, | 538 | status = acpi_install_notify_handler(bridge->func->handle, |
554 | ACPI_SYSTEM_NOTIFY, | 539 | ACPI_SYSTEM_NOTIFY, |
555 | handle_hotplug_event_func, | 540 | handle_hotplug_event_func, |
@@ -630,9 +615,6 @@ static void remove_bridge(struct acpi_pci_root *root) | |||
630 | bridge = acpiphp_handle_to_bridge(handle); | 615 | bridge = acpiphp_handle_to_bridge(handle); |
631 | if (bridge) | 616 | if (bridge) |
632 | cleanup_bridge(bridge); | 617 | cleanup_bridge(bridge); |
633 | else | ||
634 | acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
635 | handle_hotplug_event_bridge); | ||
636 | } | 618 | } |
637 | 619 | ||
638 | static int power_on_slot(struct acpiphp_slot *slot) | 620 | static int power_on_slot(struct acpiphp_slot *slot) |
@@ -734,34 +716,25 @@ static unsigned char acpiphp_max_busnr(struct pci_bus *bus) | |||
734 | */ | 716 | */ |
735 | static int acpiphp_bus_add(struct acpiphp_func *func) | 717 | static int acpiphp_bus_add(struct acpiphp_func *func) |
736 | { | 718 | { |
737 | acpi_handle phandle; | 719 | struct acpi_device *device; |
738 | struct acpi_device *device, *pdevice; | ||
739 | int ret_val; | 720 | int ret_val; |
740 | 721 | ||
741 | acpi_get_parent(func->handle, &phandle); | ||
742 | if (acpi_bus_get_device(phandle, &pdevice)) { | ||
743 | dbg("no parent device, assuming NULL\n"); | ||
744 | pdevice = NULL; | ||
745 | } | ||
746 | if (!acpi_bus_get_device(func->handle, &device)) { | 722 | if (!acpi_bus_get_device(func->handle, &device)) { |
747 | dbg("bus exists... trim\n"); | 723 | dbg("bus exists... trim\n"); |
748 | /* this shouldn't be in here, so remove | 724 | /* this shouldn't be in here, so remove |
749 | * the bus then re-add it... | 725 | * the bus then re-add it... |
750 | */ | 726 | */ |
751 | ret_val = acpi_bus_trim(device, 1); | 727 | ret_val = acpi_bus_trim(device); |
752 | dbg("acpi_bus_trim return %x\n", ret_val); | 728 | dbg("acpi_bus_trim return %x\n", ret_val); |
753 | } | 729 | } |
754 | 730 | ||
755 | ret_val = acpi_bus_add(&device, pdevice, func->handle, | 731 | ret_val = acpi_bus_scan(func->handle); |
756 | ACPI_BUS_TYPE_DEVICE); | 732 | if (!ret_val) |
757 | if (ret_val) { | 733 | ret_val = acpi_bus_get_device(func->handle, &device); |
758 | dbg("error adding bus, %x\n", | 734 | |
759 | -ret_val); | 735 | if (ret_val) |
760 | goto acpiphp_bus_add_out; | 736 | dbg("error adding bus, %x\n", -ret_val); |
761 | } | ||
762 | ret_val = acpi_bus_start(device); | ||
763 | 737 | ||
764 | acpiphp_bus_add_out: | ||
765 | return ret_val; | 738 | return ret_val; |
766 | } | 739 | } |
767 | 740 | ||
@@ -781,7 +754,7 @@ static int acpiphp_bus_trim(acpi_handle handle) | |||
781 | return retval; | 754 | return retval; |
782 | } | 755 | } |
783 | 756 | ||
784 | retval = acpi_bus_trim(device, 1); | 757 | retval = acpi_bus_trim(device); |
785 | if (retval) | 758 | if (retval) |
786 | err("cannot remove from acpi list\n"); | 759 | err("cannot remove from acpi list\n"); |
787 | 760 | ||
@@ -806,6 +779,29 @@ static void acpiphp_set_acpi_region(struct acpiphp_slot *slot) | |||
806 | } | 779 | } |
807 | } | 780 | } |
808 | 781 | ||
782 | static void check_hotplug_bridge(struct acpiphp_slot *slot, struct pci_dev *dev) | ||
783 | { | ||
784 | struct acpiphp_func *func; | ||
785 | |||
786 | if (!dev->subordinate) | ||
787 | return; | ||
788 | |||
789 | /* quirk, or pcie could set it already */ | ||
790 | if (dev->is_hotplug_bridge) | ||
791 | return; | ||
792 | |||
793 | if (PCI_SLOT(dev->devfn) != slot->device) | ||
794 | return; | ||
795 | |||
796 | list_for_each_entry(func, &slot->funcs, sibling) { | ||
797 | if (PCI_FUNC(dev->devfn) == func->function) { | ||
798 | /* check if this bridge has ejectable slots */ | ||
799 | if ((detect_ejectable_slots(func->handle) > 0)) | ||
800 | dev->is_hotplug_bridge = 1; | ||
801 | break; | ||
802 | } | ||
803 | } | ||
804 | } | ||
809 | /** | 805 | /** |
810 | * enable_device - enable, configure a slot | 806 | * enable_device - enable, configure a slot |
811 | * @slot: slot to be enabled | 807 | * @slot: slot to be enabled |
@@ -825,6 +821,9 @@ static int __ref enable_device(struct acpiphp_slot *slot) | |||
825 | if (slot->flags & SLOT_ENABLED) | 821 | if (slot->flags & SLOT_ENABLED) |
826 | goto err_exit; | 822 | goto err_exit; |
827 | 823 | ||
824 | list_for_each_entry(func, &slot->funcs, sibling) | ||
825 | acpiphp_bus_add(func); | ||
826 | |||
828 | num = pci_scan_slot(bus, PCI_DEVFN(slot->device, 0)); | 827 | num = pci_scan_slot(bus, PCI_DEVFN(slot->device, 0)); |
829 | if (num == 0) { | 828 | if (num == 0) { |
830 | /* Maybe only part of funcs are added. */ | 829 | /* Maybe only part of funcs are added. */ |
@@ -840,15 +839,14 @@ static int __ref enable_device(struct acpiphp_slot *slot) | |||
840 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | 839 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || |
841 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { | 840 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { |
842 | max = pci_scan_bridge(bus, dev, max, pass); | 841 | max = pci_scan_bridge(bus, dev, max, pass); |
843 | if (pass && dev->subordinate) | 842 | if (pass && dev->subordinate) { |
843 | check_hotplug_bridge(slot, dev); | ||
844 | pci_bus_size_bridges(dev->subordinate); | 844 | pci_bus_size_bridges(dev->subordinate); |
845 | } | ||
845 | } | 846 | } |
846 | } | 847 | } |
847 | } | 848 | } |
848 | 849 | ||
849 | list_for_each_entry(func, &slot->funcs, sibling) | ||
850 | acpiphp_bus_add(func); | ||
851 | |||
852 | pci_bus_assign_resources(bus); | 850 | pci_bus_assign_resources(bus); |
853 | acpiphp_sanitize_bus(bus); | 851 | acpiphp_sanitize_bus(bus); |
854 | acpiphp_set_hpp_values(bus); | 852 | acpiphp_set_hpp_values(bus); |
@@ -1106,73 +1104,11 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus) | |||
1106 | } | 1104 | } |
1107 | } | 1105 | } |
1108 | 1106 | ||
1109 | /* Program resources in newly inserted bridge */ | ||
1110 | static int acpiphp_configure_bridge (acpi_handle handle) | ||
1111 | { | ||
1112 | struct pci_bus *bus; | ||
1113 | |||
1114 | if (acpi_is_root_bridge(handle)) { | ||
1115 | struct acpi_pci_root *root = acpi_pci_find_root(handle); | ||
1116 | bus = root->bus; | ||
1117 | } else { | ||
1118 | struct pci_dev *pdev = acpi_get_pci_dev(handle); | ||
1119 | bus = pdev->subordinate; | ||
1120 | pci_dev_put(pdev); | ||
1121 | } | ||
1122 | |||
1123 | pci_bus_size_bridges(bus); | ||
1124 | pci_bus_assign_resources(bus); | ||
1125 | acpiphp_sanitize_bus(bus); | ||
1126 | acpiphp_set_hpp_values(bus); | ||
1127 | pci_enable_bridges(bus); | ||
1128 | return 0; | ||
1129 | } | ||
1130 | |||
1131 | static void handle_bridge_insertion(acpi_handle handle, u32 type) | ||
1132 | { | ||
1133 | struct acpi_device *device, *pdevice; | ||
1134 | acpi_handle phandle; | ||
1135 | |||
1136 | if ((type != ACPI_NOTIFY_BUS_CHECK) && | ||
1137 | (type != ACPI_NOTIFY_DEVICE_CHECK)) { | ||
1138 | err("unexpected notification type %d\n", type); | ||
1139 | return; | ||
1140 | } | ||
1141 | |||
1142 | acpi_get_parent(handle, &phandle); | ||
1143 | if (acpi_bus_get_device(phandle, &pdevice)) { | ||
1144 | dbg("no parent device, assuming NULL\n"); | ||
1145 | pdevice = NULL; | ||
1146 | } | ||
1147 | if (acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE)) { | ||
1148 | err("cannot add bridge to acpi list\n"); | ||
1149 | return; | ||
1150 | } | ||
1151 | if (!acpiphp_configure_bridge(handle) && | ||
1152 | !acpi_bus_start(device)) | ||
1153 | add_bridge(handle); | ||
1154 | else | ||
1155 | err("cannot configure and start bridge\n"); | ||
1156 | |||
1157 | } | ||
1158 | |||
1159 | /* | 1107 | /* |
1160 | * ACPI event handlers | 1108 | * ACPI event handlers |
1161 | */ | 1109 | */ |
1162 | 1110 | ||
1163 | static acpi_status | 1111 | static acpi_status |
1164 | count_sub_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
1165 | { | ||
1166 | int *count = (int *)context; | ||
1167 | struct acpiphp_bridge *bridge; | ||
1168 | |||
1169 | bridge = acpiphp_handle_to_bridge(handle); | ||
1170 | if (bridge) | ||
1171 | (*count)++; | ||
1172 | return AE_OK ; | ||
1173 | } | ||
1174 | |||
1175 | static acpi_status | ||
1176 | check_sub_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) | 1112 | check_sub_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) |
1177 | { | 1113 | { |
1178 | struct acpiphp_bridge *bridge; | 1114 | struct acpiphp_bridge *bridge; |
@@ -1190,66 +1126,20 @@ check_sub_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
1190 | return AE_OK ; | 1126 | return AE_OK ; |
1191 | } | 1127 | } |
1192 | 1128 | ||
1193 | struct acpiphp_hp_work { | ||
1194 | struct work_struct work; | ||
1195 | acpi_handle handle; | ||
1196 | u32 type; | ||
1197 | void *context; | ||
1198 | }; | ||
1199 | |||
1200 | static void alloc_acpiphp_hp_work(acpi_handle handle, u32 type, | ||
1201 | void *context, | ||
1202 | void (*func)(struct work_struct *work)) | ||
1203 | { | ||
1204 | struct acpiphp_hp_work *hp_work; | ||
1205 | int ret; | ||
1206 | |||
1207 | hp_work = kmalloc(sizeof(*hp_work), GFP_KERNEL); | ||
1208 | if (!hp_work) | ||
1209 | return; | ||
1210 | |||
1211 | hp_work->handle = handle; | ||
1212 | hp_work->type = type; | ||
1213 | hp_work->context = context; | ||
1214 | |||
1215 | INIT_WORK(&hp_work->work, func); | ||
1216 | ret = queue_work(kacpi_hotplug_wq, &hp_work->work); | ||
1217 | if (!ret) | ||
1218 | kfree(hp_work); | ||
1219 | } | ||
1220 | |||
1221 | static void _handle_hotplug_event_bridge(struct work_struct *work) | 1129 | static void _handle_hotplug_event_bridge(struct work_struct *work) |
1222 | { | 1130 | { |
1223 | struct acpiphp_bridge *bridge; | 1131 | struct acpiphp_bridge *bridge; |
1224 | char objname[64]; | 1132 | char objname[64]; |
1225 | struct acpi_buffer buffer = { .length = sizeof(objname), | 1133 | struct acpi_buffer buffer = { .length = sizeof(objname), |
1226 | .pointer = objname }; | 1134 | .pointer = objname }; |
1227 | struct acpi_device *device; | 1135 | struct acpi_hp_work *hp_work; |
1228 | int num_sub_bridges = 0; | ||
1229 | struct acpiphp_hp_work *hp_work; | ||
1230 | acpi_handle handle; | 1136 | acpi_handle handle; |
1231 | u32 type; | 1137 | u32 type; |
1232 | 1138 | ||
1233 | hp_work = container_of(work, struct acpiphp_hp_work, work); | 1139 | hp_work = container_of(work, struct acpi_hp_work, work); |
1234 | handle = hp_work->handle; | 1140 | handle = hp_work->handle; |
1235 | type = hp_work->type; | 1141 | type = hp_work->type; |
1236 | 1142 | bridge = (struct acpiphp_bridge *)hp_work->context; | |
1237 | if (acpi_bus_get_device(handle, &device)) { | ||
1238 | /* This bridge must have just been physically inserted */ | ||
1239 | handle_bridge_insertion(handle, type); | ||
1240 | goto out; | ||
1241 | } | ||
1242 | |||
1243 | bridge = acpiphp_handle_to_bridge(handle); | ||
1244 | if (type == ACPI_NOTIFY_BUS_CHECK) { | ||
1245 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, ACPI_UINT32_MAX, | ||
1246 | count_sub_bridges, NULL, &num_sub_bridges, NULL); | ||
1247 | } | ||
1248 | |||
1249 | if (!bridge && !num_sub_bridges) { | ||
1250 | err("cannot get bridge info\n"); | ||
1251 | goto out; | ||
1252 | } | ||
1253 | 1143 | ||
1254 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | 1144 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); |
1255 | 1145 | ||
@@ -1257,14 +1147,10 @@ static void _handle_hotplug_event_bridge(struct work_struct *work) | |||
1257 | case ACPI_NOTIFY_BUS_CHECK: | 1147 | case ACPI_NOTIFY_BUS_CHECK: |
1258 | /* bus re-enumerate */ | 1148 | /* bus re-enumerate */ |
1259 | dbg("%s: Bus check notify on %s\n", __func__, objname); | 1149 | dbg("%s: Bus check notify on %s\n", __func__, objname); |
1260 | if (bridge) { | 1150 | dbg("%s: re-enumerating slots under %s\n", __func__, objname); |
1261 | dbg("%s: re-enumerating slots under %s\n", | 1151 | acpiphp_check_bridge(bridge); |
1262 | __func__, objname); | 1152 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, |
1263 | acpiphp_check_bridge(bridge); | 1153 | ACPI_UINT32_MAX, check_sub_bridges, NULL, NULL, NULL); |
1264 | } | ||
1265 | if (num_sub_bridges) | ||
1266 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, | ||
1267 | ACPI_UINT32_MAX, check_sub_bridges, NULL, NULL, NULL); | ||
1268 | break; | 1154 | break; |
1269 | 1155 | ||
1270 | case ACPI_NOTIFY_DEVICE_CHECK: | 1156 | case ACPI_NOTIFY_DEVICE_CHECK: |
@@ -1281,8 +1167,7 @@ static void _handle_hotplug_event_bridge(struct work_struct *work) | |||
1281 | case ACPI_NOTIFY_EJECT_REQUEST: | 1167 | case ACPI_NOTIFY_EJECT_REQUEST: |
1282 | /* request device eject */ | 1168 | /* request device eject */ |
1283 | dbg("%s: Device eject notify on %s\n", __func__, objname); | 1169 | dbg("%s: Device eject notify on %s\n", __func__, objname); |
1284 | if ((bridge->type != BRIDGE_TYPE_HOST) && | 1170 | if ((bridge->flags & BRIDGE_HAS_EJ0) && bridge->func) { |
1285 | (bridge->flags & BRIDGE_HAS_EJ0)) { | ||
1286 | struct acpiphp_slot *slot; | 1171 | struct acpiphp_slot *slot; |
1287 | slot = bridge->func->slot; | 1172 | slot = bridge->func->slot; |
1288 | if (!acpiphp_disable_slot(slot)) | 1173 | if (!acpiphp_disable_slot(slot)) |
@@ -1310,7 +1195,6 @@ static void _handle_hotplug_event_bridge(struct work_struct *work) | |||
1310 | break; | 1195 | break; |
1311 | } | 1196 | } |
1312 | 1197 | ||
1313 | out: | ||
1314 | kfree(hp_work); /* allocated in handle_hotplug_event_bridge */ | 1198 | kfree(hp_work); /* allocated in handle_hotplug_event_bridge */ |
1315 | } | 1199 | } |
1316 | 1200 | ||
@@ -1333,8 +1217,7 @@ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, | |||
1333 | * For now just re-add this work to the kacpi_hotplug_wq so we | 1217 | * For now just re-add this work to the kacpi_hotplug_wq so we |
1334 | * don't deadlock on hotplug actions. | 1218 | * don't deadlock on hotplug actions. |
1335 | */ | 1219 | */ |
1336 | alloc_acpiphp_hp_work(handle, type, context, | 1220 | alloc_acpi_hp_work(handle, type, context, _handle_hotplug_event_bridge); |
1337 | _handle_hotplug_event_bridge); | ||
1338 | } | 1221 | } |
1339 | 1222 | ||
1340 | static void _handle_hotplug_event_func(struct work_struct *work) | 1223 | static void _handle_hotplug_event_func(struct work_struct *work) |
@@ -1343,20 +1226,17 @@ static void _handle_hotplug_event_func(struct work_struct *work) | |||
1343 | char objname[64]; | 1226 | char objname[64]; |
1344 | struct acpi_buffer buffer = { .length = sizeof(objname), | 1227 | struct acpi_buffer buffer = { .length = sizeof(objname), |
1345 | .pointer = objname }; | 1228 | .pointer = objname }; |
1346 | struct acpiphp_hp_work *hp_work; | 1229 | struct acpi_hp_work *hp_work; |
1347 | acpi_handle handle; | 1230 | acpi_handle handle; |
1348 | u32 type; | 1231 | u32 type; |
1349 | void *context; | ||
1350 | 1232 | ||
1351 | hp_work = container_of(work, struct acpiphp_hp_work, work); | 1233 | hp_work = container_of(work, struct acpi_hp_work, work); |
1352 | handle = hp_work->handle; | 1234 | handle = hp_work->handle; |
1353 | type = hp_work->type; | 1235 | type = hp_work->type; |
1354 | context = hp_work->context; | 1236 | func = (struct acpiphp_func *)hp_work->context; |
1355 | 1237 | ||
1356 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | 1238 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); |
1357 | 1239 | ||
1358 | func = (struct acpiphp_func *)context; | ||
1359 | |||
1360 | switch (type) { | 1240 | switch (type) { |
1361 | case ACPI_NOTIFY_BUS_CHECK: | 1241 | case ACPI_NOTIFY_BUS_CHECK: |
1362 | /* bus re-enumerate */ | 1242 | /* bus re-enumerate */ |
@@ -1409,23 +1289,7 @@ static void handle_hotplug_event_func(acpi_handle handle, u32 type, | |||
1409 | * For now just re-add this work to the kacpi_hotplug_wq so we | 1289 | * For now just re-add this work to the kacpi_hotplug_wq so we |
1410 | * don't deadlock on hotplug actions. | 1290 | * don't deadlock on hotplug actions. |
1411 | */ | 1291 | */ |
1412 | alloc_acpiphp_hp_work(handle, type, context, | 1292 | alloc_acpi_hp_work(handle, type, context, _handle_hotplug_event_func); |
1413 | _handle_hotplug_event_func); | ||
1414 | } | ||
1415 | |||
1416 | static acpi_status | ||
1417 | find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
1418 | { | ||
1419 | int *count = (int *)context; | ||
1420 | |||
1421 | if (!acpi_is_root_bridge(handle)) | ||
1422 | return AE_OK; | ||
1423 | |||
1424 | (*count)++; | ||
1425 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
1426 | handle_hotplug_event_bridge, NULL); | ||
1427 | |||
1428 | return AE_OK ; | ||
1429 | } | 1293 | } |
1430 | 1294 | ||
1431 | static struct acpi_pci_driver acpi_pci_hp_driver = { | 1295 | static struct acpi_pci_driver acpi_pci_hp_driver = { |
@@ -1438,15 +1302,7 @@ static struct acpi_pci_driver acpi_pci_hp_driver = { | |||
1438 | */ | 1302 | */ |
1439 | int __init acpiphp_glue_init(void) | 1303 | int __init acpiphp_glue_init(void) |
1440 | { | 1304 | { |
1441 | int num = 0; | 1305 | acpi_pci_register_driver(&acpi_pci_hp_driver); |
1442 | |||
1443 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
1444 | ACPI_UINT32_MAX, find_root_bridges, NULL, &num, NULL); | ||
1445 | |||
1446 | if (num <= 0) | ||
1447 | return -1; | ||
1448 | else | ||
1449 | acpi_pci_register_driver(&acpi_pci_hp_driver); | ||
1450 | 1306 | ||
1451 | return 0; | 1307 | return 0; |
1452 | } | 1308 | } |
@@ -1462,28 +1318,6 @@ void acpiphp_glue_exit(void) | |||
1462 | acpi_pci_unregister_driver(&acpi_pci_hp_driver); | 1318 | acpi_pci_unregister_driver(&acpi_pci_hp_driver); |
1463 | } | 1319 | } |
1464 | 1320 | ||
1465 | |||
1466 | /** | ||
1467 | * acpiphp_get_num_slots - count number of slots in a system | ||
1468 | */ | ||
1469 | int __init acpiphp_get_num_slots(void) | ||
1470 | { | ||
1471 | struct acpiphp_bridge *bridge; | ||
1472 | int num_slots = 0; | ||
1473 | |||
1474 | list_for_each_entry(bridge, &bridge_list, list) { | ||
1475 | dbg("Bus %04x:%02x has %d slot%s\n", | ||
1476 | pci_domain_nr(bridge->pci_bus), | ||
1477 | bridge->pci_bus->number, bridge->nr_slots, | ||
1478 | bridge->nr_slots == 1 ? "" : "s"); | ||
1479 | num_slots += bridge->nr_slots; | ||
1480 | } | ||
1481 | |||
1482 | dbg("Total %d slots\n", num_slots); | ||
1483 | return num_slots; | ||
1484 | } | ||
1485 | |||
1486 | |||
1487 | /** | 1321 | /** |
1488 | * acpiphp_enable_slot - power on slot | 1322 | * acpiphp_enable_slot - power on slot |
1489 | * @slot: ACPI PHP slot | 1323 | * @slot: ACPI PHP slot |
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c index dcc75c785443..d8add34177f2 100644 --- a/drivers/pci/hotplug/cpci_hotplug_pci.c +++ b/drivers/pci/hotplug/cpci_hotplug_pci.c | |||
@@ -252,8 +252,8 @@ int cpci_led_off(struct slot* slot) | |||
252 | 252 | ||
253 | int __ref cpci_configure_slot(struct slot *slot) | 253 | int __ref cpci_configure_slot(struct slot *slot) |
254 | { | 254 | { |
255 | struct pci_dev *dev; | ||
255 | struct pci_bus *parent; | 256 | struct pci_bus *parent; |
256 | int fn; | ||
257 | 257 | ||
258 | dbg("%s - enter", __func__); | 258 | dbg("%s - enter", __func__); |
259 | 259 | ||
@@ -282,18 +282,13 @@ int __ref cpci_configure_slot(struct slot *slot) | |||
282 | } | 282 | } |
283 | parent = slot->dev->bus; | 283 | parent = slot->dev->bus; |
284 | 284 | ||
285 | for (fn = 0; fn < 8; fn++) { | 285 | list_for_each_entry(dev, &parent->devices, bus_list) |
286 | struct pci_dev *dev; | 286 | if (PCI_SLOT(dev->devfn) != PCI_SLOT(slot->devfn)) |
287 | |||
288 | dev = pci_get_slot(parent, | ||
289 | PCI_DEVFN(PCI_SLOT(slot->devfn), fn)); | ||
290 | if (!dev) | ||
291 | continue; | 287 | continue; |
292 | if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || | 288 | if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || |
293 | (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) | 289 | (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) |
294 | pci_hp_add_bridge(dev); | 290 | pci_hp_add_bridge(dev); |
295 | pci_dev_put(dev); | 291 | |
296 | } | ||
297 | 292 | ||
298 | pci_assign_unassigned_bridge_resources(parent->self); | 293 | pci_assign_unassigned_bridge_resources(parent->self); |
299 | 294 | ||
@@ -305,8 +300,7 @@ int __ref cpci_configure_slot(struct slot *slot) | |||
305 | 300 | ||
306 | int cpci_unconfigure_slot(struct slot* slot) | 301 | int cpci_unconfigure_slot(struct slot* slot) |
307 | { | 302 | { |
308 | int i; | 303 | struct pci_dev *dev, *temp; |
309 | struct pci_dev *dev; | ||
310 | 304 | ||
311 | dbg("%s - enter", __func__); | 305 | dbg("%s - enter", __func__); |
312 | if (!slot->dev) { | 306 | if (!slot->dev) { |
@@ -314,13 +308,12 @@ int cpci_unconfigure_slot(struct slot* slot) | |||
314 | return -ENODEV; | 308 | return -ENODEV; |
315 | } | 309 | } |
316 | 310 | ||
317 | for (i = 0; i < 8; i++) { | 311 | list_for_each_entry_safe(dev, temp, &slot->bus->devices, bus_list) { |
318 | dev = pci_get_slot(slot->bus, | 312 | if (PCI_SLOT(dev->devfn) != PCI_SLOT(slot->devfn)) |
319 | PCI_DEVFN(PCI_SLOT(slot->devfn), i)); | 313 | continue; |
320 | if (dev) { | 314 | pci_dev_get(dev); |
321 | pci_stop_and_remove_bus_device(dev); | 315 | pci_stop_and_remove_bus_device(dev); |
322 | pci_dev_put(dev); | 316 | pci_dev_put(dev); |
323 | } | ||
324 | } | 317 | } |
325 | pci_dev_put(slot->dev); | 318 | pci_dev_put(slot->dev); |
326 | slot->dev = NULL; | 319 | slot->dev = NULL; |
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c index 36112fe212d3..d282019cda5f 100644 --- a/drivers/pci/hotplug/cpqphp_ctrl.c +++ b/drivers/pci/hotplug/cpqphp_ctrl.c | |||
@@ -1900,8 +1900,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1900 | dbg("power fault\n"); | 1900 | dbg("power fault\n"); |
1901 | } else { | 1901 | } else { |
1902 | /* refresh notification */ | 1902 | /* refresh notification */ |
1903 | if (p_slot) | 1903 | update_slot_info(ctrl, p_slot); |
1904 | update_slot_info(ctrl, p_slot); | ||
1905 | } | 1904 | } |
1906 | 1905 | ||
1907 | ctrl->event_queue[loop].event_type = 0; | 1906 | ctrl->event_queue[loop].event_type = 0; |
@@ -2520,44 +2519,28 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2520 | 2519 | ||
2521 | /* If we have IO resources copy them and fill in the bridge's | 2520 | /* If we have IO resources copy them and fill in the bridge's |
2522 | * IO range registers */ | 2521 | * IO range registers */ |
2523 | if (io_node) { | 2522 | memcpy(hold_IO_node, io_node, sizeof(struct pci_resource)); |
2524 | memcpy(hold_IO_node, io_node, sizeof(struct pci_resource)); | 2523 | io_node->next = NULL; |
2525 | io_node->next = NULL; | ||
2526 | 2524 | ||
2527 | /* set IO base and Limit registers */ | 2525 | /* set IO base and Limit registers */ |
2528 | temp_byte = io_node->base >> 8; | 2526 | temp_byte = io_node->base >> 8; |
2529 | rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_BASE, temp_byte); | 2527 | rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_BASE, temp_byte); |
2530 | 2528 | ||
2531 | temp_byte = (io_node->base + io_node->length - 1) >> 8; | 2529 | temp_byte = (io_node->base + io_node->length - 1) >> 8; |
2532 | rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_LIMIT, temp_byte); | 2530 | rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_LIMIT, temp_byte); |
2533 | } else { | ||
2534 | kfree(hold_IO_node); | ||
2535 | hold_IO_node = NULL; | ||
2536 | } | ||
2537 | |||
2538 | /* If we have memory resources copy them and fill in the | ||
2539 | * bridge's memory range registers. Otherwise, fill in the | ||
2540 | * range registers with values that disable them. */ | ||
2541 | if (mem_node) { | ||
2542 | memcpy(hold_mem_node, mem_node, sizeof(struct pci_resource)); | ||
2543 | mem_node->next = NULL; | ||
2544 | |||
2545 | /* set Mem base and Limit registers */ | ||
2546 | temp_word = mem_node->base >> 16; | ||
2547 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_BASE, temp_word); | ||
2548 | 2531 | ||
2549 | temp_word = (mem_node->base + mem_node->length - 1) >> 16; | 2532 | /* Copy the memory resources and fill in the bridge's memory |
2550 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word); | 2533 | * range registers. |
2551 | } else { | 2534 | */ |
2552 | temp_word = 0xFFFF; | 2535 | memcpy(hold_mem_node, mem_node, sizeof(struct pci_resource)); |
2553 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_BASE, temp_word); | 2536 | mem_node->next = NULL; |
2554 | 2537 | ||
2555 | temp_word = 0x0000; | 2538 | /* set Mem base and Limit registers */ |
2556 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word); | 2539 | temp_word = mem_node->base >> 16; |
2540 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_BASE, temp_word); | ||
2557 | 2541 | ||
2558 | kfree(hold_mem_node); | 2542 | temp_word = (mem_node->base + mem_node->length - 1) >> 16; |
2559 | hold_mem_node = NULL; | 2543 | rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word); |
2560 | } | ||
2561 | 2544 | ||
2562 | memcpy(hold_p_mem_node, p_mem_node, sizeof(struct pci_resource)); | 2545 | memcpy(hold_p_mem_node, p_mem_node, sizeof(struct pci_resource)); |
2563 | p_mem_node->next = NULL; | 2546 | p_mem_node->next = NULL; |
@@ -2627,7 +2610,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2627 | /* Return unused bus resources | 2610 | /* Return unused bus resources |
2628 | * First use the temporary node to store information for | 2611 | * First use the temporary node to store information for |
2629 | * the board */ | 2612 | * the board */ |
2630 | if (hold_bus_node && bus_node && temp_resources.bus_head) { | 2613 | if (bus_node && temp_resources.bus_head) { |
2631 | hold_bus_node->length = bus_node->base - hold_bus_node->base; | 2614 | hold_bus_node->length = bus_node->base - hold_bus_node->base; |
2632 | 2615 | ||
2633 | hold_bus_node->next = func->bus_head; | 2616 | hold_bus_node->next = func->bus_head; |
@@ -2751,7 +2734,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func | |||
2751 | } | 2734 | } |
2752 | /* If we have prefetchable memory space available and there | 2735 | /* If we have prefetchable memory space available and there |
2753 | * is some left at the end, return the unused portion */ | 2736 | * is some left at the end, return the unused portion */ |
2754 | if (hold_p_mem_node && temp_resources.p_mem_head) { | 2737 | if (temp_resources.p_mem_head) { |
2755 | p_mem_node = do_pre_bridge_resource_split(&(temp_resources.p_mem_head), | 2738 | p_mem_node = do_pre_bridge_resource_split(&(temp_resources.p_mem_head), |
2756 | &hold_p_mem_node, 0x100000); | 2739 | &hold_p_mem_node, 0x100000); |
2757 | 2740 | ||
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 916bf4f53aba..874a3baf1db0 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c | |||
@@ -294,7 +294,6 @@ static void pciehp_remove(struct pcie_device *dev) | |||
294 | #ifdef CONFIG_PM | 294 | #ifdef CONFIG_PM |
295 | static int pciehp_suspend (struct pcie_device *dev) | 295 | static int pciehp_suspend (struct pcie_device *dev) |
296 | { | 296 | { |
297 | dev_info(&dev->device, "%s ENTRY\n", __func__); | ||
298 | return 0; | 297 | return 0; |
299 | } | 298 | } |
300 | 299 | ||
@@ -304,7 +303,6 @@ static int pciehp_resume (struct pcie_device *dev) | |||
304 | struct slot *slot; | 303 | struct slot *slot; |
305 | u8 status; | 304 | u8 status; |
306 | 305 | ||
307 | dev_info(&dev->device, "%s ENTRY\n", __func__); | ||
308 | ctrl = get_service_data(dev); | 306 | ctrl = get_service_data(dev); |
309 | 307 | ||
310 | /* reinitialize the chipset's event detection logic */ | 308 | /* reinitialize the chipset's event detection logic */ |
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c index 09cecaf450c5..aac7a40e4a4a 100644 --- a/drivers/pci/hotplug/pciehp_pci.c +++ b/drivers/pci/hotplug/pciehp_pci.c | |||
@@ -39,7 +39,7 @@ int pciehp_configure_device(struct slot *p_slot) | |||
39 | struct pci_dev *dev; | 39 | struct pci_dev *dev; |
40 | struct pci_dev *bridge = p_slot->ctrl->pcie->port; | 40 | struct pci_dev *bridge = p_slot->ctrl->pcie->port; |
41 | struct pci_bus *parent = bridge->subordinate; | 41 | struct pci_bus *parent = bridge->subordinate; |
42 | int num, fn; | 42 | int num; |
43 | struct controller *ctrl = p_slot->ctrl; | 43 | struct controller *ctrl = p_slot->ctrl; |
44 | 44 | ||
45 | dev = pci_get_slot(parent, PCI_DEVFN(0, 0)); | 45 | dev = pci_get_slot(parent, PCI_DEVFN(0, 0)); |
@@ -57,28 +57,18 @@ int pciehp_configure_device(struct slot *p_slot) | |||
57 | return -ENODEV; | 57 | return -ENODEV; |
58 | } | 58 | } |
59 | 59 | ||
60 | for (fn = 0; fn < 8; fn++) { | 60 | list_for_each_entry(dev, &parent->devices, bus_list) |
61 | dev = pci_get_slot(parent, PCI_DEVFN(0, fn)); | ||
62 | if (!dev) | ||
63 | continue; | ||
64 | if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || | 61 | if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || |
65 | (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) | 62 | (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) |
66 | pci_hp_add_bridge(dev); | 63 | pci_hp_add_bridge(dev); |
67 | pci_dev_put(dev); | ||
68 | } | ||
69 | 64 | ||
70 | pci_assign_unassigned_bridge_resources(bridge); | 65 | pci_assign_unassigned_bridge_resources(bridge); |
71 | 66 | ||
72 | for (fn = 0; fn < 8; fn++) { | 67 | list_for_each_entry(dev, &parent->devices, bus_list) { |
73 | dev = pci_get_slot(parent, PCI_DEVFN(0, fn)); | 68 | if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) |
74 | if (!dev) | ||
75 | continue; | 69 | continue; |
76 | if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) { | 70 | |
77 | pci_dev_put(dev); | ||
78 | continue; | ||
79 | } | ||
80 | pci_configure_slot(dev); | 71 | pci_configure_slot(dev); |
81 | pci_dev_put(dev); | ||
82 | } | 72 | } |
83 | 73 | ||
84 | pci_bus_add_devices(parent); | 74 | pci_bus_add_devices(parent); |
@@ -89,9 +79,9 @@ int pciehp_configure_device(struct slot *p_slot) | |||
89 | int pciehp_unconfigure_device(struct slot *p_slot) | 79 | int pciehp_unconfigure_device(struct slot *p_slot) |
90 | { | 80 | { |
91 | int ret, rc = 0; | 81 | int ret, rc = 0; |
92 | int j; | ||
93 | u8 bctl = 0; | 82 | u8 bctl = 0; |
94 | u8 presence = 0; | 83 | u8 presence = 0; |
84 | struct pci_dev *dev, *temp; | ||
95 | struct pci_bus *parent = p_slot->ctrl->pcie->port->subordinate; | 85 | struct pci_bus *parent = p_slot->ctrl->pcie->port->subordinate; |
96 | u16 command; | 86 | u16 command; |
97 | struct controller *ctrl = p_slot->ctrl; | 87 | struct controller *ctrl = p_slot->ctrl; |
@@ -102,33 +92,31 @@ int pciehp_unconfigure_device(struct slot *p_slot) | |||
102 | if (ret) | 92 | if (ret) |
103 | presence = 0; | 93 | presence = 0; |
104 | 94 | ||
105 | for (j = 0; j < 8; j++) { | 95 | list_for_each_entry_safe(dev, temp, &parent->devices, bus_list) { |
106 | struct pci_dev *temp = pci_get_slot(parent, PCI_DEVFN(0, j)); | 96 | pci_dev_get(dev); |
107 | if (!temp) | 97 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE && presence) { |
108 | continue; | 98 | pci_read_config_byte(dev, PCI_BRIDGE_CONTROL, &bctl); |
109 | if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE && presence) { | ||
110 | pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl); | ||
111 | if (bctl & PCI_BRIDGE_CTL_VGA) { | 99 | if (bctl & PCI_BRIDGE_CTL_VGA) { |
112 | ctrl_err(ctrl, | 100 | ctrl_err(ctrl, |
113 | "Cannot remove display device %s\n", | 101 | "Cannot remove display device %s\n", |
114 | pci_name(temp)); | 102 | pci_name(dev)); |
115 | pci_dev_put(temp); | 103 | pci_dev_put(dev); |
116 | rc = -EINVAL; | 104 | rc = -EINVAL; |
117 | break; | 105 | break; |
118 | } | 106 | } |
119 | } | 107 | } |
120 | pci_stop_and_remove_bus_device(temp); | 108 | pci_stop_and_remove_bus_device(dev); |
121 | /* | 109 | /* |
122 | * Ensure that no new Requests will be generated from | 110 | * Ensure that no new Requests will be generated from |
123 | * the device. | 111 | * the device. |
124 | */ | 112 | */ |
125 | if (presence) { | 113 | if (presence) { |
126 | pci_read_config_word(temp, PCI_COMMAND, &command); | 114 | pci_read_config_word(dev, PCI_COMMAND, &command); |
127 | command &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_SERR); | 115 | command &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_SERR); |
128 | command |= PCI_COMMAND_INTX_DISABLE; | 116 | command |= PCI_COMMAND_INTX_DISABLE; |
129 | pci_write_config_word(temp, PCI_COMMAND, command); | 117 | pci_write_config_word(dev, PCI_COMMAND, command); |
130 | } | 118 | } |
131 | pci_dev_put(temp); | 119 | pci_dev_put(dev); |
132 | } | 120 | } |
133 | 121 | ||
134 | return rc; | 122 | return rc; |
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c index f64ca92253da..180e760c1653 100644 --- a/drivers/pci/hotplug/sgi_hotplug.c +++ b/drivers/pci/hotplug/sgi_hotplug.c | |||
@@ -334,7 +334,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
334 | struct slot *slot = bss_hotplug_slot->private; | 334 | struct slot *slot = bss_hotplug_slot->private; |
335 | struct pci_bus *new_bus = NULL; | 335 | struct pci_bus *new_bus = NULL; |
336 | struct pci_dev *dev; | 336 | struct pci_dev *dev; |
337 | int func, num_funcs; | 337 | int num_funcs; |
338 | int new_ppb = 0; | 338 | int new_ppb = 0; |
339 | int rc; | 339 | int rc; |
340 | char *ssdt = NULL; | 340 | char *ssdt = NULL; |
@@ -381,29 +381,26 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
381 | * to the Linux PCI interface and tell the drivers | 381 | * to the Linux PCI interface and tell the drivers |
382 | * about them. | 382 | * about them. |
383 | */ | 383 | */ |
384 | for (func = 0; func < num_funcs; func++) { | 384 | list_for_each_entry(dev, &slot->pci_bus->devices, bus_list) { |
385 | dev = pci_get_slot(slot->pci_bus, | 385 | if (PCI_SLOT(dev->devfn) != slot->device_num + 1) |
386 | PCI_DEVFN(slot->device_num + 1, | 386 | continue; |
387 | PCI_FUNC(func))); | 387 | |
388 | if (dev) { | 388 | /* Need to do slot fixup on PPB before fixup of children |
389 | /* Need to do slot fixup on PPB before fixup of children | 389 | * (PPB's pcidev_info needs to be in pcidev_info list |
390 | * (PPB's pcidev_info needs to be in pcidev_info list | 390 | * before child's SN_PCIDEV_INFO() call to setup |
391 | * before child's SN_PCIDEV_INFO() call to setup | 391 | * pdi_host_pcidev_info). |
392 | * pdi_host_pcidev_info). | 392 | */ |
393 | */ | 393 | pcibios_fixup_device_resources(dev); |
394 | pcibios_fixup_device_resources(dev); | 394 | if (SN_ACPI_BASE_SUPPORT()) |
395 | if (SN_ACPI_BASE_SUPPORT()) | 395 | sn_acpi_slot_fixup(dev); |
396 | sn_acpi_slot_fixup(dev); | 396 | else |
397 | else | 397 | sn_io_slot_fixup(dev); |
398 | sn_io_slot_fixup(dev); | 398 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { |
399 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { | 399 | pci_hp_add_bridge(dev); |
400 | pci_hp_add_bridge(dev); | 400 | if (dev->subordinate) { |
401 | if (dev->subordinate) { | 401 | new_bus = dev->subordinate; |
402 | new_bus = dev->subordinate; | 402 | new_ppb = 1; |
403 | new_ppb = 1; | ||
404 | } | ||
405 | } | 403 | } |
406 | pci_dev_put(dev); | ||
407 | } | 404 | } |
408 | } | 405 | } |
409 | 406 | ||
@@ -412,7 +409,6 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
412 | if (SN_ACPI_BASE_SUPPORT() && ssdt) { | 409 | if (SN_ACPI_BASE_SUPPORT() && ssdt) { |
413 | unsigned long long adr; | 410 | unsigned long long adr; |
414 | struct acpi_device *pdevice; | 411 | struct acpi_device *pdevice; |
415 | struct acpi_device *device; | ||
416 | acpi_handle phandle; | 412 | acpi_handle phandle; |
417 | acpi_handle chandle = NULL; | 413 | acpi_handle chandle = NULL; |
418 | acpi_handle rethandle; | 414 | acpi_handle rethandle; |
@@ -448,17 +444,14 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
448 | if (ACPI_SUCCESS(ret) && | 444 | if (ACPI_SUCCESS(ret) && |
449 | (adr>>16) == (slot->device_num + 1)) { | 445 | (adr>>16) == (slot->device_num + 1)) { |
450 | 446 | ||
451 | ret = acpi_bus_add(&device, pdevice, chandle, | 447 | ret = acpi_bus_scan(chandle); |
452 | ACPI_BUS_TYPE_DEVICE); | ||
453 | if (ACPI_FAILURE(ret)) { | 448 | if (ACPI_FAILURE(ret)) { |
454 | printk(KERN_ERR "%s: acpi_bus_add " | 449 | printk(KERN_ERR "%s: acpi_bus_scan " |
455 | "failed (0x%x) for slot %d " | 450 | "failed (0x%x) for slot %d " |
456 | "func %d\n", __func__, | 451 | "func %d\n", __func__, |
457 | ret, (int)(adr>>16), | 452 | ret, (int)(adr>>16), |
458 | (int)(adr&0xffff)); | 453 | (int)(adr&0xffff)); |
459 | /* try to continue on */ | 454 | /* try to continue on */ |
460 | } else { | ||
461 | acpi_bus_start(device); | ||
462 | } | 455 | } |
463 | } | 456 | } |
464 | } | 457 | } |
@@ -485,8 +478,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
485 | static int disable_slot(struct hotplug_slot *bss_hotplug_slot) | 478 | static int disable_slot(struct hotplug_slot *bss_hotplug_slot) |
486 | { | 479 | { |
487 | struct slot *slot = bss_hotplug_slot->private; | 480 | struct slot *slot = bss_hotplug_slot->private; |
488 | struct pci_dev *dev; | 481 | struct pci_dev *dev, *temp; |
489 | int func; | ||
490 | int rc; | 482 | int rc; |
491 | acpi_owner_id ssdt_id = 0; | 483 | acpi_owner_id ssdt_id = 0; |
492 | 484 | ||
@@ -539,22 +531,21 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot) | |||
539 | ret = acpi_bus_get_device(chandle, | 531 | ret = acpi_bus_get_device(chandle, |
540 | &device); | 532 | &device); |
541 | if (ACPI_SUCCESS(ret)) | 533 | if (ACPI_SUCCESS(ret)) |
542 | acpi_bus_trim(device, 1); | 534 | acpi_bus_trim(device); |
543 | } | 535 | } |
544 | } | 536 | } |
545 | 537 | ||
546 | } | 538 | } |
547 | 539 | ||
548 | /* Free the SN resources assigned to the Linux device.*/ | 540 | /* Free the SN resources assigned to the Linux device.*/ |
549 | for (func = 0; func < 8; func++) { | 541 | list_for_each_entry_safe(dev, temp, &slot->pci_bus->devices, bus_list) { |
550 | dev = pci_get_slot(slot->pci_bus, | 542 | if (PCI_SLOT(dev->devfn) != slot->device_num + 1) |
551 | PCI_DEVFN(slot->device_num + 1, | 543 | continue; |
552 | PCI_FUNC(func))); | 544 | |
553 | if (dev) { | 545 | pci_dev_get(dev); |
554 | sn_bus_free_data(dev); | 546 | sn_bus_free_data(dev); |
555 | pci_stop_and_remove_bus_device(dev); | 547 | pci_stop_and_remove_bus_device(dev); |
556 | pci_dev_put(dev); | 548 | pci_dev_put(dev); |
557 | } | ||
558 | } | 549 | } |
559 | 550 | ||
560 | /* Remove the SSDT for the slot from the ACPI namespace */ | 551 | /* Remove the SSDT for the slot from the ACPI namespace */ |
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c index c627ed9957d1..b0e83132542e 100644 --- a/drivers/pci/hotplug/shpchp_pci.c +++ b/drivers/pci/hotplug/shpchp_pci.c | |||
@@ -40,7 +40,7 @@ int __ref shpchp_configure_device(struct slot *p_slot) | |||
40 | struct controller *ctrl = p_slot->ctrl; | 40 | struct controller *ctrl = p_slot->ctrl; |
41 | struct pci_dev *bridge = ctrl->pci_dev; | 41 | struct pci_dev *bridge = ctrl->pci_dev; |
42 | struct pci_bus *parent = bridge->subordinate; | 42 | struct pci_bus *parent = bridge->subordinate; |
43 | int num, fn; | 43 | int num; |
44 | 44 | ||
45 | dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); | 45 | dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); |
46 | if (dev) { | 46 | if (dev) { |
@@ -57,24 +57,20 @@ int __ref shpchp_configure_device(struct slot *p_slot) | |||
57 | return -ENODEV; | 57 | return -ENODEV; |
58 | } | 58 | } |
59 | 59 | ||
60 | for (fn = 0; fn < 8; fn++) { | 60 | list_for_each_entry(dev, &parent->devices, bus_list) { |
61 | dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, fn)); | 61 | if (PCI_SLOT(dev->devfn) != p_slot->device) |
62 | if (!dev) | ||
63 | continue; | 62 | continue; |
64 | if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || | 63 | if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || |
65 | (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) | 64 | (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) |
66 | pci_hp_add_bridge(dev); | 65 | pci_hp_add_bridge(dev); |
67 | pci_dev_put(dev); | ||
68 | } | 66 | } |
69 | 67 | ||
70 | pci_assign_unassigned_bridge_resources(bridge); | 68 | pci_assign_unassigned_bridge_resources(bridge); |
71 | 69 | ||
72 | for (fn = 0; fn < 8; fn++) { | 70 | list_for_each_entry(dev, &parent->devices, bus_list) { |
73 | dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, fn)); | 71 | if (PCI_SLOT(dev->devfn) != p_slot->device) |
74 | if (!dev) | ||
75 | continue; | 72 | continue; |
76 | pci_configure_slot(dev); | 73 | pci_configure_slot(dev); |
77 | pci_dev_put(dev); | ||
78 | } | 74 | } |
79 | 75 | ||
80 | pci_bus_add_devices(parent); | 76 | pci_bus_add_devices(parent); |
@@ -85,32 +81,32 @@ int __ref shpchp_configure_device(struct slot *p_slot) | |||
85 | int shpchp_unconfigure_device(struct slot *p_slot) | 81 | int shpchp_unconfigure_device(struct slot *p_slot) |
86 | { | 82 | { |
87 | int rc = 0; | 83 | int rc = 0; |
88 | int j; | ||
89 | u8 bctl = 0; | 84 | u8 bctl = 0; |
90 | struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; | 85 | struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; |
86 | struct pci_dev *dev, *temp; | ||
91 | struct controller *ctrl = p_slot->ctrl; | 87 | struct controller *ctrl = p_slot->ctrl; |
92 | 88 | ||
93 | ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:%02x\n", | 89 | ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:%02x\n", |
94 | __func__, pci_domain_nr(parent), p_slot->bus, p_slot->device); | 90 | __func__, pci_domain_nr(parent), p_slot->bus, p_slot->device); |
95 | 91 | ||
96 | for (j = 0; j < 8 ; j++) { | 92 | list_for_each_entry_safe(dev, temp, &parent->devices, bus_list) { |
97 | struct pci_dev *temp = pci_get_slot(parent, | 93 | if (PCI_SLOT(dev->devfn) != p_slot->device) |
98 | (p_slot->device << 3) | j); | ||
99 | if (!temp) | ||
100 | continue; | 94 | continue; |
101 | if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE) { | 95 | |
102 | pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl); | 96 | pci_dev_get(dev); |
97 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { | ||
98 | pci_read_config_byte(dev, PCI_BRIDGE_CONTROL, &bctl); | ||
103 | if (bctl & PCI_BRIDGE_CTL_VGA) { | 99 | if (bctl & PCI_BRIDGE_CTL_VGA) { |
104 | ctrl_err(ctrl, | 100 | ctrl_err(ctrl, |
105 | "Cannot remove display device %s\n", | 101 | "Cannot remove display device %s\n", |
106 | pci_name(temp)); | 102 | pci_name(dev)); |
107 | pci_dev_put(temp); | 103 | pci_dev_put(dev); |
108 | rc = -EINVAL; | 104 | rc = -EINVAL; |
109 | break; | 105 | break; |
110 | } | 106 | } |
111 | } | 107 | } |
112 | pci_stop_and_remove_bus_device(temp); | 108 | pci_stop_and_remove_bus_device(dev); |
113 | pci_dev_put(temp); | 109 | pci_dev_put(dev); |
114 | } | 110 | } |
115 | return rc; | 111 | return rc; |
116 | } | 112 | } |
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index bafd2bbcaf65..4ea7139db1be 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c | |||
@@ -33,7 +33,6 @@ static inline u8 virtfn_devfn(struct pci_dev *dev, int id) | |||
33 | 33 | ||
34 | static struct pci_bus *virtfn_add_bus(struct pci_bus *bus, int busnr) | 34 | static struct pci_bus *virtfn_add_bus(struct pci_bus *bus, int busnr) |
35 | { | 35 | { |
36 | int rc; | ||
37 | struct pci_bus *child; | 36 | struct pci_bus *child; |
38 | 37 | ||
39 | if (bus->number == busnr) | 38 | if (bus->number == busnr) |
@@ -48,12 +47,7 @@ static struct pci_bus *virtfn_add_bus(struct pci_bus *bus, int busnr) | |||
48 | return NULL; | 47 | return NULL; |
49 | 48 | ||
50 | pci_bus_insert_busn_res(child, busnr, busnr); | 49 | pci_bus_insert_busn_res(child, busnr, busnr); |
51 | child->dev.parent = bus->bridge; | 50 | bus->is_added = 1; |
52 | rc = pci_bus_add_child(child); | ||
53 | if (rc) { | ||
54 | pci_remove_bus(child); | ||
55 | return NULL; | ||
56 | } | ||
57 | 51 | ||
58 | return child; | 52 | return child; |
59 | } | 53 | } |
@@ -123,8 +117,6 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset) | |||
123 | virtfn->is_virtfn = 1; | 117 | virtfn->is_virtfn = 1; |
124 | 118 | ||
125 | rc = pci_bus_add_device(virtfn); | 119 | rc = pci_bus_add_device(virtfn); |
126 | if (rc) | ||
127 | goto failed1; | ||
128 | sprintf(buf, "virtfn%u", id); | 120 | sprintf(buf, "virtfn%u", id); |
129 | rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf); | 121 | rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf); |
130 | if (rc) | 122 | if (rc) |
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 1af4008182fd..1c2587c40299 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -283,7 +283,6 @@ static struct pci_platform_pm_ops acpi_pci_platform_pm = { | |||
283 | .is_manageable = acpi_pci_power_manageable, | 283 | .is_manageable = acpi_pci_power_manageable, |
284 | .set_state = acpi_pci_set_power_state, | 284 | .set_state = acpi_pci_set_power_state, |
285 | .choose_state = acpi_pci_choose_state, | 285 | .choose_state = acpi_pci_choose_state, |
286 | .can_wakeup = acpi_pci_can_wakeup, | ||
287 | .sleep_wake = acpi_pci_sleep_wake, | 286 | .sleep_wake = acpi_pci_sleep_wake, |
288 | .run_wake = acpi_pci_run_wake, | 287 | .run_wake = acpi_pci_run_wake, |
289 | }; | 288 | }; |
@@ -303,28 +302,66 @@ static int acpi_pci_find_device(struct device *dev, acpi_handle *handle) | |||
303 | return 0; | 302 | return 0; |
304 | } | 303 | } |
305 | 304 | ||
306 | static int acpi_pci_find_root_bridge(struct device *dev, acpi_handle *handle) | 305 | static void pci_acpi_setup(struct device *dev) |
307 | { | 306 | { |
308 | int num; | 307 | struct pci_dev *pci_dev = to_pci_dev(dev); |
309 | unsigned int seg, bus; | 308 | acpi_handle handle = ACPI_HANDLE(dev); |
309 | struct acpi_device *adev; | ||
310 | acpi_status status; | ||
311 | acpi_handle dummy; | ||
310 | 312 | ||
311 | /* | 313 | /* |
312 | * The string should be the same as root bridge's name | 314 | * Evaluate and parse _PRT, if exists. This code allows parsing of |
313 | * Please look at 'pci_scan_bus_parented' | 315 | * _PRT objects within the scope of non-bridge devices. Note that |
316 | * _PRTs within the scope of a PCI bridge assume the bridge's | ||
317 | * subordinate bus number. | ||
318 | * | ||
319 | * TBD: Can _PRTs exist within the scope of non-bridge PCI devices? | ||
314 | */ | 320 | */ |
315 | num = sscanf(dev_name(dev), "pci%04x:%02x", &seg, &bus); | 321 | status = acpi_get_handle(handle, METHOD_NAME__PRT, &dummy); |
316 | if (num != 2) | 322 | if (ACPI_SUCCESS(status)) { |
317 | return -ENODEV; | 323 | unsigned char bus; |
318 | *handle = acpi_get_pci_rootbridge_handle(seg, bus); | 324 | |
319 | if (!*handle) | 325 | bus = pci_dev->subordinate ? |
320 | return -ENODEV; | 326 | pci_dev->subordinate->number : pci_dev->bus->number; |
321 | return 0; | 327 | acpi_pci_irq_add_prt(handle, pci_domain_nr(pci_dev->bus), bus); |
328 | } | ||
329 | |||
330 | acpi_power_resource_register_device(dev, handle); | ||
331 | if (acpi_bus_get_device(handle, &adev) || !adev->wakeup.flags.valid) | ||
332 | return; | ||
333 | |||
334 | device_set_wakeup_capable(dev, true); | ||
335 | acpi_pci_sleep_wake(pci_dev, false); | ||
336 | |||
337 | pci_acpi_add_pm_notifier(adev, pci_dev); | ||
338 | if (adev->wakeup.flags.run_wake) | ||
339 | device_set_run_wake(dev, true); | ||
340 | } | ||
341 | |||
342 | static void pci_acpi_cleanup(struct device *dev) | ||
343 | { | ||
344 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
345 | acpi_handle handle = ACPI_HANDLE(dev); | ||
346 | struct acpi_device *adev; | ||
347 | |||
348 | if (!acpi_bus_get_device(handle, &adev) && adev->wakeup.flags.valid) { | ||
349 | device_set_wakeup_capable(dev, false); | ||
350 | device_set_run_wake(dev, false); | ||
351 | pci_acpi_remove_pm_notifier(adev); | ||
352 | } | ||
353 | acpi_power_resource_unregister_device(dev, handle); | ||
354 | |||
355 | if (pci_dev->subordinate) | ||
356 | acpi_pci_irq_del_prt(pci_domain_nr(pci_dev->bus), | ||
357 | pci_dev->subordinate->number); | ||
322 | } | 358 | } |
323 | 359 | ||
324 | static struct acpi_bus_type acpi_pci_bus = { | 360 | static struct acpi_bus_type acpi_pci_bus = { |
325 | .bus = &pci_bus_type, | 361 | .bus = &pci_bus_type, |
326 | .find_device = acpi_pci_find_device, | 362 | .find_device = acpi_pci_find_device, |
327 | .find_bridge = acpi_pci_find_root_bridge, | 363 | .setup = pci_acpi_setup, |
364 | .cleanup = pci_acpi_cleanup, | ||
328 | }; | 365 | }; |
329 | 366 | ||
330 | static int __init acpi_pci_init(void) | 367 | static int __init acpi_pci_init(void) |
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index f9aa311b9f34..1fa1e482a999 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -1190,9 +1190,13 @@ pci_dev_driver(const struct pci_dev *dev) | |||
1190 | static int pci_bus_match(struct device *dev, struct device_driver *drv) | 1190 | static int pci_bus_match(struct device *dev, struct device_driver *drv) |
1191 | { | 1191 | { |
1192 | struct pci_dev *pci_dev = to_pci_dev(dev); | 1192 | struct pci_dev *pci_dev = to_pci_dev(dev); |
1193 | struct pci_driver *pci_drv = to_pci_driver(drv); | 1193 | struct pci_driver *pci_drv; |
1194 | const struct pci_device_id *found_id; | 1194 | const struct pci_device_id *found_id; |
1195 | 1195 | ||
1196 | if (!pci_dev->match_driver) | ||
1197 | return 0; | ||
1198 | |||
1199 | pci_drv = to_pci_driver(drv); | ||
1196 | found_id = pci_match_device(pci_drv, pci_dev); | 1200 | found_id = pci_match_device(pci_drv, pci_dev); |
1197 | if (found_id) | 1201 | if (found_id) |
1198 | return 1; | 1202 | return 1; |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index c746b04afd6a..924e4665bd57 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -450,7 +450,7 @@ static struct pci_platform_pm_ops *pci_platform_pm; | |||
450 | int pci_set_platform_pm(struct pci_platform_pm_ops *ops) | 450 | int pci_set_platform_pm(struct pci_platform_pm_ops *ops) |
451 | { | 451 | { |
452 | if (!ops->is_manageable || !ops->set_state || !ops->choose_state | 452 | if (!ops->is_manageable || !ops->set_state || !ops->choose_state |
453 | || !ops->sleep_wake || !ops->can_wakeup) | 453 | || !ops->sleep_wake) |
454 | return -EINVAL; | 454 | return -EINVAL; |
455 | pci_platform_pm = ops; | 455 | pci_platform_pm = ops; |
456 | return 0; | 456 | return 0; |
@@ -473,11 +473,6 @@ static inline pci_power_t platform_pci_choose_state(struct pci_dev *dev) | |||
473 | pci_platform_pm->choose_state(dev) : PCI_POWER_ERROR; | 473 | pci_platform_pm->choose_state(dev) : PCI_POWER_ERROR; |
474 | } | 474 | } |
475 | 475 | ||
476 | static inline bool platform_pci_can_wakeup(struct pci_dev *dev) | ||
477 | { | ||
478 | return pci_platform_pm ? pci_platform_pm->can_wakeup(dev) : false; | ||
479 | } | ||
480 | |||
481 | static inline int platform_pci_sleep_wake(struct pci_dev *dev, bool enable) | 476 | static inline int platform_pci_sleep_wake(struct pci_dev *dev, bool enable) |
482 | { | 477 | { |
483 | return pci_platform_pm ? | 478 | return pci_platform_pm ? |
@@ -1156,8 +1151,7 @@ int pci_reenable_device(struct pci_dev *dev) | |||
1156 | return 0; | 1151 | return 0; |
1157 | } | 1152 | } |
1158 | 1153 | ||
1159 | static int __pci_enable_device_flags(struct pci_dev *dev, | 1154 | static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags) |
1160 | resource_size_t flags) | ||
1161 | { | 1155 | { |
1162 | int err; | 1156 | int err; |
1163 | int i, bars = 0; | 1157 | int i, bars = 0; |
@@ -1201,7 +1195,7 @@ static int __pci_enable_device_flags(struct pci_dev *dev, | |||
1201 | */ | 1195 | */ |
1202 | int pci_enable_device_io(struct pci_dev *dev) | 1196 | int pci_enable_device_io(struct pci_dev *dev) |
1203 | { | 1197 | { |
1204 | return __pci_enable_device_flags(dev, IORESOURCE_IO); | 1198 | return pci_enable_device_flags(dev, IORESOURCE_IO); |
1205 | } | 1199 | } |
1206 | 1200 | ||
1207 | /** | 1201 | /** |
@@ -1214,7 +1208,7 @@ int pci_enable_device_io(struct pci_dev *dev) | |||
1214 | */ | 1208 | */ |
1215 | int pci_enable_device_mem(struct pci_dev *dev) | 1209 | int pci_enable_device_mem(struct pci_dev *dev) |
1216 | { | 1210 | { |
1217 | return __pci_enable_device_flags(dev, IORESOURCE_MEM); | 1211 | return pci_enable_device_flags(dev, IORESOURCE_MEM); |
1218 | } | 1212 | } |
1219 | 1213 | ||
1220 | /** | 1214 | /** |
@@ -1230,7 +1224,7 @@ int pci_enable_device_mem(struct pci_dev *dev) | |||
1230 | */ | 1224 | */ |
1231 | int pci_enable_device(struct pci_dev *dev) | 1225 | int pci_enable_device(struct pci_dev *dev) |
1232 | { | 1226 | { |
1233 | return __pci_enable_device_flags(dev, IORESOURCE_MEM | IORESOURCE_IO); | 1227 | return pci_enable_device_flags(dev, IORESOURCE_MEM | IORESOURCE_IO); |
1234 | } | 1228 | } |
1235 | 1229 | ||
1236 | /* | 1230 | /* |
@@ -1988,25 +1982,6 @@ void pci_pm_init(struct pci_dev *dev) | |||
1988 | } | 1982 | } |
1989 | } | 1983 | } |
1990 | 1984 | ||
1991 | /** | ||
1992 | * platform_pci_wakeup_init - init platform wakeup if present | ||
1993 | * @dev: PCI device | ||
1994 | * | ||
1995 | * Some devices don't have PCI PM caps but can still generate wakeup | ||
1996 | * events through platform methods (like ACPI events). If @dev supports | ||
1997 | * platform wakeup events, set the device flag to indicate as much. This | ||
1998 | * may be redundant if the device also supports PCI PM caps, but double | ||
1999 | * initialization should be safe in that case. | ||
2000 | */ | ||
2001 | void platform_pci_wakeup_init(struct pci_dev *dev) | ||
2002 | { | ||
2003 | if (!platform_pci_can_wakeup(dev)) | ||
2004 | return; | ||
2005 | |||
2006 | device_set_wakeup_capable(&dev->dev, true); | ||
2007 | platform_pci_sleep_wake(dev, false); | ||
2008 | } | ||
2009 | |||
2010 | static void pci_add_saved_cap(struct pci_dev *pci_dev, | 1985 | static void pci_add_saved_cap(struct pci_dev *pci_dev, |
2011 | struct pci_cap_saved_state *new_cap) | 1986 | struct pci_cap_saved_state *new_cap) |
2012 | { | 1987 | { |
@@ -2070,10 +2045,13 @@ void pci_free_cap_save_buffers(struct pci_dev *dev) | |||
2070 | } | 2045 | } |
2071 | 2046 | ||
2072 | /** | 2047 | /** |
2073 | * pci_enable_ari - enable ARI forwarding if hardware support it | 2048 | * pci_configure_ari - enable or disable ARI forwarding |
2074 | * @dev: the PCI device | 2049 | * @dev: the PCI device |
2050 | * | ||
2051 | * If @dev and its upstream bridge both support ARI, enable ARI in the | ||
2052 | * bridge. Otherwise, disable ARI in the bridge. | ||
2075 | */ | 2053 | */ |
2076 | void pci_enable_ari(struct pci_dev *dev) | 2054 | void pci_configure_ari(struct pci_dev *dev) |
2077 | { | 2055 | { |
2078 | u32 cap; | 2056 | u32 cap; |
2079 | struct pci_dev *bridge; | 2057 | struct pci_dev *bridge; |
@@ -2081,9 +2059,6 @@ void pci_enable_ari(struct pci_dev *dev) | |||
2081 | if (pcie_ari_disabled || !pci_is_pcie(dev) || dev->devfn) | 2059 | if (pcie_ari_disabled || !pci_is_pcie(dev) || dev->devfn) |
2082 | return; | 2060 | return; |
2083 | 2061 | ||
2084 | if (!pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI)) | ||
2085 | return; | ||
2086 | |||
2087 | bridge = dev->bus->self; | 2062 | bridge = dev->bus->self; |
2088 | if (!bridge) | 2063 | if (!bridge) |
2089 | return; | 2064 | return; |
@@ -2092,8 +2067,15 @@ void pci_enable_ari(struct pci_dev *dev) | |||
2092 | if (!(cap & PCI_EXP_DEVCAP2_ARI)) | 2067 | if (!(cap & PCI_EXP_DEVCAP2_ARI)) |
2093 | return; | 2068 | return; |
2094 | 2069 | ||
2095 | pcie_capability_set_word(bridge, PCI_EXP_DEVCTL2, PCI_EXP_DEVCTL2_ARI); | 2070 | if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI)) { |
2096 | bridge->ari_enabled = 1; | 2071 | pcie_capability_set_word(bridge, PCI_EXP_DEVCTL2, |
2072 | PCI_EXP_DEVCTL2_ARI); | ||
2073 | bridge->ari_enabled = 1; | ||
2074 | } else { | ||
2075 | pcie_capability_clear_word(bridge, PCI_EXP_DEVCTL2, | ||
2076 | PCI_EXP_DEVCTL2_ARI); | ||
2077 | bridge->ari_enabled = 0; | ||
2078 | } | ||
2097 | } | 2079 | } |
2098 | 2080 | ||
2099 | /** | 2081 | /** |
@@ -3769,18 +3751,6 @@ resource_size_t pci_specified_resource_alignment(struct pci_dev *dev) | |||
3769 | return align; | 3751 | return align; |
3770 | } | 3752 | } |
3771 | 3753 | ||
3772 | /** | ||
3773 | * pci_is_reassigndev - check if specified PCI is target device to reassign | ||
3774 | * @dev: the PCI device to check | ||
3775 | * | ||
3776 | * RETURNS: non-zero for PCI device is a target device to reassign, | ||
3777 | * or zero is not. | ||
3778 | */ | ||
3779 | int pci_is_reassigndev(struct pci_dev *dev) | ||
3780 | { | ||
3781 | return (pci_specified_resource_alignment(dev) != 0); | ||
3782 | } | ||
3783 | |||
3784 | /* | 3754 | /* |
3785 | * This function disables memory decoding and releases memory resources | 3755 | * This function disables memory decoding and releases memory resources |
3786 | * of the device specified by kernel's boot parameter 'pci=resource_alignment='. | 3756 | * of the device specified by kernel's boot parameter 'pci=resource_alignment='. |
@@ -3795,7 +3765,9 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev) | |||
3795 | resource_size_t align, size; | 3765 | resource_size_t align, size; |
3796 | u16 command; | 3766 | u16 command; |
3797 | 3767 | ||
3798 | if (!pci_is_reassigndev(dev)) | 3768 | /* check if specified PCI is target device to reassign */ |
3769 | align = pci_specified_resource_alignment(dev); | ||
3770 | if (!align) | ||
3799 | return; | 3771 | return; |
3800 | 3772 | ||
3801 | if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL && | 3773 | if (dev->hdr_type == PCI_HEADER_TYPE_NORMAL && |
@@ -3811,7 +3783,6 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev) | |||
3811 | command &= ~PCI_COMMAND_MEMORY; | 3783 | command &= ~PCI_COMMAND_MEMORY; |
3812 | pci_write_config_word(dev, PCI_COMMAND, command); | 3784 | pci_write_config_word(dev, PCI_COMMAND, command); |
3813 | 3785 | ||
3814 | align = pci_specified_resource_alignment(dev); | ||
3815 | for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) { | 3786 | for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) { |
3816 | r = &dev->resource[i]; | 3787 | r = &dev->resource[i]; |
3817 | if (!(r->flags & IORESOURCE_MEM)) | 3788 | if (!(r->flags & IORESOURCE_MEM)) |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index e8518292826f..7346ee68f47d 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -43,9 +43,6 @@ int pci_probe_reset_function(struct pci_dev *dev); | |||
43 | * platform; to be used during system-wide transitions from a | 43 | * platform; to be used during system-wide transitions from a |
44 | * sleeping state to the working state and vice versa | 44 | * sleeping state to the working state and vice versa |
45 | * | 45 | * |
46 | * @can_wakeup: returns 'true' if given device is capable of waking up the | ||
47 | * system from a sleeping state | ||
48 | * | ||
49 | * @sleep_wake: enables/disables the system wake up capability of given device | 46 | * @sleep_wake: enables/disables the system wake up capability of given device |
50 | * | 47 | * |
51 | * @run_wake: enables/disables the platform to generate run-time wake-up events | 48 | * @run_wake: enables/disables the platform to generate run-time wake-up events |
@@ -59,7 +56,6 @@ struct pci_platform_pm_ops { | |||
59 | bool (*is_manageable)(struct pci_dev *dev); | 56 | bool (*is_manageable)(struct pci_dev *dev); |
60 | int (*set_state)(struct pci_dev *dev, pci_power_t state); | 57 | int (*set_state)(struct pci_dev *dev, pci_power_t state); |
61 | pci_power_t (*choose_state)(struct pci_dev *dev); | 58 | pci_power_t (*choose_state)(struct pci_dev *dev); |
62 | bool (*can_wakeup)(struct pci_dev *dev); | ||
63 | int (*sleep_wake)(struct pci_dev *dev, bool enable); | 59 | int (*sleep_wake)(struct pci_dev *dev, bool enable); |
64 | int (*run_wake)(struct pci_dev *dev, bool enable); | 60 | int (*run_wake)(struct pci_dev *dev, bool enable); |
65 | }; | 61 | }; |
@@ -74,7 +70,6 @@ extern void pci_wakeup_bus(struct pci_bus *bus); | |||
74 | extern void pci_config_pm_runtime_get(struct pci_dev *dev); | 70 | extern void pci_config_pm_runtime_get(struct pci_dev *dev); |
75 | extern void pci_config_pm_runtime_put(struct pci_dev *dev); | 71 | extern void pci_config_pm_runtime_put(struct pci_dev *dev); |
76 | extern void pci_pm_init(struct pci_dev *dev); | 72 | extern void pci_pm_init(struct pci_dev *dev); |
77 | extern void platform_pci_wakeup_init(struct pci_dev *dev); | ||
78 | extern void pci_allocate_cap_save_buffers(struct pci_dev *dev); | 73 | extern void pci_allocate_cap_save_buffers(struct pci_dev *dev); |
79 | void pci_free_cap_save_buffers(struct pci_dev *dev); | 74 | void pci_free_cap_save_buffers(struct pci_dev *dev); |
80 | 75 | ||
@@ -208,8 +203,8 @@ extern int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, | |||
208 | struct resource *res, unsigned int reg); | 203 | struct resource *res, unsigned int reg); |
209 | extern int pci_resource_bar(struct pci_dev *dev, int resno, | 204 | extern int pci_resource_bar(struct pci_dev *dev, int resno, |
210 | enum pci_bar_type *type); | 205 | enum pci_bar_type *type); |
211 | extern int pci_bus_add_child(struct pci_bus *bus); | 206 | extern void pci_configure_ari(struct pci_dev *dev); |
212 | extern void pci_enable_ari(struct pci_dev *dev); | 207 | |
213 | /** | 208 | /** |
214 | * pci_ari_enabled - query ARI forwarding status | 209 | * pci_ari_enabled - query ARI forwarding status |
215 | * @bus: the PCI bus | 210 | * @bus: the PCI bus |
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index b52630b8eada..e8a19772cf52 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c | |||
@@ -556,6 +556,9 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev) | |||
556 | struct pcie_link_state *link; | 556 | struct pcie_link_state *link; |
557 | int blacklist = !!pcie_aspm_sanity_check(pdev); | 557 | int blacklist = !!pcie_aspm_sanity_check(pdev); |
558 | 558 | ||
559 | if (!aspm_support_enabled) | ||
560 | return; | ||
561 | |||
559 | if (!pci_is_pcie(pdev) || pdev->link_state) | 562 | if (!pci_is_pcie(pdev) || pdev->link_state) |
560 | return; | 563 | return; |
561 | if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT && | 564 | if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT && |
@@ -634,10 +637,7 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev) | |||
634 | struct pci_dev *parent = pdev->bus->self; | 637 | struct pci_dev *parent = pdev->bus->self; |
635 | struct pcie_link_state *link, *root, *parent_link; | 638 | struct pcie_link_state *link, *root, *parent_link; |
636 | 639 | ||
637 | if (!pci_is_pcie(pdev) || !parent || !parent->link_state) | 640 | if (!parent || !parent->link_state) |
638 | return; | ||
639 | if ((pci_pcie_type(parent) != PCI_EXP_TYPE_ROOT_PORT) && | ||
640 | (pci_pcie_type(parent) != PCI_EXP_TYPE_DOWNSTREAM)) | ||
641 | return; | 641 | return; |
642 | 642 | ||
643 | down_read(&pci_bus_sem); | 643 | down_read(&pci_bus_sem); |
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index b42133afca98..31063ac30992 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c | |||
@@ -272,7 +272,7 @@ static int get_port_device_capability(struct pci_dev *dev) | |||
272 | 272 | ||
273 | /* Hot-Plug Capable */ | 273 | /* Hot-Plug Capable */ |
274 | if ((cap_mask & PCIE_PORT_SERVICE_HP) && | 274 | if ((cap_mask & PCIE_PORT_SERVICE_HP) && |
275 | dev->pcie_flags_reg & PCI_EXP_FLAGS_SLOT) { | 275 | pcie_caps_reg(dev) & PCI_EXP_FLAGS_SLOT) { |
276 | pcie_capability_read_dword(dev, PCI_EXP_SLTCAP, ®32); | 276 | pcie_capability_read_dword(dev, PCI_EXP_SLTCAP, ®32); |
277 | if (reg32 & PCI_EXP_SLTCAP_HPC) { | 277 | if (reg32 & PCI_EXP_SLTCAP_HPC) { |
278 | services |= PCIE_PORT_SERVICE_HP; | 278 | services |= PCIE_PORT_SERVICE_HP; |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 6186f03d84f3..b494066ef32f 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -623,6 +623,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, | |||
623 | { | 623 | { |
624 | struct pci_bus *child; | 624 | struct pci_bus *child; |
625 | int i; | 625 | int i; |
626 | int ret; | ||
626 | 627 | ||
627 | /* | 628 | /* |
628 | * Allocate a new bus, and inherit stuff from the parent.. | 629 | * Allocate a new bus, and inherit stuff from the parent.. |
@@ -637,8 +638,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, | |||
637 | child->bus_flags = parent->bus_flags; | 638 | child->bus_flags = parent->bus_flags; |
638 | 639 | ||
639 | /* initialize some portions of the bus device, but don't register it | 640 | /* initialize some portions of the bus device, but don't register it |
640 | * now as the parent is not properly set up yet. This device will get | 641 | * now as the parent is not properly set up yet. |
641 | * registered later in pci_bus_add_devices() | ||
642 | */ | 642 | */ |
643 | child->dev.class = &pcibus_class; | 643 | child->dev.class = &pcibus_class; |
644 | dev_set_name(&child->dev, "%04x:%02x", pci_domain_nr(child), busnr); | 644 | dev_set_name(&child->dev, "%04x:%02x", pci_domain_nr(child), busnr); |
@@ -651,11 +651,14 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, | |||
651 | child->primary = parent->busn_res.start; | 651 | child->primary = parent->busn_res.start; |
652 | child->busn_res.end = 0xff; | 652 | child->busn_res.end = 0xff; |
653 | 653 | ||
654 | if (!bridge) | 654 | if (!bridge) { |
655 | return child; | 655 | child->dev.parent = parent->bridge; |
656 | goto add_dev; | ||
657 | } | ||
656 | 658 | ||
657 | child->self = bridge; | 659 | child->self = bridge; |
658 | child->bridge = get_device(&bridge->dev); | 660 | child->bridge = get_device(&bridge->dev); |
661 | child->dev.parent = child->bridge; | ||
659 | pci_set_bus_of_node(child); | 662 | pci_set_bus_of_node(child); |
660 | pci_set_bus_speed(child); | 663 | pci_set_bus_speed(child); |
661 | 664 | ||
@@ -666,6 +669,13 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, | |||
666 | } | 669 | } |
667 | bridge->subordinate = child; | 670 | bridge->subordinate = child; |
668 | 671 | ||
672 | add_dev: | ||
673 | ret = device_register(&child->dev); | ||
674 | WARN_ON(ret < 0); | ||
675 | |||
676 | /* Create legacy_io and legacy_mem files for this bus */ | ||
677 | pci_create_legacy_files(child); | ||
678 | |||
669 | return child; | 679 | return child; |
670 | } | 680 | } |
671 | 681 | ||
@@ -1280,13 +1290,12 @@ static void pci_init_capabilities(struct pci_dev *dev) | |||
1280 | 1290 | ||
1281 | /* Power Management */ | 1291 | /* Power Management */ |
1282 | pci_pm_init(dev); | 1292 | pci_pm_init(dev); |
1283 | platform_pci_wakeup_init(dev); | ||
1284 | 1293 | ||
1285 | /* Vital Product Data */ | 1294 | /* Vital Product Data */ |
1286 | pci_vpd_pci22_init(dev); | 1295 | pci_vpd_pci22_init(dev); |
1287 | 1296 | ||
1288 | /* Alternative Routing-ID Forwarding */ | 1297 | /* Alternative Routing-ID Forwarding */ |
1289 | pci_enable_ari(dev); | 1298 | pci_configure_ari(dev); |
1290 | 1299 | ||
1291 | /* Single Root I/O Virtualization */ | 1300 | /* Single Root I/O Virtualization */ |
1292 | pci_iov_init(dev); | 1301 | pci_iov_init(dev); |
@@ -1297,10 +1306,12 @@ static void pci_init_capabilities(struct pci_dev *dev) | |||
1297 | 1306 | ||
1298 | void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) | 1307 | void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) |
1299 | { | 1308 | { |
1309 | int ret; | ||
1310 | |||
1300 | device_initialize(&dev->dev); | 1311 | device_initialize(&dev->dev); |
1301 | dev->dev.release = pci_release_dev; | 1312 | dev->dev.release = pci_release_dev; |
1302 | pci_dev_get(dev); | ||
1303 | 1313 | ||
1314 | set_dev_node(&dev->dev, pcibus_to_node(bus)); | ||
1304 | dev->dev.dma_mask = &dev->dma_mask; | 1315 | dev->dev.dma_mask = &dev->dma_mask; |
1305 | dev->dev.dma_parms = &dev->dma_parms; | 1316 | dev->dev.dma_parms = &dev->dma_parms; |
1306 | dev->dev.coherent_dma_mask = 0xffffffffull; | 1317 | dev->dev.coherent_dma_mask = 0xffffffffull; |
@@ -1327,6 +1338,17 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) | |||
1327 | down_write(&pci_bus_sem); | 1338 | down_write(&pci_bus_sem); |
1328 | list_add_tail(&dev->bus_list, &bus->devices); | 1339 | list_add_tail(&dev->bus_list, &bus->devices); |
1329 | up_write(&pci_bus_sem); | 1340 | up_write(&pci_bus_sem); |
1341 | |||
1342 | pci_fixup_device(pci_fixup_final, dev); | ||
1343 | ret = pcibios_add_device(dev); | ||
1344 | WARN_ON(ret < 0); | ||
1345 | |||
1346 | /* Notifier could use PCI capabilities */ | ||
1347 | dev->match_driver = false; | ||
1348 | ret = device_add(&dev->dev); | ||
1349 | WARN_ON(ret < 0); | ||
1350 | |||
1351 | pci_proc_attach_device(dev); | ||
1330 | } | 1352 | } |
1331 | 1353 | ||
1332 | struct pci_dev *__ref pci_scan_single_device(struct pci_bus *bus, int devfn) | 1354 | struct pci_dev *__ref pci_scan_single_device(struct pci_bus *bus, int devfn) |
@@ -1349,31 +1371,31 @@ struct pci_dev *__ref pci_scan_single_device(struct pci_bus *bus, int devfn) | |||
1349 | } | 1371 | } |
1350 | EXPORT_SYMBOL(pci_scan_single_device); | 1372 | EXPORT_SYMBOL(pci_scan_single_device); |
1351 | 1373 | ||
1352 | static unsigned next_ari_fn(struct pci_dev *dev, unsigned fn) | 1374 | static unsigned next_fn(struct pci_bus *bus, struct pci_dev *dev, unsigned fn) |
1353 | { | 1375 | { |
1354 | u16 cap; | 1376 | int pos; |
1355 | unsigned pos, next_fn; | 1377 | u16 cap = 0; |
1378 | unsigned next_fn; | ||
1356 | 1379 | ||
1357 | if (!dev) | 1380 | if (pci_ari_enabled(bus)) { |
1358 | return 0; | 1381 | if (!dev) |
1382 | return 0; | ||
1383 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI); | ||
1384 | if (!pos) | ||
1385 | return 0; | ||
1359 | 1386 | ||
1360 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI); | 1387 | pci_read_config_word(dev, pos + PCI_ARI_CAP, &cap); |
1361 | if (!pos) | 1388 | next_fn = PCI_ARI_CAP_NFN(cap); |
1362 | return 0; | 1389 | if (next_fn <= fn) |
1363 | pci_read_config_word(dev, pos + 4, &cap); | 1390 | return 0; /* protect against malformed list */ |
1364 | next_fn = cap >> 8; | ||
1365 | if (next_fn <= fn) | ||
1366 | return 0; | ||
1367 | return next_fn; | ||
1368 | } | ||
1369 | 1391 | ||
1370 | static unsigned next_trad_fn(struct pci_dev *dev, unsigned fn) | 1392 | return next_fn; |
1371 | { | 1393 | } |
1372 | return (fn + 1) % 8; | 1394 | |
1373 | } | 1395 | /* dev may be NULL for non-contiguous multifunction devices */ |
1396 | if (!dev || dev->multifunction) | ||
1397 | return (fn + 1) % 8; | ||
1374 | 1398 | ||
1375 | static unsigned no_next_fn(struct pci_dev *dev, unsigned fn) | ||
1376 | { | ||
1377 | return 0; | 1399 | return 0; |
1378 | } | 1400 | } |
1379 | 1401 | ||
@@ -1406,7 +1428,6 @@ int pci_scan_slot(struct pci_bus *bus, int devfn) | |||
1406 | { | 1428 | { |
1407 | unsigned fn, nr = 0; | 1429 | unsigned fn, nr = 0; |
1408 | struct pci_dev *dev; | 1430 | struct pci_dev *dev; |
1409 | unsigned (*next_fn)(struct pci_dev *, unsigned) = no_next_fn; | ||
1410 | 1431 | ||
1411 | if (only_one_child(bus) && (devfn > 0)) | 1432 | if (only_one_child(bus) && (devfn > 0)) |
1412 | return 0; /* Already scanned the entire slot */ | 1433 | return 0; /* Already scanned the entire slot */ |
@@ -1417,12 +1438,7 @@ int pci_scan_slot(struct pci_bus *bus, int devfn) | |||
1417 | if (!dev->is_added) | 1438 | if (!dev->is_added) |
1418 | nr++; | 1439 | nr++; |
1419 | 1440 | ||
1420 | if (pci_ari_enabled(bus)) | 1441 | for (fn = next_fn(bus, dev, 0); fn > 0; fn = next_fn(bus, dev, fn)) { |
1421 | next_fn = next_ari_fn; | ||
1422 | else if (dev->multifunction) | ||
1423 | next_fn = next_trad_fn; | ||
1424 | |||
1425 | for (fn = next_fn(dev, 0); fn > 0; fn = next_fn(dev, fn)) { | ||
1426 | dev = pci_scan_single_device(bus, devfn + fn); | 1442 | dev = pci_scan_single_device(bus, devfn + fn); |
1427 | if (dev) { | 1443 | if (dev) { |
1428 | if (!dev->is_added) | 1444 | if (!dev->is_added) |
@@ -1633,6 +1649,18 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus) | |||
1633 | return max; | 1649 | return max; |
1634 | } | 1650 | } |
1635 | 1651 | ||
1652 | /** | ||
1653 | * pcibios_root_bridge_prepare - Platform-specific host bridge setup. | ||
1654 | * @bridge: Host bridge to set up. | ||
1655 | * | ||
1656 | * Default empty implementation. Replace with an architecture-specific setup | ||
1657 | * routine, if necessary. | ||
1658 | */ | ||
1659 | int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) | ||
1660 | { | ||
1661 | return 0; | ||
1662 | } | ||
1663 | |||
1636 | struct pci_bus *pci_create_root_bus(struct device *parent, int bus, | 1664 | struct pci_bus *pci_create_root_bus(struct device *parent, int bus, |
1637 | struct pci_ops *ops, void *sysdata, struct list_head *resources) | 1665 | struct pci_ops *ops, void *sysdata, struct list_head *resources) |
1638 | { | 1666 | { |
@@ -1645,13 +1673,13 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, | |||
1645 | char bus_addr[64]; | 1673 | char bus_addr[64]; |
1646 | char *fmt; | 1674 | char *fmt; |
1647 | 1675 | ||
1648 | |||
1649 | b = pci_alloc_bus(); | 1676 | b = pci_alloc_bus(); |
1650 | if (!b) | 1677 | if (!b) |
1651 | return NULL; | 1678 | return NULL; |
1652 | 1679 | ||
1653 | b->sysdata = sysdata; | 1680 | b->sysdata = sysdata; |
1654 | b->ops = ops; | 1681 | b->ops = ops; |
1682 | b->number = b->busn_res.start = bus; | ||
1655 | b2 = pci_find_bus(pci_domain_nr(b), bus); | 1683 | b2 = pci_find_bus(pci_domain_nr(b), bus); |
1656 | if (b2) { | 1684 | if (b2) { |
1657 | /* If we already got to this bus through a different bridge, ignore it */ | 1685 | /* If we already got to this bus through a different bridge, ignore it */ |
@@ -1666,6 +1694,10 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, | |||
1666 | bridge->dev.parent = parent; | 1694 | bridge->dev.parent = parent; |
1667 | bridge->dev.release = pci_release_bus_bridge_dev; | 1695 | bridge->dev.release = pci_release_bus_bridge_dev; |
1668 | dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus); | 1696 | dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus); |
1697 | error = pcibios_root_bridge_prepare(bridge); | ||
1698 | if (error) | ||
1699 | goto bridge_dev_reg_err; | ||
1700 | |||
1669 | error = device_register(&bridge->dev); | 1701 | error = device_register(&bridge->dev); |
1670 | if (error) | 1702 | if (error) |
1671 | goto bridge_dev_reg_err; | 1703 | goto bridge_dev_reg_err; |
@@ -1686,8 +1718,6 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, | |||
1686 | /* Create legacy_io and legacy_mem files for this bus */ | 1718 | /* Create legacy_io and legacy_mem files for this bus */ |
1687 | pci_create_legacy_files(b); | 1719 | pci_create_legacy_files(b); |
1688 | 1720 | ||
1689 | b->number = b->busn_res.start = bus; | ||
1690 | |||
1691 | if (parent) | 1721 | if (parent) |
1692 | dev_info(parent, "PCI host bridge to bus %s\n", dev_name(&b->dev)); | 1722 | dev_info(parent, "PCI host bridge to bus %s\n", dev_name(&b->dev)); |
1693 | else | 1723 | else |
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 7c0fd9252e6f..fc38c4883e1d 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c | |||
@@ -22,7 +22,7 @@ static void pci_stop_dev(struct pci_dev *dev) | |||
22 | if (dev->is_added) { | 22 | if (dev->is_added) { |
23 | pci_proc_detach_device(dev); | 23 | pci_proc_detach_device(dev); |
24 | pci_remove_sysfs_dev_files(dev); | 24 | pci_remove_sysfs_dev_files(dev); |
25 | device_unregister(&dev->dev); | 25 | device_del(&dev->dev); |
26 | dev->is_added = 0; | 26 | dev->is_added = 0; |
27 | } | 27 | } |
28 | 28 | ||
@@ -37,7 +37,7 @@ static void pci_destroy_dev(struct pci_dev *dev) | |||
37 | up_write(&pci_bus_sem); | 37 | up_write(&pci_bus_sem); |
38 | 38 | ||
39 | pci_free_resources(dev); | 39 | pci_free_resources(dev); |
40 | pci_dev_put(dev); | 40 | put_device(&dev->dev); |
41 | } | 41 | } |
42 | 42 | ||
43 | void pci_remove_bus(struct pci_bus *bus) | 43 | void pci_remove_bus(struct pci_bus *bus) |
diff --git a/drivers/pci/search.c b/drivers/pci/search.c index bf969ba58e59..d0627fa9f368 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c | |||
@@ -319,13 +319,13 @@ int pci_dev_present(const struct pci_device_id *ids) | |||
319 | WARN_ON(in_interrupt()); | 319 | WARN_ON(in_interrupt()); |
320 | while (ids->vendor || ids->subvendor || ids->class_mask) { | 320 | while (ids->vendor || ids->subvendor || ids->class_mask) { |
321 | found = pci_get_dev_by_id(ids, NULL); | 321 | found = pci_get_dev_by_id(ids, NULL); |
322 | if (found) | 322 | if (found) { |
323 | goto exit; | 323 | pci_dev_put(found); |
324 | return 1; | ||
325 | } | ||
324 | ids++; | 326 | ids++; |
325 | } | 327 | } |
326 | exit: | 328 | |
327 | if (found) | ||
328 | return 1; | ||
329 | return 0; | 329 | return 0; |
330 | } | 330 | } |
331 | EXPORT_SYMBOL(pci_dev_present); | 331 | EXPORT_SYMBOL(pci_dev_present); |
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 6d3591d57ea0..7e8739e25b9e 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -283,7 +283,7 @@ static void assign_requested_resources_sorted(struct list_head *head, | |||
283 | idx = res - &dev_res->dev->resource[0]; | 283 | idx = res - &dev_res->dev->resource[0]; |
284 | if (resource_size(res) && | 284 | if (resource_size(res) && |
285 | pci_assign_resource(dev_res->dev, idx)) { | 285 | pci_assign_resource(dev_res->dev, idx)) { |
286 | if (fail_head && !pci_is_root_bus(dev_res->dev->bus)) { | 286 | if (fail_head) { |
287 | /* | 287 | /* |
288 | * if the failed res is for ROM BAR, and it will | 288 | * if the failed res is for ROM BAR, and it will |
289 | * be enabled later, don't add it to the list | 289 | * be enabled later, don't add it to the list |
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 7ced5dc20dd3..5ce8d5e86734 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
@@ -91,21 +91,12 @@ struct acpi_device; | |||
91 | typedef int (*acpi_op_add) (struct acpi_device * device); | 91 | typedef int (*acpi_op_add) (struct acpi_device * device); |
92 | typedef int (*acpi_op_remove) (struct acpi_device * device, int type); | 92 | typedef int (*acpi_op_remove) (struct acpi_device * device, int type); |
93 | typedef int (*acpi_op_start) (struct acpi_device * device); | 93 | typedef int (*acpi_op_start) (struct acpi_device * device); |
94 | typedef int (*acpi_op_bind) (struct acpi_device * device); | ||
95 | typedef int (*acpi_op_unbind) (struct acpi_device * device); | ||
96 | typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event); | 94 | typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event); |
97 | 95 | ||
98 | struct acpi_bus_ops { | ||
99 | u32 acpi_op_add:1; | ||
100 | u32 acpi_op_start:1; | ||
101 | }; | ||
102 | |||
103 | struct acpi_device_ops { | 96 | struct acpi_device_ops { |
104 | acpi_op_add add; | 97 | acpi_op_add add; |
105 | acpi_op_remove remove; | 98 | acpi_op_remove remove; |
106 | acpi_op_start start; | 99 | acpi_op_start start; |
107 | acpi_op_bind bind; | ||
108 | acpi_op_unbind unbind; | ||
109 | acpi_op_notify notify; | 100 | acpi_op_notify notify; |
110 | }; | 101 | }; |
111 | 102 | ||
@@ -148,7 +139,8 @@ struct acpi_device_flags { | |||
148 | u32 power_manageable:1; | 139 | u32 power_manageable:1; |
149 | u32 performance_manageable:1; | 140 | u32 performance_manageable:1; |
150 | u32 eject_pending:1; | 141 | u32 eject_pending:1; |
151 | u32 reserved:24; | 142 | u32 match_driver:1; |
143 | u32 reserved:23; | ||
152 | }; | 144 | }; |
153 | 145 | ||
154 | /* File System */ | 146 | /* File System */ |
@@ -279,11 +271,9 @@ struct acpi_device { | |||
279 | struct acpi_device_wakeup wakeup; | 271 | struct acpi_device_wakeup wakeup; |
280 | struct acpi_device_perf performance; | 272 | struct acpi_device_perf performance; |
281 | struct acpi_device_dir dir; | 273 | struct acpi_device_dir dir; |
282 | struct acpi_device_ops ops; | ||
283 | struct acpi_driver *driver; | 274 | struct acpi_driver *driver; |
284 | void *driver_data; | 275 | void *driver_data; |
285 | struct device dev; | 276 | struct device dev; |
286 | struct acpi_bus_ops bus_ops; /* workaround for different code path for hotplug */ | ||
287 | enum acpi_bus_removal_type removal_type; /* indicate for different removal type */ | 277 | enum acpi_bus_removal_type removal_type; /* indicate for different removal type */ |
288 | u8 physical_node_count; | 278 | u8 physical_node_count; |
289 | struct list_head physical_node_list; | 279 | struct list_head physical_node_list; |
@@ -316,10 +306,19 @@ struct acpi_bus_event { | |||
316 | }; | 306 | }; |
317 | 307 | ||
318 | struct acpi_eject_event { | 308 | struct acpi_eject_event { |
319 | acpi_handle handle; | 309 | struct acpi_device *device; |
320 | u32 event; | 310 | u32 event; |
321 | }; | 311 | }; |
322 | 312 | ||
313 | struct acpi_hp_work { | ||
314 | struct work_struct work; | ||
315 | acpi_handle handle; | ||
316 | u32 type; | ||
317 | void *context; | ||
318 | }; | ||
319 | void alloc_acpi_hp_work(acpi_handle handle, u32 type, void *context, | ||
320 | void (*func)(struct work_struct *work)); | ||
321 | |||
323 | extern struct kobject *acpi_kobj; | 322 | extern struct kobject *acpi_kobj; |
324 | extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int); | 323 | extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int); |
325 | void acpi_bus_private_data_handler(acpi_handle, void *); | 324 | void acpi_bus_private_data_handler(acpi_handle, void *); |
@@ -356,11 +355,9 @@ static inline int acpi_bus_generate_proc_event(struct acpi_device *device, u8 ty | |||
356 | #endif | 355 | #endif |
357 | int acpi_bus_register_driver(struct acpi_driver *driver); | 356 | int acpi_bus_register_driver(struct acpi_driver *driver); |
358 | void acpi_bus_unregister_driver(struct acpi_driver *driver); | 357 | void acpi_bus_unregister_driver(struct acpi_driver *driver); |
359 | int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent, | 358 | int acpi_bus_scan(acpi_handle handle); |
360 | acpi_handle handle, int type); | ||
361 | void acpi_bus_hot_remove_device(void *context); | 359 | void acpi_bus_hot_remove_device(void *context); |
362 | int acpi_bus_trim(struct acpi_device *start, int rmdevice); | 360 | int acpi_bus_trim(struct acpi_device *start); |
363 | int acpi_bus_start(struct acpi_device *device); | ||
364 | acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd); | 361 | acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd); |
365 | int acpi_match_device_ids(struct acpi_device *device, | 362 | int acpi_match_device_ids(struct acpi_device *device, |
366 | const struct acpi_device_id *ids); | 363 | const struct acpi_device_id *ids); |
@@ -390,6 +387,8 @@ struct acpi_bus_type { | |||
390 | int (*find_device) (struct device *, acpi_handle *); | 387 | int (*find_device) (struct device *, acpi_handle *); |
391 | /* For bridges, such as PCI root bridge, IDE controller */ | 388 | /* For bridges, such as PCI root bridge, IDE controller */ |
392 | int (*find_bridge) (struct device *, acpi_handle *); | 389 | int (*find_bridge) (struct device *, acpi_handle *); |
390 | void (*setup)(struct device *); | ||
391 | void (*cleanup)(struct device *); | ||
393 | }; | 392 | }; |
394 | int register_acpi_bus_type(struct acpi_bus_type *); | 393 | int register_acpi_bus_type(struct acpi_bus_type *); |
395 | int unregister_acpi_bus_type(struct acpi_bus_type *); | 394 | int unregister_acpi_bus_type(struct acpi_bus_type *); |
@@ -397,7 +396,6 @@ int unregister_acpi_bus_type(struct acpi_bus_type *); | |||
397 | struct acpi_pci_root { | 396 | struct acpi_pci_root { |
398 | struct list_head node; | 397 | struct list_head node; |
399 | struct acpi_device * device; | 398 | struct acpi_device * device; |
400 | struct acpi_pci_id id; | ||
401 | struct pci_bus *bus; | 399 | struct pci_bus *bus; |
402 | u16 segment; | 400 | u16 segment; |
403 | struct resource secondary; /* downstream bus range */ | 401 | struct resource secondary; /* downstream bus range */ |
@@ -410,7 +408,6 @@ struct acpi_pci_root { | |||
410 | /* helper */ | 408 | /* helper */ |
411 | acpi_handle acpi_get_child(acpi_handle, u64); | 409 | acpi_handle acpi_get_child(acpi_handle, u64); |
412 | int acpi_is_root_bridge(acpi_handle); | 410 | int acpi_is_root_bridge(acpi_handle); |
413 | acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int); | ||
414 | struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle); | 411 | struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle); |
415 | #define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)ACPI_HANDLE(dev)) | 412 | #define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)ACPI_HANDLE(dev)) |
416 | 413 | ||
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h index 43152742b46f..66f1fd70e8c2 100644 --- a/include/acpi/acpiosxf.h +++ b/include/acpi/acpiosxf.h | |||
@@ -193,8 +193,6 @@ void acpi_os_fixed_event_count(u32 fixed_event_number); | |||
193 | /* | 193 | /* |
194 | * Threads and Scheduling | 194 | * Threads and Scheduling |
195 | */ | 195 | */ |
196 | extern struct workqueue_struct *kacpi_hotplug_wq; | ||
197 | |||
198 | acpi_thread_id acpi_os_get_thread_id(void); | 196 | acpi_thread_id acpi_os_get_thread_id(void); |
199 | 197 | ||
200 | acpi_status | 198 | acpi_status |
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 3994d7790b23..8c1d6f2a2193 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
@@ -526,9 +526,14 @@ static inline int acpi_subsys_resume_early(struct device *dev) { return 0; } | |||
526 | #endif | 526 | #endif |
527 | 527 | ||
528 | #if defined(CONFIG_ACPI) && defined(CONFIG_PM) | 528 | #if defined(CONFIG_ACPI) && defined(CONFIG_PM) |
529 | struct acpi_device *acpi_dev_pm_get_node(struct device *dev); | ||
529 | int acpi_dev_pm_attach(struct device *dev, bool power_on); | 530 | int acpi_dev_pm_attach(struct device *dev, bool power_on); |
530 | void acpi_dev_pm_detach(struct device *dev, bool power_off); | 531 | void acpi_dev_pm_detach(struct device *dev, bool power_off); |
531 | #else | 532 | #else |
533 | static inline struct acpi_device *acpi_dev_pm_get_node(struct device *dev) | ||
534 | { | ||
535 | return NULL; | ||
536 | } | ||
532 | static inline int acpi_dev_pm_attach(struct device *dev, bool power_on) | 537 | static inline int acpi_dev_pm_attach(struct device *dev, bool power_on) |
533 | { | 538 | { |
534 | return -ENODEV; | 539 | return -ENODEV; |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 15472d691ee6..7e87b1ed2175 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -286,6 +286,7 @@ struct pci_dev { | |||
286 | unsigned int irq; | 286 | unsigned int irq; |
287 | struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ | 287 | struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ |
288 | 288 | ||
289 | bool match_driver; /* Skip attaching driver */ | ||
289 | /* These fields are used by common fixups */ | 290 | /* These fields are used by common fixups */ |
290 | unsigned int transparent:1; /* Transparent PCI bridge */ | 291 | unsigned int transparent:1; /* Transparent PCI bridge */ |
291 | unsigned int multifunction:1;/* Part of multi-function device */ | 292 | unsigned int multifunction:1;/* Part of multi-function device */ |
@@ -378,6 +379,8 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge, | |||
378 | void (*release_fn)(struct pci_host_bridge *), | 379 | void (*release_fn)(struct pci_host_bridge *), |
379 | void *release_data); | 380 | void *release_data); |
380 | 381 | ||
382 | int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge); | ||
383 | |||
381 | /* | 384 | /* |
382 | * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond | 385 | * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond |
383 | * to P2P or CardBus bridge windows) go in a table. Additional ones (for | 386 | * to P2P or CardBus bridge windows) go in a table. Additional ones (for |
@@ -674,6 +677,7 @@ extern struct list_head pci_root_buses; /* list of all known PCI buses */ | |||
674 | /* Some device drivers need know if pci is initiated */ | 677 | /* Some device drivers need know if pci is initiated */ |
675 | extern int no_pci_devices(void); | 678 | extern int no_pci_devices(void); |
676 | 679 | ||
680 | void pcibios_resource_survey_bus(struct pci_bus *bus); | ||
677 | void pcibios_fixup_bus(struct pci_bus *); | 681 | void pcibios_fixup_bus(struct pci_bus *); |
678 | int __must_check pcibios_enable_device(struct pci_dev *, int mask); | 682 | int __must_check pcibios_enable_device(struct pci_dev *, int mask); |
679 | /* Architecture specific versions may override this (weak) */ | 683 | /* Architecture specific versions may override this (weak) */ |
@@ -1693,12 +1697,21 @@ static inline bool pci_is_pcie(struct pci_dev *dev) | |||
1693 | } | 1697 | } |
1694 | 1698 | ||
1695 | /** | 1699 | /** |
1700 | * pcie_caps_reg - get the PCIe Capabilities Register | ||
1701 | * @dev: PCI device | ||
1702 | */ | ||
1703 | static inline u16 pcie_caps_reg(const struct pci_dev *dev) | ||
1704 | { | ||
1705 | return dev->pcie_flags_reg; | ||
1706 | } | ||
1707 | |||
1708 | /** | ||
1696 | * pci_pcie_type - get the PCIe device/port type | 1709 | * pci_pcie_type - get the PCIe device/port type |
1697 | * @dev: PCI device | 1710 | * @dev: PCI device |
1698 | */ | 1711 | */ |
1699 | static inline int pci_pcie_type(const struct pci_dev *dev) | 1712 | static inline int pci_pcie_type(const struct pci_dev *dev) |
1700 | { | 1713 | { |
1701 | return (dev->pcie_flags_reg & PCI_EXP_FLAGS_TYPE) >> 4; | 1714 | return (pcie_caps_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4; |
1702 | } | 1715 | } |
1703 | 1716 | ||
1704 | void pci_request_acs(void); | 1717 | void pci_request_acs(void); |