Article View: linux.kernel.netdev
Article #20986Re: [PATCH v35 net-next 2/8] net/nebula-matrix: add common resource implementation
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 12:52
Date: Mon, 23 Nov 2026 12:52
209 lines
16275 bytes
16275 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
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 control-PF probe reads firmware-written board
configuration from the mailbox BAR exactly once: the DW3 port…
- [Low] net/nebula-matrix: single-implementation hw_ops and commit
message mismatch
--
net/nebula-matrix: add common resource implementation
This adds a chip-agnostic resource layer for the Nebula Matrix driver. On
the control PF it reads the PF topology, per-PF BDF, Ethernet port and VSI
mappings from hardware and firmware registers once at probe time. It also
adds plain lookup helpers that convert between VSI, PF and Ethernet IDs.
> diff --git a/drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c b/drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c
> index f363ab1fd4168..fa5b88e8c70fc 100644
> --- a/drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c
> +++ b/drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_hw_leonis.c
[ ... ]
> +/*
> + * Registers reset to zero after cold boot / FLR / bus reset. Firmware
> + * programs valid values before driver probe, so zero is only seen on
> + * hardware fault or register read failure. Initialize data=0 to guard
> + * against nbl_hw_read_mbx_regs() early-return on bounds-check failure.
> + */
> +static void nbl_hw_get_fw_eth_map(struct nbl_hw_mgt *hw_mgt, u32 *eth_map)
> +{
> + u32 data = 0;
> +
> + nbl_hw_read_mbx_regs(hw_mgt, NBL_FW_BOARD_DW6_OFFSET, &data,
> + sizeof(data));
> + *eth_map = FIELD_GET(NBL_FW_BOARD_DW6_ETH_BITMAP_MASK, data);
> +}
[ ... ]
> +static void nbl_hw_get_board_info(struct nbl_hw_mgt *hw_mgt,
> + struct nbl_board_port_info *board_info)
> +{
> + u32 data = 0;
> +
> + nbl_hw_read_mbx_regs(hw_mgt, NBL_FW_BOARD_DW3_OFFSET, &data,
> + sizeof(data));
> + board_info->eth_num = FIELD_GET(NBL_FW_BOARD_DW3_PORT_NUM_MASK, data);
[ ... ]
> diff --git a/drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c b/drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c
> new file mode 100644
> index 0000000000000..b96ac999ec82f
> --- /dev/null
> +++ b/drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c
[ ... ]
> +static int nbl_res_ctrl_dev_setup_eth_info(struct nbl_resource_mgt *res_mgt)
> +{
[ ... ]
> + fw_port_num = res_mgt->resource_info->board_info.eth_num;
> +
> + hw_ops->get_fw_eth_map(res_mgt->hw_ops_tbl->priv, ð_bitmap);
> + if (eth_bitmap & ~((1 << NBL_MAX_ETHERNET) - 1)) {
> + dev_err(dev, "FW reported invalid eth_bitmap 0x%x\n",
> + eth_bitmap);
> + return -EINVAL;
> + }
> + if (fw_port_num != hweight32(eth_bitmap)) {
> + dev_err(dev, "FW inconsistency: port_num=%u, bitmap=0x%x\n",
> + fw_port_num, eth_bitmap);
> + return -EINVAL;
> + }
> + /*
> + * Firmware is ready before probe. Valid port counts are 1/2/4;
> + * 0 (invalid config), 3 (unsupported topology), and >4 (exceeds
> + * hardware max) are all rejected with -EINVAL.
> + */
> + if (fw_port_num == 0 || fw_port_num == 3 ||
> + fw_port_num > NBL_MAX_ETHERNET) {
> + dev_err(dev, "FW reports %u Ethernet ports, unsupported (valid: 1/2/4)\n",
> + fw_port_num);
> + return -EINVAL;
> + }
[Severity: Medium]
What happens if the control PF is probed before firmware has rewritten the
DW3 and DW6 board words?
The comment above nbl_hw_get_fw_eth_map() and nbl_hw_get_board_info() says
these registers reset to zero after cold boot, FLR or bus reset. It relies on
firmware programming them before probe.
The probe path doesn't seem to check that this has happened. There is no
ready bit, poll or -EPROBE_DEFER between nbl_hw_init_leonis() and these
single reads:
nbl_probe()->nbl_core_init()->nbl_res_init_leonis()->nbl_res_start()
->nbl_res_init_board_info()
->nbl_res_ctrl_dev_setup_eth_info()
If PF0 is bound shortly after an FLR or secondary bus reset, for example a
sysfs reset followed by a bind, both reads could return 0. Then:
eth_bitmap == 0 passes the check for bits above NBL_MAX_ETHERNET
fw_port_num == 0 passes fw_port_num != hweight32(eth_bitmap)
fw_port_num == 0 returns -EINVAL
The control PF probe would then fail for good. Later in the series the
sibling PFs wait on function 0 via nbl_probe_chip_deps(). Would they stay in
-EPROBE_DEFER until the management PF is rebound by hand?
Could the all-zero case be treated as "firmware not ready yet" instead of an
invalid configuration? A bounded readiness poll in nbl_res_start(), or
returning -EPROBE_DEFER for that case, would do it.
> + eth_info->eth_num = fw_port_num;
[ ... ]
> +static int nbl_res_start(struct nbl_resource_mgt *res_mgt)
> +{
> + struct nbl_common_info *common = res_mgt->common;
> + int ret = 0;
> +
> + if (common->has_ctrl) {
> + nbl_res_init_board_info(res_mgt);
> +
> + ret = nbl_res_init_pf_num(res_mgt);
> + if (ret)
> + return ret;
[ ... ]
> diff --git a/drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h b/drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h
> --- a/drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h
> +++ b/drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h
> @@ -44,9 +57,22 @@ struct nbl_hw_ops {
> * PFs starting at PF0.
> */
> void (*get_host_pf_mask)(struct nbl_hw_mgt *hw_mgt, u32 *pf_mask);
> + void (*get_real_bus)(struct nbl_hw_mgt *hw_mgt, u8 *bus);
>
> void (*cfg_mailbox_qinfo)(struct nbl_hw_mgt *hw_mgt, u16 func_id,
> u8 bus, u8 devid, u8 function);
> + void (*get_fw_eth_map)(struct nbl_hw_mgt *hw_mgt, u32 *eth_map);
> + /**
> + * get_board_info - Fetch board info from firmware
> + * @hw_mgt: hardware management context
> + * @board_info: output pointer for board info structure
> + *
> + * Firmware contract: board_info.eth_num MUST equal the number of
> + * unmasked PFs from get_host_pf_mask(). See get_host_pf_mask for
> + * details.
> + */
> + void (*get_board_info)(struct nbl_hw_mgt *hw_mgt,
> + struct nbl_board_port_info *board_info);
> };
>
> struct nbl_hw_ops_tbl {
[Severity: Low]
This patch adds four more callbacks to struct nbl_hw_ops (flush_write,
get_real_bus, get_fw_eth_map and get_board_info), and nbl_hw_ops still
has only one implementation, the static hw_ops in nbl_hw_leonis.c.
v35 dropped nbl_resource_ops after the earlier request not to add ops
tables until a second implementation exists. Does the same reasoning
apply to nbl_hw_ops?
The callers in nbl_res_init_pf_num(), nbl_res_ctrl_dev_pf_info_init(),
nbl_res_ctrl_dev_setup_eth_info() and nbl_res_init_board_info() are all
in nbl_hw_leonis/nbl_resource_leonis.c, so this is Leonis code calling
Leonis helpers through res_mgt->hw_ops_tbl->ops. nbl_hw_setup_ops()
also devm-allocates a wrapper whose only job is to point at a static
table. Could these be direct calls until draco actually lands?
The commit message also doesn't seem to match the code. It says
nbl_hw_ops_tbl is the only remaining ops table, but struct
nbl_channel_ops_tbl is already in struct nbl_interface, and a later
patch in the series adds struct nbl_dispatch_ops_tbl. It also says the
PF mask validation and the BDF/Eth/VSI table construction are shared
between the two chip families. Those are static functions in
nbl_resource_leonis.c, called only from nbl_res_init_leonis(). Only the
ID conversion helpers in nbl_resource.c are chip-agnostic. Can the
description be updated, or the shared code moved where the message
says it is?
Finally, this patch removes the NULL checks on the static hw_ops
members in nbl_hw_setup_ops() that the channel layer patch earlier in
this series added. Those checks could never fire. Could they be left
out of the patch that introduces nbl_hw_setup_ops(), so this one does
not have to delete them?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119113530.32107-1-illusion.wang%40nebula-matrix.com
Technical Details
Message-ID:
<179543832118.3135.18073760250615993889@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369365-linux-kernel-netdev=dewy.ruReferences:
<20261119113530.32107-3-illusion.wang@nebula-matrix.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369365-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH v35 net-next 2/8] net/nebula-matrix: add common resource implementation Date: Mon, 23 Nov 2026 12:52:01 +0000 Organization: Usenet Network Message-ID: <179543832118.3135.18073760250615993889@kernel.org> References: <20261119113530.32107-3-illusion.wang@nebula-matrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3880389"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:+qBRFNK4co1t+aMPWzhZ30/J5Dg= sha256:pxW0QJn8ndsGeB9ucdUl+Do+PFsblPeSvdQm1huv/90= sha1:Pqsn4R/OBVye0kmEfrZei2pBAqc= sha256:ZI/T2qIzk3f3I5DFHmSRilgc5dJnbeN9n1+QD0RUeZA= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id E61B6125DB1; Mon, 23 Nov 2026 15:52:18 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.5 X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XpFEGlWIsCPK; Mon, 23 Nov 2026 15:52:15 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-369365-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 021F3125DAD; Mon, 23 Nov 2026 15:52:05 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 4A147604012; Mon, 23 Nov 2026 12:52:05 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795438323; b=lZjbtWvNA/aZypaaApxrXRyQxeqb2SK5SSsWELz3m8IOy73wWIc4RhrA0G3cQLS++Jlu BrgWSnWd3GDM2h9X8omBjnICNBy8ooR6UGzJ9V5EnvvZcVtnUrfah73MAAZx+1O15IpTB 0oFv7UnAxjf4JsOxKxVpItizCYtDr/CZ99JxeDNNF2MXuxuQFstxo5hXG9YQGzNwTuhod JSB9aNg8l3xGiusaWu1pw35B3ebDd4wRG8b0Iu9wJauxK3Bi6JRXztUoUY6OrGWkXz4tq B7O9bJbCmG7hT1jSl8TyYAEPKf15DBkgwzjqr2pa+z0SFfoe00eVzJmwOG93Wx/+nKQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795438323; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=p2IWpjpm56FZDYL2J6E/8Z+eeikvXsCr0/LAHQK5bkI=; b=JwWZ47owbhqe89iiYWH+Fga50NQJ81+REV3BHv9PDqTD2MzuCgaDDPF6xIIGmeOASrqG VUFnJfueLdBLcbzcmsEZ56bC0nDDdhGHXwxrNJpVBri5j1ZTsvu8HgTogFKm1BVEeXIJg 5XkUwoJ0WJ7YUZ/2ue4tQK0kYHPfm+qaweL6Y8TRL1aM/GAVA8Pp5YOsrZfyUQIh/bERd u9cDsjTb7mG/ogcYgg1jGh5ahYV40tbfe91f78+LeskFJLKGcMKwWCdyjXCtDNDHv/Ft+ IRx5gguKy7f/WglRr5h1LTRwZh/PpHTPWlhpcB6GNG6RvkECJm08X958sfqjjLGbARQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KEyiJbLf; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 78365606A682; Mon, 23 Nov 2026 12:52:03 +0000 (UTC) X-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=KEyiJbLf X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795438322; b=OSLa/aeGThBV5ierxhc5ROL9ZDHmk+XobGK93GI9TkcAwQI9MF6jJxa4iGvusMDdFbzp OgEHm5kgEz7+HAW4gDwhfaPOefkahNllCvbFip5BGAmBJ+TrgH/tOVxm/Nk3YvHq3mZEq TgDX3162LjVqqwyEoK6rPO2x5RemTlJzlnYcj5tRj1GbV8I1qid0G/xdqEZHbPsLHc+Bc pcjUlGudGW4AgYK5+pVHSCLhoyIiQaLSZEbNGwCX0D33vK1psVbhTNrJDY77S9cfuvWrd 0K8/p4jjTySV7tdcFjVTa8ULOYpIZyDqfc1uDXRBr4cepX6HBts+rlPsMmPSIlmfUmA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795438322; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=p2IWpjpm56FZDYL2J6E/8Z+eeikvXsCr0/LAHQK5bkI=; b=h0fpuylPh3Mh0xJw/wSyA3BN7dPYaI5lVhx6rGw+lSTqi57i9TNcBZFKZBB0dvhI9ja5 XU8ii1Usq7S2dBRrms0klfM+GECL9oRotD6CLIk1AduvKGSvzfbzqh3ANlWYIDMsZufdF AyGA/7mvh0NXTul8tY+B+ApoNzBap7nGXHNC9qwXy6Osm8rkygsarD80HHFN5gPz/PkEV XDjlmgsJwgBcPkvUh3nvzRK45w6PqBW3jzOsYqSPjYfJ8dfquVI+HPrIMhZfmODpNWdYs FP9svOwrWvUA7drknMjsdLKVdQv5+XLxfTkMz4XnzRFDxSn+RVc2DMkYPB09KFIfL5g== X-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=KEyiJbLf; arc=none smtp.remote-ip=100.103.45.18 X-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 99183606A334; Mon, 23 Nov 2026 12:52:02 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B24F1F000C4; Mon, 23 Nov 2026 12:52:01 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795438322; bh=p2IWpjpm56FZDYL2J6E/8Z+eeikvXsCr0/LAHQK5bkI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=KEyiJbLfUDmsEJfa1Kx/wZf9FzRuBcw9SnMx6X/r0k/X0spu68I7dygL0JCwYiJKh eNcqEI+kKP7ihvrND/GSFYfWRGr9VwVGWa/qGPz6rGUR8FruTfUHko0l4Bww8stA/a /JPdAHt9y0Lkc08FputF9Y4puMnCcfik0wTll5OxW79iwDDGt47r7dvaTb+9Hn6Taf 6I7RxaCWCy5EZNfPED2PCI/rNlG84I+cvDWvC1pHS7m0AStNksuJQ8pBMgE7fJU2N8 DWTbLLeZnpAMV0XidiIo3lpjCEbnsC5yS5RUom6JWBScIt7dG1T/B+sg8yYX46aVOr ev1jZdef4GztQ== X-Cc: dimon.zhao@nebula-matrix.com, alvin.wang@nebula-matrix.com, sam.chen@nebula-matrix.com, netdev@vger.kernel.org, kuba@kernel.org, andrew+netdev@lunn.ch, pabeni@redhat.com, edumazet@google.com, horms@kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261119113530.32107-3-illusion.wang@nebula-matrix.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list