🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
13 messages
13 total messages Started by Florian Fainelli Thu, 12 Nov 2026 04:52
[PATCH net v2 00/12] net: au1000: Bug fixes
#14899
Author: Florian Fainelli
Date: Thu, 12 Nov 2026 04:52
56 lines
13740 bytes
This patch series contains bug fixes that were found during code
inspection and also during fixing the open/close/open issue that was met
on the MTX-1 platform.

These patches were tested on a Meshcube MTX-1 board using targeted tests
to ensure the multicast and open/close/open bugs were fixed.

 Changes since v1:
• Rebased onto current net and added the Alchemy PROM Ethernet-address
  lifetime fix needed to boot MTX-1.
• Reset the MAC after PHY/MDIO teardown, since final MDIO accesses can
  re-enable it. Avoid accessing MAC control registers when its clock is
  already disabled.
• Use sleepable polling for MDIO write completion instead of millisecond
  busy-waits.
• Correct TX reclaim ordering by advancing tx_tail when submission
  reclaims a completed descriptor. Consume transmitted skbs outside the
  lock using an IRQ-safe helper.
• Restore receive filtering before enabling RX, holding the address-list
  and device locks to keep the programmed filter consistent.
• Rework startup ordering to resume the PHY synchronously, initialize
  the MAC, then start the PHY state machine. Clear cached link state on
  open and use acknowledged link/duplex state under the device lock.
• Move the LAN83C183 recovery-delay patch before the MAC/PHY sequencing
  change.
• Add a TX length check to prevent oversized packets from overflowing
  the DMA bounce buffer.

Rebuilt the kernel and root filesystem and regression-tested on MTX-1.
All 11 boot-smoke checks passed, including 15 down/up cycles across
normal, promiscuous and all-multicast modes, opened/closed and
never-opened removal/rebind, and connectivity recovery. No kernel
warnings or errors were detected.

Florian Fainelli (12):
  net: au1000: recycle RX descriptors on allocation failure
  net: au1000: clear all-multicast mode when restoring hash filtering
  net: au1000: disconnect the PHY before freeing the MDIO bus
  net: au1000: report MDIO transaction timeouts
  net: au1000: serialize TX completion with packet submission
  net: au1000: assign a valid MAC address without platform data
  net: au1000: fix buffer descriptor free list insertion
  net: au1000: restore receive filtering before enabling RX
  net: au1000: restore RX buffer addresses when restarting the MAC
  net: phy: smsc: wait for LAN83C183 power-down recovery
  net: au1000: keep the MAC stopped until the PHY link is ready
  net: au1000: reject frames larger than the TX bounce buffer

 drivers/net/ethernet/amd/au1000_eth.c | 140 ++++++++++++++++++++------
 drivers/net/phy/Kconfig               |   2 +-
 drivers/net/phy/smsc.c                |  26 +++++
 3 files changed, 134 insertions(+), 34 deletions(-)

-- 
2.53.0
[PATCH net v2 04/12] net: au1000: report MDIO transaction timeouts
#14901
Author: Florian Fainelli
Date: Thu, 12 Nov 2026 04:52
95 lines
14284 bytes
The MDIO write callback reports success even if the controller stays
busy and no write is issued. Propagate timeout errors and wait for write
completion so failure of the final transaction is reported to phylib as
well. Return ETIMEDOUT for read timeouts too.

Use readl_poll_timeout() for write completion with a 20 microsecond sleep
interval and a 20 millisecond timeout. The MDIO callback runs in sleepable
context, so avoid adding millisecond busy-waits for completion.

Fixes: 0638dec01e89 ("[PATCH] net: au1000_eth: PHY framework conversion")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/amd/au1000_eth.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
index 7063f9e5bc7c..6b2e216a8361 100644
--- a/drivers/net/ethernet/amd/au1000_eth.c
+++ b/drivers/net/ethernet/amd/au1000_eth.c
@@ -41,6 +41,7 @@
 #include <linux/platform_device.h>
 #include <linux/cpu.h>
 #include <linux/io.h>
+#include <linux/iopoll.h>
 
 #include <asm/mipsregs.h>
 #include <asm/irq.h>
@@ -278,7 +279,7 @@ static int au1000_mdio_read(struct net_device *dev, int phy_addr, int reg)
 		mdelay(1);
 		if (--timedout == 0) {
 			netdev_err(dev, "read_MII busy timeout!!\n");
-			return -1;
+			return -ETIMEDOUT;
 		}
 	}
 
@@ -292,26 +293,27 @@ static int au1000_mdio_read(struct net_device *dev, int phy_addr, int reg)
 		mdelay(1);
 		if (--timedout == 0) {
 			netdev_err(dev, "mdio_read busy timeout!!\n");
-			return -1;
+			return -ETIMEDOUT;
 		}
 	}
 	return readl(mii_data_reg);
 }
 
-static void au1000_mdio_write(struct net_device *dev, int phy_addr,
-			      int reg, u16 value)
+static int au1000_mdio_write(struct net_device *dev, int phy_addr,
+			     int reg, u16 value)
 {
 	struct au1000_private *aup = netdev_priv(dev);
 	u32 *const mii_control_reg = &aup->mac->mii_control;
 	u32 *const mii_data_reg = &aup->mac->mii_data;
 	u32 timedout = 20;
 	u32 mii_control;
+	int ret;
 
 	while (readl(mii_control_reg) & MAC_MII_BUSY) {
 		mdelay(1);
 		if (--timedout == 0) {
 			netdev_err(dev, "mdio_write busy timeout!!\n");
-			return;
+			return -ETIMEDOUT;
 		}
 	}
 
@@ -320,6 +322,13 @@ static void au1000_mdio_write(struct net_device *dev, int phy_addr,
 
 	writel(value, mii_data_reg);
 	writel(mii_control, mii_control_reg);
+
+	ret = readl_poll_timeout(mii_control_reg, mii_control,
+				 !(mii_control & MAC_MII_BUSY), 20, 20000);
+	if (ret)
+		netdev_err(dev, "mdio_write busy timeout!!\n");
+
+	return ret;
 }
 
 static int au1000_mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum)
