Devicetree
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: suraj.gupta2@amd.com
Cc: radhey.shyam.pandey@amd.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, michal.simek@amd.com, linux@armlinux.org.uk,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v5 1/6] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops
Date: Mon, 16 Nov 2026 04:12:26 +0000	[thread overview]
Message-ID: <179480234612.3136.14924278307079342368@kernel.org> (raw)
In-Reply-To: <20261114182947.2908628-2-suraj.gupta2@amd.com>

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

Critical: 0 · High: 1 · Medium: 1 · 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).

- [High] net: xilinx: axienet: axienet_probe() fails on software-node
  devices
- [Medium] This commit is presented as a no-functional-change refactor,
  but it also contains a real fix for a NULL pointer dereference.

--

net: xilinx: axienet: Introduce axienet_config for MAC-specific ops

This commit adds struct axienet_config, which holds MAC capability flags
and MAC-specific callbacks. It is filled in from the OF match table, and
the shared 1G code paths now use it. It also puts a NULL check on
lp->mii_bus around the MDIO teardown in axienet_remove().

> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> index 7e83c4b5f1931..125ad3dbf6aa9 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c

[ ... ]

> @@ -3149,10 +3297,12 @@ static int axienet_probe(struct platform_device *pdev)
>  	lp->tx_dma_cr = axienet_calc_cr(lp, XAXIDMA_DFT_TX_THRESHOLD,
>  					XAXIDMA_DFT_TX_USEC);
>  
> -	ret = axienet_mdio_setup(lp);
> -	if (ret)
> -		dev_warn(&pdev->dev,
> -			 "error registering MDIO bus: %d\n", ret);
> +	if (lp->axienet_config->mdio) {
> +		ret = axienet_mdio_setup(lp);
> +		if (ret)
> +			dev_warn(&pdev->dev,
> +				 "error registering MDIO bus: %d\n", ret);
> +	}
>  
>  	if (lp->phy_mode == PHY_INTERFACE_MODE_SGMII ||
>  	    lp->phy_mode == PHY_INTERFACE_MODE_1000BASEX) {

[ ... ]

> @@ -3235,7 +3383,8 @@ static void axienet_remove(struct platform_device *pdev)
>  	if (lp->pcs_phy)
>  		put_device(&lp->pcs_phy->dev);
>  
> -	axienet_mdio_teardown(lp);
> +	if (lp->mii_bus)
> +		axienet_mdio_teardown(lp);
>  }

[Severity: Medium]
Could this NULL check go to net as its own fix, with a Fixes: tag and
Cc: stable, and this refactor then be based on it?

Without the guard, the current 1G driver can oops on unbind. Every
failure path in axienet_mdio_setup() frees the bus and sets lp->mii_bus
to NULL. The failure paths are an MDC divisor overflow, a timeout in
axienet_mdio_wait_until_ready(), and a failed of_mdiobus_register():

drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c:axienet_mdio_setup() {
    ...
unregister:
	of_node_put(mdio_node);
	mdiobus_free(bus);
	lp->mii_bus = NULL;
	return ret;
}

axienet_probe() only warns and continues, so the device binds with
lp->mii_bus == NULL. Then, on unbind or remove:

axienet_remove()
  axienet_mdio_teardown(lp)
    mdiobus_unregister(lp->mii_bus)
      reads bus->state on a NULL bus

The commit message already describes this:

  It also hardens the existing 1G path: a failed
  axienet_mdio_setup() already left lp->mii_bus NULL while probe only warns
  and continues (e.g. a 1G device using a fixed-link), so unbinding such a
  device would dereference NULL in mdiobus_unregister().

The fix is part of a large refactor and has no Fixes: tag, so stable and
LTS kernels can't backport it. No other patch in the series carries it
on its own. Two candidates for the Fixes: tag are the commit that made
MDIO setup failure non-fatal in probe and the commit that clears
lp->mii_bus on failure.

[ ... ]

