aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pci_regs.h
diff options
context:
space:
mode:
authorMyron Stowe <myron.stowe@redhat.com>2012-06-01 17:16:37 -0400
committerBjorn Helgaas <bhelgaas@google.com>2012-06-11 22:41:23 -0400
commitc463b8cb9350cf1230cefe467a1cf279140a5437 (patch)
tree396a615ecee1763411ba5c5f61b13315aab0a219 /include/linux/pci_regs.h
parentcb97ae3485955401d637bd269b0d24d3cd3fd3ec (diff)
PCI: add pci_pcie_cap2() check for PCIe feature capabilities >= v2
This patch resolves potential issues when accessing PCI Express Capability structures. The makeup of the capability varies substantially between v1 and v2: Version 1 of the PCI Express Capability (defined by PCI Express 1.0 and 1.1 base) neither requires the endpoint to implement the entire PCIe capability structure nor specifies default values of registers that are not implemented by the device. Version 2 of the PCI Express Capability (defined by PCIe 1.1 Capability Structure Expansion ECN, PCIe 2.0, 2.1, and 3.0) added additional registers to the structure and requires all registers to be either implemented or hardwired to 0. Due to the differences in the capability structures, code dealing with capability features must be careful not to access the additional registers introduced with v2 unless the device is specifically known to be a v2 capable device. Otherwise, attempts to access non-existant registers will occur. This is a subtle issue that is hard to track down when it occurs (and it has - see commit 864d296cf94). To try and help mitigate such occurrences, this patch introduces pci_pcie_cap2() which is similar to pci_pcie_cap() but also checks that the PCIe capability version is >= 2. pci_pcie_cap2() should be used for qualifying PCIe capability features introduced after v1. Suggested by Don Dutile. Acked-by: Donald Dutile <ddutile@redhat.com> Signed-off-by: Myron Stowe <myron.stowe@redhat.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'include/linux/pci_regs.h')
-rw-r--r--include/linux/pci_regs.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h
index 4b608f543412..e7642f5bb12a 100644
--- a/include/linux/pci_regs.h
+++ b/include/linux/pci_regs.h
@@ -507,6 +507,12 @@
507#define PCI_EXP_RTSTA 32 /* Root Status */ 507#define PCI_EXP_RTSTA 32 /* Root Status */
508#define PCI_EXP_RTSTA_PME 0x10000 /* PME status */ 508#define PCI_EXP_RTSTA_PME 0x10000 /* PME status */
509#define PCI_EXP_RTSTA_PENDING 0x20000 /* PME pending */ 509#define PCI_EXP_RTSTA_PENDING 0x20000 /* PME pending */
510/*
511 * Note that the following PCI Express 'Capability Structure' registers
512 * were introduced with 'Capability Version' 0x2 (v2). These registers
513 * do not exist on devices with Capability Version 1. Use pci_pcie_cap2()
514 * to use these fields safely.
515 */
510#define PCI_EXP_DEVCAP2 36 /* Device Capabilities 2 */ 516#define PCI_EXP_DEVCAP2 36 /* Device Capabilities 2 */
511#define PCI_EXP_DEVCAP2_ARI 0x20 /* Alternative Routing-ID */ 517#define PCI_EXP_DEVCAP2_ARI 0x20 /* Alternative Routing-ID */
512#define PCI_EXP_DEVCAP2_LTR 0x800 /* Latency tolerance reporting */ 518#define PCI_EXP_DEVCAP2_LTR 0x800 /* Latency tolerance reporting */