Skip to content

Commit bec5545

Browse files
committed
Merge tag 'ntb-5.3' of git://github.com/jonmason/ntb
Pull NTB updates from Jon Mason: "New feature to add support for NTB virtual MSI interrupts, the ability to test and use this feature in the NTB transport layer. Also, bug fixes for the AMD and Switchtec drivers, as well as some general patches" * tag 'ntb-5.3' of git://github.com/jonmason/ntb: (22 commits) NTB: Describe the ntb_msi_test client in the documentation. NTB: Add MSI interrupt support to ntb_transport NTB: Add ntb_msi_test support to ntb_test NTB: Introduce NTB MSI Test Client NTB: Introduce MSI library NTB: Rename ntb.c to support multiple source files in the module NTB: Introduce functions to calculate multi-port resource index NTB: Introduce helper functions to calculate logical port number PCI/switchtec: Add module parameter to request more interrupts PCI/MSI: Support allocating virtual MSI interrupts ntb_hw_switchtec: Fix setup MW with failure bug ntb_hw_switchtec: Skip unnecessary re-setup of shared memory window for crosslink case ntb_hw_switchtec: Remove redundant steps of switchtec_ntb_reinit_peer() function NTB: correct ntb_dev_ops and ntb_dev comment typos NTB: amd: Silence shift wrapping warning in amd_ntb_db_vector_mask() ntb_hw_switchtec: potential shift wrapping bug in switchtec_ntb_init_sndev() NTB: ntb_transport: Ensure qp->tx_mw_dma_addr is initaliazed NTB: ntb_hw_amd: set peer limit register NTB: ntb_perf: Clear stale values in doorbell and command SPAD register NTB: ntb_perf: Disable NTB link after clearing peer XLAT registers ...
2 parents f1a3b43 + d9c53aa commit bec5545

File tree

19 files changed

+1458
-60
lines changed

19 files changed

+1458
-60
lines changed

Documentation/driver-api/ntb.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,33 @@ Debugfs Files:
200200
This file is used to read and write peer scratchpads. See
201201
*spad* for details.
202202

203+
NTB MSI Test Client (ntb\_msi\_test)
204+
------------------------------------
205+
206+
The MSI test client serves to test and debug the MSI library which
207+
allows for passing MSI interrupts across NTB memory windows. The
208+
test client is interacted with through the debugfs filesystem:
209+
210+
* *debugfs*/ntb\_tool/*hw*/
211+
A directory in debugfs will be created for each
212+
NTB device probed by the tool. This directory is shortened to *hw*
213+
below.
214+
* *hw*/port
215+
This file describes the local port number
216+
* *hw*/irq*_occurrences
217+
One occurrences file exists for each interrupt and, when read,
218+
returns the number of times the interrupt has been triggered.
219+
* *hw*/peer*/port
220+
This file describes the port number for each peer
221+
* *hw*/peer*/count
222+
This file describes the number of interrupts that can be
223+
triggered on each peer
224+
* *hw*/peer*/trigger
225+
Writing an interrupt number (any number less than the value
226+
specified in count) will trigger the interrupt on the
227+
specified peer. That peer's interrupt's occurrence file
228+
should be incremented.
229+
203230
NTB Hardware Drivers
204231
====================
205232

drivers/ntb/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ menuconfig NTB
1313

1414
if NTB
1515

16+
config NTB_MSI
17+
bool "MSI Interrupt Support"
18+
depends on PCI_MSI
19+
help
20+
Support using MSI interrupt forwarding instead of (or in addition to)
21+
hardware doorbells. MSI interrupts typically offer lower latency
22+
than doorbells and more MSI interrupts can be made available to
23+
clients. However this requires an extra memory window and support
24+
in the hardware driver for creating the MSI interrupts.
25+
26+
If unsure, say N.
1627
source "drivers/ntb/hw/Kconfig"
1728

1829
source "drivers/ntb/test/Kconfig"

drivers/ntb/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
obj-$(CONFIG_NTB) += ntb.o hw/ test/
33
obj-$(CONFIG_NTB_TRANSPORT) += ntb_transport.o
4+
5+
ntb-y := core.o
6+
ntb-$(CONFIG_NTB_MSI) += msi.o
File renamed without changes.

drivers/ntb/hw/amd/ntb_hw_amd.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int idx,
160160
}
161161

162162
/* set and verify setting the limit */
163-
write64(limit, mmio + limit_reg);
164-
reg_val = read64(mmio + limit_reg);
163+
write64(limit, peer_mmio + limit_reg);
164+
reg_val = read64(peer_mmio + limit_reg);
165165
if (reg_val != limit) {
166166
write64(base_addr, mmio + limit_reg);
167167
write64(0, peer_mmio + xlat_reg);
@@ -183,8 +183,8 @@ static int amd_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int idx,
183183
}
184184

185185
/* set and verify setting the limit */
186-
writel(limit, mmio + limit_reg);
187-
reg_val = readl(mmio + limit_reg);
186+
writel(limit, peer_mmio + limit_reg);
187+
reg_val = readl(peer_mmio + limit_reg);
188188
if (reg_val != limit) {
189189
writel(base_addr, mmio + limit_reg);
190190
writel(0, peer_mmio + xlat_reg);
@@ -333,7 +333,7 @@ static u64 amd_ntb_db_vector_mask(struct ntb_dev *ntb, int db_vector)
333333
if (db_vector < 0 || db_vector > ndev->db_count)
334334
return 0;
335335

336-
return ntb_ndev(ntb)->db_valid_mask & (1 << db_vector);
336+
return ntb_ndev(ntb)->db_valid_mask & (1ULL << db_vector);
337337
}
338338

339339
static u64 amd_ntb_db_read(struct ntb_dev *ntb)

drivers/ntb/hw/intel/ntb_hw_gen3.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ static int intel_ntb3_mw_set_trans(struct ntb_dev *ntb, int pidx, int idx,
532532
return 0;
533533
}
534534

