Skip to content

Commit d5081bf

Browse files
davejiangjonmason
authored andcommitted
ntb: intel: fix port config status offset for SPR
The field offset for port configuration status on SPR has been changed to bit 14 from ICX where it resides at bit 12. By chance link status detection continued to work on SPR. This is due to bit 12 being a configuration bit which is in sync with the status bit. Fix this by checking for a SPR device and checking correct status bit. Fixes: 26bfe3d ("ntb: intel: Add Icelake (gen4) support for Intel NTB") Tested-by: Jerry Dai <[email protected]> Signed-off-by: Dave Jiang <[email protected]> Signed-off-by: Jon Mason <[email protected]>
1 parent 3053256 commit d5081bf

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

drivers/ntb/hw/intel/ntb_hw_gen4.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ static enum ntb_topo gen4_ppd_topo(struct intel_ntb_dev *ndev, u32 ppd)
168168
return NTB_TOPO_NONE;
169169
}
170170

171+
static enum ntb_topo spr_ppd_topo(struct intel_ntb_dev *ndev, u32 ppd)
172+
{
173+
switch (ppd & SPR_PPD_TOPO_MASK) {
174+
case SPR_PPD_TOPO_B2B_USD:
175+
return NTB_TOPO_B2B_USD;
176+
case SPR_PPD_TOPO_B2B_DSD:
177+
return NTB_TOPO_B2B_DSD;
178+
}
179+
180+
return NTB_TOPO_NONE;
181+
}
182+
171183
int gen4_init_dev(struct intel_ntb_dev *ndev)
172184
{
173185
struct pci_dev *pdev = ndev->ntb.pdev;
@@ -183,7 +195,10 @@ int gen4_init_dev(struct intel_ntb_dev *ndev)
183195
}
184196

185197
ppd1 = ioread32(ndev->self_mmio + GEN4_PPD1_OFFSET);
186-
ndev->ntb.topo = gen4_ppd_topo(ndev, ppd1);
198+
if (pdev_is_ICX(pdev))
199+
ndev->ntb.topo = gen4_ppd_topo(ndev, ppd1);
200+
else if (pdev_is_SPR(pdev))
201+
ndev->ntb.topo = spr_ppd_topo(ndev, ppd1);
187202
dev_dbg(&pdev->dev, "ppd %#x topo %s\n", ppd1,
188203
ntb_topo_string(ndev->ntb.topo));
189204
if (ndev->ntb.topo == NTB_TOPO_NONE)

drivers/ntb/hw/intel/ntb_hw_gen4.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@
4949
#define GEN4_PPD_CLEAR_TRN 0x0001
5050
#define GEN4_PPD_LINKTRN 0x0008
5151
#define GEN4_PPD_CONN_MASK 0x0300
52+
#define SPR_PPD_CONN_MASK 0x0700
5253
#define GEN4_PPD_CONN_B2B 0x0200
5354
#define GEN4_PPD_DEV_MASK 0x1000
5455
#define GEN4_PPD_DEV_DSD 0x1000
5556
#define GEN4_PPD_DEV_USD 0x0000
57+
#define SPR_PPD_DEV_MASK 0x4000
58+
#define SPR_PPD_DEV_DSD 0x4000
59+
#define SPR_PPD_DEV_USD 0x0000
5660
#define GEN4_LINK_CTRL_LINK_DISABLE 0x0010
5761

5862
#define GEN4_SLOTSTS 0xb05a
@@ -62,6 +66,10 @@
6266
#define GEN4_PPD_TOPO_B2B_USD (GEN4_PPD_CONN_B2B | GEN4_PPD_DEV_USD)
6367
#define GEN4_PPD_TOPO_B2B_DSD (GEN4_PPD_CONN_B2B | GEN4_PPD_DEV_DSD)
6468

69+
#define SPR_PPD_TOPO_MASK (SPR_PPD_CONN_MASK | SPR_PPD_DEV_MASK)
70+
#define SPR_PPD_TOPO_B2B_USD (GEN4_PPD_CONN_B2B | SPR_PPD_DEV_USD)
71+
#define SPR_PPD_TOPO_B2B_DSD (GEN4_PPD_CONN_B2B | SPR_PPD_DEV_DSD)
72+
6573
#define GEN4_DB_COUNT 32
6674
#define GEN4_DB_LINK 32
6775
#define GEN4_DB_LINK_BIT BIT_ULL(GEN4_DB_LINK)
@@ -112,4 +120,12 @@ static inline int pdev_is_ICX(struct pci_dev *pdev)
112120
return 0;
113121
}
114122

123+
static inline int pdev_is_SPR(struct pci_dev *pdev)
124+
{
125+
if (pdev_is_gen4(pdev) &&
126+
pdev->revision > PCI_DEVICE_REVISION_ICX_MAX)
127+
return 1;
128+
return 0;
129+
}
130+
115131
#endif

0 commit comments

Comments
 (0)