[net-next PATCH v4 2/7] net: ravb: Consider busypolling status when re-enabling interrupts

From: Paul Barker
Date: Tue May 28 2024 - 11:06:53 EST


Make use of the busypolling status returned from NAPI complete to decide
if interrupts shall be re-enabled or not. This is useful to reduce the
interrupt overhead.

While at it switch to using napi_complete_done() as it take into account
the work done when providing the busypolling status.

Signed-off-by: Paul Barker <paul.barker.ct@xxxxxxxxxxxxxx>
---
Changes v3->v4:
* Used Niklas' suggested commit message.

drivers/net/ethernet/renesas/ravb_main.c | 26 ++++++++++--------------
1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 193ad05383a8..472aa80002be 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1341,23 +1341,19 @@ static int ravb_poll(struct napi_struct *napi, int budget)
if (priv->rx_fifo_errors != ndev->stats.rx_fifo_errors)
ndev->stats.rx_fifo_errors = priv->rx_fifo_errors;

- if (work_done == budget)
- goto out;
-
- napi_complete(napi);
-
- /* Re-enable RX/TX interrupts */
- spin_lock_irqsave(&priv->lock, flags);
- if (!info->irq_en_dis) {
- ravb_modify(ndev, RIC0, mask, mask);
- ravb_modify(ndev, TIC, mask, mask);
- } else {
- ravb_write(ndev, mask, RIE0);
- ravb_write(ndev, mask, TIE);
+ if (work_done < budget && napi_complete_done(napi, work_done)) {
+ /* Re-enable RX/TX interrupts */
+ spin_lock_irqsave(&priv->lock, flags);
+ if (!info->irq_en_dis) {
+ ravb_modify(ndev, RIC0, mask, mask);
+ ravb_modify(ndev, TIC, mask, mask);
+ } else {
+ ravb_write(ndev, mask, RIE0);
+ ravb_write(ndev, mask, TIE);
+ }
+ spin_unlock_irqrestore(&priv->lock, flags);
}
- spin_unlock_irqrestore(&priv->lock, flags);

-out:
return work_done;
}

--
2.39.2