net: ethernet: mtk_eth_soc: avoid writing to ESW registers on MT7628
Subsystems (4)
PATCH v3 1/1 net: ethernet: mtk_eth_soc: avoid writing to ESW registers on MT7628
The MT7628 has a fixed-link PHY and does not expose MAC control registers. Writes to these registers only corrupt the ESW VLAN configuration.
This patch registers empty phylink_mac_ops for MT7628, as removing the invalid register accesses leaves nothing to do on this SoC.
---
v3:
- Register separate mac_ops for MT7628 instead of using early return based on SoC for all phylink mac operations
- Update commit message
v2: https://lore.kernel.org/netdev/[email protected]/
- Add missing fixes tag
v1: https://lore.kernel.org/netdev/[email protected]/
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 37 ++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +33 -4
@@ -562,9 +562,7 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode,int val, ge_mode, err =0 ;u32 i; -/* MT76x8 has no hardware settings between for the MAC */ -if (!MTK_HAS_CAPS (eth->soc->caps,MTK_SOC_MT7628 ) && - mac->interface != state->interface) { +if (mac->interface != state->interface) {/* Setup soc pin functions */ switch (state->interface) {case PHY_INTERFACE_MODE_TRGMII :
@@ -956,6 +954,30 @@ static const struct phylink_mac_ops mtk_phylink_ops = { .mac_enable_tx_lpi = mtk_mac_enable_tx_lpi, }; +static void rt5350_mac_config (struct phylink_config *config,unsigned int mode, +const struct phylink_link_state *state) +{ +} + +static void rt5350_mac_link_down (struct phylink_config *config,unsigned int mode, +phy_interface_t interface) +{ +} + +static void rt5350_mac_link_up (struct phylink_config *config, +struct phy_device *phy, +unsigned int mode,phy_interface_t interface, +int speed,int duplex,bool tx_pause,bool rx_pause) +{ +} + +/* MT76x8 (rt5350-eth) does not expose any MAC control registers */ +static const struct phylink_mac_ops rt5350_phylink_ops = { + .mac_config = rt5350_mac_config, + .mac_link_down = rt5350_mac_link_down, + .mac_link_up = rt5350_mac_link_up, +}; +static void mtk_mdio_config (struct mtk_eth *eth) {u32 val;
@@ -4779,6 +4801,7 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)int id, err;int txqs =1 ;u32 val; +const struct phylink_mac_ops *mac_ops = &mtk_phylink_ops;if (!_id) {dev_err (eth->dev,"missing mac id\n" );
@@ -4906,9 +4929,15 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) mac->phylink_config.supported_interfaces); } + +if (MTK_HAS_CAPS (eth->soc->caps,MTK_SOC_MT7628 )) + mac_ops = &rt5350_phylink_ops; + phylink =phylink_create (&mac->phylink_config,of_fwnode_handle (mac->of_node), - phy_mode, &mtk_phylink_ops); + phy_mode, + mac_ops); +if (IS_ERR (phylink)) { err =PTR_ERR (phylink); goto free_netdev;
Signature · 1 line
2.52.0
Jakub Kicinski
maintainerQuoted 8 lines · On Thu, 22 Jan 2026 20:58:08 +0200 Joris Vaisvila wrote:
The MT7628 has a fixed-link PHY and does not expose MAC control registers. Writes to these registers only corrupt the ESW VLAN configuration.
This patch registers empty
phylink_mac_opsfor MT7628, as removing the invalid register accesses leaves nothing to do on this SoC.Fixes 296c9120752b ("net: ethernet: mediatek: Add MT7628/88 SoC support")
If we're going with net-next please drop the Fixes tag. We don't need a backport. You can quote the commit if you prefer eg:
This code was introduced by commit 296c9120752b ("net: ethernet:
mediatek: Add MT7628/88 SoC support")
Quoted 6 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +6
-0+static void rt5350_mac_config (struct phylink_config *config,unsigned int mode, +const struct phylink_link_state *state) +{ +} + +static void rt5350_mac_link_down(struct phylink_config *config, unsigned int mode,
drivers/net/ethernet/mediatek/mtk_eth_soc.c static const struct phylink_mac_ops mtk_phylink_ops = { · line 972
Quoted 10 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +10
-0+ phy_interface_t interface) +{ +} + +static void rt5350_mac_link_up (struct phylink_config *config, +struct phy_device *phy, +unsigned int mode,phy_interface_t interface, +int speed,int duplex,bool tx_pause,bool rx_pause) +{ +}
Is there any other driver that implements fixed link with phylink this way? I know regrettably little about phylink. I'd think that mac up/down usually would still do _something_.
drivers/net/ethernet/mediatek/mtk_eth_soc.c static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) · line 4804
Quoted 5 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +1
-0@@ -4779,6 +4801,7 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)int id, err;int txqs =1 ;u32 val; +const struct phylink_mac_ops *mac_ops = &mtk_phylink_ops;
nit: try to keep local variables ordered longest line to shortest
drivers/net/ethernet/mediatek/mtk_eth_soc.c static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) · line 4932
Quoted 7 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +1
-0if (!_id) {dev_err (eth->dev,"missing mac id\n" );@@ -4906,9 +4929,15 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) mac->phylink_config.supported_interfaces); } +
nit: double new line
drivers/net/ethernet/mediatek/mtk_eth_soc.c static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) · line 4940
Quoted 9 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +6
-1+if (MTK_HAS_CAPS (eth->soc->caps,MTK_SOC_MT7628 )) + mac_ops = &rt5350_phylink_ops; + phylink =phylink_create (&mac->phylink_config,of_fwnode_handle (mac->of_node), - phy_mode, &mtk_phylink_ops); + phy_mode, + mac_ops); +
nit: please don't insert empty lines between function call and its error check
Quoted 3 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +0
-0if (IS_ERR (phylink)) { err =PTR_ERR (phylink); goto free_netdev;
Signature · 1 line
pw-bot: cr
Quoted 12 lines
Quoted 12 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +12
-0+static void rt5350_mac_config (struct phylink_config *config,unsigned int mode, +const struct phylink_link_state *state) +{ +} + +static void rt5350_mac_link_down (struct phylink_config *config,unsigned int mode, +phy_interface_t interface) +{ +} + +static void rt5350_mac_link_up(struct phylink_config *config, + struct phy_device *phy,
Quoted 9 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c static const struct phylink_mac_ops mtk_phylink_ops = { · line 972
Quoted 4 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +4
-0+ unsigned int mode, phy_interface_t interface, + int speed, int duplex, bool tx_pause, bool rx_pause) +{ +}Is there any other driver that implements fixed link with phylink this way? I know regrettably little about phylink. I'd think that mac up/down usually would still do _something_.
net/dsa/port.c stubs are the only other place with no-op phylink mac ops.
On MT7628, the existing mtk_gdm_mac_link_up() does not actually commit any configuration to the MAC hardware. The only potentially observable change is mac->speed = speed, however leaving that as UNKNOWN_SPEED appears more accurate for this SoC, though I will recheck for side-effects of that.
mtk_mac_link_down() also does not touch any valid MAC registers. Both of these functions are already effectively no-ops in terms of MAC configuration on this SoC. They only clobber unrelated ESW registers.
While the ESW block seems to provide a way to control the CPU port speed and link state, this is a separate IP and I don't think it's appropriate to have the MAC driver program it.
While I'm not very familiar with phylink either, this is no different from how the original driver handles link up/down on this SoC.