This is a note to let you know that I've just added the patch titled serial: stm32: Merge hard IRQ and threaded IRQ handling into single IRQ handler to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: serial-stm32-merge-hard-irq-and-threaded-irq-handling-into-single-irq-handler.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From f24771b62a83239f0dce816bddf0f6807f436235 Mon Sep 17 00:00:00 2001 From: Marek Vasut <marex@xxxxxxx> Date: Thu, 12 Jan 2023 19:04:17 +0100 Subject: serial: stm32: Merge hard IRQ and threaded IRQ handling into single IRQ handler From: Marek Vasut <marex@xxxxxxx> commit f24771b62a83239f0dce816bddf0f6807f436235 upstream. Requesting an interrupt with IRQF_ONESHOT will run the primary handler in the hard-IRQ context even in the force-threaded mode. The force-threaded mode is used by PREEMPT_RT in order to avoid acquiring sleeping locks (spinlock_t) in hard-IRQ context. This combination makes it impossible and leads to "sleeping while atomic" warnings. Use one interrupt handler for both handlers (primary and secondary) and drop the IRQF_ONESHOT flag which is not needed. Fixes: e359b4411c283 ("serial: stm32: fix threaded interrupt handling") Reviewed-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> Tested-by: Valentin Caron <valentin.caron@xxxxxxxxxxx> # V3 Signed-off-by: Marek Vasut <marex@xxxxxxx> Cc: stable@xxxxxxxxxxxxxxx Link: https://lore.kernel.org/r/20230112180417.25595-1-marex@xxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/tty/serial/stm32-usart.c | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -798,23 +798,9 @@ static irqreturn_t stm32_usart_interrupt spin_unlock(&port->lock); } - if (stm32_usart_rx_dma_enabled(port)) - return IRQ_WAKE_THREAD; - else - return IRQ_HANDLED; -} - -static irqreturn_t stm32_usart_threaded_interrupt(int irq, void *ptr) -{ - struct uart_port *port = ptr; - struct tty_port *tport = &port->state->port; - struct stm32_port *stm32_port = to_stm32_port(port); - unsigned int size; - unsigned long flags; - /* Receiver timeout irq for DMA RX */ - if (!stm32_port->throttled) { - spin_lock_irqsave(&port->lock, flags); + if (stm32_usart_rx_dma_enabled(port) && !stm32_port->throttled) { + spin_lock(&port->lock); size = stm32_usart_receive_chars(port, false); uart_unlock_and_check_sysrq_irqrestore(port, flags); if (size) @@ -1016,10 +1002,8 @@ static int stm32_usart_startup(struct ua u32 val; int ret; - ret = request_threaded_irq(port->irq, stm32_usart_interrupt, - stm32_usart_threaded_interrupt, - IRQF_ONESHOT | IRQF_NO_SUSPEND, - name, port); + ret = request_irq(port->irq, stm32_usart_interrupt, + IRQF_NO_SUSPEND, name, port); if (ret) return ret; @@ -1602,13 +1586,6 @@ static int stm32_usart_of_dma_rx_probe(s struct dma_slave_config config; int ret; - /* - * Using DMA and threaded handler for the console could lead to - * deadlocks. - */ - if (uart_console(port)) - return -ENODEV; - stm32port->rx_buf = dma_alloc_coherent(dev, RX_BUF_L, &stm32port->rx_dma_buf, GFP_KERNEL); Patches currently in stable-queue which might be from marex@xxxxxxx are queue-6.1/serial-stm32-merge-hard-irq-and-threaded-irq-handling-into-single-irq-handler.patch queue-6.1/revert-serial-stm32-merge-hard-irq-and-threaded-irq-handling-into-single-irq-handler.patch