Skip to content

Commit 4921811

Browse files
davejiangjonmason
authored andcommitted
ntb: intel: Add Intel Gen6 NTB support for DiamondRapids
Add DiamondRapids NTB support by adding the DID and adjust the changed PPD0 offset. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
1 parent 7bd2743 commit 4921811

4 files changed

Lines changed: 35 additions & 9 deletions

File tree

drivers/ntb/hw/intel/ntb_hw_gen1.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,8 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf,
763763
return ndev_ntb_debugfs_read(filp, ubuf, count, offp);
764764
else if (pdev_is_gen3(ndev->ntb.pdev))
765765
return ndev_ntb3_debugfs_read(filp, ubuf, count, offp);
766-
else if (pdev_is_gen4(ndev->ntb.pdev) || pdev_is_gen5(ndev->ntb.pdev))
766+
else if (pdev_is_gen4(ndev->ntb.pdev) || pdev_is_gen5(ndev->ntb.pdev) ||
767+
pdev_is_gen6(ndev->ntb.pdev))
767768
return ndev_ntb4_debugfs_read(filp, ubuf, count, offp);
768769

769770
return -ENXIO;
@@ -1872,7 +1873,8 @@ static int intel_ntb_pci_probe(struct pci_dev *pdev,
18721873
rc = gen3_init_dev(ndev);
18731874
if (rc)
18741875
goto err_init_dev;
1875-
} else if (pdev_is_gen4(pdev) || pdev_is_gen5(pdev)) {
1876+
} else if (pdev_is_gen4(pdev) || pdev_is_gen5(pdev) ||
1877+
pdev_is_gen6(pdev)) {
18761878
ndev->ntb.ops = &intel_ntb4_ops;
18771879
rc = intel_ntb_init_pci(ndev, pdev);
18781880
if (rc)
@@ -1903,7 +1905,8 @@ static int intel_ntb_pci_probe(struct pci_dev *pdev,
19031905
err_register:
19041906
ndev_deinit_debugfs(ndev);
19051907
if (pdev_is_gen1(pdev) || pdev_is_gen3(pdev) ||
1906-
pdev_is_gen4(pdev) || pdev_is_gen5(pdev))
1908+
pdev_is_gen4(pdev) || pdev_is_gen5(pdev) ||
1909+
pdev_is_gen6(pdev))
19071910
xeon_deinit_dev(ndev);
19081911
err_init_dev:
19091912
intel_ntb_deinit_pci(ndev);
@@ -1920,7 +1923,8 @@ static void intel_ntb_pci_remove(struct pci_dev *pdev)
19201923
ntb_unregister_device(&ndev->ntb);
19211924
ndev_deinit_debugfs(ndev);
19221925
if (pdev_is_gen1(pdev) || pdev_is_gen3(pdev) ||
1923-
pdev_is_gen4(pdev) || pdev_is_gen5(pdev))
1926+
pdev_is_gen4(pdev) || pdev_is_gen5(pdev) ||
1927+
pdev_is_gen6(pdev))
19241928
xeon_deinit_dev(ndev);
19251929
intel_ntb_deinit_pci(ndev);
19261930
kfree(ndev);
@@ -2049,6 +2053,8 @@ static const struct pci_device_id intel_ntb_pci_tbl[] = {
20492053
{PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_ICX)},
20502054
/* GEN5 PCIe */
20512055
{PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_GNR)},
2056+
/* GEN6 PCIe */
2057+
{PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_DMR)},
20522058
{0}
20532059
};
20542060
MODULE_DEVICE_TABLE(pci, intel_ntb_pci_tbl);

drivers/ntb/hw/intel/ntb_hw_gen4.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ static const struct intel_ntb_alt_reg gen4_b2b_reg = {
4646
.spad = GEN4_EM_SPAD_OFFSET,
4747
};
4848

