From: Janis Edvarts Lacis <janislacis06@gmail.com>
To: netdev@vger.kernel.org
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, wellslutw@gmail.com,
linux-kernel@vger.kernel.org,
Janis Edvarts Lacis <janislacis06@gmail.com>
Subject: [PATCH net] net: ethernet: sunplus: check budget before calling napi_complete_done()
Date: Sun, 15 Nov 2026 00:27:44 +0200 [thread overview]
Message-ID: <20261114222744.535158-1-janislacis06@gmail.com> (raw)
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
reply other threads:[~2026-11-14 22:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261114222744.535158-1-janislacis06@gmail.com \
--to=janislacis06@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wellslutw@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®