> @@ -2894,27 +3042,13 @@ static int axienet_probe(struct platform_device *pdev)
>  	seqcount_mutex_init(&lp->hw_stats_seqcount, &lp->stats_lock);
>  	INIT_DEFERRABLE_WORK(&lp->stats_work, axienet_refresh_stats);
>  
> -	lp->axi_clk = devm_clk_get_optional_enabled(&pdev->dev,
> -						    "s_axi_lite_clk");
> -	if (!lp->axi_clk) {
> -		/* For backward compatibility, if named AXI clock is not present,
> -		 * treat the first clock specified as the AXI clock.
> -		 */
> -		lp->axi_clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
> -	}
> -	if (IS_ERR(lp->axi_clk))
> -		return dev_err_probe(&pdev->dev, PTR_ERR(lp->axi_clk),
> -				     "could not get AXI clock\n");
> -
> -	lp->misc_clks[0].id = "axis_clk";
> -	lp->misc_clks[1].id = "ref_clk";
> -	lp->misc_clks[2].id = "mgt_clk";
> +	lp->axienet_config = device_get_match_data(&pdev->dev);
> +	if (!lp->axienet_config)
> +		return -ENODEV;
>  
> -	ret = devm_clk_bulk_get_optional_enable(&pdev->dev, XAE_NUM_MISC_CLOCKS,
> -						lp->misc_clks);
> +	ret = lp->axienet_config->clk_init(lp);
>  	if (ret)
> -		return dev_err_probe(&pdev->dev, ret,
> -				     "could not get/enable misc. clocks\n");
> +		return ret;
>  
>  	/* Map device registers */
>  	lp->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &ethres);

[Severity: High]
This makes missing match data a hard probe failure. Doesn't that
break devices that are not instantiated from DT?

device_get_match_data() only asks the device's fwnode, through
fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev). For
an OF node that resolves through axienet_of_match. software_node_ops
does not implement .device_get_match_data, though, and axienet_driver
has no id_table either.

The driver still carries MODULE_ALIAS("platform:" AXIENET_DRIVER_NAME).
Probe also reads its configuration through device_property_read_u32()
and the fwnode helpers, so a parent driver can create the AXI Ethernet
device by name with a software_node attached. The ptp_ocp TimeCard
child device is one example. Such a device has no OF match, so
device_get_match_data() returns NULL. axienet_probe() then returns
-ENODEV before it touches the hardware. Before this patch the same
device probed fine as a 1G MAC.

The commit message says no functional change is intended for the
existing 1G path, and this is one. As far as I can see the later
patches in the series keep this lookup as is, so the regression is
still there at the end of the series.

Since every device bound by name today is a 1G MAC, would it be enough
to fall back to &axienet_1g_config when device_get_match_data() returns
NULL? Or would you rather add a platform_device_id table whose
driver_data points at axienet_1g_config, and have probe use
platform_get_device_id() when there is no fwnode match data?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261114182947.2908628-1-suraj.gupta2%40amd.com

  parent reply	other threads:[~2026-11-16  4:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 18:29 [PATCH net-next v5 0/6] net: xilinx: axienet: Add 10G/25G (XXV) ethernet support Suraj Gupta
2026-11-14 18:29 ` [PATCH net-next v5 1/6] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops Suraj Gupta
2026-11-15 18:31   ` sashiko-bot
2026-11-16  4:12   ` netdev-bot+sashiko [this message]
2026-11-14 18:29 ` [PATCH net-next v5 2/6] dt-bindings: net: xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet Suraj Gupta
2026-11-16  4:12   ` netdev-bot+sashiko
2026-11-14 18:29 ` [PATCH net-next v5 3/6] net: xilinx: axienet: Propagate device reset failure from ndo_open Suraj Gupta
2026-11-15 18:31   ` sashiko-bot
2026-11-16  4:12   ` netdev-bot+sashiko
2026-11-14 18:29 ` [PATCH net-next v5 4/6] net: xilinx: axienet: Add 10G/25G (XXV) ethernet support Suraj Gupta
2026-11-15 18:31   ` sashiko-bot
2026-11-16  4:12   ` netdev-bot+sashiko
2026-11-14 18:29 ` [PATCH net-next v5 5/6] net: xilinx: axienet: Dispatch statistics through axienet_config ops Suraj Gupta
2026-11-14 18:29 ` [PATCH net-next v5 6/6] net: xilinx: axienet: Add statistics support for XXV ethernet Suraj Gupta
2026-11-15 18:31   ` sashiko-bot
2026-11-16  4:12   ` 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=179480234612.3136.14924278307079342368@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=michal.simek@amd.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=radhey.shyam.pandey@amd.com \
    --cc=robh@kernel.org \
    --cc=suraj.gupta2@amd.com \
    /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