Skip to content

Commit 52cd5f9

Browse files
committed
Merge tag 'ntb-5.11' of git://github.com/jonmason/ntb
Pull NTB fixes from Jon Mason: "Bug fix for IDT NTB and Intel NTB LTR management support" * tag 'ntb-5.11' of git://github.com/jonmason/ntb: ntb: intel: add Intel NTB LTR vendor support for gen4 NTB ntb: idt: fix error check in ntb_hw_idt.c
2 parents 33c148a + 75b6f64 commit 52cd5f9

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

drivers/ntb/hw/idt/ntb_hw_idt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,7 +2511,7 @@ static int idt_init_dbgfs(struct idt_ntb_dev *ndev)
25112511
/* If the top directory is not created then do nothing */
25122512
if (IS_ERR_OR_NULL(dbgfs_topdir)) {
25132513
dev_info(&ndev->ntb.pdev->dev, "Top DebugFS directory absent");
2514-
return PTR_ERR(dbgfs_topdir);
2514+
return PTR_ERR_OR_ZERO(dbgfs_topdir);
25152515
}
25162516

25172517
/* Create the info file node */
@@ -2756,7 +2756,7 @@ static int idt_pci_probe(struct pci_dev *pdev,
27562756

27572757
/* Allocate the memory for IDT NTB device data */
27582758
ndev = idt_create_dev(pdev, id);
2759-
if (IS_ERR_OR_NULL(ndev))
2759+
if (IS_ERR(ndev))
27602760
return PTR_ERR(ndev);
27612761

27622762
/* Initialize the basic PCI subsystem of the device */

drivers/ntb/hw/intel/ntb_hw_gen1.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
#define NTB_HWERR_B2BDOORBELL_BIT14 BIT_ULL(2)
142142
#define NTB_HWERR_MSIX_VECTOR32_BAD BIT_ULL(3)
143143
#define NTB_HWERR_BAR_ALIGN BIT_ULL(4)
144+
#define NTB_HWERR_LTR_BAD BIT_ULL(5)
144145

145146
extern struct intel_b2b_addr xeon_b2b_usd_addr;
146147
extern struct intel_b2b_addr xeon_b2b_dsd_addr;

drivers/ntb/hw/intel/ntb_hw_gen4.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,10 @@ int gen4_init_dev(struct intel_ntb_dev *ndev)
177177

178178
ndev->reg = &gen4_reg;
179179

180-
if (pdev_is_ICX(pdev))
180+
if (pdev_is_ICX(pdev)) {
181181
ndev->hwerr_flags |= NTB_HWERR_BAR_ALIGN;
182+
ndev->hwerr_flags |= NTB_HWERR_LTR_BAD;
183+
}
182184

183185
ppd1 = ioread32(ndev->self_mmio + GEN4_PPD1_OFFSET);
184186
ndev->ntb.topo = gen4_ppd_topo(ndev, ppd1);
@@ -431,6 +433,25 @@ static int intel_ntb4_link_enable(struct ntb_dev *ntb,
431433
dev_dbg(&ntb->pdev->dev,
432434
"ignoring max_width %d\n", max_width);
433435

436+
if (!(ndev->hwerr_flags & NTB_HWERR_LTR_BAD)) {
437+
u32 ltr;
438+
439+
/* Setup active snoop LTR values */
440+
ltr = NTB_LTR_ACTIVE_REQMNT | NTB_LTR_ACTIVE_VAL | NTB_LTR_ACTIVE_LATSCALE;
441+
/* Setup active non-snoop values */
442+
ltr = (ltr << NTB_LTR_NS_SHIFT) | ltr;
443+
iowrite32(ltr, ndev->self_mmio + GEN4_LTR_ACTIVE_OFFSET);
444+
445+
/* Setup idle snoop LTR values */
446+
ltr = NTB_LTR_IDLE_VAL | NTB_LTR_IDLE_LATSCALE | NTB_LTR_IDLE_REQMNT;
447+
/* Setup idle non-snoop values */
448+
ltr = (ltr << NTB_LTR_NS_SHIFT) | ltr;
449+
iowrite32(ltr, ndev->self_mmio + GEN4_LTR_IDLE_OFFSET);
450+
451+
/* setup PCIe LTR to active */
452+
iowrite8(NTB_LTR_SWSEL_ACTIVE, ndev->self_mmio + GEN4_LTR_SWSEL_OFFSET);
453+
}
454+
434455
ntb_ctl = NTB_CTL_E2I_BAR23_SNOOP | NTB_CTL_I2E_BAR23_SNOOP;
435456
ntb_ctl |= NTB_CTL_E2I_BAR45_SNOOP | NTB_CTL_I2E_BAR45_SNOOP;
436457
iowrite32(ntb_ctl, ndev->self_mmio + ndev->reg->ntb_ctl);
@@ -476,6 +497,10 @@ static int intel_ntb4_link_disable(struct ntb_dev *ntb)
476497
lnkctl |= GEN4_LINK_CTRL_LINK_DISABLE;
477498
iowrite16(lnkctl, ndev->self_mmio + GEN4_LINK_CTRL_OFFSET);
478499

500+
/* set LTR to idle */
501+
if (!(ndev->hwerr_flags & NTB_HWERR_LTR_BAD))
502+
iowrite8(NTB_LTR_SWSEL_IDLE, ndev->self_mmio + GEN4_LTR_SWSEL_OFFSET);
503+
479504
ndev->dev_up = 0;
480505

481506
return 0;

drivers/ntb/hw/intel/ntb_hw_gen4.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
#define GEN4_IM_SPAD_SEM_OFFSET 0x00c0 /* SPAD hw semaphore */
3636
#define GEN4_IM_SPAD_STICKY_OFFSET 0x00c4 /* sticky SPAD */
3737
#define GEN4_IM_DOORBELL_OFFSET 0x0100 /* 0-31 doorbells */
38+
#define GEN4_LTR_SWSEL_OFFSET 0x30ec
39+
#define GEN4_LTR_ACTIVE_OFFSET 0x30f0
40+
#define GEN4_LTR_IDLE_OFFSET 0x30f4
3841
#define GEN4_EM_SPAD_OFFSET 0x8080
3942
/* note, link status is now in MMIO and not config space for NTB */
4043
#define GEN4_LINK_CTRL_OFFSET 0xb050
@@ -80,6 +83,18 @@
8083

8184
#define NTB_SJC_FORCEDETECT 0x000004
8285

86+
#define NTB_LTR_SWSEL_ACTIVE 0x0
87+
#define NTB_LTR_SWSEL_IDLE 0x1
88+
89+
#define NTB_LTR_NS_SHIFT 16
90+
#define NTB_LTR_ACTIVE_VAL 0x0000 /* 0 us */
91+
#define NTB_LTR_ACTIVE_LATSCALE 0x0800 /* 1us scale */
92+
#define NTB_LTR_ACTIVE_REQMNT 0x8000 /* snoop req enable */
93+
94+
#define NTB_LTR_IDLE_VAL 0x0258 /* 600 us */
95+
#define NTB_LTR_IDLE_LATSCALE 0x0800 /* 1us scale */
96+
#define NTB_LTR_IDLE_REQMNT 0x8000 /* snoop req enable */
97+
8398
ssize_t ndev_ntb4_debugfs_read(struct file *filp, char __user *ubuf,
8499
size_t count, loff_t *offp);
85100
int gen4_init_dev(struct intel_ntb_dev *ndev);

0 commit comments

Comments
 (0)