net: tc35815: rework network interface interrupt logic
authorChristian Marangi <ansuelsmth@gmail.com>
Mon, 9 Oct 2023 13:37:53 +0000 (15:37 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 12 Oct 2023 00:28:06 +0000 (17:28 -0700)
Rework network interface logic. Before this change, the code flow was:
1. Disable interrupt
2. Try to schedule a NAPI
3. Check if it was possible (NAPI is not already scheduled)
4. emit BUG() if we receive interrupt while a NAPI is scheduled

If some application busy poll or set gro_flush_timeout low enough, it's
possible to reach the BUG() condition. Given that the condition may
happen and it wouldn't be a bug, rework the logic to permit such case
and prevent stall with interrupt never enabled again.

Disable the interrupt only if the NAPI can be scheduled (aka it's not
already scheduled) and drop the printk and BUG() call. With these
change, in the event of a NAPI already scheduled, the interrupt is
simply ignored with nothing done.

Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Link: https://lore.kernel.org/r/20231009133754.9834-4-ansuelsmth@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/toshiba/tc35815.c

index 14cf6ecf6d0df3fa6991118c9253fba6e47e2cd1..6e3758dfbdbd2654cb3931183a2385b86e7a6ec0 100644 (file)
@@ -1434,14 +1434,10 @@ static irqreturn_t tc35815_interrupt(int irq, void *dev_id)
        u32 dmactl = tc_readl(&tr->DMA_Ctl);
 
        if (!(dmactl & DMA_IntMask)) {
-               /* disable interrupts */
-               tc_writel(dmactl | DMA_IntMask, &tr->DMA_Ctl);
-               if (napi_schedule_prep(&lp->napi))
+               if (napi_schedule_prep(&lp->napi)) {
+                       /* disable interrupts */
+                       tc_writel(dmactl | DMA_IntMask, &tr->DMA_Ctl);
                        __napi_schedule(&lp->napi);
-               else {
-                       printk(KERN_ERR "%s: interrupt taken in poll\n",
-                              dev->name);
-                       BUG();
                }
                (void)tc_readl(&tr->Int_Src);   /* flush */
                return IRQ_HANDLED;