Skip to content

Commit 9813616

Browse files
committed
Merge tag 'ntb-7.0' of https://github.com/jonmason/ntb
Pull NTB (PCIe non-transparent bridge) updates from Jon Mason: "NTB updates include debugfs improvements, correctness fixes, cleanups, and new hardware support: ntb_transport QP stats are converted to seq_file, a tx_memcpy_offload module parameter is introduced with associated ordering fixes, and a debugfs queue name truncation bug is corrected. Additional fixes address format specifier mismatches in ntb_tool and boundary conditions in the Switchtec driver, while unused MSI helpers are removed and the codebase migrates to dma_map_phys(). Intel Gen6 (Diamond Rapids) NTB support is also added" * tag 'ntb-7.0' of https://github.com/jonmason/ntb: NTB: ntb_transport: Use seq_file for QP stats debugfs NTB: ntb_transport: Fix too small buffer for debugfs_name ntb/ntb_tool: correct sscanf format for u64 and size_t in tool_peer_mw_trans_write ntb: intel: Add Intel Gen6 NTB support for DiamondRapids NTB/msi: Remove unused functions ntb: ntb_hw_switchtec: Increase MAX_MWS limit to 256 ntb: ntb_hw_switchtec: Fix array-index-out-of-bounds access ntb: ntb_hw_switchtec: Fix shift-out-of-bounds for 0 mw lut NTB: epf: allow built-in build ntb: migrate to dma_map_phys instead of map_page NTB: ntb_transport: Add 'tx_memcpy_offload' module option NTB: ntb_transport: Remove unused 'retries' field from ntb_queue_entry
2 parents f9d66e6 + 8c1f92c commit 9813616

10 files changed

Lines changed: 196 additions & 206 deletions

File tree

drivers/ntb/hw/epf/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
config NTB_EPF
22
tristate "Generic EPF Non-Transparent Bridge support"
3-
depends on m
43
help
54
This driver supports EPF NTB on configurable endpoint.
65
If unsure, say N.

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

drivers/ntb/hw/mscc/ntb_hw_switchtec.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ MODULE_PARM_DESC(use_lut_mws,
2929
"Enable the use of the LUT based memory windows");
3030

3131
#define SWITCHTEC_NTB_MAGIC 0x45CC0001
32-
#define MAX_MWS 128
32+
#define MAX_MWS 256
3333

3434
struct shared_mw {
3535
u32 magic;
@@ -1202,7 +1202,8 @@ static void switchtec_ntb_init_mw(struct switchtec_ntb *sndev)
12021202
sndev->mmio_self_ctrl);
12031203

12041204
sndev->nr_lut_mw = ioread16(&sndev->mmio_self_ctrl->lut_table_entries);
1205-
sndev->nr_lut_mw = rounddown_pow_of_two(sndev->nr_lut_mw);
1205+
if (sndev->nr_lut_mw)
1206+
sndev->nr_lut_mw = rounddown_pow_of_two(sndev->nr_lut_mw);
12061207

12071208
dev_dbg(&sndev->stdev->dev, "MWs: %d direct, %d lut\n",
12081209
sndev->nr_direct_mw, sndev->nr_lut_mw);
@@ -1212,7 +1213,8 @@ static void switchtec_ntb_init_mw(struct switchtec_ntb *sndev)
12121213

12131214
sndev->peer_nr_lut_mw =
12141215
ioread16(&sndev->mmio_peer_ctrl->lut_table_entries);
1215-
sndev->peer_nr_lut_mw = rounddown_pow_of_two(sndev->peer_nr_lut_mw);
1216+
if (sndev->peer_nr_lut_mw)
1217+
sndev->peer_nr_lut_mw = rounddown_pow_of_two(sndev->peer_nr_lut_mw);
12161218

