MAC 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. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Florian Fainelli --- drivers/net/ethernet/amd/au1000_eth.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c index f127c0184036..67f4899c34a6 100644 --- a/drivers/net/ethernet/amd/au1000_eth.c +++ b/drivers/net/ethernet/amd/au1000_eth.c @@ -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 = { -- 2.53.0