mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: illusion.wang@nebula-matrix.com
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
Subject: Re: [PATCH v34 net-next 8/8] net/nebula-matrix: add common dev start/stop operation
Date: Mon, 16 Nov 2026 13:54:49 +0000	[thread overview]
Message-ID: <179483728908.3136.13154556595001281898@kernel.org> (raw)
In-Reply-To: <20261112094925.6098-9-illusion.wang@nebula-matrix.com>

Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 4

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] net/nebula-matrix: unbind race and managed link del in
  nbl_probe_chip_deps()
- [Low] This patch's commit message, and the new comment in
  nbl_dev_stop() (around nbl_dev.c:729), say the coherent MSI-X map…
- [Low] The comment on nbl_dev_clear_interrupt_scheme() (nbl_dev.c:260)
  says "The handler is expected to be gone by now: both callers run…
- [Low] A comment in nbl_res_remove_leonis()
  (nbl_resource_leonis.c:358-360) says "Sibling PFs are already unbound…
- [Low] The kernel-doc of nbl_res_intr_cfg_msix_map()
  (nbl_interrupt.c:361-363) says "The in-tree caller…

--

net/nebula-matrix: add common dev start/stop operation

This adds nbl_dev_start() and nbl_dev_stop(), which nbl_probe() and
nbl_remove() call through nbl_core_start() and nbl_core_stop(). Start
configures the MSI-X map, fetches the VSI/ETH ids, allocates the MSI-X
vectors and arms the mailbox interrupt, and stop undoes those steps.
nbl_probe() also now rejects a function that has neither the ctrl nor
the net capability.

> diff --git a/drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c b/drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c
> index 0cc0c58ad6336..e91ec22e3f76b 100644
> --- a/drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c
> +++ b/drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dev.c

[ ... ]

> +static int nbl_dev_cfg_msix_map(struct nbl_dev_mgt *dev_mgt)
> +{

[ ... ]

> +	err = disp_ops->cfg_msix_map(dev_mgt->disp_ops_tbl->priv,
> +				     msix_net_num, msix_not_net_num,
> +				     mask_en);
> +
> +	return err;
> +}

[Severity: Low]
This isn't a bug, but nbl_dev_cfg_msix_map() is now the in-tree caller of
cfg_msix_map. The kernel-doc of nbl_res_intr_cfg_msix_map() in
nbl_interrupt.c names a different function:

 * in-tree caller (nbl_dev_init_msix_cnt()) asks for one non-net vector
 * per PF, far below NBL_MAX_OTHER_INTERRUPT.

nbl_dev_init_msix_cnt() only sets serv_info[NBL_MSIX_MAILBOX_TYPE].num = 1
and never calls cfg_msix_map.

Should the kernel-doc point to nbl_dev_cfg_msix_map(), reached from
nbl_dev_start(), instead?

[ ... ]

> + * The handler is expected to be gone by now: both callers run
> + * nbl_dev_free_mailbox_irq() first.
> + */
> +static void nbl_dev_clear_interrupt_scheme(struct nbl_dev_mgt *dev_mgt)
> +{
> +	struct nbl_common_info *common = dev_mgt->common;
> +
> +	pci_free_irq_vectors(common->pdev);
> +}

[Severity: Low]
Is this comment accurate for the nbl_dev_start() rollback? Five of the
error exits in nbl_dev_start() jump straight to err_destroy_map. That
label calls nbl_dev_clear_interrupt_scheme() without
nbl_dev_free_mailbox_irq():

	ret = nbl_dev_cfg_msix_map(dev_mgt);
	if (ret)
		goto err_destroy_map;
	...
	ret = nbl_dev_request_mailbox_irq(dev_mgt);
	if (ret)
		goto err_destroy_map;

The same applies to the get_vsi_id, get_eth_id and
nbl_dev_init_interrupt_scheme() failures in between. Only the
nbl_dev_enable_mailbox_irq() failure goes through err_free_irq.

On those direct paths request_irq() was either never reached or failed,
so no handler is registered and nothing goes wrong today.

Could the comment describe that case instead of saying that both callers
free the IRQ first?

[ ... ]

