Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
ethernet: stmmac: Fix the tx timeout issue for kernel-6.1 merged
Browse files Browse the repository at this point in the history
For this case, the weight might be 0, so can't do transmit. This patch
can solve following ussue:

[   60.737783][  T147] rk_gmac-dwmac fe1b0000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[   60.737877][  T147] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   65.829085][    C5] ------------[ cut here ]------------
[   65.829150][    C5] NETDEV WATCHDOG: eth0 (rk_gmac-dwmac): transmit queue 0 timed out
[   65.829252][    C5] WARNING: CPU: 5 PID: 0 at net/sched/sch_generic.c:526 dev_watchdog+0x208/0x228
[   65.829294][    C5] Modules linked in: bcmdhd dhd_static_buf r8168
[   65.829329][    C5] CPU: 5 PID: 0 Comm: swapper/5 Not tainted 6.1.25 torvalds#65
[   65.829350][    C5] Hardware name: Rockchip RK3588 EVB1 LP4 V10 Board (DT)
[   65.829365][    C5] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   65.829386][    C5] pc : dev_watchdog+0x208/0x228
[   65.829410][    C5] lr : dev_watchdog+0x208/0x228
[   65.829432][    C5] sp : ffffffc00a203e10
[   65.829446][    C5] x29: ffffffc00a203e10 x28: dead000000000122 x27: 0000000000000000
[   65.829474][    C5] x26: ffffffc00a203ea0 x25: 0000000000000001 x24: ffffff82f6dadfb0
[   65.829498][    C5] x23: ffffffc009cc6000 x22: 0000000000000000 x21: ffffff810111039c
[   65.829520][    C5] x20: ffffff8101110000 x19: ffffff8101110448 x18: ffffffc00a1ed030
[   65.829542][    C5] x17: 756f2064656d6974 x16: ffffffffffffffff x15: 0000000000000004
[   65.829564][    C5] x14: ffffffc009d4d360 x13: 0000000000003fff x12: 0000000000000003
[   65.829586][    C5] x11: 00000000ffffbfff x10: c0000000ffffbfff x9 : 242a4f7b9d363e00
[   65.829610][    C5] x8 : 242a4f7b9d363e00 x7 : 205b5d3035313932 x6 : 382e35362020205b
[   65.829631][    C5] x5 : ffffffc00a16e61f x4 : ffffffc00a203b47 x3 : 0000000000000000
[   65.829652][    C5] x2 : 0000000000000000 x1 : ffffffc00a203bb0 x0 : 0000000000000041
[   65.829675][    C5] Call trace:
[   65.829687][    C5]  dev_watchdog+0x208/0x228
[   65.829711][    C5]  call_timer_fn+0x34/0x208
[   65.829738][    C5]  __run_timers+0x1a8/0x2dc
[   65.829760][    C5]  run_timer_softirq+0x24/0x48
[   65.829783][    C5]  _stext+0xe0/0x388
[   65.829803][    C5]  ____do_softirq+0x10/0x1c
[   65.829824][    C5]  call_on_irq_stack+0x40/0x58
[   65.829844][    C5]  do_softirq_own_stack+0x1c/0x28
[   65.829865][    C5]  __irq_exit_rcu+0x98/0xec
[   65.829885][    C5]  irq_exit_rcu+0x10/0x1c
[   65.829903][    C5]  el1_interrupt+0xa0/0x170
[   65.829929][    C5]  el1h_64_irq_handler+0x18/0x24
[   65.829951][    C5]  el1h_64_irq+0x78/0x7c
[   65.829968][    C5]  cpuidle_enter_state+0x17c/0x440
[   65.829993][    C5]  cpuidle_enter+0x38/0x50
[   65.830014][    C5]  do_idle+0x1ec/0x2c0
[   65.830034][    C5]  cpu_startup_entry+0x24/0x28
[   65.830052][    C5]  secondary_start_kernel+0x12c/0x1a8
[   65.830074][    C5]  __secondary_switched+0x68/0x6c

Signed-off-by: David Wu <david.wu@rock-chips.com>
Change-Id: I56bf8cfc9bf07b3bc13356ca7b3fe4cb48065d78
  • Loading branch information
SuperDavidWu authored and rkhuangtao committed Jul 20, 2023
1 parent c4aa7f2 commit 6ea088b
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5053,7 +5053,7 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
len = 0;
}

if (count >= limit)
if ((count >= limit - 1) && limit > 1)
break;

read_again:
Expand Down Expand Up @@ -5488,7 +5488,6 @@ static int stmmac_napi_poll_tx(struct napi_struct *napi, int budget)
int work_done;

priv->xstats.napi_poll++;
budget = min(priv->plat->dma_tx_size, budget);

work_done = stmmac_tx_clean(priv, budget, chan);
work_done = min(work_done, budget);
Expand All @@ -5510,17 +5509,14 @@ static int stmmac_napi_poll_rxtx(struct napi_struct *napi, int budget)
container_of(napi, struct stmmac_channel, rxtx_napi);
struct stmmac_priv *priv = ch->priv_data;
int rx_done, tx_done, rxtx_done;
int rx_budget, tx_budget;
u32 chan = ch->index;

priv->xstats.napi_poll++;
rx_budget = min(priv->plat->dma_rx_size, budget);
tx_budget = min(priv->plat->dma_tx_size, budget);

tx_done = stmmac_tx_clean(priv, tx_budget, chan);
tx_done = stmmac_tx_clean(priv, budget, chan);
tx_done = min(tx_done, budget);

rx_done = stmmac_rx_zc(priv, rx_budget, chan);
rx_done = stmmac_rx_zc(priv, budget, chan);

rxtx_done = max(tx_done, rx_done);

Expand Down Expand Up @@ -6929,22 +6925,30 @@ static void stmmac_napi_add(struct net_device *dev)

for (queue = 0; queue < maxq; queue++) {
struct stmmac_channel *ch = &priv->channel[queue];
int rx_budget = ((priv->plat->dma_rx_size < NAPI_POLL_WEIGHT) &&
(priv->plat->dma_rx_size > 0)) ?
priv->plat->dma_rx_size : NAPI_POLL_WEIGHT;
int tx_budget = ((priv->plat->dma_tx_size < NAPI_POLL_WEIGHT) &&
(priv->plat->dma_tx_size > 0)) ?
priv->plat->dma_tx_size : NAPI_POLL_WEIGHT;
int budget = min(rx_budget, tx_budget);

ch->priv_data = priv;
ch->index = queue;
spin_lock_init(&ch->lock);

if (queue < priv->plat->rx_queues_to_use) {
netif_napi_add(dev, &ch->rx_napi, stmmac_napi_poll_rx);
netif_napi_add_weight(dev, &ch->rx_napi,
stmmac_napi_poll_rx, rx_budget);
}
if (queue < priv->plat->tx_queues_to_use) {
netif_napi_add_tx(dev, &ch->tx_napi,
stmmac_napi_poll_tx);
netif_napi_add_tx_weight(dev, &ch->tx_napi,
stmmac_napi_poll_tx, tx_budget);
}
if (queue < priv->plat->rx_queues_to_use &&
queue < priv->plat->tx_queues_to_use) {
netif_napi_add(dev, &ch->rxtx_napi,
stmmac_napi_poll_rxtx);
netif_napi_add_weight(dev, &ch->rxtx_napi,
stmmac_napi_poll_rxtx, budget);
}
}
}
Expand Down

0 comments on commit 6ea088b

Please sign in to comment.