[RFC PATCH v2 00/32] provide interfaces to access PCIe capabilities registers

July 24th, 2012 - 12:40 pm ET by Jiang Liu | Report spam
From: Jiang Liu <liuj97@gmail.com>

As suggested by Bjorn Helgaas and Don Dutile in threads
http://www.spinics.net/lists/linux-...5663.html, we could improve access
to PCIe capabilities register in to way:
1) cache content of PCIe Capabilities Register into struct pce_dev to avoid
repeatedly reading this register because it's read only.
2) provide access functions for PCIe Capabilities registers to hide differences
among PCIe base specifications, so the caller don't need to handle those
differences.

This patch set applies to
git://git.kernel.org/pub/scm/linux/...as/pci.git pci-next

And you could pull the change set from
https://github.com/jiangliu/linux.git topic/pcie-cap

These patch set is still RFC. It provides the new interfaces and has made the
major changes to adopt those new interfaces. But there are still several device
drivers left untouched. Any comments about the new interfaces are welcomed,
especially about function names:). Once we reach an agreement, I will send out
a formal version with all needed work done.

v2: 1) change return value to 0 when the register is not implemented by
V1 PCIe devices.
2) Change all driver in the source tree to use the new interfaces.

Jiang Liu (29):
PCI: add PCIe capabilities access functions to hide differences among
PCIe specs
PCI/core: use PCIe capabilities access functions to simplify
implementation
PCI/hotplug: use PCIe capabilities access functions to simplify
implementation
PCI/portdrv: use PCIe capabilities access functions to simplify
implementation
PCI/pciehp: use PCIe capabilities access functions to simplify
implementation
PCI/PME: use PCIe capabilities access functions to simplify
implementation
PCI/AER: use PCIe capabilities access functions to simplify
implementation
PCI/ASPM: use PCIe capabilities access functions to simplify
implementation
PCI/ARM: use PCIe capabilities access functions to simplify
implementation
PCI/MIPS: use PCIe capabilities access functions to simplify
implementation
PCI/tile: use PCIe capabilities access functions to simplify
implementation
PCI/r8169: use PCIe capabilities access functions to simplify
implementation
PCI/broadcom: use PCIe capabilities access functions to simplify
implementation
PCI/igb: use PCIe capabilities access functions to simplify
implementation
PCI/vxge: use PCIe capabilities access functions to simplify
implementation
PCI/mlx4: use PCIe capabilities access functions to simplify
implementation
PCI/niu: use PCIe capabilities access functions to simplify
implementation
PCI/myri10ge: use PCIe capabilities access functions to simplify
implementation
PCI/chelsio: use PCIe capabilities access functions to simplify
implementation
PCI/atl1c: use PCIe capabilities access functions to simplify
implementation
PCI/ath9k: use PCIe capabilities access functions to simplify
implementation
PCI/iwl: use PCIe capabilities access functions to simplify
implementation
PCI/mthca: use PCIe capabilities access functions to simplify
implementation
PCI/qib: use PCIe capabilities access functions to simplify
implementation
PCI/qla: use PCIe capabilities access functions to simplify
implementation
PCI/radeon: use PCIe capabilities access functions to simplify
implementation
PCI/tsi721: use PCIe capabilities access functions to simplify
implementation
PCI/et131x: use PCIe capabilities access functions to simplify
implementation
PCI/rtl8192e: use PCIe capabilities access functions to simplify
implementation

Yijing Wang (3):
PCI: add pcie_flags_reg into struct pci_dev to cache PCIe
capabilities register
PCI: introduce pci_pcie_type(dev) to replace pci_dev->pcie_type
PCI: remove unused field pcie_type from struct pci_dev

arch/arm/mach-tegra/pcie.c | 7 +-
arch/mips/pci/pci-octeon.c | 7 +-
arch/powerpc/platforms/powernv/pci-ioda.c | 2 +-
arch/tile/kernel/pci.c | 17 +-
drivers/gpu/drm/radeon/evergreen.c | 9 +-
drivers/infiniband/hw/mthca/mthca_reset.c | 8 +-
drivers/infiniband/hw/qib/qib_pcie.c | 40 ++-
drivers/iommu/intel-iommu.c | 6 +-
drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 2 +-
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 24 +-
drivers/net/ethernet/broadcom/tg3.c | 46 ++--
drivers/net/ethernet/chelsio/cxgb3/t3_hw.c | 19 +-
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 10 +-
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 7 +-
drivers/net/ethernet/intel/e1000e/netdev.c | 20 +-
drivers/net/ethernet/intel/igb/igb_main.c | 12 +-
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 +-
drivers/net/ethernet/mellanox/mlx4/reset.c | 8 +-
drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 21 +-
drivers/net/ethernet/neterion/vxge/vxge-config.c | 4 +-
.../net/ethernet/qlogic/netxen/netxen_nic_main.c | 2 +-
drivers/net/ethernet/realtek/r8169.c | 35 +--
drivers/net/ethernet/sun/niu.c | 9 +-
drivers/net/wireless/ath/ath9k/pci.c | 18 +-
drivers/net/wireless/iwlegacy/common.h | 5 +-
drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 4 +-
drivers/net/wireless/rtlwifi/pci.c | 8 +-
drivers/pci/access.c | 157 ++++++++++++
drivers/pci/hotplug/pciehp_acpi.c | 6 +-
drivers/pci/hotplug/pciehp_hpc.c | 10 +-
drivers/pci/hotplug/pcihp_slot.c | 12 +-
drivers/pci/iov.c | 6 +-
drivers/pci/pci.c | 262 +++++
drivers/pci/pcie/aer/aer_inject.c | 2 +-
drivers/pci/pcie/aer/aerdrv.c | 23 +-
drivers/pci/pcie/aer/aerdrv_acpi.c | 2 +-
drivers/pci/pcie/aer/aerdrv_core.c | 27 +-
drivers/pci/pcie/aspm.c | 108 ++++-
drivers/pci/pcie/pme.c | 23 +-
drivers/pci/pcie/portdrv_bus.c | 2 +-
drivers/pci/pcie/portdrv_core.c | 24 +-
drivers/pci/pcie/portdrv_pci.c | 15 +-
drivers/pci/probe.c | 29 +--
drivers/pci/quirks.c | 9 +-
drivers/pci/search.c | 2 +-
drivers/rapidio/devices/tsi721.c | 13 +-
drivers/scsi/qla2xxx/qla_init.c | 4 +-
drivers/scsi/qla2xxx/qla_nx.c | 8 +-
drivers/scsi/qla4xxx/ql4_nx.c | 4 +-
drivers/staging/et131x/et131x.c | 9 +-
drivers/staging/rtl8192e/rtl8192e/rtl_pci.c | 8 +-
include/linux/pci.h | 17 +-
include/linux/pci_regs.h | 2 +
53 files changed, 510 insertions(+), 626 deletions(-)

