* [PATCH net v2 0/2] net: ethernet: mtk-star-emac: fix several issues on rx/tx poll
@ 2025-04-24 8:38 Louis-Alexis Eyraud
2025-04-24 8:38 ` [PATCH net v2 1/2] net: ethernet: mtk-star-emac: fix spinlock recursion " Louis-Alexis Eyraud
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Louis-Alexis Eyraud @ 2025-04-24 8:38 UTC (permalink / raw)
To: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, Biao Huang,
Yinghua Pan, Bartosz Golaszewski
Cc: kernel, netdev, linux-kernel, linux-arm-kernel, linux-mediatek,
Louis-Alexis Eyraud
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).
Signed-off-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
---
Changes in v2:
- Add missing net subject-prefix for patchs and patchset
- Remove unneeded init for new local variables and order them in reverse
christmas tree
- Add missing Fixes: tag in second patch commit message
- Link to v1: https://lore.kernel.org/r/20250422-mtk_star_emac-fix-spinlock-recursion-issue-v1-0-1e94ea430360@collabora.com
---
Louis-Alexis Eyraud (2):
net: ethernet: mtk-star-emac: fix spinlock recursion issues on rx/tx poll
net: ethernet: mtk-star-emac: rearm interrupts in rx_poll only when advised
drivers/net/ethernet/mediatek/mtk_star_emac.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
---
base-commit: 1d2c58af2b22324cc536113e010d1a38d443f888
change-id: 20250418-mtk_star_emac-fix-spinlock-recursion-issue-4d1c9207cb21
Best regards,
--
Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net v2 1/2] net: ethernet: mtk-star-emac: fix spinlock recursion issues on rx/tx poll
2025-04-24 8:38 [PATCH net v2 0/2] net: ethernet: mtk-star-emac: fix several issues on rx/tx poll Louis-Alexis Eyraud
@ 2025-04-24 8:38 ` Louis-Alexis Eyraud
2025-04-24 9:00 ` Maxime Chevallier
2025-04-24 9:30 ` Bartosz Golaszewski
2025-04-24 8:38 ` [PATCH net v2 2/2] net: ethernet: mtk-star-emac: rearm interrupts in rx_poll only when advised Louis-Alexis Eyraud
2025-04-26 2:20 ` [PATCH net v2 0/2] net: ethernet: mtk-star-emac: fix several issues on rx/tx poll patchwork-bot+netdevbpf
2 siblings, 2 replies; 9+ messages in thread
From: Louis-Alexis Eyraud @ 2025-04-24 8:38 UTC (permalink / raw)
To: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, Biao Huang,
Yinghua Pan, Bartosz Golaszewski
Cc: kernel, netdev, linux-kernel, linux-arm-kernel, linux-mediatek,
Louis-Alexis Eyraud
Use spin_lock_irqsave and spin_unlock_irqrestore instead of spin_lock
and spin_unlock in mtk_star_emac driver to avoid spinlock recursion
occurrence that can happen when enabling the DMA interrupts again in
rx/tx poll.
```
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
```
Fixes: 0a8bd81fd6aa ("net: ethernet: mtk-star-emac: separate tx/rx handling with two NAPIs")
Signed-off-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
---
drivers/net/ethernet/mediatek/mtk_star_emac.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c
index 76f202d7f05537642ec294811ace2ad4a7eae383..23115881d8e892a622b34b593cf38e2c8bed4082 100644
--- a/drivers/net/ethernet/mediatek/mtk_star_emac.c
+++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c
@@ -1163,6 +1163,7 @@ static int mtk_star_tx_poll(struct napi_struct *napi, int budget)
struct net_device *ndev = priv->ndev;
unsigned int head = ring->head;
unsigned int entry = ring->tail;
+ unsigned long flags;
while (entry != head && count < (MTK_STAR_RING_NUM_DESCS - 1)) {
ret = mtk_star_tx_complete_one(priv);
@@ -1182,9 +1183,9 @@ static int mtk_star_tx_poll(struct napi_struct *napi, int budget)
netif_wake_queue(ndev);
if (napi_complete(napi)) {
- spin_lock(&priv->lock);
+ spin_lock_irqsave(&priv->lock, flags);
mtk_star_enable_dma_irq(priv, false, true);
- spin_unlock(&priv->lock);
+ spin_unlock_irqrestore(&priv->lock, flags);
}
return 0;
@@ -1341,6 +1342,7 @@ static int mtk_star_rx(struct mtk_star_priv *priv, int budget)
static int mtk_star_rx_poll(struct napi_struct *napi, int budget)
{
struct mtk_star_priv *priv;
+ unsigned long flags;
int work_done = 0;
priv = container_of(napi, struct mtk_star_priv, rx_napi);
@@ -1348,9 +1350,9 @@ static int mtk_star_rx_poll(struct napi_struct *napi, int budget)
work_done = mtk_star_rx(priv, budget);
if (work_done < budget) {
napi_complete_done(napi, work_done);
- spin_lock(&priv->lock);
+ spin_lock_irqsave(&priv->lock, flags);
mtk_star_enable_dma_irq(priv, true, false);
- spin_unlock(&priv->lock);
+ spin_unlock_irqrestore(&priv->lock, flags);
}
return work_done;
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net v2 2/2] net: ethernet: mtk-star-emac: rearm interrupts in rx_poll only when advised
2025-04-24 8:38 [PATCH net v2 0/2] net: ethernet: mtk-star-emac: fix several issues on rx/tx poll Louis-Alexis Eyraud
2025-04-24 8:38 ` [PATCH net v2 1/2] net: ethernet: mtk-star-emac: fix spinlock recursion " Louis-Alexis Eyraud
@ 2025-04-24 8:38 ` Louis-Alexis Eyraud
2025-04-24 9:16 ` Maxime Chevallier
2025-04-24 9:31 ` Bartosz Golaszewski
2025-04-26 2:20 ` [PATCH net v2 0/2] net: ethernet: mtk-star-emac: fix several issues on rx/tx poll patchwork-bot+netdevbpf
2 siblings, 2 replies; 9+ messages in thread
From: Louis-Alexis Eyraud @ 2025-04-24 8:38 UTC (permalink / raw)
To: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, Biao Huang,
Yinghua Pan, Bartosz Golaszewski
Cc: kernel, netdev, linux-kernel, linux-arm-kernel, linux-mediatek,
Louis-Alexis Eyraud
In mtk_star_rx_poll function, on event processing completion, the
mtk_star_emac driver calls napi_complete_done but ignores its return
code and enable RX DMA interrupts inconditionally. This return code
gives the info if a device should avoid rearming its interrupts or not,
so fix this behaviour by taking it into account.
Fixes: 8c7bd5a454ff ("net: ethernet: mtk-star-emac: new driver")
Signed-off-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
---
drivers/net/ethernet/mediatek/mtk_star_emac.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c
index 23115881d8e892a622b34b593cf38e2c8bed4082..b175119a6a7da517f20267fde7b2005d6c0bbadd 100644
--- a/drivers/net/ethernet/mediatek/mtk_star_emac.c
+++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c
@@ -1348,8 +1348,7 @@ static int mtk_star_rx_poll(struct napi_struct *napi, int budget)
priv = container_of(napi, struct mtk_star_priv, rx_napi);
work_done = mtk_star_rx(priv, budget);
- if (work_done < budget) {
- napi_complete_done(napi, work_done);
+ if (work_done < budget && napi_complete_done(napi, work_done)) {
spin_lock_irqsave(&priv->lock, flags);
mtk_star_enable_dma_irq(priv, true, false);
spin_unlock_irqrestore(&priv->lock, flags);
--
2.49.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net v2 1/2] net: ethernet: mtk-star-emac: fix spinlock recursion issues on rx/tx poll
2025-04-24 8:38 ` [PATCH net v2 1/2] net: ethernet: mtk-star-emac: fix spinlock recursion " Louis-Alexis Eyraud
@ 2025-04-24 9:00 ` Maxime Chevallier
2025-04-24 9:30 ` Bartosz Golaszewski
1 sibling, 0 replies; 9+ messages in thread
From: Maxime Chevallier @ 2025-04-24 9:00 UTC (permalink / raw)
To: Louis-Alexis Eyraud
Cc: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, Biao Huang,
Yinghua Pan, Bartosz Golaszewski, kernel, netdev, linux-kernel,
linux-arm-kernel, linux-mediatek
On Thu, 24 Apr 2025 10:38:48 +0200
Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com> wrote:
> Use spin_lock_irqsave and spin_unlock_irqrestore instead of spin_lock
> and spin_unlock in mtk_star_emac driver to avoid spinlock recursion
> occurrence that can happen when enabling the DMA interrupts again in
> rx/tx poll.
>
> ```
> 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
> ```
>
> Fixes: 0a8bd81fd6aa ("net: ethernet: mtk-star-emac: separate tx/rx handling with two NAPIs")
> Signed-off-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
> ---
This looks correct to me,
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Maxime
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v2 2/2] net: ethernet: mtk-star-emac: rearm interrupts in rx_poll only when advised
2025-04-24 8:38 ` [PATCH net v2 2/2] net: ethernet: mtk-star-emac: rearm interrupts in rx_poll only when advised Louis-Alexis Eyraud
@ 2025-04-24 9:16 ` Maxime Chevallier
2025-04-26 2:13 ` Jakub Kicinski
2025-04-24 9:31 ` Bartosz Golaszewski
1 sibling, 1 reply; 9+ messages in thread
From: Maxime Chevallier @ 2025-04-24 9:16 UTC (permalink / raw)
To: Louis-Alexis Eyraud
Cc: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, Biao Huang,
Yinghua Pan, Bartosz Golaszewski, kernel, netdev, linux-kernel,
linux-arm-kernel, linux-mediatek
Hi,
On Thu, 24 Apr 2025 10:38:49 +0200
Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com> wrote:
> In mtk_star_rx_poll function, on event processing completion, the
> mtk_star_emac driver calls napi_complete_done but ignores its return
> code and enable RX DMA interrupts inconditionally. This return code
> gives the info if a device should avoid rearming its interrupts or not,
> so fix this behaviour by taking it into account.
>
> Fixes: 8c7bd5a454ff ("net: ethernet: mtk-star-emac: new driver")
> Signed-off-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
I'm unsure wether this counts as a bugfix, as no bug was
seen, and there are quite a few divers that already ignore the return
from napi_complete_done().
I don't think the patch is wrong, but maybe it should be sent to
net-next :/
Maxime
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v2 1/2] net: ethernet: mtk-star-emac: fix spinlock recursion issues on rx/tx poll
2025-04-24 8:38 ` [PATCH net v2 1/2] net: ethernet: mtk-star-emac: fix spinlock recursion " Louis-Alexis Eyraud
2025-04-24 9:00 ` Maxime Chevallier
@ 2025-04-24 9:30 ` Bartosz Golaszewski
1 sibling, 0 replies; 9+ messages in thread
From: Bartosz Golaszewski @ 2025-04-24 9:30 UTC (permalink / raw)
To: Louis-Alexis Eyraud
Cc: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, Biao Huang,
Yinghua Pan, kernel, netdev, linux-kernel, linux-arm-kernel,
linux-mediatek
On Thu, Apr 24, 2025 at 10:40 AM Louis-Alexis Eyraud
<louisalexis.eyraud@collabora.com> wrote:
>
> Use spin_lock_irqsave and spin_unlock_irqrestore instead of spin_lock
> and spin_unlock in mtk_star_emac driver to avoid spinlock recursion
> occurrence that can happen when enabling the DMA interrupts again in
> rx/tx poll.
>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v2 2/2] net: ethernet: mtk-star-emac: rearm interrupts in rx_poll only when advised
2025-04-24 8:38 ` [PATCH net v2 2/2] net: ethernet: mtk-star-emac: rearm interrupts in rx_poll only when advised Louis-Alexis Eyraud
2025-04-24 9:16 ` Maxime Chevallier
@ 2025-04-24 9:31 ` Bartosz Golaszewski
1 sibling, 0 replies; 9+ messages in thread
From: Bartosz Golaszewski @ 2025-04-24 9:31 UTC (permalink / raw)
To: Louis-Alexis Eyraud
Cc: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, Biao Huang,
Yinghua Pan, kernel, netdev, linux-kernel, linux-arm-kernel,
linux-mediatek
On Thu, Apr 24, 2025 at 10:40 AM Louis-Alexis Eyraud
<louisalexis.eyraud@collabora.com> wrote:
>
> In mtk_star_rx_poll function, on event processing completion, the
> mtk_star_emac driver calls napi_complete_done but ignores its return
> code and enable RX DMA interrupts inconditionally. This return code
> gives the info if a device should avoid rearming its interrupts or not,
> so fix this behaviour by taking it into account.
>
> Fixes: 8c7bd5a454ff ("net: ethernet: mtk-star-emac: new driver")
> Signed-off-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
> ---
> drivers/net/ethernet/mediatek/mtk_star_emac.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c
> index 23115881d8e892a622b34b593cf38e2c8bed4082..b175119a6a7da517f20267fde7b2005d6c0bbadd 100644
> --- a/drivers/net/ethernet/mediatek/mtk_star_emac.c
> +++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c
> @@ -1348,8 +1348,7 @@ static int mtk_star_rx_poll(struct napi_struct *napi, int budget)
> priv = container_of(napi, struct mtk_star_priv, rx_napi);
>
> work_done = mtk_star_rx(priv, budget);
> - if (work_done < budget) {
> - napi_complete_done(napi, work_done);
> + if (work_done < budget && napi_complete_done(napi, work_done)) {
> spin_lock_irqsave(&priv->lock, flags);
> mtk_star_enable_dma_irq(priv, true, false);
> spin_unlock_irqrestore(&priv->lock, flags);
>
> --
> 2.49.0
>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v2 2/2] net: ethernet: mtk-star-emac: rearm interrupts in rx_poll only when advised
2025-04-24 9:16 ` Maxime Chevallier
@ 2025-04-26 2:13 ` Jakub Kicinski
0 siblings, 0 replies; 9+ messages in thread
From: Jakub Kicinski @ 2025-04-26 2:13 UTC (permalink / raw)
To: Maxime Chevallier
Cc: Louis-Alexis Eyraud, Felix Fietkau, Sean Wang, Lorenzo Bianconi,
Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, Biao Huang,
Yinghua Pan, Bartosz Golaszewski, kernel, netdev, linux-kernel,
linux-arm-kernel, linux-mediatek
On Thu, 24 Apr 2025 11:16:23 +0200 Maxime Chevallier wrote:
> > In mtk_star_rx_poll function, on event processing completion, the
> > mtk_star_emac driver calls napi_complete_done but ignores its return
> > code and enable RX DMA interrupts inconditionally. This return code
> > gives the info if a device should avoid rearming its interrupts or not,
> > so fix this behaviour by taking it into account.
> >
> > Fixes: 8c7bd5a454ff ("net: ethernet: mtk-star-emac: new driver")
> > Signed-off-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
>
> I'm unsure wether this counts as a bugfix, as no bug was
> seen, and there are quite a few divers that already ignore the return
> from napi_complete_done().
>
> I don't think the patch is wrong, but maybe it should be sent to
> net-next :/
Agreed, probably the only case where it would matter would be busy
polling. But it's trivial and looks correct, so probably not worth
the respin
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net v2 0/2] net: ethernet: mtk-star-emac: fix several issues on rx/tx poll
2025-04-24 8:38 [PATCH net v2 0/2] net: ethernet: mtk-star-emac: fix several issues on rx/tx poll Louis-Alexis Eyraud
2025-04-24 8:38 ` [PATCH net v2 1/2] net: ethernet: mtk-star-emac: fix spinlock recursion " Louis-Alexis Eyraud
2025-04-24 8:38 ` [PATCH net v2 2/2] net: ethernet: mtk-star-emac: rearm interrupts in rx_poll only when advised Louis-Alexis Eyraud
@ 2025-04-26 2:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 9+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-26 2:20 UTC (permalink / raw)
To: Louis-Alexis Eyraud
Cc: nbd, sean.wang, lorenzo, andrew+netdev, davem, edumazet, kuba,
pabeni, matthias.bgg, angelogioacchino.delregno, biao.huang,
ot_yinghua.pan, brgl, kernel, netdev, linux-kernel,
linux-arm-kernel, linux-mediatek
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 24 Apr 2025 10:38:47 +0200 you wrote:
> 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
> ```
>
> [...]
Here is the summary with links:
- [net,v2,1/2] net: ethernet: mtk-star-emac: fix spinlock recursion issues on rx/tx poll
https://git.kernel.org/netdev/net/c/6fe086601448
- [net,v2,2/2] net: ethernet: mtk-star-emac: rearm interrupts in rx_poll only when advised
https://git.kernel.org/netdev/net/c/e54b4db35e20
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-04-26 2:19 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-24 8:38 [PATCH net v2 0/2] net: ethernet: mtk-star-emac: fix several issues on rx/tx poll Louis-Alexis Eyraud
2025-04-24 8:38 ` [PATCH net v2 1/2] net: ethernet: mtk-star-emac: fix spinlock recursion " Louis-Alexis Eyraud
2025-04-24 9:00 ` Maxime Chevallier
2025-04-24 9:30 ` Bartosz Golaszewski
2025-04-24 8:38 ` [PATCH net v2 2/2] net: ethernet: mtk-star-emac: rearm interrupts in rx_poll only when advised Louis-Alexis Eyraud
2025-04-24 9:16 ` Maxime Chevallier
2025-04-26 2:13 ` Jakub Kicinski
2025-04-24 9:31 ` Bartosz Golaszewski
2025-04-26 2:20 ` [PATCH net v2 0/2] net: ethernet: mtk-star-emac: fix several issues on rx/tx poll patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).