* patch "tty: serial: imx: fix potential deadlock" added to tty-linus
@ 2020-11-12 8:33 gregkh
2020-11-16 17:54 ` Samuel Nobs
0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2020-11-12 8:33 UTC (permalink / raw)
To: samuel.nobs, gregkh, stable, u.kleine-koenig
This is a note to let you know that I've just added the patch titled
tty: serial: imx: fix potential deadlock
to my tty git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
in the tty-linus branch.
The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the
next -rc kernel release.
If you have any questions about this process, please let me know.
From 33f16855dcb973f745c51882d0e286601ff3be2b Mon Sep 17 00:00:00 2001
From: Sam Nobs <samuel.nobs@taitradio.com>
Date: Tue, 10 Nov 2020 09:50:06 +1300
Subject: tty: serial: imx: fix potential deadlock
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Enabling the lock dependency validator has revealed
that the way spinlocks are used in the IMX serial
port could result in a deadlock.
Specifically, imx_uart_int() acquires a spinlock
without disabling the interrupts, meaning that another
interrupt could come along and try to acquire the same
spinlock, potentially causing the two to wait for each
other indefinitely.
Use spin_lock_irqsave() instead to disable interrupts
upon acquisition of the spinlock.
Fixes: c974991d2620 ("tty:serial:imx: use spin_lock instead of spin_lock_irqsave in isr")
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sam Nobs <samuel.nobs@taitradio.com>
Link: https://lore.kernel.org/r/1604955006-9363-1-git-send-email-samuel.nobs@taitradio.com
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/tty/serial/imx.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 1731d9728865..3c53a3c89959 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -942,8 +942,14 @@ static irqreturn_t imx_uart_int(int irq, void *dev_id)
struct imx_port *sport = dev_id;
unsigned int usr1, usr2, ucr1, ucr2, ucr3, ucr4;
irqreturn_t ret = IRQ_NONE;
+ unsigned long flags = 0;
- spin_lock(&sport->port.lock);
+ /*
+ * IRQs might not be disabled upon entering this interrupt handler,
+ * e.g. when interrupt handlers are forced to be threaded. To support
+ * this scenario as well, disable IRQs when acquiring the spinlock.
+ */
+ spin_lock_irqsave(&sport->port.lock, flags);
usr1 = imx_uart_readl(sport, USR1);
usr2 = imx_uart_readl(sport, USR2);
@@ -1013,7 +1019,7 @@ static irqreturn_t imx_uart_int(int irq, void *dev_id)
ret = IRQ_HANDLED;
}
- spin_unlock(&sport->port.lock);
+ spin_unlock_irqrestore(&sport->port.lock, flags);
return ret;
}
--
2.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: patch "tty: serial: imx: fix potential deadlock" added to tty-linus
2020-11-12 8:33 patch "tty: serial: imx: fix potential deadlock" added to tty-linus gregkh
@ 2020-11-16 17:54 ` Samuel Nobs
0 siblings, 0 replies; 2+ messages in thread
From: Samuel Nobs @ 2020-11-16 17:54 UTC (permalink / raw)
To: gregkh; +Cc: stable, u.kleine-koenig
Great, thanks.
Cheers,
Sam
On Thu, Nov 12, 2020 at 9:32 PM <gregkh@linuxfoundation.org> wrote:
>
>
> This is a note to let you know that I've just added the patch titled
>
> tty: serial: imx: fix potential deadlock
>
> to my tty git tree which can be found at
> git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
> in the tty-linus branch.
>
> The patch will show up in the next release of the linux-next tree
> (usually sometime within the next 24 hours during the week.)
>
> The patch will hopefully also be merged in Linus's tree for the
> next -rc kernel release.
>
> If you have any questions about this process, please let me know.
>
>
> From 33f16855dcb973f745c51882d0e286601ff3be2b Mon Sep 17 00:00:00 2001
> From: Sam Nobs <samuel.nobs@taitradio.com>
> Date: Tue, 10 Nov 2020 09:50:06 +1300
> Subject: tty: serial: imx: fix potential deadlock
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> Enabling the lock dependency validator has revealed
> that the way spinlocks are used in the IMX serial
> port could result in a deadlock.
>
> Specifically, imx_uart_int() acquires a spinlock
> without disabling the interrupts, meaning that another
> interrupt could come along and try to acquire the same
> spinlock, potentially causing the two to wait for each
> other indefinitely.
>
> Use spin_lock_irqsave() instead to disable interrupts
> upon acquisition of the spinlock.
>
> Fixes: c974991d2620 ("tty:serial:imx: use spin_lock instead of spin_lock_irqsave in isr")
> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Signed-off-by: Sam Nobs <samuel.nobs@taitradio.com>
> Link: https://lore.kernel.org/r/1604955006-9363-1-git-send-email-samuel.nobs@taitradio.com
> Cc: stable <stable@vger.kernel.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> drivers/tty/serial/imx.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 1731d9728865..3c53a3c89959 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -942,8 +942,14 @@ static irqreturn_t imx_uart_int(int irq, void *dev_id)
> struct imx_port *sport = dev_id;
> unsigned int usr1, usr2, ucr1, ucr2, ucr3, ucr4;
> irqreturn_t ret = IRQ_NONE;
> + unsigned long flags = 0;
>
> - spin_lock(&sport->port.lock);
> + /*
> + * IRQs might not be disabled upon entering this interrupt handler,
> + * e.g. when interrupt handlers are forced to be threaded. To support
> + * this scenario as well, disable IRQs when acquiring the spinlock.
> + */
> + spin_lock_irqsave(&sport->port.lock, flags);
>
> usr1 = imx_uart_readl(sport, USR1);
> usr2 = imx_uart_readl(sport, USR2);
> @@ -1013,7 +1019,7 @@ static irqreturn_t imx_uart_int(int irq, void *dev_id)
> ret = IRQ_HANDLED;
> }
>
> - spin_unlock(&sport->port.lock);
> + spin_unlock_irqrestore(&sport->port.lock, flags);
>
> return ret;
> }
> --
> 2.29.2
>
>
--
Samuel Nobs
Senior Design Engineer
Tait Communications
DDI: +64 7 825 7538
Email: samuel.nobs@taitradio.com
www.taitradio.com
--
This Communication is Confidential. We only send and receive email on the
basis of the terms set out at www.taitradio.com/email_disclaimer
<http://www.taitradio.com/email_disclaimer>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-16 17:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-12 8:33 patch "tty: serial: imx: fix potential deadlock" added to tty-linus gregkh
2020-11-16 17:54 ` Samuel Nobs
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.