Re: [net-next,20/21] net: stmmac: rk: use rk_encode_wm16() for clock selection
From: Jakub Kicinski <kuba@kernel.org>
Date: 2026-01-25 22:16:51
Also in:
linux-arm-kernel, linux-rockchip
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html --- net: stmmac: rk: rk3506, rk3528 and kk3588 have rmii_mode in clock register This patch adds an rmii_mode_mask field to struct rk_clock_fields to handle RMII mode configuration in the clock GRF register. It removes the SoC-specific set_to_rmii() functions for rk3506, rk3528, and rk3588, replacing them with a generic mechanism in rk_gmac_powerup().
quoted hunk ↗ jump to hunk
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index ebbc09ea572a..759deb66ef2a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -1412,6 +1385,15 @@ static int rk_gmac_powerup(struct rk_priv_data *bsp_priv) return ret; } + if (bsp_priv->clock.rmii_mode_mask) { + val = rk_encode_wm16(ret == PHY_INTF_SEL_RMII, + bsp_priv->clock.rmii_mode_mask);
Is this comparison using the correct value? Earlier in rk_gmac_powerup(), the
variable ret is assigned the return value from rk_get_phy_intf_sel(), which is
PHY_INTF_SEL_RGMII (0) or PHY_INTF_SEL_RMII (1).
However, for SoCs that have gmac_phy_intf_sel_mask set (such as rk3588), the
code enters the preceding if block:
if (bsp_priv->gmac_phy_intf_sel_mask || bsp_priv->gmac_rmii_mode_mask) {
...
ret = regmap_write(bsp_priv->grf, bsp_priv->gmac_grf_reg, val);
...
}
After this block, ret has been overwritten with the regmap_write() return
value (0 on success). When the rmii_mode_mask block executes, the comparison
ret == PHY_INTF_SEL_RMII becomes 0 == 1, which is always false.
This means for rk3588 in RMII mode, the rmii_mode bit in the clock register
will be cleared (RGMII mode) instead of set. Would it be better to save the
PHY interface selection value in a separate variable before it gets
overwritten?
+ + ret = rk_write_clock_grf_reg(bsp_priv, val); + if (ret < 0) + return ret; + }