> @@ -303,3 +559,185 @@ void nbl_dev_remove(struct nbl_adapter *adapter)

[ ... ]

> +void nbl_dev_stop(struct nbl_adapter *adapter)
> +{

[ ... ]

> +	/*
> +	 * Destroy the hardware MSI-X map: masks all device vectors and
> +	 * clears the pcompleter map entry.
> +	 *
> +	 * Best-effort: if the destroy RPC fails, the control PF still owns
> +	 * this function's map entry, its intr_net/other_bmap bits and its
> +	 * kcalloc()ed vector array.  Those are host resources of that
> +	 * driver, released either by a later successful configuration of
> +	 * this function - nbl_res_intr_cfg_msix_map() invalidates and
> +	 * rewrites the entry, releases the old bits and frees the old array
> +	 * on its had_config path - or by nbl_intr_mgt_stop() when the
> +	 * control PF is removed, which walks every
> +	 * NBL_INTR_FUNC_CONFIGURED function through
> +	 * __nbl_res_intr_prepare_destroy_msix_map() and clears the
> +	 * FUNCTION_MSIX_MAP valid bit.  The coherent map table is neither
> +	 * freed nor reallocated by reconfiguration: it is kept for the
> +	 * function's lifetime and released only by nbl_intr_mgt_stop().
> +	 * Both rewrite the hardware entry without a chip reset; nothing else
> +	 * collects it, so a stranded one just stays as it is, and nothing
> +	 * requests one.
> +	 *
> +	 * pci_clear_master() on a non-control PF cannot stop DMA using the
> +	 * management PF's BDF.  It has not run yet on the control PF either,
> +	 * since nbl_remove() clears it after this function returns; what
> +	 * makes the only free - the one in nbl_intr_mgt_stop() - safe is
> +	 * that it runs after that point, with bus mastering off.
> +	 */

[Severity: Low]
Is "the only free" accurate here? The commit message makes the same
claim:

  The coherent map table is different: neither per-function path frees
  it, it is kept for the function's lifetime and reused in place, and
  nbl_intr_mgt_stop() is the only place it is released.

nbl_res_intr_cfg_msix_map() is a per-function path. Its
release_vecs_unlock error label frees the table while the control PF is
still bus master:

	if (!had_config && official_tbl->base_addr) {
		dma_free_coherent(dev, official_tbl->size,
				  official_tbl->base_addr,
				  official_tbl->dma);

had_config is false on a first configuration. It is also false after a
destroy, because __nbl_res_intr_complete_destroy_msix_map() keeps
base_addr but resets the state:

	func_res->state = NBL_INTR_FUNC_IDLE;

Suppose a sibling PF is configured again after an earlier destroy.
cfg_msix_map reuses the kept table, which the pcompleter has already
used. If a later vector allocation then fails with -EAGAIN, the error
path frees that table.

That contradicts the label's own comment ("release the DMA table
allocated during this call"). It also contradicts the keep-for-lifetime
rule documented in complete_destroy.

With the in-tree vector counts (one non-net vector per PF) the bitmap
pools can't run out, so the stop ordering added here is still safe
today.

Should the error path free the table only when this call allocated it?
Alternatively, should the commit message and this comment be adjusted?

> +	ret = nbl_dev_destroy_msix_map(dev_mgt);
> +	if (ret)
> +		dev_err(dev_mgt->common->dev,
> +			"Failed to destroy MSI-X map: %d\n", ret);

[Severity: Medium]
This patch doesn't change nbl_probe_chip_deps(), but with
nbl_core_start() a sibling PF now sends cfg_msix_map, get_vsi_id and
get_eth_id to func 0 from inside its own probe. The ordering that
nbl_probe_chip_deps() is meant to guarantee therefore matters more
now. Does it hold if func 0 is unbound while a sibling PF is probing?

In __device_release_driver(), device_links_busy() moves func 0's
links.status to DL_DEV_UNBINDING before device_remove() calls
nbl_remove(). Two things are only cleared after device_remove()
returns: mgt->dev.driver, by device_unbind_cleanup(), and
knode_driver, by klist_remove(). So for the whole of func 0's
nbl_core_stop() and nbl_core_remove(), the post-check in
nbl_probe_chip_deps() still passes:

	if (READ_ONCE(mgt->dev.driver) != pdev->dev.driver ||
	    !device_is_bound(&mgt->dev)) {

In that window, device_link_add() sees the supplier in
DL_DEV_UNBINDING and creates the link in DL_STATE_SUPPLIER_UNBIND.
nbl_probe_chip_deps() returns 0 anyway. The sibling then runs
nbl_core_init() and nbl_dev_start() against a control PF that is
disabling its mailbox and heading into nbl_intr_mgt_stop().

device_links_unbind_consumers() has already run on func 0, so nothing
unbinds the sibling afterwards. If the sibling's probe does complete,
device_links_driver_bound() hits its
WARN_ON(link->status != DL_STATE_CONSUMER_PROBE).

The other outcome of the race is also wrong. If func 0 has finished
nbl_remove() by the time of the post-check, the check fires and calls
device_link_del() on a link created with DL_FLAG_AUTOPROBE_CONSUMER.
That is a managed link, and the consumer is registered, so
device_link_put_kref() takes its "Unable to drop a managed device
link reference" WARN branch and leaves the link in place.

Triggering this needs root to unbind func 0 while a sibling probes.
The window is all of nbl_remove(), though, which sleeps during the
mailbox and interrupt teardown.

Could nbl_probe_chip_deps() check link->status on the link it just
added, and defer unless it is DL_STATE_CONSUMER_PROBE? A link in that
state makes device_links_busy() wait for the sibling's probe before
func 0 is unbound.

And should the defer path keep the managed link instead of calling
device_link_del() on it? That would let the driver core reprobe the
sibling when func 0 binds again.

[Severity: Low]
This destroy RPC can fail, for example with a polling-mode -ETIMEDOUT.
The comment above says the sibling's entry then stays
NBL_INTR_FUNC_CONFIGURED until nbl_intr_mgt_stop() collects it.

Does that make the existing comment in nbl_res_remove_leonis()
inaccurate?

	 * Sibling PFs are already unbound by the device-link ordering
	 * so no remote PF still has a live map entry or a running
	 * mailbox RPC at this point.

After this patch, a sibling that unbound after a failed destroy still
has a valid map entry when nbl_res_remove_leonis() runs.

The code handles this, because nbl_intr_mgt_stop() walks every
CONFIGURED function. Could the leonis comment be updated so that a later
change doesn't drop that walk based on it?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112094925.6098-1-illusion.wang%40nebula-matrix.com

      reply	other threads:[~2026-11-16 13:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  9:49 [PATCH v34 net-next 0/8] nbl driver for Nebulamatrix NICs illusion.wang
2026-11-12  9:49 ` [PATCH v34 net-next 1/8] net/nebula-matrix: add channel layer illusion.wang
2026-11-12 12:01   ` Breno Leitao
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  9:49 ` [PATCH v34 net-next 2/8] net/nebula-matrix: add common resource implementation illusion.wang
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  9:49 ` [PATCH v34 net-next 3/8] net/nebula-matrix: add intr " illusion.wang
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  9:49 ` [PATCH v34 net-next 4/8] net/nebula-matrix: add chip-wide hardware init/deinit implementation illusion.wang
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  9:49 ` [PATCH v34 net-next 5/8] net/nebula-matrix: dispatch: add control-level routing core infrastructure illusion.wang
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  9:49 ` [PATCH v34 net-next 6/8] net/nebula-matrix: dispatch: add mailbox RPCs for msix map, mailbox irq and vsi/eth id illusion.wang
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  9:49 ` [PATCH v34 net-next 7/8] net/nebula-matrix: add common/ctrl dev init/remove operation illusion.wang
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  9:49 ` [PATCH v34 net-next 8/8] net/nebula-matrix: add common dev start/stop operation illusion.wang
2026-11-16 13:54   ` 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=179483728908.3136.13154556595001281898@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alvin.wang@nebula-matrix.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=dimon.zhao@nebula-matrix.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=illusion.wang@nebula-matrix.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sam.chen@nebula-matrix.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

all inboxes | Powered by JetHome®