Skip to contentSkip to conversation

Extend interfaces to access PCIe capabilities registers

PATCH Applied Myron Stowe 2 participants 4 messages Jan 26, 2013 – Jan 31, 2013 PCI

lore
Share & tools
lore
#0 lore raw

cover Extend interfaces to access PCIe capabilities registers

This series is a minor extension to Jiang Liu's recent efforts - [PATCH v3 00/32] provide interfaces to access PCIe capabilities registers - which adds an additional PCI Express accessor for obtaining a device's Capabilities Register.

Reference: https://lkml.org/lkml/2012/8/1/253
---

Myron Stowe (2):
PCI: Use PCI Express Capability accessors
PCI: introduce accessor to retrieve PCIe Capabilities Register

 drivers/pci/access.c            |    4 ++--
 drivers/pci/pcie/portdrv_core.c |    2 +-
 include/linux/pci.h             |   11 ++++++++++-
 3 files changed, 13 insertions(+), 4 deletions(-)
#1 lore raw

PATCH 1/2 PCI: introduce accessor to retrieve PCIe Capabilities Register

Provide an accessor to retrieve the PCI Express device's Capabilities Register.

---

 include/linux/pci.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
include/linux/pci.h +9 -0
index 15472d6..78581e1 100644
@@ -1693,6 +1693,15 @@ static inline bool pci_is_pcie(struct pci_dev *dev)
 }
 
 /**
+ * pcie_caps_reg - get the PCIe Capabilities Register
+ * @dev: PCI device
+ */
+static inline u16 pcie_caps_reg(const struct pci_dev *dev)
+{
+	return dev->pcie_flags_reg;
+}
+
+/**
  * pci_pcie_type - get the PCIe device/port type
  * @dev: PCI device
  */
#2 lore raw

PATCH 2/2 PCI: Use PCI Express Capability accessors

In reply to Myron Stowe

Use PCI Express Capability access functions to simplify device Capabilities Register usages.

---

 drivers/pci/access.c            |    4 ++--
 drivers/pci/pcie/portdrv_core.c |    2 +-
 include/linux/pci.h             |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/pci/access.c +2 -2
index 3af0478..5278ac6 100644
@@ -472,7 +472,7 @@ EXPORT_SYMBOL_GPL(pci_cfg_access_unlock);
 
 static inline int pcie_cap_version(const struct pci_dev *dev)
 {
-	return dev->pcie_flags_reg & PCI_EXP_FLAGS_VERS;
+	return pcie_caps_reg(dev) & PCI_EXP_FLAGS_VERS;
 }
 
 static inline bool pcie_cap_has_devctl(const struct pci_dev *dev)
@@ -497,7 +497,7 @@ static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev)
 	return pcie_cap_version(dev) > 1 ||
 	       type == PCI_EXP_TYPE_ROOT_PORT ||
 	       (type == PCI_EXP_TYPE_DOWNSTREAM &&
-		dev->pcie_flags_reg & PCI_EXP_FLAGS_SLOT);
+		pcie_caps_reg(dev) & PCI_EXP_FLAGS_SLOT);
 }
 
 static inline bool pcie_cap_has_rtctl(const struct pci_dev *dev)
drivers/pci/pcie/portdrv_core.c +1 -1
index b42133a..31063ac 100644
@@ -272,7 +272,7 @@ static int get_port_device_capability(struct pci_dev *dev)
 
 	/* Hot-Plug Capable */
 	if ((cap_mask & PCIE_PORT_SERVICE_HP) &&
-	    dev->pcie_flags_reg & PCI_EXP_FLAGS_SLOT) {
+	    pcie_caps_reg(dev) & PCI_EXP_FLAGS_SLOT) {
 		pcie_capability_read_dword(dev, PCI_EXP_SLTCAP, &reg32);
 		if (reg32 & PCI_EXP_SLTCAP_HPC) {
 			services |= PCIE_PORT_SERVICE_HP;
include/linux/pci.h +1 -1
index 78581e1..63b3628 100644
@@ -1707,7 +1707,7 @@ static inline u16 pcie_caps_reg(const struct pci_dev *dev)
  */
 static inline int pci_pcie_type(const struct pci_dev *dev)
 {
-	return (dev->pcie_flags_reg & PCI_EXP_FLAGS_TYPE) >> 4;
+	return (pcie_caps_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4;
 }
 
 void pci_request_acs(void);
maintainer Applied
#3 lore raw
In reply to Myron Stowe
Quoted 13 lines · Myron Stowe

This series is a minor extension to Jiang Liu's recent efforts - [PATCH v3 00/32] provide interfaces to access PCIe capabilities registers - which adds an additional PCI Express accessor for obtaining a device's Capabilities Register.

Reference: https://lkml.org/lkml/2012/8/1/253
---

Myron Stowe (2):
PCI: Use PCI Express Capability accessors
PCI: introduce accessor to retrieve PCIe Capabilities Register

Quoted 4 lines
 drivers/pci/access.c            |    4 ++--
 drivers/pci/pcie/portdrv_core.c |    2 +-
 include/linux/pci.h             |   11 ++++++++++-
 3 files changed, 13 insertions(+), 4 deletions(-)

I applied these to pci/misc for v3.9. Thanks!