1.7.9.5

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
email Follow the discussionReplies 29 repliesReplies Make a reply

Replies

#1 Jiang Liu
July 24th, 2012 - 12:40 pm ET | Report spam
From: Jiang Liu

Use PCIe capabilities access functions to simplify PCIe portdrv implementation.

Signed-off-by: Jiang Liu
Signed-off-by: Yijing Wang

drivers/pci/pcie/portdrv_core.c | 20 ++++++++
drivers/pci/pcie/portdrv_pci.c | 7 ++--
2 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index bf320a9..37bff83 100644
a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -76,7 +76,6 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *vectors, int mask)
struct msix_entry *msix_entries;
int idx[PCIE_PORT_DEVICE_MAXSERVICES];
int nr_entries, status, pos, i, nvec;
- u16 reg16;
u32 reg32;

nr_entries = pci_msix_table_size(dev);
@@ -120,9 +119,7 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *vectors, int mask)
* the value in this field indicates which MSI-X Table entry is
* used to generate the interrupt message."
*/
- pos = pci_pcie_cap(dev);
- pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &reg16);
- entry = (reg16 & PCI_EXP_FLAGS_IRQ) >> 9;
+ entry = (dev->pcie_flags_reg & PCI_EXP_FLAGS_IRQ) >> 9;
if (entry >= nr_entries)
goto Error;

@@ -246,7 +243,7 @@ static void cleanup_service_irqs(struct pci_dev *dev)
*/
static int get_port_device_capability(struct pci_dev *dev)
{
- int services = 0, pos;
+ int services = 0;
u16 reg16;
u32 reg32;
int cap_mask = 0;
@@ -265,11 +262,9 @@ static int get_port_device_capability(struct pci_dev *dev)
return 0;
}

- pos = pci_pcie_cap(dev);
- pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &reg16);
/* Hot-Plug Capable */
- if ((cap_mask & PCIE_PORT_SERVICE_HP) && (reg16 & PCI_EXP_FLAGS_SLOT)) {
- pci_read_config_dword(dev, pos + PCI_EXP_SLTCAP, &reg32);
+ if ((cap_mask & PCIE_PORT_SERVICE_HP)) {
+ pci_pcie_capability_read_dword(dev, PCI_EXP_SLTCAP, &reg32);
if (reg32 & PCI_EXP_SLTCAP_HPC) {
services |= PCIE_PORT_SERVICE_HP;
/*
@@ -277,10 +272,11 @@ static int get_port_device_capability(struct pci_dev *dev)
* enabled by the BIOS and the hot-plug service driver
* is not loaded.
*/
- pos += PCI_EXP_SLTCTL;
- pci_read_config_word(dev, pos, &reg16);
+ pci_pcie_capability_read_word(dev,
+ PCI_EXP_SLTCTL, &reg16);
reg16 &= ~(PCI_EXP_SLTCTL_CCIE | PCI_EXP_SLTCTL_HPIE);
- pci_write_config_word(dev, pos, reg16);
+ pci_pcie_capability_write_word(dev,
+ PCI_EXP_SLTCTL, reg16);
}
}
/* AER capable */
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 24d1463..1b2b378 100644
a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -64,14 +64,11 @@ __setup("pcie_ports=", pcie_port_setup);
*/
void pcie_clear_root_pme_status(struct pci_dev *dev)
{
- int rtsta_pos;
u32 rtsta;

- rtsta_pos = pci_pcie_cap(dev) + PCI_EXP_RTSTA;
-
- pci_read_config_dword(dev, rtsta_pos, &rtsta);
+ pci_pcie_capability_read_dword(dev, PCI_EXP_RTSTA, &rtsta);
rtsta |= PCI_EXP_RTSTA_PME;
- pci_write_config_dword(dev, rtsta_pos, rtsta);
+ pci_pcie_capability_write_dword(dev, PCI_EXP_RTSTA, rtsta);
}

static int pcie_portdrv_restore_config(struct pci_dev *dev)
1.7.9.5

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Similar topics