[PATCH 2/2] net: ethernet: mtk-star-emac: rearm interrupts in rx_poll only when advised

Louis-Alexis Eyraud posted 2 patches 8 months ago
There is a newer version of this series
[PATCH 2/2] net: ethernet: mtk-star-emac: rearm interrupts in rx_poll only when advised
Posted by Louis-Alexis Eyraud 8 months ago
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.

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 41d6af31027f4d827dbfdfecdb7de44326bb3de1..b0ffe9b926c3d8dfaea3e11accae6d01e3ea2c4a 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
Re: [PATCH 2/2] net: ethernet: mtk-star-emac: rearm interrupts in rx_poll only when advised
Posted by Maxime Chevallier 8 months ago
Hi Louis-Alexis,

On Tue, 22 Apr 2025 15:03:39 +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.
> 
> Signed-off-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>

Patch looks correct, however is it fixing a problematic behaviour
you've seen ? I'm asking because it lacks a Fixes: tag, as well as
targetting one of the net/net-next trees :)

Thanks,

Maxime
Re: [PATCH 2/2] net: ethernet: mtk-star-emac: rearm interrupts in rx_poll only when advised
Posted by Louis-Alexis Eyraud 7 months, 4 weeks ago
Hi Maxime,

On Tue, 2025-04-22 at 16:07 +0200, Maxime Chevallier wrote:
> Hi Louis-Alexis,
> 
> On Tue, 22 Apr 2025 15:03:39 +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.
> > 
> > Signed-off-by: Louis-Alexis Eyraud
> > <louisalexis.eyraud@collabora.com>
> 
> Patch looks correct, however is it fixing a problematic behaviour
> you've seen ? I'm asking because it lacks a Fixes: tag, as well as
> targetting one of the net/net-next trees :)
> 
I found the issue by code reading and checking if the sequence is
correct with my other fix. 
It seemed the right way to do in comparison to mtk_star_tx_poll
function that does check napi_complete return code before rearming
interrupts.

Regarding the Fixes tag and subject prefix, I'll also add those in the
v2.

> Thanks,
> 
> Maxime
> 
Regards,

Louis-Alexis