fpga: dfl: Allow Port to be linked to FME's DFL
Subsystems (2)
PATCH v4 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.
---
v4: move the location of FME_PORT_OFST_BAR_SKIP definition.
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
@@ -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
@@ -89,6 +89,7 @@#define FME_HDR_NEXT_AFU NEXT_AFU#define FME_HDR_CAP 0x30#define FME_HDR_PORT_OFST (n) (0x38 + ((n) * 0x8)) +#define FME_PORT_OFST_BAR_SKIP 7#define FME_HDR_BITSTREAM_ID 0x60#define FME_HDR_BITSTREAM_MD 0x68
Signature · 1 line
2.26.2
Quoted 11 lines · Tianfei Zhang
From: Matthew Gerlach <[email protected]>
Currently we use
PORTn_OFFSETto 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 viaPORTn_OFFSETagain. If BAR value ofPORTn_OFFSETis0x7(FME_PORT_OFST_BAR_SKIP) then driver will skip searching the DFL for that port. If BAR value is invalid, return-EINVAL.Signed-off-by Matthew Gerlach <[email protected]>Signed-off-by Tianfei Zhang <[email protected]>
Quoted 51 lines
---
v4: move the location ofFME_PORT_OFST_BAR_SKIPdefinition.
v3: removedev_dbgand use goto instead of break.
v2: return-EINVALif 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@@ -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@@ -89,6 +89,7 @@#define FME_HDR_NEXT_AFU NEXT_AFU#define FME_HDR_CAP 0x30#define FME_HDR_PORT_OFST (n) (0x38 + ((n) * 0x8)) +#define FME_PORT_OFST_BAR_SKIP 7#define FME_HDR_BITSTREAM_ID 0x60#define FME_HDR_BITSTREAM_MD 0x68Signature · 1 line
2.26.2
Wu, Hao
Acked-byQuoted 10 lines · Tianfei Zhang
Quoted 9 lines
From: Matthew Gerlach <[email protected]>
Currently we use
PORTn_OFFSETto 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 viaPORTn_OFFSETagain. If BAR value ofPORTn_OFFSETis0x7(FME_PORT_OFST_BAR_SKIP) then driver will skip searching the DFL for that port. If BAR value is invalid, return-EINVAL.
Quoted 5 lines
Quoted 2 lines
Signed-off-by Matthew Gerlach <[email protected]>Signed-off-by Tianfei Zhang <[email protected]>Acked-by Xu Yilun <[email protected]>
Hi Tianfei
Please use break instead of goto (just synced with Yilun), then add
Thanks
Hao
Quoted 52 lines
Quoted 14 lines
---
v4: move the location ofFME_PORT_OFST_BAR_SKIPdefinition.
v3: removedev_dbgand use goto instead of break.
v2: return-EINVALif 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
-0drivers/fpga/dfl-pci.c static int find_dfls_by_default(struct pci_dev *pcidev, · line 269
Quoted 7 lines
drivers/fpga/dfl-pci.c +4
-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 ; + }else if (bar >=PCI_STD_NUM_BARS ) { + dev_err(&pcidev->dev, "bad BAR %d forport %d\n",
Quoted 30 lines
drivers/fpga/dfl-pci.c +6
-0+ 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
-1@@ -89,6 +89,7 @@#define FME_HDR_NEXT_AFU NEXT_AFU#define FME_HDR_CAP 0x30#define FME_HDR_PORT_OFST (n) (0x38 + ((n) * 0x8)) +#define FME_PORT_OFST_BAR_SKIP 7#define FME_HDR_BITSTREAM_ID 0x60#define FME_HDR_BITSTREAM_MD 0x68 --2.26.2
Quoted 24 lines
-----Original Message-----
From: Wu, Hao <[email protected]>
Sent: Thursday, May 5, 2022 2:38 PM
To: Xu, Yilun <[email protected]>; Zhang, Tianfei <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Matthew Gerlach <[email protected]>
Subject: RE: [PATCH v4] fpga: dfl: Allow Port to be linked to FME's DFLQuoted 14 lines · Tianfei Zhang
Quoted 12 lines
From: Matthew Gerlach <[email protected]>
Currently we use
PORTn_OFFSETto 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 viaPORTn_OFFSETagain. If BAR value ofPORTn_OFFSETis0x7
(FME_PORT_OFST_BAR_SKIP) then driver will skip searching the DFL for that port. If BAR value is invalid, return-EINVAL.Signed-off-by Matthew Gerlach <[email protected]>Signed-off-by Tianfei Zhang <[email protected]>
Quoted 8 lines
Quoted 2 lines
Acked-by Xu Yilun <[email protected]>Hi Tianfei
Please use break instead of goto (just synced with Yilun), then add
Acked-by Wu Hao <[email protected]>
Thanks Hao, I will use "break" on the new one.
Quoted 58 lines
Thanks
HaoQuoted 9 lines
Quoted 9 lines
---
v4: move the location ofFME_PORT_OFST_BAR_SKIPdefinition.
v3: removedev_dbgand use goto instead of break.
v2: return-EINVALif bar number invalid.--- drivers/fpga/dfl-pci.c | 10 ++++++++++ drivers/fpga/dfl.h | 1 + 2 files changed, 11 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..dac45f96c326100644drivers/fpga/dfl-pci.c +0
-0@@ -263,6 +263,15 @@ static int find_dfls_by_default(struct pci_dev*pcidev,
Quoted 16 lines
drivers/fpga/dfl-pci.c static int find_dfls_by_default(struct pci_dev *pcidev,
Quoted 7 lines
drivers/fpga/dfl-pci.c +4
-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 forport %d\n",
Quoted 8 lines
drivers/fpga/dfl-pci.c +5
-0+ bar, i); + ret = -EINVAL ; + goto unmap_exit; + } + start =pci_resource_start (pcidev, bar) + offset; len =pci_resource_len (pcidev, bar) - offset;Quoted 1 line
drivers/fpga/dfl-pci.c static int find_dfls_by_default(struct pci_dev
Quoted 1 line
drivers/fpga/dfl-pci.c +0
-0@@ -277,6 +286,7 @@ static int find_dfls_by_default(struct pci_dev*pcidev,
Quoted 21 lines
Quoted 21 lines
drivers/fpga/dfl-pci.c +1
-0ret = -ENODEV ; } +unmap_exit:/* release I/O mappings for next step enumeration */ pcim_iounmap_regions (pcidev,BIT (0 ));drivers/fpga/dfl.h index renamed from drivers/fpga/dfl.h +0
-0
53572c7aced0..06cfcd5e84bb100644drivers/fpga/dfl.h +1
-1@@ -89,6 +89,7 @@#define FME_HDR_NEXT_AFU NEXT_AFU#define FME_HDR_CAP 0x30#define FME_HDR_PORT_OFST (n) (0x38 + ((n) * 0x8)) +#define FME_PORT_OFST_BAR_SKIP 7#define FME_HDR_BITSTREAM_ID 0x60#define FME_HDR_BITSTREAM_MD 0x68 --2.26.2