* [PATCH net] net: ethernet: sunplus: check budget before calling napi_complete_done()
@ 2026-11-14 22:27 Janis Edvarts Lacis
0 siblings, 0 replies; only message in thread
From: Janis Edvarts Lacis @ 2026-11-14 22:27 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, wellslutw,
linux-kernel, Janis Edvarts Lacis
Sunplus drivers currently do napi_complete() after each rx/tx poll is
done without checking whether budget was exhausted or not. Interrupts
are also unmasked before the call to napi_complete().
Replace napi_complete() with napi_complete_done() and add a check for
budget_left. Call napi_complete_done() only when the budget has been
not exhausted fully, e.g. budget_left > 0 and unmask interrupts only when
napi_complete_done() returns true.
I do not have the hardware necessary, this patch is not tested on real
hardware.
Fixes: fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021")
Signed-off-by: Janis Edvarts Lacis <janislacis06@gmail.com>
---
drivers/net/ethernet/sunplus/spl2sw_int.c | 26 ++++++++++++-----------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/sunplus/spl2sw_int.c b/drivers/net/ethernet/sunplus/spl2sw_int.c
index a37c9a4c281f..1aada11429d4 100644
--- a/drivers/net/ethernet/sunplus/spl2sw_int.c
+++ b/drivers/net/ethernet/sunplus/spl2sw_int.c
@@ -125,13 +125,14 @@ int spl2sw_rx_poll(struct napi_struct *napi, int budget)
h_desc = comm->rx_desc[queue] + rx_pos;
}
- spin_lock_irqsave(&comm->int_mask_lock, flags);
- mask = readl(comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
- mask &= ~MAC_INT_RX;
- writel(mask, comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
- spin_unlock_irqrestore(&comm->int_mask_lock, flags);
+ if (budget_left > 0 && napi_complete_done(napi, budget - budget_left)) {
+ spin_lock_irqsave(&comm->int_mask_lock, flags);
+ mask = readl(comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
+ mask &= ~MAC_INT_RX;
+ writel(mask, comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
+ spin_unlock_irqrestore(&comm->int_mask_lock, flags);
+ }
- napi_complete(napi);
return budget - budget_left;
}
@@ -198,13 +199,14 @@ int spl2sw_tx_poll(struct napi_struct *napi, int budget)
spin_unlock(&comm->tx_lock);
- spin_lock_irqsave(&comm->int_mask_lock, flags);
- mask = readl(comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
- mask &= ~MAC_INT_TX;
- writel(mask, comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
- spin_unlock_irqrestore(&comm->int_mask_lock, flags);
+ if (budget_left > 0 && napi_complete_done(napi, budget - budget_left)) {
+ spin_lock_irqsave(&comm->int_mask_lock, flags);
+ mask = readl(comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
+ mask &= ~MAC_INT_TX;
+ writel(mask, comm->l2sw_reg_base + L2SW_SW_INT_MASK_0);
+ spin_unlock_irqrestore(&comm->int_mask_lock, flags);
+ }
- napi_complete(napi);
return budget - budget_left;
}
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-14 22:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-14 22:27 [PATCH net] net: ethernet: sunplus: check budget before calling napi_complete_done() Janis Edvarts Lacis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®