Skip to content

cxl_pci refactor for reusability

Ben Widawsky linux-cxl linux-iommu linux-pci linuxppc-dev 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest9 patches 14 repliesIn review
  2. v17 patches 8 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9cxl: Convert "RBI" to enumdrivers/cxl/pci.h+8 -61 reply
2/9cxl/pci: Remove dev_dbg for unknown register blocksdrivers/cxl/pci.c+0 -31 reply
3/9cxl/pci: Remove pci request/release regionsdrivers/cxl/pci.c+0 -51 reply
4/9cxl/pci: Refactor cxl_pci_setup_regsdrivers/cxl/pci.c+70 -561 reply
5/9cxl/pci: Make more use of cxl_register_mapdrivers/cxl/cxl.h drivers/cxl/pci.c+18 -191 reply
6/9PCI: Add pci_find_dvsec_capability to find designated VSECdrivers/pci/pci.c include/linux/pci.h+33 -04 replies
7/9cxl/pci: Use pci core's DVSEC functionalitydrivers/cxl/pci.c+1 -191 reply
8/9ocxl: Use pci core's DVSEC functionalityarch/powerpc/platforms/powernv/ocxl.c drivers/misc/ocxl/config.c+3 -131 reply
9/9iommu/vt-d: Use pci core's DVSEC functionalitydrivers/iommu/intel/iommu.c+1 -143 replies

Reviews trailers per patch

4 of 9 patches have a Reviewed-by or Acked-by.

PatchDan WilliamsFrederic BarratKan LiangBjorn HelgaasAndrew DonnellanJonathan Cameron
1/9
2/9R-b
3/9Recommended-by R-b
4/9
5/9
6/9R-b T-b A-b R-b R-b
7/9
8/9A-b R-b
9/9

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 6 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/9] cxl_pci refactor for reusability

Changes since v1 [3]:
- get_max_afu_index() updated to new interface (Dan)
- siov_find_pci_dvsec updated to new interface (Dan)
- remove unnecessary pci request/release regions with refactor (Dan)
- move @base into cxl_register_map (Dan)
- Expanded the Cc list to include other users of PCIe DVSEC. (Dan)

Three spots are not converted to use the new PCI core DVSEC helper as the changes are non-trivial.
- find_dvsec_afu_ctrl (ocxl)
- pmt_pci_probe (David)
- intel_uncore_has_discovery_tables (Kan)

The interdiff is below. A range-diff can be generated against v1[3] if desired. Discussion occurred partially offlist between Dan and myself. To summarize, Dan contends that patch 4, "cxl/pci: Refactor cxl_pci_setup_regs" should either be rewrittn, or have a precursor patch that cxl_pci will still scan all register blocks, but only claim the specified types. While the current diff is somewhat complex, I contend that this is unneeded churn because we can easily test this change in our existing regression testing. It also ultimately results in a simpler function in the cxl_port patch series when cxl_pci stops trying to map the component register block (loop is removed entirely). A tiebreak here would be great :-)

---

Original commit message:

Provide the ability to obtain CXL register blocks as discrete functionality. This functionality will become useful for other CXL drivers that need access to CXL register blocks. It is also in line with other additions to core which moves register mapping functionality.

At the introduction of the CXL driver the only user of CXL MMIO was cxl_pci (then known as cxl_mem). As the driver has evolved it is clear that cxl_pci will not be the only entity that needs access to CXL MMIO. This series stops short of moving the generalized functionality into cxl_core for the sake of getting eyes on the important foundational bits sooner rather than later. The ultimate plan is to move much of the code into cxl_core.

Via review of two previous patches [1] & [2] it has been suggested that the bits which are being used for DVSEC enumeration move into PCI core. As CXL core is soon going to require these, let's try to get the ball rolling now on making that happen.

---

[1]: https://lore.kernel.org/linux-pci/[email protected]/
[2]: https://lore.kernel.org/linux-cxl/[email protected]/
[3]: https://lore.kernel.org/linux-cxl/[email protected]/

Ben Widawsky (9):
cxl: Convert "RBI" to enum
cxl/pci: Remove dev_dbg for unknown register blocks cxl/pci: Remove pci request/release regions cxl/pci: Refactor cxl_pci_setup_regs
cxl/pci: Make more use of cxl_register_map
PCI: Add pci_find_dvsec_capability to find designated VSEC cxl/pci: Use pci core's DVSEC functionality
ocxl: Use pci core's DVSEC functionality iommu/vt-d: Use pci core's DVSEC functionality

 arch/powerpc/platforms/powernv/ocxl.c |   3 +-
 drivers/cxl/cxl.h                     |   1 +
 drivers/cxl/pci.c                     | 176 ++++++++++++--------------
 drivers/cxl/pci.h                     |  14 +-
 drivers/iommu/intel/iommu.c           |  15 +--
 drivers/misc/ocxl/config.c            |  13 +-
 drivers/pci/pci.c                     |  32 +++++
 include/linux/pci.h                   |   1 +
 8 files changed, 127 insertions(+), 128 deletions(-)

Interdiff against v1:

arch/powerpc/platforms/powernv/ocxl.c +2 -1
index 9105efcf242a..28b009b46464 100644
@@ -107,7 +107,8 @@ static int get_max_afu_index(struct pci_dev *dev, int *afu_idx)
 	int pos;
 	u32 val;
 
-	pos = find_dvsec_from_pos(dev, OCXL_DVSEC_FUNC_ID, 0);
+	pos = pci_find_dvsec_capability(dev, PCI_VENDOR_ID_IBM,
+					OCXL_DVSEC_FUNC_ID);
 	if (!pos)
 		return -ESRCH;
 
drivers/cxl/cxl.h +1 -0
index 7d6b011dd963..3b128ce71564 100644
@@ -140,6 +140,7 @@ struct cxl_device_reg_map {
 };
 
 struct cxl_register_map {
+	void __iomem *base;
 	u64 block_offset;
 	u8 reg_type;
 	u8 barno;
drivers/cxl/pci.c +17 -29

123 lines not on this page · raw message

drivers/iommu/intel/iommu.c +1 -14
index d75f59ae28e6..30c97181f0ae 100644
@@ -5398,20 +5398,7 @@ static int intel_iommu_disable_sva(struct device *dev)
  */
 static int siov_find_pci_dvsec(struct pci_dev *pdev)
 {
-	int pos;
-	u16 vendor, id;
-
-	pos = pci_find_next_ext_capability(pdev, 0, 0x23);
-	while (pos) {
-		pci_read_config_word(pdev, pos + 4, &vendor);
-		pci_read_config_word(pdev, pos + 8, &id);
-		if (vendor == PCI_VENDOR_ID_INTEL && id == 5)
-			return pos;
-
-		pos = pci_find_next_ext_capability(pdev, pos, 0x23);
-	}
-
-	return 0;
+	return pci_find_dvsec_capability(pdev, PCI_VENDOR_ID_INTEL, 5);
 }
 
 static bool

base-commit: 18f2a85f5e7db7468530be5048fee5b9cc7a8013

Signature · 1 line
2.33.0