@@ -344,8 +353,7 @@ static int au1000_mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum,
 	 */
 	au1000_enable_mac(dev, 0);
 
-	au1000_mdio_write(dev, phy_addr, regnum, value);
-	return 0;
+	return au1000_mdio_write(dev, phy_addr, regnum, value);
 }
 
 static int au1000_mdiobus_reset(struct mii_bus *bus)
-- 
2.53.0
[PATCH net v2 07/12] net: au1000: fix buffer descriptor free list insertion
#14900
Author: Florian Fainelli
Date: Thu, 12 Nov 2026 04:52
30 lines
12249 bytes
ReleaseDB links the old head to the returned descriptor and makes the
returned descriptor the new head without updating its stale next
pointer. This loses free descriptors and can create cycles. Link the
returned descriptor to the old head instead, matching GetFreeDB and the
list initialization.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/amd/au1000_eth.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
index ea8f7787dd5d..f127c0184036 100644
--- a/drivers/net/ethernet/amd/au1000_eth.c
+++ b/drivers/net/ethernet/amd/au1000_eth.c
@@ -581,9 +581,7 @@ static struct db_dest *au1000_GetFreeDB(struct au1000_private *aup)
 
 static void au1000_ReleaseDB(struct au1000_private *aup, struct db_dest *pDB)
 {
-	struct db_dest *pDBfree = aup->pDBfree;
-	if (pDBfree)
-		pDBfree->pnext = pDB;
+	pDB->pnext = aup->pDBfree;
 	aup->pDBfree = pDB;
 }
 
-- 
2.53.0
[PATCH net v2 10/12] net: phy: smsc: wait for LAN83C183 power-down recovery
#14902
Author: Florian Fainelli
Date: Thu, 12 Nov 2026 04:52
86 lines
13939 bytes
The LAN83C183 uses the generic PHY driver, which returns immediately
after clearing BMCR_PDOWN. Section 1.11 of the datasheet allows 500 ms
before normal operation is restored. Starting the Au1000 MAC before the
MII clocks recover can hang the MTX-1 when reopening its interface.

Add a LAN83C183 driver entry and resume callback. Wait for recovery only
when BMCR_PDOWN was actually cleared, and propagate MDIO errors without
waiting. Resuming an already awake PHY does not incur the delay.

Fixes: be9dad1f9f26 ("net: phy: suspend phydev when going to HALTED")
Link: https://pdf.dzsc.com/LAN/LAN83C183.pdf#page=44
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/Kconfig |  2 +-
 drivers/net/phy/smsc.c  | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 30e9d22c8d1a..10466b2574eb 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -421,7 +421,7 @@ config SMSC_PHY
 	tristate "SMSC PHYs"
 	select CRC16
 	help
-	  Currently supports the LAN83C185, LAN8187 and LAN8700 PHYs
+	  Currently supports the LAN83C183, LAN83C185, LAN8187 and LAN8700 PHYs
 
 config STE10XP
 	tristate "STMicroelectronics STe10Xp PHYs"
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index 48487149c225..c3b51afd4b1e 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -13,6 +13,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/delay.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mii.h>
@@ -684,8 +685,32 @@ int smsc_phy_probe(struct phy_device *phydev)
 }
 EXPORT_SYMBOL_GPL(smsc_phy_probe);
 
