Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: kaloz@kernel.org
Cc: tsbogend@alpha.franken.de, netdev@vger.kernel.org,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, linux-mips@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 2/2] net: sgi: ioc3-eth: take the MAC address from a device property
Date: Thu, 19 Nov 2026 10:22:51 +0000	[thread overview]
Message-ID: <179508377126.3136.8138823841306639675@kernel.org> (raw)
In-Reply-To: <20261116102115.27574-3-kaloz@kernel.org>

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

Critical: 0 · High: 0 (2) · 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 new fallback in ioc3eth_probe()
  (drivers/net/ethernet/sgi/ioc3-eth.c:861-863) calls…
- [Medium] On a board that has a 1-wire MAC PROM and also gets the new
  device property, which MAC address ioc3eth_probe() uses depends on…

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
  ioc3eth_probe() never calls platform_set_drvdata(pdev, dev), while…
- [High] This problem wasn't introduced by this patch, but
  ioc3eth_probe() requests the IRQ with devm_request_irq(&pdev->dev,…

--

net: sgi: ioc3-eth: take the MAC address from a device property

This commit adds a device_get_mac_address() fallback to ioc3eth_probe().
It is used when the MAC address can't be read from the 1-wire PROM, so
that boards without a PROM no longer defer probing forever.

> diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c b/drivers/net/ethernet/sgi/ioc3-eth.c
> index 25139cf5ff62c..fa844267c325a 100644
> --- a/drivers/net/ethernet/sgi/ioc3-eth.c
> +++ b/drivers/net/ethernet/sgi/ioc3-eth.c
> @@ -857,8 +857,9 @@ static int ioc3eth_probe(struct platform_device *pdev)
>  		dev_err(&pdev->dev, "Invalid resource\n");
>  		return -EINVAL;
>  	}
> -	/* get mac addr from one wire prom */
> -	if (ioc3eth_get_mac_addr(regs, mac_addr))
> +	/* get mac addr from one wire prom, or from a device property */
> +	if (ioc3eth_get_mac_addr(regs, mac_addr) &&
> +	    device_get_mac_address(&pdev->dev, mac_addr))

[Severity: Medium]
Can device_get_mac_address() succeed for this device on any in-tree board?

Only ioc3_eth_setup() in drivers/mfd/ioc3.c creates the ioc3-eth platform
device, and it does so from this cell:

drivers/mfd/ioc3.c:
static struct mfd_cell ioc3_eth_cells[] = {
	{
		.name = "ioc3-eth",
		.resources = ioc3_eth_resources,
		.num_resources = ARRAY_SIZE(ioc3_eth_resources),
	},

The cell sets neither .swnode nor .of_compatible, and IP27/IP30 have no
DT or ACPI. So mfd_add_device() never gives the child a fwnode.
dev_fwnode() returns NULL and fwnode_get_mac_address() fails.

The second step, nvmem_get_mac_address(), ends up in
nvmem_cell_get_from_lookup(), which is keyed by dev_name(). The child is
registered with PLATFORM_DEVID_AUTO ("ioc3-eth.N.auto"), so board code
can't target it reliably. Nothing in tree registers such a lookup either.

As far as I can tell, boards without a 1-wire MAC PROM still defer
forever, which is the problem the commit message says this fixes.

Which board is this meant for? Is there a companion change to
drivers/mfd/ioc3.c, for example a software node with "mac-address" or
"local-mac-address" attached to the ioc3-eth cell?

The previous commit in the series mentions "IP35 support will hand it
window addresses", so the user may be out of tree or not posted yet. Could
the commit message say so?

[Severity: Medium]
What happens on a board that has the 1-wire PROM and also gets the
property?

ioc3eth_get_mac_addr() passes the nvmem_device_find() error through
unchanged:

