@@ -797,9 +797,23 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
797
797
spin_unlock (& port -> lock );
798
798
}
799
799
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
+
800
814
/* Receiver timeout irq for DMA RX */
801
- if (stm32_usart_rx_dma_enabled ( port ) && !stm32_port -> throttled ) {
802
- spin_lock (& port -> lock );
815
+ if (!stm32_port -> throttled ) {
816
+ spin_lock_irqsave (& port -> lock , flags );
803
817
size = stm32_usart_receive_chars (port , false);
804
818
uart_unlock_and_check_sysrq_irqrestore (port , flags );
805
819
if (size )
@@ -1001,8 +1015,10 @@ static int stm32_usart_startup(struct uart_port *port)
1001
1015
u32 val ;
1002
1016
int ret ;
1003
1017
1004
- ret = request_irq (port -> irq , stm32_usart_interrupt ,
1005
- IRQF_NO_SUSPEND , name , port );
1018
+ ret = request_threaded_irq (port -> irq , stm32_usart_interrupt ,
1019
+ stm32_usart_threaded_interrupt ,
1020
+ IRQF_ONESHOT | IRQF_NO_SUSPEND ,
1021
+ name , port );
1006
1022
if (ret )
1007
1023
return ret ;
1008
1024
@@ -1585,6 +1601,13 @@ static int stm32_usart_of_dma_rx_probe(struct stm32_port *stm32port,
1585
1601
struct dma_slave_config config ;
1586
1602
int ret ;
1587
1603
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
+
1588
1611
stm32port -> rx_buf = dma_alloc_coherent (dev , RX_BUF_L ,
1589
1612
& stm32port -> rx_dma_buf ,
1590
1613
GFP_KERNEL );
0 commit comments