+static int lan83c183_resume(struct phy_device *phydev)
+{
+	int ret;
+
+	ret = phy_modify_changed(phydev, MII_BMCR, BMCR_PDOWN, 0);
+	if (ret < 0)
+		return ret;
+
+	/* The PHY needs up to 500 ms to restore operation after power-down. */
+	if (ret)
+		msleep(500);
+
+	return 0;
+}
+
 static struct phy_driver smsc_phy_driver[] = {
 {
+	.phy_id		= 0x0016f840,
+	.phy_id_mask	= 0xfffffff0,
+	.name		= "SMSC LAN83C183",
+
+	.get_features	= genphy_read_abilities,
+	.suspend	= genphy_suspend,
+	.resume		= lan83c183_resume,
+	.set_loopback	= genphy_loopback,
+}, {
 	.phy_id		= 0x0007c0a0, /* OUI=0x00800f, Model#=0x0a */
 	.phy_id_mask	= 0xfffffff0,
 	.name		= "SMSC LAN83C185",
@@ -887,6 +912,7 @@ MODULE_AUTHOR("Herbert Valerio Riedel");
 MODULE_LICENSE("GPL");
 
 static const struct mdio_device_id __maybe_unused smsc_tbl[] = {
+	{ 0x0016f840, 0xfffffff0 },
 	{ 0x0007c0a0, 0xfffffff0 },
 	{ 0x0007c0b0, 0xfffffff0 },
 	{ 0x0007c0c0, 0xfffffff0 },
-- 
2.53.0
[PATCH net v2 12/12] net: au1000: reject frames larger than the TX bounce buffer
#14903
Author: Florian Fainelli
Date: Thu, 12 Nov 2026 04:52
41 lines
12888 bytes
au1000_tx() copies skb->len bytes into a MAX_BUF_SIZE coherent buffer
without checking the length. Oversized non-GSO packets can reach this
path through AF_PACKET with PACKET_VNET_HDR and PACKET_TX_RING, whose
MTU checks are skipped when a virtio header is present. The copy can
corrupt neighboring DMA buffers or run beyond the coherent allocation.

Drop oversized packets before touching the ring or copying any data,
and account them in tx_dropped. Use an IRQ-safe skb free for netpoll.

Identified by Sashiko AI review; implementation and validation assisted
by OpenAI Codex. An extracted-function harness passed ASan/UBSan checks
for 2049- and 4096-byte drops and a 2048-byte accepted frame, as well as
TX ring regression cases. MIPS driver compilation and checkpatch passed.
The complete AF_PACKET trigger and hardware operation were not tested.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/amd/au1000_eth.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
index d60430a3795e..d8855ccf87aa 100644
--- a/drivers/net/ethernet/amd/au1000_eth.c
+++ b/drivers/net/ethernet/amd/au1000_eth.c
@@ -1008,6 +1008,12 @@ static netdev_tx_t au1000_tx(struct sk_buff *skb, struct net_device *dev)
 	int i;
 	unsigned long flags;
 
+	if (unlikely(skb->len > MAX_BUF_SIZE)) {
+		dev->stats.tx_dropped++;
+		dev_kfree_skb_any(skb);
+		return NETDEV_TX_OK;
+	}
+
 	netif_dbg(aup, tx_queued, dev, "tx: aup %x len=%d, data=%p, head %d\n",
 				(unsigned)aup, skb->len,
 				skb->data, aup->tx_head);
-- 
2.53.0
Re: [PATCH net v2 04/12] net: au1000: report MDIO transaction timeouts
#17192
Author: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 13:50
72 lines
10454 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The patch adds a second timeout exit to au1000_mdio_write()
  (drivers/net/ethernet/amd/au1000_eth.c), and both exits log the same…

--

net: au1000: report MDIO transaction timeouts

This commit makes au1000_mdio_write() return -ETIMEDOUT instead of
reporting success when the MII controller stays busy. It also adds a
readl_poll_timeout() check after the write so that a failed final
transaction is reported to phylib. The read path now returns -ETIMEDOUT
instead of -1.

> diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
> index 7063f9e5bc7c0..6b2e216a83618 100644
> --- a/drivers/net/ethernet/amd/au1000_eth.c
> +++ b/drivers/net/ethernet/amd/au1000_eth.c

[ ... ]

> @@ -292,26 +293,27 @@ static int au1000_mdio_read(struct net_device *dev, int phy_addr, int reg)

[ ... ]

>  	while (readl(mii_control_reg) & MAC_MII_BUSY) {
>  		mdelay(1);
>  		if (--timedout == 0) {
>  			netdev_err(dev, "mdio_write busy timeout!!\n");
> -			return;
> +			return -ETIMEDOUT;
>  		}
>  	}
>  
> @@ -320,6 +322,13 @@ static void au1000_mdio_write(struct net_device *dev, int phy_addr,
>  
>  	writel(value, mii_data_reg);
>  	writel(mii_control, mii_control_reg);
> +
> +	ret = readl_poll_timeout(mii_control_reg, mii_control,
> +				 !(mii_control & MAC_MII_BUSY), 20, 20000);
> +	if (ret)
> +		netdev_err(dev, "mdio_write busy timeout!!\n");

[Severity: Low]
This isn't a bug, but could this message use different wording from the
one in the busy wait loop above?

Both timeout paths in au1000_mdio_write() now print "mdio_write busy
timeout!!". The first one fires before anything is written to the
registers. The new one fires after writel() has already started the
transaction, so the PHY register may or may not have been changed. From
dmesg there is no way to tell which of the two happened.

au1000_mdio_read() already uses two separate messages ("read_MII busy
timeout!!" and "mdio_read busy timeout!!"). Something like "mdio_write
completion timeout" here would separate the two write cases the same way.

> +
> +	return ret;
>  }

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112045301.3669532-1-f.fainelli%40gmail.com
Re: [PATCH net v2 07/12] net: au1000: fix buffer descriptor free list insertion
#17188
Author: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 13:50
68 lines
10639 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message for "net: au1000: fix buffer descriptor free
  list insertion" says the old au1000_ReleaseDB() "loses free…

--

net: au1000: fix buffer descriptor free list insertion

This patch changes au1000_ReleaseDB() so the returned descriptor's pnext
points to the old free list head before it becomes the new head. Before
this, the old head's pnext was set to the returned descriptor. The new
code matches au1000_GetFreeDB() and how the list is set up in probe.

> ReleaseDB links the old head to the returned descriptor and makes the
> returned descriptor the new head without updating its stale next
> pointer. This loses free descriptors and can create cycles. Link the
> returned descriptor to the old head instead, matching GetFreeDB and the
> list initialization.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

[Severity: Low]
The code change looks correct. Should the commit message say that the old
behaviour had no runtime effect, though?

au1000_ReleaseDB() is only called on teardown paths: the err_out unwind
in au1000_probe() and au1000_remove(). In both cases the descriptor
buffers and aup are freed right afterwards:

drivers/net/ethernet/amd/au1000_eth.c:au1000_remove() {
    ...
	for (i = 0; i < NUM_RX_DMA; i++)
		if (aup->rx_db_inuse[i])
			au1000_ReleaseDB(aup, aup->rx_db_inuse[i]);

	for (i = 0; i < NUM_TX_DMA; i++)
		if (aup->tx_db_inuse[i])
			au1000_ReleaseDB(aup, aup->tx_db_inuse[i]);

	dma_free_coherent(&pdev->dev, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS),
			  aup->vaddr, aup->dma_addr);
    ...
	free_netdev(dev);
}

The err_out path in au1000_probe() also falls through to
dma_free_coherent() and free_netdev().

au1000_GetFreeDB() is only called from au1000_probe(), before any
au1000_ReleaseDB() call, and no RX or TX path walks aup->pDBfree. Also,
NUM_RX_BUFFS equals NUM_RX_DMA and NUM_TX_BUFFS equals NUM_TX_DMA, so
the free list is already empty after a successful probe.

So the lost entries or cycles only ever exist in a list that is about to
be freed and is never read again. With the Fixes: tag, stable tooling
could pick this up as a user-visible fix.

Could the message say the bug is latent with no functional impact, and
either drop the Fixes: tag or explain why it is needed?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112045301.3669532-1-f.fainelli%40gmail.com
Re: [PATCH net v2 10/12] net: phy: smsc: wait for LAN83C183 power-down recovery
#17186
Author: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 13:50
140 lines
12573 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

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

- [Medium] In this commit, the new 500 ms wait in lan83c183_resume()
  (drivers/net/phy/smsc.c) runs only after the Au1000 MAC has already…

Pre-existing issues:
- [Low] After this patch, the SMSC_PHY Kconfig help text
  (drivers/net/phy/Kconfig:424) reads "Currently supports the LAN83C183,…

--

net: phy: smsc: wait for LAN83C183 power-down recovery

This patch adds a LAN83C183 entry to the SMSC PHY driver. Its resume
callback clears BMCR_PDOWN and sleeps for 500 ms, but only if the bit
was actually set. The aim is to let the MII clocks recover before the
Au1000 MAC starts when the MTX-1 interface is reopened.

Link: https://pdf.dzsc.com/LAN/LAN83C183.pdf#page=44

> diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
> index 30e9d22c8d1a3..10466b2574eb4 100644
> --- a/drivers/net/phy/Kconfig
> +++ b/drivers/net/phy/Kconfig
> @@ -421,7 +421,7 @@ config SMSC_PHY
>  	tristate "SMSC PHYs"
>  	select CRC16
>  	help
> -	  Currently supports the LAN83C185, LAN8187 and LAN8700 PHYs
> +	  Currently supports the LAN83C183, LAN83C185, LAN8187 and LAN8700 PHYs

[Severity: Low]
This isn't a bug introduced by this patch, but the help text still
names only some of the PHYs that smsc_tbl[] in drivers/net/phy/smsc.c
binds. It leaves out the LAN911x internal PHY, the LAN8710/LAN8720,
the LAN8740 and the LAN8741/LAN8742.

Could the list be completed while this line is being changed anyway?

> diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
> index 48487149c2252..c3b51afd4b1e5 100644
> --- a/drivers/net/phy/smsc.c
> +++ b/drivers/net/phy/smsc.c

[ ... ]

> @@ -684,8 +685,32 @@ int smsc_phy_probe(struct phy_device *phydev)
>  }
>  EXPORT_SYMBOL_GPL(smsc_phy_probe);
>  
> +static int lan83c183_resume(struct phy_device *phydev)
> +{
> +	int ret;
> +
> +	ret = phy_modify_changed(phydev, MII_BMCR, BMCR_PDOWN, 0);
> +	if (ret < 0)
> +		return ret;
> +
> +	/* The PHY needs up to 500 ms to restore operation after power-down. */
> +	if (ret)
> +		msleep(500);

[Severity: Medium]
The commit message says:

  Starting the Au1000 MAC before the MII clocks recover can hang the
  MTX-1 when reopening its interface.

Does this patch alone prevent that ordering? au1000_open() starts the
MAC before it calls phy_start():

drivers/net/ethernet/amd/au1000_eth.c:au1000_open() {
    ...
	retval = au1000_init(dev);
    ...
	if (dev->phydev)
		phy_start(dev->phydev);

	netif_start_queue(dev);
    ...
}

and au1000_init() already sets the RX/TX enable bits:

drivers/net/ethernet/amd/au1000_eth.c:au1000_init() {
    ...
	control = MAC_RX_ENABLE | MAC_TX_ENABLE;
    ...
	writel(control, &aup->mac->control);
    ...
}

Suppose a close has run au1000_close()->phy_stop()->phy_suspend()->
genphy_suspend(), which sets BMCR_PDOWN. The reopen then appears to go
like this:

au1000_open()
  au1000_init()          <- MAC RX/TX enabled, PHY still powered down
  phy_start()
    __phy_resume()
      lan83c183_resume()
        clear BMCR_PDOWN
        msleep(500)

If so, the 500 ms wait only delays the PHY state machine and
netif_start_queue(). The MAC has already started by then.

The close path has the same ordering in reverse. au1000_close() calls
phy_stop() before au1000_reset_mac_unlocked(), so the PHY powers down
while the MAC is still running.

The next patch in the series, "net: au1000: keep the MAC stopped until
the PHY link is ready", seems to fix this. It calls phy_resume() before
au1000_init() and enables RX/TX only after au1000_adjust_link() has
seen link up. It also calls au1000_hard_stop() on link down. In the
PHY_HALTED path, phy_link_down() runs before phy_suspend(), so the MAC
stops before the PHY powers down.

Can the MTX-1 reopen hang still happen when bisecting to this commit
alone? If so, could the commit message mention that it depends on the
au1000 change, or could the two patches be reordered?

> +
> +	return 0;
> +}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112045301.3669532-1-f.fainelli%40gmail.com
Re: [PATCH net v2 12/12] net: au1000: reject frames larger than the TX bounce buffer
#17190
Author: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 13:50
115 lines
12400 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message understates how the overflow can be reached.

Pre-existing issues:
- [High] Several other drivers in drivers/net/ethernet/amd/ have the same
  unchecked copy of skb->len bytes into a fixed-size TX buffer.

--

net: au1000: reject frames larger than the TX bounce buffer

This patch adds a length check to au1000_tx(). Frames larger than
MAX_BUF_SIZE are now dropped and counted in tx_dropped instead of being
copied past the end of the TX bounce buffer.

> au1000_tx() copies skb->len bytes into a MAX_BUF_SIZE coherent buffer
> without checking the length. Oversized non-GSO packets can reach this
> path through AF_PACKET with PACKET_VNET_HDR and PACKET_TX_RING, whose
> MTU checks are skipped when a virtio header is present.

[Severity: Low]
Is this description narrower than the real exposure? It reads as though
PACKET_TX_RING is required. The plain sendmsg path through packet_snd()
seems to get to the same place:

net/packet/af_packet.c:packet_snd() {
    ...
	if (!vnet_hdr.gso_type &&
	    (len > dev->mtu + reserve + VLAN_HLEN + extra_len))
		goto out_unlock;
    ...
}

After that, __virtio_net_hdr_to_skb() only marks the skb as GSO when the
payload is larger than gso_size:

	/* Too small packets are not really GSO ones. */
	if (skb->len - nh_off > gso_size) {

Take a 4000-byte frame sent with gso_type=TCPV4 and gso_size=65000. It
would skip the MTU check and reach au1000_tx() as an ordinary non-GSO skb.

Real GSO skbs also get through, because gso_size is never checked against
dev->mtu. au1000 has no TSO, so validate_xmit_skb() segments them in
software into frames that can be larger than 2048 bytes.

The new check in au1000_tx() catches all of these paths, so the code
looks right. Could the commit message also mention the packet_snd() and
GSO routes?

> diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
> index d60430a3795ed..d8855ccf87aa1 100644
> --- a/drivers/net/ethernet/amd/au1000_eth.c
> +++ b/drivers/net/ethernet/amd/au1000_eth.c
> @@ -1008,6 +1008,12 @@ static netdev_tx_t au1000_tx(struct sk_buff *skb, struct net_device *dev)
>  	int i;
>  	unsigned long flags;
>  
> +	if (unlikely(skb->len > MAX_BUF_SIZE)) {
> +		dev->stats.tx_dropped++;
> +		dev_kfree_skb_any(skb);
> +		return NETDEV_TX_OK;
> +	}

[Severity: High]
This is a pre-existing issue that this patch did not introduce. Do other
drivers in drivers/net/ethernet/amd/ need the same check?

Several lance_start_xmit() implementations copy skb->len bytes into
fixed-size TX slots with no upper bound. Their slots are smaller than
au1000's 2048-byte MAX_BUF_SIZE, so a frame one byte over the limit
already overruns the slot:

7990.c:lance_start_xmit()
    skb_copy_from_linear_data(skb, (void *)&ib->tx_buf[entry][0], skblen);
    (skblen = skb->len, tx_buf slots are 1544 bytes)

a2065.c:lance_start_xmit()
    skb_copy_from_linear_data(skb, (void *)&ib->tx_buf[entry][0], skblen);
    (skblen = max(skb->len, ETH_ZLEN), tx_buf slots are 1544 bytes)

sunlance.c:lance_start_xmit()
    PIO path: lance_piocopy_from_skb()
    DMA path: skb_copy_from_linear_data(skb, &ib->tx_buf [entry][0], skblen);
    (TX_BUFF_SIZE is 1544)

sun3lance.c:lance_start_xmit()
    skb_copy_from_linear_data(skb, PKTBUF_ADDR(head), skb->len);
    (PKT_BUF_SZ is 1544)

atarilance.c:lance_start_xmit()
    lp->memcpy_f( PKTBUF_ADDR(head), (void *)skb->data, skb->len );
    (PKT_BUF_SZ is 1544)

declance.c:lance_start_xmit()
    cp_to_buf(lp->type, lp->tx_buf_ptr_cpu[entry], skb->data, len);
    (len = skb->len, TX buffers are 1536 bytes)

Using the AF_PACKET route from the commit message, can an oversized frame
in these drivers overwrite the next TX slot and then the RX buffers?

For frames near 64KB, the copy also looks like it would run past the end
of the lance_init_block or shared memory area.

Triggering this needs CAP_NET_RAW in the device's netns. The hardware is
legacy: Amiga, Sun, Atari, DEC and HP300/MVME.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112045301.3669532-1-f.fainelli%40gmail.com
Re: [PATCH net v2 04/12] net: au1000: report MDIO transaction timeouts
#18055
Author: Florian Fainelli
Date: Tue, 17 Nov 2026 19:09
70 lines
13817 bytes
On 11/16/26 05:50, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found more severe
> issue(s) in other patches of this series. This mail is only an FYI, in case
> you want to address the nit picks below when you respin.
> 
> Low priority / nit picks for your consideration:
> 
> - [Low] The patch adds a second timeout exit to au1000_mdio_write()
>    (drivers/net/ethernet/amd/au1000_eth.c), and both exits log the same…
> 
> --
> 
> net: au1000: report MDIO transaction timeouts
> 
> This commit makes au1000_mdio_write() return -ETIMEDOUT instead of
> reporting success when the MII controller stays busy. It also adds a
> readl_poll_timeout() check after the write so that a failed final
> transaction is reported to phylib. The read path now returns -ETIMEDOUT
> instead of -1.
> 
>> diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
>> index 7063f9e5bc7c0..6b2e216a83618 100644
>> --- a/drivers/net/ethernet/amd/au1000_eth.c
>> +++ b/drivers/net/ethernet/amd/au1000_eth.c
> 
> [ ... ]
> 
>> @@ -292,26 +293,27 @@ static int au1000_mdio_read(struct net_device *dev, int phy_addr, int reg)
> 
> [ ... ]
> 
>>   	while (readl(mii_control_reg) & MAC_MII_BUSY) {
>>   		mdelay(1);
>>   		if (--timedout == 0) {
>>   			netdev_err(dev, "mdio_write busy timeout!!\n");
>> -			return;
>> +			return -ETIMEDOUT;
>>   		}
>>   	}
>>   
>> @@ -320,6 +322,13 @@ static void au1000_mdio_write(struct net_device *dev, int phy_addr,
>>   
>>   	writel(value, mii_data_reg);
>>   	writel(mii_control, mii_control_reg);
>> +
>> +	ret = readl_poll_timeout(mii_control_reg, mii_control,
>> +				 !(mii_control & MAC_MII_BUSY), 20, 20000);
>> +	if (ret)
>> +		netdev_err(dev, "mdio_write busy timeout!!\n");
> 
> [Severity: Low]
> This isn't a bug, but could this message use different wording from the
> one in the busy wait loop above?
> 
> Both timeout paths in au1000_mdio_write() now print "mdio_write busy
> timeout!!". The first one fires before anything is written to the
> registers. The new one fires after writel() has already started the
> transaction, so the PHY register may or may not have been changed. From
> dmesg there is no way to tell which of the two happened.
> 
> au1000_mdio_read() already uses two separate messages ("read_MII busy
> timeout!!" and "mdio_read busy timeout!!"). Something like "mdio_write
> completion timeout" here would separate the two write cases the same way.

Sure, that can be improved to be clearer.

pw-bot: cr
-- 
Florian
Re: [PATCH net v2 07/12] net: au1000: fix buffer descriptor free list insertion
#18057
Author: Florian Fainelli
Date: Tue, 17 Nov 2026 19:13
73 lines
14076 bytes
On 11/16/26 05:50, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found more severe
> issue(s) in other patches of this series. This mail is only an FYI, in case
> you want to address the nit picks below when you respin.
> 
> Low priority / nit picks for your consideration:
> 
> - [Low] The commit message for "net: au1000: fix buffer descriptor free
>    list insertion" says the old au1000_ReleaseDB() "loses free…
> 
> --
> 
> net: au1000: fix buffer descriptor free list insertion
> 
> This patch changes au1000_ReleaseDB() so the returned descriptor's pnext
> points to the old free list head before it becomes the new head. Before
> this, the old head's pnext was set to the returned descriptor. The new
> code matches au1000_GetFreeDB() and how the list is set up in probe.
> 
>> ReleaseDB links the old head to the returned descriptor and makes the
>> returned descriptor the new head without updating its stale next
>> pointer. This loses free descriptors and can create cycles. Link the
>> returned descriptor to the old head instead, matching GetFreeDB and the
>> list initialization.
>>
>> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> 
> [Severity: Low]
> The code change looks correct. Should the commit message say that the old
> behaviour had no runtime effect, though?
> 
> au1000_ReleaseDB() is only called on teardown paths: the err_out unwind
> in au1000_probe() and au1000_remove(). In both cases the descriptor
> buffers and aup are freed right afterwards:
> 
> drivers/net/ethernet/amd/au1000_eth.c:au1000_remove() {
>      ...
> 	for (i = 0; i < NUM_RX_DMA; i++)
> 		if (aup->rx_db_inuse[i])
> 			au1000_ReleaseDB(aup, aup->rx_db_inuse[i]);
> 
> 	for (i = 0; i < NUM_TX_DMA; i++)
> 		if (aup->tx_db_inuse[i])
> 			au1000_ReleaseDB(aup, aup->tx_db_inuse[i]);
> 
> 	dma_free_coherent(&pdev->dev, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS),
> 			  aup->vaddr, aup->dma_addr);
>      ...
> 	free_netdev(dev);
> }
> 
> The err_out path in au1000_probe() also falls through to
> dma_free_coherent() and free_netdev().
> 
> au1000_GetFreeDB() is only called from au1000_probe(), before any
> au1000_ReleaseDB() call, and no RX or TX path walks aup->pDBfree. Also,
> NUM_RX_BUFFS equals NUM_RX_DMA and NUM_TX_BUFFS equals NUM_TX_DMA, so
> the free list is already empty after a successful probe.
> 
> So the lost entries or cycles only ever exist in a list that is about to
> be freed and is never read again. With the Fixes: tag, stable tooling
> could pick this up as a user-visible fix.
> 
> Could the message say the bug is latent with no functional impact, and
> either drop the Fixes: tag or explain why it is needed?
> 

Yes I dropped it from the fixes since it has no functional impact.

pw-bot: not applicable
-- 
Florian
Re: [PATCH net v2 10/12] net: phy: smsc: wait for LAN83C183 power-down recovery
#18058
Author: Florian Fainelli
Date: Tue, 17 Nov 2026 19:15
145 lines
16427 bytes
On 11/16/26 05:50, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
> 
> Critical: 0 · High: 0 · Medium: 1 · Low: 0 (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).
> 
> - [Medium] In this commit, the new 500 ms wait in lan83c183_resume()
>    (drivers/net/phy/smsc.c) runs only after the Au1000 MAC has already…
> 
> Pre-existing issues:
> - [Low] After this patch, the SMSC_PHY Kconfig help text
>    (drivers/net/phy/Kconfig:424) reads "Currently supports the LAN83C183,…
> 
> --
> 
> net: phy: smsc: wait for LAN83C183 power-down recovery
> 
> This patch adds a LAN83C183 entry to the SMSC PHY driver. Its resume
> callback clears BMCR_PDOWN and sleeps for 500 ms, but only if the bit
> was actually set. The aim is to let the MII clocks recover before the
> Au1000 MAC starts when the MTX-1 interface is reopened.
> 
> Link: https://pdf.dzsc.com/LAN/LAN83C183.pdf#page=44
> 
>> diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
>> index 30e9d22c8d1a3..10466b2574eb4 100644
>> --- a/drivers/net/phy/Kconfig
>> +++ b/drivers/net/phy/Kconfig
>> @@ -421,7 +421,7 @@ config SMSC_PHY
>>   	tristate "SMSC PHYs"
>>   	select CRC16
>>   	help
>> -	  Currently supports the LAN83C185, LAN8187 and LAN8700 PHYs
>> +	  Currently supports the LAN83C183, LAN83C185, LAN8187 and LAN8700 PHYs
> 
> [Severity: Low]
> This isn't a bug introduced by this patch, but the help text still
> names only some of the PHYs that smsc_tbl[] in drivers/net/phy/smsc.c
> binds. It leaves out the LAN911x internal PHY, the LAN8710/LAN8720,
> the LAN8740 and the LAN8741/LAN8742.
> 
> Could the list be completed while this line is being changed anyway?
> 
>> diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
>> index 48487149c2252..c3b51afd4b1e5 100644
>> --- a/drivers/net/phy/smsc.c
>> +++ b/drivers/net/phy/smsc.c
> 
> [ ... ]
> 
>> @@ -684,8 +685,32 @@ int smsc_phy_probe(struct phy_device *phydev)
>>   }
>>   EXPORT_SYMBOL_GPL(smsc_phy_probe);
>>   
>> +static int lan83c183_resume(struct phy_device *phydev)
>> +{
>> +	int ret;
>> +
>> +	ret = phy_modify_changed(phydev, MII_BMCR, BMCR_PDOWN, 0);
>> +	if (ret < 0)
>> +		return ret;
>> +
>> +	/* The PHY needs up to 500 ms to restore operation after power-down. */
>> +	if (ret)
>> +		msleep(500);
> 
> [Severity: Medium]
> The commit message says:
> 
>    Starting the Au1000 MAC before the MII clocks recover can hang the
>    MTX-1 when reopening its interface.
> 
> Does this patch alone prevent that ordering? au1000_open() starts the
> MAC before it calls phy_start():
> 
> drivers/net/ethernet/amd/au1000_eth.c:au1000_open() {
>      ...
> 	retval = au1000_init(dev);
>      ...
> 	if (dev->phydev)
> 		phy_start(dev->phydev);
> 
> 	netif_start_queue(dev);
>      ...
> }
> 
> and au1000_init() already sets the RX/TX enable bits:
> 
> drivers/net/ethernet/amd/au1000_eth.c:au1000_init() {
>      ...
> 	control = MAC_RX_ENABLE | MAC_TX_ENABLE;
>      ...
> 	writel(control, &aup->mac->control);
>      ...
> }
> 
> Suppose a close has run au1000_close()->phy_stop()->phy_suspend()->
> genphy_suspend(), which sets BMCR_PDOWN. The reopen then appears to go
> like this:
> 
> au1000_open()
>    au1000_init()          <- MAC RX/TX enabled, PHY still powered down
>    phy_start()
>      __phy_resume()
>        lan83c183_resume()
>          clear BMCR_PDOWN
>          msleep(500)
> 
> If so, the 500 ms wait only delays the PHY state machine and
> netif_start_queue(). The MAC has already started by then.
> 
> The close path has the same ordering in reverse. au1000_close() calls
> phy_stop() before au1000_reset_mac_unlocked(), so the PHY powers down
> while the MAC is still running.
> 
> The next patch in the series, "net: au1000: keep the MAC stopped until
> the PHY link is ready", seems to fix this. It calls phy_resume() before
> au1000_init() and enables RX/TX only after au1000_adjust_link() has
> seen link up. It also calls au1000_hard_stop() on link down. In the
> PHY_HALTED path, phy_link_down() runs before phy_suspend(), so the MAC
> stops before the PHY powers down.
> 
> Can the MTX-1 reopen hang still happen when bisecting to this commit
> alone? If so, could the commit message mention that it depends on the
> au1000 change, or could the two patches be reordered?

Agreed. The PHY patch alone does not fix the Au1000 startup/shutdown 
ordering, so the reopen hang remains at that intermediate commit. I have 
clarified that dependency in the commit message. The PHY patch stays 
first so its recovery delay is available when the following MAC 
sequencing fix is applied.

I will leave the pre-existing Kconfig help-text cleanup for a separate 
change.

pw-bot: cr
-- 
Florian
Re: [PATCH net v2 12/12] net: au1000: reject frames larger than the TX bounce buffer
#18060
Author: Florian Fainelli
Date: Tue, 17 Nov 2026 19:19
126 lines
16198 bytes
On 11/16/26 05:50, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found more severe
> issue(s) in other patches of this series. This mail is only an FYI, in case
> you want to address the nit picks below when you respin.
> 
> Low priority / nit picks for your consideration:
> 
> - [Low] The commit message understates how the overflow can be reached.
> 
> Pre-existing issues:
> - [High] Several other drivers in drivers/net/ethernet/amd/ have the same
>    unchecked copy of skb->len bytes into a fixed-size TX buffer.
> 
> --
> 
> net: au1000: reject frames larger than the TX bounce buffer
> 
> This patch adds a length check to au1000_tx(). Frames larger than
> MAX_BUF_SIZE are now dropped and counted in tx_dropped instead of being
> copied past the end of the TX bounce buffer.
> 
>> au1000_tx() copies skb->len bytes into a MAX_BUF_SIZE coherent buffer
>> without checking the length. Oversized non-GSO packets can reach this
>> path through AF_PACKET with PACKET_VNET_HDR and PACKET_TX_RING, whose
>> MTU checks are skipped when a virtio header is present.
> 
> [Severity: Low]
> Is this description narrower than the real exposure? It reads as though
> PACKET_TX_RING is required. The plain sendmsg path through packet_snd()
> seems to get to the same place:
> 
> net/packet/af_packet.c:packet_snd() {
>      ...
> 	if (!vnet_hdr.gso_type &&
> 	    (len > dev->mtu + reserve + VLAN_HLEN + extra_len))
> 		goto out_unlock;
>      ...
> }
> 
> After that, __virtio_net_hdr_to_skb() only marks the skb as GSO when the
> payload is larger than gso_size:
> 
> 	/* Too small packets are not really GSO ones. */
> 	if (skb->len - nh_off > gso_size) {
> 
> Take a 4000-byte frame sent with gso_type=TCPV4 and gso_size=65000. It
> would skip the MTU check and reach au1000_tx() as an ordinary non-GSO skb.
> 
> Real GSO skbs also get through, because gso_size is never checked against
> dev->mtu. au1000 has no TSO, so validate_xmit_skb() segments them in
> software into frames that can be larger than 2048 bytes.
> 
> The new check in au1000_tx() catches all of these paths, so the code
> looks right. Could the commit message also mention the packet_snd() and
> GSO routes?
> 
>> diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
>> index d60430a3795ed..d8855ccf87aa1 100644
>> --- a/drivers/net/ethernet/amd/au1000_eth.c
>> +++ b/drivers/net/ethernet/amd/au1000_eth.c
>> @@ -1008,6 +1008,12 @@ static netdev_tx_t au1000_tx(struct sk_buff *skb, struct net_device *dev)
>>   	int i;
>>   	unsigned long flags;
>>   
>> +	if (unlikely(skb->len > MAX_BUF_SIZE)) {
>> +		dev->stats.tx_dropped++;
>> +		dev_kfree_skb_any(skb);
>> +		return NETDEV_TX_OK;
>> +	}
> 
> [Severity: High]
> This is a pre-existing issue that this patch did not introduce. Do other
> drivers in drivers/net/ethernet/amd/ need the same check?
> 
> Several lance_start_xmit() implementations copy skb->len bytes into
> fixed-size TX slots with no upper bound. Their slots are smaller than
> au1000's 2048-byte MAX_BUF_SIZE, so a frame one byte over the limit
> already overruns the slot:
> 
> 7990.c:lance_start_xmit()
>      skb_copy_from_linear_data(skb, (void *)&ib->tx_buf[entry][0], skblen);
>      (skblen = skb->len, tx_buf slots are 1544 bytes)
> 
> a2065.c:lance_start_xmit()
>      skb_copy_from_linear_data(skb, (void *)&ib->tx_buf[entry][0], skblen);
>      (skblen = max(skb->len, ETH_ZLEN), tx_buf slots are 1544 bytes)
> 
> sunlance.c:lance_start_xmit()
>      PIO path: lance_piocopy_from_skb()
>      DMA path: skb_copy_from_linear_data(skb, &ib->tx_buf [entry][0], skblen);
>      (TX_BUFF_SIZE is 1544)
> 
> sun3lance.c:lance_start_xmit()
>      skb_copy_from_linear_data(skb, PKTBUF_ADDR(head), skb->len);
>      (PKT_BUF_SZ is 1544)
> 
> atarilance.c:lance_start_xmit()
>      lp->memcpy_f( PKTBUF_ADDR(head), (void *)skb->data, skb->len );
>      (PKT_BUF_SZ is 1544)
> 
> declance.c:lance_start_xmit()
>      cp_to_buf(lp->type, lp->tx_buf_ptr_cpu[entry], skb->data, len);
>      (len = skb->len, TX buffers are 1536 bytes)
> 
> Using the AF_PACKET route from the commit message, can an oversized frame
> in these drivers overwrite the next TX slot and then the RX buffers?
> 
> For frames near 64KB, the copy also looks like it would run past the end
> of the lance_init_block or shared memory area.
> 
> Triggering this needs CAP_NET_RAW in the device's netns. The hardware is
> legacy: Amiga, Sun, Atari, DEC and HP300/MVME.
> 

Agreed. I have expanded the commit message to cover both packet_snd() 
and TX_RING, including packets left non-GSO after virtio-header 
conversion and oversized segments produced by software GSO. The existing 
length check covers these cases.

The other AMD drivers require separate validation and fixes; they are 
outside this au1000 series.

pw-bot: cr
-- 
Florian
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads