Skip to content

Commit 13c7853

Browse files
Uwe Kleine-Königgregkh
authored andcommitted
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: 48a6092 ("serial: stm32-usart: Add STM32 USART Driver") Cc: stable@vger.kernel.org Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/5f92603d0dfd8a5b8014b2b10a902d91e0bb881f.1713344161.git.u.kleine-koenig@pengutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1aa4ad4 commit 13c7853

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/tty/serial/stm32-usart.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
861861
const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
862862
u32 sr;
863863
unsigned int size;
864+
irqreturn_t ret = IRQ_NONE;
864865

865866
sr = readl_relaxed(port->membase + ofs->isr);
866867

@@ -869,11 +870,14 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
869870
(sr & USART_SR_TC)) {
870871
stm32_usart_tc_interrupt_disable(port);
871872
stm32_usart_rs485_rts_disable(port);
873+
ret = IRQ_HANDLED;
872874
}
873875

874-
if ((sr & USART_SR_RTOF) && ofs->icr != UNDEF_REG)
876+
if ((sr & USART_SR_RTOF) && ofs->icr != UNDEF_REG) {
875877
writel_relaxed(USART_ICR_RTOCF,
876878
port->membase + ofs->icr);
879+
ret = IRQ_HANDLED;
880+
}
877881

878882
if ((sr & USART_SR_WUF) && ofs->icr != UNDEF_REG) {
879883
/* Clear wake up flag and disable wake up interrupt */
@@ -882,6 +886,7 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
882886
stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_WUFIE);
883887
if (irqd_is_wakeup_set(irq_get_irq_data(port->irq)))
884888
pm_wakeup_event(tport->tty->dev, 0);
889+
ret = IRQ_HANDLED;
885890
}
886891

887892
/*
@@ -896,13 +901,15 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
896901
uart_unlock_and_check_sysrq(port);
897902
if (size)
898903
tty_flip_buffer_push(tport);
904+
ret = IRQ_HANDLED;
899905
}
900906
}
901907

902908
if ((sr & USART_SR_TXE) && !(stm32_port->tx_ch)) {
903909
uart_port_lock(port);
904910
stm32_usart_transmit_chars(port);
905911
uart_port_unlock(port);
912+
ret = IRQ_HANDLED;
906913
}
907914

908915
/* Receiver timeout irq for DMA RX */
@@ -912,9 +919,10 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
912919
uart_unlock_and_check_sysrq(port);
913920
if (size)
914921
tty_flip_buffer_push(tport);
922+
ret = IRQ_HANDLED;
915923
}
916924

917-
return IRQ_HANDLED;
925+
return ret;
918926
}
919927

920928
static void stm32_usart_set_mctrl(struct uart_port *port, unsigned int mctrl)

0 commit comments

Comments
 (0)