49+
static u64 get_ppd0(struct pci_dev *pdev)
50+
{
51+
if (pdev_is_gen4(pdev) || pdev_is_gen5(pdev))
52+
return GEN4_PPD0_OFFSET;
53+
else if (pdev_is_gen6(pdev))
54+
return GEN6_PPD0_OFFSET;
55+
56+
return ULLONG_MAX;
57+
}
58+
4959
static int gen4_poll_link(struct intel_ntb_dev *ndev)
5060
{
5161
u16 reg_val;
@@ -183,7 +193,7 @@ static enum ntb_topo spr_ppd_topo(struct intel_ntb_dev *ndev, u32 ppd)
183193
int gen4_init_dev(struct intel_ntb_dev *ndev)
184194
{
185195
struct pci_dev *pdev = ndev->ntb.pdev;
186-
u32 ppd1/*, ppd0*/;
196+
u32 ppd1;
187197
u16 lnkctl;
188198
int rc;
189199

@@ -197,7 +207,7 @@ int gen4_init_dev(struct intel_ntb_dev *ndev)
197207
ppd1 = ioread32(ndev->self_mmio + GEN4_PPD1_OFFSET);
198208
if (pdev_is_ICX(pdev))
199209
ndev->ntb.topo = gen4_ppd_topo(ndev, ppd1);
200-
else if (pdev_is_SPR(pdev) || pdev_is_gen5(pdev))
210+
else if (pdev_is_SPR(pdev) || pdev_is_gen5(pdev) || pdev_is_gen6(pdev))
201211
ndev->ntb.topo = spr_ppd_topo(ndev, ppd1);
202212
dev_dbg(&pdev->dev, "ppd %#x topo %s\n", ppd1,
203213
ntb_topo_string(ndev->ntb.topo));
@@ -432,10 +442,12 @@ static int intel_ntb4_link_enable(struct ntb_dev *ntb,
432442
enum ntb_speed max_speed, enum ntb_width max_width)
433443
{
434444
struct intel_ntb_dev *ndev;
445+
struct pci_dev *pdev;
435446
u32 ntb_ctl, ppd0;
436447
u16 lnkctl;
437448

438449
ndev = container_of(ntb, struct intel_ntb_dev, ntb);
450+
pdev = ntb->pdev;
439451

440452
dev_dbg(&ntb->pdev->dev,
441453
"Enabling link with max_speed %d max_width %d\n",
@@ -476,12 +488,12 @@ static int intel_ntb4_link_enable(struct ntb_dev *ntb,
476488
iowrite16(lnkctl, ndev->self_mmio + GEN4_LINK_CTRL_OFFSET);
477489

478490
/* start link training in PPD0 */
479-
ppd0 = ioread32(ndev->self_mmio + GEN4_PPD0_OFFSET);
491+
ppd0 = ioread32(ndev->self_mmio + get_ppd0(pdev));
480492
ppd0 |= GEN4_PPD_LINKTRN;
481-
iowrite32(ppd0, ndev->self_mmio + GEN4_PPD0_OFFSET);
493+
iowrite32(ppd0, ndev->self_mmio + get_ppd0(pdev));
482494

483495
/* make sure link training has started */
484-
ppd0 = ioread32(ndev->self_mmio + GEN4_PPD0_OFFSET);
496+
ppd0 = ioread32(ndev->self_mmio + get_ppd0(pdev));
485497
if (!(ppd0 & GEN4_PPD_LINKTRN)) {
486498
dev_warn(&ntb->pdev->dev, "Link is not training\n");
487499
return -ENXIO;

drivers/ntb/hw/intel/ntb_hw_gen4.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@
103103
#define NTB_LTR_IDLE_LATSCALE 0x0800 /* 1us scale */
104104
#define NTB_LTR_IDLE_REQMNT 0x8000 /* snoop req enable */
105105

106+
#define GEN6_PPD0_OFFSET 0xf0d4
107+
106108
ssize_t ndev_ntb4_debugfs_read(struct file *filp, char __user *ubuf,
107109
size_t count, loff_t *offp);
108110
int gen4_init_dev(struct intel_ntb_dev *ndev);

drivers/ntb/hw/intel/ntb_hw_intel.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#define PCI_DEVICE_ID_INTEL_NTB_B2B_SKX 0x201C
7272
#define PCI_DEVICE_ID_INTEL_NTB_B2B_ICX 0x347e
7373
#define PCI_DEVICE_ID_INTEL_NTB_B2B_GNR 0x0db4
74+
#define PCI_DEVICE_ID_INTEL_NTB_B2B_DMR 0x7868
7475

7576
/* Ntb control and link status */
7677
#define NTB_CTL_CFG_LOCK BIT(0)
@@ -235,4 +236,9 @@ static inline int pdev_is_gen5(struct pci_dev *pdev)
235236
return pdev->device == PCI_DEVICE_ID_INTEL_NTB_B2B_GNR;
236237
}
237238

239+
static inline int pdev_is_gen6(struct pci_dev *pdev)
240+
{
241+
return pdev->device == PCI_DEVICE_ID_INTEL_NTB_B2B_DMR;
242+
}
243+
238244
#endif

0 commit comments

Comments
 (0)