diff options
55 files changed, 912 insertions, 721 deletions
diff --git a/Documentation/PCI/MSI-HOWTO.txt b/Documentation/PCI/MSI-HOWTO.txt index a8d01005f480..10a93696e55a 100644 --- a/Documentation/PCI/MSI-HOWTO.txt +++ b/Documentation/PCI/MSI-HOWTO.txt | |||
@@ -82,7 +82,19 @@ Most of the hard work is done for the driver in the PCI layer. It simply | |||
82 | has to request that the PCI layer set up the MSI capability for this | 82 | has to request that the PCI layer set up the MSI capability for this |
83 | device. | 83 | device. |
84 | 84 | ||
85 | 4.2.1 pci_enable_msi_range | 85 | 4.2.1 pci_enable_msi |
86 | |||
87 | int pci_enable_msi(struct pci_dev *dev) | ||
88 | |||
89 | A successful call allocates ONE interrupt to the device, regardless | ||
90 | of how many MSIs the device supports. The device is switched from | ||
91 | pin-based interrupt mode to MSI mode. The dev->irq number is changed | ||
92 | to a new number which represents the message signaled interrupt; | ||
93 | consequently, this function should be called before the driver calls | ||
94 | request_irq(), because an MSI is delivered via a vector that is | ||
95 | different from the vector of a pin-based interrupt. | ||
96 | |||
97 | 4.2.2 pci_enable_msi_range | ||
86 | 98 | ||
87 | int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec) | 99 | int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec) |
88 | 100 | ||
@@ -147,6 +159,11 @@ static int foo_driver_enable_msi(struct pci_dev *pdev, int nvec) | |||
147 | return pci_enable_msi_range(pdev, nvec, nvec); | 159 | return pci_enable_msi_range(pdev, nvec, nvec); |
148 | } | 160 | } |
149 | 161 | ||
162 | Note, unlike pci_enable_msi_exact() function, which could be also used to | ||
163 | enable a particular number of MSI-X interrupts, pci_enable_msi_range() | ||
164 | returns either a negative errno or 'nvec' (not negative errno or 0 - as | ||
165 | pci_enable_msi_exact() does). | ||
166 | |||
150 | 4.2.1.3 Single MSI mode | 167 | 4.2.1.3 Single MSI mode |
151 | 168 | ||
152 | The most notorious example of the request type described above is | 169 | The most notorious example of the request type described above is |
@@ -158,7 +175,27 @@ static int foo_driver_enable_single_msi(struct pci_dev *pdev) | |||
158 | return pci_enable_msi_range(pdev, 1, 1); | 175 | return pci_enable_msi_range(pdev, 1, 1); |
159 | } | 176 | } |
160 | 177 | ||
161 | 4.2.2 pci_disable_msi | 178 | Note, unlike pci_enable_msi() function, which could be also used to |
179 | enable the single MSI mode, pci_enable_msi_range() returns either a | ||
180 | negative errno or 1 (not negative errno or 0 - as pci_enable_msi() | ||
181 | does). | ||
182 | |||
183 | 4.2.3 pci_enable_msi_exact | ||
184 | |||
185 | int pci_enable_msi_exact(struct pci_dev *dev, int nvec) | ||
186 | |||
187 | This variation on pci_enable_msi_range() call allows a device driver to | ||
188 | request exactly 'nvec' MSIs. | ||
189 | |||
190 | If this function returns a negative number, it indicates an error and | ||
191 | the driver should not attempt to request any more MSI interrupts for | ||
192 | this device. | ||
193 | |||
194 | By contrast with pci_enable_msi_range() function, pci_enable_msi_exact() | ||
195 | returns zero in case of success, which indicates MSI interrupts have been | ||
196 | successfully allocated. | ||
197 | |||
198 | 4.2.4 pci_disable_msi | ||
162 | 199 | ||
163 | void pci_disable_msi(struct pci_dev *dev) | 200 | void pci_disable_msi(struct pci_dev *dev) |
164 | 201 | ||
@@ -172,7 +209,7 @@ on any interrupt for which it previously called request_irq(). | |||
172 | Failure to do so results in a BUG_ON(), leaving the device with | 209 | Failure to do so results in a BUG_ON(), leaving the device with |
173 | MSI enabled and thus leaking its vector. | 210 | MSI enabled and thus leaking its vector. |
174 | 211 | ||
175 | 4.2.3 pci_msi_vec_count | 212 | 4.2.4 pci_msi_vec_count |
176 | 213 | ||
177 | int pci_msi_vec_count(struct pci_dev *dev) | 214 | int pci_msi_vec_count(struct pci_dev *dev) |
178 | 215 | ||
@@ -257,8 +294,8 @@ possible, likely up to the limit returned by pci_msix_vec_count() function: | |||
257 | 294 | ||
258 | static int foo_driver_enable_msix(struct foo_adapter *adapter, int nvec) | 295 | static int foo_driver_enable_msix(struct foo_adapter *adapter, int nvec) |
259 | { | 296 | { |
260 | return pci_enable_msi_range(adapter->pdev, adapter->msix_entries, | 297 | return pci_enable_msix_range(adapter->pdev, adapter->msix_entries, |
261 | 1, nvec); | 298 | 1, nvec); |
262 | } | 299 | } |
263 | 300 | ||
264 | Note the value of 'minvec' parameter is 1. As 'minvec' is inclusive, | 301 | Note the value of 'minvec' parameter is 1. As 'minvec' is inclusive, |
@@ -269,8 +306,8 @@ In this case the function could look like this: | |||
269 | 306 | ||
270 | static int foo_driver_enable_msix(struct foo_adapter *adapter, int nvec) | 307 | static int foo_driver_enable_msix(struct foo_adapter *adapter, int nvec) |
271 | { | 308 | { |
272 | return pci_enable_msi_range(adapter->pdev, adapter->msix_entries, | 309 | return pci_enable_msix_range(adapter->pdev, adapter->msix_entries, |
273 | FOO_DRIVER_MINIMUM_NVEC, nvec); | 310 | FOO_DRIVER_MINIMUM_NVEC, nvec); |
274 | } | 311 | } |
275 | 312 | ||
276 | 4.3.1.2 Exact number of MSI-X interrupts | 313 | 4.3.1.2 Exact number of MSI-X interrupts |
@@ -282,10 +319,15 @@ parameters: | |||
282 | 319 | ||
283 | static int foo_driver_enable_msix(struct foo_adapter *adapter, int nvec) | 320 | static int foo_driver_enable_msix(struct foo_adapter *adapter, int nvec) |
284 | { | 321 | { |
285 | return pci_enable_msi_range(adapter->pdev, adapter->msix_entries, | 322 | return pci_enable_msix_range(adapter->pdev, adapter->msix_entries, |
286 | nvec, nvec); | 323 | nvec, nvec); |
287 | } | 324 | } |
288 | 325 | ||
326 | Note, unlike pci_enable_msix_exact() function, which could be also used to | ||
327 | enable a particular number of MSI-X interrupts, pci_enable_msix_range() | ||
328 | returns either a negative errno or 'nvec' (not negative errno or 0 - as | ||
329 | pci_enable_msix_exact() does). | ||
330 | |||
289 | 4.3.1.3 Specific requirements to the number of MSI-X interrupts | 331 | 4.3.1.3 Specific requirements to the number of MSI-X interrupts |
290 | 332 | ||
291 | As noted above, there could be devices that can not operate with just any | 333 | As noted above, there could be devices that can not operate with just any |
@@ -332,7 +374,64 @@ Note how pci_enable_msix_range() return value is analized for a fallback - | |||
332 | any error code other than -ENOSPC indicates a fatal error and should not | 374 | any error code other than -ENOSPC indicates a fatal error and should not |
333 | be retried. | 375 | be retried. |
334 | 376 | ||
335 | 4.3.2 pci_disable_msix | 377 | 4.3.2 pci_enable_msix_exact |
378 | |||
379 | int pci_enable_msix_exact(struct pci_dev *dev, | ||
380 | struct msix_entry *entries, int nvec) | ||
381 | |||
382 | This variation on pci_enable_msix_range() call allows a device driver to | ||
383 | request exactly 'nvec' MSI-Xs. | ||
384 | |||
385 | If this function returns a negative number, it indicates an error and | ||
386 | the driver should not attempt to allocate any more MSI-X interrupts for | ||
387 | this device. | ||
388 | |||
389 | By contrast with pci_enable_msix_range() function, pci_enable_msix_exact() | ||
390 | returns zero in case of success, which indicates MSI-X interrupts have been | ||
391 | successfully allocated. | ||
392 | |||
393 | Another version of a routine that enables MSI-X mode for a device with | ||
394 | specific requirements described in chapter 4.3.1.3 might look like this: | ||
395 | |||
396 | /* | ||
397 | * Assume 'minvec' and 'maxvec' are non-zero | ||
398 | */ | ||
399 | static int foo_driver_enable_msix(struct foo_adapter *adapter, | ||
400 | int minvec, int maxvec) | ||
401 | { | ||
402 | int rc; | ||
403 | |||
404 | minvec = roundup_pow_of_two(minvec); | ||
405 | maxvec = rounddown_pow_of_two(maxvec); | ||
406 | |||
407 | if (minvec > maxvec) | ||
408 | return -ERANGE; | ||
409 | |||
410 | retry: | ||
411 | rc = pci_enable_msix_exact(adapter->pdev, | ||
412 | adapter->msix_entries, maxvec); | ||
413 | |||
414 | /* | ||
415 | * -ENOSPC is the only error code allowed to be analyzed | ||
416 | */ | ||
417 | if (rc == -ENOSPC) { | ||
418 | if (maxvec == 1) | ||
419 | return -ENOSPC; | ||
420 | |||
421 | maxvec /= 2; | ||
422 | |||
423 | if (minvec > maxvec) | ||
424 | return -ENOSPC; | ||
425 | |||
426 | goto retry; | ||
427 | } else if (rc < 0) { | ||
428 | return rc; | ||
429 | } | ||
430 | |||
431 | return maxvec; | ||
432 | } | ||
433 | |||
434 | 4.3.3 pci_disable_msix | ||
336 | 435 | ||
337 | void pci_disable_msix(struct pci_dev *dev) | 436 | void pci_disable_msix(struct pci_dev *dev) |
338 | 437 | ||
diff --git a/Documentation/PCI/pci-iov-howto.txt b/Documentation/PCI/pci-iov-howto.txt index 86551cc72e03..2d91ae251982 100644 --- a/Documentation/PCI/pci-iov-howto.txt +++ b/Documentation/PCI/pci-iov-howto.txt | |||
@@ -68,10 +68,6 @@ To disable SR-IOV capability: | |||
68 | echo 0 > \ | 68 | echo 0 > \ |
69 | /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs | 69 | /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs |
70 | 70 | ||
71 | To notify SR-IOV core of Virtual Function Migration: | ||
72 | (a) In the driver: | ||
73 | irqreturn_t pci_sriov_migration(struct pci_dev *dev); | ||
74 | |||
75 | 3.2 Usage example | 71 | 3.2 Usage example |
76 | 72 | ||
77 | Following piece of code illustrates the usage of the SR-IOV API. | 73 | Following piece of code illustrates the usage of the SR-IOV API. |
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index 317da88ae65b..d0d46786892c 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c | |||
@@ -19,7 +19,7 @@ | |||
19 | static int debug_pci; | 19 | static int debug_pci; |
20 | 20 | ||
21 | /* | 21 | /* |
22 | * We can't use pci_find_device() here since we are | 22 | * We can't use pci_get_device() here since we are |
23 | * called from interrupt context. | 23 | * called from interrupt context. |
24 | */ | 24 | */ |
25 | static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, int warn) | 25 | static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, int warn) |
@@ -57,13 +57,10 @@ static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, in | |||
57 | 57 | ||
58 | void pcibios_report_status(u_int status_mask, int warn) | 58 | void pcibios_report_status(u_int status_mask, int warn) |
59 | { | 59 | { |
60 | struct list_head *l; | 60 | struct pci_bus *bus; |
61 | |||
62 | list_for_each(l, &pci_root_buses) { | ||
63 | struct pci_bus *bus = pci_bus_b(l); | ||
64 | 61 | ||
62 | list_for_each_entry(bus, &pci_root_buses, node) | ||
65 | pcibios_bus_report_status(bus, status_mask, warn); | 63 | pcibios_bus_report_status(bus, status_mask, warn); |
66 | } | ||
67 | } | 64 | } |
68 | 65 | ||
69 | /* | 66 | /* |
diff --git a/arch/frv/mb93090-mb00/pci-frv.c b/arch/frv/mb93090-mb00/pci-frv.c index c28121765448..67b1d1685759 100644 --- a/arch/frv/mb93090-mb00/pci-frv.c +++ b/arch/frv/mb93090-mb00/pci-frv.c | |||
@@ -88,7 +88,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list) | |||
88 | 88 | ||
89 | /* Depth-First Search on bus tree */ | 89 | /* Depth-First Search on bus tree */ |
90 | for (ln=bus_list->next; ln != bus_list; ln=ln->next) { | 90 | for (ln=bus_list->next; ln != bus_list; ln=ln->next) { |
91 | bus = pci_bus_b(ln); | 91 | bus = list_entry(ln, struct pci_bus, node); |
92 | if ((dev = bus->self)) { | 92 | if ((dev = bus->self)) { |
93 | for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) { | 93 | for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) { |
94 | r = &dev->resource[idx]; | 94 | r = &dev->resource[idx]; |
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c index 8e858b593e4f..007361d59aa6 100644 --- a/arch/ia64/hp/common/sba_iommu.c +++ b/arch/ia64/hp/common/sba_iommu.c | |||
@@ -1140,11 +1140,13 @@ sba_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, | |||
1140 | 1140 | ||
1141 | #ifdef CONFIG_NUMA | 1141 | #ifdef CONFIG_NUMA |
1142 | { | 1142 | { |
1143 | int node = ioc->node; | ||
1143 | struct page *page; | 1144 | struct page *page; |
1144 | page = alloc_pages_exact_node(ioc->node == MAX_NUMNODES ? | ||
1145 | numa_node_id() : ioc->node, flags, | ||
1146 | get_order(size)); | ||
1147 | 1145 | ||
1146 | if (node == NUMA_NO_NODE) | ||
1147 | node = numa_node_id(); | ||
1148 | |||
1149 | page = alloc_pages_exact_node(node, flags, get_order(size)); | ||
1148 | if (unlikely(!page)) | 1150 | if (unlikely(!page)) |
1149 | return NULL; | 1151 | return NULL; |
1150 | 1152 | ||
@@ -1914,7 +1916,7 @@ ioc_show(struct seq_file *s, void *v) | |||
1914 | seq_printf(s, "Hewlett Packard %s IOC rev %d.%d\n", | 1916 | seq_printf(s, "Hewlett Packard %s IOC rev %d.%d\n", |
1915 | ioc->name, ((ioc->rev >> 4) & 0xF), (ioc->rev & 0xF)); | 1917 | ioc->name, ((ioc->rev >> 4) & 0xF), (ioc->rev & 0xF)); |
1916 | #ifdef CONFIG_NUMA | 1918 | #ifdef CONFIG_NUMA |
1917 | if (ioc->node != MAX_NUMNODES) | 1919 | if (ioc->node != NUMA_NO_NODE) |
1918 | seq_printf(s, "NUMA node : %d\n", ioc->node); | 1920 | seq_printf(s, "NUMA node : %d\n", ioc->node); |
1919 | #endif | 1921 | #endif |
1920 | seq_printf(s, "IOVA size : %ld MB\n", ((ioc->pdir_size >> 3) * iovp_size)/(1024*1024)); | 1922 | seq_printf(s, "IOVA size : %ld MB\n", ((ioc->pdir_size >> 3) * iovp_size)/(1024*1024)); |
@@ -2015,31 +2017,19 @@ sba_connect_bus(struct pci_bus *bus) | |||
2015 | printk(KERN_WARNING "No IOC for PCI Bus %04x:%02x in ACPI\n", pci_domain_nr(bus), bus->number); | 2017 | printk(KERN_WARNING "No IOC for PCI Bus %04x:%02x in ACPI\n", pci_domain_nr(bus), bus->number); |
2016 | } | 2018 | } |
2017 | 2019 | ||
2018 | #ifdef CONFIG_NUMA | ||
2019 | static void __init | 2020 | static void __init |
2020 | sba_map_ioc_to_node(struct ioc *ioc, acpi_handle handle) | 2021 | sba_map_ioc_to_node(struct ioc *ioc, acpi_handle handle) |
2021 | { | 2022 | { |
2023 | #ifdef CONFIG_NUMA | ||
2022 | unsigned int node; | 2024 | unsigned int node; |
2023 | int pxm; | ||
2024 | |||
2025 | ioc->node = MAX_NUMNODES; | ||
2026 | |||
2027 | pxm = acpi_get_pxm(handle); | ||
2028 | |||
2029 | if (pxm < 0) | ||
2030 | return; | ||
2031 | |||
2032 | node = pxm_to_node(pxm); | ||
2033 | 2025 | ||
2034 | if (node >= MAX_NUMNODES || !node_online(node)) | 2026 | node = acpi_get_node(handle); |
2035 | return; | 2027 | if (node != NUMA_NO_NODE && !node_online(node)) |
2028 | node = NUMA_NO_NODE; | ||
2036 | 2029 | ||
2037 | ioc->node = node; | 2030 | ioc->node = node; |
2038 | return; | ||
2039 | } | ||
2040 | #else | ||
2041 | #define sba_map_ioc_to_node(ioc, handle) | ||
2042 | #endif | 2031 | #endif |
2032 | } | ||
2043 | 2033 | ||
2044 | static int __init | 2034 | static int __init |
2045 | acpi_sba_ioc_add(struct acpi_device *device, | 2035 | acpi_sba_ioc_add(struct acpi_device *device, |
diff --git a/arch/ia64/include/asm/pci.h b/arch/ia64/include/asm/pci.h index 71fbaaa495cc..7d41cc089822 100644 --- a/arch/ia64/include/asm/pci.h +++ b/arch/ia64/include/asm/pci.h | |||
@@ -98,7 +98,7 @@ struct pci_controller { | |||
98 | struct acpi_device *companion; | 98 | struct acpi_device *companion; |
99 | void *iommu; | 99 | void *iommu; |
100 | int segment; | 100 | int segment; |
101 | int node; /* nearest node with memory or -1 for global allocation */ | 101 | int node; /* nearest node with memory or NUMA_NO_NODE for global allocation */ |
102 | 102 | ||
103 | void *platform_data; | 103 | void *platform_data; |
104 | }; | 104 | }; |
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index 07d209c9507f..5a585ebe9df3 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c | |||
@@ -803,14 +803,9 @@ int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi) | |||
803 | * ACPI based hotplug CPU support | 803 | * ACPI based hotplug CPU support |
804 | */ | 804 | */ |
805 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | 805 | #ifdef CONFIG_ACPI_HOTPLUG_CPU |
806 | static | 806 | static int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) |
807 | int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) | ||
808 | { | 807 | { |
809 | #ifdef CONFIG_ACPI_NUMA | 808 | #ifdef CONFIG_ACPI_NUMA |
810 | int pxm_id; | ||
811 | int nid; | ||
812 | |||
813 | pxm_id = acpi_get_pxm(handle); | ||
814 | /* | 809 | /* |
815 | * We don't have cpu-only-node hotadd. But if the system equips | 810 | * We don't have cpu-only-node hotadd. But if the system equips |
816 | * SRAT table, pxm is already found and node is ready. | 811 | * SRAT table, pxm is already found and node is ready. |
@@ -818,11 +813,10 @@ int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) | |||
818 | * This code here is for the system which doesn't have full SRAT | 813 | * This code here is for the system which doesn't have full SRAT |
819 | * table for possible cpus. | 814 | * table for possible cpus. |
820 | */ | 815 | */ |
821 | nid = acpi_map_pxm_to_node(pxm_id); | ||
822 | node_cpuid[cpu].phys_id = physid; | 816 | node_cpuid[cpu].phys_id = physid; |
823 | node_cpuid[cpu].nid = nid; | 817 | node_cpuid[cpu].nid = acpi_get_node(handle); |
824 | #endif | 818 | #endif |
825 | return (0); | 819 | return 0; |
826 | } | 820 | } |
827 | 821 | ||
828 | int additional_cpus __initdata = -1; | 822 | int additional_cpus __initdata = -1; |
@@ -929,7 +923,7 @@ static acpi_status acpi_map_iosapic(acpi_handle handle, u32 depth, | |||
929 | union acpi_object *obj; | 923 | union acpi_object *obj; |
930 | struct acpi_madt_io_sapic *iosapic; | 924 | struct acpi_madt_io_sapic *iosapic; |
931 | unsigned int gsi_base; | 925 | unsigned int gsi_base; |
932 | int pxm, node; | 926 | int node; |
933 | 927 | ||
934 | /* Only care about objects w/ a method that returns the MADT */ | 928 | /* Only care about objects w/ a method that returns the MADT */ |
935 | if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) | 929 | if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) |
@@ -956,17 +950,9 @@ static acpi_status acpi_map_iosapic(acpi_handle handle, u32 depth, | |||
956 | 950 | ||
957 | kfree(buffer.pointer); | 951 | kfree(buffer.pointer); |
958 | 952 | ||
959 | /* | 953 | /* OK, it's an IOSAPIC MADT entry; associate it with a node */ |
960 | * OK, it's an IOSAPIC MADT entry, look for a _PXM value to tell | 954 | node = acpi_get_node(handle); |
961 | * us which node to associate this with. | 955 | if (node == NUMA_NO_NODE || !node_online(node) || |
962 | */ | ||
963 | pxm = acpi_get_pxm(handle); | ||
964 | if (pxm < 0) | ||
965 | return AE_OK; | ||
966 | |||
967 | node = pxm_to_node(pxm); | ||
968 | |||
969 | if (node >= MAX_NUMNODES || !node_online(node) || | ||
970 | cpumask_empty(cpumask_of_node(node))) | 956 | cpumask_empty(cpumask_of_node(node))) |
971 | return AE_OK; | 957 | return AE_OK; |
972 | 958 | ||
diff --git a/arch/ia64/pci/fixup.c b/arch/ia64/pci/fixup.c index 5dc969dd4ac0..eee069a0b539 100644 --- a/arch/ia64/pci/fixup.c +++ b/arch/ia64/pci/fixup.c | |||
@@ -5,6 +5,7 @@ | |||
5 | 5 | ||
6 | #include <linux/pci.h> | 6 | #include <linux/pci.h> |
7 | #include <linux/init.h> | 7 | #include <linux/init.h> |
8 | #include <linux/vgaarb.h> | ||
8 | 9 | ||
9 | #include <asm/machvec.h> | 10 | #include <asm/machvec.h> |
10 | 11 | ||
@@ -19,9 +20,10 @@ | |||
19 | * IORESOURCE_ROM_SHADOW is used to associate the boot video | 20 | * IORESOURCE_ROM_SHADOW is used to associate the boot video |
20 | * card with this copy. On laptops this copy has to be used since | 21 | * card with this copy. On laptops this copy has to be used since |
21 | * the main ROM may be compressed or combined with another image. | 22 | * the main ROM may be compressed or combined with another image. |
22 | * See pci_map_rom() for use of this flag. IORESOURCE_ROM_SHADOW | 23 | * See pci_map_rom() for use of this flag. Before marking the device |
23 | * is marked here since the boot video device will be the only enabled | 24 | * with IORESOURCE_ROM_SHADOW check if a vga_default_device is already set |
24 | * video device at this point. | 25 | * by either arch cde or vga-arbitration, if so only apply the fixup to this |
26 | * already determined primary video card. | ||
25 | */ | 27 | */ |
26 | 28 | ||
27 | static void pci_fixup_video(struct pci_dev *pdev) | 29 | static void pci_fixup_video(struct pci_dev *pdev) |
@@ -35,9 +37,6 @@ static void pci_fixup_video(struct pci_dev *pdev) | |||
35 | return; | 37 | return; |
36 | /* Maybe, this machine supports legacy memory map. */ | 38 | /* Maybe, this machine supports legacy memory map. */ |
37 | 39 | ||
38 | if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA) | ||
39 | return; | ||
40 | |||
41 | /* Is VGA routed to us? */ | 40 | /* Is VGA routed to us? */ |
42 | bus = pdev->bus; | 41 | bus = pdev->bus; |
43 | while (bus) { | 42 | while (bus) { |
@@ -60,10 +59,14 @@ static void pci_fixup_video(struct pci_dev *pdev) | |||
60 | } | 59 | } |
61 | bus = bus->parent; | 60 | bus = bus->parent; |
62 | } | 61 | } |
63 | pci_read_config_word(pdev, PCI_COMMAND, &config); | 62 | if (!vga_default_device() || pdev == vga_default_device()) { |
64 | if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) { | 63 | pci_read_config_word(pdev, PCI_COMMAND, &config); |
65 | pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW; | 64 | if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) { |
66 | dev_printk(KERN_DEBUG, &pdev->dev, "Boot video device\n"); | 65 | pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW; |
66 | dev_printk(KERN_DEBUG, &pdev->dev, "Boot video device\n"); | ||
67 | vga_set_default_device(pdev); | ||
68 | } | ||
67 | } | 69 | } |
68 | } | 70 | } |
69 | DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video); | 71 | DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, |
72 | PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_video); | ||
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 9e4938d8ca4d..291a582777cf 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c | |||
@@ -126,7 +126,6 @@ static struct pci_controller *alloc_pci_controller(int seg) | |||
126 | return NULL; | 126 | return NULL; |
127 | 127 | ||
128 | controller->segment = seg; | 128 | controller->segment = seg; |
129 | controller->node = -1; | ||
130 | return controller; | 129 | return controller; |
131 | } | 130 | } |
132 | 131 | ||
@@ -430,19 +429,14 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) | |||
430 | struct pci_root_info *info = NULL; | 429 | struct pci_root_info *info = NULL; |
431 | int busnum = root->secondary.start; | 430 | int busnum = root->secondary.start; |
432 | struct pci_bus *pbus; | 431 | struct pci_bus *pbus; |
433 | int pxm, ret; | 432 | int ret; |
434 | 433 | ||
435 | controller = alloc_pci_controller(domain); | 434 | controller = alloc_pci_controller(domain); |
436 | if (!controller) | 435 | if (!controller) |
437 | return NULL; | 436 | return NULL; |
438 | 437 | ||
439 | controller->companion = device; | 438 | controller->companion = device; |
440 | 439 | controller->node = acpi_get_node(device->handle); | |
441 | pxm = acpi_get_pxm(device->handle); | ||
442 | #ifdef CONFIG_NUMA | ||
443 | if (pxm >= 0) | ||
444 | controller->node = pxm_to_node(pxm); | ||
445 | #endif | ||
446 | 440 | ||
447 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 441 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
448 | if (!info) { | 442 | if (!info) { |
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index a9e311f7a9dd..2a4779091a58 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c | |||
@@ -208,7 +208,6 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus, | |||
208 | unsigned long in_devfn) | 208 | unsigned long in_devfn) |
209 | { | 209 | { |
210 | struct pci_controller* hose; | 210 | struct pci_controller* hose; |
211 | struct list_head *ln; | ||
212 | struct pci_bus *bus = NULL; | 211 | struct pci_bus *bus = NULL; |
213 | struct device_node *hose_node; | 212 | struct device_node *hose_node; |
214 | 213 | ||
@@ -230,8 +229,7 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus, | |||
230 | * used on pre-domains setup. We return the first match | 229 | * used on pre-domains setup. We return the first match |
231 | */ | 230 | */ |
232 | 231 | ||
233 | for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) { | 232 | list_for_each_entry(bus, &pci_root_buses, node) { |
234 | bus = pci_bus_b(ln); | ||
235 | if (in_bus >= bus->number && in_bus <= bus->busn_res.end) | 233 | if (in_bus >= bus->number && in_bus <= bus->busn_res.end) |
236 | break; | 234 | break; |
237 | bus = NULL; | 235 | bus = NULL; |
diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c index efe61374f6ea..203cbf0dc101 100644 --- a/arch/powerpc/platforms/pseries/pci_dlpar.c +++ b/arch/powerpc/platforms/pseries/pci_dlpar.c | |||
@@ -37,15 +37,15 @@ find_bus_among_children(struct pci_bus *bus, | |||
37 | struct device_node *dn) | 37 | struct device_node *dn) |
38 | { | 38 | { |
39 | struct pci_bus *child = NULL; | 39 | struct pci_bus *child = NULL; |
40 | struct list_head *tmp; | 40 | struct pci_bus *tmp; |
41 | struct device_node *busdn; | 41 | struct device_node *busdn; |
42 | 42 | ||
43 | busdn = pci_bus_to_OF_node(bus); | 43 | busdn = pci_bus_to_OF_node(bus); |
44 | if (busdn == dn) | 44 | if (busdn == dn) |
45 | return bus; | 45 | return bus; |
46 | 46 | ||
47 | list_for_each(tmp, &bus->children) { | 47 | list_for_each_entry(tmp, &bus->children, node) { |
48 | child = find_bus_among_children(pci_bus_b(tmp), dn); | 48 | child = find_bus_among_children(tmp, dn); |
49 | if (child) | 49 | if (child) |
50 | break; | 50 | break; |
51 | }; | 51 | }; |
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h index 1ac6114c9ea5..96ae4f4040bb 100644 --- a/arch/x86/include/asm/pci.h +++ b/arch/x86/include/asm/pci.h | |||
@@ -26,11 +26,6 @@ extern int pci_routeirq; | |||
26 | extern int noioapicquirk; | 26 | extern int noioapicquirk; |
27 | extern int noioapicreroute; | 27 | extern int noioapicreroute; |
28 | 28 | ||
29 | /* scan a bus after allocating a pci_sysdata for it */ | ||
30 | extern struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops, | ||
31 | int node); | ||
32 | extern struct pci_bus *pci_scan_bus_with_sysdata(int busno); | ||
33 | |||
34 | #ifdef CONFIG_PCI | 29 | #ifdef CONFIG_PCI |
35 | 30 | ||
36 | #ifdef CONFIG_PCI_DOMAINS | 31 | #ifdef CONFIG_PCI_DOMAINS |
@@ -70,7 +65,7 @@ extern unsigned long pci_mem_start; | |||
70 | 65 | ||
71 | extern int pcibios_enabled; | 66 | extern int pcibios_enabled; |
72 | void pcibios_config_init(void); | 67 | void pcibios_config_init(void); |
73 | struct pci_bus *pcibios_scan_root(int bus); | 68 | void pcibios_scan_root(int bus); |
74 | 69 | ||
75 | void pcibios_set_master(struct pci_dev *dev); | 70 | void pcibios_set_master(struct pci_dev *dev); |
76 | void pcibios_penalize_isa_irq(int irq, int active); | 71 | void pcibios_penalize_isa_irq(int irq, int active); |
diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h index d35f24e231cd..c840571afa4e 100644 --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h | |||
@@ -131,6 +131,7 @@ static inline void arch_fix_phys_package_id(int num, u32 slot) | |||
131 | } | 131 | } |
132 | 132 | ||
133 | struct pci_bus; | 133 | struct pci_bus; |
134 | int x86_pci_root_bus_node(int bus); | ||
134 | void x86_pci_root_bus_resources(int bus, struct list_head *resources); | 135 | void x86_pci_root_bus_resources(int bus, struct list_head *resources); |
135 | 136 | ||
136 | #ifdef CONFIG_SMP | 137 | #ifdef CONFIG_SMP |
@@ -139,17 +140,4 @@ void x86_pci_root_bus_resources(int bus, struct list_head *resources); | |||
139 | #define smt_capable() (smp_num_siblings > 1) | 140 | #define smt_capable() (smp_num_siblings > 1) |
140 | #endif | 141 | #endif |
141 | 142 | ||
142 | #ifdef CONFIG_NUMA | ||
143 | extern int get_mp_bus_to_node(int busnum); | ||
144 | extern void set_mp_bus_to_node(int busnum, int node); | ||
145 | #else | ||
146 | static inline int get_mp_bus_to_node(int busnum) | ||
147 | { | ||
148 | return 0; | ||
149 | } | ||
150 | static inline void set_mp_bus_to_node(int busnum, int node) | ||
151 | { | ||
152 | } | ||
153 | #endif | ||
154 | |||
155 | #endif /* _ASM_X86_TOPOLOGY_H */ | 143 | #endif /* _ASM_X86_TOPOLOGY_H */ |
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index 4f25ec077552..01edac6c5e18 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c | |||
@@ -218,9 +218,8 @@ static void teardown_mcfg_map(struct pci_root_info *info) | |||
218 | } | 218 | } |
219 | #endif | 219 | #endif |
220 | 220 | ||
221 | static acpi_status | 221 | static acpi_status resource_to_addr(struct acpi_resource *resource, |
222 | resource_to_addr(struct acpi_resource *resource, | 222 | struct acpi_resource_address64 *addr) |
223 | struct acpi_resource_address64 *addr) | ||
224 | { | 223 | { |
225 | acpi_status status; | 224 | acpi_status status; |
226 | struct acpi_resource_memory24 *memory24; | 225 | struct acpi_resource_memory24 *memory24; |
@@ -265,8 +264,7 @@ resource_to_addr(struct acpi_resource *resource, | |||
265 | return AE_ERROR; | 264 | return AE_ERROR; |
266 | } | 265 | } |
267 | 266 | ||
268 | static acpi_status | 267 | static acpi_status count_resource(struct acpi_resource *acpi_res, void *data) |
269 | count_resource(struct acpi_resource *acpi_res, void *data) | ||
270 | { | 268 | { |
271 | struct pci_root_info *info = data; | 269 | struct pci_root_info *info = data; |
272 | struct acpi_resource_address64 addr; | 270 | struct acpi_resource_address64 addr; |
@@ -278,8 +276,7 @@ count_resource(struct acpi_resource *acpi_res, void *data) | |||
278 | return AE_OK; | 276 | return AE_OK; |
279 | } | 277 | } |
280 | 278 | ||
281 | static acpi_status | 279 | static acpi_status setup_resource(struct acpi_resource *acpi_res, void *data) |
282 | setup_resource(struct acpi_resource *acpi_res, void *data) | ||
283 | { | 280 | { |
284 | struct pci_root_info *info = data; | 281 | struct pci_root_info *info = data; |
285 | struct resource *res; | 282 | struct resource *res; |
@@ -435,9 +432,9 @@ static void release_pci_root_info(struct pci_host_bridge *bridge) | |||
435 | __release_pci_root_info(info); | 432 | __release_pci_root_info(info); |
436 | } | 433 | } |
437 | 434 | ||
438 | static void | 435 | static void probe_pci_root_info(struct pci_root_info *info, |
439 | probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device, | 436 | struct acpi_device *device, |
440 | int busnum, int domain) | 437 | int busnum, int domain) |
441 | { | 438 | { |
442 | size_t size; | 439 | size_t size; |
443 | 440 | ||
@@ -473,16 +470,13 @@ probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device, | |||
473 | struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) | 470 | struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) |
474 | { | 471 | { |
475 | struct acpi_device *device = root->device; | 472 | struct acpi_device *device = root->device; |
476 | struct pci_root_info *info = NULL; | 473 | struct pci_root_info *info; |
477 | int domain = root->segment; | 474 | int domain = root->segment; |
478 | int busnum = root->secondary.start; | 475 | int busnum = root->secondary.start; |
479 | LIST_HEAD(resources); | 476 | LIST_HEAD(resources); |
480 | struct pci_bus *bus = NULL; | 477 | struct pci_bus *bus; |
481 | struct pci_sysdata *sd; | 478 | struct pci_sysdata *sd; |
482 | int node; | 479 | int node; |
483 | #ifdef CONFIG_ACPI_NUMA | ||
484 | int pxm; | ||
485 | #endif | ||
486 | 480 | ||
487 | if (pci_ignore_seg) | 481 | if (pci_ignore_seg) |
488 | domain = 0; | 482 | domain = 0; |
@@ -494,19 +488,12 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) | |||
494 | return NULL; | 488 | return NULL; |
495 | } | 489 | } |
496 | 490 | ||
497 | node = -1; | 491 | node = acpi_get_node(device->handle); |
498 | #ifdef CONFIG_ACPI_NUMA | 492 | if (node == NUMA_NO_NODE) |
499 | pxm = acpi_get_pxm(device->handle); | 493 | node = x86_pci_root_bus_node(busnum); |
500 | if (pxm >= 0) | ||
501 | node = pxm_to_node(pxm); | ||
502 | if (node != -1) | ||
503 | set_mp_bus_to_node(busnum, node); | ||
504 | else | ||
505 | #endif | ||
506 | node = get_mp_bus_to_node(busnum); | ||
507 | 494 | ||
508 | if (node != -1 && !node_online(node)) | 495 | if (node != NUMA_NO_NODE && !node_online(node)) |
509 | node = -1; | 496 | node = NUMA_NO_NODE; |
510 | 497 | ||
511 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 498 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
512 | if (!info) { | 499 | if (!info) { |
@@ -519,15 +506,12 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) | |||
519 | sd->domain = domain; | 506 | sd->domain = domain; |
520 | sd->node = node; | 507 | sd->node = node; |
521 | sd->companion = device; | 508 | sd->companion = device; |
522 | /* | 509 | |
523 | * Maybe the desired pci bus has been already scanned. In such case | ||
524 | * it is unnecessary to scan the pci bus with the given domain,busnum. | ||
525 | */ | ||
526 | bus = pci_find_bus(domain, busnum); | 510 | bus = pci_find_bus(domain, busnum); |
527 | if (bus) { | 511 | if (bus) { |
528 | /* | 512 | /* |
529 | * If the desired bus exits, the content of bus->sysdata will | 513 | * If the desired bus has been scanned already, replace |
530 | * be replaced by sd. | 514 | * its bus->sysdata. |
531 | */ | 515 | */ |
532 | memcpy(bus->sysdata, sd, sizeof(*sd)); | 516 | memcpy(bus->sysdata, sd, sizeof(*sd)); |
533 | kfree(info); | 517 | kfree(info); |
@@ -572,15 +556,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) | |||
572 | pcie_bus_configure_settings(child); | 556 | pcie_bus_configure_settings(child); |
573 | } | 557 | } |
574 | 558 | ||
575 | if (bus && node != -1) { | 559 | if (bus && node != NUMA_NO_NODE) |
576 | #ifdef CONFIG_ACPI_NUMA | ||
577 | if (pxm >= 0) | ||
578 | dev_printk(KERN_DEBUG, &bus->dev, | ||
579 | "on NUMA node %d (pxm %d)\n", node, pxm); | ||
580 | #else | ||
581 | dev_printk(KERN_DEBUG, &bus->dev, "on NUMA node %d\n", node); | 560 | dev_printk(KERN_DEBUG, &bus->dev, "on NUMA node %d\n", node); |
582 | #endif | ||
583 | } | ||
584 | 561 | ||
585 | return bus; | 562 | return bus; |
586 | } | 563 | } |
diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c index a48be98e9ded..a313a7fb6b86 100644 --- a/arch/x86/pci/amd_bus.c +++ b/arch/x86/pci/amd_bus.c | |||
@@ -44,15 +44,6 @@ static struct pci_root_info __init *find_pci_root_info(int node, int link) | |||
44 | return NULL; | 44 | return NULL; |
45 | } | 45 | } |
46 | 46 | ||
47 | static void __init set_mp_bus_range_to_node(int min_bus, int max_bus, int node) | ||
48 | { | ||
49 | #ifdef CONFIG_NUMA | ||
50 | int j; | ||
51 | |||
52 | for (j = min_bus; j <= max_bus; j++) | ||
53 | set_mp_bus_to_node(j, node); | ||
54 | #endif | ||
55 | } | ||
56 | /** | 47 | /** |
57 | * early_fill_mp_bus_to_node() | 48 | * early_fill_mp_bus_to_node() |
58 | * called before pcibios_scan_root and pci_scan_bus | 49 | * called before pcibios_scan_root and pci_scan_bus |
@@ -117,7 +108,6 @@ static int __init early_fill_mp_bus_info(void) | |||
117 | min_bus = (reg >> 16) & 0xff; | 108 | min_bus = (reg >> 16) & 0xff; |
118 | max_bus = (reg >> 24) & 0xff; | 109 | max_bus = (reg >> 24) & 0xff; |
119 | node = (reg >> 4) & 0x07; | 110 | node = (reg >> 4) & 0x07; |
120 | set_mp_bus_range_to_node(min_bus, max_bus, node); | ||
121 | link = (reg >> 8) & 0x03; | 111 | link = (reg >> 8) & 0x03; |
122 | 112 | ||
123 | info = alloc_pci_root_info(min_bus, max_bus, node, link); | 113 | info = alloc_pci_root_info(min_bus, max_bus, node, link); |
diff --git a/arch/x86/pci/bus_numa.c b/arch/x86/pci/bus_numa.c index c2735feb2508..f3a2cfc14125 100644 --- a/arch/x86/pci/bus_numa.c +++ b/arch/x86/pci/bus_numa.c | |||
@@ -10,9 +10,6 @@ static struct pci_root_info *x86_find_pci_root_info(int bus) | |||
10 | { | 10 | { |
11 | struct pci_root_info *info; | 11 | struct pci_root_info *info; |
12 | 12 | ||
13 | if (list_empty(&pci_root_infos)) | ||
14 | return NULL; | ||
15 | |||
16 | list_for_each_entry(info, &pci_root_infos, list) | 13 | list_for_each_entry(info, &pci_root_infos, list) |
17 | if (info->busn.start == bus) | 14 | if (info->busn.start == bus) |
18 | return info; | 15 | return info; |
@@ -20,6 +17,16 @@ static struct pci_root_info *x86_find_pci_root_info(int bus) | |||
20 | return NULL; | 17 | return NULL; |
21 | } | 18 | } |
22 | 19 | ||
20 | int x86_pci_root_bus_node(int bus) | ||
21 | { | ||
22 | struct pci_root_info *info = x86_find_pci_root_info(bus); | ||
23 | |||
24 | if (!info) | ||
25 | return NUMA_NO_NODE; | ||
26 | |||
27 | return info->node; | ||
28 | } | ||
29 | |||
23 | void x86_pci_root_bus_resources(int bus, struct list_head *resources) | 30 | void x86_pci_root_bus_resources(int bus, struct list_head *resources) |
24 | { | 31 | { |
25 | struct pci_root_info *info = x86_find_pci_root_info(bus); | 32 | struct pci_root_info *info = x86_find_pci_root_info(bus); |
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 981c2dbd72cc..d491deddebae 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c | |||
@@ -456,19 +456,25 @@ void __init dmi_check_pciprobe(void) | |||
456 | dmi_check_system(pciprobe_dmi_table); | 456 | dmi_check_system(pciprobe_dmi_table); |
457 | } | 457 | } |
458 | 458 | ||
459 | struct pci_bus *pcibios_scan_root(int busnum) | 459 | void pcibios_scan_root(int busnum) |
460 | { | 460 | { |
461 | struct pci_bus *bus = NULL; | 461 | struct pci_bus *bus; |
462 | struct pci_sysdata *sd; | ||
463 | LIST_HEAD(resources); | ||
462 | 464 | ||
463 | while ((bus = pci_find_next_bus(bus)) != NULL) { | 465 | sd = kzalloc(sizeof(*sd), GFP_KERNEL); |
464 | if (bus->number == busnum) { | 466 | if (!sd) { |
465 | /* Already scanned */ | 467 | printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busnum); |
466 | return bus; | 468 | return; |
467 | } | 469 | } |
470 | sd->node = x86_pci_root_bus_node(busnum); | ||
471 | x86_pci_root_bus_resources(busnum, &resources); | ||
472 | printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum); | ||
473 | bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, sd, &resources); | ||
474 | if (!bus) { | ||
475 | pci_free_resource_list(&resources); | ||
476 | kfree(sd); | ||
468 | } | 477 | } |
469 | |||
470 | return pci_scan_bus_on_node(busnum, &pci_root_ops, | ||
471 | get_mp_bus_to_node(busnum)); | ||
472 | } | 478 | } |
473 | 479 | ||
474 | void __init pcibios_set_cache_line_size(void) | 480 | void __init pcibios_set_cache_line_size(void) |
@@ -677,105 +683,3 @@ int pci_ext_cfg_avail(void) | |||
677 | else | 683 | else |
678 | return 0; | 684 | return 0; |
679 | } | 685 | } |
680 | |||
681 | struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node) | ||
682 | { | ||
683 | LIST_HEAD(resources); | ||
684 | struct pci_bus *bus = NULL; | ||
685 | struct pci_sysdata *sd; | ||
686 | |||
687 | /* | ||
688 | * Allocate per-root-bus (not per bus) arch-specific data. | ||
689 | * TODO: leak; this memory is never freed. | ||
690 | * It's arguable whether it's worth the trouble to care. | ||
691 | */ | ||
692 | sd = kzalloc(sizeof(*sd), GFP_KERNEL); | ||
693 | if (!sd) { | ||
694 | printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busno); | ||
695 | return NULL; | ||
696 | } | ||
697 | sd->node = node; | ||
698 | x86_pci_root_bus_resources(busno, &resources); | ||
699 | printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busno); | ||
700 | bus = pci_scan_root_bus(NULL, busno, ops, sd, &resources); | ||
701 | if (!bus) { | ||
702 | pci_free_resource_list(&resources); | ||
703 | kfree(sd); | ||
704 | } | ||
705 | |||
706 | return bus; | ||
707 | } | ||
708 | |||
709 | struct pci_bus *pci_scan_bus_with_sysdata(int busno) | ||
710 | { | ||
711 | return pci_scan_bus_on_node(busno, &pci_root_ops, -1); | ||
712 | } | ||
713 | |||
714 | /* | ||
715 | * NUMA info for PCI busses | ||
716 | * | ||
717 | * Early arch code is responsible for filling in reasonable values here. | ||
718 | * A node id of "-1" means "use current node". In other words, if a bus | ||
719 | * has a -1 node id, it's not tightly coupled to any particular chunk | ||
720 | * of memory (as is the case on some Nehalem systems). | ||
721 | */ | ||
722 | #ifdef CONFIG_NUMA | ||
723 | |||
724 | #define BUS_NR 256 | ||
725 | |||
726 | #ifdef CONFIG_X86_64 | ||
727 | |||
728 | static int mp_bus_to_node[BUS_NR] = { | ||
729 | [0 ... BUS_NR - 1] = -1 | ||
730 | }; | ||
731 | |||
732 | void set_mp_bus_to_node(int busnum, int node) | ||
733 | { | ||
734 | if (busnum >= 0 && busnum < BUS_NR) | ||
735 | mp_bus_to_node[busnum] = node; | ||
736 | } | ||
737 | |||
738 | int get_mp_bus_to_node(int busnum) | ||
739 | { | ||
740 | int node = -1; | ||
741 | |||
742 | if (busnum < 0 || busnum > (BUS_NR - 1)) | ||
743 | return node; | ||
744 | |||
745 | node = mp_bus_to_node[busnum]; | ||
746 | |||
747 | /* | ||
748 | * let numa_node_id to decide it later in dma_alloc_pages | ||
749 | * if there is no ram on that node | ||
750 | */ | ||
751 | if (node != -1 && !node_online(node)) | ||
752 | node = -1; | ||
753 | |||
754 | return node; | ||
755 | } | ||
756 | |||
757 | #else /* CONFIG_X86_32 */ | ||
758 | |||
759 | static int mp_bus_to_node[BUS_NR] = { | ||
760 | [0 ... BUS_NR - 1] = -1 | ||
761 | }; | ||
762 | |||
763 | void set_mp_bus_to_node(int busnum, int node) | ||
764 | { | ||
765 | if (busnum >= 0 && busnum < BUS_NR) | ||
766 | mp_bus_to_node[busnum] = (unsigned char) node; | ||
767 | } | ||
768 | |||
769 | int get_mp_bus_to_node(int busnum) | ||
770 | { | ||
771 | int node; | ||
772 | |||
773 | if (busnum < 0 || busnum > (BUS_NR - 1)) | ||
774 | return 0; | ||
775 | node = mp_bus_to_node[busnum]; | ||
776 | return node; | ||
777 | } | ||
778 | |||
779 | #endif /* CONFIG_X86_32 */ | ||
780 | |||
781 | #endif /* CONFIG_NUMA */ | ||
diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c index bca9e85daaa5..94ae9ae9574f 100644 --- a/arch/x86/pci/fixup.c +++ b/arch/x86/pci/fixup.c | |||
@@ -25,9 +25,9 @@ static void pci_fixup_i450nx(struct pci_dev *d) | |||
25 | dev_dbg(&d->dev, "i450NX PXB %d: %02x/%02x/%02x\n", pxb, busno, | 25 | dev_dbg(&d->dev, "i450NX PXB %d: %02x/%02x/%02x\n", pxb, busno, |
26 | suba, subb); | 26 | suba, subb); |
27 | if (busno) | 27 | if (busno) |
28 | pci_scan_bus_with_sysdata(busno); /* Bus A */ | 28 | pcibios_scan_root(busno); /* Bus A */ |
29 | if (suba < subb) | 29 | if (suba < subb) |
30 | pci_scan_bus_with_sysdata(suba+1); /* Bus B */ | 30 | pcibios_scan_root(suba+1); /* Bus B */ |
31 | } | 31 | } |
32 | pcibios_last_bus = -1; | 32 | pcibios_last_bus = -1; |
33 | } | 33 | } |
@@ -42,7 +42,7 @@ static void pci_fixup_i450gx(struct pci_dev *d) | |||
42 | u8 busno; | 42 | u8 busno; |
43 | pci_read_config_byte(d, 0x4a, &busno); | 43 | pci_read_config_byte(d, 0x4a, &busno); |
44 | dev_info(&d->dev, "i440KX/GX host bridge; secondary bus %02x\n", busno); | 44 | dev_info(&d->dev, "i440KX/GX host bridge; secondary bus %02x\n", busno); |
45 | pci_scan_bus_with_sysdata(busno); | 45 | pcibios_scan_root(busno); |
46 | pcibios_last_bus = -1; | 46 | pcibios_last_bus = -1; |
47 | } | 47 | } |
48 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454GX, pci_fixup_i450gx); | 48 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454GX, pci_fixup_i450gx); |
@@ -313,9 +313,10 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MCH_PC1, pcie_r | |||
313 | * IORESOURCE_ROM_SHADOW is used to associate the boot video | 313 | * IORESOURCE_ROM_SHADOW is used to associate the boot video |
314 | * card with this copy. On laptops this copy has to be used since | 314 | * card with this copy. On laptops this copy has to be used since |
315 | * the main ROM may be compressed or combined with another image. | 315 | * the main ROM may be compressed or combined with another image. |
316 | * See pci_map_rom() for use of this flag. IORESOURCE_ROM_SHADOW | 316 | * See pci_map_rom() for use of this flag. Before marking the device |
317 | * is marked here since the boot video device will be the only enabled | 317 | * with IORESOURCE_ROM_SHADOW check if a vga_default_device is already set |
318 | * video device at this point. | 318 | * by either arch cde or vga-arbitration, if so only apply the fixup to this |
319 | * already determined primary video card. | ||
319 | */ | 320 | */ |
320 | 321 | ||
321 | static void pci_fixup_video(struct pci_dev *pdev) | 322 | static void pci_fixup_video(struct pci_dev *pdev) |
@@ -346,12 +347,13 @@ static void pci_fixup_video(struct pci_dev *pdev) | |||
346 | } | 347 | } |
347 | bus = bus->parent; | 348 | bus = bus->parent; |
348 | } | 349 | } |
349 | pci_read_config_word(pdev, PCI_COMMAND, &config); | 350 | if (!vga_default_device() || pdev == vga_default_device()) { |
350 | if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) { | 351 | pci_read_config_word(pdev, PCI_COMMAND, &config); |
351 | pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW; | 352 | if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) { |
352 | dev_printk(KERN_DEBUG, &pdev->dev, "Boot video device\n"); | 353 | pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW; |
353 | if (!vga_default_device()) | 354 | dev_printk(KERN_DEBUG, &pdev->dev, "Boot video device\n"); |
354 | vga_set_default_device(pdev); | 355 | vga_set_default_device(pdev); |
356 | } | ||
355 | } | 357 | } |
356 | } | 358 | } |
357 | DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, | 359 | DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, |
diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c index 372e9b8989b3..84112f55dd7a 100644 --- a/arch/x86/pci/irq.c +++ b/arch/x86/pci/irq.c | |||
@@ -136,13 +136,9 @@ static void __init pirq_peer_trick(void) | |||
136 | busmap[e->bus] = 1; | 136 | busmap[e->bus] = 1; |
137 | } | 137 | } |
138 | for (i = 1; i < 256; i++) { | 138 | for (i = 1; i < 256; i++) { |
139 | int node; | ||
140 | if (!busmap[i] || pci_find_bus(0, i)) | 139 | if (!busmap[i] || pci_find_bus(0, i)) |
141 | continue; | 140 | continue; |
142 | node = get_mp_bus_to_node(i); | 141 | pcibios_scan_root(i); |
143 | if (pci_scan_bus_on_node(i, &pci_root_ops, node)) | ||
144 | printk(KERN_INFO "PCI: Discovered primary peer " | ||
145 | "bus %02x [IRQ]\n", i); | ||
146 | } | 142 | } |
147 | pcibios_last_bus = -1; | 143 | pcibios_last_bus = -1; |
148 | } | 144 | } |
diff --git a/arch/x86/pci/legacy.c b/arch/x86/pci/legacy.c index 4db96fb1c232..5b662c0faf8c 100644 --- a/arch/x86/pci/legacy.c +++ b/arch/x86/pci/legacy.c | |||
@@ -37,19 +37,17 @@ int __init pci_legacy_init(void) | |||
37 | void pcibios_scan_specific_bus(int busn) | 37 | void pcibios_scan_specific_bus(int busn) |
38 | { | 38 | { |
39 | int devfn; | 39 | int devfn; |
40 | long node; | ||
41 | u32 l; | 40 | u32 l; |
42 | 41 | ||
43 | if (pci_find_bus(0, busn)) | 42 | if (pci_find_bus(0, busn)) |
44 | return; | 43 | return; |
45 | 44 | ||
46 | node = get_mp_bus_to_node(busn); | ||
47 | for (devfn = 0; devfn < 256; devfn += 8) { | 45 | for (devfn = 0; devfn < 256; devfn += 8) { |
48 | if (!raw_pci_read(0, busn, devfn, PCI_VENDOR_ID, 2, &l) && | 46 | if (!raw_pci_read(0, busn, devfn, PCI_VENDOR_ID, 2, &l) && |
49 | l != 0x0000 && l != 0xffff) { | 47 | l != 0x0000 && l != 0xffff) { |
50 | DBG("Found device at %02x:%02x [%04x]\n", busn, devfn, l); | 48 | DBG("Found device at %02x:%02x [%04x]\n", busn, devfn, l); |
51 | printk(KERN_INFO "PCI: Discovered peer bus %02x\n", busn); | 49 | printk(KERN_INFO "PCI: Discovered peer bus %02x\n", busn); |
52 | pci_scan_bus_on_node(busn, &pci_root_ops, node); | 50 | pcibios_scan_root(busn); |
53 | return; | 51 | return; |
54 | } | 52 | } |
55 | } | 53 | } |
diff --git a/arch/x86/pci/numaq_32.c b/arch/x86/pci/numaq_32.c index 72c229f9ebcf..080eb0374fff 100644 --- a/arch/x86/pci/numaq_32.c +++ b/arch/x86/pci/numaq_32.c | |||
@@ -135,11 +135,11 @@ static void pci_fixup_i450nx(struct pci_dev *d) | |||
135 | pxb, busno, suba, subb); | 135 | pxb, busno, suba, subb); |
136 | if (busno) { | 136 | if (busno) { |
137 | /* Bus A */ | 137 | /* Bus A */ |
138 | pci_scan_bus_with_sysdata(QUADLOCAL2BUS(quad, busno)); | 138 | pcibios_scan_root(QUADLOCAL2BUS(quad, busno)); |
139 | } | 139 | } |
140 | if (suba < subb) { | 140 | if (suba < subb) { |
141 | /* Bus B */ | 141 | /* Bus B */ |
142 | pci_scan_bus_with_sysdata(QUADLOCAL2BUS(quad, suba+1)); | 142 | pcibios_scan_root(QUADLOCAL2BUS(quad, suba+1)); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | pcibios_last_bus = -1; | 145 | pcibios_last_bus = -1; |
@@ -159,7 +159,7 @@ int __init pci_numaq_init(void) | |||
159 | continue; | 159 | continue; |
160 | printk("Scanning PCI bus %d for quad %d\n", | 160 | printk("Scanning PCI bus %d for quad %d\n", |
161 | QUADLOCAL2BUS(quad,0), quad); | 161 | QUADLOCAL2BUS(quad,0), quad); |
162 | pci_scan_bus_with_sysdata(QUADLOCAL2BUS(quad, 0)); | 162 | pcibios_scan_root(QUADLOCAL2BUS(quad, 0)); |
163 | } | 163 | } |
164 | return 0; | 164 | return 0; |
165 | } | 165 | } |
diff --git a/arch/x86/pci/visws.c b/arch/x86/pci/visws.c index 3e6d2a6db866..cd9d4d1681d2 100644 --- a/arch/x86/pci/visws.c +++ b/arch/x86/pci/visws.c | |||
@@ -78,8 +78,8 @@ int __init pci_visws_init(void) | |||
78 | "bridge B (PIIX4) bus: %u\n", pci_bus1, pci_bus0); | 78 | "bridge B (PIIX4) bus: %u\n", pci_bus1, pci_bus0); |
79 | 79 | ||
80 | raw_pci_ops = &pci_direct_conf1; | 80 | raw_pci_ops = &pci_direct_conf1; |
81 | pci_scan_bus_with_sysdata(pci_bus0); | 81 | pcibios_scan_root(pci_bus0); |
82 | pci_scan_bus_with_sysdata(pci_bus1); | 82 | pcibios_scan_root(pci_bus1); |
83 | pci_fixup_irqs(pci_common_swizzle, visws_map_irq); | 83 | pci_fixup_irqs(pci_common_swizzle, visws_map_irq); |
84 | pcibios_resource_survey(); | 84 | pcibios_resource_survey(); |
85 | /* Request bus scan */ | 85 | /* Request bus scan */ |
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index 9e6816ef280a..24b5476449a1 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c | |||
@@ -60,7 +60,7 @@ int node_to_pxm(int node) | |||
60 | return node_to_pxm_map[node]; | 60 | return node_to_pxm_map[node]; |
61 | } | 61 | } |
62 | 62 | ||
63 | void __acpi_map_pxm_to_node(int pxm, int node) | 63 | static void __acpi_map_pxm_to_node(int pxm, int node) |
64 | { | 64 | { |
65 | if (pxm_to_node_map[pxm] == NUMA_NO_NODE || node < pxm_to_node_map[pxm]) | 65 | if (pxm_to_node_map[pxm] == NUMA_NO_NODE || node < pxm_to_node_map[pxm]) |
66 | pxm_to_node_map[pxm] = node; | 66 | pxm_to_node_map[pxm] = node; |
@@ -193,7 +193,7 @@ static int __init acpi_parse_slit(struct acpi_table_header *table) | |||
193 | return 0; | 193 | return 0; |
194 | } | 194 | } |
195 | 195 | ||
196 | void __init __attribute__ ((weak)) | 196 | void __init __weak |
197 | acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa) | 197 | acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa) |
198 | { | 198 | { |
199 | printk(KERN_WARNING PREFIX | 199 | printk(KERN_WARNING PREFIX |
@@ -314,7 +314,7 @@ int __init acpi_numa_init(void) | |||
314 | return 0; | 314 | return 0; |
315 | } | 315 | } |
316 | 316 | ||
317 | int acpi_get_pxm(acpi_handle h) | 317 | static int acpi_get_pxm(acpi_handle h) |
318 | { | 318 | { |
319 | unsigned long long pxm; | 319 | unsigned long long pxm; |
320 | acpi_status status; | 320 | acpi_status status; |
@@ -331,14 +331,14 @@ int acpi_get_pxm(acpi_handle h) | |||
331 | return -1; | 331 | return -1; |
332 | } | 332 | } |
333 | 333 | ||
334 | int acpi_get_node(acpi_handle *handle) | 334 | int acpi_get_node(acpi_handle handle) |
335 | { | 335 | { |
336 | int pxm, node = NUMA_NO_NODE; | 336 | int pxm; |
337 | 337 | ||
338 | pxm = acpi_get_pxm(handle); | 338 | pxm = acpi_get_pxm(handle); |
339 | if (pxm >= 0 && pxm < MAX_PXM_DOMAINS) | 339 | if (pxm < 0 || pxm >= MAX_PXM_DOMAINS) |
340 | node = acpi_map_pxm_to_node(pxm); | 340 | return NUMA_NO_NODE; |
341 | 341 | ||
342 | return node; | 342 | return acpi_map_pxm_to_node(pxm); |
343 | } | 343 | } |
344 | EXPORT_SYMBOL(acpi_get_node); | 344 | EXPORT_SYMBOL(acpi_get_node); |
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index dc2756fb6f33..023710905289 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -1151,13 +1151,13 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host) | |||
1151 | static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports, | 1151 | static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports, |
1152 | struct ahci_host_priv *hpriv) | 1152 | struct ahci_host_priv *hpriv) |
1153 | { | 1153 | { |
1154 | int rc, nvec; | 1154 | int nvec; |
1155 | 1155 | ||
1156 | if (hpriv->flags & AHCI_HFLAG_NO_MSI) | 1156 | if (hpriv->flags & AHCI_HFLAG_NO_MSI) |
1157 | goto intx; | 1157 | goto intx; |
1158 | 1158 | ||
1159 | rc = pci_msi_vec_count(pdev); | 1159 | nvec = pci_msi_vec_count(pdev); |
1160 | if (rc < 0) | 1160 | if (nvec < 0) |
1161 | goto intx; | 1161 | goto intx; |
1162 | 1162 | ||
1163 | /* | 1163 | /* |
@@ -1165,19 +1165,19 @@ static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports, | |||
1165 | * Message mode could be enforced. In this case assume that advantage | 1165 | * Message mode could be enforced. In this case assume that advantage |
1166 | * of multipe MSIs is negated and use single MSI mode instead. | 1166 | * of multipe MSIs is negated and use single MSI mode instead. |
1167 | */ | 1167 | */ |
1168 | if (rc < n_ports) | 1168 | if (nvec < n_ports) |
1169 | goto single_msi; | 1169 | goto single_msi; |
1170 | 1170 | ||
1171 | nvec = rc; | 1171 | nvec = pci_enable_msi_range(pdev, nvec, nvec); |
1172 | rc = pci_enable_msi_block(pdev, nvec); | 1172 | if (nvec == -ENOSPC) |
1173 | if (rc) | 1173 | goto single_msi; |
1174 | else if (nvec < 0) | ||
1174 | goto intx; | 1175 | goto intx; |
1175 | 1176 | ||
1176 | return nvec; | 1177 | return nvec; |
1177 | 1178 | ||
1178 | single_msi: | 1179 | single_msi: |
1179 | rc = pci_enable_msi(pdev); | 1180 | if (pci_enable_msi(pdev)) |
1180 | if (rc) | ||
1181 | goto intx; | 1181 | goto intx; |
1182 | return 1; | 1182 | return 1; |
1183 | 1183 | ||
diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c index 725c46162bbd..2ac754e18bcf 100644 --- a/drivers/bus/mvebu-mbus.c +++ b/drivers/bus/mvebu-mbus.c | |||
@@ -870,14 +870,14 @@ static void __init mvebu_mbus_get_pcie_resources(struct device_node *np, | |||
870 | ret = of_property_read_u32_array(np, "pcie-mem-aperture", reg, ARRAY_SIZE(reg)); | 870 | ret = of_property_read_u32_array(np, "pcie-mem-aperture", reg, ARRAY_SIZE(reg)); |
871 | if (!ret) { | 871 | if (!ret) { |
872 | mem->start = reg[0]; | 872 | mem->start = reg[0]; |
873 | mem->end = mem->start + reg[1]; | 873 | mem->end = mem->start + reg[1] - 1; |
874 | mem->flags = IORESOURCE_MEM; | 874 | mem->flags = IORESOURCE_MEM; |
875 | } | 875 | } |
876 | 876 | ||
877 | ret = of_property_read_u32_array(np, "pcie-io-aperture", reg, ARRAY_SIZE(reg)); | 877 | ret = of_property_read_u32_array(np, "pcie-io-aperture", reg, ARRAY_SIZE(reg)); |
878 | if (!ret) { | 878 | if (!ret) { |
879 | io->start = reg[0]; | 879 | io->start = reg[0]; |
880 | io->end = io->start + reg[1]; | 880 | io->end = io->start + reg[1] - 1; |
881 | io->flags = IORESOURCE_IO; | 881 | io->flags = IORESOURCE_IO; |
882 | } | 882 | } |
883 | } | 883 | } |
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index 7f2af9aca038..309023f12d7f 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c | |||
@@ -319,7 +319,8 @@ static int drm_open_helper(struct inode *inode, struct file *filp, | |||
319 | pci_dev_put(pci_dev); | 319 | pci_dev_put(pci_dev); |
320 | } | 320 | } |
321 | if (!dev->hose) { | 321 | if (!dev->hose) { |
322 | struct pci_bus *b = pci_bus_b(pci_root_buses.next); | 322 | struct pci_bus *b = list_entry(pci_root_buses.next, |
323 | struct pci_bus, node); | ||
323 | if (b) | 324 | if (b) |
324 | dev->hose = b->sysdata; | 325 | dev->hose = b->sysdata; |
325 | } | 326 | } |
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index e400fbe411de..cff039df056e 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/list.h> | 25 | #include <linux/list.h> |
26 | #include <linux/spinlock.h> | 26 | #include <linux/spinlock.h> |
27 | #include <linux/pci.h> | 27 | #include <linux/pci.h> |
28 | #include <linux/irqreturn.h> | ||
28 | 29 | ||
29 | /* | 30 | /* |
30 | * Maximum number of IOMMUs supported | 31 | * Maximum number of IOMMUs supported |
diff --git a/drivers/misc/mei/hw-me.h b/drivers/misc/mei/hw-me.h index 80bd829fbd9a..893d5119fa9b 100644 --- a/drivers/misc/mei/hw-me.h +++ b/drivers/misc/mei/hw-me.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #define _MEI_INTERFACE_H_ | 20 | #define _MEI_INTERFACE_H_ |
21 | 21 | ||
22 | #include <linux/mei.h> | 22 | #include <linux/mei.h> |
23 | #include <linux/irqreturn.h> | ||
23 | #include "mei_dev.h" | 24 | #include "mei_dev.h" |
24 | #include "client.h" | 25 | #include "client.h" |
25 | 26 | ||
diff --git a/drivers/misc/mic/card/mic_device.h b/drivers/misc/mic/card/mic_device.h index 347b9b3b7916..306f502be95e 100644 --- a/drivers/misc/mic/card/mic_device.h +++ b/drivers/misc/mic/card/mic_device.h | |||
@@ -29,6 +29,7 @@ | |||
29 | 29 | ||
30 | #include <linux/workqueue.h> | 30 | #include <linux/workqueue.h> |
31 | #include <linux/io.h> | 31 | #include <linux/io.h> |
32 | #include <linux/irqreturn.h> | ||
32 | 33 | ||
33 | /** | 34 | /** |
34 | * struct mic_intr_info - Contains h/w specific interrupt sources info | 35 | * struct mic_intr_info - Contains h/w specific interrupt sources info |
diff --git a/drivers/misc/mic/host/mic_device.h b/drivers/misc/mic/host/mic_device.h index 1a6edce2ecde..0398c696d257 100644 --- a/drivers/misc/mic/host/mic_device.h +++ b/drivers/misc/mic/host/mic_device.h | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/cdev.h> | 24 | #include <linux/cdev.h> |
25 | #include <linux/idr.h> | 25 | #include <linux/idr.h> |
26 | #include <linux/notifier.h> | 26 | #include <linux/notifier.h> |
27 | #include <linux/irqreturn.h> | ||
27 | 28 | ||
28 | #include "mic_intr.h" | 29 | #include "mic_intr.h" |
29 | 30 | ||
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 17d2b07ee67c..e2501ac6fe84 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile | |||
@@ -33,21 +33,15 @@ obj-$(CONFIG_PCI_IOV) += iov.o | |||
33 | # | 33 | # |
34 | # Some architectures use the generic PCI setup functions | 34 | # Some architectures use the generic PCI setup functions |
35 | # | 35 | # |
36 | obj-$(CONFIG_X86) += setup-bus.o | 36 | obj-$(CONFIG_ALPHA) += setup-irq.o |
37 | obj-$(CONFIG_ALPHA) += setup-bus.o setup-irq.o | 37 | obj-$(CONFIG_ARM) += setup-irq.o |
38 | obj-$(CONFIG_ARM) += setup-bus.o setup-irq.o | 38 | obj-$(CONFIG_UNICORE32) += setup-irq.o |
39 | obj-$(CONFIG_UNICORE32) += setup-bus.o setup-irq.o | 39 | obj-$(CONFIG_SUPERH) += setup-irq.o |
40 | obj-$(CONFIG_PARISC) += setup-bus.o | 40 | obj-$(CONFIG_MIPS) += setup-irq.o |
41 | obj-$(CONFIG_SUPERH) += setup-bus.o setup-irq.o | ||
42 | obj-$(CONFIG_PPC) += setup-bus.o | ||
43 | obj-$(CONFIG_FRV) += setup-bus.o | ||
44 | obj-$(CONFIG_MIPS) += setup-bus.o setup-irq.o | ||
45 | obj-$(CONFIG_X86_VISWS) += setup-irq.o | 41 | obj-$(CONFIG_X86_VISWS) += setup-irq.o |
46 | obj-$(CONFIG_MN10300) += setup-bus.o | 42 | obj-$(CONFIG_TILE) += setup-irq.o |
47 | obj-$(CONFIG_MICROBLAZE) += setup-bus.o | 43 | obj-$(CONFIG_SPARC_LEON) += setup-irq.o |
48 | obj-$(CONFIG_TILE) += setup-bus.o setup-irq.o | 44 | obj-$(CONFIG_M68K) += setup-irq.o |
49 | obj-$(CONFIG_SPARC_LEON) += setup-bus.o setup-irq.o | ||
50 | obj-$(CONFIG_M68K) += setup-bus.o setup-irq.o | ||
51 | 45 | ||
52 | # | 46 | # |
53 | # ACPI Related PCI FW Functions | 47 | # ACPI Related PCI FW Functions |
diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig index 47d46c6d8468..a6f67ec8882f 100644 --- a/drivers/pci/host/Kconfig +++ b/drivers/pci/host/Kconfig | |||
@@ -27,7 +27,7 @@ config PCI_TEGRA | |||
27 | 27 | ||
28 | config PCI_RCAR_GEN2 | 28 | config PCI_RCAR_GEN2 |
29 | bool "Renesas R-Car Gen2 Internal PCI controller" | 29 | bool "Renesas R-Car Gen2 Internal PCI controller" |
30 | depends on ARM && (ARCH_R8A7790 || ARCH_R8A7791 || COMPILE_TEST) | 30 | depends on ARCH_SHMOBILE || (ARM && COMPILE_TEST) |
31 | help | 31 | help |
32 | Say Y here if you want internal PCI support on R-Car Gen2 SoC. | 32 | Say Y here if you want internal PCI support on R-Car Gen2 SoC. |
33 | There are 3 internal PCI controllers available with a single | 33 | There are 3 internal PCI controllers available with a single |
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c index 13478ecd4113..d3d1cfd51e09 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c | |||
@@ -60,14 +60,6 @@ | |||
60 | #define PCIE_DEBUG_CTRL 0x1a60 | 60 | #define PCIE_DEBUG_CTRL 0x1a60 |
61 | #define PCIE_DEBUG_SOFT_RESET BIT(20) | 61 | #define PCIE_DEBUG_SOFT_RESET BIT(20) |
62 | 62 | ||
63 | /* | ||
64 | * This product ID is registered by Marvell, and used when the Marvell | ||
65 | * SoC is not the root complex, but an endpoint on the PCIe bus. It is | ||
66 | * therefore safe to re-use this PCI ID for our emulated PCI-to-PCI | ||
67 | * bridge. | ||
68 | */ | ||
69 | #define MARVELL_EMULATED_PCI_PCI_BRIDGE_ID 0x7846 | ||
70 | |||
71 | /* PCI configuration space of a PCI-to-PCI bridge */ | 63 | /* PCI configuration space of a PCI-to-PCI bridge */ |
72 | struct mvebu_sw_pci_bridge { | 64 | struct mvebu_sw_pci_bridge { |
73 | u16 vendor; | 65 | u16 vendor; |
@@ -109,7 +101,9 @@ struct mvebu_pcie { | |||
109 | struct mvebu_pcie_port *ports; | 101 | struct mvebu_pcie_port *ports; |
110 | struct msi_chip *msi; | 102 | struct msi_chip *msi; |
111 | struct resource io; | 103 | struct resource io; |
104 | char io_name[30]; | ||
112 | struct resource realio; | 105 | struct resource realio; |
106 | char mem_name[30]; | ||
113 | struct resource mem; | 107 | struct resource mem; |
114 | struct resource busn; | 108 | struct resource busn; |
115 | int nports; | 109 | int nports; |
@@ -388,7 +382,8 @@ static void mvebu_sw_pci_bridge_init(struct mvebu_pcie_port *port) | |||
388 | 382 | ||
389 | bridge->class = PCI_CLASS_BRIDGE_PCI; | 383 | bridge->class = PCI_CLASS_BRIDGE_PCI; |
390 | bridge->vendor = PCI_VENDOR_ID_MARVELL; | 384 | bridge->vendor = PCI_VENDOR_ID_MARVELL; |
391 | bridge->device = MARVELL_EMULATED_PCI_PCI_BRIDGE_ID; | 385 | bridge->device = mvebu_readl(port, PCIE_DEV_ID_OFF) >> 16; |
386 | bridge->revision = mvebu_readl(port, PCIE_DEV_REV_OFF) & 0xff; | ||
392 | bridge->header_type = PCI_HEADER_TYPE_BRIDGE; | 387 | bridge->header_type = PCI_HEADER_TYPE_BRIDGE; |
393 | bridge->cache_line_size = 0x10; | 388 | bridge->cache_line_size = 0x10; |
394 | 389 | ||
@@ -679,10 +674,30 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys) | |||
679 | { | 674 | { |
680 | struct mvebu_pcie *pcie = sys_to_pcie(sys); | 675 | struct mvebu_pcie *pcie = sys_to_pcie(sys); |
681 | int i; | 676 | int i; |
677 | int domain = 0; | ||
678 | |||
679 | #ifdef CONFIG_PCI_DOMAINS | ||
680 | domain = sys->domain; | ||
681 | #endif | ||
682 | |||
683 | snprintf(pcie->mem_name, sizeof(pcie->mem_name), "PCI MEM %04x", | ||
684 | domain); | ||
685 | pcie->mem.name = pcie->mem_name; | ||
682 | 686 | ||
683 | if (resource_size(&pcie->realio) != 0) | 687 | snprintf(pcie->io_name, sizeof(pcie->io_name), "PCI I/O %04x", domain); |
688 | pcie->realio.name = pcie->io_name; | ||
689 | |||
690 | if (request_resource(&iomem_resource, &pcie->mem)) | ||
691 | return 0; | ||
692 | |||
693 | if (resource_size(&pcie->realio) != 0) { | ||
694 | if (request_resource(&ioport_resource, &pcie->realio)) { | ||
695 | release_resource(&pcie->mem); | ||
696 | return 0; | ||
697 | } | ||
684 | pci_add_resource_offset(&sys->resources, &pcie->realio, | 698 | pci_add_resource_offset(&sys->resources, &pcie->realio, |
685 | sys->io_offset); | 699 | sys->io_offset); |
700 | } | ||
686 | pci_add_resource_offset(&sys->resources, &pcie->mem, sys->mem_offset); | 701 | pci_add_resource_offset(&sys->resources, &pcie->mem, sys->mem_offset); |
687 | pci_add_resource(&sys->resources, &pcie->busn); | 702 | pci_add_resource(&sys->resources, &pcie->busn); |
688 | 703 | ||
@@ -804,7 +819,7 @@ static int mvebu_get_tgt_attr(struct device_node *np, int devfn, | |||
804 | 819 | ||
805 | for (i = 0; i < nranges; i++) { | 820 | for (i = 0; i < nranges; i++) { |
806 | u32 flags = of_read_number(range, 1); | 821 | u32 flags = of_read_number(range, 1); |
807 | u32 slot = of_read_number(range, 2); | 822 | u32 slot = of_read_number(range + 1, 1); |
808 | u64 cpuaddr = of_read_number(range + na, pna); | 823 | u64 cpuaddr = of_read_number(range + na, pna); |
809 | unsigned long rtype; | 824 | unsigned long rtype; |
810 | 825 | ||
diff --git a/drivers/pci/host/pci-rcar-gen2.c b/drivers/pci/host/pci-rcar-gen2.c index ceec147baec3..fd3e3ab56509 100644 --- a/drivers/pci/host/pci-rcar-gen2.c +++ b/drivers/pci/host/pci-rcar-gen2.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/pm_runtime.h> | 20 | #include <linux/pm_runtime.h> |
21 | #include <linux/sizes.h> | ||
21 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
22 | 23 | ||
23 | /* AHB-PCI Bridge PCI communication registers */ | 24 | /* AHB-PCI Bridge PCI communication registers */ |
@@ -39,9 +40,26 @@ | |||
39 | 40 | ||
40 | #define RCAR_PCI_INT_ENABLE_REG (RCAR_AHBPCI_PCICOM_OFFSET + 0x20) | 41 | #define RCAR_PCI_INT_ENABLE_REG (RCAR_AHBPCI_PCICOM_OFFSET + 0x20) |
41 | #define RCAR_PCI_INT_STATUS_REG (RCAR_AHBPCI_PCICOM_OFFSET + 0x24) | 42 | #define RCAR_PCI_INT_STATUS_REG (RCAR_AHBPCI_PCICOM_OFFSET + 0x24) |
43 | #define RCAR_PCI_INT_SIGTABORT (1 << 0) | ||
44 | #define RCAR_PCI_INT_SIGRETABORT (1 << 1) | ||
45 | #define RCAR_PCI_INT_REMABORT (1 << 2) | ||
46 | #define RCAR_PCI_INT_PERR (1 << 3) | ||
47 | #define RCAR_PCI_INT_SIGSERR (1 << 4) | ||
48 | #define RCAR_PCI_INT_RESERR (1 << 5) | ||
49 | #define RCAR_PCI_INT_WIN1ERR (1 << 12) | ||
50 | #define RCAR_PCI_INT_WIN2ERR (1 << 13) | ||
42 | #define RCAR_PCI_INT_A (1 << 16) | 51 | #define RCAR_PCI_INT_A (1 << 16) |
43 | #define RCAR_PCI_INT_B (1 << 17) | 52 | #define RCAR_PCI_INT_B (1 << 17) |
44 | #define RCAR_PCI_INT_PME (1 << 19) | 53 | #define RCAR_PCI_INT_PME (1 << 19) |
54 | #define RCAR_PCI_INT_ALLERRORS (RCAR_PCI_INT_SIGTABORT | \ | ||
55 | RCAR_PCI_INT_SIGRETABORT | \ | ||
56 | RCAR_PCI_INT_SIGRETABORT | \ | ||
57 | RCAR_PCI_INT_REMABORT | \ | ||
58 | RCAR_PCI_INT_PERR | \ | ||
59 | RCAR_PCI_INT_SIGSERR | \ | ||
60 | RCAR_PCI_INT_RESERR | \ | ||
61 | RCAR_PCI_INT_WIN1ERR | \ | ||
62 | RCAR_PCI_INT_WIN2ERR) | ||
45 | 63 | ||
46 | #define RCAR_AHB_BUS_CTR_REG (RCAR_AHBPCI_PCICOM_OFFSET + 0x30) | 64 | #define RCAR_AHB_BUS_CTR_REG (RCAR_AHBPCI_PCICOM_OFFSET + 0x30) |
47 | #define RCAR_AHB_BUS_MMODE_HTRANS (1 << 0) | 65 | #define RCAR_AHB_BUS_MMODE_HTRANS (1 << 0) |
@@ -74,9 +92,6 @@ | |||
74 | 92 | ||
75 | #define RCAR_PCI_UNIT_REV_REG (RCAR_AHBPCI_PCICOM_OFFSET + 0x48) | 93 | #define RCAR_PCI_UNIT_REV_REG (RCAR_AHBPCI_PCICOM_OFFSET + 0x48) |
76 | 94 | ||
77 | /* Number of internal PCI controllers */ | ||
78 | #define RCAR_PCI_NR_CONTROLLERS 3 | ||
79 | |||
80 | struct rcar_pci_priv { | 95 | struct rcar_pci_priv { |
81 | struct device *dev; | 96 | struct device *dev; |
82 | void __iomem *reg; | 97 | void __iomem *reg; |
@@ -84,6 +99,7 @@ struct rcar_pci_priv { | |||
84 | struct resource mem_res; | 99 | struct resource mem_res; |
85 | struct resource *cfg_res; | 100 | struct resource *cfg_res; |
86 | int irq; | 101 | int irq; |
102 | unsigned long window_size; | ||
87 | }; | 103 | }; |
88 | 104 | ||
89 | /* PCI configuration space operations */ | 105 | /* PCI configuration space operations */ |
@@ -102,6 +118,10 @@ static void __iomem *rcar_pci_cfg_base(struct pci_bus *bus, unsigned int devfn, | |||
102 | if (slot > 2) | 118 | if (slot > 2) |
103 | return NULL; | 119 | return NULL; |
104 | 120 | ||
121 | /* bridge logic only has registers to 0x40 */ | ||
122 | if (slot == 0x0 && where >= 0x40) | ||
123 | return NULL; | ||
124 | |||
105 | val = slot ? RCAR_AHBPCI_WIN1_DEVICE | RCAR_AHBPCI_WIN_CTR_CFG : | 125 | val = slot ? RCAR_AHBPCI_WIN1_DEVICE | RCAR_AHBPCI_WIN_CTR_CFG : |
106 | RCAR_AHBPCI_WIN1_HOST | RCAR_AHBPCI_WIN_CTR_CFG; | 126 | RCAR_AHBPCI_WIN1_HOST | RCAR_AHBPCI_WIN_CTR_CFG; |
107 | 127 | ||
@@ -156,7 +176,7 @@ static int rcar_pci_write_config(struct pci_bus *bus, unsigned int devfn, | |||
156 | } | 176 | } |
157 | 177 | ||
158 | /* PCI interrupt mapping */ | 178 | /* PCI interrupt mapping */ |
159 | static int __init rcar_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | 179 | static int rcar_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
160 | { | 180 | { |
161 | struct pci_sys_data *sys = dev->bus->sysdata; | 181 | struct pci_sys_data *sys = dev->bus->sysdata; |
162 | struct rcar_pci_priv *priv = sys->private_data; | 182 | struct rcar_pci_priv *priv = sys->private_data; |
@@ -164,8 +184,48 @@ static int __init rcar_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | |||
164 | return priv->irq; | 184 | return priv->irq; |
165 | } | 185 | } |
166 | 186 | ||
187 | #ifdef CONFIG_PCI_DEBUG | ||
188 | /* if debug enabled, then attach an error handler irq to the bridge */ | ||
189 | |||
190 | static irqreturn_t rcar_pci_err_irq(int irq, void *pw) | ||
191 | { | ||
192 | struct rcar_pci_priv *priv = pw; | ||
193 | u32 status = ioread32(priv->reg + RCAR_PCI_INT_STATUS_REG); | ||
194 | |||
195 | if (status & RCAR_PCI_INT_ALLERRORS) { | ||
196 | dev_err(priv->dev, "error irq: status %08x\n", status); | ||
197 | |||
198 | /* clear the error(s) */ | ||
199 | iowrite32(status & RCAR_PCI_INT_ALLERRORS, | ||
200 | priv->reg + RCAR_PCI_INT_STATUS_REG); | ||
201 | return IRQ_HANDLED; | ||
202 | } | ||
203 | |||
204 | return IRQ_NONE; | ||
205 | } | ||
206 | |||
207 | static void rcar_pci_setup_errirq(struct rcar_pci_priv *priv) | ||
208 | { | ||
209 | int ret; | ||
210 | u32 val; | ||
211 | |||
212 | ret = devm_request_irq(priv->dev, priv->irq, rcar_pci_err_irq, | ||
213 | IRQF_SHARED, "error irq", priv); | ||
214 | if (ret) { | ||
215 | dev_err(priv->dev, "cannot claim IRQ for error handling\n"); | ||
216 | return; | ||
217 | } | ||
218 | |||
219 | val = ioread32(priv->reg + RCAR_PCI_INT_ENABLE_REG); | ||
220 | val |= RCAR_PCI_INT_ALLERRORS; | ||
221 | iowrite32(val, priv->reg + RCAR_PCI_INT_ENABLE_REG); | ||
222 | } | ||
223 | #else | ||
224 | static inline void rcar_pci_setup_errirq(struct rcar_pci_priv *priv) { } | ||
225 | #endif | ||
226 | |||
167 | /* PCI host controller setup */ | 227 | /* PCI host controller setup */ |
168 | static int __init rcar_pci_setup(int nr, struct pci_sys_data *sys) | 228 | static int rcar_pci_setup(int nr, struct pci_sys_data *sys) |
169 | { | 229 | { |
170 | struct rcar_pci_priv *priv = sys->private_data; | 230 | struct rcar_pci_priv *priv = sys->private_data; |
171 | void __iomem *reg = priv->reg; | 231 | void __iomem *reg = priv->reg; |
@@ -183,10 +243,31 @@ static int __init rcar_pci_setup(int nr, struct pci_sys_data *sys) | |||
183 | iowrite32(val, reg + RCAR_USBCTR_REG); | 243 | iowrite32(val, reg + RCAR_USBCTR_REG); |
184 | udelay(4); | 244 | udelay(4); |
185 | 245 | ||
186 | /* De-assert reset and set PCIAHB window1 size to 1GB */ | 246 | /* De-assert reset and reset PCIAHB window1 size */ |
187 | val &= ~(RCAR_USBCTR_PCIAHB_WIN1_MASK | RCAR_USBCTR_PCICLK_MASK | | 247 | val &= ~(RCAR_USBCTR_PCIAHB_WIN1_MASK | RCAR_USBCTR_PCICLK_MASK | |
188 | RCAR_USBCTR_USBH_RST | RCAR_USBCTR_PLL_RST); | 248 | RCAR_USBCTR_USBH_RST | RCAR_USBCTR_PLL_RST); |
189 | iowrite32(val | RCAR_USBCTR_PCIAHB_WIN1_1G, reg + RCAR_USBCTR_REG); | 249 | |
250 | /* Setup PCIAHB window1 size */ | ||
251 | switch (priv->window_size) { | ||
252 | case SZ_2G: | ||
253 | val |= RCAR_USBCTR_PCIAHB_WIN1_2G; | ||
254 | break; | ||
255 | case SZ_1G: | ||
256 | val |= RCAR_USBCTR_PCIAHB_WIN1_1G; | ||
257 | break; | ||
258 | case SZ_512M: | ||
259 | val |= RCAR_USBCTR_PCIAHB_WIN1_512M; | ||
260 | break; | ||
261 | default: | ||
262 | pr_warn("unknown window size %ld - defaulting to 256M\n", | ||
263 | priv->window_size); | ||
264 | priv->window_size = SZ_256M; | ||
265 | /* fall-through */ | ||
266 | case SZ_256M: | ||
267 | val |= RCAR_USBCTR_PCIAHB_WIN1_256M; | ||
268 | break; | ||
269 | } | ||
270 | iowrite32(val, reg + RCAR_USBCTR_REG); | ||
190 | 271 | ||
191 | /* Configure AHB master and slave modes */ | 272 | /* Configure AHB master and slave modes */ |
192 | iowrite32(RCAR_AHB_BUS_MODE, reg + RCAR_AHB_BUS_CTR_REG); | 273 | iowrite32(RCAR_AHB_BUS_MODE, reg + RCAR_AHB_BUS_CTR_REG); |
@@ -197,7 +278,7 @@ static int __init rcar_pci_setup(int nr, struct pci_sys_data *sys) | |||
197 | RCAR_PCI_ARBITER_PCIBP_MODE; | 278 | RCAR_PCI_ARBITER_PCIBP_MODE; |
198 | iowrite32(val, reg + RCAR_PCI_ARBITER_CTR_REG); | 279 | iowrite32(val, reg + RCAR_PCI_ARBITER_CTR_REG); |
199 | 280 | ||
200 | /* PCI-AHB mapping: 0x40000000-0x80000000 */ | 281 | /* PCI-AHB mapping: 0x40000000 base */ |
201 | iowrite32(0x40000000 | RCAR_PCIAHB_PREFETCH16, | 282 | iowrite32(0x40000000 | RCAR_PCIAHB_PREFETCH16, |
202 | reg + RCAR_PCIAHB_WIN1_CTR_REG); | 283 | reg + RCAR_PCIAHB_WIN1_CTR_REG); |
203 | 284 | ||
@@ -224,10 +305,15 @@ static int __init rcar_pci_setup(int nr, struct pci_sys_data *sys) | |||
224 | iowrite32(RCAR_PCI_INT_A | RCAR_PCI_INT_B | RCAR_PCI_INT_PME, | 305 | iowrite32(RCAR_PCI_INT_A | RCAR_PCI_INT_B | RCAR_PCI_INT_PME, |
225 | reg + RCAR_PCI_INT_ENABLE_REG); | 306 | reg + RCAR_PCI_INT_ENABLE_REG); |
226 | 307 | ||
308 | if (priv->irq > 0) | ||
309 | rcar_pci_setup_errirq(priv); | ||
310 | |||
227 | /* Add PCI resources */ | 311 | /* Add PCI resources */ |
228 | pci_add_resource(&sys->resources, &priv->io_res); | 312 | pci_add_resource(&sys->resources, &priv->io_res); |
229 | pci_add_resource(&sys->resources, &priv->mem_res); | 313 | pci_add_resource(&sys->resources, &priv->mem_res); |
230 | 314 | ||
315 | /* Setup bus number based on platform device id */ | ||
316 | sys->busnr = to_platform_device(priv->dev)->id; | ||
231 | return 1; | 317 | return 1; |
232 | } | 318 | } |
233 | 319 | ||
@@ -236,48 +322,13 @@ static struct pci_ops rcar_pci_ops = { | |||
236 | .write = rcar_pci_write_config, | 322 | .write = rcar_pci_write_config, |
237 | }; | 323 | }; |
238 | 324 | ||
239 | static struct hw_pci rcar_hw_pci __initdata = { | 325 | static int rcar_pci_probe(struct platform_device *pdev) |
240 | .map_irq = rcar_pci_map_irq, | ||
241 | .ops = &rcar_pci_ops, | ||
242 | .setup = rcar_pci_setup, | ||
243 | }; | ||
244 | |||
245 | static int rcar_pci_count __initdata; | ||
246 | |||
247 | static int __init rcar_pci_add_controller(struct rcar_pci_priv *priv) | ||
248 | { | ||
249 | void **private_data; | ||
250 | int count; | ||
251 | |||
252 | if (rcar_hw_pci.nr_controllers < rcar_pci_count) | ||
253 | goto add_priv; | ||
254 | |||
255 | /* (Re)allocate private data pointer array if needed */ | ||
256 | count = rcar_pci_count + RCAR_PCI_NR_CONTROLLERS; | ||
257 | private_data = kzalloc(count * sizeof(void *), GFP_KERNEL); | ||
258 | if (!private_data) | ||
259 | return -ENOMEM; | ||
260 | |||
261 | rcar_pci_count = count; | ||
262 | if (rcar_hw_pci.private_data) { | ||
263 | memcpy(private_data, rcar_hw_pci.private_data, | ||
264 | rcar_hw_pci.nr_controllers * sizeof(void *)); | ||
265 | kfree(rcar_hw_pci.private_data); | ||
266 | } | ||
267 | |||
268 | rcar_hw_pci.private_data = private_data; | ||
269 | |||
270 | add_priv: | ||
271 | /* Add private data pointer to the array */ | ||
272 | rcar_hw_pci.private_data[rcar_hw_pci.nr_controllers++] = priv; | ||
273 | return 0; | ||
274 | } | ||
275 | |||
276 | static int __init rcar_pci_probe(struct platform_device *pdev) | ||
277 | { | 326 | { |
278 | struct resource *cfg_res, *mem_res; | 327 | struct resource *cfg_res, *mem_res; |
279 | struct rcar_pci_priv *priv; | 328 | struct rcar_pci_priv *priv; |
280 | void __iomem *reg; | 329 | void __iomem *reg; |
330 | struct hw_pci hw; | ||
331 | void *hw_private[1]; | ||
281 | 332 | ||
282 | cfg_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 333 | cfg_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
283 | reg = devm_ioremap_resource(&pdev->dev, cfg_res); | 334 | reg = devm_ioremap_resource(&pdev->dev, cfg_res); |
@@ -308,31 +359,34 @@ static int __init rcar_pci_probe(struct platform_device *pdev) | |||
308 | priv->reg = reg; | 359 | priv->reg = reg; |
309 | priv->dev = &pdev->dev; | 360 | priv->dev = &pdev->dev; |
310 | 361 | ||
311 | return rcar_pci_add_controller(priv); | 362 | if (priv->irq < 0) { |
363 | dev_err(&pdev->dev, "no valid irq found\n"); | ||
364 | return priv->irq; | ||
365 | } | ||
366 | |||
367 | priv->window_size = SZ_1G; | ||
368 | |||
369 | hw_private[0] = priv; | ||
370 | memset(&hw, 0, sizeof(hw)); | ||
371 | hw.nr_controllers = ARRAY_SIZE(hw_private); | ||
372 | hw.private_data = hw_private; | ||
373 | hw.map_irq = rcar_pci_map_irq; | ||
374 | hw.ops = &rcar_pci_ops; | ||
375 | hw.setup = rcar_pci_setup; | ||
376 | pci_common_init_dev(&pdev->dev, &hw); | ||
377 | return 0; | ||
312 | } | 378 | } |
313 | 379 | ||
314 | static struct platform_driver rcar_pci_driver = { | 380 | static struct platform_driver rcar_pci_driver = { |
315 | .driver = { | 381 | .driver = { |
316 | .name = "pci-rcar-gen2", | 382 | .name = "pci-rcar-gen2", |
383 | .owner = THIS_MODULE, | ||
384 | .suppress_bind_attrs = true, | ||
317 | }, | 385 | }, |
386 | .probe = rcar_pci_probe, | ||
318 | }; | 387 | }; |
319 | 388 | ||
320 | static int __init rcar_pci_init(void) | 389 | module_platform_driver(rcar_pci_driver); |
321 | { | ||
322 | int retval; | ||
323 | |||
324 | retval = platform_driver_probe(&rcar_pci_driver, rcar_pci_probe); | ||
325 | if (!retval) | ||
326 | pci_common_init(&rcar_hw_pci); | ||
327 | |||
328 | /* Private data pointer array is not needed any more */ | ||
329 | kfree(rcar_hw_pci.private_data); | ||
330 | rcar_hw_pci.private_data = NULL; | ||
331 | |||
332 | return retval; | ||
333 | } | ||
334 | |||
335 | subsys_initcall(rcar_pci_init); | ||
336 | 390 | ||
337 | MODULE_LICENSE("GPL v2"); | 391 | MODULE_LICENSE("GPL v2"); |
338 | MODULE_DESCRIPTION("Renesas R-Car Gen2 internal PCI"); | 392 | MODULE_DESCRIPTION("Renesas R-Car Gen2 internal PCI"); |
diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c index 17ce88f79d2b..6d23d8c893cd 100644 --- a/drivers/pci/host/pcie-designware.c +++ b/drivers/pci/host/pcie-designware.c | |||
@@ -800,7 +800,7 @@ void dw_pcie_setup_rc(struct pcie_port *pp) | |||
800 | 800 | ||
801 | /* setup RC BARs */ | 801 | /* setup RC BARs */ |
802 | dw_pcie_writel_rc(pp, 0x00000004, PCI_BASE_ADDRESS_0); | 802 | dw_pcie_writel_rc(pp, 0x00000004, PCI_BASE_ADDRESS_0); |
803 | dw_pcie_writel_rc(pp, 0x00000004, PCI_BASE_ADDRESS_1); | 803 | dw_pcie_writel_rc(pp, 0x00000000, PCI_BASE_ADDRESS_1); |
804 | 804 | ||
805 | /* setup interrupt pins */ | 805 | /* setup interrupt pins */ |
806 | dw_pcie_readl_rc(pp, PCI_INTERRUPT_LINE, &val); | 806 | dw_pcie_readl_rc(pp, PCI_INTERRUPT_LINE, &val); |
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index cd929aed3613..aee6a0acbbe9 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -450,7 +450,7 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge) | |||
450 | */ | 450 | */ |
451 | static unsigned char acpiphp_max_busnr(struct pci_bus *bus) | 451 | static unsigned char acpiphp_max_busnr(struct pci_bus *bus) |
452 | { | 452 | { |
453 | struct list_head *tmp; | 453 | struct pci_bus *tmp; |
454 | unsigned char max, n; | 454 | unsigned char max, n; |
455 | 455 | ||
456 | /* | 456 | /* |
@@ -463,8 +463,8 @@ static unsigned char acpiphp_max_busnr(struct pci_bus *bus) | |||
463 | */ | 463 | */ |
464 | max = bus->busn_res.start; | 464 | max = bus->busn_res.start; |
465 | 465 | ||
466 | list_for_each(tmp, &bus->children) { | 466 | list_for_each_entry(tmp, &bus->children, node) { |
467 | n = pci_bus_max_busnr(pci_bus_b(tmp)); | 467 | n = pci_bus_max_busnr(tmp); |
468 | if (n > max) | 468 | if (n > max) |
469 | max = n; | 469 | max = n; |
470 | } | 470 | } |
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index 31273e155e6c..037e2612c5bd 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c | |||
@@ -920,12 +920,12 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
920 | bus->max_bus_speed = PCI_SPEED_100MHz_PCIX; | 920 | bus->max_bus_speed = PCI_SPEED_100MHz_PCIX; |
921 | break; | 921 | break; |
922 | } | 922 | } |
923 | if (bus_cap & 20) { | 923 | if (bus_cap & 0x20) { |
924 | dbg("bus max supports 66MHz PCI-X\n"); | 924 | dbg("bus max supports 66MHz PCI-X\n"); |
925 | bus->max_bus_speed = PCI_SPEED_66MHz_PCIX; | 925 | bus->max_bus_speed = PCI_SPEED_66MHz_PCIX; |
926 | break; | 926 | break; |
927 | } | 927 | } |
928 | if (bus_cap & 10) { | 928 | if (bus_cap & 0x10) { |
929 | dbg("bus max supports 66MHz PCI\n"); | 929 | dbg("bus max supports 66MHz PCI\n"); |
930 | bus->max_bus_speed = PCI_SPEED_66MHz; | 930 | bus->max_bus_speed = PCI_SPEED_66MHz; |
931 | break; | 931 | break; |
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 88b37cad4b35..8a66866b8cf1 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h | |||
@@ -76,6 +76,7 @@ struct slot { | |||
76 | struct hotplug_slot *hotplug_slot; | 76 | struct hotplug_slot *hotplug_slot; |
77 | struct delayed_work work; /* work for button event */ | 77 | struct delayed_work work; /* work for button event */ |
78 | struct mutex lock; | 78 | struct mutex lock; |
79 | struct mutex hotplug_lock; | ||
79 | struct workqueue_struct *wq; | 80 | struct workqueue_struct *wq; |
80 | }; | 81 | }; |
81 | 82 | ||
@@ -109,6 +110,8 @@ struct controller { | |||
109 | #define INT_BUTTON_PRESS 7 | 110 | #define INT_BUTTON_PRESS 7 |
110 | #define INT_BUTTON_RELEASE 8 | 111 | #define INT_BUTTON_RELEASE 8 |
111 | #define INT_BUTTON_CANCEL 9 | 112 | #define INT_BUTTON_CANCEL 9 |
113 | #define INT_LINK_UP 10 | ||
114 | #define INT_LINK_DOWN 11 | ||
112 | 115 | ||
113 | #define STATIC_STATE 0 | 116 | #define STATIC_STATE 0 |
114 | #define BLINKINGON_STATE 1 | 117 | #define BLINKINGON_STATE 1 |
@@ -132,6 +135,7 @@ u8 pciehp_handle_attention_button(struct slot *p_slot); | |||
132 | u8 pciehp_handle_switch_change(struct slot *p_slot); | 135 | u8 pciehp_handle_switch_change(struct slot *p_slot); |
133 | u8 pciehp_handle_presence_change(struct slot *p_slot); | 136 | u8 pciehp_handle_presence_change(struct slot *p_slot); |
134 | u8 pciehp_handle_power_fault(struct slot *p_slot); | 137 | u8 pciehp_handle_power_fault(struct slot *p_slot); |
138 | void pciehp_handle_linkstate_change(struct slot *p_slot); | ||
135 | int pciehp_configure_device(struct slot *p_slot); | 139 | int pciehp_configure_device(struct slot *p_slot); |
136 | int pciehp_unconfigure_device(struct slot *p_slot); | 140 | int pciehp_unconfigure_device(struct slot *p_slot); |
137 | void pciehp_queue_pushbutton_work(struct work_struct *work); | 141 | void pciehp_queue_pushbutton_work(struct work_struct *work); |
@@ -153,6 +157,7 @@ void pciehp_green_led_on(struct slot *slot); | |||
153 | void pciehp_green_led_off(struct slot *slot); | 157 | void pciehp_green_led_off(struct slot *slot); |
154 | void pciehp_green_led_blink(struct slot *slot); | 158 | void pciehp_green_led_blink(struct slot *slot); |
155 | int pciehp_check_link_status(struct controller *ctrl); | 159 | int pciehp_check_link_status(struct controller *ctrl); |
160 | bool pciehp_check_link_active(struct controller *ctrl); | ||
156 | void pciehp_release_ctrl(struct controller *ctrl); | 161 | void pciehp_release_ctrl(struct controller *ctrl); |
157 | int pciehp_reset_slot(struct slot *slot, int probe); | 162 | int pciehp_reset_slot(struct slot *slot, int probe); |
158 | 163 | ||
diff --git a/drivers/pci/hotplug/pciehp_acpi.c b/drivers/pci/hotplug/pciehp_acpi.c index eddddd447d0d..20fea57d2149 100644 --- a/drivers/pci/hotplug/pciehp_acpi.c +++ b/drivers/pci/hotplug/pciehp_acpi.c | |||
@@ -112,6 +112,7 @@ static struct pcie_port_service_driver __initdata dummy_driver = { | |||
112 | static int __init select_detection_mode(void) | 112 | static int __init select_detection_mode(void) |
113 | { | 113 | { |
114 | struct dummy_slot *slot, *tmp; | 114 | struct dummy_slot *slot, *tmp; |
115 | |||
115 | if (pcie_port_service_register(&dummy_driver)) | 116 | if (pcie_port_service_register(&dummy_driver)) |
116 | return PCIEHP_DETECT_ACPI; | 117 | return PCIEHP_DETECT_ACPI; |
117 | pcie_port_service_unregister(&dummy_driver); | 118 | pcie_port_service_unregister(&dummy_driver); |
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 53b58debc288..0e0a2fff20a3 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c | |||
@@ -108,6 +108,7 @@ static int init_slot(struct controller *ctrl) | |||
108 | ops = kzalloc(sizeof(*ops), GFP_KERNEL); | 108 | ops = kzalloc(sizeof(*ops), GFP_KERNEL); |
109 | if (!ops) | 109 | if (!ops) |
110 | goto out; | 110 | goto out; |
111 | |||
111 | ops->enable_slot = enable_slot; | 112 | ops->enable_slot = enable_slot; |
112 | ops->disable_slot = disable_slot; | 113 | ops->disable_slot = disable_slot; |
113 | ops->get_power_status = get_power_status; | 114 | ops->get_power_status = get_power_status; |
@@ -283,8 +284,11 @@ static int pciehp_probe(struct pcie_device *dev) | |||
283 | slot = ctrl->slot; | 284 | slot = ctrl->slot; |
284 | pciehp_get_adapter_status(slot, &occupied); | 285 | pciehp_get_adapter_status(slot, &occupied); |
285 | pciehp_get_power_status(slot, &poweron); | 286 | pciehp_get_power_status(slot, &poweron); |
286 | if (occupied && pciehp_force) | 287 | if (occupied && pciehp_force) { |
288 | mutex_lock(&slot->hotplug_lock); | ||
287 | pciehp_enable_slot(slot); | 289 | pciehp_enable_slot(slot); |
290 | mutex_unlock(&slot->hotplug_lock); | ||
291 | } | ||
288 | /* If empty slot's power status is on, turn power off */ | 292 | /* If empty slot's power status is on, turn power off */ |
289 | if (!occupied && poweron && POWER_CTRL(ctrl)) | 293 | if (!occupied && poweron && POWER_CTRL(ctrl)) |
290 | pciehp_power_off_slot(slot); | 294 | pciehp_power_off_slot(slot); |
@@ -328,10 +332,12 @@ static int pciehp_resume (struct pcie_device *dev) | |||
328 | 332 | ||
329 | /* Check if slot is occupied */ | 333 | /* Check if slot is occupied */ |
330 | pciehp_get_adapter_status(slot, &status); | 334 | pciehp_get_adapter_status(slot, &status); |
335 | mutex_lock(&slot->hotplug_lock); | ||
331 | if (status) | 336 | if (status) |
332 | pciehp_enable_slot(slot); | 337 | pciehp_enable_slot(slot); |
333 | else | 338 | else |
334 | pciehp_disable_slot(slot); | 339 | pciehp_disable_slot(slot); |
340 | mutex_unlock(&slot->hotplug_lock); | ||
335 | return 0; | 341 | return 0; |
336 | } | 342 | } |
337 | #endif /* PM */ | 343 | #endif /* PM */ |
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 50628487597d..c75e6a678dcc 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c | |||
@@ -150,6 +150,27 @@ u8 pciehp_handle_power_fault(struct slot *p_slot) | |||
150 | return 1; | 150 | return 1; |
151 | } | 151 | } |
152 | 152 | ||
153 | void pciehp_handle_linkstate_change(struct slot *p_slot) | ||
154 | { | ||
155 | u32 event_type; | ||
156 | struct controller *ctrl = p_slot->ctrl; | ||
157 | |||
158 | /* Link Status Change */ | ||
159 | ctrl_dbg(ctrl, "Data Link Layer State change\n"); | ||
160 | |||
161 | if (pciehp_check_link_active(ctrl)) { | ||
162 | ctrl_info(ctrl, "slot(%s): Link Up event\n", | ||
163 | slot_name(p_slot)); | ||
164 | event_type = INT_LINK_UP; | ||
165 | } else { | ||
166 | ctrl_info(ctrl, "slot(%s): Link Down event\n", | ||
167 | slot_name(p_slot)); | ||
168 | event_type = INT_LINK_DOWN; | ||
169 | } | ||
170 | |||
171 | queue_interrupt_event(p_slot, event_type); | ||
172 | } | ||
173 | |||
153 | /* The following routines constitute the bulk of the | 174 | /* The following routines constitute the bulk of the |
154 | hotplug controller logic | 175 | hotplug controller logic |
155 | */ | 176 | */ |
@@ -212,7 +233,8 @@ static int board_added(struct slot *p_slot) | |||
212 | if (retval) { | 233 | if (retval) { |
213 | ctrl_err(ctrl, "Cannot add device at %04x:%02x:00\n", | 234 | ctrl_err(ctrl, "Cannot add device at %04x:%02x:00\n", |
214 | pci_domain_nr(parent), parent->number); | 235 | pci_domain_nr(parent), parent->number); |
215 | goto err_exit; | 236 | if (retval != -EEXIST) |
237 | goto err_exit; | ||
216 | } | 238 | } |
217 | 239 | ||
218 | pciehp_green_led_on(p_slot); | 240 | pciehp_green_led_on(p_slot); |
@@ -255,6 +277,9 @@ static int remove_board(struct slot *p_slot) | |||
255 | struct power_work_info { | 277 | struct power_work_info { |
256 | struct slot *p_slot; | 278 | struct slot *p_slot; |
257 | struct work_struct work; | 279 | struct work_struct work; |
280 | unsigned int req; | ||
281 | #define DISABLE_REQ 0 | ||
282 | #define ENABLE_REQ 1 | ||
258 | }; | 283 | }; |
259 | 284 | ||
260 | /** | 285 | /** |
@@ -269,30 +294,38 @@ static void pciehp_power_thread(struct work_struct *work) | |||
269 | struct power_work_info *info = | 294 | struct power_work_info *info = |
270 | container_of(work, struct power_work_info, work); | 295 | container_of(work, struct power_work_info, work); |
271 | struct slot *p_slot = info->p_slot; | 296 | struct slot *p_slot = info->p_slot; |
297 | int ret; | ||
272 | 298 | ||
273 | mutex_lock(&p_slot->lock); | 299 | switch (info->req) { |
274 | switch (p_slot->state) { | 300 | case DISABLE_REQ: |
275 | case POWEROFF_STATE: | ||
276 | mutex_unlock(&p_slot->lock); | ||
277 | ctrl_dbg(p_slot->ctrl, | 301 | ctrl_dbg(p_slot->ctrl, |
278 | "Disabling domain:bus:device=%04x:%02x:00\n", | 302 | "Disabling domain:bus:device=%04x:%02x:00\n", |
279 | pci_domain_nr(p_slot->ctrl->pcie->port->subordinate), | 303 | pci_domain_nr(p_slot->ctrl->pcie->port->subordinate), |
280 | p_slot->ctrl->pcie->port->subordinate->number); | 304 | p_slot->ctrl->pcie->port->subordinate->number); |
305 | mutex_lock(&p_slot->hotplug_lock); | ||
281 | pciehp_disable_slot(p_slot); | 306 | pciehp_disable_slot(p_slot); |
307 | mutex_unlock(&p_slot->hotplug_lock); | ||
282 | mutex_lock(&p_slot->lock); | 308 | mutex_lock(&p_slot->lock); |
283 | p_slot->state = STATIC_STATE; | 309 | p_slot->state = STATIC_STATE; |
284 | break; | ||
285 | case POWERON_STATE: | ||
286 | mutex_unlock(&p_slot->lock); | 310 | mutex_unlock(&p_slot->lock); |
287 | if (pciehp_enable_slot(p_slot)) | 311 | break; |
312 | case ENABLE_REQ: | ||
313 | ctrl_dbg(p_slot->ctrl, | ||
314 | "Enabling domain:bus:device=%04x:%02x:00\n", | ||
315 | pci_domain_nr(p_slot->ctrl->pcie->port->subordinate), | ||
316 | p_slot->ctrl->pcie->port->subordinate->number); | ||
317 | mutex_lock(&p_slot->hotplug_lock); | ||
318 | ret = pciehp_enable_slot(p_slot); | ||
319 | mutex_unlock(&p_slot->hotplug_lock); | ||
320 | if (ret) | ||
288 | pciehp_green_led_off(p_slot); | 321 | pciehp_green_led_off(p_slot); |
289 | mutex_lock(&p_slot->lock); | 322 | mutex_lock(&p_slot->lock); |
290 | p_slot->state = STATIC_STATE; | 323 | p_slot->state = STATIC_STATE; |
324 | mutex_unlock(&p_slot->lock); | ||
291 | break; | 325 | break; |
292 | default: | 326 | default: |
293 | break; | 327 | break; |
294 | } | 328 | } |
295 | mutex_unlock(&p_slot->lock); | ||
296 | 329 | ||
297 | kfree(info); | 330 | kfree(info); |
298 | } | 331 | } |
@@ -315,9 +348,11 @@ void pciehp_queue_pushbutton_work(struct work_struct *work) | |||
315 | switch (p_slot->state) { | 348 | switch (p_slot->state) { |
316 | case BLINKINGOFF_STATE: | 349 | case BLINKINGOFF_STATE: |
317 | p_slot->state = POWEROFF_STATE; | 350 | p_slot->state = POWEROFF_STATE; |
351 | info->req = DISABLE_REQ; | ||
318 | break; | 352 | break; |
319 | case BLINKINGON_STATE: | 353 | case BLINKINGON_STATE: |
320 | p_slot->state = POWERON_STATE; | 354 | p_slot->state = POWERON_STATE; |
355 | info->req = ENABLE_REQ; | ||
321 | break; | 356 | break; |
322 | default: | 357 | default: |
323 | kfree(info); | 358 | kfree(info); |
@@ -364,11 +399,10 @@ static void handle_button_press_event(struct slot *p_slot) | |||
364 | */ | 399 | */ |
365 | ctrl_info(ctrl, "Button cancel on Slot(%s)\n", slot_name(p_slot)); | 400 | ctrl_info(ctrl, "Button cancel on Slot(%s)\n", slot_name(p_slot)); |
366 | cancel_delayed_work(&p_slot->work); | 401 | cancel_delayed_work(&p_slot->work); |
367 | if (p_slot->state == BLINKINGOFF_STATE) { | 402 | if (p_slot->state == BLINKINGOFF_STATE) |
368 | pciehp_green_led_on(p_slot); | 403 | pciehp_green_led_on(p_slot); |
369 | } else { | 404 | else |
370 | pciehp_green_led_off(p_slot); | 405 | pciehp_green_led_off(p_slot); |
371 | } | ||
372 | pciehp_set_attention_status(p_slot, 0); | 406 | pciehp_set_attention_status(p_slot, 0); |
373 | ctrl_info(ctrl, "PCI slot #%s - action canceled " | 407 | ctrl_info(ctrl, "PCI slot #%s - action canceled " |
374 | "due to button press\n", slot_name(p_slot)); | 408 | "due to button press\n", slot_name(p_slot)); |
@@ -407,14 +441,81 @@ static void handle_surprise_event(struct slot *p_slot) | |||
407 | INIT_WORK(&info->work, pciehp_power_thread); | 441 | INIT_WORK(&info->work, pciehp_power_thread); |
408 | 442 | ||
409 | pciehp_get_adapter_status(p_slot, &getstatus); | 443 | pciehp_get_adapter_status(p_slot, &getstatus); |
410 | if (!getstatus) | 444 | if (!getstatus) { |
411 | p_slot->state = POWEROFF_STATE; | 445 | p_slot->state = POWEROFF_STATE; |
412 | else | 446 | info->req = DISABLE_REQ; |
447 | } else { | ||
413 | p_slot->state = POWERON_STATE; | 448 | p_slot->state = POWERON_STATE; |
449 | info->req = ENABLE_REQ; | ||
450 | } | ||
414 | 451 | ||
415 | queue_work(p_slot->wq, &info->work); | 452 | queue_work(p_slot->wq, &info->work); |
416 | } | 453 | } |
417 | 454 | ||
455 | /* | ||
456 | * Note: This function must be called with slot->lock held | ||
457 | */ | ||
458 | static void handle_link_event(struct slot *p_slot, u32 event) | ||
459 | { | ||
460 | struct controller *ctrl = p_slot->ctrl; | ||
461 | struct power_work_info *info; | ||
462 | |||
463 | info = kmalloc(sizeof(*info), GFP_KERNEL); | ||
464 | if (!info) { | ||
465 | ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n", | ||
466 | __func__); | ||
467 | return; | ||
468 | } | ||
469 | info->p_slot = p_slot; | ||
470 | info->req = event == INT_LINK_UP ? ENABLE_REQ : DISABLE_REQ; | ||
471 | INIT_WORK(&info->work, pciehp_power_thread); | ||
472 | |||
473 | switch (p_slot->state) { | ||
474 | case BLINKINGON_STATE: | ||
475 | case BLINKINGOFF_STATE: | ||
476 | cancel_delayed_work(&p_slot->work); | ||
477 | /* Fall through */ | ||
478 | case STATIC_STATE: | ||
479 | p_slot->state = event == INT_LINK_UP ? | ||
480 | POWERON_STATE : POWEROFF_STATE; | ||
481 | queue_work(p_slot->wq, &info->work); | ||
482 | break; | ||
483 | case POWERON_STATE: | ||
484 | if (event == INT_LINK_UP) { | ||
485 | ctrl_info(ctrl, | ||
486 | "Link Up event ignored on slot(%s): already powering on\n", | ||
487 | slot_name(p_slot)); | ||
488 | kfree(info); | ||
489 | } else { | ||
490 | ctrl_info(ctrl, | ||
491 | "Link Down event queued on slot(%s): currently getting powered on\n", | ||
492 | slot_name(p_slot)); | ||
493 | p_slot->state = POWEROFF_STATE; | ||
494 | queue_work(p_slot->wq, &info->work); | ||
495 | } | ||
496 | break; | ||
497 | case POWEROFF_STATE: | ||
498 | if (event == INT_LINK_UP) { | ||
499 | ctrl_info(ctrl, | ||
500 | "Link Up event queued on slot(%s): currently getting powered off\n", | ||
501 | slot_name(p_slot)); | ||
502 | p_slot->state = POWERON_STATE; | ||
503 | queue_work(p_slot->wq, &info->work); | ||
504 | } else { | ||
505 | ctrl_info(ctrl, | ||
506 | "Link Down event ignored on slot(%s): already powering off\n", | ||
507 | slot_name(p_slot)); | ||
508 | kfree(info); | ||
509 | } | ||
510 | break; | ||
511 | default: | ||
512 | ctrl_err(ctrl, "Not a valid state on slot(%s)\n", | ||
513 | slot_name(p_slot)); | ||
514 | kfree(info); | ||
515 | break; | ||
516 | } | ||
517 | } | ||
518 | |||
418 | static void interrupt_event_handler(struct work_struct *work) | 519 | static void interrupt_event_handler(struct work_struct *work) |
419 | { | 520 | { |
420 | struct event_info *info = container_of(work, struct event_info, work); | 521 | struct event_info *info = container_of(work, struct event_info, work); |
@@ -433,12 +534,23 @@ static void interrupt_event_handler(struct work_struct *work) | |||
433 | pciehp_green_led_off(p_slot); | 534 | pciehp_green_led_off(p_slot); |
434 | break; | 535 | break; |
435 | case INT_PRESENCE_ON: | 536 | case INT_PRESENCE_ON: |
436 | case INT_PRESENCE_OFF: | ||
437 | if (!HP_SUPR_RM(ctrl)) | 537 | if (!HP_SUPR_RM(ctrl)) |
438 | break; | 538 | break; |
539 | ctrl_dbg(ctrl, "Surprise Insertion\n"); | ||
540 | handle_surprise_event(p_slot); | ||
541 | break; | ||
542 | case INT_PRESENCE_OFF: | ||
543 | /* | ||
544 | * Regardless of surprise capability, we need to | ||
545 | * definitely remove a card that has been pulled out! | ||
546 | */ | ||
439 | ctrl_dbg(ctrl, "Surprise Removal\n"); | 547 | ctrl_dbg(ctrl, "Surprise Removal\n"); |
440 | handle_surprise_event(p_slot); | 548 | handle_surprise_event(p_slot); |
441 | break; | 549 | break; |
550 | case INT_LINK_UP: | ||
551 | case INT_LINK_DOWN: | ||
552 | handle_link_event(p_slot, info->event_type); | ||
553 | break; | ||
442 | default: | 554 | default: |
443 | break; | 555 | break; |
444 | } | 556 | } |
@@ -447,6 +559,9 @@ static void interrupt_event_handler(struct work_struct *work) | |||
447 | kfree(info); | 559 | kfree(info); |
448 | } | 560 | } |
449 | 561 | ||
562 | /* | ||
563 | * Note: This function must be called with slot->hotplug_lock held | ||
564 | */ | ||
450 | int pciehp_enable_slot(struct slot *p_slot) | 565 | int pciehp_enable_slot(struct slot *p_slot) |
451 | { | 566 | { |
452 | u8 getstatus = 0; | 567 | u8 getstatus = 0; |
@@ -479,13 +594,15 @@ int pciehp_enable_slot(struct slot *p_slot) | |||
479 | pciehp_get_latch_status(p_slot, &getstatus); | 594 | pciehp_get_latch_status(p_slot, &getstatus); |
480 | 595 | ||
481 | rc = board_added(p_slot); | 596 | rc = board_added(p_slot); |
482 | if (rc) { | 597 | if (rc) |
483 | pciehp_get_latch_status(p_slot, &getstatus); | 598 | pciehp_get_latch_status(p_slot, &getstatus); |
484 | } | 599 | |
485 | return rc; | 600 | return rc; |
486 | } | 601 | } |
487 | 602 | ||
488 | 603 | /* | |
604 | * Note: This function must be called with slot->hotplug_lock held | ||
605 | */ | ||
489 | int pciehp_disable_slot(struct slot *p_slot) | 606 | int pciehp_disable_slot(struct slot *p_slot) |
490 | { | 607 | { |
491 | u8 getstatus = 0; | 608 | u8 getstatus = 0; |
@@ -494,24 +611,6 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
494 | if (!p_slot->ctrl) | 611 | if (!p_slot->ctrl) |
495 | return 1; | 612 | return 1; |
496 | 613 | ||
497 | if (!HP_SUPR_RM(p_slot->ctrl)) { | ||
498 | pciehp_get_adapter_status(p_slot, &getstatus); | ||
499 | if (!getstatus) { | ||
500 | ctrl_info(ctrl, "No adapter on slot(%s)\n", | ||
501 | slot_name(p_slot)); | ||
502 | return -ENODEV; | ||
503 | } | ||
504 | } | ||
505 | |||
506 | if (MRL_SENS(p_slot->ctrl)) { | ||
507 | pciehp_get_latch_status(p_slot, &getstatus); | ||
508 | if (getstatus) { | ||
509 | ctrl_info(ctrl, "Latch open on slot(%s)\n", | ||
510 | slot_name(p_slot)); | ||
511 | return -ENODEV; | ||
512 | } | ||
513 | } | ||
514 | |||
515 | if (POWER_CTRL(p_slot->ctrl)) { | 614 | if (POWER_CTRL(p_slot->ctrl)) { |
516 | pciehp_get_power_status(p_slot, &getstatus); | 615 | pciehp_get_power_status(p_slot, &getstatus); |
517 | if (!getstatus) { | 616 | if (!getstatus) { |
@@ -536,7 +635,9 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot) | |||
536 | case STATIC_STATE: | 635 | case STATIC_STATE: |
537 | p_slot->state = POWERON_STATE; | 636 | p_slot->state = POWERON_STATE; |
538 | mutex_unlock(&p_slot->lock); | 637 | mutex_unlock(&p_slot->lock); |
638 | mutex_lock(&p_slot->hotplug_lock); | ||
539 | retval = pciehp_enable_slot(p_slot); | 639 | retval = pciehp_enable_slot(p_slot); |
640 | mutex_unlock(&p_slot->hotplug_lock); | ||
540 | mutex_lock(&p_slot->lock); | 641 | mutex_lock(&p_slot->lock); |
541 | p_slot->state = STATIC_STATE; | 642 | p_slot->state = STATIC_STATE; |
542 | break; | 643 | break; |
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 14acfccb7670..d7d058fa19a4 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c | |||
@@ -206,7 +206,7 @@ static void pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask) | |||
206 | mutex_unlock(&ctrl->ctrl_lock); | 206 | mutex_unlock(&ctrl->ctrl_lock); |
207 | } | 207 | } |
208 | 208 | ||
209 | static bool check_link_active(struct controller *ctrl) | 209 | bool pciehp_check_link_active(struct controller *ctrl) |
210 | { | 210 | { |
211 | struct pci_dev *pdev = ctrl_dev(ctrl); | 211 | struct pci_dev *pdev = ctrl_dev(ctrl); |
212 | u16 lnk_status; | 212 | u16 lnk_status; |
@@ -225,12 +225,12 @@ static void __pcie_wait_link_active(struct controller *ctrl, bool active) | |||
225 | { | 225 | { |
226 | int timeout = 1000; | 226 | int timeout = 1000; |
227 | 227 | ||
228 | if (check_link_active(ctrl) == active) | 228 | if (pciehp_check_link_active(ctrl) == active) |
229 | return; | 229 | return; |
230 | while (timeout > 0) { | 230 | while (timeout > 0) { |
231 | msleep(10); | 231 | msleep(10); |
232 | timeout -= 10; | 232 | timeout -= 10; |
233 | if (check_link_active(ctrl) == active) | 233 | if (pciehp_check_link_active(ctrl) == active) |
234 | return; | 234 | return; |
235 | } | 235 | } |
236 | ctrl_dbg(ctrl, "Data Link Layer Link Active not %s in 1000 msec\n", | 236 | ctrl_dbg(ctrl, "Data Link Layer Link Active not %s in 1000 msec\n", |
@@ -242,11 +242,6 @@ static void pcie_wait_link_active(struct controller *ctrl) | |||
242 | __pcie_wait_link_active(ctrl, true); | 242 | __pcie_wait_link_active(ctrl, true); |
243 | } | 243 | } |
244 | 244 | ||
245 | static void pcie_wait_link_not_active(struct controller *ctrl) | ||
246 | { | ||
247 | __pcie_wait_link_active(ctrl, false); | ||
248 | } | ||
249 | |||
250 | static bool pci_bus_check_dev(struct pci_bus *bus, int devfn) | 245 | static bool pci_bus_check_dev(struct pci_bus *bus, int devfn) |
251 | { | 246 | { |
252 | u32 l; | 247 | u32 l; |
@@ -332,11 +327,6 @@ static int pciehp_link_enable(struct controller *ctrl) | |||
332 | return __pciehp_link_set(ctrl, true); | 327 | return __pciehp_link_set(ctrl, true); |
333 | } | 328 | } |
334 | 329 | ||
335 | static int pciehp_link_disable(struct controller *ctrl) | ||
336 | { | ||
337 | return __pciehp_link_set(ctrl, false); | ||
338 | } | ||
339 | |||
340 | void pciehp_get_attention_status(struct slot *slot, u8 *status) | 330 | void pciehp_get_attention_status(struct slot *slot, u8 *status) |
341 | { | 331 | { |
342 | struct controller *ctrl = slot->ctrl; | 332 | struct controller *ctrl = slot->ctrl; |
@@ -508,14 +498,6 @@ void pciehp_power_off_slot(struct slot * slot) | |||
508 | { | 498 | { |
509 | struct controller *ctrl = slot->ctrl; | 499 | struct controller *ctrl = slot->ctrl; |
510 | 500 | ||
511 | /* Disable the link at first */ | ||
512 | pciehp_link_disable(ctrl); | ||
513 | /* wait the link is down */ | ||
514 | if (ctrl->link_active_reporting) | ||
515 | pcie_wait_link_not_active(ctrl); | ||
516 | else | ||
517 | msleep(1000); | ||
518 | |||
519 | pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_OFF, PCI_EXP_SLTCTL_PCC); | 501 | pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_OFF, PCI_EXP_SLTCTL_PCC); |
520 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, | 502 | ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, |
521 | pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, | 503 | pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, |
@@ -540,7 +522,7 @@ static irqreturn_t pcie_isr(int irq, void *dev_id) | |||
540 | 522 | ||
541 | detected &= (PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD | | 523 | detected &= (PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD | |
542 | PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_PDC | | 524 | PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_PDC | |
543 | PCI_EXP_SLTSTA_CC); | 525 | PCI_EXP_SLTSTA_CC | PCI_EXP_SLTSTA_DLLSC); |
544 | detected &= ~intr_loc; | 526 | detected &= ~intr_loc; |
545 | intr_loc |= detected; | 527 | intr_loc |= detected; |
546 | if (!intr_loc) | 528 | if (!intr_loc) |
@@ -579,6 +561,10 @@ static irqreturn_t pcie_isr(int irq, void *dev_id) | |||
579 | ctrl->power_fault_detected = 1; | 561 | ctrl->power_fault_detected = 1; |
580 | pciehp_handle_power_fault(slot); | 562 | pciehp_handle_power_fault(slot); |
581 | } | 563 | } |
564 | |||
565 | if (intr_loc & PCI_EXP_SLTSTA_DLLSC) | ||
566 | pciehp_handle_linkstate_change(slot); | ||
567 | |||
582 | return IRQ_HANDLED; | 568 | return IRQ_HANDLED; |
583 | } | 569 | } |
584 | 570 | ||
@@ -596,9 +582,17 @@ void pcie_enable_notification(struct controller *ctrl) | |||
596 | * when it is cleared in the interrupt service routine, and | 582 | * when it is cleared in the interrupt service routine, and |
597 | * next power fault detected interrupt was notified again. | 583 | * next power fault detected interrupt was notified again. |
598 | */ | 584 | */ |
599 | cmd = PCI_EXP_SLTCTL_PDCE; | 585 | |
586 | /* | ||
587 | * Always enable link events: thus link-up and link-down shall | ||
588 | * always be treated as hotplug and unplug respectively. Enable | ||
589 | * presence detect only if Attention Button is not present. | ||
590 | */ | ||
591 | cmd = PCI_EXP_SLTCTL_DLLSCE; | ||
600 | if (ATTN_BUTTN(ctrl)) | 592 | if (ATTN_BUTTN(ctrl)) |
601 | cmd |= PCI_EXP_SLTCTL_ABPE; | 593 | cmd |= PCI_EXP_SLTCTL_ABPE; |
594 | else | ||
595 | cmd |= PCI_EXP_SLTCTL_PDCE; | ||
602 | if (MRL_SENS(ctrl)) | 596 | if (MRL_SENS(ctrl)) |
603 | cmd |= PCI_EXP_SLTCTL_MRLSCE; | 597 | cmd |= PCI_EXP_SLTCTL_MRLSCE; |
604 | if (!pciehp_poll_mode) | 598 | if (!pciehp_poll_mode) |
@@ -606,7 +600,8 @@ void pcie_enable_notification(struct controller *ctrl) | |||
606 | 600 | ||
607 | mask = (PCI_EXP_SLTCTL_PDCE | PCI_EXP_SLTCTL_ABPE | | 601 | mask = (PCI_EXP_SLTCTL_PDCE | PCI_EXP_SLTCTL_ABPE | |
608 | PCI_EXP_SLTCTL_MRLSCE | PCI_EXP_SLTCTL_PFDE | | 602 | PCI_EXP_SLTCTL_MRLSCE | PCI_EXP_SLTCTL_PFDE | |
609 | PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE); | 603 | PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE | |
604 | PCI_EXP_SLTCTL_DLLSCE); | ||
610 | 605 | ||
611 | pcie_write_cmd(ctrl, cmd, mask); | 606 | pcie_write_cmd(ctrl, cmd, mask); |
612 | } | 607 | } |
@@ -624,33 +619,38 @@ static void pcie_disable_notification(struct controller *ctrl) | |||
624 | 619 | ||
625 | /* | 620 | /* |
626 | * pciehp has a 1:1 bus:slot relationship so we ultimately want a secondary | 621 | * pciehp has a 1:1 bus:slot relationship so we ultimately want a secondary |
627 | * bus reset of the bridge, but if the slot supports surprise removal we need | 622 | * bus reset of the bridge, but at the same time we want to ensure that it is |
628 | * to disable presence detection around the bus reset and clear any spurious | 623 | * not seen as a hot-unplug, followed by the hot-plug of the device. Thus, |
624 | * disable link state notification and presence detection change notification | ||
625 | * momentarily, if we see that they could interfere. Also, clear any spurious | ||
629 | * events after. | 626 | * events after. |
630 | */ | 627 | */ |
631 | int pciehp_reset_slot(struct slot *slot, int probe) | 628 | int pciehp_reset_slot(struct slot *slot, int probe) |
632 | { | 629 | { |
633 | struct controller *ctrl = slot->ctrl; | 630 | struct controller *ctrl = slot->ctrl; |
634 | struct pci_dev *pdev = ctrl_dev(ctrl); | 631 | struct pci_dev *pdev = ctrl_dev(ctrl); |
632 | u16 stat_mask = 0, ctrl_mask = 0; | ||
635 | 633 | ||
636 | if (probe) | 634 | if (probe) |
637 | return 0; | 635 | return 0; |
638 | 636 | ||
639 | if (HP_SUPR_RM(ctrl)) { | 637 | if (!ATTN_BUTTN(ctrl)) { |
640 | pcie_write_cmd(ctrl, 0, PCI_EXP_SLTCTL_PDCE); | 638 | ctrl_mask |= PCI_EXP_SLTCTL_PDCE; |
641 | if (pciehp_poll_mode) | 639 | stat_mask |= PCI_EXP_SLTSTA_PDC; |
642 | del_timer_sync(&ctrl->poll_timer); | ||
643 | } | 640 | } |
641 | ctrl_mask |= PCI_EXP_SLTCTL_DLLSCE; | ||
642 | stat_mask |= PCI_EXP_SLTSTA_DLLSC; | ||
643 | |||
644 | pcie_write_cmd(ctrl, 0, ctrl_mask); | ||
645 | if (pciehp_poll_mode) | ||
646 | del_timer_sync(&ctrl->poll_timer); | ||
644 | 647 | ||
645 | pci_reset_bridge_secondary_bus(ctrl->pcie->port); | 648 | pci_reset_bridge_secondary_bus(ctrl->pcie->port); |
646 | 649 | ||
647 | if (HP_SUPR_RM(ctrl)) { | 650 | pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, stat_mask); |
648 | pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, | 651 | pcie_write_cmd(ctrl, ctrl_mask, ctrl_mask); |
649 | PCI_EXP_SLTSTA_PDC); | 652 | if (pciehp_poll_mode) |
650 | pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PDCE, PCI_EXP_SLTCTL_PDCE); | 653 | int_poll_timeout(ctrl->poll_timer.data); |
651 | if (pciehp_poll_mode) | ||
652 | int_poll_timeout(ctrl->poll_timer.data); | ||
653 | } | ||
654 | 654 | ||
655 | return 0; | 655 | return 0; |
656 | } | 656 | } |
@@ -687,6 +687,7 @@ static int pcie_init_slot(struct controller *ctrl) | |||
687 | 687 | ||
688 | slot->ctrl = ctrl; | 688 | slot->ctrl = ctrl; |
689 | mutex_init(&slot->lock); | 689 | mutex_init(&slot->lock); |
690 | mutex_init(&slot->hotplug_lock); | ||
690 | INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work); | 691 | INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work); |
691 | ctrl->slot = slot; | 692 | ctrl->slot = slot; |
692 | return 0; | 693 | return 0; |
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c index b07d7cc2d697..1b533060ce65 100644 --- a/drivers/pci/hotplug/pciehp_pci.c +++ b/drivers/pci/hotplug/pciehp_pci.c | |||
@@ -50,7 +50,7 @@ int pciehp_configure_device(struct slot *p_slot) | |||
50 | "at %04x:%02x:00, cannot hot-add\n", pci_name(dev), | 50 | "at %04x:%02x:00, cannot hot-add\n", pci_name(dev), |
51 | pci_domain_nr(parent), parent->number); | 51 | pci_domain_nr(parent), parent->number); |
52 | pci_dev_put(dev); | 52 | pci_dev_put(dev); |
53 | ret = -EINVAL; | 53 | ret = -EEXIST; |
54 | goto out; | 54 | goto out; |
55 | } | 55 | } |
56 | 56 | ||
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 9dce7c5e2a77..de7a74782f92 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c | |||
@@ -170,97 +170,6 @@ static void virtfn_remove(struct pci_dev *dev, int id, int reset) | |||
170 | pci_dev_put(dev); | 170 | pci_dev_put(dev); |
171 | } | 171 | } |
172 | 172 | ||
173 | static int sriov_migration(struct pci_dev *dev) | ||
174 | { | ||
175 | u16 status; | ||
176 | struct pci_sriov *iov = dev->sriov; | ||
177 | |||
178 | if (!iov->num_VFs) | ||
179 | return 0; | ||
180 | |||
181 | if (!(iov->cap & PCI_SRIOV_CAP_VFM)) | ||
182 | return 0; | ||
183 | |||
184 | pci_read_config_word(dev, iov->pos + PCI_SRIOV_STATUS, &status); | ||
185 | if (!(status & PCI_SRIOV_STATUS_VFM)) | ||
186 | return 0; | ||
187 | |||
188 | schedule_work(&iov->mtask); | ||
189 | |||
190 | return 1; | ||
191 | } | ||
192 | |||
193 | static void sriov_migration_task(struct work_struct *work) | ||
194 | { | ||
195 | int i; | ||
196 | u8 state; | ||
197 | u16 status; | ||
198 | struct pci_sriov *iov = container_of(work, struct pci_sriov, mtask); | ||
199 | |||
200 | for (i = iov->initial_VFs; i < iov->num_VFs; i++) { | ||
201 | state = readb(iov->mstate + i); | ||
202 | if (state == PCI_SRIOV_VFM_MI) { | ||
203 | writeb(PCI_SRIOV_VFM_AV, iov->mstate + i); | ||
204 | state = readb(iov->mstate + i); | ||
205 | if (state == PCI_SRIOV_VFM_AV) | ||
206 | virtfn_add(iov->self, i, 1); | ||
207 | } else if (state == PCI_SRIOV_VFM_MO) { | ||
208 | virtfn_remove(iov->self, i, 1); | ||
209 | writeb(PCI_SRIOV_VFM_UA, iov->mstate + i); | ||
210 | state = readb(iov->mstate + i); | ||
211 | if (state == PCI_SRIOV_VFM_AV) | ||
212 | virtfn_add(iov->self, i, 0); | ||
213 | } | ||
214 | } | ||
215 | |||
216 | pci_read_config_word(iov->self, iov->pos + PCI_SRIOV_STATUS, &status); | ||
217 | status &= ~PCI_SRIOV_STATUS_VFM; | ||
218 | pci_write_config_word(iov->self, iov->pos + PCI_SRIOV_STATUS, status); | ||
219 | } | ||
220 | |||
221 | static int sriov_enable_migration(struct pci_dev *dev, int nr_virtfn) | ||
222 | { | ||
223 | int bir; | ||
224 | u32 table; | ||
225 | resource_size_t pa; | ||
226 | struct pci_sriov *iov = dev->sriov; | ||
227 | |||
228 | if (nr_virtfn <= iov->initial_VFs) | ||
229 | return 0; | ||
230 | |||
231 | pci_read_config_dword(dev, iov->pos + PCI_SRIOV_VFM, &table); | ||
232 | bir = PCI_SRIOV_VFM_BIR(table); | ||
233 | if (bir > PCI_STD_RESOURCE_END) | ||
234 | return -EIO; | ||
235 | |||
236 | table = PCI_SRIOV_VFM_OFFSET(table); | ||
237 | if (table + nr_virtfn > pci_resource_len(dev, bir)) | ||
238 | return -EIO; | ||
239 | |||
240 | pa = pci_resource_start(dev, bir) + table; | ||
241 | iov->mstate = ioremap(pa, nr_virtfn); | ||
242 | if (!iov->mstate) | ||
243 | return -ENOMEM; | ||
244 | |||
245 | INIT_WORK(&iov->mtask, sriov_migration_task); | ||
246 | |||
247 | iov->ctrl |= PCI_SRIOV_CTRL_VFM | PCI_SRIOV_CTRL_INTR; | ||
248 | pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl); | ||
249 | |||
250 | return 0; | ||
251 | } | ||
252 | |||
253 | static void sriov_disable_migration(struct pci_dev *dev) | ||
254 | { | ||
255 | struct pci_sriov *iov = dev->sriov; | ||
256 | |||
257 | iov->ctrl &= ~(PCI_SRIOV_CTRL_VFM | PCI_SRIOV_CTRL_INTR); | ||
258 | pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl); | ||
259 | |||
260 | cancel_work_sync(&iov->mtask); | ||
261 | iounmap(iov->mstate); | ||
262 | } | ||
263 | |||
264 | static int sriov_enable(struct pci_dev *dev, int nr_virtfn) | 173 | static int sriov_enable(struct pci_dev *dev, int nr_virtfn) |
265 | { | 174 | { |
266 | int rc; | 175 | int rc; |
@@ -351,12 +260,6 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) | |||
351 | goto failed; | 260 | goto failed; |
352 | } | 261 | } |
353 | 262 | ||
354 | if (iov->cap & PCI_SRIOV_CAP_VFM) { | ||
355 | rc = sriov_enable_migration(dev, nr_virtfn); | ||
356 | if (rc) | ||
357 | goto failed; | ||
358 | } | ||
359 | |||
360 | kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); | 263 | kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); |
361 | iov->num_VFs = nr_virtfn; | 264 | iov->num_VFs = nr_virtfn; |
362 | 265 | ||
@@ -387,9 +290,6 @@ static void sriov_disable(struct pci_dev *dev) | |||
387 | if (!iov->num_VFs) | 290 | if (!iov->num_VFs) |
388 | return; | 291 | return; |
389 | 292 | ||
390 | if (iov->cap & PCI_SRIOV_CAP_VFM) | ||
391 | sriov_disable_migration(dev); | ||
392 | |||
393 | for (i = 0; i < iov->num_VFs; i++) | 293 | for (i = 0; i < iov->num_VFs; i++) |
394 | virtfn_remove(dev, i, 0); | 294 | virtfn_remove(dev, i, 0); |
395 | 295 | ||
@@ -688,25 +588,6 @@ void pci_disable_sriov(struct pci_dev *dev) | |||
688 | EXPORT_SYMBOL_GPL(pci_disable_sriov); | 588 | EXPORT_SYMBOL_GPL(pci_disable_sriov); |
689 | 589 | ||
690 | /** | 590 | /** |
691 | * pci_sriov_migration - notify SR-IOV core of Virtual Function Migration | ||
692 | * @dev: the PCI device | ||
693 | * | ||
694 | * Returns IRQ_HANDLED if the IRQ is handled, or IRQ_NONE if not. | ||
695 | * | ||
696 | * Physical Function driver is responsible to register IRQ handler using | ||
697 | * VF Migration Interrupt Message Number, and call this function when the | ||
698 | * interrupt is generated by the hardware. | ||
699 | */ | ||
700 | irqreturn_t pci_sriov_migration(struct pci_dev *dev) | ||
701 | { | ||
702 | if (!dev->is_physfn) | ||
703 | return IRQ_NONE; | ||
704 | |||
705 | return sriov_migration(dev) ? IRQ_HANDLED : IRQ_NONE; | ||
706 | } | ||
707 | EXPORT_SYMBOL_GPL(pci_sriov_migration); | ||
708 | |||
709 | /** | ||
710 | * pci_num_vf - return number of VFs associated with a PF device_release_driver | 591 | * pci_num_vf - return number of VFs associated with a PF device_release_driver |
711 | * @dev: the PCI device | 592 | * @dev: the PCI device |
712 | * | 593 | * |
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 7a0fec6ce571..955ab7990c5b 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -545,9 +545,15 @@ static int populate_msi_sysfs(struct pci_dev *pdev) | |||
545 | return -ENOMEM; | 545 | return -ENOMEM; |
546 | list_for_each_entry(entry, &pdev->msi_list, list) { | 546 | list_for_each_entry(entry, &pdev->msi_list, list) { |
547 | char *name = kmalloc(20, GFP_KERNEL); | 547 | char *name = kmalloc(20, GFP_KERNEL); |
548 | if (!name) | ||
549 | goto error_attrs; | ||
550 | |||
548 | msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL); | 551 | msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL); |
549 | if (!msi_dev_attr) | 552 | if (!msi_dev_attr) { |
553 | kfree(name); | ||
550 | goto error_attrs; | 554 | goto error_attrs; |
555 | } | ||
556 | |||
551 | sprintf(name, "%d", entry->irq); | 557 | sprintf(name, "%d", entry->irq); |
552 | sysfs_attr_init(&msi_dev_attr->attr); | 558 | sysfs_attr_init(&msi_dev_attr->attr); |
553 | msi_dev_attr->attr.name = name; | 559 | msi_dev_attr->attr.name = name; |
@@ -589,6 +595,7 @@ error_attrs: | |||
589 | ++count; | 595 | ++count; |
590 | msi_attr = msi_attrs[count]; | 596 | msi_attr = msi_attrs[count]; |
591 | } | 597 | } |
598 | kfree(msi_attrs); | ||
592 | return ret; | 599 | return ret; |
593 | } | 600 | } |
594 | 601 | ||
@@ -959,7 +966,6 @@ EXPORT_SYMBOL(pci_disable_msi); | |||
959 | /** | 966 | /** |
960 | * pci_msix_vec_count - return the number of device's MSI-X table entries | 967 | * pci_msix_vec_count - return the number of device's MSI-X table entries |
961 | * @dev: pointer to the pci_dev data structure of MSI-X device function | 968 | * @dev: pointer to the pci_dev data structure of MSI-X device function |
962 | |||
963 | * This function returns the number of device's MSI-X table entries and | 969 | * This function returns the number of device's MSI-X table entries and |
964 | * therefore the number of MSI-X vectors device is capable of sending. | 970 | * therefore the number of MSI-X vectors device is capable of sending. |
965 | * It returns a negative errno if the device is not capable of sending MSI-X | 971 | * It returns a negative errno if the device is not capable of sending MSI-X |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 1febe90831b4..b6ddde1d04ca 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -108,12 +108,12 @@ static bool pcie_ari_disabled; | |||
108 | */ | 108 | */ |
109 | unsigned char pci_bus_max_busnr(struct pci_bus* bus) | 109 | unsigned char pci_bus_max_busnr(struct pci_bus* bus) |
110 | { | 110 | { |
111 | struct list_head *tmp; | 111 | struct pci_bus *tmp; |
112 | unsigned char max, n; | 112 | unsigned char max, n; |
113 | 113 | ||
114 | max = bus->busn_res.end; | 114 | max = bus->busn_res.end; |
115 | list_for_each(tmp, &bus->children) { | 115 | list_for_each_entry(tmp, &bus->children, node) { |
116 | n = pci_bus_max_busnr(pci_bus_b(tmp)); | 116 | n = pci_bus_max_busnr(tmp); |
117 | if(n > max) | 117 | if(n > max) |
118 | max = n; | 118 | max = n; |
119 | } | 119 | } |
@@ -1181,6 +1181,8 @@ EXPORT_SYMBOL_GPL(pci_load_and_free_saved_state); | |||
1181 | static int do_pci_enable_device(struct pci_dev *dev, int bars) | 1181 | static int do_pci_enable_device(struct pci_dev *dev, int bars) |
1182 | { | 1182 | { |
1183 | int err; | 1183 | int err; |
1184 | u16 cmd; | ||
1185 | u8 pin; | ||
1184 | 1186 | ||
1185 | err = pci_set_power_state(dev, PCI_D0); | 1187 | err = pci_set_power_state(dev, PCI_D0); |
1186 | if (err < 0 && err != -EIO) | 1188 | if (err < 0 && err != -EIO) |
@@ -1190,6 +1192,14 @@ static int do_pci_enable_device(struct pci_dev *dev, int bars) | |||
1190 | return err; | 1192 | return err; |
1191 | pci_fixup_device(pci_fixup_enable, dev); | 1193 | pci_fixup_device(pci_fixup_enable, dev); |
1192 | 1194 | ||
1195 | pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); | ||
1196 | if (pin) { | ||
1197 | pci_read_config_word(dev, PCI_COMMAND, &cmd); | ||
1198 | if (cmd & PCI_COMMAND_INTX_DISABLE) | ||
1199 | pci_write_config_word(dev, PCI_COMMAND, | ||
1200 | cmd & ~PCI_COMMAND_INTX_DISABLE); | ||
1201 | } | ||
1202 | |||
1193 | return 0; | 1203 | return 0; |
1194 | } | 1204 | } |
1195 | 1205 | ||
@@ -1611,29 +1621,27 @@ static void pci_pme_list_scan(struct work_struct *work) | |||
1611 | struct pci_pme_device *pme_dev, *n; | 1621 | struct pci_pme_device *pme_dev, *n; |
1612 | 1622 | ||
1613 | mutex_lock(&pci_pme_list_mutex); | 1623 | mutex_lock(&pci_pme_list_mutex); |
1614 | if (!list_empty(&pci_pme_list)) { | 1624 | list_for_each_entry_safe(pme_dev, n, &pci_pme_list, list) { |
1615 | list_for_each_entry_safe(pme_dev, n, &pci_pme_list, list) { | 1625 | if (pme_dev->dev->pme_poll) { |
1616 | if (pme_dev->dev->pme_poll) { | 1626 | struct pci_dev *bridge; |
1617 | struct pci_dev *bridge; | 1627 | |
1618 | 1628 | bridge = pme_dev->dev->bus->self; | |
1619 | bridge = pme_dev->dev->bus->self; | 1629 | /* |
1620 | /* | 1630 | * If bridge is in low power state, the |
1621 | * If bridge is in low power state, the | 1631 | * configuration space of subordinate devices |
1622 | * configuration space of subordinate devices | 1632 | * may be not accessible |
1623 | * may be not accessible | 1633 | */ |
1624 | */ | 1634 | if (bridge && bridge->current_state != PCI_D0) |
1625 | if (bridge && bridge->current_state != PCI_D0) | 1635 | continue; |
1626 | continue; | 1636 | pci_pme_wakeup(pme_dev->dev, NULL); |
1627 | pci_pme_wakeup(pme_dev->dev, NULL); | 1637 | } else { |
1628 | } else { | 1638 | list_del(&pme_dev->list); |
1629 | list_del(&pme_dev->list); | 1639 | kfree(pme_dev); |
1630 | kfree(pme_dev); | ||
1631 | } | ||
1632 | } | 1640 | } |
1633 | if (!list_empty(&pci_pme_list)) | ||
1634 | schedule_delayed_work(&pci_pme_work, | ||
1635 | msecs_to_jiffies(PME_TIMEOUT)); | ||
1636 | } | 1641 | } |
1642 | if (!list_empty(&pci_pme_list)) | ||
1643 | schedule_delayed_work(&pci_pme_work, | ||
1644 | msecs_to_jiffies(PME_TIMEOUT)); | ||
1637 | mutex_unlock(&pci_pme_list_mutex); | 1645 | mutex_unlock(&pci_pme_list_mutex); |
1638 | } | 1646 | } |
1639 | 1647 | ||
@@ -2180,21 +2188,18 @@ void pci_request_acs(void) | |||
2180 | } | 2188 | } |
2181 | 2189 | ||
2182 | /** | 2190 | /** |
2183 | * pci_enable_acs - enable ACS if hardware support it | 2191 | * pci_std_enable_acs - enable ACS on devices using standard ACS capabilites |
2184 | * @dev: the PCI device | 2192 | * @dev: the PCI device |
2185 | */ | 2193 | */ |
2186 | void pci_enable_acs(struct pci_dev *dev) | 2194 | static int pci_std_enable_acs(struct pci_dev *dev) |
2187 | { | 2195 | { |
2188 | int pos; | 2196 | int pos; |
2189 | u16 cap; | 2197 | u16 cap; |
2190 | u16 ctrl; | 2198 | u16 ctrl; |
2191 | 2199 | ||
2192 | if (!pci_acs_enable) | ||
2193 | return; | ||
2194 | |||
2195 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS); | 2200 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS); |
2196 | if (!pos) | 2201 | if (!pos) |
2197 | return; | 2202 | return -ENODEV; |
2198 | 2203 | ||
2199 | pci_read_config_word(dev, pos + PCI_ACS_CAP, &cap); | 2204 | pci_read_config_word(dev, pos + PCI_ACS_CAP, &cap); |
2200 | pci_read_config_word(dev, pos + PCI_ACS_CTRL, &ctrl); | 2205 | pci_read_config_word(dev, pos + PCI_ACS_CTRL, &ctrl); |
@@ -2212,6 +2217,23 @@ void pci_enable_acs(struct pci_dev *dev) | |||
2212 | ctrl |= (cap & PCI_ACS_UF); | 2217 | ctrl |= (cap & PCI_ACS_UF); |
2213 | 2218 | ||
2214 | pci_write_config_word(dev, pos + PCI_ACS_CTRL, ctrl); | 2219 | pci_write_config_word(dev, pos + PCI_ACS_CTRL, ctrl); |
2220 | |||
2221 | return 0; | ||
2222 | } | ||
2223 | |||
2224 | /** | ||
2225 | * pci_enable_acs - enable ACS if hardware support it | ||
2226 | * @dev: the PCI device | ||
2227 | */ | ||
2228 | void pci_enable_acs(struct pci_dev *dev) | ||
2229 | { | ||
2230 | if (!pci_acs_enable) | ||
2231 | return; | ||
2232 | |||
2233 | if (!pci_std_enable_acs(dev)) | ||
2234 | return; | ||
2235 | |||
2236 | pci_dev_specific_enable_acs(dev); | ||
2215 | } | 2237 | } |
2216 | 2238 | ||
2217 | static bool pci_acs_flags_enabled(struct pci_dev *pdev, u16 acs_flags) | 2239 | static bool pci_acs_flags_enabled(struct pci_dev *pdev, u16 acs_flags) |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 4df38df224f4..6bd082299e31 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -1,8 +1,6 @@ | |||
1 | #ifndef DRIVERS_PCI_H | 1 | #ifndef DRIVERS_PCI_H |
2 | #define DRIVERS_PCI_H | 2 | #define DRIVERS_PCI_H |
3 | 3 | ||
4 | #include <linux/workqueue.h> | ||
5 | |||
6 | #define PCI_CFG_SPACE_SIZE 256 | 4 | #define PCI_CFG_SPACE_SIZE 256 |
7 | #define PCI_CFG_SPACE_EXP_SIZE 4096 | 5 | #define PCI_CFG_SPACE_EXP_SIZE 4096 |
8 | 6 | ||
@@ -240,8 +238,6 @@ struct pci_sriov { | |||
240 | struct pci_dev *dev; /* lowest numbered PF */ | 238 | struct pci_dev *dev; /* lowest numbered PF */ |
241 | struct pci_dev *self; /* this PF */ | 239 | struct pci_dev *self; /* this PF */ |
242 | struct mutex lock; /* lock for VF bus */ | 240 | struct mutex lock; /* lock for VF bus */ |
243 | struct work_struct mtask; /* VF Migration task */ | ||
244 | u8 __iomem *mstate; /* VF Migration State Array */ | ||
245 | }; | 241 | }; |
246 | 242 | ||
247 | #ifdef CONFIG_PCI_ATS | 243 | #ifdef CONFIG_PCI_ATS |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 6e34498ec9f0..509494381a7a 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -731,22 +731,6 @@ struct pci_bus *__ref pci_add_new_bus(struct pci_bus *parent, struct pci_dev *de | |||
731 | return child; | 731 | return child; |
732 | } | 732 | } |
733 | 733 | ||
734 | static void pci_fixup_parent_subordinate_busnr(struct pci_bus *child, int max) | ||
735 | { | ||
736 | struct pci_bus *parent = child->parent; | ||
737 | |||
738 | /* Attempts to fix that up are really dangerous unless | ||
739 | we're going to re-assign all bus numbers. */ | ||
740 | if (!pcibios_assign_all_busses()) | ||
741 | return; | ||
742 | |||
743 | while (parent->parent && parent->busn_res.end < max) { | ||
744 | parent->busn_res.end = max; | ||
745 | pci_write_config_byte(parent->self, PCI_SUBORDINATE_BUS, max); | ||
746 | parent = parent->parent; | ||
747 | } | ||
748 | } | ||
749 | |||
750 | /* | 734 | /* |
751 | * If it's a bridge, configure it and scan the bus behind it. | 735 | * If it's a bridge, configure it and scan the bus behind it. |
752 | * For CardBus bridges, we don't scan behind as the devices will | 736 | * For CardBus bridges, we don't scan behind as the devices will |
@@ -782,7 +766,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass) | |||
782 | /* Check if setup is sensible at all */ | 766 | /* Check if setup is sensible at all */ |
783 | if (!pass && | 767 | if (!pass && |
784 | (primary != bus->number || secondary <= bus->number || | 768 | (primary != bus->number || secondary <= bus->number || |
785 | secondary > subordinate)) { | 769 | secondary > subordinate || subordinate > bus->busn_res.end)) { |
786 | dev_info(&dev->dev, "bridge configuration invalid ([bus %02x-%02x]), reconfiguring\n", | 770 | dev_info(&dev->dev, "bridge configuration invalid ([bus %02x-%02x]), reconfiguring\n", |
787 | secondary, subordinate); | 771 | secondary, subordinate); |
788 | broken = 1; | 772 | broken = 1; |
@@ -805,11 +789,10 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass) | |||
805 | goto out; | 789 | goto out; |
806 | 790 | ||
807 | /* | 791 | /* |
808 | * If we already got to this bus through a different bridge, | 792 | * The bus might already exist for two reasons: Either we are |
809 | * don't re-add it. This can happen with the i450NX chipset. | 793 | * rescanning the bus or the bus is reachable through more than |
810 | * | 794 | * one bridge. The second case can happen with the i450NX |
811 | * However, we continue to descend down the hierarchy and | 795 | * chipset. |
812 | * scan remaining child buses. | ||
813 | */ | 796 | */ |
814 | child = pci_find_bus(pci_domain_nr(bus), secondary); | 797 | child = pci_find_bus(pci_domain_nr(bus), secondary); |
815 | if (!child) { | 798 | if (!child) { |
@@ -822,17 +805,19 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass) | |||
822 | } | 805 | } |
823 | 806 | ||
824 | cmax = pci_scan_child_bus(child); | 807 | cmax = pci_scan_child_bus(child); |
825 | if (cmax > max) | 808 | if (cmax > subordinate) |
826 | max = cmax; | 809 | dev_warn(&dev->dev, "bridge has subordinate %02x but max busn %02x\n", |
827 | if (child->busn_res.end > max) | 810 | subordinate, cmax); |
828 | max = child->busn_res.end; | 811 | /* subordinate should equal child->busn_res.end */ |
812 | if (subordinate > max) | ||
813 | max = subordinate; | ||
829 | } else { | 814 | } else { |
830 | /* | 815 | /* |
831 | * We need to assign a number to this bus which we always | 816 | * We need to assign a number to this bus which we always |
832 | * do in the second pass. | 817 | * do in the second pass. |
833 | */ | 818 | */ |
834 | if (!pass) { | 819 | if (!pass) { |
835 | if (pcibios_assign_all_busses() || broken) | 820 | if (pcibios_assign_all_busses() || broken || is_cardbus) |
836 | /* Temporarily disable forwarding of the | 821 | /* Temporarily disable forwarding of the |
837 | configuration cycles on all bridges in | 822 | configuration cycles on all bridges in |
838 | this bus segment to avoid possible | 823 | this bus segment to avoid possible |
@@ -844,19 +829,25 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass) | |||
844 | goto out; | 829 | goto out; |
845 | } | 830 | } |
846 | 831 | ||
832 | if (max >= bus->busn_res.end) { | ||
833 | dev_warn(&dev->dev, "can't allocate child bus %02x from %pR\n", | ||
834 | max, &bus->busn_res); | ||
835 | goto out; | ||
836 | } | ||
837 | |||
847 | /* Clear errors */ | 838 | /* Clear errors */ |
848 | pci_write_config_word(dev, PCI_STATUS, 0xffff); | 839 | pci_write_config_word(dev, PCI_STATUS, 0xffff); |
849 | 840 | ||
850 | /* Prevent assigning a bus number that already exists. | 841 | /* The bus will already exist if we are rescanning */ |
851 | * This can happen when a bridge is hot-plugged, so in | ||
852 | * this case we only re-scan this bus. */ | ||
853 | child = pci_find_bus(pci_domain_nr(bus), max+1); | 842 | child = pci_find_bus(pci_domain_nr(bus), max+1); |
854 | if (!child) { | 843 | if (!child) { |
855 | child = pci_add_new_bus(bus, dev, ++max); | 844 | child = pci_add_new_bus(bus, dev, max+1); |
856 | if (!child) | 845 | if (!child) |
857 | goto out; | 846 | goto out; |
858 | pci_bus_insert_busn_res(child, max, 0xff); | 847 | pci_bus_insert_busn_res(child, max+1, |
848 | bus->busn_res.end); | ||
859 | } | 849 | } |
850 | max++; | ||
860 | buses = (buses & 0xff000000) | 851 | buses = (buses & 0xff000000) |
861 | | ((unsigned int)(child->primary) << 0) | 852 | | ((unsigned int)(child->primary) << 0) |
862 | | ((unsigned int)(child->busn_res.start) << 8) | 853 | | ((unsigned int)(child->busn_res.start) << 8) |
@@ -878,20 +869,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass) | |||
878 | 869 | ||
879 | if (!is_cardbus) { | 870 | if (!is_cardbus) { |
880 | child->bridge_ctl = bctl; | 871 | child->bridge_ctl = bctl; |
881 | /* | ||
882 | * Adjust subordinate busnr in parent buses. | ||
883 | * We do this before scanning for children because | ||
884 | * some devices may not be detected if the bios | ||
885 | * was lazy. | ||
886 | */ | ||
887 | pci_fixup_parent_subordinate_busnr(child, max); | ||
888 | /* Now we can scan all subordinate buses... */ | ||
889 | max = pci_scan_child_bus(child); | 872 | max = pci_scan_child_bus(child); |
890 | /* | ||
891 | * now fix it up again since we have found | ||
892 | * the real value of max. | ||
893 | */ | ||
894 | pci_fixup_parent_subordinate_busnr(child, max); | ||
895 | } else { | 873 | } else { |
896 | /* | 874 | /* |
897 | * For CardBus bridges, we leave 4 bus numbers | 875 | * For CardBus bridges, we leave 4 bus numbers |
@@ -922,11 +900,15 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass) | |||
922 | } | 900 | } |
923 | } | 901 | } |
924 | max += i; | 902 | max += i; |
925 | pci_fixup_parent_subordinate_busnr(child, max); | ||
926 | } | 903 | } |
927 | /* | 904 | /* |
928 | * Set the subordinate bus number to its real value. | 905 | * Set the subordinate bus number to its real value. |
929 | */ | 906 | */ |
907 | if (max > bus->busn_res.end) { | ||
908 | dev_warn(&dev->dev, "max busn %02x is outside %pR\n", | ||
909 | max, &bus->busn_res); | ||
910 | max = bus->busn_res.end; | ||
911 | } | ||
930 | pci_bus_update_busn_res_end(child, max); | 912 | pci_bus_update_busn_res_end(child, max); |
931 | pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); | 913 | pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max); |
932 | } | 914 | } |
@@ -1835,7 +1817,7 @@ int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max) | |||
1835 | res->flags |= IORESOURCE_PCI_FIXED; | 1817 | res->flags |= IORESOURCE_PCI_FIXED; |
1836 | } | 1818 | } |
1837 | 1819 | ||
1838 | conflict = insert_resource_conflict(parent_res, res); | 1820 | conflict = request_resource_conflict(parent_res, res); |
1839 | 1821 | ||
1840 | if (conflict) | 1822 | if (conflict) |
1841 | dev_printk(KERN_DEBUG, &b->dev, | 1823 | dev_printk(KERN_DEBUG, &b->dev, |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 5cb726c193de..ed2ed867c34c 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -3423,6 +3423,61 @@ static int pci_quirk_amd_sb_acs(struct pci_dev *dev, u16 acs_flags) | |||
3423 | #endif | 3423 | #endif |
3424 | } | 3424 | } |
3425 | 3425 | ||
3426 | /* | ||
3427 | * Many Intel PCH root ports do provide ACS-like features to disable peer | ||
3428 | * transactions and validate bus numbers in requests, but do not provide an | ||
3429 | * actual PCIe ACS capability. This is the list of device IDs known to fall | ||
3430 | * into that category as provided by Intel in Red Hat bugzilla 1037684. | ||
3431 | */ | ||
3432 | static const u16 pci_quirk_intel_pch_acs_ids[] = { | ||
3433 | /* Ibexpeak PCH */ | ||
3434 | 0x3b42, 0x3b43, 0x3b44, 0x3b45, 0x3b46, 0x3b47, 0x3b48, 0x3b49, | ||
3435 | 0x3b4a, 0x3b4b, 0x3b4c, 0x3b4d, 0x3b4e, 0x3b4f, 0x3b50, 0x3b51, | ||
3436 | /* Cougarpoint PCH */ | ||
3437 | 0x1c10, 0x1c11, 0x1c12, 0x1c13, 0x1c14, 0x1c15, 0x1c16, 0x1c17, | ||
3438 | 0x1c18, 0x1c19, 0x1c1a, 0x1c1b, 0x1c1c, 0x1c1d, 0x1c1e, 0x1c1f, | ||
3439 | /* Pantherpoint PCH */ | ||
3440 | 0x1e10, 0x1e11, 0x1e12, 0x1e13, 0x1e14, 0x1e15, 0x1e16, 0x1e17, | ||
3441 | 0x1e18, 0x1e19, 0x1e1a, 0x1e1b, 0x1e1c, 0x1e1d, 0x1e1e, 0x1e1f, | ||
3442 | /* Lynxpoint-H PCH */ | ||
3443 | 0x8c10, 0x8c11, 0x8c12, 0x8c13, 0x8c14, 0x8c15, 0x8c16, 0x8c17, | ||
3444 | 0x8c18, 0x8c19, 0x8c1a, 0x8c1b, 0x8c1c, 0x8c1d, 0x8c1e, 0x8c1f, | ||
3445 | /* Lynxpoint-LP PCH */ | ||
3446 | 0x9c10, 0x9c11, 0x9c12, 0x9c13, 0x9c14, 0x9c15, 0x9c16, 0x9c17, | ||
3447 | 0x9c18, 0x9c19, 0x9c1a, 0x9c1b, | ||
3448 | /* Wildcat PCH */ | ||
3449 | 0x9c90, 0x9c91, 0x9c92, 0x9c93, 0x9c94, 0x9c95, 0x9c96, 0x9c97, | ||
3450 | 0x9c98, 0x9c99, 0x9c9a, 0x9c9b, | ||
3451 | }; | ||
3452 | |||
3453 | static bool pci_quirk_intel_pch_acs_match(struct pci_dev *dev) | ||
3454 | { | ||
3455 | int i; | ||
3456 | |||
3457 | /* Filter out a few obvious non-matches first */ | ||
3458 | if (!pci_is_pcie(dev) || pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) | ||
3459 | return false; | ||
3460 | |||
3461 | for (i = 0; i < ARRAY_SIZE(pci_quirk_intel_pch_acs_ids); i++) | ||
3462 | if (pci_quirk_intel_pch_acs_ids[i] == dev->device) | ||
3463 | return true; | ||
3464 | |||
3465 | return false; | ||
3466 | } | ||
3467 | |||
3468 | #define INTEL_PCH_ACS_FLAGS (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_SV) | ||
3469 | |||
3470 | static int pci_quirk_intel_pch_acs(struct pci_dev *dev, u16 acs_flags) | ||
3471 | { | ||
3472 | u16 flags = dev->dev_flags & PCI_DEV_FLAGS_ACS_ENABLED_QUIRK ? | ||
3473 | INTEL_PCH_ACS_FLAGS : 0; | ||
3474 | |||
3475 | if (!pci_quirk_intel_pch_acs_match(dev)) | ||
3476 | return -ENOTTY; | ||
3477 | |||
3478 | return acs_flags & ~flags ? 0 : 1; | ||
3479 | } | ||
3480 | |||
3426 | static const struct pci_dev_acs_enabled { | 3481 | static const struct pci_dev_acs_enabled { |
3427 | u16 vendor; | 3482 | u16 vendor; |
3428 | u16 device; | 3483 | u16 device; |
@@ -3434,6 +3489,7 @@ static const struct pci_dev_acs_enabled { | |||
3434 | { PCI_VENDOR_ID_ATI, 0x439d, pci_quirk_amd_sb_acs }, | 3489 | { PCI_VENDOR_ID_ATI, 0x439d, pci_quirk_amd_sb_acs }, |
3435 | { PCI_VENDOR_ID_ATI, 0x4384, pci_quirk_amd_sb_acs }, | 3490 | { PCI_VENDOR_ID_ATI, 0x4384, pci_quirk_amd_sb_acs }, |
3436 | { PCI_VENDOR_ID_ATI, 0x4399, pci_quirk_amd_sb_acs }, | 3491 | { PCI_VENDOR_ID_ATI, 0x4399, pci_quirk_amd_sb_acs }, |
3492 | { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_intel_pch_acs }, | ||
3437 | { 0 } | 3493 | { 0 } |
3438 | }; | 3494 | }; |
3439 | 3495 | ||
@@ -3461,3 +3517,132 @@ int pci_dev_specific_acs_enabled(struct pci_dev *dev, u16 acs_flags) | |||
3461 | 3517 | ||
3462 | return -ENOTTY; | 3518 | return -ENOTTY; |
3463 | } | 3519 | } |
3520 | |||
3521 | /* Config space offset of Root Complex Base Address register */ | ||
3522 | #define INTEL_LPC_RCBA_REG 0xf0 | ||
3523 | /* 31:14 RCBA address */ | ||
3524 | #define INTEL_LPC_RCBA_MASK 0xffffc000 | ||
3525 | /* RCBA Enable */ | ||
3526 | #define INTEL_LPC_RCBA_ENABLE (1 << 0) | ||
3527 | |||
3528 | /* Backbone Scratch Pad Register */ | ||
3529 | #define INTEL_BSPR_REG 0x1104 | ||
3530 | /* Backbone Peer Non-Posted Disable */ | ||
3531 | #define INTEL_BSPR_REG_BPNPD (1 << 8) | ||
3532 | /* Backbone Peer Posted Disable */ | ||
3533 | #define INTEL_BSPR_REG_BPPD (1 << 9) | ||
3534 | |||
3535 | /* Upstream Peer Decode Configuration Register */ | ||
3536 | #define INTEL_UPDCR_REG 0x1114 | ||
3537 | /* 5:0 Peer Decode Enable bits */ | ||
3538 | #define INTEL_UPDCR_REG_MASK 0x3f | ||
3539 | |||
3540 | static int pci_quirk_enable_intel_lpc_acs(struct pci_dev *dev) | ||
3541 | { | ||
3542 | u32 rcba, bspr, updcr; | ||
3543 | void __iomem *rcba_mem; | ||
3544 | |||
3545 | /* | ||
3546 | * Read the RCBA register from the LPC (D31:F0). PCH root ports | ||
3547 | * are D28:F* and therefore get probed before LPC, thus we can't | ||
3548 | * use pci_get_slot/pci_read_config_dword here. | ||
3549 | */ | ||
3550 | pci_bus_read_config_dword(dev->bus, PCI_DEVFN(31, 0), | ||
3551 | INTEL_LPC_RCBA_REG, &rcba); | ||
3552 | if (!(rcba & INTEL_LPC_RCBA_ENABLE)) | ||
3553 | return -EINVAL; | ||
3554 | |||
3555 | rcba_mem = ioremap_nocache(rcba & INTEL_LPC_RCBA_MASK, | ||
3556 | PAGE_ALIGN(INTEL_UPDCR_REG)); | ||
3557 | if (!rcba_mem) | ||
3558 | return -ENOMEM; | ||
3559 | |||
3560 | /* | ||
3561 | * The BSPR can disallow peer cycles, but it's set by soft strap and | ||
3562 | * therefore read-only. If both posted and non-posted peer cycles are | ||
3563 | * disallowed, we're ok. If either are allowed, then we need to use | ||
3564 | * the UPDCR to disable peer decodes for each port. This provides the | ||
3565 | * PCIe ACS equivalent of PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF | ||
3566 | */ | ||
3567 | bspr = readl(rcba_mem + INTEL_BSPR_REG); | ||
3568 | bspr &= INTEL_BSPR_REG_BPNPD | INTEL_BSPR_REG_BPPD; | ||
3569 | if (bspr != (INTEL_BSPR_REG_BPNPD | INTEL_BSPR_REG_BPPD)) { | ||
3570 | updcr = readl(rcba_mem + INTEL_UPDCR_REG); | ||
3571 | if (updcr & INTEL_UPDCR_REG_MASK) { | ||
3572 | dev_info(&dev->dev, "Disabling UPDCR peer decodes\n"); | ||
3573 | updcr &= ~INTEL_UPDCR_REG_MASK; | ||
3574 | writel(updcr, rcba_mem + INTEL_UPDCR_REG); | ||
3575 | } | ||
3576 | } | ||
3577 | |||
3578 | iounmap(rcba_mem); | ||
3579 | return 0; | ||
3580 | } | ||
3581 | |||
3582 | /* Miscellaneous Port Configuration register */ | ||
3583 | #define INTEL_MPC_REG 0xd8 | ||
3584 | /* MPC: Invalid Receive Bus Number Check Enable */ | ||
3585 | #define INTEL_MPC_REG_IRBNCE (1 << 26) | ||
3586 | |||
3587 | static void pci_quirk_enable_intel_rp_mpc_acs(struct pci_dev *dev) | ||
3588 | { | ||
3589 | u32 mpc; | ||
3590 | |||
3591 | /* | ||
3592 | * When enabled, the IRBNCE bit of the MPC register enables the | ||
3593 | * equivalent of PCI ACS Source Validation (PCI_ACS_SV), which | ||
3594 | * ensures that requester IDs fall within the bus number range | ||
3595 | * of the bridge. Enable if not already. | ||
3596 | */ | ||
3597 | pci_read_config_dword(dev, INTEL_MPC_REG, &mpc); | ||
3598 | if (!(mpc & INTEL_MPC_REG_IRBNCE)) { | ||
3599 | dev_info(&dev->dev, "Enabling MPC IRBNCE\n"); | ||
3600 | mpc |= INTEL_MPC_REG_IRBNCE; | ||
3601 | pci_write_config_word(dev, INTEL_MPC_REG, mpc); | ||
3602 | } | ||
3603 | } | ||
3604 | |||
3605 | static int pci_quirk_enable_intel_pch_acs(struct pci_dev *dev) | ||
3606 | { | ||
3607 | if (!pci_quirk_intel_pch_acs_match(dev)) | ||
3608 | return -ENOTTY; | ||
3609 | |||
3610 | if (pci_quirk_enable_intel_lpc_acs(dev)) { | ||
3611 | dev_warn(&dev->dev, "Failed to enable Intel PCH ACS quirk\n"); | ||
3612 | return 0; | ||
3613 | } | ||
3614 | |||
3615 | pci_quirk_enable_intel_rp_mpc_acs(dev); | ||
3616 | |||
3617 | dev->dev_flags |= PCI_DEV_FLAGS_ACS_ENABLED_QUIRK; | ||
3618 | |||
3619 | dev_info(&dev->dev, "Intel PCH root port ACS workaround enabled\n"); | ||
3620 | |||
3621 | return 0; | ||
3622 | } | ||
3623 | |||
3624 | static const struct pci_dev_enable_acs { | ||
3625 | u16 vendor; | ||
3626 | u16 device; | ||
3627 | int (*enable_acs)(struct pci_dev *dev); | ||
3628 | } pci_dev_enable_acs[] = { | ||
3629 | { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_enable_intel_pch_acs }, | ||
3630 | { 0 } | ||
3631 | }; | ||
3632 | |||
3633 | void pci_dev_specific_enable_acs(struct pci_dev *dev) | ||
3634 | { | ||
3635 | const struct pci_dev_enable_acs *i; | ||
3636 | int ret; | ||
3637 | |||
3638 | for (i = pci_dev_enable_acs; i->enable_acs; i++) { | ||
3639 | if ((i->vendor == dev->vendor || | ||
3640 | i->vendor == (u16)PCI_ANY_ID) && | ||
3641 | (i->device == dev->device || | ||
3642 | i->device == (u16)PCI_ANY_ID)) { | ||
3643 | ret = i->enable_acs(dev); | ||
3644 | if (ret >= 0) | ||
3645 | return; | ||
3646 | } | ||
3647 | } | ||
3648 | } | ||
diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 3ff2ac7c14e2..4a1b972efe7f 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c | |||
@@ -54,14 +54,14 @@ pci_find_upstream_pcie_bridge(struct pci_dev *pdev) | |||
54 | 54 | ||
55 | static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr) | 55 | static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr) |
56 | { | 56 | { |
57 | struct pci_bus* child; | 57 | struct pci_bus *child; |
58 | struct list_head *tmp; | 58 | struct pci_bus *tmp; |
59 | 59 | ||
60 | if(bus->number == busnr) | 60 | if(bus->number == busnr) |
61 | return bus; | 61 | return bus; |
62 | 62 | ||
63 | list_for_each(tmp, &bus->children) { | 63 | list_for_each_entry(tmp, &bus->children, node) { |
64 | child = pci_do_find_bus(pci_bus_b(tmp), busnr); | 64 | child = pci_do_find_bus(tmp, busnr); |
65 | if(child) | 65 | if(child) |
66 | return child; | 66 | return child; |
67 | } | 67 | } |
@@ -111,7 +111,7 @@ pci_find_next_bus(const struct pci_bus *from) | |||
111 | down_read(&pci_bus_sem); | 111 | down_read(&pci_bus_sem); |
112 | n = from ? from->node.next : pci_root_buses.next; | 112 | n = from ? from->node.next : pci_root_buses.next; |
113 | if (n != &pci_root_buses) | 113 | if (n != &pci_root_buses) |
114 | b = pci_bus_b(n); | 114 | b = list_entry(n, struct pci_bus, node); |
115 | up_read(&pci_bus_sem); | 115 | up_read(&pci_bus_sem); |
116 | return b; | 116 | return b; |
117 | } | 117 | } |
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 8485761e76af..946f90ef6020 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c | |||
@@ -1076,7 +1076,7 @@ static void yenta_config_init(struct yenta_socket *socket) | |||
1076 | */ | 1076 | */ |
1077 | static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge) | 1077 | static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge) |
1078 | { | 1078 | { |
1079 | struct list_head *tmp; | 1079 | struct pci_bus *sibling; |
1080 | unsigned char upper_limit; | 1080 | unsigned char upper_limit; |
1081 | /* | 1081 | /* |
1082 | * We only check and fix the parent bridge: All systems which need | 1082 | * We only check and fix the parent bridge: All systems which need |
@@ -1095,18 +1095,18 @@ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge) | |||
1095 | /* stay within the limits of the bus range of the parent: */ | 1095 | /* stay within the limits of the bus range of the parent: */ |
1096 | upper_limit = bridge_to_fix->parent->busn_res.end; | 1096 | upper_limit = bridge_to_fix->parent->busn_res.end; |
1097 | 1097 | ||
1098 | /* check the bus ranges of all silbling bridges to prevent overlap */ | 1098 | /* check the bus ranges of all sibling bridges to prevent overlap */ |
1099 | list_for_each(tmp, &bridge_to_fix->parent->children) { | 1099 | list_for_each_entry(sibling, &bridge_to_fix->parent->children, |
1100 | struct pci_bus *silbling = pci_bus_b(tmp); | 1100 | node) { |
1101 | /* | 1101 | /* |
1102 | * If the silbling has a higher secondary bus number | 1102 | * If the sibling has a higher secondary bus number |
1103 | * and it's secondary is equal or smaller than our | 1103 | * and it's secondary is equal or smaller than our |
1104 | * current upper limit, set the new upper limit to | 1104 | * current upper limit, set the new upper limit to |
1105 | * the bus number below the silbling's range: | 1105 | * the bus number below the sibling's range: |
1106 | */ | 1106 | */ |
1107 | if (silbling->busn_res.start > bridge_to_fix->busn_res.end | 1107 | if (sibling->busn_res.start > bridge_to_fix->busn_res.end |
1108 | && silbling->busn_res.start <= upper_limit) | 1108 | && sibling->busn_res.start <= upper_limit) |
1109 | upper_limit = silbling->busn_res.start - 1; | 1109 | upper_limit = sibling->busn_res.start - 1; |
1110 | } | 1110 | } |
1111 | 1111 | ||
1112 | /* Show that the wanted subordinate number is not possible: */ | 1112 | /* Show that the wanted subordinate number is not possible: */ |
diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c index 210357691dc0..9dd49c9839ac 100644 --- a/drivers/vfio/pci/vfio_pci_intrs.c +++ b/drivers/vfio/pci/vfio_pci_intrs.c | |||
@@ -482,15 +482,19 @@ static int vfio_msi_enable(struct vfio_pci_device *vdev, int nvec, bool msix) | |||
482 | for (i = 0; i < nvec; i++) | 482 | for (i = 0; i < nvec; i++) |
483 | vdev->msix[i].entry = i; | 483 | vdev->msix[i].entry = i; |
484 | 484 | ||
485 | ret = pci_enable_msix(pdev, vdev->msix, nvec); | 485 | ret = pci_enable_msix_range(pdev, vdev->msix, 1, nvec); |
486 | if (ret) { | 486 | if (ret < nvec) { |
487 | if (ret > 0) | ||
488 | pci_disable_msix(pdev); | ||
487 | kfree(vdev->msix); | 489 | kfree(vdev->msix); |
488 | kfree(vdev->ctx); | 490 | kfree(vdev->ctx); |
489 | return ret; | 491 | return ret; |
490 | } | 492 | } |
491 | } else { | 493 | } else { |
492 | ret = pci_enable_msi_block(pdev, nvec); | 494 | ret = pci_enable_msi_range(pdev, 1, nvec); |
493 | if (ret) { | 495 | if (ret < nvec) { |
496 | if (ret > 0) | ||
497 | pci_disable_msi(pdev); | ||
494 | kfree(vdev->ctx); | 498 | kfree(vdev->ctx); |
495 | return ret; | 499 | return ret; |
496 | } | 500 | } |
diff --git a/include/acpi/acpi_numa.h b/include/acpi/acpi_numa.h index 451823cb8837..94a37cd7fbda 100644 --- a/include/acpi/acpi_numa.h +++ b/include/acpi/acpi_numa.h | |||
@@ -13,7 +13,6 @@ | |||
13 | 13 | ||
14 | extern int pxm_to_node(int); | 14 | extern int pxm_to_node(int); |
15 | extern int node_to_pxm(int); | 15 | extern int node_to_pxm(int); |
16 | extern void __acpi_map_pxm_to_node(int, int); | ||
17 | extern int acpi_map_pxm_to_node(int); | 16 | extern int acpi_map_pxm_to_node(int); |
18 | extern unsigned char acpi_srat_revision; | 17 | extern unsigned char acpi_srat_revision; |
19 | 18 | ||
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 1151a1dcfe41..6c29abbefd41 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
@@ -259,14 +259,9 @@ extern void acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d); | |||
259 | extern void acpi_osi_setup(char *str); | 259 | extern void acpi_osi_setup(char *str); |
260 | 260 | ||
261 | #ifdef CONFIG_ACPI_NUMA | 261 | #ifdef CONFIG_ACPI_NUMA |
262 | int acpi_get_pxm(acpi_handle handle); | 262 | int acpi_get_node(acpi_handle handle); |
263 | int acpi_get_node(acpi_handle *handle); | ||
264 | #else | 263 | #else |
265 | static inline int acpi_get_pxm(acpi_handle handle) | 264 | static inline int acpi_get_node(acpi_handle handle) |
266 | { | ||
267 | return 0; | ||
268 | } | ||
269 | static inline int acpi_get_node(acpi_handle *handle) | ||
270 | { | 265 | { |
271 | return 0; | 266 | return 0; |
272 | } | 267 | } |
diff --git a/include/linux/pci.h b/include/linux/pci.h index fb57c892b214..d47b352c2e11 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/atomic.h> | 29 | #include <linux/atomic.h> |
30 | #include <linux/device.h> | 30 | #include <linux/device.h> |
31 | #include <linux/io.h> | 31 | #include <linux/io.h> |
32 | #include <linux/irqreturn.h> | ||
33 | #include <uapi/linux/pci.h> | 32 | #include <uapi/linux/pci.h> |
34 | 33 | ||
35 | #include <linux/pci_ids.h> | 34 | #include <linux/pci_ids.h> |
@@ -170,6 +169,8 @@ enum pci_dev_flags { | |||
170 | PCI_DEV_FLAGS_NO_D3 = (__force pci_dev_flags_t) 2, | 169 | PCI_DEV_FLAGS_NO_D3 = (__force pci_dev_flags_t) 2, |
171 | /* Provide indication device is assigned by a Virtual Machine Manager */ | 170 | /* Provide indication device is assigned by a Virtual Machine Manager */ |
172 | PCI_DEV_FLAGS_ASSIGNED = (__force pci_dev_flags_t) 4, | 171 | PCI_DEV_FLAGS_ASSIGNED = (__force pci_dev_flags_t) 4, |
172 | /* Flag for quirk use to store if quirk-specific ACS is enabled */ | ||
173 | PCI_DEV_FLAGS_ACS_ENABLED_QUIRK = (__force pci_dev_flags_t) 8, | ||
173 | }; | 174 | }; |
174 | 175 | ||
175 | enum pci_irq_reroute_variant { | 176 | enum pci_irq_reroute_variant { |
@@ -461,7 +462,6 @@ struct pci_bus { | |||
461 | unsigned int is_added:1; | 462 | unsigned int is_added:1; |
462 | }; | 463 | }; |
463 | 464 | ||
464 | #define pci_bus_b(n) list_entry(n, struct pci_bus, node) | ||
465 | #define to_pci_bus(n) container_of(n, struct pci_bus, dev) | 465 | #define to_pci_bus(n) container_of(n, struct pci_bus, dev) |
466 | 466 | ||
467 | /* | 467 | /* |
@@ -1169,8 +1169,23 @@ void msi_remove_pci_irq_vectors(struct pci_dev *dev); | |||
1169 | void pci_restore_msi_state(struct pci_dev *dev); | 1169 | void pci_restore_msi_state(struct pci_dev *dev); |
1170 | int pci_msi_enabled(void); | 1170 | int pci_msi_enabled(void); |
1171 | int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec); | 1171 | int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec); |
1172 | static inline int pci_enable_msi_exact(struct pci_dev *dev, int nvec) | ||
1173 | { | ||
1174 | int rc = pci_enable_msi_range(dev, nvec, nvec); | ||
1175 | if (rc < 0) | ||
1176 | return rc; | ||
1177 | return 0; | ||
1178 | } | ||
1172 | int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, | 1179 | int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, |
1173 | int minvec, int maxvec); | 1180 | int minvec, int maxvec); |
1181 | static inline int pci_enable_msix_exact(struct pci_dev *dev, | ||
1182 | struct msix_entry *entries, int nvec) | ||
1183 | { | ||
1184 | int rc = pci_enable_msix_range(dev, entries, nvec, nvec); | ||
1185 | if (rc < 0) | ||
1186 | return rc; | ||
1187 | return 0; | ||
1188 | } | ||
1174 | #else | 1189 | #else |
1175 | static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; } | 1190 | static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; } |
1176 | static inline int pci_enable_msi_block(struct pci_dev *dev, int nvec) | 1191 | static inline int pci_enable_msi_block(struct pci_dev *dev, int nvec) |
@@ -1189,9 +1204,14 @@ static inline int pci_msi_enabled(void) { return 0; } | |||
1189 | static inline int pci_enable_msi_range(struct pci_dev *dev, int minvec, | 1204 | static inline int pci_enable_msi_range(struct pci_dev *dev, int minvec, |
1190 | int maxvec) | 1205 | int maxvec) |
1191 | { return -ENOSYS; } | 1206 | { return -ENOSYS; } |
1207 | static inline int pci_enable_msi_exact(struct pci_dev *dev, int nvec) | ||
1208 | { return -ENOSYS; } | ||
1192 | static inline int pci_enable_msix_range(struct pci_dev *dev, | 1209 | static inline int pci_enable_msix_range(struct pci_dev *dev, |
1193 | struct msix_entry *entries, int minvec, int maxvec) | 1210 | struct msix_entry *entries, int minvec, int maxvec) |
1194 | { return -ENOSYS; } | 1211 | { return -ENOSYS; } |
1212 | static inline int pci_enable_msix_exact(struct pci_dev *dev, | ||
1213 | struct msix_entry *entries, int nvec) | ||
1214 | { return -ENOSYS; } | ||
1195 | #endif | 1215 | #endif |
1196 | 1216 | ||
1197 | #ifdef CONFIG_PCIEPORTBUS | 1217 | #ifdef CONFIG_PCIEPORTBUS |
@@ -1510,6 +1530,7 @@ enum pci_fixup_pass { | |||
1510 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); | 1530 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); |
1511 | struct pci_dev *pci_get_dma_source(struct pci_dev *dev); | 1531 | struct pci_dev *pci_get_dma_source(struct pci_dev *dev); |
1512 | int pci_dev_specific_acs_enabled(struct pci_dev *dev, u16 acs_flags); | 1532 | int pci_dev_specific_acs_enabled(struct pci_dev *dev, u16 acs_flags); |
1533 | void pci_dev_specific_enable_acs(struct pci_dev *dev); | ||
1513 | #else | 1534 | #else |
1514 | static inline void pci_fixup_device(enum pci_fixup_pass pass, | 1535 | static inline void pci_fixup_device(enum pci_fixup_pass pass, |
1515 | struct pci_dev *dev) { } | 1536 | struct pci_dev *dev) { } |
@@ -1522,6 +1543,7 @@ static inline int pci_dev_specific_acs_enabled(struct pci_dev *dev, | |||
1522 | { | 1543 | { |
1523 | return -ENOTTY; | 1544 | return -ENOTTY; |
1524 | } | 1545 | } |
1546 | static inline void pci_dev_specific_enable_acs(struct pci_dev *dev) { } | ||
1525 | #endif | 1547 | #endif |
1526 | 1548 | ||
1527 | void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); | 1549 | void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); |
@@ -1577,7 +1599,6 @@ void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); | |||
1577 | #ifdef CONFIG_PCI_IOV | 1599 | #ifdef CONFIG_PCI_IOV |
1578 | int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); | 1600 | int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); |
1579 | void pci_disable_sriov(struct pci_dev *dev); | 1601 | void pci_disable_sriov(struct pci_dev *dev); |
1580 | irqreturn_t pci_sriov_migration(struct pci_dev *dev); | ||
1581 | int pci_num_vf(struct pci_dev *dev); | 1602 | int pci_num_vf(struct pci_dev *dev); |
1582 | int pci_vfs_assigned(struct pci_dev *dev); | 1603 | int pci_vfs_assigned(struct pci_dev *dev); |
1583 | int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs); | 1604 | int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs); |
@@ -1586,8 +1607,6 @@ int pci_sriov_get_totalvfs(struct pci_dev *dev); | |||
1586 | static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) | 1607 | static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) |
1587 | { return -ENODEV; } | 1608 | { return -ENODEV; } |
1588 | static inline void pci_disable_sriov(struct pci_dev *dev) { } | 1609 | static inline void pci_disable_sriov(struct pci_dev *dev) { } |
1589 | static inline irqreturn_t pci_sriov_migration(struct pci_dev *dev) | ||
1590 | { return IRQ_NONE; } | ||
1591 | static inline int pci_num_vf(struct pci_dev *dev) { return 0; } | 1610 | static inline int pci_num_vf(struct pci_dev *dev) { return 0; } |
1592 | static inline int pci_vfs_assigned(struct pci_dev *dev) | 1611 | static inline int pci_vfs_assigned(struct pci_dev *dev) |
1593 | { return 0; } | 1612 | { return 0; } |