From: Joris Vaisvila <joey@tinyisr.com>
To: netdev@vger.kernel.org
Cc: nbd@nbd.name, sean.wang@mediatek.com, lorenzo@kernel.org,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com,
Joris Vaisvila <joey@tinyisr.com>
Subject: [PATCH] net: ethernet: mtk_eth_soc: avoid writing to ESW registers on MT7628
Date: Tue, 30 Dec 2025 11:10:41 +0200 [thread overview]
Message-ID: <20251230091151.129176-1-joey@tinyisr.com> (raw)
The MT7628 does not expose MAC control registers. Writes to these
registers corrupt the ESW VLAN configuration. Existing drivers
never use the affected features, so this went unnoticed.
This patch skips MCR register reads and writes on MT7628, preventing
invalid register access.
Signed-off-by: Joris Vaisvila <joey@tinyisr.com>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index e68997a29191..2fae6bd368a6 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -699,6 +699,9 @@ static int mtk_mac_finish(struct phylink_config *config, unsigned int mode,
struct mtk_eth *eth = mac->hw;
u32 mcr_cur, mcr_new;
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
+ return 0;
+
/* Enable SGMII */
if (interface == PHY_INTERFACE_MODE_SGMII ||
phy_interface_mode_is_8023z(interface))
@@ -724,6 +727,9 @@ static void mtk_mac_link_down(struct phylink_config *config, unsigned int mode,
struct mtk_mac *mac = container_of(config, struct mtk_mac,
phylink_config);
+ if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_SOC_MT7628))
+ return;
+
if (!mtk_interface_mode_is_xgmii(mac->hw, interface)) {
/* GMAC modes */
mtk_m32(mac->hw,
@@ -815,6 +821,9 @@ static void mtk_gdm_mac_link_up(struct mtk_mac *mac,
{
u32 mcr;
+ if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_SOC_MT7628))
+ return;
+
mcr = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id));
mcr &= ~(MAC_MCR_SPEED_100 | MAC_MCR_SPEED_1000 |
MAC_MCR_FORCE_DPX | MAC_MCR_FORCE_TX_FC |
@@ -4357,9 +4366,11 @@ static void mtk_prepare_for_reset(struct mtk_eth *eth)
mtk_w32(eth, 0, MTK_FE_INT_ENABLE);
/* force link down GMAC */
- for (i = 0; i < 2; i++) {
- val = mtk_r32(eth, MTK_MAC_MCR(i)) & ~MAC_MCR_FORCE_LINK;
- mtk_w32(eth, val, MTK_MAC_MCR(i));
+ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) {
+ for (i = 0; i < 2; i++) {
+ val = mtk_r32(eth, MTK_MAC_MCR(i)) & ~MAC_MCR_FORCE_LINK;
+ mtk_w32(eth, val, MTK_MAC_MCR(i));
+ }
}
}
--
2.52.0
reply other threads:[~2025-12-30 9:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20251230091151.129176-1-joey@tinyisr.com \
--to=joey@tinyisr.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=lorenzo@kernel.org \
--cc=nbd@nbd.name \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sean.wang@mediatek.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;
as well as URLs for NNTP newsgroup(s).