	nvmem = nvmem_device_find(prefix, ioc3eth_nvmem_match);
	if (IS_ERR(nvmem))
		return PTR_ERR(nvmem);

nvmem_device_match() in drivers/nvmem/core.c returns
ERR_PTR(-EPROBE_DEFER) whenever the PROM's nvmem device isn't registered
yet. So "no PROM fitted" and "PROM not enumerated yet" give the same
error here.

The PROM's nvmem device only appears after the w1 master kthread
(w1_process()->w1_search_process()) finds the slave and the family driver
binds. Also, the "ioc3-eth" cell comes before "sgi_w1" in
ioc3_eth_cells[], so the first ioc3-eth probe can run before the 1-wire
master exists at all.

Before this patch, any PROM failure deferred the probe, so a board with a
PROM always ended up using the PROM address. Now the first failed lookup
falls back to the property and probe succeeds. eth_hw_addr_set() and
ioc3_init() then program that address into EMAR_H/EMAR_L for the rest of
the boot.

Could the MAC address then change from boot to boot, depending on w1
enumeration timing? The new comment suggests the PROM takes priority, but
that only holds if enumeration finishes first.

A PROM with a bad CRC (-EINVAL) also falls back to the property without
any message, and nothing logs which source supplied the address.

>  		return -EPROBE_DEFER; /* not available yet */
>  
>  	dev = alloc_etherdev(sizeof(struct ioc3_private));

[Severity: High]
This isn't a bug introduced by this patch, but ioc3eth_probe() never calls
platform_set_drvdata(pdev, dev), while ioc3eth_remove() relies on it:

drivers/net/ethernet/sgi/ioc3-eth.c:ioc3eth_remove() {
	struct net_device *dev = platform_get_drvdata(pdev);
	struct ioc3_private *ip = netdev_priv(dev);

	unregister_netdev(dev);
	timer_delete_sync(&ip->ioc3_timer);
	...
}

After a successful probe, won't platform_get_drvdata() return NULL here?
If so, unregister_netdev(NULL) oopses. The timer_delete_sync() and
dma_free_coherent() calls would then work on a bogus ip pointer, and the
netdev, DMA rings and timer never get torn down.

This path is reachable through /sys/bus/platform/drivers/ioc3-eth/unbind
(suppress_bind_attrs isn't set), or by removing the parent IOC3 MFD
device.

Because this patch lets probe succeed on more boards, more systems can
reach this remove path.

[Severity: High]
This is also a pre-existing issue, but ioc3eth_probe() requests a shared
IRQ with devm and passes the net_device, which isn't devm-managed, as
dev_id:

	if (devm_request_irq(&pdev->dev, dev->irq, ioc3_interrupt,
			     IRQF_SHARED, "ioc3-eth", dev)) {

Every error path after that ends here: rx/tx ring allocation failure, the
"Didn't find a PHY" case, and register_netdev() failure.

out_free:
	free_netdev(dev);
	return err;

The netdev was never registered, so free_netdev() frees it right away.
The IRQ stays installed until devres_release_all() runs after probe
returns. ioc3eth_remove() has the same ordering: it calls free_netdev(dev)
before devres frees the IRQ.

Can ioc3_interrupt() run on the freed net_device in that window?

static irqreturn_t ioc3_interrupt(int irq, void *dev_id)
{
	struct ioc3_private *ip = netdev_priv(dev_id);
	struct ioc3_ethregs *regs = ip->regs;
	u32 eisr;

	eisr = readl(&regs->eisr);
	writel(eisr, &regs->eisr);
	...

An interrupt from another device on the shared line can trigger this.
With CONFIG_DEBUG_SHIRQ it always happens, because __free_irq() calls the
handler one extra time for IRQF_SHARED actions.

Either a plain request_irq()/free_irq() pair, with free_irq() called
before free_netdev(), or devm_alloc_etherdev() would avoid this.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116102115.27574-1-kaloz%40kernel.org

      reply	other threads:[~2026-11-19 10:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 10:21 [PATCH net-next v2 0/2] net: sgi: ioc3-eth: two changes for the IOC3 on SGI IP35 machines Imre Kaloz
2026-11-16 10:21 ` [PATCH net-next v2 1/2] net: sgi: ioc3-eth: apply the DMA attributes only to 64-bit addresses Imre Kaloz
2026-11-19 10:22   ` netdev-bot+sashiko
2026-11-16 10:21 ` [PATCH net-next v2 2/2] net: sgi: ioc3-eth: take the MAC address from a device property Imre Kaloz
2026-11-19 10:22   ` netdev-bot+sashiko [this message]

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=179508377126.3136.8138823841306639675@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kaloz@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tsbogend@alpha.franken.de \
    /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