From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Martin Subject: [PATCH] serial/amba-pl011: Disable interrupts around TX softirq Date: Fri, 5 Jun 2015 15:07:47 +0100 Message-ID: <1433513267-24163-1-git-send-email-Dave.Martin@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: linux-serial@vger.kernel.org, Greg Kroah-Hartman Cc: Russell King , =?UTF-8?q?Jakub=20Kici=C5=84ski?= , Andre Przywara , Andrew Jackson , Graeme Gregory , popcorn mix , Jorge Ramirez-Ortiz , Robin Murphy , linux-arm-kernel@lists.infradead.org List-Id: linux-serial@vger.kernel.org pl011_tx_softirq() currently uses spin_{,un}lock(), which are not sufficient to inhibit pl011_int() from being triggered by a local IRQ and trying to re-take the same lock. This can lead to deadlocks. This patch uses the _irq() locking variants instead to ensure that pl011_int() handling for a given port is deferred until any pl011_tx_softirq() work for that port is complete. Signed-off-by: Dave Martin --- Another candidate for v4.1 if possible (sorry!) -- I thought this change was already in, but it went astray when I was refactoring. This patch conflicts with tty-next like the previous patch, since it fixes code that is removed by tty-next. The correct resolution for the resulting merge conflict is to keep the code from tty-next. I am not 100% certain yet whether some rare deadlocks that Robin is seeing are caused by this issue, or whether this patch fixes them -- he's testing atm. The patch is straightforward and using non _irq() locking in a workitem that expects the lock to protect against interrupt handlers on the same CPU is clearly wrong. Cheers ---Dave drivers/tty/serial/amba-pl011.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 763eb20..0cc622a 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -1360,9 +1360,9 @@ static void pl011_tx_softirq(struct work_struct *work) struct uart_amba_port *uap = container_of(dwork, struct uart_amba_port, tx_softirq_work); - spin_lock(&uap->port.lock); + spin_lock_irq(&uap->port.lock); while (pl011_tx_chars(uap)) ; - spin_unlock(&uap->port.lock); + spin_unlock_irq(&uap->port.lock); } static void pl011_tx_irq_seen(struct uart_amba_port *uap) -- 1.7.10.4 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave.Martin@arm.com (Dave Martin) Date: Fri, 5 Jun 2015 15:07:47 +0100 Subject: [PATCH] serial/amba-pl011: Disable interrupts around TX softirq Message-ID: <1433513267-24163-1-git-send-email-Dave.Martin@arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org pl011_tx_softirq() currently uses spin_{,un}lock(), which are not sufficient to inhibit pl011_int() from being triggered by a local IRQ and trying to re-take the same lock. This can lead to deadlocks. This patch uses the _irq() locking variants instead to ensure that pl011_int() handling for a given port is deferred until any pl011_tx_softirq() work for that port is complete. Signed-off-by: Dave Martin --- Another candidate for v4.1 if possible (sorry!) -- I thought this change was already in, but it went astray when I was refactoring. This patch conflicts with tty-next like the previous patch, since it fixes code that is removed by tty-next. The correct resolution for the resulting merge conflict is to keep the code from tty-next. I am not 100% certain yet whether some rare deadlocks that Robin is seeing are caused by this issue, or whether this patch fixes them -- he's testing atm. The patch is straightforward and using non _irq() locking in a workitem that expects the lock to protect against interrupt handlers on the same CPU is clearly wrong. Cheers ---Dave drivers/tty/serial/amba-pl011.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 763eb20..0cc622a 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -1360,9 +1360,9 @@ static void pl011_tx_softirq(struct work_struct *work) struct uart_amba_port *uap = container_of(dwork, struct uart_amba_port, tx_softirq_work); - spin_lock(&uap->port.lock); + spin_lock_irq(&uap->port.lock); while (pl011_tx_chars(uap)) ; - spin_unlock(&uap->port.lock); + spin_unlock_irq(&uap->port.lock); } static void pl011_tx_irq_seen(struct uart_amba_port *uap) -- 1.7.10.4