net: au1000: Bug fixes
Subsystems (3)
v2 cover net: au1000: Bug fixes
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(-)
Signature · 1 line
2.53.0
PATCH v2 1/12 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 v2 2/12 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 v2 3/12 net: au1000: disconnect the PHY before freeing the MDIO bus
In reply to Florian FainelliBalance phy_connect() on probe failure and removal. Otherwise PHY interrupts, device references and the attachment to the freed netdev survive teardown. 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. Always clear the DMA descriptor control bits and TX state.
The teardown corrections were identified by Sashiko AI review and hardware testing, with OpenAI Codex assisting implementation, validation and commit-message consolidation. Previously validated on MTX-1 with opened and never-opened removal, rebind and traffic; both removal cases left the MAC enable register at zero. MIPS build and extracted-function ASan/UBSan checks passed before this series was consolidated.
--- 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 v2 4/12 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 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)
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net v2 04/12] net: au1000: report MDIO transaction timeouts
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…
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.
Quoted 4 lines
drivers/net/ethernet/amd/au1000_eth.c +0
-0
[ ... ]
Quoted 1 line
drivers/net/ethernet/amd/au1000_eth.c +0
-0@@ -292,26 +293,27 @@ static int au1000_mdio_read(struct net_device *dev, int phy_addr, int reg)
[ ... ]
Quoted 10 lines
drivers/net/ethernet/amd/au1000_eth.c +1
-1while (readl (mii_control_reg) &MAC_MII_BUSY ) {mdelay (1 );if (--timedout ==0 ) {netdev_err (dev,"mdio_write busy timeout!!\n" ); -return ; +return -ETIMEDOUT ; } }
drivers/net/ethernet/amd/au1000_eth.c static void au1000_mdio_write(struct net_device *dev, int phy_addr, · line 329
Quoted 8 lines
drivers/net/ethernet/amd/au1000_eth.c +5
-0@@ -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.
Quoted 3 lines
drivers/net/ethernet/amd/au1000_eth.c +2
-0+ +return ret; }
[ ... ]
Signature · 1 line
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
Quoted 59 lines · On 11/16/26 05:50, [email protected] 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-ETIMEDOUTinstead of reporting success when the MII controller stays busy. It also adds areadl_poll_timeout()check after the write so that a failed final transaction is reported to phylib. The read path now returns-ETIMEDOUTinstead of -1.Quoted 4 lines
drivers/net/ethernet/amd/au1000_eth.c +0
-0[ ... ]
Quoted 1 line
drivers/net/ethernet/amd/au1000_eth.c +0
-0@@ -292,26 +293,27 @@ static int au1000_mdio_read(struct net_device *dev, int phy_addr, int reg)[ ... ]
Quoted 10 lines
while (readl(mii_control_reg) & MAC_MII_BUSY) { mdelay(1); if (--timedout == 0) { netdev_err(dev, "mdio_write busy timeout!!\n");drivers/net/ethernet/amd/au1000_eth.c +1
-1-return ; +return -ETIMEDOUT ; } }drivers/net/ethernet/amd/au1000_eth.c static void au1000_mdio_write(struct net_device *dev, int phy_addr, · line 329
Quoted 8 lines
drivers/net/ethernet/amd/au1000_eth.c +5
-0@@ -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_writebusy timeout!!". The first one fires before anything is written to the registers. The new one fires afterwritel()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.
Quoted 3 lines
au1000_mdio_read()already uses two separate messages ("read_MIIbusy timeout!!" and "mdio_readbusy timeout!!"). Something like "mdio_writecompletion timeout" here would separate the two write cases the same way.
Sure, that can be improved to be clearer.
pw-bot: cr
Signature · 1 line
Florian
PATCH v2 5/12 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.
When submission reclaims a completed descriptor at tx_head, advance tx_tail before reusing it so the interrupt handler does not wait on the new packet while older completions remain pending. 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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/ethernet/amd/au1000_eth.c +10 -1
@@ -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,25 @@ 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->len =0 ; + aup->tx_tail = (aup->tx_tail +1 ) & (NUM_TX_DMA -1 ); }if (aup->tx_full) {
@@ -1009,8 +1017,9 @@ static netdev_tx_t au1000_tx(struct sk_buff *skb, struct net_device *dev) 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 v2 6/12 net: au1000: assign a valid MAC address without platform data
In reply to Florian FainelliThe supported no-platform-data path leaves dev_addr as all zeroes. The device can register but eth_validate_addr() prevents it from opening. Generate a random address just as for platform data containing an invalid address.
--- drivers/net/ethernet/amd/au1000_eth.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/amd/au1000_eth.c +1 -0
@@ -1196,6 +1196,7 @@ static int au1000_probe(struct platform_device *pdev)dev_info (&pdev->dev,"no platform_data passed," " PHY search on MAC0\n" ); aup->phy1_search_mac0 =1 ; +eth_hw_addr_random (dev); }else {if (is_valid_ether_addr (pd->mac)) {eth_hw_addr_set (dev, pd->mac);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net v2 06/12] net: au1000: assign a valid MAC address without platform data
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…
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 overstates how far the bug reaches, and it carries a Fixes: tag.
--
net: au1000: assign a valid MAC address without platform data
When no platform data is passed, au1000_probe() now calls eth_hw_addr_random(). Before this, the device kept an all-zero dev_addr, and eth_validate_addr() rejected it at open time.
Quoted 2 lines
The supported no-platform-data path leaves
dev_addras all zeroes. The device can register buteth_validate_addr()prevents it from opening.
[Severity: Low]
Can any in-tree configuration actually reach this path?
The only in-tree au1000-eth platform devices are au1xxx_eth0_device and au1xxx_eth1_device in arch/mips/alchemy/common/platform.c. Both always set platform_data:
.platform_data = &au1xxx_eth0_platform_data,
au1xxx_override_eth_cfg() is the board override path, used by board-mtx1.c. It copies into the same static structures, so the pointer stays non-NULL:
if (port == 0) memcpy(&au1xxx_eth0_platform_data, eth_data, sizeof(struct au1000_eth_platform_data));
au1000_eth_driver has no of_match_table or id_table. It can only bind by name to the platform devices above.
So dev_get_platdata() never seems to return NULL for an in-tree user. The failure described could only happen with out-of-tree board code that registers the device without platform data.
The code change itself looks correct. It restores what the !pd branch did before 7718f2c27dbd, which only added eth_hw_addr_random() to the invalid-MAC branch.
Quoted 1 line
Fixes 7718f2c27dbd ("au1000_eth: use eth_hw_addr_random() instead of random_ether_addr()")
Could the commit message say that only out-of-tree platform code can hit this, or describe the change as hardening? As written, the Fixes: tag may lead to a stable backport for a failure no mainline configuration can hit.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112045301.3669532-1-f.fainelli%40gmail.com
Re: [PATCH net v2 06/12] net: au1000: assign a valid MAC address without platform data
Quoted 48 lines · On 11/16/26 05:50, [email protected] 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 overstates how far the bug reaches, and it carries a Fixes: tag.
--
net: au1000: assign a valid MAC address without platform data
When no platform data is passed,
au1000_probe()now callseth_hw_addr_random(). Before this, the device kept an all-zerodev_addr, andeth_validate_addr()rejected it at open time.Quoted 2 lines
The supported no-platform-data path leaves
dev_addras all zeroes. The device can register buteth_validate_addr()prevents it from opening.[Severity: Low]
Can any in-tree configuration actually reach this path?The only in-tree au1000-eth platform devices are
au1xxx_eth0_deviceandau1xxx_eth1_deviceinarch/mips/alchemy/common/platform.c. Both always setplatform_data:.platform_data =
&au1xxx_eth0_platform_data,
au1xxx_override_eth_cfg()is the board override path, used byboard-mtx1.c. It copies into the same static structures, so the pointer stays non-NULL:if (port == 0) memcpy(&au1xxx_eth0_platform_data, eth_data, sizeof(struct au1000_eth_platform_data));
au1000_eth_driverhas noof_match_tableorid_table. It can only bind by name to the platform devices above.So
dev_get_platdata()never seems to return NULL for an in-tree user. The failure described could only happen with out-of-tree board code that registers the device without platform data.The code change itself looks correct. It restores what the !pd branch did before
7718f2c27dbd, which only addedeth_hw_addr_random()to the invalid-MAC branch.
Quoted 6 lines
Quoted 1 line
Fixes 7718f2c27dbd ("au1000_eth: use eth_hw_addr_random() instead of random_ether_addr()")Could the commit message say that only out-of-tree platform code can hit this, or describe the change as hardening? As written, the Fixes: tag may lead to a stable backport for a failure no mainline configuration can hit.
Yes this is more of a defensive change, I will drop it from this series.
pw-bot: not applicable
Signature · 1 line
Florian
PATCH v2 7/12 net: au1000: fix buffer descriptor free list insertion
In reply to Florian FainelliReleaseDB 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.
--- drivers/net/ethernet/amd/au1000_eth.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/amd/au1000_eth.c +1 -3
@@ -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; }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net v2 07/12] net: au1000: fix buffer descriptor free list insertion
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…
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.
Quoted 7 lines
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?
Signature · 1 line
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
Quoted 58 lines · On 11/16/26 05:50, [email protected] 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 matchesau1000_GetFreeDB()and how the list is set up in probe.Quoted 7 lines
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: theerr_outunwind inau1000_probe()andau1000_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_outpath inau1000_probe()also falls through todma_free_coherent()andfree_netdev().
au1000_GetFreeDB()is only called fromau1000_probe(), before anyau1000_ReleaseDB()call, and no RX or TX path walksaup->pDBfree. Also,NUM_RX_BUFFSequalsNUM_RX_DMAandNUM_TX_BUFFSequalsNUM_TX_DMA, so the free list is already empty after a successful probe.
Quoted 7 lines
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
Signature · 1 line
Florian
PATCH v2 8/12 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
@@ -683,6 +683,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. *
@@ -704,6 +706,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);
@@ -736,11 +739,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 ; }
@@ -1034,13 +1040,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) ||
@@ -1061,7 +1066,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 v2 9/12 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
@@ -722,7 +722,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 v2 10/12 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.
--- drivers/net/phy/Kconfig | 2 +- drivers/net/phy/smsc.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 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 +26 -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,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 },
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net v2 10/12] net: phy: smsc: wait for LAN83C183 power-down recovery
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
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.
drivers/net/phy/Kconfig config SMSC_PHY · line 424
Quoted 10 lines
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
[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?
Quoted 4 lines
drivers/net/phy/smsc.c +0
-0
[ ... ]
Quoted 5 lines
drivers/net/phy/smsc.c +1
-0@@ -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)
drivers/net/phy/smsc.c int smsc_phy_probe(struct phy_device *phydev) · line 698
Quoted 10 lines
drivers/net/phy/smsc.c +10
-0+{ +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?
Quoted 3 lines
drivers/net/phy/smsc.c +3
-0+ +return 0 ; +}
[ ... ]
Signature · 1 line
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
Quoted 127 lines · On 11/16/26 05:50, [email protected] 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, theSMSC_PHYKconfighelp 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_PDOWNand 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.drivers/net/phy/Kconfig config SMSC_PHY · line 424
Quoted 10 lines
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[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[] indrivers/net/phy/smsc.cbinds. 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?
Quoted 4 lines
drivers/net/phy/smsc.c +0
-0[ ... ]
Quoted 5 lines
drivers/net/phy/smsc.c +1
-0@@ -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)drivers/net/phy/smsc.c int smsc_phy_probe(struct phy_device *phydev) · line 698
Quoted 10 lines
drivers/net/phy/smsc.c +10
-0+{ +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 callsphy_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 setsBMCR_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()callsphy_stop()beforeau1000_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()beforeau1000_init()and enables RX/TX only afterau1000_adjust_link()has seen link up. It also callsau1000_hard_stop()on link down. In thePHY_HALTEDpath,phy_link_down()runs beforephy_suspend(), so the MAC stops before the PHY powers down.
Quoted 3 lines
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
Signature · 1 line
Florian
PATCH v2 11/12 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. 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. Initialize the MAC before phy_start() 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. On resume failure reset the MAC and release the IRQ; if initialization fails, suspend the PHY again before cleanup.
--- drivers/net/ethernet/amd/au1000_eth.c | 39 ++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 7 deletions(-)
drivers/net/ethernet/amd/au1000_eth.c +32 -7
@@ -456,7 +456,8 @@ 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_hard_stop (dev); aup->old_speed =0 ; aup->old_duplex =-1 ; }
@@ -691,8 +692,8 @@ static u32 au1000_rx_mode(struct net_device *dev, u32 reg);* 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. +* conserve power. The device must be stopped before au1000_init() is +* called, but may be out of reset for MDIO accesses while resuming the PHY. */ static int au1000_init (struct net_device *dev) {
@@ -727,12 +728,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 ;
@@ -742,6 +743,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 */
@@ -916,6 +921,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);
@@ -928,11 +934,25 @@ static int au1000_open(struct net_device *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; + } + retval =au1000_init (dev);if (retval) {netdev_err (dev,"error in au1000_init\n" ); -free_irq (dev->irq, dev); -return retval; +if (dev->phydev) +phy_suspend (dev->phydev); + goto err_reset; }if (dev->phydev)
@@ -943,6 +963,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)
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net v2 11/12] net: au1000: keep the MAC stopped until the PHY link is ready
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…
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 and comments in this patch don't match the code.
--
net: au1000: keep the MAC stopped until the PHY link is ready
This patch stops the MAC when the PHY reports link-down. On open, it now calls phy_resume() before au1000_init(). It also keeps MAC RX/TX disabled in au1000_init() until au1000_adjust_link() has seen a link-up.
Quoted 4 lines
drivers/net/ethernet/amd/au1000_eth.c +0
-0
[ ... ]
Quoted 11 lines
drivers/net/ethernet/amd/au1000_eth.c +2
-2@@ -691,8 +692,8 @@ static u32 au1000_rx_mode(struct net_device *dev, u32 reg);* 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. +* conserve power. The device must be stopped before au1000_init() is +* called, but may be out of reset for MDIO accesses while resuming the PHY. */ static int au1000_init (struct net_device *dev) {
[ ... ]
Quoted 4 lines
drivers/net/ethernet/amd/au1000_eth.c +0
-0@@ -928,11 +934,25 @@ static int au1000_open(struct net_device *dev)return retval; }
[ ... ]
Quoted 6 lines
drivers/net/ethernet/amd/au1000_eth.c +6
-0+/* Restore the MII clocks without starting the PHY state machine. */ +if (dev->phydev) { + retval =phy_resume (dev->phydev); +if (retval) + goto err_reset; + }
drivers/net/ethernet/amd/au1000_eth.c static int au1000_open(struct net_device *dev) · line 956
Quoted 10 lines
drivers/net/ethernet/amd/au1000_eth.c +4
-2+ retval =au1000_init (dev);if (retval) {netdev_err (dev,"error in au1000_init\n" ); -free_irq (dev->irq, dev); -return retval; +if (dev->phydev) +phy_suspend (dev->phydev); + goto err_reset; }
[Severity: Low]
Can this error branch in au1000_open() ever run? au1000_init() has only one return statement:
drivers/net/ethernet/amd/au1000_eth.c:au1000_init() {
...
spin_unlock_irqrestore(&aup->lock, flags);
netif_addr_unlock_bh(dev);
return 0;
}au1000_enable_mac() returns void, so nothing in au1000_init() can fail. That makes the new phy_suspend() rollback look like dead code, even though the commit message describes it as:
if initialization fails, suspend the PHY again before cleanup.
The commit message also says:
Initialize the MAC before phy_start() so the PHY worker cannot access MDIO or enable traffic during setup.
Didn't au1000_open() already call au1000_init() before phy_start() before this patch? The diff shows that order as unchanged context.
The actual changes seem to be the new phy_resume() call before au1000_init(), and making RX/TX depend on aup->old_link. Could the commit message describe those changes instead?
Separately, the au1000_init() header comment now says the device "may be out of reset for MDIO accesses while resuming the PHY". The comment in au1000_probe() was not changed and still says:
/* * The boot code uses the ethernet controller, so reset it to start * fresh. au1000_init() expects that the device is in reset state. */
Should these two comments be reconciled? They now give conflicting preconditions for au1000_init(). Neither is strictly accurate, because au1000_init() always forces a reset itself through au1000_enable_mac(dev, 1).
Quoted 2 lines
if (
dev->phydev)
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112045301.3669532-1-f.fainelli%40gmail.com
Re: [PATCH net v2 11/12] net: au1000: keep the MAC stopped until the PHY link is ready
Quoted 101 lines · On 11/16/26 05:50, [email protected] 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 and comments in this patch don't match the code.
--
net: au1000: keep the MAC stopped until the PHY link is ready
This patch stops the MAC when the PHY reports link-down. On open, it now calls
phy_resume()beforeau1000_init(). It also keeps MAC RX/TX disabled inau1000_init()untilau1000_adjust_link()has seen a link-up.Quoted 4 lines
drivers/net/ethernet/amd/au1000_eth.c +0
-0[ ... ]
Quoted 11 lines
drivers/net/ethernet/amd/au1000_eth.c +2
-2@@ -691,8 +692,8 @@ static u32 au1000_rx_mode(struct net_device *dev, u32 reg);* 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. +* conserve power. The device must be stopped before au1000_init() is +* called, but may be out of reset for MDIO accesses while resuming the PHY. */ static int au1000_init (struct net_device *dev) {[ ... ]
Quoted 4 lines
drivers/net/ethernet/amd/au1000_eth.c +0
-0@@ -928,11 +934,25 @@ static int au1000_open(struct net_device *dev)return retval; }[ ... ]
Quoted 6 lines
drivers/net/ethernet/amd/au1000_eth.c +6
-0+/* Restore the MII clocks without starting the PHY state machine. */ +if (dev->phydev) { + retval =phy_resume (dev->phydev); +if (retval) + goto err_reset; + }drivers/net/ethernet/amd/au1000_eth.c static int au1000_open(struct net_device *dev) · line 956
Quoted 10 lines
drivers/net/ethernet/amd/au1000_eth.c +4
-2+ retval =au1000_init (dev);if (retval) {netdev_err (dev,"error in au1000_init\n" ); -free_irq (dev->irq, dev); -return retval; +if (dev->phydev) +phy_suspend (dev->phydev); + goto err_reset; }[Severity: Low]
Can this error branch in
au1000_open()ever run?au1000_init()has only one return statement:drivers/net/ethernet/amd/au1000_eth.c:au1000_init() { ... spin_unlock_irqrestore(&aup->lock, flags); netif_addr_unlock_bh(dev); return 0; }
au1000_enable_mac()returns void, so nothing inau1000_init()can fail. That makes the newphy_suspend()rollback look like dead code, even though the commit message describes it as:if initialization fails, suspend the PHY again before cleanup.
The commit message also says:
Initialize the MAC before
phy_start()so the PHY worker cannot access MDIO or enable traffic during setup.Didn't
au1000_open()already callau1000_init()beforephy_start()before this patch? The diff shows that order as unchanged context.The actual changes seem to be the new
phy_resume()call beforeau1000_init(), and making RX/TX depend onaup->old_link. Could the commit message describe those changes instead?Separately, the
au1000_init()header comment now says the device "may be out of reset for MDIO accesses while resuming the PHY". The comment inau1000_probe()was not changed and still says:/* * The boot code uses the ethernet controller, so reset it to start * fresh. au1000_init() expects that the device is in reset state. */
Quoted 4 lines
Should these two comments be reconciled? They now give conflicting preconditions for
au1000_init(). Neither is strictly accurate, becauseau1000_init()always forces a reset itself throughau1000_enable_mac(dev, 1).
Agreed on all three points. In the respin I have:
• Removed the unreachable initialization-error branch, including the new phy_suspend() rollback, since au1000_init() always returns zero.
• Updated the commit message to describe the new synchronous phy_resume() before MAC initialization, while preserving the existing initialization-before-phy_start() ordering.
• Reconciled the comments to explain that au1000_init() forces a reset itself and that preceding MDIO accesses may already have enabled the MAC.
pw-bot: cr
Signature · 1 line
Florian
PATCH v2 12/12 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. 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.
--- drivers/net/ethernet/amd/au1000_eth.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/amd/au1000_eth.c +6 -0
@@ -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);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net v2 12/12] net: au1000: reject frames larger than the TX bounce buffer
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…
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.
Quoted 4 lines
au1000_tx()copiesskb->lenbytes into aMAX_BUF_SIZEcoherent buffer without checking the length. Oversized non-GSO packets can reach this path throughAF_PACKETwithPACKET_VNET_HDRandPACKET_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?
drivers/net/ethernet/amd/au1000_eth.c static netdev_tx_t au1000_tx(struct sk_buff *skb, struct net_device *dev) · line 1015
Quoted 13 lines
drivers/net/ethernet/amd/au1000_eth.c +5
-0@@ -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.
Signature · 1 line
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
Quoted 103 lines · On 11/16/26 05:50, [email protected] 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 indrivers/net/ethernet/amd/have the same unchecked copy ofskb->lenbytes 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 thanMAX_BUF_SIZEare now dropped and counted intx_droppedinstead of being copied past the end of the TX bounce buffer.Quoted 4 lines
au1000_tx()copiesskb->lenbytes into aMAX_BUF_SIZEcoherent buffer without checking the length. Oversized non-GSO packets can reach this path throughAF_PACKETwithPACKET_VNET_HDRandPACKET_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 thoughPACKET_TX_RINGis required. The plain sendmsg path throughpacket_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 thangso_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_sizeis never checked againstdev->mtu. au1000 has no TSO, sovalidate_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 thepacket_snd()and GSO routes?drivers/net/ethernet/amd/au1000_eth.c static netdev_tx_t au1000_tx(struct sk_buff *skb, struct net_device *dev) · line 1015
Quoted 13 lines
drivers/net/ethernet/amd/au1000_eth.c +5
-0@@ -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 indrivers/net/ethernet/amd/need the same check?Several
lance_start_xmit()implementations copyskb->lenbytes into fixed-size TX slots with no upper bound. Their slots are smaller than au1000's 2048-byteMAX_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)
Quoted 9 lines
Using the
AF_PACKETroute 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_blockor shared memory area.Triggering this needs
CAP_NET_RAWin 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
Signature · 1 line
Florian