From nobody Mon Feb 9 17:07:34 2026 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0DBE52E229C; Thu, 13 Nov 2025 11:27:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763033261; cv=none; b=LqME4cGTMqPPOC7Ib1StC7nkJulfksnYdUZsvt+dya2Z7L2hiji8PkNucpcV51mk82ntBBN5VBXxiPM/aA/k6xDNZpoRid9gzMwv/Fu/UBkQb1doPT7XuwCeNTuEBO5HwTxbCN+qzTcNY5rrrryFWAERnM3/g9cR0i3EQvwz2es= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763033261; c=relaxed/simple; bh=Ykan8xg4LV228B+EDdgarrcEdQ0ZYv4eVacvyc4kgkk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D8vLYk2xPFhYmV9e5N83O4S4WpTQzzk1ZNucfucL6jfAngQy6N7Vsq8XTfig6rUMRHNyJd1ltbQQ9b3vLrNLlAwnGgE3g0mV/dKQnx98MLJt06z/vQayKWUCTHHGh3SH4GrE/yQKHjuZ1dOAaZtATTGmCPuTAvGr+vuSSqwyfew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: Z4y3QjuaTqmsgxq+sukCIw== X-CSE-MsgGUID: ehtI6f+7QGGN6QAhnXukJw== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 13 Nov 2025 20:27:32 +0900 Received: from vm01.adwin.renesas.com (unknown [10.226.92.175]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 25CC7428B0E9; Thu, 13 Nov 2025 20:27:27 +0900 (JST) From: Ovidiu Panait To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, rmk+kernel@armlinux.org.uk, maxime.chevallier@bootlin.com, boon.khai.ng@altera.com Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 1/2] net: stmmac: Fix VLAN 0 deletion in vlan_del_hw_rx_fltr() Date: Thu, 13 Nov 2025 11:27:20 +0000 Message-ID: <20251113112721.70500-2-ovidiu.panait.rb@renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251113112721.70500-1-ovidiu.panait.rb@renesas.com> References: <20251113112721.70500-1-ovidiu.panait.rb@renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When the "rx-vlan-filter" feature is enabled on a network device, the 8021q module automatically adds a VLAN 0 hardware filter when the device is brought administratively up. For stmmac, this causes vlan_add_hw_rx_fltr() to create a new entry for VID 0 in the mac_device_info->vlan_filter array, in the following format: VLAN_TAG_DATA_ETV | VLAN_TAG_DATA_VEN | vid Here, VLAN_TAG_DATA_VEN indicates that the hardware filter is enabled for that VID. However, on the delete path, vlan_del_hw_rx_fltr() searches the vlan_filter array by VID only, without verifying whether a VLAN entry is enabled. As a result, when the 8021q module attempts to remove VLAN 0, the function may mistakenly match a zero-initialized slot rather than the actual VLAN 0 entry, causing incorrect deletions and leaving stale entries in the hardware table. Fix this by verifying that the VLAN entry's enable bit (VLAN_TAG_DATA_VEN) is set before matching and deleting by VID. This ensures only active VLAN entries are removed and avoids leaving stale entries in the VLAN filter table, particularly for VLAN ID 0. Fixes: ed64639bc1e08 ("net: stmmac: Add support for VLAN Rx filtering") Signed-off-by: Ovidiu Panait Reviewed-by: Maxime Chevallier --- v2 changes: none drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_vlan.c index ff02a79c00d4..b18404dd5a8b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c @@ -122,7 +122,8 @@ static int vlan_del_hw_rx_fltr(struct net_device *dev, =20 /* Extended Rx VLAN Filter Enable */ for (i =3D 0; i < hw->num_vlan; i++) { - if ((hw->vlan_filter[i] & VLAN_TAG_DATA_VID) =3D=3D vid) { + if ((hw->vlan_filter[i] & VLAN_TAG_DATA_VEN) && + ((hw->vlan_filter[i] & VLAN_TAG_DATA_VID) =3D=3D vid)) { ret =3D vlan_write_filter(dev, hw, i, 0); =20 if (!ret) --=20 2.51.0 From nobody Mon Feb 9 17:07:34 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB46133C52E; Thu, 13 Nov 2025 11:27:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763033260; cv=none; b=i9jwtINpN0fuoGovJsUi9kWVVm3/omRfh2nULbrpJp2QU6vGe3rV8iNLX9iAk7Uq47OY6SvqOj1UPG1/6S7Y+U2HGgnSrKeTswrHF+qTjRnb7R2KmbuWYL0UDESNtbdp8p0Es9SdrHQMp6NPwYbeH38ocwvDazFKS8x8iXjuUx4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763033260; c=relaxed/simple; bh=+ev+Lm7ALu6QWPuInxQp8hFbgIcRZFszd1M8OMejVIg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iQcJtkrgMLhk7AX3C+Tw4KHpEuuBNkkrG44UjnY1yFVopHJlBlfQdL9zProLQsOBvPxAgOQGZ2EwyilQofSw/Ve5mE43RBS4BlxpgEGXJIscggs60vD2T0db2uvWbPqmjO6MfwvyyoAO7ZIAPq7hn3GCsfPF3ebOPlN0wnCD2Z8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: MRHuWa0kTI6Lt2ZP5B982A== X-CSE-MsgGUID: KyhrcSpkSba0cQfQ1HQTYg== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 13 Nov 2025 20:27:37 +0900 Received: from vm01.adwin.renesas.com (unknown [10.226.92.175]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 3FC48428B0EC; Thu, 13 Nov 2025 20:27:32 +0900 (JST) From: Ovidiu Panait To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, rmk+kernel@armlinux.org.uk, maxime.chevallier@bootlin.com, boon.khai.ng@altera.com Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 2/2] net: stmmac: Disable EEE RX clock stop when VLAN is enabled Date: Thu, 13 Nov 2025 11:27:21 +0000 Message-ID: <20251113112721.70500-3-ovidiu.panait.rb@renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251113112721.70500-1-ovidiu.panait.rb@renesas.com> References: <20251113112721.70500-1-ovidiu.panait.rb@renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On the Renesas RZ/V2H EVK platform, where the stmmac MAC is connected to a Microchip KSZ9131RNXI PHY, creating or deleting VLAN interfaces may fail with timeouts: # ip link add link end1 name end1.5 type vlan id 5 15c40000.ethernet end1: Timeout accessing MAC_VLAN_Tag_Filter RTNETLINK answers: Device or resource busy Disabling EEE at runtime avoids the problem: # ethtool --set-eee end1 eee off # ip link add link end1 name end1.5 type vlan id 5 # ip link del end1.5 The stmmac hardware requires the receive clock to be running when writing certain registers, such as those used for MAC address configuration or VLAN filtering. However, by default the driver enables Energy Efficient Ethernet (EEE) and allows the PHY to stop the receive clock when the link is idle. As a result, the RX clock might be stopped when attempting to access these registers, leading to timeouts and other issues. Commit dd557266cf5fb ("net: stmmac: block PHY RXC clock-stop") addressed this issue for most register accesses by wrapping them in phylink_rx_clk_stop_block()/phylink_rx_clk_stop_unblock() calls. However, VLAN add/delete operations may be invoked with bottom halves disabled, where sleeping is not allowed, so using these helpers is not possible. Therefore, to fix this, disable the RX clock stop feature in the phylink configuration if VLAN features are set. This ensures the RX clock remains active and register accesses succeed during VLAN operations. Signed-off-by: Ovidiu Panait Reviewed-by: Russell King (Oracle) --- v2 changes: - Added comment mentioning that EEE RX clock stop is disabled to allow access to VLAN registers. - Added "Reviewed-by" tag from Russell. drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index ccf383b355e7..101babc8513e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1245,7 +1245,11 @@ static int stmmac_phylink_setup(struct stmmac_priv *= priv) /* Stmmac always requires an RX clock for hardware initialization */ config->mac_requires_rxc =3D true; =20 - if (!(priv->plat->flags & STMMAC_FLAG_RX_CLK_RUNS_IN_LPI)) + /* Disable EEE RX clock stop to ensure VLAN register access works + * correctly. + */ + if (!(priv->plat->flags & STMMAC_FLAG_RX_CLK_RUNS_IN_LPI) && + !(priv->dev->features & NETIF_F_VLAN_FEATURES)) config->eee_rx_clk_stop_enable =3D true; =20 /* Set the default transmit clock stop bit based on the platform glue */ --=20 2.51.0