Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: satishkh@cisco.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	willemb@google.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, sebaddel@cisco.com,
	aradhana@cisco.com, rfaucett@cisco.com
Subject: Re: [PATCH net-next v4 2/6] enic: serialize V2 VF mailbox requests
Date: Tue, 01 Dec 2026 14:04:48 +0000	[thread overview]
Message-ID: <179613388882.3146.17579339315974208420@kernel.org> (raw)
In-Reply-To: <20261130-b4-enic-sriov-v2-vf-receive-control-v4-2-5858d5a9ecb1@cisco.com>

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

  reply	other threads:[~2026-12-01 14:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 13:58 [PATCH net-next v4 0/6] enic: add V2 VF receive control over MBOX Satish Kharat
2026-11-30 13:58 ` [PATCH net-next v4 1/6] net: add netif_rx_mode_schedule_update() Satish Kharat
2026-11-30 13:58 ` [PATCH net-next v4 2/6] enic: serialize V2 VF mailbox requests Satish Kharat
2026-12-01 14:04   ` netdev-bot+sashiko [this message]
2026-11-30 13:58 ` [PATCH net-next v4 3/6] enic: recover V2 VF mailbox after request failure Satish Kharat
2026-12-01 14:04   ` netdev-bot+sashiko
2026-11-30 13:58 ` [PATCH net-next v4 4/6] enic: validate V2 VF configuration replies Satish Kharat
2026-12-01 14:04   ` netdev-bot+sashiko
2026-11-30 13:58 ` [PATCH net-next v4 5/6] enic: manage V2 VF station and administrative MAC Satish Kharat
2026-12-01 14:04   ` netdev-bot+sashiko
2026-11-30 13:58 ` [PATCH net-next v4 6/6] enic: configure V2 VF receive mode over mailbox Satish Kharat
2026-12-01 14:04   ` netdev-bot+sashiko

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=179613388882.3146.17579339315974208420@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=aradhana@cisco.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rfaucett@cisco.com \
    --cc=satishkh@cisco.com \
    --cc=sebaddel@cisco.com \
    --cc=willemb@google.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