* [PATCH v3] serial: max310x: improve interrupt handling
@ 2025-09-08 6:53 Tapio Reijonen
2025-09-08 6:57 ` Jiri Slaby
2025-09-08 13:53 ` Hugo Villeneuve
0 siblings, 2 replies; 3+ messages in thread
From: Tapio Reijonen @ 2025-09-08 6:53 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Alexander Shiyan, Hugo Villeneuve
Cc: linux-kernel, linux-serial, Tapio Reijonen
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>
---
Changes in v3:
- Change variable port to unsigned int
- Use varible bool to stop while loop
- Link to v2: https://lore.kernel.org/r/20250905-master-max310x-improve-interrupt-handling-v2-1-7387651a5ed2@vaisala.com
Changes in v2:
- Improve content of the commit message
- Fix a line indention in prevoius patch
- According review comments, changed to use for_each_clear_bit
to simplify serve all IRQs in a loop.
NOTE: When a bit in IRQ[n] is set 0 the associated UART’s
internal IRQ is generated.
- Link to v1: https://lore.kernel.org/r/20250903-master-max310x-improve-interrupt-handling-v1-1-bfb44829e760@vaisala.com
---
drivers/tty/serial/max310x.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index ce260e9949c3c268e706b2615d6fc01adc21e49b..e3af381b1702ad7df7a7911030c958d07933fe43 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -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;
---
base-commit: c8bc81a52d5a2ac2e4b257ae123677cf94112755
change-id: 20250903-master-max310x-improve-interrupt-handling-aa22b7ba1c1d
Best regards,
--
Tapio Reijonen <tapio.reijonen@vaisala.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] serial: max310x: improve interrupt handling
2025-09-08 6:53 [PATCH v3] serial: max310x: improve interrupt handling Tapio Reijonen
@ 2025-09-08 6:57 ` Jiri Slaby
2025-09-08 13:53 ` Hugo Villeneuve
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Slaby @ 2025-09-08 6:57 UTC (permalink / raw)
To: Tapio Reijonen, Greg Kroah-Hartman, Alexander Shiyan,
Hugo Villeneuve
Cc: linux-kernel, linux-serial
On 08. 09. 25, 8:53, Tapio Reijonen wrote:
> 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>
Looks/Reads much better now.
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
--
js
suse labs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] serial: max310x: improve interrupt handling
2025-09-08 6:53 [PATCH v3] serial: max310x: improve interrupt handling Tapio Reijonen
2025-09-08 6:57 ` Jiri Slaby
@ 2025-09-08 13:53 ` Hugo Villeneuve
1 sibling, 0 replies; 3+ messages in thread
From: Hugo Villeneuve @ 2025-09-08 13:53 UTC (permalink / raw)
To: Tapio Reijonen
Cc: Greg Kroah-Hartman, Jiri Slaby, Alexander Shiyan, Hugo Villeneuve,
linux-kernel, linux-serial
On Mon, 08 Sep 2025 06:53:43 +0000
Tapio Reijonen <tapio.reijonen@vaisala.com> wrote:
> 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: Hugo Villeneuve <hvilleneuve@dimonoff.com>
--
Hugo Villeneuve
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-08 13:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-08 6:53 [PATCH v3] serial: max310x: improve interrupt handling Tapio Reijonen
2025-09-08 6:57 ` Jiri Slaby
2025-09-08 13:53 ` Hugo Villeneuve
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox