linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] serial: liteuart: polling all interrupts in the IRQ process
@ 2025-08-26  8:14 Inochi Amaoto
  2025-08-30  9:34 ` Inochi Amaoto
  0 siblings, 1 reply; 2+ messages in thread
From: Inochi Amaoto @ 2025-08-26  8:14 UTC (permalink / raw)
  To: Karol Gugala, Mateusz Holenko, Gabriel Somlo, Joel Stanley,
	Greg Kroah-Hartman, Jiri Slaby
  Cc: Inochi Amaoto, linux-kernel, linux-serial, Yixun Lan, Longbin Li

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.

Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
 drivers/tty/serial/liteuart.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c
index 6429e8f11f36..436e8f06fb75 100644
--- a/drivers/tty/serial/liteuart.c
+++ b/drivers/tty/serial/liteuart.c
@@ -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);
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] serial: liteuart: polling all interrupts in the IRQ process
  2025-08-26  8:14 [PATCH] serial: liteuart: polling all interrupts in the IRQ process Inochi Amaoto
@ 2025-08-30  9:34 ` Inochi Amaoto
  0 siblings, 0 replies; 2+ messages in thread
From: Inochi Amaoto @ 2025-08-30  9:34 UTC (permalink / raw)
  To: Karol Gugala, Mateusz Holenko, Gabriel Somlo, Joel Stanley,
	Greg Kroah-Hartman, Jiri Slaby
  Cc: Inochi Amaoto, linux-kernel, linux-serial, Yixun Lan, Longbin Li

On Tue, Aug 26, 2025 at 04:14:44PM +0800, Inochi Amaoto wrote:
> 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.
> 
> Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
> ---
>  drivers/tty/serial/liteuart.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c
> index 6429e8f11f36..436e8f06fb75 100644
> --- a/drivers/tty/serial/liteuart.c
> +++ b/drivers/tty/serial/liteuart.c
> @@ -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);
> -- 
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-30  9:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-26  8:14 [PATCH] serial: liteuart: polling all interrupts in the IRQ process Inochi Amaoto
2025-08-30  9:34 ` Inochi Amaoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).