Thread (68 messages) 68 messages, 4 authors, 2026-01-23
STALE135d

[RFC PATCH v4 24/38] NTB: ntb_transport: Run ntb_set_mw() before link-up negotiation

From: Koichiro Den <hidden>
Date: 2026-01-18 13:55:29
Also in: dmaengine, linux-devicetree, linux-doc, linux-iommu, linux-kselftest, linux-pci, linux-renesas-soc, lkml
Subsystem: ntb driver core, the rest · Maintainers: Jon Mason, Dave Jiang, Allen Hubbe, Linus Torvalds

Some backends may need to program BAR subrange mappings, and due to
pci_epc_set_bar() submap API constraint, the entire BAR layout needs to
be provided when calling the function. Since one MW that is to be
programmed by ntb_set_mw() can be the last piece that allows us to call
pci_epc_set_bar() for the BAR, calling it only after link-up can race
with post-link-up setup on the host.

Invoke ntb_set_mw() before the link-up handshake so the MW translation
is established early and the post-link-up setup can run without relying
on late MW programming. Since ntb_set_mw() can re-setup the MW when it
turns out that the size differs, it's safe to do so.

Signed-off-by: Koichiro Den <redacted>
---
 drivers/ntb/ntb_transport_core.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/drivers/ntb/ntb_transport_core.c b/drivers/ntb/ntb_transport_core.c
index 2129fa7a22d8..185d73f8ea93 100644
--- a/drivers/ntb/ntb_transport_core.c
+++ b/drivers/ntb/ntb_transport_core.c
@@ -977,6 +977,10 @@ static void ntb_transport_link_work(struct work_struct *work)
 
 		spad = MW0_SZ_LOW + (i * 2);
 		ntb_peer_spad_write(ndev, PIDX, spad, lower_32_bits(size));
+
+		rc = ntb_set_mw(nt, i, size);
+		if (rc)
+			goto out;
 	}
 
 	ntb_peer_spad_write(ndev, PIDX, NUM_MWS, nt->mw_count);
@@ -1032,6 +1036,7 @@ static void ntb_transport_link_work(struct work_struct *work)
 
 		dev_dbg(&pdev->dev, "Remote MW%d size = %#llx\n", i, val64);
 
+		/* If it turns out that the size differs, reconfigure it */
 		rc = ntb_set_mw(nt, i, val64);
 		if (rc)
 			goto out1;
-- 
2.51.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help