diff mbox series

[net-next,12/14] net: ethernet: mtk_eth_soc: reduce unnecessary interrupts

Message ID 20210422040914.47788-13-ilya.lipnitskiy@gmail.com (mailing list archive)
State New, archived
Headers show
Series mtk_eth_soc: fixes and performance improvements | expand

Commit Message

Ilya Lipnitskiy April 22, 2021, 4:09 a.m. UTC
From: Felix Fietkau <nbd@nbd.name>

Avoid rearming interrupt if napi_complete returns false

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Jakub Kicinski April 22, 2021, 4:26 p.m. UTC | #1
On Wed, 21 Apr 2021 21:09:12 -0700 Ilya Lipnitskiy wrote:
> @@ -1551,8 +1551,9 @@ static int mtk_napi_rx(struct napi_struct *napi, int budget)
>  		remain_budget -= rx_done;
>  		goto poll_again;
>  	}
> -	napi_complete(napi);
> -	mtk_rx_irq_enable(eth, MTK_RX_DONE_INT);
> +
> +	if (napi_complete(napi))
> +		mtk_rx_irq_enable(eth, MTK_RX_DONE_INT);

Why not napi_complete_done(napi, rx_done + budget - remain_budget)?
(Modulo possible elimination of rx_done in this function.)
Ilya Lipnitskiy April 23, 2021, 4:20 a.m. UTC | #2
On Thu, Apr 22, 2021 at 9:26 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Wed, 21 Apr 2021 21:09:12 -0700 Ilya Lipnitskiy wrote:
> > @@ -1551,8 +1551,9 @@ static int mtk_napi_rx(struct napi_struct *napi, int budget)
> >               remain_budget -= rx_done;
> >               goto poll_again;
> >       }
> > -     napi_complete(napi);
> > -     mtk_rx_irq_enable(eth, MTK_RX_DONE_INT);
> > +
> > +     if (napi_complete(napi))
> > +             mtk_rx_irq_enable(eth, MTK_RX_DONE_INT);
>
> Why not napi_complete_done(napi, rx_done + budget - remain_budget)?
> (Modulo possible elimination of rx_done in this function.)
No reason, I think. Thanks for pointing it out. I will clean up both
TX and RX NAPI callbacks to use napi_complete_done and to get rid of
that ugly goto...

Ilya
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 5a531bb83348..88a437f478fd 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1517,8 +1517,8 @@  static int mtk_napi_tx(struct napi_struct *napi, int budget)
 	if (status & MTK_TX_DONE_INT)
 		return budget;
 
-	napi_complete(napi);
-	mtk_tx_irq_enable(eth, MTK_TX_DONE_INT);
+	if (napi_complete(napi))
+		mtk_tx_irq_enable(eth, MTK_TX_DONE_INT);
 
 	return tx_done;
 }
@@ -1551,8 +1551,9 @@  static int mtk_napi_rx(struct napi_struct *napi, int budget)
 		remain_budget -= rx_done;
 		goto poll_again;
 	}
-	napi_complete(napi);
-	mtk_rx_irq_enable(eth, MTK_RX_DONE_INT);
+
+	if (napi_complete(napi))
+		mtk_rx_irq_enable(eth, MTK_RX_DONE_INT);
 
 	return rx_done + budget - remain_budget;
 }