aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-13 15:14:47 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-13 15:14:47 -0500
commit193c0d682525987db59ac3a24531a77e4947aa95 (patch)
tree7b58346171c4d07e2c2ee6c3c469c325495149a4
parent8b0cab14951fbf8126795ab301835a8f8126a988 (diff)
parent1cb73f8c479e66541fefd3f7fa547b1fa56cdc54 (diff)
Merge tag 'for-3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull PCI update from Bjorn Helgaas: "Host bridge hotplug: - Untangle _PRT from struct pci_bus (Bjorn Helgaas) - Request _OSC control before scanning root bus (Taku Izumi) - Assign resources when adding host bridge (Yinghai Lu) - Remove root bus when removing host bridge (Yinghai Lu) - Remove _PRT during hot remove (Yinghai Lu) SRIOV - Add sysfs knobs to control numVFs (Don Dutile) Power management - Notify devices when power resource turned on (Huang Ying) Bug fixes - Work around broken _SEG on HP xw9300 (Bjorn Helgaas) - Keep runtime PM enabled for unbound PCI devices (Huang Ying) - Fix Optimus dual-GPU runtime D3 suspend issue (Dave Airlie) - Fix xen frontend shutdown issue (David Vrabel) - Work around PLX PCI 9050 BAR alignment erratum (Ian Abbott) Miscellaneous - Add GPL license for drivers/pci/ioapic (Andrew Cooks) - Add standard PCI-X, PCIe ASPM register #defines (Bjorn Helgaas) - NumaChip remote PCI support (Daniel Blueman) - Fix PCIe Link Capabilities Supported Link Speed definition (Jingoo Han) - Convert dev_printk() to dev_info(), etc (Joe Perches) - Add support for non PCI BAR ROM data (Matthew Garrett) - Add x86 support for host bridge translation offset (Mike Yoknis) - Report success only when every driver supports AER (Vijay Pandarathil)" Fix up trivial conflicts. * tag 'for-3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (48 commits) PCI: Use phys_addr_t for physical ROM address x86/PCI: Add NumaChip remote PCI support ath9k: Use standard #defines for PCIe Capability ASPM fields iwlwifi: Use standard #defines for PCIe Capability ASPM fields iwlwifi: collapse wrapper for pcie_capability_read_word() iwlegacy: Use standard #defines for PCIe Capability ASPM fields iwlegacy: collapse wrapper for pcie_capability_read_word() cxgb3: Use standard #defines for PCIe Capability ASPM fields PCI: Add standard PCIe Capability Link ASPM field names PCI/portdrv: Use PCI Express Capability accessors PCI: Use standard PCIe Capability Link register field names x86: Use PCI setup data PCI: Add support for non-BAR ROMs PCI: Add pcibios_add_device EFI: Stash ROMs if they're not in the PCI BAR PCI: Add and use standard PCI-X Capability register names PCI/PM: Keep runtime PM enabled for unbound PCI devices xen-pcifront: Handle backend CLOSED without CLOSING PCI: SRIOV control and status via sysfs (documentation) PCI/AER: Report success only when every device has AER-aware driver ...
-rw-r--r--Documentation/ABI/testing/sysfs-bus-pci34
-rw-r--r--Documentation/PCI/pci-iov-howto.txt48
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/boot/compressed/eboot.c118
-rw-r--r--arch/x86/include/asm/bootparam.h1
-rw-r--r--arch/x86/include/asm/numachip/numachip.h19
-rw-r--r--arch/x86/include/asm/pci.h12
-rw-r--r--arch/x86/kernel/apic/apic_numachip.c2
-rw-r--r--arch/x86/kernel/setup.c4
-rw-r--r--arch/x86/pci/Makefile1
-rw-r--r--arch/x86/pci/acpi.c46
-rw-r--r--arch/x86/pci/common.c32
-rw-r--r--arch/x86/pci/numachip.c129
-rw-r--r--drivers/acpi/pci_bind.c12
-rw-r--r--drivers/acpi/pci_irq.c17
-rw-r--r--drivers/acpi/pci_root.c165
-rw-r--r--drivers/net/ethernet/chelsio/cxgb3/t3_hw.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/pci.c8
-rw-r--r--drivers/net/wireless/iwlegacy/4965.h4
-rw-r--r--drivers/net/wireless/iwlegacy/common.c10
-rw-r--r--drivers/net/wireless/iwlegacy/common.h12
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/trans.c8
-rw-r--r--drivers/pci/bus.c5
-rw-r--r--drivers/pci/ioapic.c2
-rw-r--r--drivers/pci/iov.c87
-rw-r--r--drivers/pci/irq.c10
-rw-r--r--drivers/pci/pci-driver.c73
-rw-r--r--drivers/pci/pci-stub.c2
-rw-r--r--drivers/pci/pci-sysfs.c172
-rw-r--r--drivers/pci/pci.c48
-rw-r--r--drivers/pci/pci.h8
-rw-r--r--drivers/pci/pcie/aer/aerdrv.h5
-rw-r--r--drivers/pci/pcie/aer/aerdrv_core.c22
-rw-r--r--drivers/pci/pcie/aspm.c18
-rw-r--r--drivers/pci/pcie/portdrv_core.c3
-rw-r--r--drivers/pci/probe.c42
-rw-r--r--drivers/pci/quirks.c39
-rw-r--r--drivers/pci/remove.c36
-rw-r--r--drivers/pci/rom.c11
-rw-r--r--drivers/pci/setup-bus.c22
-rw-r--r--drivers/pci/xen-pcifront.c5
-rw-r--r--include/acpi/acpi_drivers.h4
-rw-r--r--include/linux/efi.h71
-rw-r--r--include/linux/pci.h22
-rw-r--r--include/uapi/linux/pci_regs.h23
45 files changed, 1147 insertions, 268 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci
index dff1f48d252d..1ce5ae329c04 100644
--- a/Documentation/ABI/testing/sysfs-bus-pci
+++ b/Documentation/ABI/testing/sysfs-bus-pci
@@ -222,3 +222,37 @@ Description:
222 satisfied too. Reading this attribute will show the current 222 satisfied too. Reading this attribute will show the current
223 value of d3cold_allowed bit. Writing this attribute will set 223 value of d3cold_allowed bit. Writing this attribute will set
224 the value of d3cold_allowed bit. 224 the value of d3cold_allowed bit.
225
226What: /sys/bus/pci/devices/.../sriov_totalvfs
227Date: November 2012
228Contact: Donald Dutile <ddutile@redhat.com>
229Description:
230 This file appears when a physical PCIe device supports SR-IOV.
231 Userspace applications can read this file to determine the
232 maximum number of Virtual Functions (VFs) a PCIe physical
233 function (PF) can support. Typically, this is the value reported
234 in the PF's SR-IOV extended capability structure's TotalVFs
235 element. Drivers have the ability at probe time to reduce the
236 value read from this file via the pci_sriov_set_totalvfs()
237 function.
238
239What: /sys/bus/pci/devices/.../sriov_numvfs
240Date: November 2012
241Contact: Donald Dutile <ddutile@redhat.com>
242Description:
243 This file appears when a physical PCIe device supports SR-IOV.
244 Userspace applications can read and write to this file to
245 determine and control the enablement or disablement of Virtual
246 Functions (VFs) on the physical function (PF). A read of this
247 file will return the number of VFs that are enabled on this PF.
248 A number written to this file will enable the specified
249 number of VFs. A userspace application would typically read the
250 file and check that the value is zero, and then write the number
251 of VFs that should be enabled on the PF; the value written
252 should be less than or equal to the value in the sriov_totalvfs
253 file. A userspace application wanting to disable the VFs would
254 write a zero to this file. The core ensures that valid values
255 are written to this file, and returns errors when values are not
256 valid. For example, writing a 2 to this file when sriov_numvfs
257 is not 0 and not 2 already will return an error. Writing a 10
258 when the value of sriov_totalvfs is 8 will return an error.
diff --git a/Documentation/PCI/pci-iov-howto.txt b/Documentation/PCI/pci-iov-howto.txt
index fc73ef5d65b8..cfaca7e69893 100644
--- a/Documentation/PCI/pci-iov-howto.txt
+++ b/Documentation/PCI/pci-iov-howto.txt
@@ -2,6 +2,9 @@
2 Copyright (C) 2009 Intel Corporation 2 Copyright (C) 2009 Intel Corporation
3 Yu Zhao <yu.zhao@intel.com> 3 Yu Zhao <yu.zhao@intel.com>
4 4
5 Update: November 2012
6 -- sysfs-based SRIOV enable-/disable-ment
7 Donald Dutile <ddutile@redhat.com>
5 8
61. Overview 91. Overview
7 10
@@ -24,10 +27,21 @@ real existing PCI device.
24 27
252.1 How can I enable SR-IOV capability 282.1 How can I enable SR-IOV capability
26 29
27The device driver (PF driver) will control the enabling and disabling 30Multiple methods are available for SR-IOV enablement.
28of the capability via API provided by SR-IOV core. If the hardware 31In the first method, the device driver (PF driver) will control the
29has SR-IOV capability, loading its PF driver would enable it and all 32enabling and disabling of the capability via API provided by SR-IOV core.
30VFs associated with the PF. 33If the hardware has SR-IOV capability, loading its PF driver would
34enable it and all VFs associated with the PF. Some PF drivers require
35a module parameter to be set to determine the number of VFs to enable.
36In the second method, a write to the sysfs file sriov_numvfs will
37enable and disable the VFs associated with a PCIe PF. This method
38enables per-PF, VF enable/disable values versus the first method,
39which applies to all PFs of the same device. Additionally, the
40PCI SRIOV core support ensures that enable/disable operations are
41valid to reduce duplication in multiple drivers for the same
42checks, e.g., check numvfs == 0 if enabling VFs, ensure
43numvfs <= totalvfs.
44The second method is the recommended method for new/future VF devices.
31 45
322.2 How can I use the Virtual Functions 462.2 How can I use the Virtual Functions
33 47
@@ -40,13 +54,22 @@ requires device driver that is same as a normal PCI device's.
403.1 SR-IOV API 543.1 SR-IOV API
41 55
42To enable SR-IOV capability: 56To enable SR-IOV capability:
57(a) For the first method, in the driver:
43 int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); 58 int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
44 'nr_virtfn' is number of VFs to be enabled. 59 'nr_virtfn' is number of VFs to be enabled.
60(b) For the second method, from sysfs:
61 echo 'nr_virtfn' > \
62 /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs
45 63
46To disable SR-IOV capability: 64To disable SR-IOV capability:
65(a) For the first method, in the driver:
47 void pci_disable_sriov(struct pci_dev *dev); 66 void pci_disable_sriov(struct pci_dev *dev);
67(b) For the second method, from sysfs:
68 echo 0 > \
69 /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs
48 70
49To notify SR-IOV core of Virtual Function Migration: 71To notify SR-IOV core of Virtual Function Migration:
72(a) In the driver:
50 irqreturn_t pci_sriov_migration(struct pci_dev *dev); 73 irqreturn_t pci_sriov_migration(struct pci_dev *dev);
51 74
523.2 Usage example 753.2 Usage example
@@ -88,6 +111,22 @@ static void dev_shutdown(struct pci_dev *dev)
88 ... 111 ...
89} 112}
90 113
114static int dev_sriov_configure(struct pci_dev *dev, int numvfs)
115{
116 if (numvfs > 0) {
117 ...
118 pci_enable_sriov(dev, numvfs);
119 ...
120 return numvfs;
121 }
122 if (numvfs == 0) {
123 ....
124 pci_disable_sriov(dev);
125 ...
126 return 0;
127 }
128}
129
91static struct pci_driver dev_driver = { 130static struct pci_driver dev_driver = {
92 .name = "SR-IOV Physical Function driver", 131 .name = "SR-IOV Physical Function driver",
93 .id_table = dev_id_table, 132 .id_table = dev_id_table,
@@ -96,4 +135,5 @@ static struct pci_driver dev_driver = {
96 .suspend = dev_suspend, 135 .suspend = dev_suspend,
97 .resume = dev_resume, 136 .resume = dev_resume,
98 .shutdown = dev_shutdown, 137 .shutdown = dev_shutdown,
138 .sriov_configure = dev_sriov_configure,
99}; 139};
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 9195fd80e11e..65a872bf72f9 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -370,6 +370,7 @@ config X86_NUMACHIP
370 depends on NUMA 370 depends on NUMA
371 depends on SMP 371 depends on SMP
372 depends on X86_X2APIC 372 depends on X86_X2APIC
373 depends on PCI_MMCONFIG
373 ---help--- 374 ---help---
374 Adds support for Numascale NumaChip large-SMP systems. Needed to 375 Adds support for Numascale NumaChip large-SMP systems. Needed to
375 enable more than ~168 cores. 376 enable more than ~168 cores.
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index e87b0cac14b5..b1942e222768 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -8,6 +8,7 @@
8 * ----------------------------------------------------------------------- */ 8 * ----------------------------------------------------------------------- */
9 9
10#include <linux/efi.h> 10#include <linux/efi.h>
11#include <linux/pci.h>
11#include <asm/efi.h> 12#include <asm/efi.h>
12#include <asm/setup.h> 13#include <asm/setup.h>
13#include <asm/desc.h> 14#include <asm/desc.h>
@@ -245,6 +246,121 @@ static void find_bits(unsigned long mask, u8 *pos, u8 *size)
245 *size = len; 246 *size = len;
246} 247}
247 248
249static efi_status_t setup_efi_pci(struct boot_params *params)
250{
251 efi_pci_io_protocol *pci;
252 efi_status_t status;
253 void **pci_handle;
254 efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID;
255 unsigned long nr_pci, size = 0;
256 int i;
257 struct setup_data *data;
258
259 data = (struct setup_data *)params->hdr.setup_data;
260
261 while (data && data->next)
262 data = (struct setup_data *)data->next;
263
264 status = efi_call_phys5(sys_table->boottime->locate_handle,
265 EFI_LOCATE_BY_PROTOCOL, &pci_proto,
266 NULL, &size, pci_handle);
267
268 if (status == EFI_BUFFER_TOO_SMALL) {
269 status = efi_call_phys3(sys_table->boottime->allocate_pool,
270 EFI_LOADER_DATA, size, &pci_handle);
271
272 if (status != EFI_SUCCESS)
273 return status;
274
275 status = efi_call_phys5(sys_table->boottime->locate_handle,
276 EFI_LOCATE_BY_PROTOCOL, &pci_proto,
277 NULL, &size, pci_handle);
278 }
279
280 if (status != EFI_SUCCESS)
281 goto free_handle;
282
283 nr_pci = size / sizeof(void *);
284 for (i = 0; i < nr_pci; i++) {
285 void *h = pci_handle[i];
286 uint64_t attributes;
287 struct pci_setup_rom *rom;
288
289 status = efi_call_phys3(sys_table->boottime->handle_protocol,
290 h, &pci_proto, &pci);
291
292 if (status != EFI_SUCCESS)
293 continue;
294
295 if (!pci)
296 continue;
297
298 status = efi_call_phys4(pci->attributes, pci,
299 EfiPciIoAttributeOperationGet, 0,
300 &attributes);
301
302 if (status != EFI_SUCCESS)
303 continue;
304
305 if (!attributes & EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM)
306 continue;
307
308 if (!pci->romimage || !pci->romsize)
309 continue;
310
311 size = pci->romsize + sizeof(*rom);
312
313 status = efi_call_phys3(sys_table->boottime->allocate_pool,
314 EFI_LOADER_DATA, size, &rom);
315
316 if (status != EFI_SUCCESS)
317 continue;
318
319 rom->data.type = SETUP_PCI;
320 rom->data.len = size - sizeof(struct setup_data);
321 rom->data.next = 0;
322 rom->pcilen = pci->romsize;
323
324 status = efi_call_phys5(pci->pci.read, pci,
325 EfiPciIoWidthUint16, PCI_VENDOR_ID,
326 1, &(rom->vendor));
327
328 if (status != EFI_SUCCESS)
329 goto free_struct;
330
331 status = efi_call_phys5(pci->pci.read, pci,
332 EfiPciIoWidthUint16, PCI_DEVICE_ID,
333 1, &(rom->devid));
334
335 if (status != EFI_SUCCESS)
336 goto free_struct;
337
338 status = efi_call_phys5(pci->get_location, pci,
339 &(rom->segment), &(rom->bus),
340 &(rom->device), &(rom->function));
341
342 if (status != EFI_SUCCESS)
343 goto free_struct;
344
345 memcpy(rom->romdata, pci->romimage, pci->romsize);
346
347 if (data)
348 data->next = (uint64_t)rom;
349 else
350 params->hdr.setup_data = (uint64_t)rom;
351
352 data = (struct setup_data *)rom;
353
354 continue;
355 free_struct:
356 efi_call_phys1(sys_table->boottime->free_pool, rom);
357 }
358
359free_handle:
360 efi_call_phys1(sys_table->boottime->free_pool, pci_handle);
361 return status;
362}
363
248/* 364/*
249 * See if we have Graphics Output Protocol 365 * See if we have Graphics Output Protocol
250 */ 366 */
@@ -1028,6 +1144,8 @@ struct boot_params *efi_main(void *handle, efi_system_table_t *_table,
1028 1144
1029 setup_graphics(boot_params); 1145 setup_graphics(boot_params);
1030 1146
1147 setup_efi_pci(boot_params);
1148
1031 status = efi_call_phys3(sys_table->boottime->allocate_pool, 1149 status = efi_call_phys3(sys_table->boottime->allocate_pool,
1032 EFI_LOADER_DATA, sizeof(*gdt), 1150 EFI_LOADER_DATA, sizeof(*gdt),
1033 (void **)&gdt); 1151 (void **)&gdt);
diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
index 2ad874cb661c..92862cd90201 100644
--- a/arch/x86/include/asm/bootparam.h
+++ b/arch/x86/include/asm/bootparam.h
@@ -13,6 +13,7 @@
13#define SETUP_NONE 0 13#define SETUP_NONE 0
14#define SETUP_E820_EXT 1 14#define SETUP_E820_EXT 1
15#define SETUP_DTB 2 15#define SETUP_DTB 2
16#define SETUP_PCI 3
16 17
17/* extensible setup data list node */ 18/* extensible setup data list node */
18struct setup_data { 19struct setup_data {
diff --git a/arch/x86/include/asm/numachip/numachip.h b/arch/x86/include/asm/numachip/numachip.h
new file mode 100644
index 000000000000..1c6f7f6212c1
--- /dev/null
+++ b/arch/x86/include/asm/numachip/numachip.h
@@ -0,0 +1,19 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Numascale NumaConnect-specific header file
7 *
8 * Copyright (C) 2012 Numascale AS. All rights reserved.
9 *
10 * Send feedback to <support@numascale.com>
11 *
12 */
13
14#ifndef _ASM_X86_NUMACHIP_NUMACHIP_H
15#define _ASM_X86_NUMACHIP_NUMACHIP_H
16
17extern int __init pci_numachip_init(void);
18
19#endif /* _ASM_X86_NUMACHIP_NUMACHIP_H */
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index 6e41b9343928..dba7805176bf 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -171,4 +171,16 @@ cpumask_of_pcibus(const struct pci_bus *bus)
171} 171}
172#endif 172#endif
173 173
174struct pci_setup_rom {
175 struct setup_data data;
176 uint16_t vendor;
177 uint16_t devid;
178 uint64_t pcilen;
179 unsigned long segment;
180 unsigned long bus;
181 unsigned long device;
182 unsigned long function;
183 uint8_t romdata[0];
184};
185
174#endif /* _ASM_X86_PCI_H */ 186#endif /* _ASM_X86_PCI_H */
diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c
index a65829ac2b9a..9c2aa89a11cb 100644
--- a/arch/x86/kernel/apic/apic_numachip.c
+++ b/arch/x86/kernel/apic/apic_numachip.c
@@ -22,6 +22,7 @@
22#include <linux/hardirq.h> 22#include <linux/hardirq.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24 24
25#include <asm/numachip/numachip.h>
25#include <asm/numachip/numachip_csr.h> 26#include <asm/numachip/numachip_csr.h>
26#include <asm/smp.h> 27#include <asm/smp.h>
27#include <asm/apic.h> 28#include <asm/apic.h>
@@ -179,6 +180,7 @@ static int __init numachip_system_init(void)
179 return 0; 180 return 0;
180 181
181 x86_cpuinit.fixup_cpu_id = fixup_cpu_id; 182 x86_cpuinit.fixup_cpu_id = fixup_cpu_id;
183 x86_init.pci.arch_init = pci_numachip_init;
182 184
183 map_csrs(); 185 map_csrs();
184 186
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index ca45696f30fb..c228322ca180 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -143,11 +143,7 @@ int default_check_phys_apicid_present(int phys_apicid)
143} 143}
144#endif 144#endif
145 145
146#ifndef CONFIG_DEBUG_BOOT_PARAMS
147struct boot_params __initdata boot_params;
148#else
149struct boot_params boot_params; 146struct boot_params boot_params;
150#endif
151 147
152/* 148/*
153 * Machine setup.. 149 * Machine setup..
diff --git a/arch/x86/pci/Makefile b/arch/x86/pci/Makefile
index 3af5a1e79c9c..ee0af58ca5bd 100644
--- a/arch/x86/pci/Makefile
+++ b/arch/x86/pci/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_STA2X11) += sta2x11-fixup.o
16obj-$(CONFIG_X86_VISWS) += visws.o 16obj-$(CONFIG_X86_VISWS) += visws.o
17 17
18obj-$(CONFIG_X86_NUMAQ) += numaq_32.o 18obj-$(CONFIG_X86_NUMAQ) += numaq_32.o
19obj-$(CONFIG_X86_NUMACHIP) += numachip.o
19 20
20obj-$(CONFIG_X86_INTEL_MID) += mrst.o 21obj-$(CONFIG_X86_INTEL_MID) += mrst.o
21 22
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 192397c98606..0c01261fe5a8 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -12,6 +12,7 @@ struct pci_root_info {
12 char name[16]; 12 char name[16];
13 unsigned int res_num; 13 unsigned int res_num;
14 struct resource *res; 14 struct resource *res;
15 resource_size_t *res_offset;
15 struct pci_sysdata sd; 16 struct pci_sysdata sd;
16#ifdef CONFIG_PCI_MMCONFIG 17#ifdef CONFIG_PCI_MMCONFIG
17 bool mcfg_added; 18 bool mcfg_added;
@@ -22,6 +23,7 @@ struct pci_root_info {
22}; 23};
23 24
24static bool pci_use_crs = true; 25static bool pci_use_crs = true;
26static bool pci_ignore_seg = false;
25 27
26static int __init set_use_crs(const struct dmi_system_id *id) 28static int __init set_use_crs(const struct dmi_system_id *id)
27{ 29{
@@ -35,7 +37,14 @@ static int __init set_nouse_crs(const struct dmi_system_id *id)
35 return 0; 37 return 0;
36} 38}
37 39
38static const struct dmi_system_id pci_use_crs_table[] __initconst = { 40static int __init set_ignore_seg(const struct dmi_system_id *id)
41{
42 printk(KERN_INFO "PCI: %s detected: ignoring ACPI _SEG\n", id->ident);
43 pci_ignore_seg = true;
44 return 0;
45}
46
47static const struct dmi_system_id pci_crs_quirks[] __initconst = {
39 /* http://bugzilla.kernel.org/show_bug.cgi?id=14183 */ 48 /* http://bugzilla.kernel.org/show_bug.cgi?id=14183 */
40 { 49 {
41 .callback = set_use_crs, 50 .callback = set_use_crs,
@@ -98,6 +107,16 @@ static const struct dmi_system_id pci_use_crs_table[] __initconst = {
98 DMI_MATCH(DMI_BIOS_VERSION, "6JET85WW (1.43 )"), 107 DMI_MATCH(DMI_BIOS_VERSION, "6JET85WW (1.43 )"),
99 }, 108 },
100 }, 109 },
110
111 /* https://bugzilla.kernel.org/show_bug.cgi?id=15362 */
112 {
113 .callback = set_ignore_seg,
114 .ident = "HP xw9300",
115 .matches = {
116 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
117 DMI_MATCH(DMI_PRODUCT_NAME, "HP xw9300 Workstation"),
118 },
119 },
101 {} 120 {}
102}; 121};
103 122
@@ -108,7 +127,7 @@ void __init pci_acpi_crs_quirks(void)
108 if (dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL) && year < 2008) 127 if (dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL) && year < 2008)
109 pci_use_crs = false; 128 pci_use_crs = false;
110 129
111 dmi_check_system(pci_use_crs_table); 130 dmi_check_system(pci_crs_quirks);
112 131
113 /* 132 /*
114 * If the user specifies "pci=use_crs" or "pci=nocrs" explicitly, that 133 * If the user specifies "pci=use_crs" or "pci=nocrs" explicitly, that
@@ -305,6 +324,7 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
305 res->flags = flags; 324 res->flags = flags;
306 res->start = start; 325 res->start = start;
307 res->end = end; 326 res->end = end;
327 info->res_offset[info->res_num] = addr.translation_offset;
308 328
309 if (!pci_use_crs) { 329 if (!pci_use_crs) {
310 dev_printk(KERN_DEBUG, &info->bridge->dev, 330 dev_printk(KERN_DEBUG, &info->bridge->dev,
@@ -374,7 +394,8 @@ static void add_resources(struct pci_root_info *info,
374 "ignoring host bridge window %pR (conflicts with %s %pR)\n", 394 "ignoring host bridge window %pR (conflicts with %s %pR)\n",
375 res, conflict->name, conflict); 395 res, conflict->name, conflict);
376 else 396 else
377 pci_add_resource(resources, res); 397 pci_add_resource_offset(resources, res,
398 info->res_offset[i]);
378 } 399 }
379} 400}
380 401
@@ -382,6 +403,8 @@ static void free_pci_root_info_res(struct pci_root_info *info)
382{ 403{
383 kfree(info->res); 404 kfree(info->res);
384 info->res = NULL; 405 info->res = NULL;
406 kfree(info->res_offset);
407 info->res_offset = NULL;
385 info->res_num = 0; 408 info->res_num = 0;
386} 409}
387 410
@@ -432,10 +455,20 @@ probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device,
432 return; 455 return;
433 456
434 size = sizeof(*info->res) * info->res_num; 457 size = sizeof(*info->res) * info->res_num;
435 info->res_num = 0;
436 info->res = kzalloc(size, GFP_KERNEL); 458 info->res = kzalloc(size, GFP_KERNEL);
437 if (!info->res) 459 if (!info->res) {
460 info->res_num = 0;
461 return;
462 }
463
464 size = sizeof(*info->res_offset) * info->res_num;
465 info->res_num = 0;
466 info->res_offset = kzalloc(size, GFP_KERNEL);
467 if (!info->res_offset) {
468 kfree(info->res);
469 info->res = NULL;
438 return; 470 return;
471 }
439 472
440 acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource, 473 acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource,
441 info); 474 info);
@@ -455,6 +488,9 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
455 int pxm; 488 int pxm;
456#endif 489#endif
457 490
491 if (pci_ignore_seg)
492 domain = 0;
493
458 if (domain && !pci_domains_supported) { 494 if (domain && !pci_domains_supported) {
459 printk(KERN_WARNING "pci_bus %04x:%02x: " 495 printk(KERN_WARNING "pci_bus %04x:%02x: "
460 "ignored (multiple domains not supported)\n", 496 "ignored (multiple domains not supported)\n",
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 720e973fc34a..1b1dda90a945 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -17,6 +17,7 @@
17#include <asm/io.h> 17#include <asm/io.h>
18#include <asm/smp.h> 18#include <asm/smp.h>
19#include <asm/pci_x86.h> 19#include <asm/pci_x86.h>
20#include <asm/setup.h>
20 21
21unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 | 22unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 |
22 PCI_PROBE_MMCONF; 23 PCI_PROBE_MMCONF;
@@ -608,6 +609,35 @@ unsigned int pcibios_assign_all_busses(void)
608 return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0; 609 return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0;
609} 610}
610 611
612int pcibios_add_device(struct pci_dev *dev)
613{
614 struct setup_data *data;
615 struct pci_setup_rom *rom;
616 u64 pa_data;
617
618 pa_data = boot_params.hdr.setup_data;
619 while (pa_data) {
620 data = phys_to_virt(pa_data);
621
622 if (data->type == SETUP_PCI) {
623 rom = (struct pci_setup_rom *)data;
624
625 if ((pci_domain_nr(dev->bus) == rom->segment) &&
626 (dev->bus->number == rom->bus) &&
627 (PCI_SLOT(dev->devfn) == rom->device) &&
628 (PCI_FUNC(dev->devfn) == rom->function) &&
629 (dev->vendor == rom->vendor) &&
630 (dev->device == rom->devid)) {
631 dev->rom = pa_data +
632 offsetof(struct pci_setup_rom, romdata);
633 dev->romlen = rom->pcilen;
634 }
635 }
636 pa_data = data->next;
637 }
638 return 0;
639}
640
611int pcibios_enable_device(struct pci_dev *dev, int mask) 641int pcibios_enable_device(struct pci_dev *dev, int mask)
612{ 642{
613 int err; 643 int err;
@@ -626,7 +656,7 @@ void pcibios_disable_device (struct pci_dev *dev)
626 pcibios_disable_irq(dev); 656 pcibios_disable_irq(dev);
627} 657}
628 658
629int pci_ext_cfg_avail(struct pci_dev *dev) 659int pci_ext_cfg_avail(void)
630{ 660{
631 if (raw_pci_ext_ops) 661 if (raw_pci_ext_ops)
632 return 1; 662 return 1;
diff --git a/arch/x86/pci/numachip.c b/arch/x86/pci/numachip.c
new file mode 100644
index 000000000000..7307d9d12d15
--- /dev/null
+++ b/arch/x86/pci/numachip.c
@@ -0,0 +1,129 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Numascale NumaConnect-specific PCI code
7 *
8 * Copyright (C) 2012 Numascale AS. All rights reserved.
9 *
10 * Send feedback to <support@numascale.com>
11 *
12 * PCI accessor functions derived from mmconfig_64.c
13 *
14 */
15
16#include <linux/pci.h>
17#include <asm/pci_x86.h>
18
19static u8 limit __read_mostly;
20
21static inline char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn)
22{
23 struct pci_mmcfg_region *cfg = pci_mmconfig_lookup(seg, bus);
24
25 if (cfg && cfg->virt)
26 return cfg->virt + (PCI_MMCFG_BUS_OFFSET(bus) | (devfn << 12));
27 return NULL;
28}
29
30static int pci_mmcfg_read_numachip(unsigned int seg, unsigned int bus,
31 unsigned int devfn, int reg, int len, u32 *value)
32{
33 char __iomem *addr;
34
35 /* Why do we have this when nobody checks it. How about a BUG()!? -AK */
36 if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095))) {
37err: *value = -1;
38 return -EINVAL;
39 }
40
41 /* Ensure AMD Northbridges don't decode reads to other devices */
42 if (unlikely(bus == 0 && devfn >= limit)) {
43 *value = -1;
44 return 0;
45 }
46
47 rcu_read_lock();
48 addr = pci_dev_base(seg, bus, devfn);
49 if (!addr) {
50 rcu_read_unlock();
51 goto err;
52 }
53
54 switch (len) {
55 case 1:
56 *value = mmio_config_readb(addr + reg);
57 break;
58 case 2:
59 *value = mmio_config_readw(addr + reg);
60 break;
61 case 4:
62 *value = mmio_config_readl(addr + reg);
63 break;
64 }
65 rcu_read_unlock();
66
67 return 0;
68}
69
70static int pci_mmcfg_write_numachip(unsigned int seg, unsigned int bus,
71 unsigned int devfn, int reg, int len, u32 value)
72{
73 char __iomem *addr;
74
75 /* Why do we have this when nobody checks it. How about a BUG()!? -AK */
76 if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095)))
77 return -EINVAL;
78
79 /* Ensure AMD Northbridges don't decode writes to other devices */
80 if (unlikely(bus == 0 && devfn >= limit))
81 return 0;
82
83 rcu_read_lock();
84 addr = pci_dev_base(seg, bus, devfn);
85 if (!addr) {
86 rcu_read_unlock();
87 return -EINVAL;
88 }
89
90 switch (len) {
91 case 1:
92 mmio_config_writeb(addr + reg, value);
93 break;
94 case 2:
95 mmio_config_writew(addr + reg, value);
96 break;
97 case 4:
98 mmio_config_writel(addr + reg, value);
99 break;
100 }
101 rcu_read_unlock();
102
103 return 0;
104}
105
106const struct pci_raw_ops pci_mmcfg_numachip = {
107 .read = pci_mmcfg_read_numachip,
108 .write = pci_mmcfg_write_numachip,
109};
110
111int __init pci_numachip_init(void)
112{
113 int ret = 0;
114 u32 val;
115
116 /* For remote I/O, restrict bus 0 access to the actual number of AMD
117 Northbridges, which starts at device number 0x18 */
118 ret = raw_pci_read(0, 0, PCI_DEVFN(0x18, 0), 0x60, sizeof(val), &val);
119 if (ret)
120 goto out;
121
122 /* HyperTransport fabric size in bits 6:4 */
123 limit = PCI_DEVFN(0x18 + ((val >> 4) & 7) + 1, 0);
124
125 /* Use NumaChip PCI accessors for non-extended and extended access */
126 raw_pci_ops = raw_pci_ext_ops = &pci_mmcfg_numachip;
127out:
128 return ret;
129}
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
index 2ef04098cc1d..a1dee29beed3 100644
--- a/drivers/acpi/pci_bind.c
+++ b/drivers/acpi/pci_bind.c
@@ -45,11 +45,12 @@ static int acpi_pci_unbind(struct acpi_device *device)
45 45
46 device_set_run_wake(&dev->dev, false); 46 device_set_run_wake(&dev->dev, false);
47 pci_acpi_remove_pm_notifier(device); 47 pci_acpi_remove_pm_notifier(device);
48 acpi_power_resource_unregister_device(&dev->dev, device->handle);
48 49
49 if (!dev->subordinate) 50 if (!dev->subordinate)
50 goto out; 51 goto out;
51 52
52 acpi_pci_irq_del_prt(dev->subordinate); 53 acpi_pci_irq_del_prt(pci_domain_nr(dev->bus), dev->subordinate->number);
53 54
54 device->ops.bind = NULL; 55 device->ops.bind = NULL;
55 device->ops.unbind = NULL; 56 device->ops.unbind = NULL;
@@ -63,7 +64,7 @@ static int acpi_pci_bind(struct acpi_device *device)
63{ 64{
64 acpi_status status; 65 acpi_status status;
65 acpi_handle handle; 66 acpi_handle handle;
66 struct pci_bus *bus; 67 unsigned char bus;
67 struct pci_dev *dev; 68 struct pci_dev *dev;
68 69
69 dev = acpi_get_pci_dev(device->handle); 70 dev = acpi_get_pci_dev(device->handle);
@@ -71,6 +72,7 @@ static int acpi_pci_bind(struct acpi_device *device)
71 return 0; 72 return 0;
72 73
73 pci_acpi_add_pm_notifier(device, dev); 74 pci_acpi_add_pm_notifier(device, dev);
75 acpi_power_resource_register_device(&dev->dev, device->handle);
74 if (device->wakeup.flags.run_wake) 76 if (device->wakeup.flags.run_wake)
75 device_set_run_wake(&dev->dev, true); 77 device_set_run_wake(&dev->dev, true);
76 78
@@ -100,11 +102,11 @@ static int acpi_pci_bind(struct acpi_device *device)
100 goto out; 102 goto out;
101 103
102 if (dev->subordinate) 104 if (dev->subordinate)
103 bus = dev->subordinate; 105 bus = dev->subordinate->number;
104 else 106 else
105 bus = dev->bus; 107 bus = dev->bus->number;
106 108
107 acpi_pci_irq_add_prt(device->handle, bus); 109 acpi_pci_irq_add_prt(device->handle, pci_domain_nr(dev->bus), bus);
108 110
109out: 111out:
110 pci_dev_put(dev); 112 pci_dev_put(dev);
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 23a032490130..68a921d03247 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -184,7 +184,7 @@ static void do_prt_fixups(struct acpi_prt_entry *entry,
184 } 184 }
185} 185}
186 186
187static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus, 187static int acpi_pci_irq_add_entry(acpi_handle handle, int segment, int bus,
188 struct acpi_pci_routing_table *prt) 188 struct acpi_pci_routing_table *prt)
189{ 189{
190 struct acpi_prt_entry *entry; 190 struct acpi_prt_entry *entry;
@@ -198,8 +198,8 @@ static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus,
198 * 1=INTA, 2=INTB. We use the PCI encoding throughout, so convert 198 * 1=INTA, 2=INTB. We use the PCI encoding throughout, so convert
199 * it here. 199 * it here.
200 */ 200 */
201 entry->id.segment = pci_domain_nr(bus); 201 entry->id.segment = segment;
202 entry->id.bus = bus->number; 202 entry->id.bus = bus;
203 entry->id.device = (prt->address >> 16) & 0xFFFF; 203 entry->id.device = (prt->address >> 16) & 0xFFFF;
204 entry->pin = prt->pin + 1; 204 entry->pin = prt->pin + 1;
205 205
@@ -244,7 +244,7 @@ static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus,
244 return 0; 244 return 0;
245} 245}
246 246
247int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus) 247int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
248{ 248{
249 acpi_status status; 249 acpi_status status;
250 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 250 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -273,7 +273,7 @@ int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus)
273 273
274 entry = buffer.pointer; 274 entry = buffer.pointer;
275 while (entry && (entry->length > 0)) { 275 while (entry && (entry->length > 0)) {
276 acpi_pci_irq_add_entry(handle, bus, entry); 276 acpi_pci_irq_add_entry(handle, segment, bus, entry);
277 entry = (struct acpi_pci_routing_table *) 277 entry = (struct acpi_pci_routing_table *)
278 ((unsigned long)entry + entry->length); 278 ((unsigned long)entry + entry->length);
279 } 279 }
@@ -282,17 +282,16 @@ int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus)
282 return 0; 282 return 0;
283} 283}
284 284
285void acpi_pci_irq_del_prt(struct pci_bus *bus) 285void acpi_pci_irq_del_prt(int segment, int bus)
286{ 286{
287 struct acpi_prt_entry *entry, *tmp; 287 struct acpi_prt_entry *entry, *tmp;
288 288
289 printk(KERN_DEBUG 289 printk(KERN_DEBUG
290 "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n", 290 "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n",
291 pci_domain_nr(bus), bus->number); 291 segment, bus);
292 spin_lock(&acpi_prt_lock); 292 spin_lock(&acpi_prt_lock);
293 list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) { 293 list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) {
294 if (pci_domain_nr(bus) == entry->id.segment 294 if (segment == entry->id.segment && bus == entry->id.bus) {
295 && bus->number == entry->id.bus) {
296 list_del(&entry->list); 295 list_del(&entry->list);
297 kfree(entry); 296 kfree(entry);
298 } 297 }
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index f70b9e5fc1b5..7928d4dc7056 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -454,6 +454,7 @@ static int acpi_pci_root_add(struct acpi_device *device)
454 acpi_handle handle; 454 acpi_handle handle;
455 struct acpi_device *child; 455 struct acpi_device *child;
456 u32 flags, base_flags; 456 u32 flags, base_flags;
457 bool is_osc_granted = false;
457 458
458 root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); 459 root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
459 if (!root) 460 if (!root)
@@ -501,85 +502,47 @@ static int acpi_pci_root_add(struct acpi_device *device)
501 strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); 502 strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
502 device->driver_data = root; 503 device->driver_data = root;
503 504
504 root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle);
505
506 /*
507 * All supported architectures that use ACPI have support for
508 * PCI domains, so we indicate this in _OSC support capabilities.
509 */
510 flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
511 acpi_pci_osc_support(root, flags);
512
513 /*
514 * TBD: Need PCI interface for enumeration/configuration of roots.
515 */
516
517 mutex_lock(&acpi_pci_root_lock);
518 list_add_tail(&root->node, &acpi_pci_roots);
519 mutex_unlock(&acpi_pci_root_lock);
520
521 printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n", 505 printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n",
522 acpi_device_name(device), acpi_device_bid(device), 506 acpi_device_name(device), acpi_device_bid(device),
523 root->segment, &root->secondary); 507 root->segment, &root->secondary);
524 508
525 /* 509 /*
526 * Scan the Root Bridge
527 * --------------------
528 * Must do this prior to any attempt to bind the root device, as the
529 * PCI namespace does not get created until this call is made (and
530 * thus the root bridge's pci_dev does not exist).
531 */
532 root->bus = pci_acpi_scan_root(root);
533 if (!root->bus) {
534 printk(KERN_ERR PREFIX
535 "Bus %04x:%02x not present in PCI namespace\n",
536 root->segment, (unsigned int)root->secondary.start);
537 result = -ENODEV;
538 goto out_del_root;
539 }
540
541 /*
542 * Attach ACPI-PCI Context
543 * -----------------------
544 * Thus binding the ACPI and PCI devices.
545 */
546 result = acpi_pci_bind_root(device);
547 if (result)
548 goto out_del_root;
549
550 /*
551 * PCI Routing Table 510 * PCI Routing Table
552 * ----------------- 511 * -----------------
553 * Evaluate and parse _PRT, if exists. 512 * Evaluate and parse _PRT, if exists.
554 */ 513 */
555 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); 514 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
556 if (ACPI_SUCCESS(status)) 515 if (ACPI_SUCCESS(status))
557 result = acpi_pci_irq_add_prt(device->handle, root->bus); 516 result = acpi_pci_irq_add_prt(device->handle, root->segment,
517 root->secondary.start);
518
519 root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle);
558 520
559 /* 521 /*
560 * Scan and bind all _ADR-Based Devices 522 * All supported architectures that use ACPI have support for
523 * PCI domains, so we indicate this in _OSC support capabilities.
561 */ 524 */
562 list_for_each_entry(child, &device->children, node) 525 flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
563 acpi_pci_bridge_scan(child); 526 acpi_pci_osc_support(root, flags);
564 527
565 /* Indicate support for various _OSC capabilities. */ 528 /* Indicate support for various _OSC capabilities. */
566 if (pci_ext_cfg_avail(root->bus->self)) 529 if (pci_ext_cfg_avail())
567 flags |= OSC_EXT_PCI_CONFIG_SUPPORT; 530 flags |= OSC_EXT_PCI_CONFIG_SUPPORT;
568 if (pcie_aspm_support_enabled()) 531 if (pcie_aspm_support_enabled()) {
569 flags |= OSC_ACTIVE_STATE_PWR_SUPPORT | 532 flags |= OSC_ACTIVE_STATE_PWR_SUPPORT |
570 OSC_CLOCK_PWR_CAPABILITY_SUPPORT; 533 OSC_CLOCK_PWR_CAPABILITY_SUPPORT;
534 }
571 if (pci_msi_enabled()) 535 if (pci_msi_enabled())
572 flags |= OSC_MSI_SUPPORT; 536 flags |= OSC_MSI_SUPPORT;
573 if (flags != base_flags) { 537 if (flags != base_flags) {
574 status = acpi_pci_osc_support(root, flags); 538 status = acpi_pci_osc_support(root, flags);
575 if (ACPI_FAILURE(status)) { 539 if (ACPI_FAILURE(status)) {
576 dev_info(root->bus->bridge, "ACPI _OSC support " 540 dev_info(&device->dev, "ACPI _OSC support "
577 "notification failed, disabling PCIe ASPM\n"); 541 "notification failed, disabling PCIe ASPM\n");
578 pcie_no_aspm(); 542 pcie_no_aspm();
579 flags = base_flags; 543 flags = base_flags;
580 } 544 }
581 } 545 }
582
583 if (!pcie_ports_disabled 546 if (!pcie_ports_disabled
584 && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) { 547 && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
585 flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL 548 flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL
@@ -588,40 +551,81 @@ static int acpi_pci_root_add(struct acpi_device *device)
588 551
589 if (pci_aer_available()) { 552 if (pci_aer_available()) {
590 if (aer_acpi_firmware_first()) 553 if (aer_acpi_firmware_first())
591 dev_dbg(root->bus->bridge, 554 dev_dbg(&device->dev,
592 "PCIe errors handled by BIOS.\n"); 555 "PCIe errors handled by BIOS.\n");
593 else 556 else
594 flags |= OSC_PCI_EXPRESS_AER_CONTROL; 557 flags |= OSC_PCI_EXPRESS_AER_CONTROL;
595 } 558 }
596 559
597 dev_info(root->bus->bridge, 560 dev_info(&device->dev,
598 "Requesting ACPI _OSC control (0x%02x)\n", flags); 561 "Requesting ACPI _OSC control (0x%02x)\n", flags);
599 562
600 status = acpi_pci_osc_control_set(device->handle, &flags, 563 status = acpi_pci_osc_control_set(device->handle, &flags,
601 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); 564 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
602 if (ACPI_SUCCESS(status)) { 565 if (ACPI_SUCCESS(status)) {
603 dev_info(root->bus->bridge, 566 is_osc_granted = true;
567 dev_info(&device->dev,
604 "ACPI _OSC control (0x%02x) granted\n", flags); 568 "ACPI _OSC control (0x%02x) granted\n", flags);
605 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) {
606 /*
607 * We have ASPM control, but the FADT indicates
608 * that it's unsupported. Clear it.
609 */
610 pcie_clear_aspm(root->bus);
611 }
612 } else { 569 } else {
613 dev_info(root->bus->bridge, 570 is_osc_granted = false;
571 dev_info(&device->dev,
614 "ACPI _OSC request failed (%s), " 572 "ACPI _OSC request failed (%s), "
615 "returned control mask: 0x%02x\n", 573 "returned control mask: 0x%02x\n",
616 acpi_format_exception(status), flags); 574 acpi_format_exception(status), flags);
617 pr_info("ACPI _OSC control for PCIe not granted, "
618 "disabling ASPM\n");
619 pcie_no_aspm();
620 } 575 }
621 } else { 576 } else {
622 dev_info(root->bus->bridge, 577 dev_info(&device->dev,
623 "Unable to request _OSC control " 578 "Unable to request _OSC control "
624 "(_OSC support mask: 0x%02x)\n", flags); 579 "(_OSC support mask: 0x%02x)\n", flags);
580 }
581
582 /*
583 * TBD: Need PCI interface for enumeration/configuration of roots.
584 */
585
586 mutex_lock(&acpi_pci_root_lock);
587 list_add_tail(&root->node, &acpi_pci_roots);
588 mutex_unlock(&acpi_pci_root_lock);
589
590 /*
591 * Scan the Root Bridge
592 * --------------------
593 * Must do this prior to any attempt to bind the root device, as the
594 * PCI namespace does not get created until this call is made (and
595 * thus the root bridge's pci_dev does not exist).
596 */
597 root->bus = pci_acpi_scan_root(root);
598 if (!root->bus) {
599 printk(KERN_ERR PREFIX
600 "Bus %04x:%02x not present in PCI namespace\n",
601 root->segment, (unsigned int)root->secondary.start);
602 result = -ENODEV;
603 goto out_del_root;
604 }
605
606 /*
607 * Attach ACPI-PCI Context
608 * -----------------------
609 * Thus binding the ACPI and PCI devices.
610 */
611 result = acpi_pci_bind_root(device);
612 if (result)
613 goto out_del_root;
614
615 /*
616 * Scan and bind all _ADR-Based Devices
617 */
618 list_for_each_entry(child, &device->children, node)
619 acpi_pci_bridge_scan(child);
620
621 /* ASPM setting */
622 if (is_osc_granted) {
623 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
624 pcie_clear_aspm(root->bus);
625 } else {
626 pr_info("ACPI _OSC control for PCIe not granted, "
627 "disabling ASPM\n");
628 pcie_no_aspm();
625 } 629 }
626 630
627 pci_acpi_add_bus_pm_notifier(device, root->bus); 631 pci_acpi_add_bus_pm_notifier(device, root->bus);
@@ -634,6 +638,8 @@ out_del_root:
634 mutex_lock(&acpi_pci_root_lock); 638 mutex_lock(&acpi_pci_root_lock);
635 list_del(&root->node); 639 list_del(&root->node);
636 mutex_unlock(&acpi_pci_root_lock); 640 mutex_unlock(&acpi_pci_root_lock);
641
642 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
637end: 643end:
638 kfree(root); 644 kfree(root);
639 return result; 645 return result;
@@ -644,12 +650,19 @@ static int acpi_pci_root_start(struct acpi_device *device)
644 struct acpi_pci_root *root = acpi_driver_data(device); 650 struct acpi_pci_root *root = acpi_driver_data(device);
645 struct acpi_pci_driver *driver; 651 struct acpi_pci_driver *driver;
646 652
653 if (system_state != SYSTEM_BOOTING)
654 pci_assign_unassigned_bus_resources(root->bus);
655
647 mutex_lock(&acpi_pci_root_lock); 656 mutex_lock(&acpi_pci_root_lock);
648 list_for_each_entry(driver, &acpi_pci_drivers, node) 657 list_for_each_entry(driver, &acpi_pci_drivers, node)
649 if (driver->add) 658 if (driver->add)
650 driver->add(root); 659 driver->add(root);
651 mutex_unlock(&acpi_pci_root_lock); 660 mutex_unlock(&acpi_pci_root_lock);
652 661
662 /* need to after hot-added ioapic is registered */
663 if (system_state != SYSTEM_BOOTING)
664 pci_enable_bridges(root->bus);
665
653 pci_bus_add_devices(root->bus); 666 pci_bus_add_devices(root->bus);
654 667
655 return 0; 668 return 0;
@@ -657,17 +670,29 @@ static int acpi_pci_root_start(struct acpi_device *device)
657 670
658static int acpi_pci_root_remove(struct acpi_device *device, int type) 671static int acpi_pci_root_remove(struct acpi_device *device, int type)
659{ 672{
673 acpi_status status;
674 acpi_handle handle;
660 struct acpi_pci_root *root = acpi_driver_data(device); 675 struct acpi_pci_root *root = acpi_driver_data(device);
661 struct acpi_pci_driver *driver; 676 struct acpi_pci_driver *driver;
662 677
678 pci_stop_root_bus(root->bus);
679
663 mutex_lock(&acpi_pci_root_lock); 680 mutex_lock(&acpi_pci_root_lock);
664 list_for_each_entry(driver, &acpi_pci_drivers, node) 681 list_for_each_entry_reverse(driver, &acpi_pci_drivers, node)
665 if (driver->remove) 682 if (driver->remove)
666 driver->remove(root); 683 driver->remove(root);
684 mutex_unlock(&acpi_pci_root_lock);
667 685
668 device_set_run_wake(root->bus->bridge, false); 686 device_set_run_wake(root->bus->bridge, false);
669 pci_acpi_remove_bus_pm_notifier(device); 687 pci_acpi_remove_bus_pm_notifier(device);
670 688
689 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
690 if (ACPI_SUCCESS(status))
691 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
692
693 pci_remove_root_bus(root->bus);
694
695 mutex_lock(&acpi_pci_root_lock);
671 list_del(&root->node); 696 list_del(&root->node);
672 mutex_unlock(&acpi_pci_root_lock); 697 mutex_unlock(&acpi_pci_root_lock);
673 kfree(root); 698 kfree(root);
diff --git a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
index aef45d3113ba..3dee68612c9e 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
@@ -3307,7 +3307,7 @@ static void config_pcie(struct adapter *adap)
3307 G_NUMFSTTRNSEQRX(t3_read_reg(adap, A_PCIE_MODE)); 3307 G_NUMFSTTRNSEQRX(t3_read_reg(adap, A_PCIE_MODE));
3308 log2_width = fls(adap->params.pci.width) - 1; 3308 log2_width = fls(adap->params.pci.width) - 1;
3309 acklat = ack_lat[log2_width][pldsize]; 3309 acklat = ack_lat[log2_width][pldsize];
3310 if (val & 1) /* check LOsEnable */ 3310 if (val & PCI_EXP_LNKCTL_ASPM_L0S) /* check LOsEnable */
3311 acklat += fst_trn_tx * 4; 3311 acklat += fst_trn_tx * 4;
3312 rpllmt = rpl_tmr[log2_width][pldsize] + fst_trn_rx * 4; 3312 rpllmt = rpl_tmr[log2_width][pldsize] + fst_trn_rx * 4;
3313 3313
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index 8e9b826f878b..7ae73fbd9136 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -114,23 +114,23 @@ static void ath_pci_aspm_init(struct ath_common *common)
114 114
115 if ((ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) && 115 if ((ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) &&
116 (AR_SREV_9285(ah))) { 116 (AR_SREV_9285(ah))) {
117 /* Bluetooth coexistance requires disabling ASPM. */ 117 /* Bluetooth coexistence requires disabling ASPM. */
118 pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, 118 pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL,
119 PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); 119 PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1);
120 120
121 /* 121 /*
122 * Both upstream and downstream PCIe components should 122 * Both upstream and downstream PCIe components should
123 * have the same ASPM settings. 123 * have the same ASPM settings.
124 */ 124 */
125 pcie_capability_clear_word(parent, PCI_EXP_LNKCTL, 125 pcie_capability_clear_word(parent, PCI_EXP_LNKCTL,
126 PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); 126 PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1);
127 127
128 ath_info(common, "Disabling ASPM since BTCOEX is enabled\n"); 128 ath_info(common, "Disabling ASPM since BTCOEX is enabled\n");
129 return; 129 return;
130 } 130 }
131 131
132 pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm); 132 pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm);
133 if (aspm & (PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1)) { 133 if (aspm & (PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1)) {
134 ah->aspm_enabled = true; 134 ah->aspm_enabled = true;
135 /* Initialize PCIe PM and SERDES registers. */ 135 /* Initialize PCIe PM and SERDES registers. */
136 ath9k_hw_configpcipowersave(ah, false); 136 ath9k_hw_configpcipowersave(ah, false);
diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h
index 2d092f328547..1b15b0b2292b 100644
--- a/drivers/net/wireless/iwlegacy/4965.h
+++ b/drivers/net/wireless/iwlegacy/4965.h
@@ -917,10 +917,6 @@ struct il4965_scd_bc_tbl {
917/* PCI registers */ 917/* PCI registers */
918#define PCI_CFG_RETRY_TIMEOUT 0x041 918#define PCI_CFG_RETRY_TIMEOUT 0x041
919 919
920/* PCI register values */
921#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01
922#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02
923
924#define IL4965_DEFAULT_TX_RETRY 15 920#define IL4965_DEFAULT_TX_RETRY 15
925 921
926/* EEPROM */ 922/* EEPROM */
diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c
index 318ed3c9fe74..7e16d10a7f14 100644
--- a/drivers/net/wireless/iwlegacy/common.c
+++ b/drivers/net/wireless/iwlegacy/common.c
@@ -1183,9 +1183,10 @@ EXPORT_SYMBOL(il_power_update_mode);
1183void 1183void
1184il_power_initialize(struct il_priv *il) 1184il_power_initialize(struct il_priv *il)
1185{ 1185{
1186 u16 lctl = il_pcie_link_ctl(il); 1186 u16 lctl;
1187 1187
1188 il->power_data.pci_pm = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); 1188 pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl);
1189 il->power_data.pci_pm = !(lctl & PCI_EXP_LNKCTL_ASPM_L0S);
1189 1190
1190 il->power_data.debug_sleep_level_override = -1; 1191 il->power_data.debug_sleep_level_override = -1;
1191 1192
@@ -4233,9 +4234,8 @@ il_apm_init(struct il_priv *il)
4233 * power savings, even without L1. 4234 * power savings, even without L1.
4234 */ 4235 */
4235 if (il->cfg->set_l0s) { 4236 if (il->cfg->set_l0s) {
4236 lctl = il_pcie_link_ctl(il); 4237 pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &lctl);
4237 if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == 4238 if (lctl & PCI_EXP_LNKCTL_ASPM_L1) {
4238 PCI_CFG_LINK_CTRL_VAL_L1_EN) {
4239 /* L1-ASPM enabled; disable(!) L0S */ 4239 /* L1-ASPM enabled; disable(!) L0S */
4240 il_set_bit(il, CSR_GIO_REG, 4240 il_set_bit(il, CSR_GIO_REG,
4241 CSR_GIO_REG_VAL_L0S_ENABLED); 4241 CSR_GIO_REG_VAL_L0S_ENABLED);
diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h
index e254cba4557a..a9a569f432fb 100644
--- a/drivers/net/wireless/iwlegacy/common.h
+++ b/drivers/net/wireless/iwlegacy/common.h
@@ -1829,14 +1829,6 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd);
1829 * PCI * 1829 * PCI *
1830 *****************************************************/ 1830 *****************************************************/
1831 1831
1832static inline u16
1833il_pcie_link_ctl(struct il_priv *il)
1834{
1835 u16 pci_lnk_ctl;
1836 pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &pci_lnk_ctl);
1837 return pci_lnk_ctl;
1838}
1839
1840void il_bg_watchdog(unsigned long data); 1832void il_bg_watchdog(unsigned long data);
1841u32 il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval); 1833u32 il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval);
1842__le32 il_add_beacon_time(struct il_priv *il, u32 base, u32 addon, 1834__le32 il_add_beacon_time(struct il_priv *il, u32 base, u32 addon,
@@ -2434,10 +2426,6 @@ struct il_tfd {
2434/* PCI registers */ 2426/* PCI registers */
2435#define PCI_CFG_RETRY_TIMEOUT 0x041 2427#define PCI_CFG_RETRY_TIMEOUT 0x041
2436 2428
2437/* PCI register values */
2438#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01
2439#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02
2440
2441struct il_rate_info { 2429struct il_rate_info {
2442 u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ 2430 u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */
2443 u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */ 2431 u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index d66cad4a7d6a..35708b959ad6 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -94,8 +94,6 @@ static void iwl_pcie_set_pwr_vmain(struct iwl_trans *trans)
94 94
95/* PCI registers */ 95/* PCI registers */
96#define PCI_CFG_RETRY_TIMEOUT 0x041 96#define PCI_CFG_RETRY_TIMEOUT 0x041
97#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01
98#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02
99 97
100static void iwl_pcie_apm_config(struct iwl_trans *trans) 98static void iwl_pcie_apm_config(struct iwl_trans *trans)
101{ 99{
@@ -111,9 +109,7 @@ static void iwl_pcie_apm_config(struct iwl_trans *trans)
111 * power savings, even without L1. 109 * power savings, even without L1.
112 */ 110 */
113 pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_LNKCTL, &lctl); 111 pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_LNKCTL, &lctl);
114 112 if (lctl & PCI_EXP_LNKCTL_ASPM_L1) {
115 if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) ==
116 PCI_CFG_LINK_CTRL_VAL_L1_EN) {
117 /* L1-ASPM enabled; disable(!) L0S */ 113 /* L1-ASPM enabled; disable(!) L0S */
118 iwl_set_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); 114 iwl_set_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
119 dev_info(trans->dev, "L1 Enabled; Disabling L0S\n"); 115 dev_info(trans->dev, "L1 Enabled; Disabling L0S\n");
@@ -122,7 +118,7 @@ static void iwl_pcie_apm_config(struct iwl_trans *trans)
122 iwl_clear_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); 118 iwl_clear_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
123 dev_info(trans->dev, "L1 Disabled; Enabling L0S\n"); 119 dev_info(trans->dev, "L1 Disabled; Enabling L0S\n");
124 } 120 }
125 trans->pm_support = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); 121 trans->pm_support = !(lctl & PCI_EXP_LNKCTL_ASPM_L0S);
126} 122}
127 123
128/* 124/*
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index a543746fb354..ad6a8b635692 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -170,6 +170,11 @@ int pci_bus_add_device(struct pci_dev *dev)
170 int retval; 170 int retval;
171 171
172 pci_fixup_device(pci_fixup_final, dev); 172 pci_fixup_device(pci_fixup_final, dev);
173
174 retval = pcibios_add_device(dev);
175 if (retval)
176 return retval;
177
173 retval = device_add(&dev->dev); 178 retval = device_add(&dev->dev);
174 if (retval) 179 if (retval)
175 return retval; 180 return retval;
diff --git a/drivers/pci/ioapic.c b/drivers/pci/ioapic.c
index 2eca902a4283..3c6bbdd059a4 100644
--- a/drivers/pci/ioapic.c
+++ b/drivers/pci/ioapic.c
@@ -125,3 +125,5 @@ static void __exit ioapic_exit(void)
125 125
126module_init(ioapic_init); 126module_init(ioapic_init);
127module_exit(ioapic_exit); 127module_exit(ioapic_exit);
128
129MODULE_LICENSE("GPL");
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index aeccc911abb8..bafd2bbcaf65 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -106,7 +106,7 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
106 virtfn->resource[i].name = pci_name(virtfn); 106 virtfn->resource[i].name = pci_name(virtfn);
107 virtfn->resource[i].flags = res->flags; 107 virtfn->resource[i].flags = res->flags;
108 size = resource_size(res); 108 size = resource_size(res);
109 do_div(size, iov->total); 109 do_div(size, iov->total_VFs);
110 virtfn->resource[i].start = res->start + size * id; 110 virtfn->resource[i].start = res->start + size * id;
111 virtfn->resource[i].end = virtfn->resource[i].start + size - 1; 111 virtfn->resource[i].end = virtfn->resource[i].start + size - 1;
112 rc = request_resource(res, &virtfn->resource[i]); 112 rc = request_resource(res, &virtfn->resource[i]);
@@ -194,7 +194,7 @@ static int sriov_migration(struct pci_dev *dev)
194 u16 status; 194 u16 status;
195 struct pci_sriov *iov = dev->sriov; 195 struct pci_sriov *iov = dev->sriov;
196 196
197 if (!iov->nr_virtfn) 197 if (!iov->num_VFs)
198 return 0; 198 return 0;
199 199
200 if (!(iov->cap & PCI_SRIOV_CAP_VFM)) 200 if (!(iov->cap & PCI_SRIOV_CAP_VFM))
@@ -216,7 +216,7 @@ static void sriov_migration_task(struct work_struct *work)
216 u16 status; 216 u16 status;
217 struct pci_sriov *iov = container_of(work, struct pci_sriov, mtask); 217 struct pci_sriov *iov = container_of(work, struct pci_sriov, mtask);
218 218
219 for (i = iov->initial; i < iov->nr_virtfn; i++) { 219 for (i = iov->initial_VFs; i < iov->num_VFs; i++) {
220 state = readb(iov->mstate + i); 220 state = readb(iov->mstate + i);
221 if (state == PCI_SRIOV_VFM_MI) { 221 if (state == PCI_SRIOV_VFM_MI) {
222 writeb(PCI_SRIOV_VFM_AV, iov->mstate + i); 222 writeb(PCI_SRIOV_VFM_AV, iov->mstate + i);
@@ -244,7 +244,7 @@ static int sriov_enable_migration(struct pci_dev *dev, int nr_virtfn)
244 resource_size_t pa; 244 resource_size_t pa;
245 struct pci_sriov *iov = dev->sriov; 245 struct pci_sriov *iov = dev->sriov;
246 246
247 if (nr_virtfn <= iov->initial) 247 if (nr_virtfn <= iov->initial_VFs)
248 return 0; 248 return 0;
249 249
250 pci_read_config_dword(dev, iov->pos + PCI_SRIOV_VFM, &table); 250 pci_read_config_dword(dev, iov->pos + PCI_SRIOV_VFM, &table);
@@ -294,15 +294,15 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
294 if (!nr_virtfn) 294 if (!nr_virtfn)
295 return 0; 295 return 0;
296 296
297 if (iov->nr_virtfn) 297 if (iov->num_VFs)
298 return -EINVAL; 298 return -EINVAL;
299 299
300 pci_read_config_word(dev, iov->pos + PCI_SRIOV_INITIAL_VF, &initial); 300 pci_read_config_word(dev, iov->pos + PCI_SRIOV_INITIAL_VF, &initial);
301 if (initial > iov->total || 301 if (initial > iov->total_VFs ||
302 (!(iov->cap & PCI_SRIOV_CAP_VFM) && (initial != iov->total))) 302 (!(iov->cap & PCI_SRIOV_CAP_VFM) && (initial != iov->total_VFs)))
303 return -EIO; 303 return -EIO;
304 304
305 if (nr_virtfn < 0 || nr_virtfn > iov->total || 305 if (nr_virtfn < 0 || nr_virtfn > iov->total_VFs ||
306 (!(iov->cap & PCI_SRIOV_CAP_VFM) && (nr_virtfn > initial))) 306 (!(iov->cap & PCI_SRIOV_CAP_VFM) && (nr_virtfn > initial)))
307 return -EINVAL; 307 return -EINVAL;
308 308
@@ -359,7 +359,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
359 msleep(100); 359 msleep(100);
360 pci_cfg_access_unlock(dev); 360 pci_cfg_access_unlock(dev);
361 361
362 iov->initial = initial; 362 iov->initial_VFs = initial;
363 if (nr_virtfn < initial) 363 if (nr_virtfn < initial)
364 initial = nr_virtfn; 364 initial = nr_virtfn;
365 365
@@ -376,7 +376,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
376 } 376 }
377 377
378 kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); 378 kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE);
379 iov->nr_virtfn = nr_virtfn; 379 iov->num_VFs = nr_virtfn;
380 380
381 return 0; 381 return 0;
382 382
@@ -401,13 +401,13 @@ static void sriov_disable(struct pci_dev *dev)
401 int i; 401 int i;
402 struct pci_sriov *iov = dev->sriov; 402 struct pci_sriov *iov = dev->sriov;
403 403
404 if (!iov->nr_virtfn) 404 if (!iov->num_VFs)
405 return; 405 return;
406 406
407 if (iov->cap & PCI_SRIOV_CAP_VFM) 407 if (iov->cap & PCI_SRIOV_CAP_VFM)
408 sriov_disable_migration(dev); 408 sriov_disable_migration(dev);
409 409
410 for (i = 0; i < iov->nr_virtfn; i++) 410 for (i = 0; i < iov->num_VFs; i++)
411 virtfn_remove(dev, i, 0); 411 virtfn_remove(dev, i, 0);
412 412
413 iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE); 413 iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE);
@@ -419,7 +419,7 @@ static void sriov_disable(struct pci_dev *dev)
419 if (iov->link != dev->devfn) 419 if (iov->link != dev->devfn)
420 sysfs_remove_link(&dev->dev.kobj, "dep_link"); 420 sysfs_remove_link(&dev->dev.kobj, "dep_link");
421 421
422 iov->nr_virtfn = 0; 422 iov->num_VFs = 0;
423} 423}
424 424
425static int sriov_init(struct pci_dev *dev, int pos) 425static int sriov_init(struct pci_dev *dev, int pos)
@@ -496,7 +496,7 @@ found:
496 iov->pos = pos; 496 iov->pos = pos;
497 iov->nres = nres; 497 iov->nres = nres;
498 iov->ctrl = ctrl; 498 iov->ctrl = ctrl;
499 iov->total = total; 499 iov->total_VFs = total;
500 iov->offset = offset; 500 iov->offset = offset;
501 iov->stride = stride; 501 iov->stride = stride;
502 iov->pgsz = pgsz; 502 iov->pgsz = pgsz;
@@ -529,7 +529,7 @@ failed:
529 529
530static void sriov_release(struct pci_dev *dev) 530static void sriov_release(struct pci_dev *dev)
531{ 531{
532 BUG_ON(dev->sriov->nr_virtfn); 532 BUG_ON(dev->sriov->num_VFs);
533 533
534 if (dev != dev->sriov->dev) 534 if (dev != dev->sriov->dev)
535 pci_dev_put(dev->sriov->dev); 535 pci_dev_put(dev->sriov->dev);
@@ -554,7 +554,7 @@ static void sriov_restore_state(struct pci_dev *dev)
554 pci_update_resource(dev, i); 554 pci_update_resource(dev, i);
555 555
556 pci_write_config_dword(dev, iov->pos + PCI_SRIOV_SYS_PGSIZE, iov->pgsz); 556 pci_write_config_dword(dev, iov->pos + PCI_SRIOV_SYS_PGSIZE, iov->pgsz);
557 pci_write_config_word(dev, iov->pos + PCI_SRIOV_NUM_VF, iov->nr_virtfn); 557 pci_write_config_word(dev, iov->pos + PCI_SRIOV_NUM_VF, iov->num_VFs);
558 pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl); 558 pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);
559 if (iov->ctrl & PCI_SRIOV_CTRL_VFE) 559 if (iov->ctrl & PCI_SRIOV_CTRL_VFE)
560 msleep(100); 560 msleep(100);
@@ -661,7 +661,7 @@ int pci_iov_bus_range(struct pci_bus *bus)
661 list_for_each_entry(dev, &bus->devices, bus_list) { 661 list_for_each_entry(dev, &bus->devices, bus_list) {
662 if (!dev->is_physfn) 662 if (!dev->is_physfn)
663 continue; 663 continue;
664 busnr = virtfn_bus(dev, dev->sriov->total - 1); 664 busnr = virtfn_bus(dev, dev->sriov->total_VFs - 1);
665 if (busnr > max) 665 if (busnr > max)
666 max = busnr; 666 max = busnr;
667 } 667 }
@@ -729,9 +729,56 @@ EXPORT_SYMBOL_GPL(pci_sriov_migration);
729 */ 729 */
730int pci_num_vf(struct pci_dev *dev) 730int pci_num_vf(struct pci_dev *dev)
731{ 731{
732 if (!dev || !dev->is_physfn) 732 if (!dev->is_physfn)
733 return 0; 733 return 0;
734 else 734
735 return dev->sriov->nr_virtfn; 735 return dev->sriov->num_VFs;
736} 736}
737EXPORT_SYMBOL_GPL(pci_num_vf); 737EXPORT_SYMBOL_GPL(pci_num_vf);
738
739/**
740 * pci_sriov_set_totalvfs -- reduce the TotalVFs available
741 * @dev: the PCI PF device
742 * numvfs: number that should be used for TotalVFs supported
743 *
744 * Should be called from PF driver's probe routine with
745 * device's mutex held.
746 *
747 * Returns 0 if PF is an SRIOV-capable device and
748 * value of numvfs valid. If not a PF with VFS, return -EINVAL;
749 * if VFs already enabled, return -EBUSY.
750 */
751int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs)
752{
753 if (!dev->is_physfn || (numvfs > dev->sriov->total_VFs))
754 return -EINVAL;
755
756 /* Shouldn't change if VFs already enabled */
757 if (dev->sriov->ctrl & PCI_SRIOV_CTRL_VFE)
758 return -EBUSY;
759 else
760 dev->sriov->driver_max_VFs = numvfs;
761
762 return 0;
763}
764EXPORT_SYMBOL_GPL(pci_sriov_set_totalvfs);
765
766/**
767 * pci_sriov_get_totalvfs -- get total VFs supported on this devic3
768 * @dev: the PCI PF device
769 *
770 * For a PCIe device with SRIOV support, return the PCIe
771 * SRIOV capability value of TotalVFs or the value of driver_max_VFs
772 * if the driver reduced it. Otherwise, -EINVAL.
773 */
774int pci_sriov_get_totalvfs(struct pci_dev *dev)
775{
776 if (!dev->is_physfn)
777 return -EINVAL;
778
779 if (dev->sriov->driver_max_VFs)
780 return dev->sriov->driver_max_VFs;
781
782 return dev->sriov->total_VFs;
783}
784EXPORT_SYMBOL_GPL(pci_sriov_get_totalvfs);
diff --git a/drivers/pci/irq.c b/drivers/pci/irq.c
index e5f69a43b1b1..b008cf86b9c3 100644
--- a/drivers/pci/irq.c
+++ b/drivers/pci/irq.c
@@ -14,11 +14,11 @@ static void pci_note_irq_problem(struct pci_dev *pdev, const char *reason)
14{ 14{
15 struct pci_dev *parent = to_pci_dev(pdev->dev.parent); 15 struct pci_dev *parent = to_pci_dev(pdev->dev.parent);
16 16
17 dev_printk(KERN_ERR, &pdev->dev, 17 dev_err(&pdev->dev,
18 "Potentially misrouted IRQ (Bridge %s %04x:%04x)\n", 18 "Potentially misrouted IRQ (Bridge %s %04x:%04x)\n",
19 dev_name(&parent->dev), parent->vendor, parent->device); 19 dev_name(&parent->dev), parent->vendor, parent->device);
20 dev_printk(KERN_ERR, &pdev->dev, "%s\n", reason); 20 dev_err(&pdev->dev, "%s\n", reason);
21 dev_printk(KERN_ERR, &pdev->dev, "Please report to linux-kernel@vger.kernel.org\n"); 21 dev_err(&pdev->dev, "Please report to linux-kernel@vger.kernel.org\n");
22 WARN_ON(1); 22 WARN_ON(1);
23} 23}
24 24
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 1dc78c5cabf8..f79cbcd3944b 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -248,31 +248,26 @@ struct drv_dev_and_id {
248static long local_pci_probe(void *_ddi) 248static long local_pci_probe(void *_ddi)
249{ 249{
250 struct drv_dev_and_id *ddi = _ddi; 250 struct drv_dev_and_id *ddi = _ddi;
251 struct device *dev = &ddi->dev->dev; 251 struct pci_dev *pci_dev = ddi->dev;
252 struct device *parent = dev->parent; 252 struct pci_driver *pci_drv = ddi->drv;
253 struct device *dev = &pci_dev->dev;
253 int rc; 254 int rc;
254 255
255 /* The parent bridge must be in active state when probing */ 256 /*
256 if (parent) 257 * Unbound PCI devices are always put in D0, regardless of
257 pm_runtime_get_sync(parent); 258 * runtime PM status. During probe, the device is set to
258 /* Unbound PCI devices are always set to disabled and suspended. 259 * active and the usage count is incremented. If the driver
259 * During probe, the device is set to enabled and active and the 260 * supports runtime PM, it should call pm_runtime_put_noidle()
260 * usage count is incremented. If the driver supports runtime PM, 261 * in its probe routine and pm_runtime_get_noresume() in its
261 * it should call pm_runtime_put_noidle() in its probe routine and 262 * remove routine.
262 * pm_runtime_get_noresume() in its remove routine.
263 */ 263 */
264 pm_runtime_get_noresume(dev); 264 pm_runtime_get_sync(dev);
265 pm_runtime_set_active(dev); 265 pci_dev->driver = pci_drv;
266 pm_runtime_enable(dev); 266 rc = pci_drv->probe(pci_dev, ddi->id);
267
268 rc = ddi->drv->probe(ddi->dev, ddi->id);
269 if (rc) { 267 if (rc) {
270 pm_runtime_disable(dev); 268 pci_dev->driver = NULL;
271 pm_runtime_set_suspended(dev); 269 pm_runtime_put_sync(dev);
272 pm_runtime_put_noidle(dev);
273 } 270 }
274 if (parent)
275 pm_runtime_put(parent);
276 return rc; 271 return rc;
277} 272}
278 273
@@ -322,10 +317,8 @@ __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev)
322 id = pci_match_device(drv, pci_dev); 317 id = pci_match_device(drv, pci_dev);
323 if (id) 318 if (id)
324 error = pci_call_probe(drv, pci_dev, id); 319 error = pci_call_probe(drv, pci_dev, id);
325 if (error >= 0) { 320 if (error >= 0)
326 pci_dev->driver = drv;
327 error = 0; 321 error = 0;
328 }
329 } 322 }
330 return error; 323 return error;
331} 324}
@@ -361,9 +354,7 @@ static int pci_device_remove(struct device * dev)
361 } 354 }
362 355
363 /* Undo the runtime PM settings in local_pci_probe() */ 356 /* Undo the runtime PM settings in local_pci_probe() */
364 pm_runtime_disable(dev); 357 pm_runtime_put_sync(dev);
365 pm_runtime_set_suspended(dev);
366 pm_runtime_put_noidle(dev);
367 358
368 /* 359 /*
369 * If the device is still on, set the power state as "unknown", 360 * If the device is still on, set the power state as "unknown",
@@ -986,6 +977,13 @@ static int pci_pm_runtime_suspend(struct device *dev)
986 pci_power_t prev = pci_dev->current_state; 977 pci_power_t prev = pci_dev->current_state;
987 int error; 978 int error;
988 979
980 /*
981 * If pci_dev->driver is not set (unbound), the device should
982 * always remain in D0 regardless of the runtime PM status
983 */
984 if (!pci_dev->driver)
985 return 0;
986
989 if (!pm || !pm->runtime_suspend) 987 if (!pm || !pm->runtime_suspend)
990 return -ENOSYS; 988 return -ENOSYS;
991 989
@@ -1007,10 +1005,10 @@ static int pci_pm_runtime_suspend(struct device *dev)
1007 return 0; 1005 return 0;
1008 } 1006 }
1009 1007
1010 if (!pci_dev->state_saved) 1008 if (!pci_dev->state_saved) {
1011 pci_save_state(pci_dev); 1009 pci_save_state(pci_dev);
1012 1010 pci_finish_runtime_suspend(pci_dev);
1013 pci_finish_runtime_suspend(pci_dev); 1011 }
1014 1012
1015 return 0; 1013 return 0;
1016} 1014}
@@ -1021,6 +1019,13 @@ static int pci_pm_runtime_resume(struct device *dev)
1021 struct pci_dev *pci_dev = to_pci_dev(dev); 1019 struct pci_dev *pci_dev = to_pci_dev(dev);
1022 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 1020 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
1023 1021
1022 /*
1023 * If pci_dev->driver is not set (unbound), the device should
1024 * always remain in D0 regardless of the runtime PM status
1025 */
1026 if (!pci_dev->driver)
1027 return 0;
1028
1024 if (!pm || !pm->runtime_resume) 1029 if (!pm || !pm->runtime_resume)
1025 return -ENOSYS; 1030 return -ENOSYS;
1026 1031
@@ -1038,8 +1043,16 @@ static int pci_pm_runtime_resume(struct device *dev)
1038 1043
1039static int pci_pm_runtime_idle(struct device *dev) 1044static int pci_pm_runtime_idle(struct device *dev)
1040{ 1045{
1046 struct pci_dev *pci_dev = to_pci_dev(dev);
1041 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 1047 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
1042 1048
1049 /*
1050 * If pci_dev->driver is not set (unbound), the device should
1051 * always remain in D0 regardless of the runtime PM status
1052 */
1053 if (!pci_dev->driver)
1054 goto out;
1055
1043 if (!pm) 1056 if (!pm)
1044 return -ENOSYS; 1057 return -ENOSYS;
1045 1058
@@ -1049,8 +1062,8 @@ static int pci_pm_runtime_idle(struct device *dev)
1049 return ret; 1062 return ret;
1050 } 1063 }
1051 1064
1065out:
1052 pm_runtime_suspend(dev); 1066 pm_runtime_suspend(dev);
1053
1054 return 0; 1067 return 0;
1055} 1068}
1056 1069
diff --git a/drivers/pci/pci-stub.c b/drivers/pci/pci-stub.c
index 775e933c2225..6e47c519c510 100644
--- a/drivers/pci/pci-stub.c
+++ b/drivers/pci/pci-stub.c
@@ -28,7 +28,7 @@ MODULE_PARM_DESC(ids, "Initial PCI IDs to add to the stub driver, format is "
28 28
29static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id) 29static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id)
30{ 30{
31 dev_printk(KERN_INFO, &dev->dev, "claimed by stub\n"); 31 dev_info(&dev->dev, "claimed by stub\n");
32 return 0; 32 return 0;
33} 33}
34 34
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 68d56f02e721..05b78b16d20b 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -401,6 +401,106 @@ static ssize_t d3cold_allowed_show(struct device *dev,
401} 401}
402#endif 402#endif
403 403
404#ifdef CONFIG_PCI_IOV
405static ssize_t sriov_totalvfs_show(struct device *dev,
406 struct device_attribute *attr,
407 char *buf)
408{
409 struct pci_dev *pdev = to_pci_dev(dev);
410
411 return sprintf(buf, "%u\n", pci_sriov_get_totalvfs(pdev));
412}
413
414
415static ssize_t sriov_numvfs_show(struct device *dev,
416 struct device_attribute *attr,
417 char *buf)
418{
419 struct pci_dev *pdev = to_pci_dev(dev);
420
421 return sprintf(buf, "%u\n", pdev->sriov->num_VFs);
422}
423
424/*
425 * num_vfs > 0; number of vfs to enable
426 * num_vfs = 0; disable all vfs
427 *
428 * Note: SRIOV spec doesn't allow partial VF
429 * disable, so its all or none.
430 */
431static ssize_t sriov_numvfs_store(struct device *dev,
432 struct device_attribute *attr,
433 const char *buf, size_t count)
434{
435 struct pci_dev *pdev = to_pci_dev(dev);
436 int num_vfs_enabled = 0;
437 int num_vfs;
438 int ret = 0;
439 u16 total;
440
441 if (kstrtoint(buf, 0, &num_vfs) < 0)
442 return -EINVAL;
443
444 /* is PF driver loaded w/callback */
445 if (!pdev->driver || !pdev->driver->sriov_configure) {
446 dev_info(&pdev->dev,
447 "Driver doesn't support SRIOV configuration via sysfs\n");
448 return -ENOSYS;
449 }
450
451 /* if enabling vf's ... */
452 total = pci_sriov_get_totalvfs(pdev);
453 /* Requested VFs to enable < totalvfs and none enabled already */
454 if ((num_vfs > 0) && (num_vfs <= total)) {
455 if (pdev->sriov->num_VFs == 0) {
456 num_vfs_enabled =
457 pdev->driver->sriov_configure(pdev, num_vfs);
458 if ((num_vfs_enabled >= 0) &&
459 (num_vfs_enabled != num_vfs)) {
460 dev_warn(&pdev->dev,
461 "Only %d VFs enabled\n",
462 num_vfs_enabled);
463 return count;
464 } else if (num_vfs_enabled < 0)
465 /* error code from driver callback */
466 return num_vfs_enabled;
467 } else if (num_vfs == pdev->sriov->num_VFs) {
468 dev_warn(&pdev->dev,
469 "%d VFs already enabled; no enable action taken\n",
470 num_vfs);
471 return count;
472 } else {
473 dev_warn(&pdev->dev,
474 "%d VFs already enabled. Disable before enabling %d VFs\n",
475 pdev->sriov->num_VFs, num_vfs);
476 return -EINVAL;
477 }
478 }
479
480 /* disable vfs */
481 if (num_vfs == 0) {
482 if (pdev->sriov->num_VFs != 0) {
483 ret = pdev->driver->sriov_configure(pdev, 0);
484 return ret ? ret : count;
485 } else {
486 dev_warn(&pdev->dev,
487 "All VFs disabled; no disable action taken\n");
488 return count;
489 }
490 }
491
492 dev_err(&pdev->dev,
493 "Invalid value for number of VFs to enable: %d\n", num_vfs);
494
495 return -EINVAL;
496}
497
498static struct device_attribute sriov_totalvfs_attr = __ATTR_RO(sriov_totalvfs);
499static struct device_attribute sriov_numvfs_attr =
500 __ATTR(sriov_numvfs, (S_IRUGO|S_IWUSR|S_IWGRP),
501 sriov_numvfs_show, sriov_numvfs_store);
502#endif /* CONFIG_PCI_IOV */
503
404struct device_attribute pci_dev_attrs[] = { 504struct device_attribute pci_dev_attrs[] = {
405 __ATTR_RO(resource), 505 __ATTR_RO(resource),
406 __ATTR_RO(vendor), 506 __ATTR_RO(vendor),
@@ -1262,29 +1362,20 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
1262 pdev->rom_attr = attr; 1362 pdev->rom_attr = attr;
1263 } 1363 }
1264 1364
1265 if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) {
1266 retval = device_create_file(&pdev->dev, &vga_attr);
1267 if (retval)
1268 goto err_rom_file;
1269 }
1270
1271 /* add platform-specific attributes */ 1365 /* add platform-specific attributes */
1272 retval = pcibios_add_platform_entries(pdev); 1366 retval = pcibios_add_platform_entries(pdev);
1273 if (retval) 1367 if (retval)
1274 goto err_vga_file; 1368 goto err_rom_file;
1275 1369
1276 /* add sysfs entries for various capabilities */ 1370 /* add sysfs entries for various capabilities */
1277 retval = pci_create_capabilities_sysfs(pdev); 1371 retval = pci_create_capabilities_sysfs(pdev);
1278 if (retval) 1372 if (retval)
1279 goto err_vga_file; 1373 goto err_rom_file;
1280 1374
1281 pci_create_firmware_label_files(pdev); 1375 pci_create_firmware_label_files(pdev);
1282 1376
1283 return 0; 1377 return 0;
1284 1378
1285err_vga_file:
1286 if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
1287 device_remove_file(&pdev->dev, &vga_attr);
1288err_rom_file: 1379err_rom_file:
1289 if (rom_size) { 1380 if (rom_size) {
1290 sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); 1381 sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr);
@@ -1370,3 +1461,62 @@ static int __init pci_sysfs_init(void)
1370} 1461}
1371 1462
1372late_initcall(pci_sysfs_init); 1463late_initcall(pci_sysfs_init);
1464
1465static struct attribute *pci_dev_dev_attrs[] = {
1466 &vga_attr.attr,
1467 NULL,
1468};
1469
1470static umode_t pci_dev_attrs_are_visible(struct kobject *kobj,
1471 struct attribute *a, int n)
1472{
1473 struct device *dev = container_of(kobj, struct device, kobj);
1474 struct pci_dev *pdev = to_pci_dev(dev);
1475
1476 if (a == &vga_attr.attr)
1477 if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
1478 return 0;
1479
1480 return a->mode;
1481}
1482
1483#ifdef CONFIG_PCI_IOV
1484static struct attribute *sriov_dev_attrs[] = {
1485 &sriov_totalvfs_attr.attr,
1486 &sriov_numvfs_attr.attr,
1487 NULL,
1488};
1489
1490static umode_t sriov_attrs_are_visible(struct kobject *kobj,
1491 struct attribute *a, int n)
1492{
1493 struct device *dev = container_of(kobj, struct device, kobj);
1494
1495 if (!dev_is_pf(dev))
1496 return 0;
1497
1498 return a->mode;
1499}
1500
1501static struct attribute_group sriov_dev_attr_group = {
1502 .attrs = sriov_dev_attrs,
1503 .is_visible = sriov_attrs_are_visible,
1504};
1505#endif /* CONFIG_PCI_IOV */
1506
1507static struct attribute_group pci_dev_attr_group = {
1508 .attrs = pci_dev_dev_attrs,
1509 .is_visible = pci_dev_attrs_are_visible,
1510};
1511
1512static const struct attribute_group *pci_dev_attr_groups[] = {
1513 &pci_dev_attr_group,
1514#ifdef CONFIG_PCI_IOV
1515 &sriov_dev_attr_group,
1516#endif
1517 NULL,
1518};
1519
1520struct device_type pci_dev_type = {
1521 .groups = pci_dev_attr_groups,
1522};
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index bdf66b500f22..5cb5820fae40 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1333,6 +1333,19 @@ void pcim_pin_device(struct pci_dev *pdev)
1333 dr->pinned = 1; 1333 dr->pinned = 1;
1334} 1334}
1335 1335
1336/*
1337 * pcibios_add_device - provide arch specific hooks when adding device dev
1338 * @dev: the PCI device being added
1339 *
1340 * Permits the platform to provide architecture specific functionality when
1341 * devices are added. This is the default implementation. Architecture
1342 * implementations can override this.
1343 */
1344int __weak pcibios_add_device (struct pci_dev *dev)
1345{
1346 return 0;
1347}
1348
1336/** 1349/**
1337 * pcibios_disable_device - disable arch specific PCI resources for device dev 1350 * pcibios_disable_device - disable arch specific PCI resources for device dev
1338 * @dev: the PCI device to disable 1351 * @dev: the PCI device to disable
@@ -1578,15 +1591,25 @@ void pci_pme_active(struct pci_dev *dev, bool enable)
1578 1591
1579 pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr); 1592 pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr);
1580 1593
1581 /* PCI (as opposed to PCIe) PME requires that the device have 1594 /*
1582 its PME# line hooked up correctly. Not all hardware vendors 1595 * PCI (as opposed to PCIe) PME requires that the device have
1583 do this, so the PME never gets delivered and the device 1596 * its PME# line hooked up correctly. Not all hardware vendors
1584 remains asleep. The easiest way around this is to 1597 * do this, so the PME never gets delivered and the device
1585 periodically walk the list of suspended devices and check 1598 * remains asleep. The easiest way around this is to
1586 whether any have their PME flag set. The assumption is that 1599 * periodically walk the list of suspended devices and check
1587 we'll wake up often enough anyway that this won't be a huge 1600 * whether any have their PME flag set. The assumption is that
1588 hit, and the power savings from the devices will still be a 1601 * we'll wake up often enough anyway that this won't be a huge
1589 win. */ 1602 * hit, and the power savings from the devices will still be a
1603 * win.
1604 *
1605 * Although PCIe uses in-band PME message instead of PME# line
1606 * to report PME, PME does not work for some PCIe devices in
1607 * reality. For example, there are devices that set their PME
1608 * status bits, but don't really bother to send a PME message;
1609 * there are PCI Express Root Ports that don't bother to
1610 * trigger interrupts when they receive PME messages from the
1611 * devices below. So PME poll is used for PCIe devices too.
1612 */
1590 1613
1591 if (dev->pme_poll) { 1614 if (dev->pme_poll) {
1592 struct pci_pme_device *pme_dev; 1615 struct pci_pme_device *pme_dev;
@@ -1900,6 +1923,8 @@ void pci_pm_init(struct pci_dev *dev)
1900 u16 pmc; 1923 u16 pmc;
1901 1924
1902 pm_runtime_forbid(&dev->dev); 1925 pm_runtime_forbid(&dev->dev);
1926 pm_runtime_set_active(&dev->dev);
1927 pm_runtime_enable(&dev->dev);
1903 device_enable_async_suspend(&dev->dev); 1928 device_enable_async_suspend(&dev->dev);
1904 dev->wakeup_prepared = false; 1929 dev->wakeup_prepared = false;
1905 1930
@@ -3865,14 +3890,13 @@ static void pci_no_domains(void)
3865} 3890}
3866 3891
3867/** 3892/**
3868 * pci_ext_cfg_enabled - can we access extended PCI config space? 3893 * pci_ext_cfg_avail - can we access extended PCI config space?
3869 * @dev: The PCI device of the root bridge.
3870 * 3894 *
3871 * Returns 1 if we can access PCI extended config space (offsets 3895 * Returns 1 if we can access PCI extended config space (offsets
3872 * greater than 0xff). This is the default implementation. Architecture 3896 * greater than 0xff). This is the default implementation. Architecture
3873 * implementations can override this. 3897 * implementations can override this.
3874 */ 3898 */
3875int __weak pci_ext_cfg_avail(struct pci_dev *dev) 3899int __weak pci_ext_cfg_avail(void)
3876{ 3900{
3877 return 1; 3901 return 1;
3878} 3902}
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index e253881c4275..e8518292826f 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -158,6 +158,7 @@ static inline int pci_no_d1d2(struct pci_dev *dev)
158} 158}
159extern struct device_attribute pci_dev_attrs[]; 159extern struct device_attribute pci_dev_attrs[];
160extern struct device_attribute pcibus_dev_attrs[]; 160extern struct device_attribute pcibus_dev_attrs[];
161extern struct device_type pci_dev_type;
161extern struct bus_attribute pci_bus_attrs[]; 162extern struct bus_attribute pci_bus_attrs[];
162 163
163 164
@@ -229,13 +230,14 @@ struct pci_sriov {
229 int nres; /* number of resources */ 230 int nres; /* number of resources */
230 u32 cap; /* SR-IOV Capabilities */ 231 u32 cap; /* SR-IOV Capabilities */
231 u16 ctrl; /* SR-IOV Control */ 232 u16 ctrl; /* SR-IOV Control */
232 u16 total; /* total VFs associated with the PF */ 233 u16 total_VFs; /* total VFs associated with the PF */
233 u16 initial; /* initial VFs associated with the PF */ 234 u16 initial_VFs; /* initial VFs associated with the PF */
234 u16 nr_virtfn; /* number of VFs available */ 235 u16 num_VFs; /* number of VFs available */
235 u16 offset; /* first VF Routing ID offset */ 236 u16 offset; /* first VF Routing ID offset */
236 u16 stride; /* following VF stride */ 237 u16 stride; /* following VF stride */
237 u32 pgsz; /* page size for BAR alignment */ 238 u32 pgsz; /* page size for BAR alignment */
238 u8 link; /* Function Dependency Link */ 239 u8 link; /* Function Dependency Link */
240 u16 driver_max_VFs; /* max num VFs driver supports */
239 struct pci_dev *dev; /* lowest numbered PF */ 241 struct pci_dev *dev; /* lowest numbered PF */
240 struct pci_dev *self; /* this PF */ 242 struct pci_dev *self; /* this PF */
241 struct mutex lock; /* lock for VF bus */ 243 struct mutex lock; /* lock for VF bus */
diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h
index 94a7598eb262..22f840f4dda1 100644
--- a/drivers/pci/pcie/aer/aerdrv.h
+++ b/drivers/pci/pcie/aer/aerdrv.h
@@ -87,6 +87,9 @@ struct aer_broadcast_data {
87static inline pci_ers_result_t merge_result(enum pci_ers_result orig, 87static inline pci_ers_result_t merge_result(enum pci_ers_result orig,
88 enum pci_ers_result new) 88 enum pci_ers_result new)
89{ 89{
90 if (new == PCI_ERS_RESULT_NO_AER_DRIVER)
91 return PCI_ERS_RESULT_NO_AER_DRIVER;
92
90 if (new == PCI_ERS_RESULT_NONE) 93 if (new == PCI_ERS_RESULT_NONE)
91 return orig; 94 return orig;
92 95
@@ -97,7 +100,7 @@ static inline pci_ers_result_t merge_result(enum pci_ers_result orig,
97 break; 100 break;
98 case PCI_ERS_RESULT_DISCONNECT: 101 case PCI_ERS_RESULT_DISCONNECT:
99 if (new == PCI_ERS_RESULT_NEED_RESET) 102 if (new == PCI_ERS_RESULT_NEED_RESET)
100 orig = new; 103 orig = PCI_ERS_RESULT_NEED_RESET;
101 break; 104 break;
102 default: 105 default:
103 break; 106 break;
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index af4e31cd3a3b..421bbc5fee32 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -232,13 +232,27 @@ static int report_error_detected(struct pci_dev *dev, void *data)
232 dev->driver ? 232 dev->driver ?
233 "no AER-aware driver" : "no driver"); 233 "no AER-aware driver" : "no driver");
234 } 234 }
235 goto out; 235
236 /*
237 * If there's any device in the subtree that does not
238 * have an error_detected callback, returning
239 * PCI_ERS_RESULT_NO_AER_DRIVER prevents calling of
240 * the subsequent mmio_enabled/slot_reset/resume
241 * callbacks of "any" device in the subtree. All the
242 * devices in the subtree are left in the error state
243 * without recovery.
244 */
245
246 if (!(dev->hdr_type & PCI_HEADER_TYPE_BRIDGE))
247 vote = PCI_ERS_RESULT_NO_AER_DRIVER;
248 else
249 vote = PCI_ERS_RESULT_NONE;
250 } else {
251 err_handler = dev->driver->err_handler;
252 vote = err_handler->error_detected(dev, result_data->state);
236 } 253 }
237 254
238 err_handler = dev->driver->err_handler;
239 vote = err_handler->error_detected(dev, result_data->state);
240 result_data->result = merge_result(result_data->result, vote); 255 result_data->result = merge_result(result_data->result, vote);
241out:
242 device_unlock(&dev->dev); 256 device_unlock(&dev->dev);
243 return 0; 257 return 0;
244} 258}
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 213753b283a6..b52630b8eada 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -242,8 +242,7 @@ static void pcie_aspm_configure_common_clock(struct pcie_link_state *link)
242 return; 242 return;
243 243
244 /* Training failed. Restore common clock configurations */ 244 /* Training failed. Restore common clock configurations */
245 dev_printk(KERN_ERR, &parent->dev, 245 dev_err(&parent->dev, "ASPM: Could not configure common clock\n");
246 "ASPM: Could not configure common clock\n");
247 list_for_each_entry(child, &linkbus->devices, bus_list) 246 list_for_each_entry(child, &linkbus->devices, bus_list)
248 pcie_capability_write_word(child, PCI_EXP_LNKCTL, 247 pcie_capability_write_word(child, PCI_EXP_LNKCTL,
249 child_reg[PCI_FUNC(child->devfn)]); 248 child_reg[PCI_FUNC(child->devfn)]);
@@ -427,7 +426,8 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
427 426
428static void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val) 427static void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val)
429{ 428{
430 pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL, 0x3, val); 429 pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL,
430 PCI_EXP_LNKCTL_ASPMC, val);
431} 431}
432 432
433static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state) 433static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state)
@@ -442,12 +442,12 @@ static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state)
442 return; 442 return;
443 /* Convert ASPM state to upstream/downstream ASPM register state */ 443 /* Convert ASPM state to upstream/downstream ASPM register state */
444 if (state & ASPM_STATE_L0S_UP) 444 if (state & ASPM_STATE_L0S_UP)
445 dwstream |= PCIE_LINK_STATE_L0S; 445 dwstream |= PCI_EXP_LNKCTL_ASPM_L0S;
446 if (state & ASPM_STATE_L0S_DW) 446 if (state & ASPM_STATE_L0S_DW)
447 upstream |= PCIE_LINK_STATE_L0S; 447 upstream |= PCI_EXP_LNKCTL_ASPM_L0S;
448 if (state & ASPM_STATE_L1) { 448 if (state & ASPM_STATE_L1) {
449 upstream |= PCIE_LINK_STATE_L1; 449 upstream |= PCI_EXP_LNKCTL_ASPM_L1;
450 dwstream |= PCIE_LINK_STATE_L1; 450 dwstream |= PCI_EXP_LNKCTL_ASPM_L1;
451 } 451 }
452 /* 452 /*
453 * Spec 2.0 suggests all functions should be configured the 453 * Spec 2.0 suggests all functions should be configured the
@@ -507,9 +507,7 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
507 */ 507 */
508 pcie_capability_read_dword(child, PCI_EXP_DEVCAP, &reg32); 508 pcie_capability_read_dword(child, PCI_EXP_DEVCAP, &reg32);
509 if (!(reg32 & PCI_EXP_DEVCAP_RBER) && !aspm_force) { 509 if (!(reg32 & PCI_EXP_DEVCAP_RBER) && !aspm_force) {
510 dev_printk(KERN_INFO, &child->dev, "disabling ASPM" 510 dev_info(&child->dev, "disabling ASPM on pre-1.1 PCIe device. You can enable it with 'pcie_aspm=force'\n");
511 " on pre-1.1 PCIe device. You can enable it"
512 " with 'pcie_aspm=force'\n");
513 return -EINVAL; 511 return -EINVAL;
514 } 512 }
515 } 513 }
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index ed129b414624..b42133afca98 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -120,8 +120,7 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *vectors, int mask)
120 * the value in this field indicates which MSI-X Table entry is 120 * the value in this field indicates which MSI-X Table entry is
121 * used to generate the interrupt message." 121 * used to generate the interrupt message."
122 */ 122 */
123 pos = pci_pcie_cap(dev); 123 pcie_capability_read_word(dev, PCI_EXP_FLAGS, &reg16);
124 pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &reg16);
125 entry = (reg16 & PCI_EXP_FLAGS_IRQ) >> 9; 124 entry = (reg16 & PCI_EXP_FLAGS_IRQ) >> 9;
126 if (entry >= nr_entries) 125 if (entry >= nr_entries)
127 goto Error; 126 goto Error;
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 3683f6094e3f..6186f03d84f3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -521,7 +521,7 @@ static unsigned char pcie_link_speed[] = {
521 521
522void pcie_update_link_speed(struct pci_bus *bus, u16 linksta) 522void pcie_update_link_speed(struct pci_bus *bus, u16 linksta)
523{ 523{
524 bus->cur_bus_speed = pcie_link_speed[linksta & 0xf]; 524 bus->cur_bus_speed = pcie_link_speed[linksta & PCI_EXP_LNKSTA_CLS];
525} 525}
526EXPORT_SYMBOL_GPL(pcie_update_link_speed); 526EXPORT_SYMBOL_GPL(pcie_update_link_speed);
527 527
@@ -579,14 +579,16 @@ static void pci_set_bus_speed(struct pci_bus *bus)
579 if (pos) { 579 if (pos) {
580 u16 status; 580 u16 status;
581 enum pci_bus_speed max; 581 enum pci_bus_speed max;
582 pci_read_config_word(bridge, pos + 2, &status);
583 582
584 if (status & 0x8000) { 583 pci_read_config_word(bridge, pos + PCI_X_BRIDGE_SSTATUS,
584 &status);
585
586 if (status & PCI_X_SSTATUS_533MHZ) {
585 max = PCI_SPEED_133MHz_PCIX_533; 587 max = PCI_SPEED_133MHz_PCIX_533;
586 } else if (status & 0x4000) { 588 } else if (status & PCI_X_SSTATUS_266MHZ) {
587 max = PCI_SPEED_133MHz_PCIX_266; 589 max = PCI_SPEED_133MHz_PCIX_266;
588 } else if (status & 0x0002) { 590 } else if (status & PCI_X_SSTATUS_133MHZ) {
589 if (((status >> 12) & 0x3) == 2) { 591 if ((status & PCI_X_SSTATUS_VERS) == PCI_X_SSTATUS_V2) {
590 max = PCI_SPEED_133MHz_PCIX_ECC; 592 max = PCI_SPEED_133MHz_PCIX_ECC;
591 } else { 593 } else {
592 max = PCI_SPEED_133MHz_PCIX; 594 max = PCI_SPEED_133MHz_PCIX;
@@ -596,7 +598,8 @@ static void pci_set_bus_speed(struct pci_bus *bus)
596 } 598 }
597 599
598 bus->max_bus_speed = max; 600 bus->max_bus_speed = max;
599 bus->cur_bus_speed = pcix_bus_speed[(status >> 6) & 0xf]; 601 bus->cur_bus_speed = pcix_bus_speed[
602 (status & PCI_X_SSTATUS_FREQ) >> 6];
600 603
601 return; 604 return;
602 } 605 }
@@ -607,7 +610,7 @@ static void pci_set_bus_speed(struct pci_bus *bus)
607 u16 linksta; 610 u16 linksta;
608 611
609 pcie_capability_read_dword(bridge, PCI_EXP_LNKCAP, &linkcap); 612 pcie_capability_read_dword(bridge, PCI_EXP_LNKCAP, &linkcap);
610 bus->max_bus_speed = pcie_link_speed[linkcap & 0xf]; 613 bus->max_bus_speed = pcie_link_speed[linkcap & PCI_EXP_LNKCAP_SLS];
611 614
612 pcie_capability_read_word(bridge, PCI_EXP_LNKSTA, &linksta); 615 pcie_capability_read_word(bridge, PCI_EXP_LNKSTA, &linksta);
613 pcie_update_link_speed(bus, linksta); 616 pcie_update_link_speed(bus, linksta);
@@ -975,6 +978,7 @@ int pci_setup_device(struct pci_dev *dev)
975 dev->sysdata = dev->bus->sysdata; 978 dev->sysdata = dev->bus->sysdata;
976 dev->dev.parent = dev->bus->bridge; 979 dev->dev.parent = dev->bus->bridge;
977 dev->dev.bus = &pci_bus_type; 980 dev->dev.bus = &pci_bus_type;
981 dev->dev.type = &pci_dev_type;
978 dev->hdr_type = hdr_type & 0x7f; 982 dev->hdr_type = hdr_type & 0x7f;
979 dev->multifunction = !!(hdr_type & 0x80); 983 dev->multifunction = !!(hdr_type & 0x80);
980 dev->error_state = pci_channel_io_normal; 984 dev->error_state = pci_channel_io_normal;
@@ -1889,6 +1893,28 @@ unsigned int __ref pci_rescan_bus_bridge_resize(struct pci_dev *bridge)
1889 return max; 1893 return max;
1890} 1894}
1891 1895
1896/**
1897 * pci_rescan_bus - scan a PCI bus for devices.
1898 * @bus: PCI bus to scan
1899 *
1900 * Scan a PCI bus and child buses for new devices, adds them,
1901 * and enables them.
1902 *
1903 * Returns the max number of subordinate bus discovered.
1904 */
1905unsigned int __ref pci_rescan_bus(struct pci_bus *bus)
1906{
1907 unsigned int max;
1908
1909 max = pci_scan_child_bus(bus);
1910 pci_assign_unassigned_bus_resources(bus);
1911 pci_enable_bridges(bus);
1912 pci_bus_add_devices(bus);
1913
1914 return max;
1915}
1916EXPORT_SYMBOL_GPL(pci_rescan_bus);
1917
1892EXPORT_SYMBOL(pci_add_new_bus); 1918EXPORT_SYMBOL(pci_add_new_bus);
1893EXPORT_SYMBOL(pci_scan_slot); 1919EXPORT_SYMBOL(pci_scan_slot);
1894EXPORT_SYMBOL(pci_scan_bridge); 1920EXPORT_SYMBOL(pci_scan_bridge);
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 22ad3ee0cf0b..8f7a6344e79e 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1790,6 +1790,45 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TOSHIBA_2,
1790 PCI_DEVICE_ID_TOSHIBA_TC86C001_IDE, 1790 PCI_DEVICE_ID_TOSHIBA_TC86C001_IDE,
1791 quirk_tc86c001_ide); 1791 quirk_tc86c001_ide);
1792 1792
1793/*
1794 * PLX PCI 9050 PCI Target bridge controller has an errata that prevents the
1795 * local configuration registers accessible via BAR0 (memory) or BAR1 (i/o)
1796 * being read correctly if bit 7 of the base address is set.
1797 * The BAR0 or BAR1 region may be disabled (size 0) or enabled (size 128).
1798 * Re-allocate the regions to a 256-byte boundary if necessary.
1799 */
1800static void quirk_plx_pci9050(struct pci_dev *dev)
1801{
1802 unsigned int bar;
1803
1804 /* Fixed in revision 2 (PCI 9052). */
1805 if (dev->revision >= 2)
1806 return;
1807 for (bar = 0; bar <= 1; bar++)
1808 if (pci_resource_len(dev, bar) == 0x80 &&
1809 (pci_resource_start(dev, bar) & 0x80)) {
1810 struct resource *r = &dev->resource[bar];
1811 dev_info(&dev->dev,
1812 "Re-allocating PLX PCI 9050 BAR %u to length 256 to avoid bit 7 bug\n",
1813 bar);
1814 r->start = 0;
1815 r->end = 0xff;
1816 }
1817}
1818DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
1819 quirk_plx_pci9050);
1820/*
1821 * The following Meilhaus (vendor ID 0x1402) device IDs (amongst others)
1822 * may be using the PLX PCI 9050: 0x0630, 0x0940, 0x0950, 0x0960, 0x100b,
1823 * 0x1400, 0x140a, 0x140b, 0x14e0, 0x14ea, 0x14eb, 0x1604, 0x1608, 0x160c,
1824 * 0x168f, 0x2000, 0x2600, 0x3000, 0x810a, 0x810b.
1825 *
1826 * Currently, device IDs 0x2000 and 0x2600 are used by the Comedi "me_daq"
1827 * driver.
1828 */
1829DECLARE_PCI_FIXUP_HEADER(0x1402, 0x2000, quirk_plx_pci9050);
1830DECLARE_PCI_FIXUP_HEADER(0x1402, 0x2600, quirk_plx_pci9050);
1831
1793static void quirk_netmos(struct pci_dev *dev) 1832static void quirk_netmos(struct pci_dev *dev)
1794{ 1833{
1795 unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4; 1834 unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4;
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index 513972f3ed13..7c0fd9252e6f 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -111,3 +111,39 @@ void pci_stop_and_remove_bus_device(struct pci_dev *dev)
111 pci_remove_bus_device(dev); 111 pci_remove_bus_device(dev);
112} 112}
113EXPORT_SYMBOL(pci_stop_and_remove_bus_device); 113EXPORT_SYMBOL(pci_stop_and_remove_bus_device);
114
115void pci_stop_root_bus(struct pci_bus *bus)
116{
117 struct pci_dev *child, *tmp;
118 struct pci_host_bridge *host_bridge;
119
120 if (!pci_is_root_bus(bus))
121 return;
122
123 host_bridge = to_pci_host_bridge(bus->bridge);
124 list_for_each_entry_safe_reverse(child, tmp,
125 &bus->devices, bus_list)
126 pci_stop_bus_device(child);
127
128 /* stop the host bridge */
129 device_del(&host_bridge->dev);
130}
131
132void pci_remove_root_bus(struct pci_bus *bus)
133{
134 struct pci_dev *child, *tmp;
135 struct pci_host_bridge *host_bridge;
136
137 if (!pci_is_root_bus(bus))
138 return;
139
140 host_bridge = to_pci_host_bridge(bus->bridge);
141 list_for_each_entry_safe(child, tmp,
142 &bus->devices, bus_list)
143 pci_remove_bus_device(child);
144 pci_remove_bus(bus);
145 host_bridge->bus = NULL;
146
147 /* remove the host bridge */
148 put_device(&host_bridge->dev);
149}
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index 0b3037ab8b93..ab886b7ee327 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -118,11 +118,17 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
118 void __iomem *rom; 118 void __iomem *rom;
119 119
120 /* 120 /*
121 * Some devices may provide ROMs via a source other than the BAR
122 */
123 if (pdev->rom && pdev->romlen) {
124 *size = pdev->romlen;
125 return phys_to_virt(pdev->rom);
126 /*
121 * IORESOURCE_ROM_SHADOW set on x86, x86_64 and IA64 supports legacy 127 * IORESOURCE_ROM_SHADOW set on x86, x86_64 and IA64 supports legacy
122 * memory map if the VGA enable bit of the Bridge Control register is 128 * memory map if the VGA enable bit of the Bridge Control register is
123 * set for embedded VGA. 129 * set for embedded VGA.
124 */ 130 */
125 if (res->flags & IORESOURCE_ROM_SHADOW) { 131 } else if (res->flags & IORESOURCE_ROM_SHADOW) {
126 /* primary video rom always starts here */ 132 /* primary video rom always starts here */
127 start = (loff_t)0xC0000; 133 start = (loff_t)0xC0000;
128 *size = 0x20000; /* cover C000:0 through E000:0 */ 134 *size = 0x20000; /* cover C000:0 through E000:0 */
@@ -181,7 +187,8 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)
181 if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_BIOS_COPY)) 187 if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_BIOS_COPY))
182 return; 188 return;
183 189
184 iounmap(rom); 190 if (!pdev->rom || !pdev->romlen)
191 iounmap(rom);
185 192
186 /* Disable again before continuing, leave enabled if pci=rom */ 193 /* Disable again before continuing, leave enabled if pci=rom */
187 if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW))) 194 if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW)))
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 1e808ca338f8..6d3591d57ea0 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1550,25 +1550,12 @@ enable_all:
1550} 1550}
1551EXPORT_SYMBOL_GPL(pci_assign_unassigned_bridge_resources); 1551EXPORT_SYMBOL_GPL(pci_assign_unassigned_bridge_resources);
1552 1552
1553#ifdef CONFIG_HOTPLUG 1553void pci_assign_unassigned_bus_resources(struct pci_bus *bus)
1554/**
1555 * pci_rescan_bus - scan a PCI bus for devices.
1556 * @bus: PCI bus to scan
1557 *
1558 * Scan a PCI bus and child buses for new devices, adds them,
1559 * and enables them.
1560 *
1561 * Returns the max number of subordinate bus discovered.
1562 */
1563unsigned int __ref pci_rescan_bus(struct pci_bus *bus)
1564{ 1554{
1565 unsigned int max;
1566 struct pci_dev *dev; 1555 struct pci_dev *dev;
1567 LIST_HEAD(add_list); /* list of resources that 1556 LIST_HEAD(add_list); /* list of resources that
1568 want additional resources */ 1557 want additional resources */
1569 1558
1570 max = pci_scan_child_bus(bus);
1571
1572 down_read(&pci_bus_sem); 1559 down_read(&pci_bus_sem);
1573 list_for_each_entry(dev, &bus->devices, bus_list) 1560 list_for_each_entry(dev, &bus->devices, bus_list)
1574 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || 1561 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
@@ -1579,11 +1566,4 @@ unsigned int __ref pci_rescan_bus(struct pci_bus *bus)
1579 up_read(&pci_bus_sem); 1566 up_read(&pci_bus_sem);
1580 __pci_bus_assign_resources(bus, &add_list, NULL); 1567 __pci_bus_assign_resources(bus, &add_list, NULL);
1581 BUG_ON(!list_empty(&add_list)); 1568 BUG_ON(!list_empty(&add_list));
1582
1583 pci_enable_bridges(bus);
1584 pci_bus_add_devices(bus);
1585
1586 return max;
1587} 1569}
1588EXPORT_SYMBOL_GPL(pci_rescan_bus);
1589#endif
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index db542f4196a4..966abc6054d7 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -1068,13 +1068,16 @@ static void __init_refok pcifront_backend_changed(struct xenbus_device *xdev,
1068 case XenbusStateInitialising: 1068 case XenbusStateInitialising:
1069 case XenbusStateInitWait: 1069 case XenbusStateInitWait:
1070 case XenbusStateInitialised: 1070 case XenbusStateInitialised:
1071 case XenbusStateClosed:
1072 break; 1071 break;
1073 1072
1074 case XenbusStateConnected: 1073 case XenbusStateConnected:
1075 pcifront_try_connect(pdev); 1074 pcifront_try_connect(pdev);
1076 break; 1075 break;
1077 1076
1077 case XenbusStateClosed:
1078 if (xdev->state == XenbusStateClosed)
1079 break;
1080 /* Missed the backend's CLOSING state -- fallthrough */
1078 case XenbusStateClosing: 1081 case XenbusStateClosing:
1079 dev_warn(&xdev->dev, "backend going away!\n"); 1082 dev_warn(&xdev->dev, "backend going away!\n");
1080 pcifront_try_disconnect(pdev); 1083 pcifront_try_disconnect(pdev);
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index bb145e4b935e..8b1d7a6a9695 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -92,8 +92,8 @@ int acpi_pci_link_free_irq(acpi_handle handle);
92 92
93/* ACPI PCI Interrupt Routing (pci_irq.c) */ 93/* ACPI PCI Interrupt Routing (pci_irq.c) */
94 94
95int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus); 95int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus);
96void acpi_pci_irq_del_prt(struct pci_bus *bus); 96void acpi_pci_irq_del_prt(int segment, int bus);
97 97
98/* ACPI PCI Device Binding (pci_bind.c) */ 98/* ACPI PCI Device Binding (pci_bind.c) */
99 99
diff --git a/include/linux/efi.h b/include/linux/efi.h
index c47ec36f3f39..b02099d0b4fc 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -196,6 +196,77 @@ typedef struct {
196 void *create_event_ex; 196 void *create_event_ex;
197} efi_boot_services_t; 197} efi_boot_services_t;
198 198
199typedef enum {
200 EfiPciIoWidthUint8,
201 EfiPciIoWidthUint16,
202 EfiPciIoWidthUint32,
203 EfiPciIoWidthUint64,
204 EfiPciIoWidthFifoUint8,
205 EfiPciIoWidthFifoUint16,
206 EfiPciIoWidthFifoUint32,
207 EfiPciIoWidthFifoUint64,
208 EfiPciIoWidthFillUint8,
209 EfiPciIoWidthFillUint16,
210 EfiPciIoWidthFillUint32,
211 EfiPciIoWidthFillUint64,
212 EfiPciIoWidthMaximum
213} EFI_PCI_IO_PROTOCOL_WIDTH;
214
215typedef enum {
216 EfiPciIoAttributeOperationGet,
217 EfiPciIoAttributeOperationSet,
218 EfiPciIoAttributeOperationEnable,
219 EfiPciIoAttributeOperationDisable,
220 EfiPciIoAttributeOperationSupported,
221 EfiPciIoAttributeOperationMaximum
222} EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION;
223
224
225typedef struct {
226 void *read;
227 void *write;
228} efi_pci_io_protocol_access_t;
229
230typedef struct {
231 void *poll_mem;
232 void *poll_io;
233 efi_pci_io_protocol_access_t mem;
234 efi_pci_io_protocol_access_t io;
235 efi_pci_io_protocol_access_t pci;
236 void *copy_mem;
237 void *map;
238 void *unmap;
239 void *allocate_buffer;
240 void *free_buffer;
241 void *flush;
242 void *get_location;
243 void *attributes;
244 void *get_bar_attributes;
245 void *set_bar_attributes;
246 uint64_t romsize;
247 void *romimage;
248} efi_pci_io_protocol;
249
250#define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001
251#define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002
252#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004
253#define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008
254#define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010
255#define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020
256#define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040
257#define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080
258#define EFI_PCI_IO_ATTRIBUTE_IO 0x0100
259#define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200
260#define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400
261#define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800
262#define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000
263#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000
264#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000
265#define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000
266#define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000
267#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000
268#define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000
269
199/* 270/*
200 * Types and defines for EFI ResetSystem 271 * Types and defines for EFI ResetSystem
201 */ 272 */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index af8229244ee2..15472d691ee6 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -333,6 +333,8 @@ struct pci_dev {
333 }; 333 };
334 struct pci_ats *ats; /* Address Translation Service */ 334 struct pci_ats *ats; /* Address Translation Service */
335#endif 335#endif
336 phys_addr_t rom; /* Physical address of ROM if it's not from the BAR */
337 size_t romlen; /* Length of ROM if it's not from the BAR */
336}; 338};
337 339
338static inline struct pci_dev *pci_physfn(struct pci_dev *dev) 340static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
@@ -538,6 +540,9 @@ enum pci_ers_result {
538 540
539 /* Device driver is fully recovered and operational */ 541 /* Device driver is fully recovered and operational */
540 PCI_ERS_RESULT_RECOVERED = (__force pci_ers_result_t) 5, 542 PCI_ERS_RESULT_RECOVERED = (__force pci_ers_result_t) 5,
543
544 /* No AER capabilities registered for the driver */
545 PCI_ERS_RESULT_NO_AER_DRIVER = (__force pci_ers_result_t) 6,
541}; 546};
542 547
543/* PCI bus error event callbacks */ 548/* PCI bus error event callbacks */
@@ -573,6 +578,7 @@ struct pci_driver {
573 int (*resume_early) (struct pci_dev *dev); 578 int (*resume_early) (struct pci_dev *dev);
574 int (*resume) (struct pci_dev *dev); /* Device woken up */ 579 int (*resume) (struct pci_dev *dev); /* Device woken up */
575 void (*shutdown) (struct pci_dev *dev); 580 void (*shutdown) (struct pci_dev *dev);
581 int (*sriov_configure) (struct pci_dev *dev, int num_vfs); /* PF pdev */
576 const struct pci_error_handlers *err_handler; 582 const struct pci_error_handlers *err_handler;
577 struct device_driver driver; 583 struct device_driver driver;
578 struct pci_dynids dynids; 584 struct pci_dynids dynids;
@@ -726,6 +732,8 @@ extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
726extern void pci_dev_put(struct pci_dev *dev); 732extern void pci_dev_put(struct pci_dev *dev);
727extern void pci_remove_bus(struct pci_bus *b); 733extern void pci_remove_bus(struct pci_bus *b);
728extern void pci_stop_and_remove_bus_device(struct pci_dev *dev); 734extern void pci_stop_and_remove_bus_device(struct pci_dev *dev);
735void pci_stop_root_bus(struct pci_bus *bus);
736void pci_remove_root_bus(struct pci_bus *bus);
729void pci_setup_cardbus(struct pci_bus *bus); 737void pci_setup_cardbus(struct pci_bus *bus);
730extern void pci_sort_breadthfirst(void); 738extern void pci_sort_breadthfirst(void);
731#define dev_is_pci(d) ((d)->bus == &pci_bus_type) 739#define dev_is_pci(d) ((d)->bus == &pci_bus_type)
@@ -970,6 +978,7 @@ void pci_bus_size_bridges(struct pci_bus *bus);
970int pci_claim_resource(struct pci_dev *, int); 978int pci_claim_resource(struct pci_dev *, int);
971void pci_assign_unassigned_resources(void); 979void pci_assign_unassigned_resources(void);
972void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge); 980void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge);
981void pci_assign_unassigned_bus_resources(struct pci_bus *bus);
973void pdev_enable_device(struct pci_dev *); 982void pdev_enable_device(struct pci_dev *);
974int pci_enable_resources(struct pci_dev *, int mask); 983int pci_enable_resources(struct pci_dev *, int mask);
975void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *), 984void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *),
@@ -1604,6 +1613,7 @@ void pcibios_disable_device(struct pci_dev *dev);
1604void pcibios_set_master(struct pci_dev *dev); 1613void pcibios_set_master(struct pci_dev *dev);
1605int pcibios_set_pcie_reset_state(struct pci_dev *dev, 1614int pcibios_set_pcie_reset_state(struct pci_dev *dev,
1606 enum pcie_reset_state state); 1615 enum pcie_reset_state state);
1616int pcibios_add_device(struct pci_dev *dev);
1607 1617
1608#ifdef CONFIG_PCI_MMCONFIG 1618#ifdef CONFIG_PCI_MMCONFIG
1609extern void __init pci_mmcfg_early_init(void); 1619extern void __init pci_mmcfg_early_init(void);
@@ -1613,7 +1623,7 @@ static inline void pci_mmcfg_early_init(void) { }
1613static inline void pci_mmcfg_late_init(void) { } 1623static inline void pci_mmcfg_late_init(void) { }
1614#endif 1624#endif
1615 1625
1616int pci_ext_cfg_avail(struct pci_dev *dev); 1626int pci_ext_cfg_avail(void);
1617 1627
1618void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); 1628void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
1619 1629
@@ -1622,6 +1632,8 @@ extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
1622extern void pci_disable_sriov(struct pci_dev *dev); 1632extern void pci_disable_sriov(struct pci_dev *dev);
1623extern irqreturn_t pci_sriov_migration(struct pci_dev *dev); 1633extern irqreturn_t pci_sriov_migration(struct pci_dev *dev);
1624extern int pci_num_vf(struct pci_dev *dev); 1634extern int pci_num_vf(struct pci_dev *dev);
1635extern int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs);
1636extern int pci_sriov_get_totalvfs(struct pci_dev *dev);
1625#else 1637#else
1626static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) 1638static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
1627{ 1639{
@@ -1638,6 +1650,14 @@ static inline int pci_num_vf(struct pci_dev *dev)
1638{ 1650{
1639 return 0; 1651 return 0;
1640} 1652}
1653static inline int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs)
1654{
1655 return 0;
1656}
1657static inline int pci_sriov_get_totalvfs(struct pci_dev *dev)
1658{
1659 return 0;
1660}
1641#endif 1661#endif
1642 1662
1643#if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE) 1663#if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE)
diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h
index 20ae747ddf34..6b7b6f1e2fd6 100644
--- a/include/uapi/linux/pci_regs.h
+++ b/include/uapi/linux/pci_regs.h
@@ -349,7 +349,7 @@
349#define PCI_AF_STATUS_TP 0x01 349#define PCI_AF_STATUS_TP 0x01
350#define PCI_CAP_AF_SIZEOF 6 /* size of AF registers */ 350#define PCI_CAP_AF_SIZEOF 6 /* size of AF registers */
351 351
352/* PCI-X registers */ 352/* PCI-X registers (Type 0 (non-bridge) devices) */
353 353
354#define PCI_X_CMD 2 /* Modes & Features */ 354#define PCI_X_CMD 2 /* Modes & Features */
355#define PCI_X_CMD_DPERR_E 0x0001 /* Data Parity Error Recovery Enable */ 355#define PCI_X_CMD_DPERR_E 0x0001 /* Data Parity Error Recovery Enable */
@@ -389,6 +389,19 @@
389#define PCI_CAP_PCIX_SIZEOF_V1 24 /* size for Version 1 */ 389#define PCI_CAP_PCIX_SIZEOF_V1 24 /* size for Version 1 */
390#define PCI_CAP_PCIX_SIZEOF_V2 PCI_CAP_PCIX_SIZEOF_V1 /* Same for v2 */ 390#define PCI_CAP_PCIX_SIZEOF_V2 PCI_CAP_PCIX_SIZEOF_V1 /* Same for v2 */
391 391
392/* PCI-X registers (Type 1 (bridge) devices) */
393
394#define PCI_X_BRIDGE_SSTATUS 2 /* Secondary Status */
395#define PCI_X_SSTATUS_64BIT 0x0001 /* Secondary AD interface is 64 bits */
396#define PCI_X_SSTATUS_133MHZ 0x0002 /* 133 MHz capable */
397#define PCI_X_SSTATUS_FREQ 0x03c0 /* Secondary Bus Mode and Frequency */
398#define PCI_X_SSTATUS_VERS 0x3000 /* PCI-X Capability Version */
399#define PCI_X_SSTATUS_V1 0x1000 /* Mode 2, not Mode 1 */
400#define PCI_X_SSTATUS_V2 0x2000 /* Mode 1 or Modes 1 and 2 */
401#define PCI_X_SSTATUS_266MHZ 0x4000 /* 266 MHz capable */
402#define PCI_X_SSTATUS_533MHZ 0x8000 /* 533 MHz capable */
403#define PCI_X_BRIDGE_STATUS 4 /* Bridge Status */
404
392/* PCI Bridge Subsystem ID registers */ 405/* PCI Bridge Subsystem ID registers */
393 406
394#define PCI_SSVID_VENDOR_ID 4 /* PCI-Bridge subsystem vendor id register */ 407#define PCI_SSVID_VENDOR_ID 4 /* PCI-Bridge subsystem vendor id register */
@@ -456,6 +469,8 @@
456#define PCI_EXP_LNKCAP_PN 0xff000000 /* Port Number */ 469#define PCI_EXP_LNKCAP_PN 0xff000000 /* Port Number */
457#define PCI_EXP_LNKCTL 16 /* Link Control */ 470#define PCI_EXP_LNKCTL 16 /* Link Control */
458#define PCI_EXP_LNKCTL_ASPMC 0x0003 /* ASPM Control */ 471#define PCI_EXP_LNKCTL_ASPMC 0x0003 /* ASPM Control */
472#define PCI_EXP_LNKCTL_ASPM_L0S 0x01 /* L0s Enable */
473#define PCI_EXP_LNKCTL_ASPM_L1 0x02 /* L1 Enable */
459#define PCI_EXP_LNKCTL_RCB 0x0008 /* Read Completion Boundary */ 474#define PCI_EXP_LNKCTL_RCB 0x0008 /* Read Completion Boundary */
460#define PCI_EXP_LNKCTL_LD 0x0010 /* Link Disable */ 475#define PCI_EXP_LNKCTL_LD 0x0010 /* Link Disable */
461#define PCI_EXP_LNKCTL_RL 0x0020 /* Retrain Link */ 476#define PCI_EXP_LNKCTL_RL 0x0020 /* Retrain Link */
@@ -544,9 +559,9 @@
544#define PCI_EXP_OBFF_WAKE_EN 0x6000 /* OBFF using WAKE# signaling */ 559#define PCI_EXP_OBFF_WAKE_EN 0x6000 /* OBFF using WAKE# signaling */
545#define PCI_CAP_EXP_ENDPOINT_SIZEOF_V2 44 /* v2 endpoints end here */ 560#define PCI_CAP_EXP_ENDPOINT_SIZEOF_V2 44 /* v2 endpoints end here */
546#define PCI_EXP_LNKCAP2 44 /* Link Capability 2 */ 561#define PCI_EXP_LNKCAP2 44 /* Link Capability 2 */
547#define PCI_EXP_LNKCAP2_SLS_2_5GB 0x01 /* Current Link Speed 2.5GT/s */ 562#define PCI_EXP_LNKCAP2_SLS_2_5GB 0x02 /* Supported Link Speed 2.5GT/s */
548#define PCI_EXP_LNKCAP2_SLS_5_0GB 0x02 /* Current Link Speed 5.0GT/s */ 563#define PCI_EXP_LNKCAP2_SLS_5_0GB 0x04 /* Supported Link Speed 5.0GT/s */
549#define PCI_EXP_LNKCAP2_SLS_8_0GB 0x04 /* Current Link Speed 8.0GT/s */ 564#define PCI_EXP_LNKCAP2_SLS_8_0GB 0x08 /* Supported Link Speed 8.0GT/s */
550#define PCI_EXP_LNKCAP2_CROSSLINK 0x100 /* Crosslink supported */ 565#define PCI_EXP_LNKCAP2_CROSSLINK 0x100 /* Crosslink supported */
551#define PCI_EXP_LNKCTL2 48 /* Link Control 2 */ 566#define PCI_EXP_LNKCTL2 48 /* Link Control 2 */
552#define PCI_EXP_LNKSTA2 50 /* Link Status 2 */ 567#define PCI_EXP_LNKSTA2 50 /* Link Status 2 */