mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: "Ionut Nechita (Wind River)" <ionut.nechita@windriver.com>,
	<intel-wired-lan@lists.osuosl.org>,
	Tony Nguyen <anthony.l.nguyen@intel.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Larysa Zaremba <larysa.zaremba@intel.com>,
	Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
	Jacob Keller <jacob.e.keller@intel.com>,
	Wojciech Drewek <wojciech.drewek@intel.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH iwl-net] ice: release IRQs and rings in ice_dis_vsi() when the VSI is already down
Date: Mon, 23 Nov 2026 15:15:19 +0100	[thread overview]
Message-ID: <cec955ac-54e1-41eb-8a1c-3c4d65cd9a07@intel.com> (raw)
In-Reply-To: <20261106171657.583713-1-ionut.nechita@windriver.com>

On 11/6/26 6:16 PM, Ionut Nechita (Wind River) wrote:
> From: Ionut Nechita <ionut.nechita@windriver.com>
> 
> Since commit d8c40b9d3a6c ("ice: check ICE_VSI_DOWN under rtnl_lock when
> preparing for reset"), ice_dis_vsi() sets ICE_VSI_NEEDS_RESTART
> unconditionally, but still skips ice_vsi_close() when ICE_VSI_DOWN is
> already set. For a running netdev, ice_ena_vsi() then calls
> ice_open_internal() -> ice_vsi_open(), which does a full open: it sets
> up the rings and requests the IRQs again.
> 
> A running netdev with ICE_VSI_DOWN set is not always a closed VSI.
> ice_down() only cleans the rings. It keeps the ring memory and the IRQs
> so that ice_up() can restart the VSI quickly. If the restart fails, the
> VSI stays in that state while the netdev is still running, for example:
> 
>    - ice_down_up(), when ice_down() or ice_up() fails (the latter also
>      via ice_change_mtu());
>    - ice_xdp_setup_prog(), when ice_down() fails.
> 
> If ice_dis_vsi()/ice_ena_vsi() are called on such a VSI without an
> ice_vsi_rebuild() in between, which is the case for the DCB
> reconfiguration in ice_pf_dcb_cfg() and
> ice_dcb_process_lldp_set_mib_change(), ice_vsi_open() runs on rings and
> IRQs that were never released:
> 
>    - ice_setup_tx_ring() hits WARN_ON(tx_ring->tx_buf) and overwrites
>      tx_buf and desc, leaking the previous arrays;
>    - ice_setup_rx_ring() overwrites desc, leaking the previous descriptor
>      memory;
>    - ice_vsi_req_irq_msix() requests the PF vectors again without
>      IRQF_SHARED and fails with -EBUSY, so the open fails and the
>      interface stays down until it is closed and opened again.
> 
> On the reset and mqprio paths, ice_vsi_rebuild() frees the ring
> structures in between, so there is no WARN, but the ring memory still
> held by them is not released until the device is unbound.
> 
> Call ice_vsi_close() unconditionally for a running netdev, under
> rtnl_lock. ice_vsi_close() already handles a VSI that is down: it only
> calls ice_down() if ICE_VSI_DOWN was not set, ice_vsi_free_irq() returns
> early when the IRQs are not requested, and ice_vsi_free_{tx,rx}_rings()
> only free rings that have a descriptor ring. This is also what
> ice_stop() does for a VSI in this state. The race fixed by the commit
> above does not come back: ICE_VSI_DOWN is still tested, by
> ice_vsi_close(), under rtnl_lock.
> 
> The non-running and ICE_VSI_CTRL branches are left as they are. In both
> cases ice_ena_vsi() either does not reopen the VSI or, for the control
> VSI, the only paths that set ICE_VSI_DOWN also release its rings and
> IRQs.
> 
> Fixes: d8c40b9d3a6c ("ice: check ICE_VSI_DOWN under rtnl_lock when preparing for reset")
> Assisted-by: Claude:claude-opus-5.5

this tag is overly specific, please just use "Assisted-by: LLM"

> Signed-off-by: Ionut Nechita <ionut.nechita@windriver.com>
> ---
> Found while chasing the same WARN_ON() in ice_setup_{rx,tx}_ring() with
> the out-of-tree ice driver on an E830 port without a module installed,
> where ice_vsi_cfg_lan() fails and ice_dis_vsi()/ice_ena_vsi() then
> reopen a VSI that ice_down() left with its rings allocated. The
> in-tree paths above were found by code reading.

thank you for working on that, and its nice to see that the problem
comes from an actual usage (instead of plain AI hunting)

> 
> Based on net (f66469d9905b, "Merge tag 'net-7.4-rc2'").
> Tested: build only (W=1, no new warnings).
> 
>   drivers/net/ethernet/intel/ice/ice_lib.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
> index 7cd2dd066ef5e..0421b0738abd1 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_lib.c
> @@ -2852,9 +2852,14 @@ void ice_dis_vsi(struct ice_vsi *vsi, bool locked)
>   		if (netif_running(vsi->netdev)) {
>   			if (!locked)
>   				rtnl_lock();
> -			already_down = test_bit(ICE_VSI_DOWN, vsi->state);
> -			if (!already_down)
> -				ice_vsi_close(vsi);
> +			/* ice_ena_vsi() will reopen the VSI with
> +			 * ice_open_internal(), so release IRQs and rings even
> +			 * if the VSI is already down: ice_down() keeps both,
> +			 * and a failed restart (e.g. in ice_down_up()) leaves
> +			 * the VSI in that state. ice_vsi_close() skips
> +			 * ice_down() when ICE_VSI_DOWN is already set.
> +			 */

this comment is too verbose, and you have already provided the same via
commit msg, so either make it really short or just drop

> +			ice_vsi_close(vsi);
>   
>   			if (!locked)
>   				rtnl_unlock();


  reply	other threads:[~2026-11-23 14:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 17:16 Ionut Nechita (Wind River)
2026-11-23 14:15 ` Przemek Kitszel [this message]
2026-11-23 19:12   ` Jacob Keller

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=cec955ac-54e1-41eb-8a1c-3c4d65cd9a07@intel.com \
    --to=przemyslaw.kitszel@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=ionut.nechita@windriver.com \
    --cc=jacob.e.keller@intel.com \
    --cc=kuba@kernel.org \
    --cc=larysa.zaremba@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=wojciech.drewek@intel.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®