Skip to contentSkip to conversation

serial: liteuart: polling all interrupts in the IRQ process

PATCH In review Inochi Amaoto 1 participant 2 messages Aug 26, 2025 – Aug 30, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: liteuart: polling all interrupts in the IRQ process

When using liteuart with aplic and imsic, the new interrupt will lost if the interrupt handler can not handle all the data. This is simply because the interrupt line will never be low, and the aplic will not send the interrupt to imsic again.

Handle all data in the IRQ handler until no data incoming.

---
 drivers/tty/serial/liteuart.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/tty/serial/liteuart.c +11 -5
index 6429e8f11f36..436e8f06fb75 100644
@@ -140,11 +140,17 @@ static irqreturn_t liteuart_interrupt(int irq, void *data)
 	 * irq[save|restore] spin_lock variants to cover all possibilities
 	 */
 	uart_port_lock_irqsave(port, &flags);
-	isr = litex_read8(port->membase + OFF_EV_PENDING) & uart->irq_reg;
-	if (isr & EV_RX)
-		liteuart_rx_chars(port);
-	if (isr & EV_TX)
-		liteuart_tx_chars(port);
+
+	isr = litex_read8(port->membase + OFF_EV_PENDING);
+
+	while (isr & uart->irq_reg) {
+		if (isr & EV_RX)
+			liteuart_rx_chars(port);
+		if (isr & EV_TX)
+			liteuart_tx_chars(port);
+		isr = litex_read8(port->membase + OFF_EV_PENDING);
+	}
+
 	uart_port_unlock_irqrestore(port, flags);
 
 	return IRQ_RETVAL(isr);
Signature · 1 line
2.51.0
#1 lore raw
Quoted 42 lines · Inochi Amaoto

When using liteuart with aplic and imsic, the new interrupt will lost if the interrupt handler can not handle all the data. This is simply because the interrupt line will never be low, and the aplic will not send the interrupt to imsic again.

Handle all data in the IRQ handler until no data incoming.

---
 drivers/tty/serial/liteuart.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/tty/serial/liteuart.c +11 -5
index 6429e8f11f36..436e8f06fb75 100644
@@ -140,11 +140,17 @@ static irqreturn_t liteuart_interrupt(int irq, void *data)
 	 * irq[save|restore] spin_lock variants to cover all possibilities
 	 */
 	uart_port_lock_irqsave(port, &flags);
-	isr = litex_read8(port->membase + OFF_EV_PENDING) & uart->irq_reg;
-	if (isr & EV_RX)
-		liteuart_rx_chars(port);
-	if (isr & EV_TX)
-		liteuart_tx_chars(port);
+
+	isr = litex_read8(port->membase + OFF_EV_PENDING);
+
+	while (isr & uart->irq_reg) {
+		if (isr & EV_RX)
+			liteuart_rx_chars(port);
+		if (isr & EV_TX)
+			liteuart_tx_chars(port);
+		isr = litex_read8(port->membase + OFF_EV_PENDING);
+	}
+
 	uart_port_unlock_irqrestore(port, flags);
 
 	return IRQ_RETVAL(isr);
Signature · 1 line
2.51.0

Just ignore this patch. The problem is caused by our incorrect hardware implementation. And everything works fine as the hardware is fixed.

Regards
Inochi