Skip to contentSkip to conversation

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

PATCH Superseded Tianfei Zhang 3 participants 5 messages Apr 19, 2022 – Apr 26, 2022

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

---
v2: return -EINVAL if bar number invalid.

---
 drivers/fpga/dfl-pci.c | 11 +++++++++++
 drivers/fpga/dfl.h     |  1 +
 2 files changed, 12 insertions(+)
drivers/fpga/dfl-pci.c +11 -0
index 86ed9e4223d3..5bd6ef231ccc 100644
@@ -263,6 +263,17 @@ 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) {
+				dev_dbg(&pcidev->dev, "skipping search DFL for port %d on BAR %d\n",
+					i, bar);
+				continue;
+			} else if (bar >= PCI_STD_NUM_BARS) {
+				dev_err(&pcidev->dev, "bad BAR %d for port %d\n",
+					bar, i);
+				ret = -EINVAL;
+				break;
+			}
+
 			start = pci_resource_start(pcidev, bar) + offset;
 			len = pci_resource_len(pcidev, bar) - offset;
 
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
maintainer
#1 lore raw
Quoted 23 lines · Tianfei Zhang

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.

---
v2: return -EINVAL if bar number invalid.

---
 drivers/fpga/dfl-pci.c | 11 +++++++++++
 drivers/fpga/dfl.h     |  1 +
 2 files changed, 12 insertions(+)
drivers/fpga/dfl-pci.c +0 -0
index 86ed9e4223d3..5bd6ef231ccc 100644

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

Quoted 6 lines
drivers/fpga/dfl-pci.c +3 -0
@@ -263,6 +263,17 @@ 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) {
+				dev_dbg(&pcidev->dev, "skipping search DFL for port %d on BAR %d\n",
+					i, bar);

I suggest we remove the dev_dbg, it's a normal case in DFL walking.

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

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

The code is workable, but I suggest we use goto instead of break for error out.

Thanks,
Yilun

Quoted 19 lines
drivers/fpga/dfl-pci.c +2 -0
+			}
+
 			start = pci_resource_start(pcidev, bar) + offset;
 			len = pci_resource_len(pcidev, bar) - offset;
 
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
#2 lore raw
Quoted 41 lines

-----Original Message-----
From: Xu, Yilun <[email protected]>
Sent: Monday, April 25, 2022 4:20 PM
To: Zhang, Tianfei <[email protected]>
Cc: Wu, Hao <[email protected]>; [email protected]; [email protected]; linux- [email protected]; Matthew Gerlach <[email protected]>
Subject: Re: [PATCH v2] fpga: dfl: Allow Port to be linked to FME's DFL

Quoted 24 lines · Tianfei Zhang

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.

---
v2: return -EINVAL if bar number invalid.

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

86ed9e4223d3..5bd6ef231ccc 100644

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

Quoted 5 lines
drivers/fpga/dfl-pci.c +2 -0
@@ -263,6 +263,17 @@ 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) {
+				dev_dbg(&pcidev->dev, "skipping search DFL

for port %d on BAR %d\n",

Quoted 3 lines

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

Quoted 1 line
drivers/fpga/dfl-pci.c +1 -0
+					i, bar);

I suggest we remove the dev_dbg, it's a normal case in DFL walking.

I agree.

Quoted 10 lines

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

Quoted 4 lines
drivers/fpga/dfl-pci.c +3 -0
+				continue;
+			} else if (bar >= PCI_STD_NUM_BARS) {
+				dev_err(&pcidev->dev, "bad BAR %d for port

%d\n",

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

Quoted 3 lines
drivers/fpga/dfl-pci.c +3 -0
+					bar, i);
+				ret = -EINVAL;
+				break;

The code is workable, but I suggest we use goto instead of break for error out.

Ok, use goto is fine, I will change for next patch.

Quoted 24 lines

Thanks,
Yilun

Quoted 10 lines
drivers/fpga/dfl-pci.c +2 -0
+			}
+
 			start = pci_resource_start(pcidev, bar) + offset;
 			len = pci_resource_len(pcidev, bar) - offset;
 
drivers/fpga/dfl.h index renamed from drivers/fpga/dfl.h +0 -0

53572c7aced0..e0f0abfbeb8c 100644

drivers/fpga/dfl.h line 97

Quoted 7 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
 
 /* FME Fab Capability Register Bitfield */
 #define FME_CAP_FABRIC_VERID	GENMASK_ULL(7, 0)	/* Fabric

version ID */

Quoted 2 lines

--
2.26.2

#3 lore raw
In reply to Xu Yilun
Quoted 38 lines · Tianfei Zhang
Quoted 23 lines

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.

---
v2: return -EINVAL if bar number invalid.

