pch_gbe_set_multi() loops through each unused MAC address register, masking them one by one & waiting for a bit to clear indicating that the change has taken effect before zeroing out the MAC register.
This is needlessly inefficient. We can instead set all the desired mask bits with a single write to the ADDR_MASK register & wait only once for the busy bit to clear indicating that the addresses are masked (ie. ignored) as required. It's pointless zeroing the MAC registers since they're masked anyway so their contents are irrelevant, so we can avoid looping over them here entirely. Signed-off-by: Paul Burton <[email protected]> Cc: Andrew Lunn <[email protected]> Cc: David S. Miller <[email protected]> Cc: [email protected] --- Changes in v7: New patch drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c index 8908ef654d94..9651fa02d4bb 100644 --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c @@ -2140,15 +2140,13 @@ static void pch_gbe_set_multi(struct net_device *netdev) pch_gbe_mac_mar_set(hw, ha->addr, i++); /* If there are spare MAC registers, mask & clear them */ - for (; i < PCH_GBE_MAR_ENTRIES; i++) { - /* Clear MAC address mask */ + if (i < PCH_GBE_MAR_ENTRIES) { adrmask = ioread32(&hw->reg->ADDR_MASK); - iowrite32(adrmask | BIT(i), &hw->reg->ADDR_MASK); + adrmask |= GENMASK(PCH_GBE_MAR_ENTRIES - 1, i); + iowrite32(adrmask, &hw->reg->ADDR_MASK); + /* wait busy */ pch_gbe_wait_clr_bit(&hw->reg->ADDR_MASK, PCH_GBE_BUSY); - /* Clear MAC address */ - iowrite32(0, &hw->reg->mac_adr[i].high); - iowrite32(0, &hw->reg->mac_adr[i].low); } netdev_dbg(netdev, -- 2.18.0
