Commit f24771b6 authored by Marek Vasut's avatar Marek Vasut Committed by Greg Kroah-Hartman

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: e359b441 ("serial: stm32: fix threaded interrupt handling")
Reviewed-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Tested-by: Valentin Caron <valentin.caron@foss.st.com> # V3
Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230112180417.25595-1-marex@denx.deSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4f39aca2
...@@ -797,23 +797,9 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr) ...@@ -797,23 +797,9 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
spin_unlock(&port->lock); 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 */ /* Receiver timeout irq for DMA RX */
if (!stm32_port->throttled) { if (stm32_usart_rx_dma_enabled(port) && !stm32_port->throttled) {
spin_lock_irqsave(&port->lock, flags); spin_lock(&port->lock);
size = stm32_usart_receive_chars(port, false); size = stm32_usart_receive_chars(port, false);
uart_unlock_and_check_sysrq_irqrestore(port, flags); uart_unlock_and_check_sysrq_irqrestore(port, flags);
if (size) if (size)
...@@ -1015,10 +1001,8 @@ static int stm32_usart_startup(struct uart_port *port) ...@@ -1015,10 +1001,8 @@ static int stm32_usart_startup(struct uart_port *port)
u32 val; u32 val;
int ret; int ret;
ret = request_threaded_irq(port->irq, stm32_usart_interrupt, ret = request_irq(port->irq, stm32_usart_interrupt,
stm32_usart_threaded_interrupt, IRQF_NO_SUSPEND, name, port);
IRQF_ONESHOT | IRQF_NO_SUSPEND,
name, port);
if (ret) if (ret)
return ret; return ret;
...@@ -1601,13 +1585,6 @@ static int stm32_usart_of_dma_rx_probe(struct stm32_port *stm32port, ...@@ -1601,13 +1585,6 @@ static int stm32_usart_of_dma_rx_probe(struct stm32_port *stm32port,
struct dma_slave_config config; struct dma_slave_config config;
int ret; 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_buf = dma_alloc_coherent(dev, RX_BUF_L,
&stm32port->rx_dma_buf, &stm32port->rx_dma_buf,
GFP_KERNEL); GFP_KERNEL);
......
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