From: netdev-bot+sashiko@kernel.org
To: me@7xz.dev
Cc: sam@mendozajonas.com, fercerpav@gmail.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, delphine_cc_chiu@wiwynn.com
Subject: Re: [PATCH net] net/ncsi: fix channel loop termination when Channel Count is 0
Date: Mon, 23 Nov 2026 10:28:40 +0000 [thread overview]
Message-ID: <179542972017.3135.10691735313982658423@kernel.org> (raw)
In-Reply-To: <20261119100625.72505-1-me@7xz.dev>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 (1) · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The commit message says that "With the patch, Channel Count 0
behaves exactly like Channel Count 1" and that the probe-path change…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch's
own reasoning depends on it: the commit message says "Fixing the loop…
--
net/ncsi: fix channel loop termination when Channel Count is 0
This patch changes the termination checks of the channel walks in
ncsi_suspend_channel() and ncsi_probe_channel() from "==" to ">=". The
goal is that a controller reporting Channel Count 0 in its Get
Capabilities response can no longer make the walks run past the reported
count. The suspend_gls change fixes a hang seen after a link-down AEN.
> diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
> index 1d63958c4429b..c5cf2ca0385c1 100644
> --- a/net/ncsi/ncsi-manage.c
> +++ b/net/ncsi/ncsi-manage.c
[ ... ]
> @@ -1491,7 +1491,7 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)
> ndp->channel_probe_id++;
> }
>
> - if (ndp->channel_probe_id == ndp->channel_count) {
> + if (ndp->channel_probe_id >= ndp->channel_count) {
> ndp->channel_probe_id = 0;
> nd->state = ncsi_dev_state_probe_dp;
> }
[Severity: High]
This is a pre-existing issue, not one introduced by this patch. The
commit message says:
Fixing the loop bounds handles any reported value where it is used
Does that hold for large counts? ncsi_rsp_handler_gc() still stores the
8-bit Channel Count with no upper bound:
net/ncsi/ncsi-rsp.c:ncsi_rsp_handler_gc() {
...
np->ndp->channel_count = rsp->channel_cnt;
...
}
A controller can report a count from 33 to 255. Both this probe loop and
the suspend_gls state in ncsi_suspend_channel() then send commands with
nca.channel = channel_probe_id, up to channel 254.
ncsi_cmd_build_header() does not mask the channel:
#define NCSI_TO_CHANNEL(p, c) (((p) << NCSI_PACKAGE_SHIFT) | (c))
So channel 31 becomes the reserved package-level channel. On package 0,
channel 32 goes out as 0x20, which is package 1, channel 0.
A channel that does not answer does not stop the walk.
ncsi_request_timeout()->ncsi_free_request() schedules the work again and
probing continues.
Suppose a second package, or an emulator that echoes the channel byte,
answers the CIS sent to 0x20. Package 1 has not been added yet, because
that only happens in ncsi_rsp_handler_sp(). So
ncsi_find_package_and_channel() returns np == NULL and nc == NULL:
net/ncsi/ncsi-rsp.c:ncsi_rsp_handler_cis() {
...
ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, &np, &nc);
if (!nc) {
if (ndp->flags & NCSI_DEV_PROBED)
return -ENXIO;
id = NCSI_CHANNEL_INDEX(rsp->rsp.common.channel);
nc = ncsi_add_channel(np, id);
}
...
}
NCSI_DEV_PROBED is still clear during probe. Can ncsi_add_channel() then
oops on spin_lock_irqsave(&np->lock, flags) in the NET_RX softirq?
The old "==" check produced the same aliasing for these counts. Would it
help to clamp channel_cnt in ncsi_rsp_handler_gc() to the range 1 to
NCSI_MAX_CHANNEL - 1, and to add an np NULL check in
ncsi_rsp_handler_cis()?
[Severity: Medium]
The commit message says:
With the patch, Channel Count 0 behaves exactly like Channel Count 1
(same command counts); Channel Count 1 is unchanged.
It also says the probe path change "removes the ordering dependency".
Is that true for ncsi_probe_channel()?
This check runs after every CIS/GVI/GC/GLS step. It compares against
ndp->channel_count, which is a single device-wide value.
ncsi_register_dev() sets it to NCSI_RESERVED_CHANNEL once. After that,
only ncsi_rsp_handler_gc() writes it, and it is never reset between
packages.
Take a single package that reports 0. If the GC response is processed
before the check that follows the GC command, as in the tests described
above, the check sees 0 >= 0. The state then moves to probe_dp and GLS is
never sent to channel 0.
If the response arrives later, GLS is sent. With a count of 1, GLS is
always sent. So with a count of 0, the result still depends on response
timing.
Now take multiple packages, where package N reports 0. The probe of
package N+1 sends CIS to channel 0 and hits the check right away:
ncsi_dev_state_probe_cis:
send CIS to channel 0
nd->state = ncsi_dev_state_probe_gvi
channel_probe_id (0) >= channel_count (0)
nd->state = ncsi_dev_state_probe_dp
GVI, GC and GLS are never sent to package N+1 channel 0. Its caps,
version and link state stay at zero, and its other channels are not
probed. The zero caps could also make ncsi_check_hwa() treat the device
as not supporting HWA.
"==" behaves the same way in both of these cases, so this is no worse
than before. For a count of 0 to really behave like a count of 1, would
it need a clamp such as max(channel_cnt, 1), or a per-package bound?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119100625.72505-1-me%407xz.dev
prev parent reply other threads:[~2026-11-23 10:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 10:06 [PATCH net] net/ncsi: fix channel loop termination when Channel Count is 0 Sihyeon Park
2026-11-23 10:28 ` netdev-bot+sashiko [this message]
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=179542972017.3135.10691735313982658423@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=delphine_cc_chiu@wiwynn.com \
--cc=edumazet@kernel.org \
--cc=fercerpav@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@7xz.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sam@mendozajonas.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox