mirror of https://lore.kernel.org/lkml/
 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 3/7] net: ftgmac100: Add AST2700 compatible support
Date: Mon, 16 Nov 2026 13:54:17 +0000	[thread overview]
Message-ID: <179483725712.3136.17992179574597275768@kernel.org> (raw)
In-Reply-To: <20261112-support_ast2700-v6-3-238020bf46cf@aspeedtech.com>

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

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

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] ftgmac100_reset_and_config_mac() dereferences
  priv->netdev->phydev->interface whenever priv->is_aspeed is true, with…
- [High] net: ftgmac100: missing MAC reset deassertion for AST2700 in
  ftgmac100_probe()
- [Medium] Since this patch, AST2700 goes through the Aspeed path in
  ftgmac100_probe(): is_aspeed is set, EDORR/EDOTR use BIT(30), and…
- [Medium] The series commit "dt-bindings: net: ftgmac100: Make Aspeed
  compatibles standalone" (extended by "dt-bindings: net: ftgmac100: Add…
- [Low] The binding requires `phy-mode` for every aspeed,ast2700-mac
  node, and its commit message says this matches "the driver's probe-…
- [Low] The comment on struct ftgmac100::rclk still says `/*
  AST2500/AST2600 RMII ref clock gate */`.

--

net: ftgmac100: Add AST2700 compatible support

This patch adds an FTGMAC100_AST2700 mac_id, its OF match data and an
"aspeed,ast2700-mac" compatible entry. It also adds AST2700 to the Aspeed
branch in ftgmac100_probe(), which sets is_aspeed and the BIT(30)
EDORR/EDOTR masks for the new MAC.

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

[ ... ]

