From nobody Tue Apr 7 14:06:12 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D5983D349B; Wed, 25 Feb 2026 14:24:56 +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=1772029497; cv=none; b=QLCmP6DIZuNbyFbYwrlgQDkV4lYc41vmjrDQm2XXx8BCJJt1sEp54SzQbnmn3eSAhiXGJD2nSZGIVJK3ShGhPd5v7kMJv0JAelj30X4nSeKOS6U6VzutL9RYR10AXEc4MwhYD80zJxXPZhwXedPWKp/Xj4upXaJ3MeCAgIT+cqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772029497; c=relaxed/simple; bh=+RmBZM1X2mmeQ5E0ux8AhVEjIHMn5mMEsxCjHMYhfOU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TqL2ZpZGLivHnkTK0At7IaB4kUr5hZqcsNXOhdEVfMuo6AW5bZbEn/F1cIEni1/JGfG348hRe3KQOBqzlnBIm5vHYCb6FpJ6ML2jFNZz7pFIzrlkw8IVJ11fzu/hR3fsnZZovwkMh6smzoRD1TkztP/r3UMBqE70VM8Iq3IRKVI= 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: wjXg1zDVTHaep9JmLwo6EA== X-CSE-MsgGUID: pbnM9QIVQWudH1d9Ob5JRQ== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 25 Feb 2026 23:24:55 +0900 Received: from vm01.adwin.renesas.com (unknown [10.226.92.192]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id B10104017D8D; Wed, 25 Feb 2026 23:24:49 +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, linux@armlinux.org.uk, rmk+kernel@armlinux.org.uk, maxime.chevallier@bootlin.com, boon.khai.ng@altera.com, rohan.g.thomas@altera.com, vladimir.oltean@nxp.com, hayashi.kunihiko@socionext.com, boon.leong.ong@intel.com, kim.tatt.chuah@intel.com Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 5/5] net: stmmac: Defer VLAN HW configuration when interface is down Date: Wed, 25 Feb 2026 14:24:14 +0000 Message-ID: <20260225142414.130144-6-ovidiu.panait.rb@renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260225142414.130144-1-ovidiu.panait.rb@renesas.com> References: <20260225142414.130144-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" VLAN register accesses on the MAC side require the PHY RX clock to be active. When the network interface is down, the PHY is suspended and the RX clock is unavailable, causing VLAN operations to fail with timeouts. The VLAN core automatically removes VID 0 after the interface goes down and re-adds it when it comes back up, so these timeouts happen during normal interface down/up: # ip link set end1 down renesas-gbeth 15c40000.ethernet end1: Timeout accessing MAC_VLAN_Tag_Fi= lter renesas-gbeth 15c40000.ethernet end1: failed to kill vid 0081/0 Adding VLANs while the interface is down also fails: # ip link add link end1 name end1.10 type vlan id 10 renesas-gbeth 15c40000.ethernet end1: Timeout accessing MAC_VLAN_Tag_Fi= lter RTNETLINK answers: Device or resource busy Use the write_hw parameter introduced in the previous commit to skip hardware register writes when the interface is down. The software state is always kept up to date regardless of interface state. When the interface is brought up, stmmac_vlan_restore() is called to write the VLAN state to hardware. Signed-off-by: Ovidiu Panait --- v2 changes: - Split this commit - added a new commit (3/5) which fixes VLAN restore on resume and open paths. - Dropped phylink_rx_clk_stop_block()/unblock() calls around VLAN restore. .../net/ethernet/stmicro/stmmac/stmmac_main.c | 16 ++++++++++------ .../net/ethernet/stmicro/stmmac/stmmac_vlan.c | 9 ++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index 19c86e3b42cc..1098227272ed 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -6787,6 +6787,7 @@ static int stmmac_vlan_update(struct stmmac_priv *pri= v, bool is_double, static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u= 16 vid) { struct stmmac_priv *priv =3D netdev_priv(ndev); + bool write_hw =3D netif_running(ndev); unsigned int num_double_vlans; bool is_double =3D false; int ret; @@ -6800,7 +6801,7 @@ static int stmmac_vlan_rx_add_vid(struct net_device *= ndev, __be16 proto, u16 vid =20 set_bit(vid, priv->active_vlans); num_double_vlans =3D priv->num_double_vlans + is_double; - ret =3D stmmac_vlan_update(priv, num_double_vlans, true); + ret =3D stmmac_vlan_update(priv, num_double_vlans, write_hw); if (ret) { clear_bit(vid, priv->active_vlans); goto err_pm_put; @@ -6808,10 +6809,11 @@ static int stmmac_vlan_rx_add_vid(struct net_device= *ndev, __be16 proto, u16 vid =20 if (priv->hw->num_vlan) { ret =3D stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, - vid, true); + vid, write_hw); if (ret) { clear_bit(vid, priv->active_vlans); - stmmac_vlan_update(priv, priv->num_double_vlans, true); + stmmac_vlan_update(priv, priv->num_double_vlans, + write_hw); goto err_pm_put; } } @@ -6830,6 +6832,7 @@ static int stmmac_vlan_rx_add_vid(struct net_device *= ndev, __be16 proto, u16 vid static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, = u16 vid) { struct stmmac_priv *priv =3D netdev_priv(ndev); + bool write_hw =3D netif_running(ndev); unsigned int num_double_vlans; bool is_double =3D false; int ret; @@ -6843,7 +6846,7 @@ static int stmmac_vlan_rx_kill_vid(struct net_device = *ndev, __be16 proto, u16 vi =20 clear_bit(vid, priv->active_vlans); num_double_vlans =3D priv->num_double_vlans - is_double; - ret =3D stmmac_vlan_update(priv, num_double_vlans, true); + ret =3D stmmac_vlan_update(priv, num_double_vlans, write_hw); if (ret) { set_bit(vid, priv->active_vlans); goto del_vlan_error; @@ -6851,10 +6854,11 @@ static int stmmac_vlan_rx_kill_vid(struct net_devic= e *ndev, __be16 proto, u16 vi =20 if (priv->hw->num_vlan) { ret =3D stmmac_del_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, - vid, true); + vid, write_hw); if (ret) { set_bit(vid, priv->active_vlans); - stmmac_vlan_update(priv, priv->num_double_vlans, true); + stmmac_vlan_update(priv, priv->num_double_vlans, + write_hw); goto del_vlan_error; } } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_vlan.c index f81015179d04..261bc751ade2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c @@ -147,7 +147,6 @@ static int vlan_del_hw_rx_fltr(struct net_device *dev, static void vlan_restore_hw_rx_fltr(struct net_device *dev, struct mac_device_info *hw) { - u32 val; int i; =20 /* Single Rx VLAN Filter */ @@ -157,12 +156,8 @@ static void vlan_restore_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_VEN) { - val =3D hw->vlan_filter[i]; - vlan_write_filter(dev, hw, i, val); - } - } + for (i =3D 0; i < hw->num_vlan; i++) + vlan_write_filter(dev, hw, i, hw->vlan_filter[i]); } =20 static void vlan_update_hash(struct mac_device_info *hw, u32 hash, --=20 2.51.0