Re: [PATCH net-next v7 4/7] net: ftgmac100: Enable AST2700 RMII support

From: netdev-bot+sashiko

Date: Mon Nov 23 2026 - 05:13:40 EST


Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The commit message says "ftgmac100_probe_dt() always attaches
a phy_device before register_netdev() can succeed", and a new comment…
- [Medium] Speculative hardware-sequencing risk.

--

net: ftgmac100: Enable AST2700 RMII support

This adds a FTGMAC100_QUIRK_RMII_ENABLE match-data quirk for AST2700. It
also sets the new MACCR RMII enable bit (bit 20) in ftgmac100_start_hw()
when the attached PHY interface is RMII. The commit message argues that
netdev->phydev is always populated by the time ftgmac100_start_hw() runs.

> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
> index 67b1fa464a421..9b7becb017262 100644
> --- a/drivers/net/ethernet/faraday/ftgmac100.c
> +++ b/drivers/net/ethernet/faraday/ftgmac100.c

[ ... ]

> @@ -355,6 +359,12 @@ static void ftgmac100_init_hw(struct ftgmac100 *priv)
> static void ftgmac100_start_hw(struct ftgmac100 *priv)
> {
> u32 maccr = ioread32(priv->base + FTGMAC100_OFFSET_MACCR);
> + /*
> + * Only reached once the device is open, so a phy_device is already
> + * attached: a discrete PHY via "phy-handle", a "fixed-link" node, or
> + * NC-SI's internal fixed 100M PHY.
> + */
> + struct phy_device *phydev = priv->netdev->phydev;

[Severity: Medium]
Is this invariant actually guaranteed? The commit message says:

ftgmac100_probe_dt() always attaches a phy_device before
register_netdev() can succeed

But ftgmac100_probe_dt() has a path that returns 0 without attaching a PHY:

drivers/net/ethernet/faraday/ftgmac100.c:ftgmac100_probe_dt() {
...
if (!ftgmac100_has_child_node(np, "mdio")) {
...
err = ftgmac100_mii_probe(netdev);
...
}

return 0;
}

Take a node with an mdio child and none of use-ncsi, fixed-link or
phy-handle. It skips both of_phy_get_and_connect() and
ftgmac100_mii_probe(), and register_netdev() then succeeds with
netdev->phydev == NULL.

The ast2700-mac binding seems to allow this. It only requires one of
phy-mode or use-ncsi, phy-handle is optional and an mdio child is
allowed. So phy-mode = "rmii" plus an mdio node with no phy-handle
passes schema validation.

The rest of the driver also treats a NULL phydev as a valid state. For
example, ftgmac100_open() does:

if (netdev->phydev) {
/* If we have a PHY, start polling */
phy_start(netdev->phydev);

ftgmac100_stop(), ftgmac100_reset() and ftgmac100_phy_disconnect() check
for NULL in the same way.

The commit message cites ftgmac100_reset_and_config_mac() as precedent.
That check has the same latent problem, and it runs before every path
into ftgmac100_start_hw():

if (priv->is_aspeed && priv->netdev->phydev->interface == PHY_INTERFACE_MODE_RMII) {

So with such a DT, ftgmac100_open()->ftgmac100_reset_and_config_mac()
would oops first, and that NULL dereference predates this patch.

This patch does write the false invariant into both the commit message
and the source. It also adds a second unguarded phydev->interface
dereference that would need fixing too if the one in
ftgmac100_reset_and_config_mac() were made NULL safe. The final patch in
this series doesn't seem to change either dereference or
ftgmac100_probe_dt().

Would it make sense to guard this with a phydev check, or to cache the
DT phy-mode at probe time? Another option would be for
ftgmac100_probe_dt() to fail on Aspeed parts when no PHY gets attached.

>
> /* Keep the original GMAC and FAST bits */
> maccr &= (FTGMAC100_MACCR_FAST_MODE | FTGMAC100_MACCR_GIGA_MODE);
> @@ -383,6 +393,11 @@ static void ftgmac100_start_hw(struct ftgmac100 *priv)
> if (priv->netdev->features & NETIF_F_HW_VLAN_CTAG_RX)
> maccr |= FTGMAC100_MACCR_RM_VLAN;
>
> + if ((priv->quirks & FTGMAC100_QUIRK_RMII_ENABLE) &&
> + phydev->interface == PHY_INTERFACE_MODE_RMII) {
> + maccr |= FTGMAC100_MACCR_RMII_ENABLE;
> + }

[Severity: Medium]
Does the AST2700 need the RMII interface select to be in place across the
MAC soft reset?

FTGMAC100_MACCR_RMII_ENABLE is set only here, in the same MACCR write
that turns on TXDMA/RXDMA/TXMAC/RXMAC. The maccr that
ftgmac100_reset_and_config_mac() passes to ftgmac100_reset_mac() holds
only the speed bits:

/* The doc says reset twice with 10us interval */
if (ftgmac100_reset_mac(priv, maccr))
return -EIO;
usleep_range(10, 1000);
return ftgmac100_reset_mac(priv, maccr);

ftgmac100_start_hw() also masks MACCR down to FAST_MODE | GIGA_MODE
before rebuilding it.

So on every open, reset_task or link change, an RMII AST2700 port goes
through the SCU reset, both SW_RST cycles and ftgmac100_init_hw() in the
default non-RMII mode. That includes NC-SI ports, which connect with
PHY_INTERFACE_MODE_RMII. The port switches to RMII only when the MAC and
DMA are enabled.

On AST2500/AST2600 the RMII selection is in the SCU, so it is already set
before the MAC reset.

If the interface select (and its clock source mux) must be stable during
SW_RST or before MAC enable, the SW_RST poll in ftgmac100_reset_mac()
could time out with "Hardware reset failed". The MAC could also start
with inconsistent clock domains. This depends on AST2700 hardware
behaviour that can't be confirmed from the code alone.

phydev->interface doesn't change after probe. Could the bit be added to
the maccr built in ftgmac100_reset_and_config_mac() and kept by the mask
in ftgmac100_start_hw()?

> +
> /* Hit the HW */
> iowrite32(maccr, priv->base + FTGMAC100_OFFSET_MACCR);
> }

[ ... ]

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119-support_ast2700-v7-0-33c8ca2d0dd7%40aspeedtech.com