Skip to contentSkip to conversation

fpga: dfl: Allow Port to be linked to FME's DFL

PATCH Superseded Tianfei Zhang 2 participants 3 messages Apr 26, 2022

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 fpga: dfl: Allow Port to be linked to FME's DFL

From: Matthew Gerlach <[email protected]>

Currently we use PORTn_OFFSET to locate PORT DFLs, and PORT DFLs are not connected FME DFL. But for some cases (e.g. Intel Open FPGA Stack device), PORT DFLs are connected to FME DFL directly, so we don't need to search PORT DFLs via PORTn_OFFSET again. If BAR value of PORTn_OFFSET is 0x7 (FME_PORT_OFST_BAR_SKIP) then driver will skip searching the DFL for that port. If BAR value is invalid, return -EINVAL.

---
v3: remove dev_dbg and use goto instead of break.
v2: return -EINVAL if bar number invalid.

---
 drivers/fpga/dfl-pci.c | 10 ++++++++++
 drivers/fpga/dfl.h     |  1 +
 2 files changed, 11 insertions(+)
drivers/fpga/dfl-pci.c +10 -0
index 86ed9e4223d3..dac45f96c326 100644
@@ -263,6 +263,15 @@ static int find_dfls_by_default(struct pci_dev *pcidev,
 			 */
 			bar = FIELD_GET(FME_PORT_OFST_BAR_ID, v);
 			offset = FIELD_GET(FME_PORT_OFST_DFH_OFST, v);
+			if (bar == FME_PORT_OFST_BAR_SKIP) {
+				continue;
+			} else if (bar >= PCI_STD_NUM_BARS) {
+				dev_err(&pcidev->dev, "bad BAR %d for port %d\n",
+					bar, i);
+				ret = -EINVAL;
+				goto unmap_exit;
+			}
+
 			start = pci_resource_start(pcidev, bar) + offset;
 			len = pci_resource_len(pcidev, bar) - offset;
 
@@ -277,6 +286,7 @@ static int find_dfls_by_default(struct pci_dev *pcidev,
 		ret = -ENODEV;
 	}
 
+unmap_exit:
 	/* release I/O mappings for next step enumeration */
 	pcim_iounmap_regions(pcidev, BIT(0));
 
drivers/fpga/dfl.h +1 -0
index 53572c7aced0..e0f0abfbeb8c 100644
@@ -91,6 +91,7 @@
 #define FME_HDR_PORT_OFST(n)	(0x38 + ((n) * 0x8))
 #define FME_HDR_BITSTREAM_ID	0x60
 #define FME_HDR_BITSTREAM_MD	0x68
+#define FME_PORT_OFST_BAR_SKIP	7
 
 /* FME Fab Capability Register Bitfield */
 #define FME_CAP_FABRIC_VERID	GENMASK_ULL(7, 0)	/* Fabric version ID */
Signature · 1 line
2.26.2
#1 lore raw
Quoted 34 lines

-----Original Message-----
From: Zhang, Tianfei <[email protected]>
Sent: Tuesday, April 26, 2022 9:49 AM
To: Wu, Hao <[email protected]>; [email protected]; [email protected]; Xu, Yilun <[email protected]>; [email protected]
Cc: Matthew Gerlach <[email protected]>; Zhang, Tianfei <[email protected]>
Subject: [PATCH v3] fpga: dfl: Allow Port to be linked to FME's DFL

From: Matthew Gerlach <[email protected]>

Currently we use PORTn_OFFSET to locate PORT DFLs, and PORT DFLs are not connected FME DFL. But for some cases (e.g. Intel Open FPGA Stack device), PORT DFLs are connected to FME DFL directly, so we don't need to search PORT DFLs via PORTn_OFFSET again. If BAR value of PORTn_OFFSET is 0x7 (FME_PORT_OFST_BAR_SKIP) then driver will skip searching the DFL for that port. If BAR value is invalid, return -EINVAL.

---
v3: remove dev_dbg and use goto instead of break.
v2: return -EINVAL if bar number invalid.

---
 drivers/fpga/dfl-pci.c | 10 ++++++++++
 drivers/fpga/dfl.h     |  1 +
 2 files changed, 11 insertions(+)
drivers/fpga/dfl-pci.c +0 -0
index 86ed9e4223d3..dac45f96c326 100644
@@ -263,6 +263,15 @@ static int find_dfls_by_default(struct pci_dev *pcidev,
 			 */

drivers/fpga/dfl-pci.c static int find_dfls_by_default(struct pci_dev *pcidev, · line 273

Quoted 10 lines
drivers/fpga/dfl-pci.c +7 -0
 			bar = FIELD_GET(FME_PORT_OFST_BAR_ID, v);
 			offset = FIELD_GET(FME_PORT_OFST_DFH_OFST, v);
+			if (bar == FME_PORT_OFST_BAR_SKIP) {
+				continue;
+			} else if (bar >= PCI_STD_NUM_BARS) {
+				dev_err(&pcidev->dev, "bad BAR %d for
 port %d\n",
+					bar, i);
+				ret = -EINVAL;
+				goto unmap_exit;

will break work here?

Quoted 18 lines
drivers/fpga/dfl-pci.c +3 -0
+			}
+
 			start = pci_resource_start(pcidev, bar) + offset;
 			len = pci_resource_len(pcidev, bar) - offset;
@@ -277,6 +286,7 @@ static int find_dfls_by_default(struct pci_dev *pcidev,
 		ret = -ENODEV;
 	}
 
+unmap_exit:
 	/* release I/O mappings for next step enumeration */
 	pcim_iounmap_regions(pcidev, BIT(0));
 
drivers/fpga/dfl.h +0 -0
index 53572c7aced0..e0f0abfbeb8c 100644

drivers/fpga/dfl.h line 94

Quoted 4 lines
drivers/fpga/dfl.h +1 -0
@@ -91,6 +91,7 @@
 #define FME_HDR_PORT_OFST(n)	(0x38 + ((n) * 0x8))
 #define FME_HDR_BITSTREAM_ID	0x60
 #define FME_HDR_BITSTREAM_MD	0x68
+#define FME_PORT_OFST_BAR_SKIP	7

Move this line under FME_HDR_PORT_OFST(n),
other place looks good to me.

Quoted 6 lines
drivers/fpga/dfl.h +0 -0
 /* FME Fab Capability Register Bitfield */
 #define FME_CAP_FABRIC_VERID	GENMASK_ULL(7, 0)	/* Fabric

version ID */
--
2.26.2

#2 lore raw
Quoted 49 lines

-----Original Message-----
From: Wu, Hao <[email protected]>
Sent: Tuesday, April 26, 2022 10:12 AM
To: Zhang, Tianfei <[email protected]>; [email protected]; [email protected]; Xu, Yilun <[email protected]>; [email protected]
Cc: Matthew Gerlach <[email protected]>
Subject: RE: [PATCH v3] fpga: dfl: Allow Port to be linked to FME's DFL

Quoted 39 lines

-----Original Message-----
From: Zhang, Tianfei <[email protected]>
Sent: Tuesday, April 26, 2022 9:49 AM
To: Wu, Hao <[email protected]>; [email protected]; [email protected]; Xu, Yilun <[email protected]>; [email protected]
Cc: Matthew Gerlach <[email protected]>; Zhang, Tianfei <[email protected]>
Subject: [PATCH v3] fpga: dfl: Allow Port to be linked to FME's DFL

From: Matthew Gerlach <[email protected]>

Currently we use PORTn_OFFSET to locate PORT DFLs, and PORT DFLs are not connected FME DFL. But for some cases (e.g. Intel Open FPGA Stack device), PORT DFLs are connected to FME DFL directly, so we don't need to search PORT DFLs via PORTn_OFFSET again. If BAR value of PORTn_OFFSET is 0x7
(FME_PORT_OFST_BAR_SKIP) then driver will skip searching the DFL for that port. If BAR value is invalid, return -EINVAL.

---
v3: remove dev_dbg and use goto instead of break.
v2: return -EINVAL if bar number invalid.

---
 drivers/fpga/dfl-pci.c | 10 ++++++++++
 drivers/fpga/dfl.h     |  1 +
 2 files changed, 11 insertions(+)
drivers/fpga/dfl-pci.c index renamed from drivers/fpga/dfl-pci.c +0 -0

86ed9e4223d3..dac45f96c326 100644

drivers/fpga/dfl-pci.c +2 -0
@@ -263,6 +263,15 @@ static int find_dfls_by_default(struct pci_dev *pcidev,
 			 */
 			bar = FIELD_GET(FME_PORT_OFST_BAR_ID, v);
 			offset = FIELD_GET(FME_PORT_OFST_DFH_OFST, v);
+			if (bar == FME_PORT_OFST_BAR_SKIP) {
+				continue;
Quoted 8 lines

drivers/fpga/dfl-pci.c static int find_dfls_by_default(struct pci_dev *pcidev, · line 272

Quoted 6 lines
drivers/fpga/dfl-pci.c +5 -0
+			} else if (bar >= PCI_STD_NUM_BARS) {
+				dev_err(&pcidev->dev, "bad BAR %d for
 port %d\n",
+					bar, i);
+				ret = -EINVAL;
+				goto unmap_exit;

will break work here?

Yes, I think if Bar >= PCI_STD_NUM_BARS, this should be DFL hardware issue.

Quoted 14 lines
Quoted 14 lines
drivers/fpga/dfl-pci.c +3 -0
+			}
+
 			start = pci_resource_start(pcidev, bar) + offset;
 			len = pci_resource_len(pcidev, bar) - offset;
@@ -277,6 +286,7 @@ static int find_dfls_by_default(struct pci_dev *pcidev,
 		ret = -ENODEV;
 	}
 
+unmap_exit:
 	/* release I/O mappings for next step enumeration */
 	pcim_iounmap_regions(pcidev, BIT(0));
 
Quoted 11 lines

drivers/fpga/dfl.h line 94

Quoted 9 lines
drivers/fpga/dfl.h index renamed from drivers/fpga/dfl.h +0 -0

53572c7aced0..e0f0abfbeb8c 100644

drivers/fpga/dfl.h +1 -0
@@ -91,6 +91,7 @@
 #define FME_HDR_PORT_OFST(n)	(0x38 + ((n) * 0x8))
 #define FME_HDR_BITSTREAM_ID	0x60
 #define FME_HDR_BITSTREAM_MD	0x68
+#define FME_PORT_OFST_BAR_SKIP	7

Move this line under FME_HDR_PORT_OFST(n), other place looks good to me.

Ok, I agree, I will fix it.

Quoted 8 lines
Quoted 8 lines
drivers/fpga/dfl.h +0 -0
 /* FME Fab Capability Register Bitfield */
 #define FME_CAP_FABRIC_VERID	GENMASK_ULL(7, 0)	/* Fabric

version ID */
--
2.26.2