Re: serial: imx: Possible circular locking dependency
From: Fabio Estevam <festevam@gmail.com>
Date: 2021-09-29 20:50:16
On Wed, Sep 29, 2021 at 3:35 PM Fabio Estevam [off-list ref] wrote:
quoted hunk ↗ jump to hunk
On Wed, Sep 29, 2021 at 1:10 PM Fabio Estevam [off-list ref] wrote:quoted
Hi Petr and Sergey, I know this has been reported before [1] and [2], but I am still observing the deadlock below on an imx6q board since commit dbdda842fe96 ("printk: Add console owner and waiter logic to load balance console writes"). To reproduce it: # echo t > /proc/sysrq-trigger [ 20.325246] ====================================================== [ 20.325252] WARNING: possible circular locking dependency detected [ 20.325260] 5.15.0-rc2-next-20210924-00004-gd2d6e664f29f-dirty #163If I move the __imx_uart_rxint() block outside the spin_lock() like this:diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 8b121cd869e9..c94704f5dd99 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c@@ -955,13 +955,6 @@ static irqreturn_t imx_uart_int(int irq, void *dev_id) if ((ucr4 & UCR4_OREN) == 0) usr2 &= ~USR2_ORE; - if (usr1 & (USR1_RRDY | USR1_AGTIM)) { - imx_uart_writel(sport, USR1_AGTIM, USR1); - - __imx_uart_rxint(irq, dev_id); - ret = IRQ_HANDLED; - } - if ((usr1 & USR1_TRDY) || (usr2 & USR2_TXDC)) { imx_uart_transmit_buffer(sport); ret = IRQ_HANDLED;@@ -993,6 +986,13 @@ static irqreturn_t imx_uart_int(int irq, void *dev_id) spin_unlock(&sport->port.lock); + if (usr1 & (USR1_RRDY | USR1_AGTIM)) { + imx_uart_writel(sport, USR1_AGTIM, USR1); + + __imx_uart_rxint(irq, dev_id); + ret = IRQ_HANDLED; + } + return ret; }Then the problem does not happen anymore. Is this a proper fix?
It seems that a proper fix would be to use the same approach as in
5697df7322fe ("serial: fsl_lpuart: split sysrq handling):
I will send a proper patch with this solution.
Thanks