Skip to content

Commit f24771b

Browse files
Marek Vasutgregkh
authored andcommitted
serial: stm32: Merge hard IRQ and threaded IRQ handling into single IRQ handler
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: e359b44 ("serial: stm32: fix threaded interrupt handling") Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Tested-by: Valentin Caron <valentin.caron@foss.st.com> # V3 Signed-off-by: Marek Vasut <marex@denx.de> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20230112180417.25595-1-marex@denx.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4f39aca commit f24771b

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

drivers/tty/serial/stm32-usart.c

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -797,23 +797,9 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
797797
spin_unlock(&port->lock);
798798
}
799799

800-
if (stm32_usart_rx_dma_enabled(port))
801-
return IRQ_WAKE_THREAD;
802-
else
803-
return IRQ_HANDLED;
804-
}
805-
806-
static irqreturn_t stm32_usart_threaded_interrupt(int irq, void *ptr)
807-
{
808-
struct uart_port *port = ptr;
809-
struct tty_port *tport = &port->state->port;
810-
struct stm32_port *stm32_port = to_stm32_port(port);
811-
unsigned int size;
812-
unsigned long flags;
813-
814800
/* Receiver timeout irq for DMA RX */
815-
if (!stm32_port->throttled) {
816-
spin_lock_irqsave(&port->lock, flags);
801+
if (stm32_usart_rx_dma_enabled(port) && !stm32_port->throttled) {
802+
spin_lock(&port->lock);
817803
size = stm32_usart_receive_chars(port, false);
818804
uart_unlock_and_check_sysrq_irqrestore(port, flags);
819805
if (size)
@@ -1015,10 +1001,8 @@ static int stm32_usart_startup(struct uart_port *port)
10151001
u32 val;
10161002
int ret;
10171003

1018-
ret = request_threaded_irq(port->irq, stm32_usart_interrupt,
1019-
stm32_usart_threaded_interrupt,
1020-
IRQF_ONESHOT | IRQF_NO_SUSPEND,
1021-
name, port);
1004+
ret = request_irq(port->irq, stm32_usart_interrupt,
1005+
IRQF_NO_SUSPEND, name, port);
10221006
if (ret)
10231007
return ret;
10241008

@@ -1601,13 +1585,6 @@ static int stm32_usart_of_dma_rx_probe(struct stm32_port *stm32port,
16011585
struct dma_slave_config config;
16021586
int ret;
16031587

1604-
/*
1605-
* Using DMA and threaded handler for the console could lead to
1606-
* deadlocks.
1607-
*/
1608-
if (uart_console(port))
1609-
return -ENODEV;
1610-
16111588
stm32port->rx_buf = dma_alloc_coherent(dev, RX_BUF_L,
16121589
&stm32port->rx_dma_buf,
16131590
GFP_KERNEL);

0 commit comments

Comments
 (0)