net: stmmac: dwmac4/5: Clear unused address entries
authorJose Abreu <Jose.Abreu@synopsys.com>
Fri, 24 May 2019 08:20:25 +0000 (10:20 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 24 May 2019 20:45:57 +0000 (13:45 -0700)
In case we don't use a given address entry we need to clear it because
it could contain previous values that are no longer valid.

Found out while running stmmac selftests.

Signed-off-by: Jose Abreu <joabreu@synopsys.com>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c

index 4038fe914f7221386efe340af828aa469d007dc3..5e98da4e14f9a2b3a3bd3b6dd29469ec57b54317 100644 (file)
@@ -448,14 +448,20 @@ static void dwmac4_set_filter(struct mac_device_info *hw,
                 * are required
                 */
                value |= GMAC_PACKET_FILTER_PR;
-       } else if (!netdev_uc_empty(dev)) {
-               int reg = 1;
+       } else {
                struct netdev_hw_addr *ha;
+               int reg = 1;
 
                netdev_for_each_uc_addr(ha, dev) {
                        dwmac4_set_umac_addr(hw, ha->addr, reg);
                        reg++;
                }
+
+               while (reg <= GMAC_MAX_PERFECT_ADDRESSES) {
+                       writel(0, ioaddr + GMAC_ADDR_HIGH(reg));
+                       writel(0, ioaddr + GMAC_ADDR_LOW(reg));
+                       reg++;
+               }
        }
 
        writel(value, ioaddr + GMAC_PACKET_FILTER);