> @@ -2017,7 +2018,8 @@ static int ftgmac100_probe(struct platform_device *pdev)
>  
>  	if (priv->mac_id == FTGMAC100_AST2400 ||
>  	    priv->mac_id == FTGMAC100_AST2500 ||
> -	    priv->mac_id == FTGMAC100_AST2600) {
> +	    priv->mac_id == FTGMAC100_AST2600 ||
> +	    priv->mac_id == FTGMAC100_AST2700) {
>  		priv->rxdes0_edorr_mask = BIT(30);
>  		priv->txdes0_edotr_mask = BIT(30);
>  		priv->is_aspeed = true;

[Severity: High]
With AST2700 now on the is_aspeed path, does anything release the MAC
from reset on this SoC?

On AST2400 to AST2600, the MAC clock gates in the Aspeed clock drivers
carry a coupled reset index. Enabling MACCLK through
devm_clk_get_enabled() in ftgmac100_setup_clk() therefore also
deasserts the SCU MAC reset.

On AST2700 that coupling seems to be gone. The SCU1_CLK_GATE_MAC0CLK to
MAC2CLK gates in clk-ast2700.c only clear the stop bit in
SCU1_CLK_STOP. SCU1_RESET_MAC0 to MAC2 are separate reset lines in
reset-aspeed.c, so enabling the clock leaves the MAC in reset.

ftgmac100_probe() gets priv->rst with
devm_reset_control_get_optional_exclusive() but never calls
reset_control_deassert() on it. The only deassert is in
ftgmac100_reset_and_config_mac(), and only for RMII:

	/* Aspeed RMII needs SCU reset to clear status */
	if (priv->is_aspeed && priv->netdev->phydev->interface == PHY_INTERFACE_MODE_RMII) {

Suppose the bootloader did not release the AST2700 MAC reset. An RGMII
MAC would then stay in reset across probe and ndo_open, and
ftgmac100_open() -> ftgmac100_reset_and_config_mac() ->
ftgmac100_reset_mac() would be driving a block that is held in reset.
The interface would not come up, and the most likely visible symptom is
-EIO from the SW_RST poll.

The probe ordering has a related problem. ftgmac100_initial_mac() reads
FTGMAC100_OFFSET_MAC_MADR and FTGMAC100_OFFSET_MAC_LADR before priv->rst
is obtained and before ftgmac100_setup_clk() enables the MAC clock. On
AST2700 this read can hit a gated and reset block. In that case the
bootloader-programmed address is lost and the driver falls back to a
random MAC.

Other AST2700 peripheral drivers, such as aspeed-vhub and
aspeed-g6-pwm-tach, deassert their reset explicitly in probe. For
AST2700, should ftgmac100_probe() enable the clock and deassert
priv->rst before it first touches MAC registers? Or does the series
expect firmware to always leave the MAC clocked and out of reset? If it
is the latter, that requirement should be stated somewhere.

[Severity: Medium]
This groups AST2700 with the AST2600-style Aspeed MACs. Should the two
AST2600-only workarounds later in ftgmac100_probe() also apply to AST2700?

	/* Disable ast2600 problematic HW arbitration */
	if (priv->mac_id == FTGMAC100_AST2600)
		iowrite32(FTGMAC100_TM_DEFAULT,
			  priv->base + FTGMAC100_OFFSET_TM);
	...
	/* AST2600 tx checksum with NCSI is broken */
	if (priv->use_ncsi && priv->mac_id == FTGMAC100_AST2600)
		netdev->hw_features &= ~NETIF_F_HW_CSUM;

Suppose the AST2700 MAC kept the AST2600 arbitration logic or the NC-SI TX
checksum defect. AST2700 would then run with the hardware default
arbitration mode, and with NC-SI it would still advertise NETIF_F_HW_CSUM.

Neither this patch nor the rest of the series changes these checks or says
that AST2700 is free of these errata.

[Severity: High]
Now that is_aspeed is set for AST2700, can ftgmac100_reset_and_config_mac()
dereference a NULL phydev?

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

ftgmac100_probe_dt() returns 0 without attaching a PHY when the node has no
use-ncsi, no fixed-link and no phy-handle, but does have an mdio child:

	if (!ftgmac100_has_child_node(np, "mdio")) {
		...
		err = ftgmac100_mii_probe(netdev);
		...
	}

	return 0;

The binding allows this configuration. For such an AST2700 node,
register_netdev() succeeds. After that, both of these paths would reach the
unchecked dereference:

  ftgmac100_open()->ftgmac100_reset_and_config_mac()
  ftgmac100_reset()->ftgmac100_reset_and_config_mac()

ftgmac100_open() runs under RTNL, so an oops there would leave rtnl_mutex
held.

The dereference itself dates back to commit af350ee72e9d ("net: ftgmac100:
Add optional reset control for RMII mode on Aspeed SoCs"), which covered
AST2400 to AST2600. This patch makes it reachable for AST2700.

Later in the series, "net: ftgmac100: Enable AST2700 RMII support" adds a
second unchecked dereference in ftgmac100_start_hw():

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

That commit message says "ftgmac100_probe_dt() always attaches a
phy_device before register_netdev() can succeed". The mdio child path
above shows that this is not always true.

Elsewhere, ftgmac100_open() and the reset task both check
if (netdev->phydev) before using it. Should these two paths do the same?

[Severity: Low]
This isn't a bug, but with is_aspeed now set for AST2700,
ftgmac100_setup_clk() also stores the "RCLK" clock in priv->rclk for
AST2700. The comment on that field in struct ftgmac100 still reads:

	/* AST2500/AST2600 RMII ref clock gate */
	struct clk *rclk;

Should it mention AST2700, as the binding in this series does?

[ ... ]

> @@ -2142,6 +2148,8 @@ static const struct of_device_id ftgmac100_of_match[] = {
>  	  .data = &ftgmac100_match_data_ast2500 },
>  	{ .compatible = "aspeed,ast2600-mac",
>  	  .data = &ftgmac100_match_data_ast2600 },
> +	{ .compatible = "aspeed,ast2700-mac",
> +	  .data = &ftgmac100_match_data_ast2700 },
>  	{ .compatible = "faraday,ftgmac100",
>  	  .data = &ftgmac100_match_data_faraday },
>  	{ }

[Severity: Medium]
This comment is about the binding changes elsewhere in the series, not this
hunk. "dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone",
later extended by "dt-bindings: net: ftgmac100: Add AST2700 compatible",
removes the oneOf that accepted the "aspeed,ast2x00-mac",
"faraday,ftgmac100" pair. In its place is a single-value enum:

  compatible:
    enum:
      - faraday,ftgmac100
      - aspeed,ast2400-mac
      - aspeed,ast2500-mac
      - aspeed,ast2600-mac
      - aspeed,ast2700-mac

Will the in-tree Aspeed MAC nodes still validate? They all still use the
two-string form. For example, aspeed-g6.dtsi has:

	compatible = "aspeed,ast2600-mac", "faraday,ftgmac100";

aspeed-g4.dtsi and aspeed-g5.dtsi use the same form, and the series does
not change any of them. With a bare enum, dtbs_check would reject all of
these nodes as too long.

The change also drops a documented compatible combination that deployed
DTBs use. The match table above already handles both forms, so the driver
does not need the binding restructured.

[Severity: Low]
This one is also about the series. The binding makes phy-mode required for
every aspeed,ast2700-mac node, and its commit message says this matches
"the driver's probe-time requirement". Can the driver ever enforce that
requirement?

"net: ftgmac100: Require phy-mode for AST2700" adds this check to
ftgmac100_mii_probe():

	if (priv->mac_id == FTGMAC100_AST2700) {
		dev_err(priv->dev, "phy-mode is required for this SoC\n");
		return -EINVAL;
	}

However, ftgmac100_mii_probe() returns -ENODEV earlier when !priv->mii_bus.
priv->mii_bus is only set by ftgmac100_setup_mdio(), and ftgmac100_probe()
calls that only for FARADAY, AST2400 and AST2500:

	if (priv->mac_id == FTGMAC100_FARADAY ||
	    priv->mac_id == FTGMAC100_AST2400 ||
	    priv->mac_id == FTGMAC100_AST2500) {
		err = ftgmac100_setup_mdio(netdev);

The other paths behave as follows:

  - ftgmac100_probe_ncsi() hard-codes PHY_INTERFACE_MODE_RMII and never
    reads phy-mode.
  - On the phy-handle and fixed-link path, of_phy_get_and_connect() fails
    without phy-mode for every compatible, not just AST2700.

So the new AST2700 check looks unreachable, and NC-SI AST2700 nodes would
have to carry a property that the driver ignores.

Could the binding constraint and the commit messages be updated to match
what the driver actually does?

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

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

Thread overview: 18+ 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-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-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-16 13:54   ` netdev-bot+sashiko [this message]
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-16 13:54   ` netdev-bot+sashiko
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=179483725712.3136.17992179574597275768@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

all inboxes | Powered by JetHome®