Skip to content

Commit 503fa23

Browse files
maciej-w-rozyckibjorn-helgaas
authored andcommitted
PCI: Access Link 2 registers only for devices with Links
PCIe r2.0, sec 7.8 added Link Capabilities/Status/Control 2 registers to the PCIe Capability with Capability Version 2. Previously we assumed these registers were implemented for all PCIe Capabilities of version 2 or greater, but in fact they are only implemented for devices with Links. Update pcie_capability_reg_implemented() to check whether the device has a Link. [bhelgaas: commit log, squash export] Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Maciej W. Rozycki <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 9abf231 commit 503fa23

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

drivers/pci/access.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,11 @@ bool pcie_cap_has_lnkctl(const struct pci_dev *dev)
350350
type == PCI_EXP_TYPE_PCIE_BRIDGE;
351351
}
352352

353+
bool pcie_cap_has_lnkctl2(const struct pci_dev *dev)
354+
{
355+
return pcie_cap_has_lnkctl(dev) && pcie_cap_version(dev) > 1;
356+
}
357+
353358
static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev)
354359
{
355360
return pcie_downstream_port(dev) &&
@@ -390,10 +395,11 @@ static bool pcie_capability_reg_implemented(struct pci_dev *dev, int pos)
390395
return pcie_cap_has_rtctl(dev);
391396
case PCI_EXP_DEVCAP2:
392397
case PCI_EXP_DEVCTL2:
398+
return pcie_cap_version(dev) > 1;
393399
case PCI_EXP_LNKCAP2:
394400
case PCI_EXP_LNKCTL2:
395401
case PCI_EXP_LNKSTA2:
396-
return pcie_cap_version(dev) > 1;
402+
return pcie_cap_has_lnkctl2(dev);
397403
default:
398404
return false;
399405
}

drivers/pci/pci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ extern const unsigned char pcie_link_speed[];
1515
extern bool pci_early_dump;
1616

1717
bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
18+
bool pcie_cap_has_lnkctl2(const struct pci_dev *dev);
1819
bool pcie_cap_has_rtctl(const struct pci_dev *dev);
1920

2021
/* Functions internal to the PCI core code */

0 commit comments

Comments
 (0)