Devicetree
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: jacky_chou@aspeedtech.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, kuba@kernel.org,
	pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, ratbert@faraday-tech.com,
	edumazet@kernel.org, hkallweit1@gmail.com, linux@armlinux.org.uk,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, andrew@lunn.ch
Subject: Re: [PATCH net-next v6 5/7] net: ftgmac100: Require phy-mode for AST2700
Date: Mon, 16 Nov 2026 13:54:20 +0000	[thread overview]
Message-ID: <179483726032.3136.17044396273720911557@kernel.org> (raw)
In-Reply-To: <20261112-support_ast2700-v6-5-238020bf46cf@aspeedtech.com>

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

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

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).

- [High] The new AST2700 check in ftgmac100_mii_probe()
  (drivers/net/ethernet/faraday/ftgmac100.c, lines 1529-1535) can never…
- [High] The commit says it makes phy-mode required for AST2700 and fails
  probe when it is missing.
- [Low] In the series' binding change (commit "dt-bindings: net:
  ftgmac100: Add AST2700 compatible"), phy-mode is required for every…

--

net: ftgmac100: Require phy-mode for AST2700

This commit makes ftgmac100_mii_probe() fail with -EINVAL on AST2700 when
the phy-mode property is missing, instead of falling back to RGMII. The
stated goal is to make phy-mode a required property for AST2700, since
that SoC also supports RMII.

> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
> index 9b7becb017262..5a578a62df673 100644
> --- a/drivers/net/ethernet/faraday/ftgmac100.c
> +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> @@ -1526,8 +1526,13 @@ static int ftgmac100_mii_probe(struct net_device *netdev)
>  
>  	/* Default to RGMII. It's a gigabit part after all */
>  	err = of_get_phy_mode(np, &phy_intf);
> -	if (err)
> +	if (err) {
> +		if (priv->mac_id == FTGMAC100_AST2700) {
> +			dev_err(priv->dev, "phy-mode is required for this SoC\n");
> +			return -EINVAL;
> +		}
>  		phy_intf = PHY_INTERFACE_MODE_RGMII;
> +	}

[Severity: High]
Can this new branch ever be reached on AST2700?

priv->mii_bus is only set by ftgmac100_setup_mdio(), and ftgmac100_probe()
only calls that for the Faraday, AST2400 and AST2500 variants:

drivers/net/ethernet/faraday/ftgmac100.c:ftgmac100_probe() {
    ...
	if (priv->mac_id == FTGMAC100_FARADAY ||
	    priv->mac_id == FTGMAC100_AST2400 ||
	    priv->mac_id == FTGMAC100_AST2500) {
		err = ftgmac100_setup_mdio(netdev);
    ...
}

So on AST2700 priv->mii_bus is always NULL, and ftgmac100_mii_probe()
returns before it gets to the new check:

drivers/net/ethernet/faraday/ftgmac100.c:ftgmac100_mii_probe() {
    ...
	if (!priv->mii_bus) {
		dev_err(priv->dev, "No MDIO bus available\n");
		return -ENODEV;
	}
    ...
}

That would mean the "phy-mode is required for this SoC" message is never
printed, and the patch has no effect at runtime.

The commit message also says:

  The driver currently defaults to RGMII when the "phy-mode" property
  is missing from the device tree.

Is that accurate for AST2700? These are the probe paths in
ftgmac100_probe_dt():

  - use-ncsi: ftgmac100_probe_ncsi() hard-codes PHY_INTERFACE_MODE_RMII.
  - phy-handle / fixed-link: of_phy_get_and_connect() calls
    of_get_phy_mode() itself and returns NULL if phy-mode is missing, so
    probe already fails with "Failed to connect to phy".
  - no "mdio" child: stops at the mii_bus check above.

None of these paths reach the RGMII fallback.

The binding patch in this series ("dt-bindings: net: ftgmac100: Add
AST2700 compatible") says its required phy-mode matches the driver's
probe-time requirement, but this check doesn't seem to provide that.

The later patches in the series ("net: ftgmac100: Add AST2700 upper DMA
address support", "net: ftgmac100: Allow building on ARM64") don't touch
ftgmac100_mii_probe() or ftgmac100_probe_dt(). The check would still be
unreachable at the end of the series.

Would it make more sense to put this check on a path AST2700 actually
takes, for example at the top of ftgmac100_probe_dt()?

[Severity: High]
Apart from the reachability question above, some AST2700 probe paths
still succeed without phy-mode and never read it.

If the node has an "mdio" child but no phy-handle, fixed-link or
use-ncsi, ftgmac100_probe_dt() skips the legacy block and returns 0 with
no PHY attached:

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

	return 0;
}

The use-ncsi path also connects the fixed PHY with a hard-coded
PHY_INTERFACE_MODE_RMII and ignores phy-mode.

In the mdio-child case, netdev->phydev is still NULL after a successful
probe. Could opening the interface then oops in
ftgmac100_reset_and_config_mac()?

drivers/net/ethernet/faraday/ftgmac100.c:ftgmac100_reset_and_config_mac() {
    ...
	if (priv->is_aspeed && priv->netdev->phydev->interface == PHY_INTERFACE_MODE_RMII) {
    ...
}

ftgmac100_start_hw() has the same kind of unchecked dereference through
the RMII quirk:

	if ((priv->quirks & FTGMAC100_QUIRK_RMII_ENABLE) &&
	    phydev->interface == PHY_INTERFACE_MODE_RMII) {

This would happen through ftgmac100_open()->ftgmac100_reset_and_config_mac(),
whether or not the DT has phy-mode. It also contradicts the claim in
"net: ftgmac100: Enable AST2700 RMII support" that ftgmac100_probe_dt()
always attaches a phy_device.

The dereference in ftgmac100_reset_and_config_mac() already existed for
AST2600 (since af350ee72e9dda). Earlier patches in this series make it
reachable on AST2700.

Should the phy-mode check go at the top of ftgmac100_probe_dt() (or in
ftgmac100_probe()), before the branching, instead of in the legacy
MDIO-scan helper?

[Severity: Low]
This isn't a bug, but the binding and the driver disagree on the NC-SI
path. "dt-bindings: net: ftgmac100: Add AST2700 compatible" requires
phy-mode for every aspeed,ast2700-mac node, including use-ncsi nodes:

  - if:
      properties:
        compatible:
          contains:
            const: aspeed,ast2700-mac
    then:
      required:
        - phy-mode

ftgmac100_probe_dt() hands off to ftgmac100_probe_ncsi() as soon as
use-ncsi is present, and that path connects with a fixed RMII mode:

	err = phy_connect_direct(netdev, phydev, ftgmac100_adjust_link,
				 PHY_INTERFACE_MODE_RMII);

An NC-SI node with phy-mode = "rgmii" would pass schema validation, but
the value is silently ignored. ftgmac100_start_hw() would still set
FTGMAC100_MACCR_RMII_ENABLE.

Should the binding exempt use-ncsi nodes, or should the driver check
phy-mode against RMII on that path?

>  
>  	/* Aspeed only supports these. I don't know about other IP
>  	 * block vendors so I'm going to just let them through for

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112-support_ast2700-v6-0-238020bf46cf%40aspeedtech.com

  parent reply	other threads:[~2026-11-16 13:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  8:39 [PATCH net-next v6 0/7] net: ftgmac100: Add AST2700 support Jacky Chou
2026-11-12  8:39 ` [PATCH net-next v6 1/7] dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone Jacky Chou
2026-11-12 18:43   ` Conor Dooley
2026-11-13  8:39   ` sashiko-bot
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  8:39 ` [PATCH net-next v6 2/7] dt-bindings: net: ftgmac100: Add AST2700 compatible Jacky Chou
2026-11-12 18:44   ` Conor Dooley
2026-11-13  8:39   ` sashiko-bot
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-16 14:10     ` Andrew Lunn
2026-11-12  8:39 ` [PATCH net-next v6 3/7] net: ftgmac100: Add AST2700 compatible support Jacky Chou
2026-11-13  8:39   ` sashiko-bot
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  8:39 ` [PATCH net-next v6 4/7] net: ftgmac100: Enable AST2700 RMII support Jacky Chou
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  8:39 ` [PATCH net-next v6 5/7] net: ftgmac100: Require phy-mode for AST2700 Jacky Chou
2026-11-13  8:39   ` sashiko-bot
2026-11-16 13:54   ` netdev-bot+sashiko [this message]
2026-11-12  8:39 ` [PATCH net-next v6 6/7] net: ftgmac100: Add AST2700 upper DMA address support Jacky Chou
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  8:39 ` [PATCH net-next v6 7/7] net: ftgmac100: Allow building on ARM64 Jacky Chou
2026-11-16 13:54   ` netdev-bot+sashiko

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=179483726032.3136.17044396273720911557@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=jacky_chou@aspeedtech.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ratbert@faraday-tech.com \
    --cc=robh@kernel.org \
    /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