535-
int intel_ntb3_peer_db_addr(struct ntb_dev *ntb, phys_addr_t *db_addr,
536-
resource_size_t *db_size,
537-
u64 *db_data, int db_bit)
535+
static int intel_ntb3_peer_db_addr(struct ntb_dev *ntb, phys_addr_t *db_addr,
536+
resource_size_t *db_size,
537+
u64 *db_data, int db_bit)
538538
{
539539
phys_addr_t db_addr_base;
540540
struct intel_ntb_dev *ndev = ntb_ndev(ntb);

drivers/ntb/hw/mscc/ntb_hw_switchtec.c

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ struct switchtec_ntb {
8686
bool link_is_up;
8787
enum ntb_speed link_speed;
8888
enum ntb_width link_width;
89-
struct work_struct link_reinit_work;
89+
struct work_struct check_link_status_work;
90+
bool link_force_down;
9091
};
9192

9293
static struct switchtec_ntb *ntb_sndev(struct ntb_dev *ntb)
@@ -485,33 +486,11 @@ enum switchtec_msg {
485486

486487
static int switchtec_ntb_reinit_peer(struct switchtec_ntb *sndev);
487488

488-
static void link_reinit_work(struct work_struct *work)
489-
{
490-
struct switchtec_ntb *sndev;
491-
492-
sndev = container_of(work, struct switchtec_ntb, link_reinit_work);
493-
494-
switchtec_ntb_reinit_peer(sndev);
495-
}
496-
497-
static void switchtec_ntb_check_link(struct switchtec_ntb *sndev,
498-
enum switchtec_msg msg)
489+
static void switchtec_ntb_link_status_update(struct switchtec_ntb *sndev)
499490
{
500491
int link_sta;
501492
int old = sndev->link_is_up;
502493

503-
if (msg == MSG_LINK_FORCE_DOWN) {
504-
schedule_work(&sndev->link_reinit_work);
505-
506-
if (sndev->link_is_up) {
507-
sndev->link_is_up = 0;
508-
ntb_link_event(&sndev->ntb);
509-
dev_info(&sndev->stdev->dev, "ntb link forced down\n");
510-
}
511-
512-
return;
513-
}
514-
515494
link_sta = sndev->self_shared->link_sta;
516495
if (link_sta) {
517496
u64 peer = ioread64(&sndev->peer_shared->magic);
@@ -536,6 +515,38 @@ static void switchtec_ntb_check_link(struct switchtec_ntb *sndev,
536515
}
537516
}
538517

518+
static void check_link_status_work(struct work_struct *work)
519+
{
520+
struct switchtec_ntb *sndev;
521+
522+
sndev = container_of(work, struct switchtec_ntb,
523+
check_link_status_work);
524+
525+
if (sndev->link_force_down) {
526+
sndev->link_force_down = false;
527+
switchtec_ntb_reinit_peer(sndev);
528+
529+
if (sndev->link_is_up) {
530+
sndev->link_is_up = 0;
531+
ntb_link_event(&sndev->ntb);
532+
dev_info(&sndev->stdev->dev, "ntb link forced down\n");
533+
}
534+
535+
return;
536+
}
537+
538+
switchtec_ntb_link_status_update(sndev);
539+
}
540+
541+
static void switchtec_ntb_check_link(struct switchtec_ntb *sndev,
542+
enum switchtec_msg msg)
543+
{
544+
if (msg == MSG_LINK_FORCE_DOWN)
545+
sndev->link_force_down = true;
546+
547+
schedule_work(&sndev->check_link_status_work);
548+
}
549+
539550
static void switchtec_ntb_link_notification(struct switchtec_dev *stdev)
540551
{
541552
struct switchtec_ntb *sndev = stdev->sndev;
@@ -568,7 +579,7 @@ static int switchtec_ntb_link_enable(struct ntb_dev *ntb,
568579
sndev->self_shared->link_sta = 1;
569580
switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_UP);
570581

571-
switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
582+
switchtec_ntb_link_status_update(sndev);
572583

573584
return 0;
574585
}
@@ -582,7 +593,7 @@ static int switchtec_ntb_link_disable(struct ntb_dev *ntb)
582593
sndev->self_shared->link_sta = 0;
583594
switchtec_ntb_send_msg(sndev, LINK_MESSAGE, MSG_LINK_DOWN);
584595

585-
switchtec_ntb_check_link(sndev, MSG_CHECK_LINK);
596+
switchtec_ntb_link_status_update(sndev);
586597

587598
return 0;
588599
}
@@ -835,7 +846,8 @@ static int switchtec_ntb_init_sndev(struct switchtec_ntb *sndev)
835846
sndev->ntb.topo = NTB_TOPO_SWITCH;
836847
sndev->ntb.ops = &switchtec_ntb_ops;
837848

838-
INIT_WORK(&sndev->link_reinit_work, link_reinit_work);
849+
INIT_WORK(&sndev->check_link_status_work, check_link_status_work);
850+
sndev->link_force_down = false;
839851

840852
sndev->self_partition = sndev->stdev->partition;
841853

@@ -872,7 +884,7 @@ static int switchtec_ntb_init_sndev(struct switchtec_ntb *sndev)
872884
}
873885

874886
sndev->peer_partition = ffs(tpart_vec) - 1;
875-
if (!(part_map & (1 << sndev->peer_partition))) {
887+
if (!(part_map & (1ULL << sndev->peer_partition))) {
876888
dev_err(&sndev->stdev->dev,
877889
"ntb target partition is not NT partition\n");
878890
return -ENODEV;
@@ -1448,10 +1460,16 @@ static void switchtec_ntb_deinit_db_msg_irq(struct switchtec_ntb *sndev)
14481460

14491461
static int switchtec_ntb_reinit_peer(struct switchtec_ntb *sndev)
14501462
{
1451-
dev_info(&sndev->stdev->dev, "peer reinitialized\n");
1452-
switchtec_ntb_deinit_shared_mw(sndev);
1453-
switchtec_ntb_init_mw(sndev);
1454-
return switchtec_ntb_init_shared_mw(sndev);
1463+
int rc;
1464+
1465+
if (crosslink_is_enabled(sndev))
1466+
return 0;
1467+
1468+
dev_info(&sndev->stdev->dev, "reinitialize shared memory window\n");
1469+
rc = config_rsvd_lut_win(sndev, sndev->mmio_peer_ctrl, 0,
1470+
sndev->self_partition,
1471+
sndev->self_shared_dma);
1472+
return rc;
14551473
}
14561474

14571475
static int switchtec_ntb_add(struct device *dev,

0 commit comments

Comments
 (0)