Skip to content

Commit 4c1b566

Browse files
Shenwei WangPaolo Abeni
Shenwei Wang
authored and
Paolo Abeni
committed
net: stmmac: dwmac4: extend timeout for VLAN Tag register busy bit check
Increase the timeout for checking the busy bit of the VLAN Tag register from 10µs to 500ms. This change is necessary to accommodate scenarios where Energy Efficient Ethernet (EEE) is enabled. Overnight testing revealed that when EEE is active, the busy bit can remain set for up to approximately 300ms. The new 500ms timeout provides a safety margin. Fixes: ed64639 ("net: stmmac: Add support for VLAN Rx filtering") Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com> Link: https://patch.msgid.link/20240924205424.573913-1-shenwei.wang@nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 23e19f2 commit 4c1b566

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/slab.h>
1515
#include <linux/ethtool.h>
1616
#include <linux/io.h>
17+
#include <linux/iopoll.h>
1718
#include "stmmac.h"
1819
#include "stmmac_pcs.h"
1920
#include "dwmac4.h"
@@ -471,7 +472,7 @@ static int dwmac4_write_vlan_filter(struct net_device *dev,
471472
u8 index, u32 data)
472473
{
473474
void __iomem *ioaddr = (void __iomem *)dev->base_addr;
474-
int i, timeout = 10;
475+
int ret;
475476
u32 val;
476477

477478
if (index >= hw->num_vlan)
@@ -487,16 +488,15 @@ static int dwmac4_write_vlan_filter(struct net_device *dev,
487488

488489
writel(val, ioaddr + GMAC_VLAN_TAG);
489490

490-
for (i = 0; i < timeout; i++) {
491-
val = readl(ioaddr + GMAC_VLAN_TAG);
492-
if (!(val & GMAC_VLAN_TAG_CTRL_OB))
493-
return 0;
494-
udelay(1);
491+
ret = readl_poll_timeout(ioaddr + GMAC_VLAN_TAG, val,
492+
!(val & GMAC_VLAN_TAG_CTRL_OB),
493+
1000, 500000);
494+
if (ret) {
495+
netdev_err(dev, "Timeout accessing MAC_VLAN_Tag_Filter\n");
496+
return -EBUSY;
495497
}
496498

497-
netdev_err(dev, "Timeout accessing MAC_VLAN_Tag_Filter\n");
498-
499-
return -EBUSY;
499+
return 0;
500500
}
501501

502502
static int dwmac4_add_hw_vlan_rx_fltr(struct net_device *dev,

0 commit comments

Comments
 (0)