From: sashiko-bot@kernel.org
To: "Oguzhan KAYNAK" <kaynak.oguzhan0@gmail.com>
Cc: ntb@lists.linux.dev
Subject: Re: [RFC PATCH 2/3] NTB: ntb_transport: Retry link setup on a zero peer MW size
Date: Sun, 06 Dec 2026 07:32:38 +0000 [thread overview]
Message-ID: <sashiko-outbox-252246@kernel.org> (raw)
In-Reply-To: <20261206070959.8519-3-kaynak.oguzhan0@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] ntb: link setup livelock in ntb_transport_link_work() on zero
peer MW size
- [Low] ntb: ntb_transport_link_work() leaves VERSION set on zero MW
size retry
--
commit a8fba74b998be95cc0493ee4cdfa68d6dd40c92d
Author: Oguzhan KAYNAK <kaynak.oguzhan0@gmail.com>
NTB: ntb_transport: Retry link setup on a zero peer MW size
This commit makes ntb_transport_link_work() retry link setup when a peer's
memory window size scratchpad reads as zero instead of passing zero to
ntb_set_mw() and aborting.
> diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
> index 31c214d147c4c..478f2f6a399f5 100644
> --- a/drivers/ntb/ntb_transport.c
> +++ b/drivers/ntb/ntb_transport.c
> @@ -1172,6 +1172,14 @@ static void ntb_transport_link_work(struct work_struct *work)
>
> dev_dbg(&pdev->dev, "Remote MW%d size = %#llx\n", i, val64);
>
> + /*
> + * A zero size is not a failure: a link cleanup on our side
> + * cleared the scratchpads while the peer was writing them.
> + * Retry; the peer writes them again on its next try.
> + */
> + if (!val64)
> + goto out;
> +
> rc = ntb_set_mw(nt, i, val64);
> if (rc)
> goto out1;
[Severity: Medium]
Can this retry livelock forever if the peer has already brought its side of
the link up?
ntb_transport_link_work() writes all local scratchpads including VERSION to
the peer before reading its own. During a link bounce, a local cleanup can
zero MW0_SZ_HIGH/LOW after the peer writes them, while local link_work still
publishes valid scratchpads to the peer:
Host A Host B
ntb_transport_link_cleanup() ntb_transport_link_work()
clear VERSION..NUM_MWS write A's MW0_SZ_HIGH/LOW
clear MW0_SZ_HIGH/LOW
schedule link_work
ntb_transport_link_work()
write B's MW0_SZ..VERSION write A's NUM_MWS, NUM_QPS, VERSION
read B's scratchpads (valid)
link_is_up = true; return
read A's VERSION..NUM_MWS
read A's MW0_SZ == 0
goto out <-- retries every 10 ms forever
Once Host B sets link_is_up to true, it returns early from
ntb_transport_link_work() and will never rewrite Host A's MW size
scratchpads. Host A then retries every 10 ms rewriting peer scratchpads
over MMIO while the transport link never comes up.
[Severity: Low]
Does jumping to out without clearing the local VERSION scratchpad allow a
subsequent retry to read a torn 64-bit MW size?
VERSION acts as a publication barrier for the two 32-bit writes to
MW0_SZ_HIGH and MW0_SZ_LOW. With VERSION left set, a later retry landing
between those two writes on a peer with a > 4 GiB MW whose lower 32 bits are
non-zero reads a non-zero truncated size ((u64)upper << 32).
Passing that torn size to ntb_set_mw() either fails and aborts link_work, or
if the allocation succeeds, causes ntb_transport_setup_qp_mw() to cast
mw->xlat_size to unsigned int (yielding 0) and underflow rx_size. Clearing
local VERSION before jumping to out avoids reading a half-written size.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261206070959.8519-1-kaynak.oguzhan0@gmail.com?part=2
next prev parent reply other threads:[~2026-12-06 7:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-252246@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kaynak.oguzhan0@gmail.com \
--cc=ntb@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.