πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by netdev-bot+sashiko Tue, 01 Dec 2026 14:04
Re: [PATCH net-next v4 2/6] enic: serialize V2 VF mailbox requests
#25317
Author: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 14:04
117 lines
12490 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message describes a race that cannot happen at this
  commit: "If two VF control paths issue requests at the same time, the…
- [Low] The commit message says the patch will "Clear pending state on
  send failure so a later request cannot inherit it".

--

enic: serialize V2 VF mailbox requests

This commit adds a VF-only mutex, vf_mbox_request_lock. The mutex is held
from before a mailbox request is armed until its reply or timeout has
been consumed. The commit also rechecks vf_registered in
enic_mbox_vf_unregister() after taking the mutex, and clears the expected
reply state when a send fails.

> The VF stores one expected reply and uses one completion for mailbox
> requests. If two VF control paths issue requests at the same time, the
> second request can replace the reply state for the first.

[Severity: Low]
Can two VF control paths actually issue requests at the same time at this
commit?

The only VF request senders are enic_mbox_vf_capability_check(),
enic_mbox_vf_register() and enic_mbox_vf_unregister() in enic_mbox.c.
Their callers in enic_main.c already appear to exclude each other:

  - enic_admin_chan_reopen() is only called from enic_reset() and
    enic_tx_hang_reset(). Both hold rtnl_lock() for the whole reset.

  - Probe calls the capability check and register back to back. This
    happens before INIT_WORK() for the reset works and before
    register_netdev().

  - enic_remove() calls disable_work_sync() on reset, tx_hang_reset and
    change_mtu_work before it calls enic_mbox_vf_unregister(). The probe
    error path is single threaded.

So the new recheck in enic_mbox_vf_unregister() does not seem to guard
against any overlap the current tree can produce:

	enic_mbox_vf_request_start(enic);
	if (!READ_ONCE(enic->vf_registered)) {
		enic_mbox_vf_request_finish(enic);
		return 0;
	}

The mutex seems to become necessary later in the series. That is where
more enic_mbox_vf_request_start() users are added for the MAC add/del,
packet filter and recovery paths.

Could the commit message say this is preparation for those concurrent
request paths? Otherwise it may be read, or backported, as a standalone
race fix.

The comment above mbox_comp in struct enic in enic.h also still says:

	/* MBOX request-reply state.  Existing request callers allow only one
	 * request in flight.  [ ... ]

Should that comment be updated together with the new
vf_mbox_request_lock?

> Add a request mutex used only by the VF. Hold it from before a request is
> armed until its reply or timeout has been consumed. Recheck registration
> in the unregister path after taking the mutex. Clear pending state on
> send failure so a later request cannot inherit it.

[Severity: Low]
Does "Clear pending state on send failure so a later request cannot
inherit it" describe new behavior? enic_mbox_send_msg_id() already clears
the armed state on its unlock path:

unlock:
	if (err && reply_expected) {
		spin_lock_bh(&enic->mbox_state_lock);
		if (enic->mbox_expected_reply == expected_reply &&
		    enic->mbox_expected_msg_num == msg_num) {
			enic->mbox_expected_reply = 0;
			enic->mbox_expected_msg_num = 0;
		}
		spin_unlock_bh(&enic->mbox_state_lock);
	}

That covers the two failures that can happen after arming: the
dma_mapping_error() -ENOMEM and the send -ETIMEDOUT.

The earlier exits are the -EINVAL payload size check, the -ENODEV check
for no channel or sends disabled, -ENOSPC, and the kmalloc() -ENOMEM.
All of them return before reply_expected is set, so no state was armed.

enic_mbox_vf_request_start() also zeroes mbox_expected_reply and
mbox_expected_msg_num before every request. Because of that, the clear
in enic_mbox_vf_request_abort() repeats what already happens:

> +static void enic_mbox_vf_request_abort(struct enic *enic)
> +{
> +	lockdep_assert_held(&enic->vf_mbox_request_lock);
> +	spin_lock_bh(&enic->mbox_state_lock);
> +	enic->mbox_expected_reply = 0;
> +	enic->mbox_expected_msg_num = 0;
> +	spin_unlock_bh(&enic->mbox_state_lock);
> +	mutex_unlock(&enic->vf_mbox_request_lock);
> +}

Could the commit message be reworded so this is not presented as a fix
for an inheritance problem?

-- 
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-b4-enic-sriov-v2-vf-receive-control-v4-0-5858d5a9ecb1%40cisco.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads