net: stmmac: dwmac4/5: Clear unused address entries [Linux 4.9.187]

This Linux kernel change "net: stmmac: dwmac4/5: Clear unused address entries" is included in the Linux 4.9.187 release. This change is authored by Jose Abreu <Jose.Abreu [at] synopsys.com> on Fri May 24 10:20:25 2019 +0200. The commit for this change in Linux stable tree is 49799ad (patch) which is from upstream commit 0620ec6. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 0620ec6.

net: stmmac: dwmac4/5: Clear unused address entries

[ Upstream commit 0620ec6c62a5a07625b65f699adc5d1b90394ee6 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>

There are 10 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index 51019b7..f46f2bf 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -173,14 +173,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);

Leave a Reply

Your email address will not be published. Required fields are marked *