Skip to content

Commit 6ea088b

Browse files
SuperDavidWurkhuangtao
authored andcommitted
ethernet: stmmac: Fix the tx timeout issue for kernel-6.1 merged
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 <[email protected]> Change-Id: I56bf8cfc9bf07b3bc13356ca7b3fe4cb48065d78
1 parent c4aa7f2 commit 6ea088b

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5053,7 +5053,7 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
50535053
len = 0;
50545054
}
50555055

5056-
if (count >= limit)
5056+
if ((count >= limit - 1) && limit > 1)
50575057
break;
50585058

50595059
read_again:
@@ -5488,7 +5488,6 @@ static int stmmac_napi_poll_tx(struct napi_struct *napi, int budget)
54885488
int work_done;
54895489

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

54935492
work_done = stmmac_tx_clean(priv, budget, chan);
54945493
work_done = min(work_done, budget);
@@ -5510,17 +5509,14 @@ static int stmmac_napi_poll_rxtx(struct napi_struct *napi, int budget)
55105509
container_of(napi, struct stmmac_channel, rxtx_napi);
55115510
struct stmmac_priv *priv = ch->priv_data;
55125511
int rx_done, tx_done, rxtx_done;
5513-
int rx_budget, tx_budget;
55145512
u32 chan = ch->index;
55155513

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

5520-
tx_done = stmmac_tx_clean(priv, tx_budget, chan);
5516+
tx_done = stmmac_tx_clean(priv, budget, chan);
55215517
tx_done = min(tx_done, budget);
55225518

5523-
rx_done = stmmac_rx_zc(priv, rx_budget, chan);
5519+
rx_done = stmmac_rx_zc(priv, budget, chan);
55245520

55255521
rxtx_done = max(tx_done, rx_done);
55265522

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

69306926
for (queue = 0; queue < maxq; queue++) {
69316927
struct stmmac_channel *ch = &priv->channel[queue];
6928+
int rx_budget = ((priv->plat->dma_rx_size < NAPI_POLL_WEIGHT) &&
6929+
(priv->plat->dma_rx_size > 0)) ?
6930+
priv->plat->dma_rx_size : NAPI_POLL_WEIGHT;
6931+
int tx_budget = ((priv->plat->dma_tx_size < NAPI_POLL_WEIGHT) &&
6932+
(priv->plat->dma_tx_size > 0)) ?
6933+
priv->plat->dma_tx_size : NAPI_POLL_WEIGHT;
6934+
int budget = min(rx_budget, tx_budget);
69326935

69336936
ch->priv_data = priv;
69346937
ch->index = queue;
69356938
spin_lock_init(&ch->lock);
69366939

69376940
if (queue < priv->plat->rx_queues_to_use) {
6938-
netif_napi_add(dev, &ch->rx_napi, stmmac_napi_poll_rx);
6941+
netif_napi_add_weight(dev, &ch->rx_napi,
6942+
stmmac_napi_poll_rx, rx_budget);
69396943
}
69406944
if (queue < priv->plat->tx_queues_to_use) {
6941-
netif_napi_add_tx(dev, &ch->tx_napi,
6942-
stmmac_napi_poll_tx);
6945+
netif_napi_add_tx_weight(dev, &ch->tx_napi,
6946+
stmmac_napi_poll_tx, tx_budget);
69436947
}
69446948
if (queue < priv->plat->rx_queues_to_use &&
69456949
queue < priv->plat->tx_queues_to_use) {
6946-
netif_napi_add(dev, &ch->rxtx_napi,
6947-
stmmac_napi_poll_rxtx);
6950+
netif_napi_add_weight(dev, &ch->rxtx_napi,
6951+
stmmac_napi_poll_rxtx, budget);
69486952
}
69496953
}
69506954
}

0 commit comments

Comments
 (0)