All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] NTB: ntb_transport: Lost link-up after a late link cleanup
@ 2026-12-06  7:09 Oguzhan KAYNAK
  2026-12-06  7:09 ` [RFC PATCH 1/3] NTB: ntb_transport: Run a pending link cleanup before the next link setup Oguzhan KAYNAK
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Oguzhan KAYNAK @ 2026-12-06  7:09 UTC (permalink / raw)
  To: Jon Mason, Dave Jiang, Allen Hubbe
  Cc: Koichiro Den, Logan Gunthorpe, Frank Li, ntb, linux-kernel,
	Oguzhan KAYNAK

ntb_transport can stay link-down after both sides have loaded it. The
event at probe time sees the link down and queues link_cleanup; the
peer's link-up queues link_work; if the cleanup runs after that, it
either cancels link_work, or tears the new link down, or clears the
scratchpads while the peer writes them. In each case nothing sets the
link up again until the next link event.

1/3 orders the two works: link_work does nothing while a link-down's
cleanup is pending, and the cleanup queues link_work when it is done.
2/3 retries link setup on a zero peer MW size instead of giving up.
3/3 keeps the scratchpads (except QP_LINKS) in a cleanup before the
first link-up, so it does not clear what the peer is already writing
for this link.

What this does not cover, and why it is an RFC: after the link has been
up, a cleanup still clears all scratchpads and can do so while the peer
rewrites them on a real bounce. The peer keeps retrying until it reads
ours, so with 1/3 and 2/3 it normally writes them again, but a clear
between its last write and its read would leave us with an incomplete
set; and a clear between the high and low halves of an MW size gives a
wrong non-zero size for windows of 4 GiB or more, which 2/3 does not
catch. I did not see either in testing. Also, 3/3 assumes the
scratchpads hold nothing from an earlier link at probe time, normally
true after our ntb_transport_free() or a device reset but not after a
crash or kexec. A clear at probe while the link is still down would
cover that, unless the peer can write them then. Closing all of this
seems to need a change to the handshake (a generation number, or
clearing on the link-down event itself); I would like to hear which
direction you prefer.

This applies on top of Koichiro Den's "[PATCH v4 00/15] NTB:
ntb_transport: Miscellaneous fixes" [1], which reworks the same
functions; the race is older than that series. Not for stable as is.

Tested on two KVM guests joined by an emulated NTB device (qemu-ntb
[2]), not on NTB hardware: guest A loads ntb_transport, guest B 0-30
ms later; the link must come up within 10 s. A test-only change [3]
delays the cleanup work by 200 ms to force the order; kprobe traces
(ktrace=1 in [3]) tell the rounds in which the cleanup ran after the
link-up event on A:

                     rounds   cleanup after   link came up in
                              link-up         those rounds
  v4 series              30   10              0
  + this series         100   100             100

With the v4 series the 10 window rounds were the only failures; with
this series all 100 rounds came up. Without the delay, with four
busy-loop processes on A while it loads, the link did not come up in 4
of 560 rounds with the v4 series and in 3 of 115 rounds without it
(short runs: without the v4 series the guests stop at the removal-time
bugs it fixes). With this series 200 such rounds all came up; such runs
hit the window only once or twice in 200 rounds, so the forced runs are
the real test. With this series the unbind-under-load test (use_dma=1)
and the load/unload test (use_dma=1 and 0) in [3] pass, 100 rounds
each.

AI (Claude) was used to write and run the tests and to write the
reports; I ran the tests and confirmed the results.

[1] https://lore.kernel.org/r/20261127020533.2481725-1-den@valinux.co.jp/
[2] https://github.com/oguzhankynk/qemu-ntb
[3] https://github.com/oguzhankynk/qemu-ntb/blob/ntb-transport-teardown/docs/transport-teardown.md

Oguzhan KAYNAK (3):
  NTB: ntb_transport: Run a pending link cleanup before the next link
    setup
  NTB: ntb_transport: Retry link setup on a zero peer MW size
  NTB: ntb_transport: Keep scratchpads in a cleanup before first link-up

 drivers/ntb/ntb_transport.c | 60 +++++++++++++++++++++++++++++++++----
 1 file changed, 54 insertions(+), 6 deletions(-)


base-commit: 0aa2e6bc39f17e1199345aaf21278e3ea25e6036
prerequisite-patch-id: b954941a7a66ae77636ddc401305db31689138c9
prerequisite-patch-id: e6ed5be0fbead6a3c00bbc42153eabcaf42d11fb
prerequisite-patch-id: 3f510b83fbf9240c64ea6115de25ac8ef8642529
prerequisite-patch-id: 8a4e919a25055c8f3bbed01def07b5bfbbcc25fb
prerequisite-patch-id: 4145d6956e9f03f3c425f093b68f6b617290302b
prerequisite-patch-id: a83d11a915d2edd5ee5ffb82f7656cda47161545
prerequisite-patch-id: 06ff83ea4246b902816f01268849e6f5edc7cf64
prerequisite-patch-id: 1add4889fcfc25e4e111c0103ca947ad301e2e4c
prerequisite-patch-id: cdfac2a4b47b92c9b5c454dbd047577284190c94
prerequisite-patch-id: 1bafe7eb5b5db9a3fe355162d6ac30d3cc77507e
prerequisite-patch-id: 050f5390a0004e80e56187512162195e657dda36
prerequisite-patch-id: 369b25058434db698967792ac21df54d0f6a4dd3
prerequisite-patch-id: 91c68f035371cd778436877a73afba71e07ae881
prerequisite-patch-id: 8e043b113b4d5538a30c4df4babc1d70ba227474
prerequisite-patch-id: bd22304fa63b345a852032f369fa98bc19e7b2ab
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-12-06  7:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-06  7:09 [RFC PATCH 0/3] NTB: ntb_transport: Lost link-up after a late link cleanup Oguzhan KAYNAK
2026-12-06  7:09 ` [RFC PATCH 1/3] NTB: ntb_transport: Run a pending link cleanup before the next link setup Oguzhan KAYNAK
2026-12-06  7:33   ` sashiko-bot
2026-12-06  7:09 ` [RFC PATCH 2/3] NTB: ntb_transport: Retry link setup on a zero peer MW size Oguzhan KAYNAK
2026-12-06  7:32   ` sashiko-bot
2026-12-06  7:09 ` [RFC PATCH 3/3] NTB: ntb_transport: Keep scratchpads in a cleanup before first link-up Oguzhan KAYNAK
2026-12-06  7:35   ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.