Commit 13c78532 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Greg Kroah-Hartman

serial: stm32: Return IRQ_NONE in the ISR if no handling happend

If there is a stuck irq that the handler doesn't address, returning
IRQ_HANDLED unconditionally makes it impossible for the irq core to
detect the problem and disable the irq. So only return IRQ_HANDLED if
an event was handled.

A stuck irq is still problematic, but with this change at least it only
makes the UART nonfunctional instead of occupying the (usually only) CPU
by 100% and so stall the whole machine.

Fixes: 48a6092f ("serial: stm32-usart: Add STM32 USART Driver")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/5f92603d0dfd8a5b8014b2b10a902d91e0bb881f.1713344161.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1aa4ad4e
...@@ -861,6 +861,7 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr) ...@@ -861,6 +861,7 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
u32 sr; u32 sr;
unsigned int size; unsigned int size;
irqreturn_t ret = IRQ_NONE;
sr = readl_relaxed(port->membase + ofs->isr); sr = readl_relaxed(port->membase + ofs->isr);
...@@ -869,11 +870,14 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr) ...@@ -869,11 +870,14 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
(sr & USART_SR_TC)) { (sr & USART_SR_TC)) {
stm32_usart_tc_interrupt_disable(port); stm32_usart_tc_interrupt_disable(port);
stm32_usart_rs485_rts_disable(port); stm32_usart_rs485_rts_disable(port);
ret = IRQ_HANDLED;
} }
if ((sr & USART_SR_RTOF) && ofs->icr != UNDEF_REG) if ((sr & USART_SR_RTOF) && ofs->icr != UNDEF_REG) {
writel_relaxed(USART_ICR_RTOCF, writel_relaxed(USART_ICR_RTOCF,
port->membase + ofs->icr); port->membase + ofs->icr);
ret = IRQ_HANDLED;
}
if ((sr & USART_SR_WUF) && ofs->icr != UNDEF_REG) { if ((sr & USART_SR_WUF) && ofs->icr != UNDEF_REG) {
/* Clear wake up flag and disable wake up interrupt */ /* Clear wake up flag and disable wake up interrupt */
...@@ -882,6 +886,7 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr) ...@@ -882,6 +886,7 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_WUFIE); stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_WUFIE);
if (irqd_is_wakeup_set(irq_get_irq_data(port->irq))) if (irqd_is_wakeup_set(irq_get_irq_data(port->irq)))
pm_wakeup_event(tport->tty->dev, 0); pm_wakeup_event(tport->tty->dev, 0);
ret = IRQ_HANDLED;
} }
/* /*
...@@ -896,6 +901,7 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr) ...@@ -896,6 +901,7 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
uart_unlock_and_check_sysrq(port); uart_unlock_and_check_sysrq(port);
if (size) if (size)
tty_flip_buffer_push(tport); tty_flip_buffer_push(tport);
ret = IRQ_HANDLED;
} }
} }
...@@ -903,6 +909,7 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr) ...@@ -903,6 +909,7 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
uart_port_lock(port); uart_port_lock(port);
stm32_usart_transmit_chars(port); stm32_usart_transmit_chars(port);
uart_port_unlock(port); uart_port_unlock(port);
ret = IRQ_HANDLED;
} }
/* Receiver timeout irq for DMA RX */ /* Receiver timeout irq for DMA RX */
...@@ -912,9 +919,10 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr) ...@@ -912,9 +919,10 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
uart_unlock_and_check_sysrq(port); uart_unlock_and_check_sysrq(port);
if (size) if (size)
tty_flip_buffer_push(tport); tty_flip_buffer_push(tport);
ret = IRQ_HANDLED;
} }
return IRQ_HANDLED; return ret;
} }
static void stm32_usart_set_mctrl(struct uart_port *port, unsigned int mctrl) static void stm32_usart_set_mctrl(struct uart_port *port, unsigned int mctrl)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment