]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
can: sun4i_can: sun4i_can_interrupt(): fix max irq loop handling
authorMarc Kleine-Budde <mkl@pengutronix.de>
Sun, 16 Nov 2025 15:55:26 +0000 (16:55 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 17 Nov 2025 16:23:37 +0000 (17:23 +0100)
Reading the interrupt register `SUN4I_REG_INT_ADDR` causes all of its bits
to be reset. If we ever reach the condition of handling more than
`SUN4I_CAN_MAX_IRQ` IRQs, we will have read the register and reset all its
bits but without actually handling the interrupt inside of the loop body.

This may, among other issues, cause us to never `netif_wake_queue()` again
after a transmission interrupt.

Fixes: 0738eff14d81 ("can: Allwinner A10/A20 CAN Controller support - Kernel module")
Cc: stable@vger.kernel.org
Co-developed-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Link: https://patch.msgid.link/20251116-sun4i-fix-loop-v1-1-3d76d3f81950@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/sun4i_can.c

index 53bfd873de9bdecaf6923049007f9efd71289dd3..0a7ba0942839e7cd3e1f70d2a525272dcf2e13d9 100644 (file)
@@ -657,8 +657,8 @@ static irqreturn_t sun4i_can_interrupt(int irq, void *dev_id)
        u8 isrc, status;
        int n = 0;
 
-       while ((isrc = readl(priv->base + SUN4I_REG_INT_ADDR)) &&
-              (n < SUN4I_CAN_MAX_IRQ)) {
+       while ((n < SUN4I_CAN_MAX_IRQ) &&
+              (isrc = readl(priv->base + SUN4I_REG_INT_ADDR))) {
                n++;
                status = readl(priv->base + SUN4I_REG_STA_ADDR);