12171219
dev_dbg(&sndev->stdev->dev, "Peer MWs: %d direct, %d lut\n",
12181220
sndev->peer_nr_direct_mw, sndev->peer_nr_lut_mw);
@@ -1314,6 +1316,12 @@ static void switchtec_ntb_init_shared(struct switchtec_ntb *sndev)
13141316
for (i = 0; i < sndev->nr_lut_mw; i++) {
13151317
int idx = sndev->nr_direct_mw + i;
13161318

1319+
if (idx >= MAX_MWS) {
1320+
dev_err(&sndev->stdev->dev,
1321+
"Total number of MW cannot be bigger than %d", MAX_MWS);
1322+
break;
1323+
}
1324+
13171325
sndev->self_shared->mw_sizes[idx] = LUT_SIZE;
13181326
}
13191327
}

drivers/ntb/msi.c

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -315,37 +315,6 @@ int ntbm_msi_request_threaded_irq(struct ntb_dev *ntb, irq_handler_t handler,
315315
}
316316
EXPORT_SYMBOL(ntbm_msi_request_threaded_irq);
317317

318-
static int ntbm_msi_callback_match(struct device *dev, void *res, void *data)
319-
{
320-
struct ntb_dev *ntb = dev_ntb(dev);
321-
struct ntb_msi_devres *dr = res;
322-
323-
return dr->ntb == ntb && dr->entry == data;
324-
}
325-
326-
/**
327-
* ntbm_msi_free_irq() - free an interrupt
328-
* @ntb: NTB device context
329-
* @irq: Interrupt line to free
330-
* @dev_id: Device identity to free
331-
*
332-
* This function should be used to manually free IRQs allocated with
333-
* ntbm_request_[threaded_]irq().
334-
*/
335-
void ntbm_msi_free_irq(struct ntb_dev *ntb, unsigned int irq, void *dev_id)
336-
{
337-
struct msi_desc *entry = irq_get_msi_desc(irq);
338-
339-
entry->write_msi_msg = NULL;
340-
entry->write_msi_msg_data = NULL;
341-
342-
WARN_ON(devres_destroy(&ntb->dev, ntbm_msi_callback_release,
343-
ntbm_msi_callback_match, entry));
344-
345-
devm_free_irq(&ntb->dev, irq, dev_id);
346-
}
347-
EXPORT_SYMBOL(ntbm_msi_free_irq);
348-
349318
/**
350319
* ntb_msi_peer_trigger() - Trigger an interrupt handler on a peer
351320
* @ntb: NTB device context
@@ -373,36 +342,3 @@ int ntb_msi_peer_trigger(struct ntb_dev *ntb, int peer,
373342
return 0;
374343
}
375344
EXPORT_SYMBOL(ntb_msi_peer_trigger);
376-
377-
/**
378-
* ntb_msi_peer_addr() - Get the DMA address to trigger a peer's MSI interrupt
379-
* @ntb: NTB device context
380-
* @peer: Peer index
381-
* @desc: MSI descriptor data which triggers the interrupt
382-
* @msi_addr: Physical address to trigger the interrupt
383-
*
384-
* This function allows using DMA engines to trigger an interrupt
385-
* (for example, trigger an interrupt to process the data after
386-
* sending it). To trigger the interrupt, write @desc.data to the address
387-
* returned in @msi_addr
388-
*
389-
* Return: Zero on success, otherwise a negative error number.
390-
*/
391-
int ntb_msi_peer_addr(struct ntb_dev *ntb, int peer,
392-
struct ntb_msi_desc *desc,
393-
phys_addr_t *msi_addr)
394-
{
395-
int peer_widx = ntb_peer_mw_count(ntb) - 1 - peer;
396-
phys_addr_t mw_phys_addr;
397-
int ret;
398-
399-
ret = ntb_peer_mw_get_addr(ntb, peer_widx, &mw_phys_addr, NULL);
400-
if (ret)
401-
return ret;
402-
403-
if (msi_addr)
404-
*msi_addr = mw_phys_addr + desc->addr_offset;
405-
406-
return 0;
407-
}
408-
EXPORT_SYMBOL(ntb_msi_peer_addr);

0 commit comments

Comments
 (0)