net: au1000: Bug fixes
Subsystems (3)
v4 cover net: au1000: Bug fixes
This series fixes RX descriptor recycling, receive filtering, MDIO error reporting, TX ring synchronization, MAC/PHY lifecycle ordering, and TX bounce-buffer bounds in the Au1xxx Ethernet driver. It also adds the LAN83C183 PHY resume delay needed for MII clock recovery on the MTX-1.
Changes in v4:
- Correct the PHY-disconnect commit message: the attachment path uses polling, so describe device/module reference leaks and the stale netdev attachment instead of surviving PHY interrupts. Document the existing repeated-reset hazard after register_netdev() failure.
- Narrow the TX critical sections to descriptor reservation and final publication. Copy and pad the packet outside the IRQ-disabled lock. Clear TX_T_DONE and advance tx_tail before dropping the lock when submission reclaims a completed descriptor, preventing double reclaim by a completion interrupt during the unlocked copy.
- Document that the SMSC PHY driver must bind before MAC attachment. The tested early-boot configuration uses CONFIG_SMSC_PHY=y; loading smsc.ko after genphy has attached does not replace that binding.
- Add the LSI/SEEQ OUI/model comment and document that the LAN83C183 PHY ID is shared with the L80227, which receives the same conservative resume delay. L80227 hardware remains untested.
- Add MAC-managed system-sleep callbacks. Explicitly stop and quiesce MAC RX/TX before stopping the PHY, including PHY states without a link-down callback. Restore the PHY before MAC initialization on resume. Handle inactive interfaces and keep failed resumes detached with the MAC reset; prevent IRQ-disable nesting on a subsequent retry.
- Move the link-down quiesce wait outside the device lock and use a sleepable wait with local interrupts restored. Retain existing atomic waits in the duplex-change and reset paths.
- Extend validation with TX/PM sanitizer harnesses, simultaneous TX/RX traffic, RX-stop descriptor observations, and device suspend/resume tests on MTX-1.
Changes in v3:
- Drop the no-platform-data MAC-address patch: in-tree platform devices always supply platform data, so this is defensive hardening rather than a fix for an in-tree configuration.
- Drop the buffer descriptor free-list insertion patch: the affected list is only rebuilt during teardown and is never consumed again. The series now contains 10 patches instead of 12.
- Distinguish MDIO write-completion timeouts from pre-write busy timeouts in the diagnostic message.
- Clarify that the LAN83C183 recovery-delay patch and the following au1000 MAC/PHY sequencing patch are both required to fix MTX-1 reopen. Keep the PHY patch first so its delay is available to the MAC fix.
- Remove the unreachable initialization-error branch and PHY rollback from au1000_open(). Correct the commit message to distinguish the new synchronous PHY resume from the existing initialization-before- phy_start() ordering, and reconcile the reset comments.
- Expand the TX bounds-check commit message to cover plain AF_PACKET sendmsg(), PACKET_TX_RING, and oversized software-GSO segments.
- Rebuild the kernel and root filesystem and repeat MTX-1 regression testing after the review changes.
Changes in v2:
- Rebase onto net.
- Reset the MAC after PHY/MDIO teardown, and avoid MAC control accesses when its clock is already disabled.
- Use sleepable polling for MDIO write completion.
- Advance tx_tail when submission reclaims a completed TX descriptor, and consume transmitted skbs outside the lock with an IRQ-safe helper.
- Restore receive filtering before enabling RX, with the address-list and device locks held to keep the programmed filter consistent.
- Resume the PHY synchronously before MAC initialization, clear cached link state on open, and use acknowledged link/duplex state under the device lock. Place the LAN83C183 recovery-delay patch before this fix.
- Add a TX length check to prevent overflowing the DMA bounce buffer.
Testing:
The current series was rebuilt with Buildroot and tested on a Meshcube MTX-1, using the Alchemy PROM Ethernet-address lifetime fix as a separate boot prerequisite. That prerequisite is not included in this series. CONFIG_MIPS_AU1X00_ENET=y and CONFIG_SMSC_PHY=y were used, and boot logs confirmed attachment to the SMSC LAN83C183 driver.
The final run passed all 11 boot-smoke checks, including 15 down/up cycles across normal, promiscuous and all-multicast modes, opened/closed and never-opened removal/rebind, and connectivity recovery. Five additional device suspend/resume cycles passed: three with the interface up, one down, and one never opened after rebind. These used pm_test=devices with freeze and CONFIG_PM_DEBUG=y. The final ping received all 10 replies, and the kernel-log check reported no findings. Actual platform suspend-to-RAM was not tested.
An earlier run with the revised TX locking completed 20 seconds of bidirectional iperf3 traffic at approximately 14.4 Mbit/s TX and 40.9 Mbit/s RX. RX missed-frame errors increased by 10, while TX errors did not increase. There was no before/after overrun or IRQ-latency measurement; this test does not establish elimination of RX overruns.
The extracted TX functions passed 432 ring, copy, padding, IRQ-state and completion-interleaving cases under ASan/UBSan, plus busy and oversized-packet paths. Tests rejected the original locked copy and a variant omitting the early TX_T_DONE clear. A separate PM harness checked up/down and PHY-less cases, missing link-down callbacks, error cleanup and retry, and the unlocked link-down wait.
A logging-only kernel captured 44 RX descriptor snapshots across 11 stops during duplex changes under incoming traffic. Nine descriptors had advanced addresses with EN set and DN clear before stopping; all nine had DN set after the existing 10 ms wait. The reported state with an advanced address and DN clear after stopping was not reproduced. This finite MTX-1 test does not establish behavior for every silicon revision or link-loss timing; no RX reload change was made for that path.
Full AF_PACKET overflow triggers and hardware fault injection were not exercised.
Sashiko AI review identified issues addressed in the revisions. OpenAI Codex assisted source and datasheet analysis, code and changelog revisions, patch consolidation, test harnesses and regression testing.
Florian Fainelli (10):
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: 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 | 248 +++++++++++++++++++++----- drivers/net/phy/Kconfig | 2 +- drivers/net/phy/smsc.c | 27 +++ 3 files changed, 233 insertions(+), 44 deletions(-)
base-commit: 145480b28ca82e9fae789427cc4569e596515a32
Signature · 1 line
2.53.0
PATCH v4 1/10 net: au1000: recycle RX descriptors on allocation failure
An skb allocation failure retries the same completed descriptor forever in hard IRQ context. Return the buffer to DMA and advance the ring even when the packet must be dropped.
--- drivers/net/ethernet/amd/au1000_eth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/amd/au1000_eth.c +2 -1
@@ -788,7 +788,7 @@ static int au1000_rx(struct net_device *dev) skb =netdev_alloc_skb (dev, frmlen +2 );if (!skb) { dev->stats.rx_dropped++; -continue ; + goto next; }skb_reserve (skb,2 );/* 16 byte IP header align */ skb_copy_to_linear_data(skb,
@@ -820,6 +820,7 @@ static int au1000_rx(struct net_device *dev)pr_cont ("\n" ); } } +next: prxd->buff_stat =lower_32_bits (pDB->dma_addr) |RX_DMA_ENABLE ; aup->rx_head = (aup->rx_head +1 ) & (NUM_RX_DMA -1 );wmb ();/* drain writebuffer */
Signature · 1 line
2.53.0
PATCH v4 2/10 net: au1000: clear all-multicast mode when restoring hash filtering
In reply to Florian FainelliMAC_PASS_ALL_MULTI remains set after IFF_ALLMULTI is cleared or the multicast list shrinks below the filter limit. Clear it when programming the selective multicast hash so unwanted multicast traffic is filtered again.
--- drivers/net/ethernet/amd/au1000_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/amd/au1000_eth.c +1 -1
@@ -1042,7 +1042,7 @@ static void au1000_multicast_list(struct net_device *dev) (long *)mc_filter);writel (mc_filter[1 ], &aup->mac->multi_hash_high);writel (mc_filter[0 ], &aup->mac->multi_hash_low); - reg &= ~MAC_PROMISCUOUS ; + reg &= ~(MAC_PROMISCUOUS |MAC_PASS_ALL_MULTI ); reg |=MAC_HASH_MODE ; }writel (reg, &aup->mac->control);
Signature · 1 line
2.53.0
PATCH v4 3/10 net: au1000: disconnect the PHY before freeing the MDIO bus
In reply to Florian FainelliBalance phy_connect() on probe failure and removal. Otherwise device and module references taken during PHY attachment leak, and the PHY retains an attached_dev pointer to the freed netdev. The attachment path uses PHY polling, so there is no PHY interrupt to release. Disconnect before unregistering the bus while its MDIO callbacks and MAC registers remain usable.
PHY teardown can re-enable the MAC for MDIO even if the interface was never opened. Reset the MAC after PHY and MDIO bus teardown, before releasing descriptors and register mappings. Skip MAC control accesses when mac_enabled is clear, since stopping an already clock-gated MAC hangs MTX-1. This guard also covers the existing probe failure path:au1000_probe() resets and gates the MAC before register_netdev(), and registration failure reaches another reset in err_out. If no intervening MDIO access has re-enabled the MAC, that second reset must not touch its control register. Always clear the DMA descriptor control bits and TX state.
--- drivers/net/ethernet/amd/au1000_eth.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)
drivers/net/ethernet/amd/au1000_eth.c +17 -9
@@ -584,14 +584,17 @@ static void au1000_reset_mac_unlocked(struct net_device *dev)struct au1000_private *const aup =netdev_priv (dev);int i; -au1000_hard_stop (dev); +if (aup->mac_enabled) { +au1000_hard_stop (dev); -writel (MAC_EN_CLOCK_ENABLE , aup->enable); -wmb ();/* drain writebuffer */ -mdelay (2 ); -writel (0 , aup->enable); -wmb ();/* drain writebuffer */ -mdelay (2 ); +writel (MAC_EN_CLOCK_ENABLE , aup->enable); +wmb ();/* drain writebuffer */ +mdelay (2 ); +writel (0 , aup->enable); +wmb ();/* drain writebuffer */ +mdelay (2 ); + aup->mac_enabled =0 ; + } aup->tx_full =0 ;for (i =0 ; i <NUM_RX_DMA ; i++) {
@@ -603,8 +606,6 @@ static void au1000_reset_mac_unlocked(struct net_device *dev) aup->tx_dma_ring[i]->buff_stat &= ~0xf ; } - aup->mac_enabled =0 ; - }static void au1000_reset_mac (struct net_device *dev)
@@ -1287,6 +1288,8 @@ static int au1000_probe(struct platform_device *pdev)return 0 ; err_out: +if (dev->phydev) +phy_disconnect (dev->phydev);if (aup->mii_bus)mdiobus_unregister (aup->mii_bus);
@@ -1334,9 +1337,14 @@ static void au1000_remove(struct platform_device *pdev)struct resource *base, *macen;unregister_netdev (dev); +if (dev->phydev) +phy_disconnect (dev->phydev);mdiobus_unregister (aup->mii_bus);mdiobus_free (aup->mii_bus); +/* PHY teardown may have re-enabled the MAC for MDIO accesses. */ +au1000_reset_mac (dev); +for (i =0 ; i <NUM_RX_DMA ; i++)if (aup->rx_db_inuse[i])au1000_ReleaseDB (aup, aup->rx_db_inuse[i]);
Signature · 1 line
2.53.0
PATCH v4 4/10 net: au1000: report MDIO transaction timeouts
In reply to Florian FainelliThe 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.
--- drivers/net/ethernet/amd/au1000_eth.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
drivers/net/ethernet/amd/au1000_eth.c +15 -7
@@ -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 completion 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)
Signature · 1 line
2.53.0
PATCH v4 5/10 net: au1000: serialize TX completion with packet submission
In reply to Florian FainelliTX completion runs in hard IRQ context while ndo_start_xmit updates the same descriptors and ring state without locking. An interrupt between netif_stop_queue() and setting tx_full can miss the wakeup and leave the queue stopped until the watchdog runs. Use the existing IRQ-safe device lock in both paths to serialize reclamation and queue state changes. Keep the packet copy and padding outside this lock so uncached DMA buffer writes do not extend the IRQ-disabled critical section.
When submission reclaims a completed descriptor at tx_head, advance tx_tail and clear TX_T_DONE before dropping the lock so the interrupt handler cannot reclaim it twice. The TX queue lock reserves the idle descriptor while its buffer is filled; completion stops at a descriptor without TX_T_DONE and never accesses its payload. Reacquire the device lock to publish the length, DMA ownership and tx_head together. Consume the copied skb after releasing the lock with dev_consume_skb_any(), which also handles netpoll entry with hardware interrupts disabled.
--- drivers/net/ethernet/amd/au1000_eth.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
drivers/net/ethernet/amd/au1000_eth.c +18 -4
@@ -872,7 +872,9 @@ static void au1000_tx_ack(struct net_device *dev) {struct au1000_private *aup =netdev_priv (dev);struct tx_dma *ptxd; +unsigned long flags; +spin_lock_irqsave (&aup->lock, flags); ptxd = aup->tx_dma_ring[aup->tx_tail];while (ptxd->buff_stat &TX_T_DONE ) {
@@ -889,6 +891,8 @@ static void au1000_tx_ack(struct net_device *dev)netif_wake_queue (dev); } } + +spin_unlock_irqrestore (&aup->lock, flags); }/*
@@ -972,21 +976,27 @@ static netdev_tx_t au1000_tx(struct sk_buff *skb, struct net_device *dev)u32 buff_stat;struct db_dest *pDB;int i; +unsigned long flags;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); +spin_lock_irqsave (&aup->lock, flags); ptxd = aup->tx_dma_ring[aup->tx_head]; buff_stat = ptxd->buff_stat;if (buff_stat &TX_DMA_ENABLE ) {/* We've wrapped around and the transmitter is still busy */ netif_stop_queue (dev); aup->tx_full =1 ; +spin_unlock_irqrestore (&aup->lock, flags);return NETDEV_TX_BUSY ; }else if (buff_stat &TX_T_DONE ) {au1000_update_tx_stats (dev, ptxd->status); + ptxd->buff_stat = buff_stat & ~TX_T_DONE ; ptxd->len =0 ; +wmb ();/* drain writebuffer */ + aup->tx_tail = (aup->tx_tail +1 ) & (NUM_TX_DMA -1 ); }if (aup->tx_full) {
@@ -995,22 +1005,26 @@ static netdev_tx_t au1000_tx(struct sk_buff *skb, struct net_device *dev) } pDB = aup->tx_db_inuse[aup->tx_head]; +/* The TX queue lock reserves this idle descriptor until submission. */ +spin_unlock_irqrestore (&aup->lock, flags); +skb_copy_from_linear_data (skb, (void *)pDB->vaddr, skb->len);if (skb->len <ETH_ZLEN ) {for (i = skb->len; i <ETH_ZLEN ; i++) ((char *)pDB->vaddr)[i] =0 ; + } - ptxd->len =ETH_ZLEN ; - }else - ptxd->len = skb->len; +spin_lock_irqsave (&aup->lock, flags); + ptxd->len = max_t(unsigned int, skb->len, ETH_ZLEN); ps->tx_packets++; ps->tx_bytes += ptxd->len; ptxd->buff_stat =lower_32_bits (pDB->dma_addr) |TX_DMA_ENABLE ;wmb ();/* drain writebuffer */ -dev_kfree_skb (skb); aup->tx_head = (aup->tx_head +1 ) & (NUM_TX_DMA -1 ); +spin_unlock_irqrestore (&aup->lock, flags); +dev_consume_skb_any (skb);return NETDEV_TX_OK ; }
Signature · 1 line
2.53.0
PATCH v4 6/10 net: au1000: restore receive filtering before enabling RX
In reply to Florian FainelliMAC initialization overwrites the receive mode, dropping promiscuous and multicast settings after a watchdog reset without notifying the network stack. Restore the requested filtering before the control write that enables RX, avoiding a window with the wrong filter.
Factor receive-mode programming into a helper shared by initialization and the receive-mode callback. Hold the address-list lock before the device lock through initialization so the filter snapshot stays current. Protect callback control-register updates with the device lock as well.
--- drivers/net/ethernet/amd/au1000_eth.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/net/ethernet/amd/au1000_eth.c +20 -3
@@ -685,6 +685,8 @@ static const struct ethtool_ops au1000_ethtool_ops = { .set_link_ksettings = phy_ethtool_set_link_ksettings, }; +static u32 au1000_rx_mode (struct net_device *dev,u32 reg); +/* * Initialize the interface. *
@@ -706,6 +708,7 @@ static int au1000_init(struct net_device *dev)/* bring the device out of reset */ au1000_enable_mac (dev,1 ); +netif_addr_lock_bh (dev);spin_lock_irqsave (&aup->lock, flags);writel (0 , &aup->mac->control);
@@ -738,11 +741,14 @@ static int au1000_init(struct net_device *dev) control |=MAC_FULL_DUPLEX ; } + control =au1000_rx_mode (dev, control); +writel (control, &aup->mac->control);writel (0x8100 , &aup->mac->vlan1_tag);/* activate vlan support */ wmb ();/* drain writebuffer */ spin_unlock_irqrestore (&aup->lock, flags); +netif_addr_unlock_bh (dev);return 0 ; }
@@ -1041,13 +1047,12 @@ static void au1000_tx_timeout(struct net_device *dev, unsigned int txqueue)netif_wake_queue (dev); } -static void au1000_multicast_list (struct net_device *dev) +/* Caller holds the address-list lock and aup->lock. */ +static u32 au1000_rx_mode (struct net_device *dev,u32 reg) {struct au1000_private *aup =netdev_priv (dev); -u32 reg;netif_dbg (aup, drv, dev,"%s: flags=%x\n" , __func__, dev->flags); - reg =readl (&aup->mac->control);if (dev->flags &IFF_PROMISC ) {/* Set promiscuous. */ reg |=MAC_PROMISCUOUS ; } else if ((dev->flags & IFF_ALLMULTI) ||
@@ -1068,7 +1073,19 @@ static void au1000_multicast_list(struct net_device *dev) reg &= ~(MAC_PROMISCUOUS |MAC_PASS_ALL_MULTI ); reg |=MAC_HASH_MODE ; } +return reg; +} + +static void au1000_multicast_list (struct net_device *dev) +{ +struct au1000_private *aup =netdev_priv (dev); +unsigned long flags; +u32 reg; + +spin_lock_irqsave (&aup->lock, flags); + reg =au1000_rx_mode (dev,readl (&aup->mac->control));writel (reg, &aup->mac->control); +spin_unlock_irqrestore (&aup->lock, flags); }static const struct net_device_ops au1000_netdev_ops = {
Signature · 1 line
2.53.0
PATCH v4 7/10 net: au1000: restore RX buffer addresses when restarting the MAC
In reply to Florian FainelliThe MAC DMA engine updates each receive descriptor's address as it transfers data. Clearing the descriptor control bits during reset does not restore the buffer's starting address.
au1000_init() only set RX_DMA_ENABLE on the address left in the descriptor. After closing and reopening the interface, a receive could therefore start partway through its buffer and overwrite memory beyond the allocation.
Reload each RX descriptor from rx_db_inuse before enabling it, as the receive completion path already does.
--- drivers/net/ethernet/amd/au1000_eth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/amd/au1000_eth.c +2 -1
@@ -724,7 +724,8 @@ static int au1000_init(struct net_device *dev)for (i =0 ; i <NUM_RX_DMA ; i++) - aup->rx_dma_ring[i]->buff_stat |=RX_DMA_ENABLE ; +writel (lower_32_bits (aup->rx_db_inuse[i]->dma_addr) | +RX_DMA_ENABLE , &aup->rx_dma_ring[i]->buff_stat);wmb ();/* drain writebuffer */
Signature · 1 line
2.53.0
PATCH v4 8/10 net: phy: smsc: wait for LAN83C183 power-down recovery
In reply to Florian FainelliThe 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.
This supplies the PHY recovery delay; it does not by itself fix the Au1000 MAC/PHY ordering on reopen. The companion patch, "net: au1000:
keep the MAC stopped until the PHY link is ready", resumes the PHY synchronously before MAC initialization and stops the MAC before PHY suspend. Both changes are needed to address the MTX-1 reopen hang. Keep this PHY change first so the recovery delay is available when the MAC sequencing fix is applied.
The specific PHY driver must be bound before the MAC attaches the PHY. For a built-in au1000 MAC used during early boot, enable CONFIG_SMSC_PHY=y. Module configurations must arrange for smsc.ko to be loaded before PHY attachment. If attachment falls back to genphy, loading smsc.ko later does not replace that binding and the recovery delay will not run. MTX-1 validation used CONFIG_MIPS_AU1X00_ENET=y and CONFIG_SMSC_PHY=y; the boot logs confirmed attachment to the SMSC LAN83C183 driver.
The LAN83C183 and LSI L80227 document the same LSI/SEEQ OUI and model 4, so this ID match also binds the L80227 and applies the same conservative 500 ms delay when clearing power-down. The entry otherwise uses generic PHY helpers and does not program SMSC-specific registers. Hardware validation is limited to the LAN83C183; the L80227 was not tested.
Sashiko AI review identified the dependency, binding prerequisite and shared PHY ID.
--- drivers/net/phy/Kconfig | 2 +- drivers/net/phy/smsc.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-)
drivers/net/phy/Kconfig +1 -1
@@ -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"
drivers/net/phy/smsc.c +27 -0
@@ -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,33 @@ 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[] = { { +/* LSI/SEEQ OUI 00:a0:7d, model 4; shared with L80227. */ + .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 +913,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 },
Signature · 1 line
2.53.0
PATCH v4 9/10 net: au1000: keep the MAC stopped until the PHY link is ready
In reply to Florian Fainelliphy_stop() powers down the PHY when the interface is closed. The driver leaves MAC receive/transmit enabled on link-down and enables them during initialization before the PHY resumes. System sleep can also suspend the PHY without invoking the link-down callback. MTX-1 can hang when the MAC runs while its MII clocks are absent or still recovering.
Stop the MAC on link-down before phylib suspends the PHY. On open, clear the driver's acknowledged link cache and synchronously resume the PHY to restore its MII clocks and honor its recovery delay before MAC initialization. Preserve the existing au1000_init() before phy_start() ordering so the PHY worker cannot access MDIO or enable traffic during setup. Leave RX/TX stopped until a link-up callback configures duplex and enables traffic.
Use the acknowledged link and duplex cache under the device lock during initialization, retaining it for watchdog recovery. Keep the reset-time hard stop for paths without a preceding link-down callback. If PHY resume fails during open, reset the MAC and release the IRQ. Remove the unreachable initialization-error branch, since au1000_init() always returns zero. Reconcile the initialization and probe comments:
initialization forces a reset itself, and PHY resume may already have enabled the MAC for MDIO accesses.
Manage system-sleep PHY power transitions from the MAC driver. For a running interface, detach and drain the TX queue, disable its IRQ, and explicitly stop MAC RX/TX before stopping the PHY and resetting the MAC. This also covers PHY states that do not deliver a link-down callback. Suspend an inactive PHY without starting the interface. On resume, initialize and resume the PHY before MAC initialization, then restore its IRQ and state machine and reattach the interface. Keep an inactive interface stopped and leave a failed resume detached with the MAC reset. Set mac_managed_pm so MDIO bus PM does not independently power down the PHY before the MAC has stopped.
Keep the link-down control-register update under the device lock, but wait for RX/TX quiescence after restoring local interrupts. phylib holds the PHY lock across the callback, so PHY suspend and a subsequent link callback cannot overtake that wait. Retain the existing atomic stop waits for duplex changes and reset paths.
Sashiko AI review identified the system-sleep gap, IRQ-off link-down wait, unreachable rollback and inaccurate wording.
--- drivers/net/ethernet/amd/au1000_eth.c | 141 ++++++++++++++++++++++---- 1 file changed, 124 insertions(+), 17 deletions(-)
drivers/net/ethernet/amd/au1000_eth.c +124 -17
@@ -31,6 +31,7 @@#include <linux/slab.h> #include <linux/interrupt.h> #include <linux/netdevice.h> +#include <linux/rtnetlink.h> #include <linux/etherdevice.h> #include <linux/ethtool.h> #include <linux/mii.h>
@@ -39,6 +40,7 @@#include <linux/crc32.h> #include <linux/phy.h> #include <linux/platform_device.h> +#include <linux/pm.h> #include <linux/cpu.h> #include <linux/io.h> #include <linux/iopoll.h>
@@ -368,7 +370,7 @@ static int au1000_mdiobus_reset(struct mii_bus *bus)return 0 ; } -static void au1000_hard_stop (struct net_device *dev) +static void au1000_disable_rx_tx (struct net_device *dev) {struct au1000_private *aup =netdev_priv (dev);u32 reg;
@@ -379,6 +381,11 @@ static void au1000_hard_stop(struct net_device *dev) reg &= ~(MAC_RX_ENABLE |MAC_TX_ENABLE );writel (reg, &aup->mac->control);wmb ();/* drain writebuffer */ +} + +static void au1000_hard_stop (struct net_device *dev) +{ +au1000_disable_rx_tx (dev);mdelay (10 ); }
@@ -405,6 +412,7 @@ au1000_adjust_link(struct net_device *dev)u32 reg;int status_change =0 ; +bool wait_for_stop = false;BUG_ON (!phydev);
@@ -456,7 +464,9 @@ au1000_adjust_link(struct net_device *dev)/* link state changed */ if (!phydev->link) { -/* link went down */ +/* Stop the MAC before the PHY can remove its clocks. */ +au1000_disable_rx_tx (dev); + wait_for_stop = true; aup->old_speed =0 ; aup->old_duplex =-1 ; }
@@ -467,6 +477,10 @@ au1000_adjust_link(struct net_device *dev)spin_unlock_irqrestore (&aup->lock, flags); +/* phylib holds its PHY lock until this callback returns. */ +if (wait_for_stop) +usleep_range (10000 ,11000 ); +if (status_change) {if (phydev->link) netdev_info(dev, "link up (%d/%s)\n",
@@ -553,6 +567,7 @@ static int au1000_mii_probe(struct net_device *dev) }phy_set_max_speed (phydev,SPEED_100 ); + phydev->mac_managed_pm = true; aup->old_link =0 ; aup->old_speed =0 ;
@@ -688,13 +703,11 @@ static const struct ethtool_ops au1000_ethtool_ops = {static u32 au1000_rx_mode (struct net_device *dev,u32 reg);/* -* Initialize the interface. +* Reset and initialize the interface. * -* When the device powers up, the clocks are disabled and the -* mac is in reset state. When the interface is closed, we -* do the same -- reset the device and disable the clocks to -* conserve power. Thus, whenever au1000_init() is called, -* the device should already be in reset state. +* The PHY must be resumed before initializing the MAC. MDIO accesses +* during PHY resume may have already enabled the MAC clocks and released +* reset; au1000_enable_mac(dev, 1) forces a reset regardless of that state. */ static int au1000_init (struct net_device *dev) {
@@ -729,12 +742,12 @@ static int au1000_init(struct net_device *dev)wmb ();/* drain writebuffer */ - control =MAC_RX_ENABLE |MAC_TX_ENABLE ; + control =0 ;#ifndef CONFIG_CPU_LITTLE_ENDIAN control |=MAC_BIG_ENDIAN ;#endif if (dev->phydev) { -if (dev->phydev->link && (DUPLEX_FULL == dev->phydev->duplex)) +if (aup->old_link && aup->old_duplex ==DUPLEX_FULL ) control |=MAC_FULL_DUPLEX ;else control |=MAC_DISABLE_RX_OWN ;
@@ -744,6 +757,10 @@ static int au1000_init(struct net_device *dev) control =au1000_rx_mode (dev, control); +/* Only use link state acknowledged by au1000_adjust_link(). */ +if (!dev->phydev || aup->old_link) + control |=MAC_RX_ENABLE |MAC_TX_ENABLE ; +writel (control, &aup->mac->control);writel (0x8100 , &aup->mac->vlan1_tag);/* activate vlan support */ wmb ();/* drain writebuffer */
@@ -918,6 +935,7 @@ static irqreturn_t au1000_interrupt(int irq, void *dev_id)static int au1000_open (struct net_device *dev) { +unsigned long flags;int retval;struct au1000_private *aup =netdev_priv (dev);
@@ -930,13 +948,21 @@ static int au1000_open(struct net_device *dev)return retval; } - retval =au1000_init (dev); -if (retval) { -netdev_err (dev,"error in au1000_init\n" ); -free_irq (dev->irq, dev); -return retval; +spin_lock_irqsave (&aup->lock, flags); + aup->old_link =0 ; + aup->old_speed =0 ; + aup->old_duplex =-1 ; +spin_unlock_irqrestore (&aup->lock, flags); + +/* Restore the MII clocks without starting the PHY state machine. */ +if (dev->phydev) { + retval =phy_resume (dev->phydev); +if (retval) + goto err_reset; } +au1000_init (dev); +if (dev->phydev)phy_start (dev->phydev);
@@ -945,6 +971,11 @@ static int au1000_open(struct net_device *dev)netif_dbg (aup, drv, dev,"open: Initialization done.\n" );return 0 ; + +err_reset: +au1000_reset_mac (dev); +free_irq (dev->irq, dev); +return retval; }static int au1000_close (struct net_device *dev)
@@ -972,6 +1003,81 @@ static int au1000_close(struct net_device *dev)return 0 ; } +static int au1000_suspend (struct device *device) +{ +struct net_device *dev =dev_get_drvdata (device); +struct au1000_private *aup =netdev_priv (dev); +unsigned long flags; +int ret =0 ; + +rtnl_lock (); +if (netif_running (dev)) { +if (!netif_device_present (dev)) + goto out; +netif_device_detach (dev); +netif_tx_disable (dev); +disable_irq (dev->irq); +/* Do not depend on phylib delivering a link-down callback. */ +spin_lock_irqsave (&aup->lock, flags); +if (aup->mac_enabled) +au1000_disable_rx_tx (dev); +spin_unlock_irqrestore (&aup->lock, flags); +usleep_range (10000 ,11000 ); +if (dev->phydev) +phy_stop (dev->phydev); + }else if (dev->phydev) { + ret =phy_suspend (dev->phydev); + } + +/* The final PHY MDIO access may have enabled the MAC clock. */ +au1000_reset_mac (dev); +out: +rtnl_unlock (); +return ret; +} + +static int au1000_resume (struct device *device) +{ +struct net_device *dev =dev_get_drvdata (device); +struct au1000_private *aup =netdev_priv (dev); +unsigned long flags; +int ret =0 ; + +rtnl_lock (); +if (!netif_running (dev)) + goto out; + +spin_lock_irqsave (&aup->lock, flags); + aup->old_link =0 ; + aup->old_speed =0 ; + aup->old_duplex =-1 ; +spin_unlock_irqrestore (&aup->lock, flags); + +if (dev->phydev) { + ret =phy_init_hw (dev->phydev); +if (ret) + goto err_reset; + ret =phy_resume (dev->phydev); +if (ret) + goto err_reset; + } + +au1000_init (dev); +enable_irq (dev->irq); +if (dev->phydev) +phy_start (dev->phydev); +netif_device_attach (dev); + goto out; + +err_reset: +au1000_reset_mac (dev); +out: +rtnl_unlock (); +return ret; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(au1000_pm_ops, au1000_suspend, au1000_resume); +/* * Au1000 transmit routine. */
@@ -1311,8 +1417,8 @@ static int au1000_probe(struct platform_device *pdev) dev->watchdog_timeo =ETH_TX_TIMEOUT ;/* -* The boot code uses the ethernet controller, so reset it to start -* fresh. au1000_init() expects that the device is in reset state. +* The boot code uses the ethernet controller, so stop it and gate +* its clock until the driver needs it. */ au1000_reset_mac (dev);
@@ -1417,6 +1523,7 @@ static struct platform_driver au1000_eth_driver = { .remove = au1000_remove, .driver = { .name = "au1000-eth", + .pm = pm_sleep_ptr(&au1000_pm_ops), }, };
Signature · 1 line
2.53.0
PATCH v4 10/10 net: au1000: reject frames larger than the TX bounce buffer
In reply to Florian Fainelliau1000_tx() copies skb->len bytes into a MAX_BUF_SIZE coherent buffer without checking the length. The copy can corrupt neighboring DMA buffers or run beyond the coherent allocation.
AF_PACKET with PACKET_VNET_HDR can deliver oversized frames through both plain sendmsg() and PACKET_TX_RING. In packet_snd(), a nonzero virtio GSO type bypasses the MTU checks, even when the supplied gso_size is large enough that virtio_net_hdr_to_skb() leaves the skb non-GSO. Genuine GSO packets can also reach the driver as oversized frames:
au1000 has no TSO, and software segmentation using a user-supplied gso_size can produce segments larger than MAX_BUF_SIZE.
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.
--- drivers/net/ethernet/amd/au1000_eth.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/amd/au1000_eth.c +6 -0
@@ -1091,6 +1091,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);
Signature · 1 line
2.53.0
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.
Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Quoted 13 lines · On 11/20/26 16:53, [email protected] wrote:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.
Quoted 6 lines
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.
The issue that was found during testing is that doing an interface open/close/open would hang, every other issue was a result of code inspection hunting for other bugs.
Signature · 1 line
Florian
Jakub Kicinski
maintainerQuoted 6 lines · On Fri, 20 Nov 2026 16:54:49 -0800 Florian Fainelli wrote:
Quoted 2 lines
*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.
The issue that was found during testing is that doing an interface open/close/open would hang, every other issue was a result of code inspection hunting for other bugs.
Do you see the bit above in the quoted message that says *IMPORTANT* ?