From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796542405; b=YHlrNbSIacEgOI0gnOd449zM8t67T7bPlZ4W+NSjrVVH2Pjs33SfRamRkwJDjY8K7uQI 8pwfyABONkD1dGFZ77fMGvgjlmBmV3lvt693AZIhh2bOw8xFarhQjRI/ShDYb3FagxoZA 6Rm+DnLfqaZ2IyKObKxkuIXB00zUy93SJb8BGf9tpiHI6+jS/NcAjMwk5ahXlVL0Xb75A uolP6ou6PRdVS6z0i7qPdZJTV1yVuwVNjARr7+B8agzyHOuQM4MnNISq23CyA4UfPS4tV 0Ar+mzmuTM+oF6PEVtwXphSoORqaWDNPET38iuiyi+Ymo2V+9iUcqSqfErQFxJ2mQuw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796542405; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=uJEyfo22TY7D9ES7ERVkWw0zwff/2f/8Rsvifp6fuyY=; b=yBineFNlZ4kswMLXuEBfAjgb8pfj7VgcEOcajfwHVtcsed+doExINRsgfSUY0xLCn3zf tLbb0oO3EdbdmQEiw8OfLra7PcfJwv3kqBf17lKeIjqePXo61krI1TePjEXh4Cw0IKdEU p6RCLbqkCGSOdXZs7xfV3DBPWGeP0Pjn/9ryZhmrS8sMX3VLFthwjHYNrEmFjRPHQbox4 Ex8zVxYvaU1U2dw0DtIAGydF6CapwBtFp4K7EVOB5oOqZlbudiPSaBmr7LdnL8pagApr7 T8uheJrvAnIEzVHJbRu5zUf1PI8w7quspZYfbBbr1mqMouB4WbZFAh+kFJA5n4nVl3g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Uh6FZKWt; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A28BC606A31F for ; Sun, 6 Dec 2026 07:33:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Uh6FZKWt Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37CA31F0092B; Sun, 6 Dec 2026 07:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796542405; bh=uJEyfo22TY7D9ES7ERVkWw0zwff/2f/8Rsvifp6fuyY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Uh6FZKWtfVOdqT2pRDe5mHqkXL9H+/xR350aoX+P2Y8BUW5ffv1Z3dx9Y1pGSYCOa mP3DdTcFfoafxVypg02BPzqyrYvlRiXMy0gqu1lhTA4yS03BOzd+V4/qecbToy74XR L/FJdmvjW8aYNa/dWm32oiZIYD/fULiUM5Sws+UgN2QNFoCGHpVwC2dJqbgQfCJTSO N2bYnUbRTKtE54ZqqDLGVJ3kcbQEo+Z41gwRapW6WBKWSs/WRIFYpqY+6DvbMZT4M1 TIIXsIn30+1GY/jimWGL3NpHwDNJa9WpMknWb/4oXROilmEVQgcw4BNxg/09FEDENb sWjg7tx5+F0Lg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH 1/3] NTB: ntb_transport: Run a pending link cleanup before the next link setup Reply-To: sashiko-reviews@lists.linux.dev To: "Oguzhan KAYNAK" Cc: ntb@lists.linux.dev In-Reply-To: <20261206070959.8519-2-kaynak.oguzhan0@gmail.com> References: <20261206070959.8519-1-kaynak.oguzhan0@gmail.com> <20261206070959.8519-2-kaynak.oguzhan0@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 06 Dec 2026 07:33:24 +0000 X-Mailing-List: ntb@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] ntb_transport: unsynchronized link_up check causes spurious link teardown -- commit ff41587a6452a6a2bd40eda8955de637cc27dd31 Author: Oguzhan KAYNAK NTB: ntb_transport: Run a pending link cleanup before the next link setup This commit adds a link_down_pending flag so that ntb_transport_link_work() defers link setup until a pending ntb_transport_link_cleanup() completes, a= nd has ntb_transport_link_cleanup_work() reschedule link_work if the hardware link is up. > diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c > index 3cf2d778bf925..31c214d147c4c 100644 > --- a/drivers/ntb/ntb_transport.c > +++ b/drivers/ntb/ntb_transport.c [ ... ] > @@ -1057,17 +1068,27 @@ static void ntb_transport_link_cleanup_work(struc= t work_struct *work) > struct ntb_transport_ctx *nt =3D > container_of(work, struct ntb_transport_ctx, link_cleanup); > =20 > - ntb_transport_link_cleanup(nt); > + ntb_transport_link_cleanup(nt, true); > + > + /* > + * ntb_transport_link_work() does nothing while a cleanup is pending, > + * and the cleanup may have cancelled it: set the link up now if the > + * link came back. > + */ > + if (ntb_link_is_up(nt->ndev, NULL, NULL) =3D=3D 1) > + schedule_delayed_work(&nt->link_work, 0); > } > =20 > static void ntb_transport_event_callback(void *data) > { > struct ntb_transport_ctx *nt =3D data; > =20 > - if (ntb_link_is_up(nt->ndev, NULL, NULL) =3D=3D 1) > + if (ntb_link_is_up(nt->ndev, NULL, NULL) =3D=3D 1) { > schedule_delayed_work(&nt->link_work, 0); > - else > + } else { > + atomic_set(&nt->link_down_pending, 1); > schedule_work(&nt->link_cleanup); > + } > } [Severity: Medium] Can a delayed ntb_transport_event_callback() set link_down_pending after the link has already come up, tearing down a live link? ntb_link_event() only holds ntb->ctx_lock around ntb_transport_event_callback(), which the link work items never take. If CPU0 is delayed between reading ntb_link_is_up() =3D=3D 0 and setting link_down_pending while an earlier cleanup finishes: CPU0 CPU1 ntb_transport_event_callback() ntb_transport_link_cleanup_work() ntb_link_is_up() =3D=3D 0 ntb_transport_link_cleanup(nt, true) /* delayed */ atomic_xchg(&link_down_pending, 0) ... /* hardware link comes up */ ntb_link_is_up() =3D=3D 1 schedule_delayed_work(&link_work, 0) ntb_transport_link_work() link_down_pending =3D=3D 0, link_is_up = =3D=3D 0 /* completes handshake with peer */ atomic_set_release(&link_is_up, true) atomic_set(&link_down_pending, 1) schedule_work(&link_cleanup) ntb_transport_link_cleanup_work() ntb_transport_link_cleanup(nt, true) /* tears down QPs/MWs, zeroes spads */ <-- spurious link teardown The second cleanup zeroes the local scratchpads and reschedules link_work, which then reads VERSION =3D=3D 0 and retries indefinitely while the peer s= till considers the link up and does not rewrite the scratchpads. The transport link stays wedged until another hardware link-down occurs. Serializing the ntb_link_is_up() check and link_down_pending update against ntb_transport_link_cleanup_work() and ntb_transport_link_work() would close this race. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261206070959.8519= -1-kaynak.oguzhan0@gmail.com?part=3D1