Skip to content

Commit f73f05c

Browse files
committed
Merge branch 'net-ethernet-mtk-star-emac-fix-several-issues-on-rx-tx-poll'
Louis-Alexis Eyraud says: ==================== net: ethernet: mtk-star-emac: fix several issues on rx/tx poll This patchset fixes two issues with the mtk-star-emac driver. The first patch fixes spin lock recursion issues I've observed on the Mediatek Genio 350-EVK board using this driver when the Ethernet functionality is enabled on the board (requires a correct jumper and DIP switch configuration, as well as enabling the device in the devicetree). The issues can be easily reproduced with apt install or ssh commands especially and with the CONFIG_DEBUG_SPINLOCK parameter, when one occurs, there is backtrace similar to this: ``` BUG: spinlock recursion on CPU#0, swapper/0/0 lock: 0xffff00000db9cf20, .magic: dead4ead, .owner: swapper/0/0, .owner_cpu: 0 CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 6.15.0-rc2-next-20250417-00001-gf6a27738686c-dirty #28 PREEMPT Hardware name: MediaTek MT8365 Open Platform EVK (DT) Call trace: show_stack+0x18/0x24 (C) dump_stack_lvl+0x60/0x80 dump_stack+0x18/0x24 spin_dump+0x78/0x88 do_raw_spin_lock+0x11c/0x120 _raw_spin_lock+0x20/0x2c mtk_star_handle_irq+0xc0/0x22c [mtk_star_emac] __handle_irq_event_percpu+0x48/0x140 handle_irq_event+0x4c/0xb0 handle_fasteoi_irq+0xa0/0x1bc handle_irq_desc+0x34/0x58 generic_handle_domain_irq+0x1c/0x28 gic_handle_irq+0x4c/0x120 do_interrupt_handler+0x50/0x84 el1_interrupt+0x34/0x68 el1h_64_irq_handler+0x18/0x24 el1h_64_irq+0x6c/0x70 regmap_mmio_read32le+0xc/0x20 (P) _regmap_bus_reg_read+0x6c/0xac _regmap_read+0x60/0xdc regmap_read+0x4c/0x80 mtk_star_rx_poll+0x2f4/0x39c [mtk_star_emac] __napi_poll+0x38/0x188 net_rx_action+0x164/0x2c0 handle_softirqs+0x100/0x244 __do_softirq+0x14/0x20 ____do_softirq+0x10/0x20 call_on_irq_stack+0x24/0x64 do_softirq_own_stack+0x1c/0x40 __irq_exit_rcu+0xd4/0x10c irq_exit_rcu+0x10/0x1c el1_interrupt+0x38/0x68 el1h_64_irq_handler+0x18/0x24 el1h_64_irq+0x6c/0x70 cpuidle_enter_state+0xac/0x320 (P) cpuidle_enter+0x38/0x50 do_idle+0x1e4/0x260 cpu_startup_entry+0x34/0x3c rest_init+0xdc/0xe0 console_on_rootfs+0x0/0x6c __primary_switched+0x88/0x90 ``` The second patch is a cleanup patch to fix a inconsistency in the mtk_star_rx_poll function between the napi_complete_done api usage and its description in documentation. I've tested this patchset on Mediatek Genio 350-EVK board with a kernel based on linux-next (tag: next-20250422). v1: https://lore.kernel.org/20250422-mtk_star_emac-fix-spinlock-recursion-issue-v1-0-1e94ea430360@collabora.com ==================== Link: https://patch.msgid.link/20250424-mtk_star_emac-fix-spinlock-recursion-issue-v2-0-f3fde2e529d8@collabora.com Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 68f9d89 + e54b4db commit f73f05c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/net/ethernet/mediatek/mtk_star_emac.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,7 @@ static int mtk_star_tx_poll(struct napi_struct *napi, int budget)
11631163
struct net_device *ndev = priv->ndev;
11641164
unsigned int head = ring->head;
11651165
unsigned int entry = ring->tail;
1166+
unsigned long flags;
11661167

11671168
while (entry != head && count < (MTK_STAR_RING_NUM_DESCS - 1)) {
11681169
ret = mtk_star_tx_complete_one(priv);
@@ -1182,9 +1183,9 @@ static int mtk_star_tx_poll(struct napi_struct *napi, int budget)
11821183
netif_wake_queue(ndev);
11831184

11841185
if (napi_complete(napi)) {
1185-
spin_lock(&priv->lock);
1186+
spin_lock_irqsave(&priv->lock, flags);
11861187
mtk_star_enable_dma_irq(priv, false, true);
1187-
spin_unlock(&priv->lock);
1188+
spin_unlock_irqrestore(&priv->lock, flags);
11881189
}
11891190

11901191
return 0;
@@ -1341,16 +1342,16 @@ static int mtk_star_rx(struct mtk_star_priv *priv, int budget)
13411342
static int mtk_star_rx_poll(struct napi_struct *napi, int budget)
13421343
{
13431344
struct mtk_star_priv *priv;
1345+
unsigned long flags;
13441346
int work_done = 0;
13451347

13461348
priv = container_of(napi, struct mtk_star_priv, rx_napi);
13471349

13481350
work_done = mtk_star_rx(priv, budget);
1349-
if (work_done < budget) {
1350-
napi_complete_done(napi, work_done);
1351-
spin_lock(&priv->lock);
1351+
if (work_done < budget && napi_complete_done(napi, work_done)) {
1352+
spin_lock_irqsave(&priv->lock, flags);
13521353
mtk_star_enable_dma_irq(priv, true, false);
1353-
spin_unlock(&priv->lock);
1354+
spin_unlock_irqrestore(&priv->lock, flags);
13541355
}
13551356

13561357
return work_done;

0 commit comments

Comments
 (0)