---
 drivers/fpga/dfl-pci.c | 11 +++++++++++
 drivers/fpga/dfl.h     |  1 +
 2 files changed, 12 insertions(+)
drivers/fpga/dfl-pci.c +0 -0
index 86ed9e4223d3..5bd6ef231ccc 100644

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

Quoted 5 lines
drivers/fpga/dfl-pci.c +2 -0
@@ -263,6 +263,17 @@ 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) {
+				dev_dbg(&pcidev->dev, "skipping search DFL

for port %d on BAR %d\n",

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

Quoted 1 line
drivers/fpga/dfl-pci.c +1 -0
+					i, bar);

I suggest we remove the dev_dbg, it's a normal case in DFL walking.

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

Quoted 3 lines
drivers/fpga/dfl-pci.c +3 -0
+				continue;
+			} else if (bar >= PCI_STD_NUM_BARS) {
+				dev_err(&pcidev->dev, "bad BAR %d for

port %d\n",

Quoted 6 lines

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

Quoted 3 lines
drivers/fpga/dfl-pci.c +3 -0
+					bar, i);
+				ret = -EINVAL;
+				break;

The code is workable, but I suggest we use goto instead of break for error out.

Maybe "break" is better, if additional code is required after the loop in the future, we don't have to modify the goto label code again. Just my personal preference.

Quoted 24 lines

Thanks,
Yilun

Quoted 10 lines
drivers/fpga/dfl-pci.c +2 -0
+			}
+
 			start = pci_resource_start(pcidev, bar) + offset;
 			len = pci_resource_len(pcidev, bar) - offset;
 
drivers/fpga/dfl.h +0 -0
index 53572c7aced0..e0f0abfbeb8c 100644

drivers/fpga/dfl.h line 97

Quoted 7 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
 
 /* FME Fab Capability Register Bitfield */
 #define FME_CAP_FABRIC_VERID	GENMASK_ULL(7, 0)	/* Fabric

version ID */

Quoted 2 lines

--
2.26.2

#4 lore raw
Quoted 57 lines

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

Quoted 20 lines · Tianfei Zhang
Quoted 19 lines

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.

---
v2: return -EINVAL if bar number invalid.

---
 drivers/fpga/dfl-pci.c | 11 +++++++++++
 drivers/fpga/dfl.h     |  1 +
 2 files changed, 12 insertions(+)
Quoted 5 lines

drivers/fpga/dfl-pci.c static int find_dfls_by_default(struct pci_dev

Quoted 5 lines
drivers/fpga/dfl-pci.c index renamed from drivers/fpga/dfl-pci.c +0 -0

86ed9e4223d3..5bd6ef231ccc 100644

drivers/fpga/dfl-pci.c +0 -0
@@ -263,6 +263,17 @@ static int find_dfls_by_default(struct pci_dev

*pcidev,

Quoted 14 lines

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

Quoted 5 lines
drivers/fpga/dfl-pci.c +2 -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) {
+				dev_dbg(&pcidev->dev, "skipping search DFL

for port %d on BAR %d\n",

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

Quoted 1 line
drivers/fpga/dfl-pci.c +1 -0
+					i, bar);

I suggest we remove the dev_dbg, it's a normal case in DFL walking.

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

Quoted 3 lines
drivers/fpga/dfl-pci.c +3 -0
+				continue;
+			} else if (bar >= PCI_STD_NUM_BARS) {
+				dev_err(&pcidev->dev, "bad BAR %d for

port %d\n",

Quoted 6 lines

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

Quoted 3 lines
drivers/fpga/dfl-pci.c +3 -0
+					bar, i);
+				ret = -EINVAL;
+				break;

The code is workable, but I suggest we use goto instead of break for error out.

Quoted 3 lines

Maybe "break" is better, if additional code is required after the loop in the future, we don't have to modify the goto label code again. Just my personal preference.

Yes, Yilun suggested here is goto is better, because this is a hardware issue, it should be handle the error immediately.

Quoted 25 lines
Quoted 25 lines

Thanks,
Yilun

Quoted 10 lines
drivers/fpga/dfl-pci.c +2 -0
+			}
+
 			start = pci_resource_start(pcidev, bar) + offset;
 			len = pci_resource_len(pcidev, bar) - offset;
 
drivers/fpga/dfl.h index renamed from drivers/fpga/dfl.h +0 -0

53572c7aced0..e0f0abfbeb8c 100644

drivers/fpga/dfl.h line 97

Quoted 7 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
 
 /* FME Fab Capability Register Bitfield */
 #define FME_CAP_FABRIC_VERID	GENMASK_ULL(7, 0)	/* Fabric

version ID */

Quoted 2 lines

--
2.26.2