]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
net: ethernet: mediatek: disable irq before schedule napi
authorChristian Marangi <ansuelsmth@gmail.com>
Mon, 2 Oct 2023 14:08:05 +0000 (16:08 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 5 Oct 2023 11:36:12 +0000 (13:36 +0200)
While searching for possible refactor of napi_schedule_prep and
__napi_schedule it was notice that the mtk eth driver disable the
interrupt for rx and tx AFTER napi is scheduled.

While this is a very hard to repro case it might happen to have
situation where the interrupt is disabled and never enabled again as the
napi completes and the interrupt is enabled before.

This is caused by the fact that a napi driven by interrupt expect a
logic with:
1. interrupt received. napi prepared -> interrupt disabled -> napi
   scheduled
2. napi triggered. ring cleared -> interrupt enabled -> wait for new
   interrupt

To prevent this case, disable the interrupt BEFORE the napi is
scheduled.

Fixes: 656e705243fd ("net-next: mediatek: add support for MT7623 ethernet")
Cc: stable@vger.kernel.org
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Link: https://lore.kernel.org/r/20231002140805.568-1-ansuelsmth@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/mediatek/mtk_eth_soc.c

index 3cffd1bd306777e5a79ff23a47558622d9e8d82d..20afe79f380a240c55bb6c3d06a0bd614046f70c 100644 (file)
@@ -3171,8 +3171,8 @@ static irqreturn_t mtk_handle_irq_rx(int irq, void *_eth)
 
        eth->rx_events++;
        if (likely(napi_schedule_prep(&eth->rx_napi))) {
-               __napi_schedule(&eth->rx_napi);
                mtk_rx_irq_disable(eth, eth->soc->txrx.rx_irq_done_mask);
+               __napi_schedule(&eth->rx_napi);
        }
 
        return IRQ_HANDLED;
@@ -3184,8 +3184,8 @@ static irqreturn_t mtk_handle_irq_tx(int irq, void *_eth)
 
        eth->tx_events++;
        if (likely(napi_schedule_prep(&eth->tx_napi))) {
-               __napi_schedule(&eth->tx_napi);
                mtk_tx_irq_disable(eth, MTK_TX_DONE_INT);
+               __napi_schedule(&eth->tx_napi);
        }
 
        return IRQ_HANDLED;