]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
serial: max310x: improve interrupt handling
authorTapio Reijonen <tapio.reijonen@vaisala.com>
Mon, 8 Sep 2025 06:53:43 +0000 (06:53 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 12 Sep 2025 14:10:16 +0000 (16:10 +0200)
When there is a heavy load of receiving characters to all
four UART's, the warning 'Hardware RX FIFO overrun' is
sometimes detected.
The current implementation always service first the highest UART
until no more interrupt and then service another UART
(ex: UART3 will be serviced for as long as there are interrupts
for it, then UART2, etc).

This commit handle all individual interrupt sources before
reading the global IRQ register again.

This commit has also a nice side-effect of improving the efficiency
of the driver by reducing the number of reads of the global
IRQ register.

Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Reviewed-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Link: https://lore.kernel.org/r/20250908-master-max310x-improve-interrupt-handling-v3-1-91985e82ba39@vaisala.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/max310x.c

index e8749b8629703b55e47a03c6df996e7e641983d6..ac7d3f197c3a5ce3531d5607f48e21a807314021 100644 (file)
@@ -823,17 +823,28 @@ static irqreturn_t max310x_ist(int irq, void *dev_id)
        bool handled = false;
 
        if (s->devtype->nr > 1) {
+               bool done;
+
                do {
                        unsigned int val = ~0;
+                       unsigned long irq;
+                       unsigned int port;
+
+                       done = true;
 
                        WARN_ON_ONCE(regmap_read(s->regmap,
                                                 MAX310X_GLOBALIRQ_REG, &val));
-                       val = ((1 << s->devtype->nr) - 1) & ~val;
-                       if (!val)
-                               break;
-                       if (max310x_port_irq(s, fls(val) - 1) == IRQ_HANDLED)
-                               handled = true;
-               } while (1);
+
+                       irq = val;
+
+                       for_each_clear_bit(port, &irq, s->devtype->nr) {
+                               done = false;
+
+                               if (max310x_port_irq(s, port) == IRQ_HANDLED)
+                                       handled = true;
+                       }
+
+               } while (!done);
        } else {
                if (max310x_port_irq(s, 0) == IRQ_HANDLED)
                        handled = true;