From patchwork Fri Mar 1 21:45:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 13579171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0DEF8C54E4A for ; Fri, 1 Mar 2024 21:53:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0UdU35eBOXy7Xx6PWoVBQBnj0cjM/wSwt/lGhI3JNwE=; b=H1Bd7W9y48z4en STf14F9Qge4lFDwmPaB769MNcBIqeTYQOyq7oloGcBD7XJRpHqxM8vtc/vlBatBrM/eSknS39Th54 Q9awBISylwqgxiBhaK0oH1PgMSc1q1yO9Rmse4kRurp7lwt66LvOd05p7EBu79wak90lbTceYsszL Wc1vN0vhZaEQKEjC7w2bCL7YunFav4r3HbX0KQ+4EG36/ZnSM94CMCZ4eKPoG1Ed/bjgU5DUh22dn iQRSKQqmaM6kA+liTYAN5GlpESs3vK16292KHg8Fn1n6YYJBOzo1WdlmaIsBcIyDU3QTJn1pP5ExF cqmznF5XPERMjbXDEfXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgAoR-000000024cU-0yLi; Fri, 01 Mar 2024 21:53:03 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgAoJ-000000024ZB-2BSB; Fri, 01 Mar 2024 21:52:59 +0000 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1709329971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H7r1ch2QCFOhprkBXp7qfcKOLIETYbzIerJUqrI061g=; b=w/6JWsipW/VNMSxnbJX8VayPbqNtoFevsHC0HxJHEM28w+pOSJYMStG5tGBURutPNa4Uv0 /Cdk7vy072Gsb8Ga/umkx9aOc0YCPdGtWI1uVIW4fHv+cuPTX57Fn0qo5FHPOagxmzEG9H wzlTGQ7okWDu7DSN+rXSTJxBaKZOqMEj34b9ZSeN1/2Ya5YReELIZ0xNy+wJyqWYK/osTF SKdHBUN0LXR8q46lK6ct0VxQoC8yzA2yVsnvoKAz1ciiQ20MrQdB7ECNOY+ANq+hSsB1Pz yKTTBP7wIDSBkwlrFUr/veUFOkNIpEHSiXAXYsBDnZMqq4NtZIqfB495vBRhsQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1709329971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H7r1ch2QCFOhprkBXp7qfcKOLIETYbzIerJUqrI061g=; b=U6vXNia4v+kROl9sdz8uXe84USxD/w5gbTSFDQcdI6uy01AQNDumm3pKag2zc2pDX3elqF pAsAVrjwYp95xZDA== To: linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby , Thomas Gleixner , Sebastian Andrzej Siewior , Kevin Hilman , Jerome Brunet , linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org Subject: [PATCH 04/18] serial: meson: Use uart_prepare_sysrq_char(). Date: Fri, 1 Mar 2024 22:45:17 +0100 Message-ID: <20240301215246.891055-5-bigeasy@linutronix.de> In-Reply-To: <20240301215246.891055-1-bigeasy@linutronix.de> References: <20240301215246.891055-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240301_135255_731177_06123A75 X-CRM114-Status: GOOD ( 12.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The port lock is a spinlock_t which is becomes a sleeping lock on PREEMPT_RT. The driver splits the locking function into two parts: local_irq_save() and uart_port_lock() and this breaks PREEMPT_RT. Delay handling sysrq until port lock is dropped. Remove the special case in the console write routine an always use the complete locking function. Cc: Kevin Hilman Cc: Jerome Brunet Cc: linux-arm-kernel@lists.infradead.org Cc: linux-amlogic@lists.infradead.org Signed-off-by: Sebastian Andrzej Siewior --- drivers/tty/serial/meson_uart.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c index 8395688f5ee92..6feac459c0cf4 100644 --- a/drivers/tty/serial/meson_uart.c +++ b/drivers/tty/serial/meson_uart.c @@ -220,7 +220,7 @@ static void meson_receive_chars(struct uart_port *port) continue; } - if (uart_handle_sysrq_char(port, ch)) + if (uart_prepare_sysrq_char(port, ch)) continue; if ((status & port->ignore_status_mask) == 0) @@ -248,7 +248,7 @@ static irqreturn_t meson_uart_interrupt(int irq, void *dev_id) meson_uart_start_tx(port); } - uart_port_unlock(port); + uart_unlock_and_check_sysrq(port); return IRQ_HANDLED; } @@ -556,18 +556,13 @@ static void meson_serial_port_write(struct uart_port *port, const char *s, u_int count) { unsigned long flags; - int locked; + int locked = 1; u32 val, tmp; - local_irq_save(flags); - if (port->sysrq) { - locked = 0; - } else if (oops_in_progress) { - locked = uart_port_trylock(port); - } else { - uart_port_lock(port); - locked = 1; - } + if (oops_in_progress) + locked = uart_port_trylock_irqsave(port, &flags); + else + uart_port_lock_irqsave(port, &flags); val = readl(port->membase + AML_UART_CONTROL); tmp = val & ~(AML_UART_TX_INT_EN | AML_UART_RX_INT_EN); @@ -577,8 +572,7 @@ static void meson_serial_port_write(struct uart_port *port, const char *s, writel(val, port->membase + AML_UART_CONTROL); if (locked) - uart_port_unlock(port); - local_irq_restore(flags); + uart_port_unlock_irqrestore(port, flags); } static void meson_serial_console_write(struct console *co, const char *s, From patchwork Fri Mar 1 21:45:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 13579170 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93125C54E55 for ; Fri, 1 Mar 2024 21:53:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JCCtSiCc4l7zsgBjpiDYlW/JxHVrKmZ68JtKCB0Oi4M=; b=L9EkoBGsvYV1Ks ayyuCl6yu7MeDWk+hE1ee6NBoAWO/QSP+9Pk0g6jSSjgCvmNumIf7CaXDOyyo0CDKn/bPsPtK67CN MtcFmK1avE5mu2JdgKNBObdznVEMwmvs9BFnlRi6DAjZXrnKktDezwsSD2R6zIWjp9+1KUGEmCFtj dktV6Y3y9y/8SZIRy8L1XVOwoxbGu5f8UK0F5tBaOUyyYnQS6wfYerrr8UyymNJC2zmLCgbzG2jMo GW6B08LaZzAMQcYEuXM/iJvuSCMZ9jpPPdLMLpwmtOH3Pi1iWZAcc09M7xTEPsKVJjr+ekRL0O+Am BWJcY2g9xWxC9RfNIIHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgAoS-000000024dP-1y6e; Fri, 01 Mar 2024 21:53:04 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgAoJ-000000024ZG-3Z8s for linux-arm-kernel@lists.infradead.org; Fri, 01 Mar 2024 21:53:02 +0000 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1709329972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wNzlMgcB7Ml8SwiiDSy2k2m2CzXu6bUYS/NmyaqyVvY=; b=JQE6hsuD4GBq+eQWc1quSwSjrpKc+JJK9sl7nxnUK6YtebPrz+us/3ItDp3nCY+aXVJaKU J5MJhR1O4NE02wDDBMTp7Frme1R84yw2W/iDfnKVd0MMqpvy3BdFsr3vqgqqPDn4es10kC TOyr48sCvlSD/pFbbyFXjnDnK91V3ChT+Q9fVrelgUUXtnbE4HEGPq8OYEochRaUceNK+v dFcJq5HzvYjikpjiLO8Iuo6JjnQupfD/xM54Wyl6XVOYVpWn9SpxG6HCJNtcjUKc4XtldN ywzBmmqbm2xjS7QDlKCdwR1ANQEyAP4aUuWRQZeEvB2Umk1tlH/w91kfT28eZg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1709329972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wNzlMgcB7Ml8SwiiDSy2k2m2CzXu6bUYS/NmyaqyVvY=; b=naHLAMDrbDn1VJoY3UrOJIMmXbzlyfLeNOfYuiezN0L9NJsU7IConNvIk0CYZk/r2oE0cR sOmLRPGu8VdeuICw== To: linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby , Thomas Gleixner , Sebastian Andrzej Siewior , Vladimir Zapolskiy , linux-arm-kernel@lists.infradead.org Subject: [PATCH 09/18] serial: lpc32xx_hs: Use uart_prepare_sysrq_char() to handle sysrq. Date: Fri, 1 Mar 2024 22:45:22 +0100 Message-ID: <20240301215246.891055-10-bigeasy@linutronix.de> In-Reply-To: <20240301215246.891055-1-bigeasy@linutronix.de> References: <20240301215246.891055-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240301_135256_078684_B995463A X-CRM114-Status: GOOD ( 11.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The port lock is a spinlock_t which is becomes a sleeping lock on PREEMPT_RT. The driver splits the locking function into two parts: local_irq_save() and uart_port_lock() and this breaks PREEMPT_RT. Handle sysrq requests sysrq once the port lock is dropped. Remove the special case in the console write routine an always use the complete locking function. Cc: Vladimir Zapolskiy Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Sebastian Andrzej Siewior --- drivers/tty/serial/lpc32xx_hs.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c index ec20329f06036..e70fa59dbcc3b 100644 --- a/drivers/tty/serial/lpc32xx_hs.c +++ b/drivers/tty/serial/lpc32xx_hs.c @@ -136,20 +136,16 @@ static void lpc32xx_hsuart_console_write(struct console *co, const char *s, int locked = 1; touch_nmi_watchdog(); - local_irq_save(flags); - if (up->port.sysrq) - locked = 0; - else if (oops_in_progress) - locked = uart_port_trylock(&up->port); + if (oops_in_progress) + locked = uart_port_trylock_irqsave(&up->port, &flags); else - uart_port_lock(&up->port); + uart_port_lock_irqsave(&up->port, &flags); uart_console_write(&up->port, s, count, lpc32xx_hsuart_console_putchar); wait_for_xmit_empty(&up->port); if (locked) - uart_port_unlock(&up->port); - local_irq_restore(flags); + uart_port_unlock_irqrestore(&up->port, flags); } static int __init lpc32xx_hsuart_console_setup(struct console *co, @@ -268,7 +264,8 @@ static void __serial_lpc32xx_rx(struct uart_port *port) tty_insert_flip_char(tport, 0, TTY_FRAME); } - tty_insert_flip_char(tport, (tmp & 0xFF), flag); + if (!uart_prepare_sysrq_char(port, tmp & 0xff)) + tty_insert_flip_char(tport, (tmp & 0xFF), flag); tmp = readl(LPC32XX_HSUART_FIFO(port->membase)); } @@ -333,7 +330,7 @@ static irqreturn_t serial_lpc32xx_interrupt(int irq, void *dev_id) __serial_lpc32xx_tx(port); } - uart_port_unlock(port); + uart_unlock_and_check_sysrq(port); return IRQ_HANDLED; } From patchwork Fri Mar 1 21:45:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 13579169 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 557ADC5475B for ; Fri, 1 Mar 2024 21:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/Jbk6AyAqYcmbu/qFTio7XMnYmoBC+xhk82ItKaRNGQ=; b=CocfyUQq0eaNVO yD4Cmj/GllAyAXJjHUCm5sYOhC7u15nlt0KX7NdQeVcQz5872+9yM7S/qdBl/9xNPxeLAkhA/9lzi mbriegpCmNY2PbQmt95kbTsL2RUBia/luwSoyQV3fjqFQq3I/Zxk45zQy1x3ZcC0BZye6eqNKhJKH xVaOIGZ++VSw9B8FG/GnlV8g86ioUi+2PTpk/fsxTCSVk4UB4xsAKHNsNYc2McHM4SA77ubkfe97T vV49fb4yBDXu0CKNVbNNtaflPDul430zrL1m/uTUPtNALecqmYs7gloLlqAxg4pzrrTi1LOMkFpvU AlwHk+lDoaIg6fbhsIjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgAoO-000000024ba-13vQ; Fri, 01 Mar 2024 21:53:00 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgAoJ-000000024ZH-2Fug; Fri, 01 Mar 2024 21:52:58 +0000 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1709329972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9WNSSuDhcj1L0hdKTmzZHOjjPZHLEmPBI6eyJikJAxs=; b=32PpjUGOijguemtgK5OGL/uEcf+Ed5E32JT6lbtR3GdeCV/eo5rXQWWEWRbAFi8twtwK+Z DpCoTwloeyPP3686UB83pPO1uTmvR/F89B3IpF7mms7xnOvECB6bQuCtL94tOj84OMiFZ+ zzdm3c4XGpuplfAOzcvELdBKzvPp2nWjC/dxcOGVNJno8zju2BTyiz2fcCRBpRpAF8yY9z da3gu/2i764YDfyrXFaXdfx176v+rJ+rBI0h+vHTNQRHJwyX7sxc+viQLOTIZ4CN0wbHWs aHTHl9HXan2ME0xdmsyxgcwR9DhvF/kj6ox19EMx1oecaTh1wVMO/mKJGoc3Hw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1709329972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9WNSSuDhcj1L0hdKTmzZHOjjPZHLEmPBI6eyJikJAxs=; b=SsMk5Jrp930Xb5w5e046HrQjoh1Hx9Ojuzkx+xUxFIuhu7kwcDYIMuFG26sXao5zaumeRr pvOTdEiB48/6juBg== To: linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby , Thomas Gleixner , Sebastian Andrzej Siewior , =?utf-8?q?Andreas_F?= =?utf-8?q?=C3=A4rber?= , Manivannan Sadhasivam , linux-arm-kernel@lists.infradead.org, linux-actions@lists.infradead.org Subject: [PATCH 10/18] serial: owl: Use uart_prepare_sysrq_char() to handle sysrq. Date: Fri, 1 Mar 2024 22:45:23 +0100 Message-ID: <20240301215246.891055-11-bigeasy@linutronix.de> In-Reply-To: <20240301215246.891055-1-bigeasy@linutronix.de> References: <20240301215246.891055-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240301_135255_740682_00D18E9C X-CRM114-Status: GOOD ( 13.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The port lock is a spinlock_t which is becomes a sleeping lock on PREEMPT_RT. The driver splits the locking function into two parts: local_irq_save() and uart_port_lock() and this breaks PREEMPT_RT. Handle sysrq requests sysrq once the port lock is dropped. Remove the special case in the console write routine an always use the complete locking function. Cc: "Andreas Färber" Cc: Manivannan Sadhasivam Cc: linux-arm-kernel@lists.infradead.org Cc: linux-actions@lists.infradead.org Signed-off-by: Sebastian Andrzej Siewior --- drivers/tty/serial/owl-uart.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c index d9fe85397741d..8b60ac0ad7cd3 100644 --- a/drivers/tty/serial/owl-uart.c +++ b/drivers/tty/serial/owl-uart.c @@ -199,6 +199,7 @@ static void owl_uart_receive_chars(struct uart_port *port) stat = owl_uart_read(port, OWL_UART_STAT); while (!(stat & OWL_UART_STAT_RFEM)) { char flag = TTY_NORMAL; + bool sysrq; if (stat & OWL_UART_STAT_RXER) port->icount.overrun++; @@ -217,7 +218,9 @@ static void owl_uart_receive_chars(struct uart_port *port) val = owl_uart_read(port, OWL_UART_RXDAT); val &= 0xff; - if ((stat & port->ignore_status_mask) == 0) + sysrq = uart_prepare_sysrq_char(port, val); + + if (!sysrq && (stat & port->ignore_status_mask) == 0) tty_insert_flip_char(&port->state->port, val, flag); stat = owl_uart_read(port, OWL_UART_STAT); @@ -229,10 +232,9 @@ static void owl_uart_receive_chars(struct uart_port *port) static irqreturn_t owl_uart_irq(int irq, void *dev_id) { struct uart_port *port = dev_id; - unsigned long flags; u32 stat; - uart_port_lock_irqsave(port, &flags); + uart_port_lock(port); stat = owl_uart_read(port, OWL_UART_STAT); @@ -246,7 +248,7 @@ static irqreturn_t owl_uart_irq(int irq, void *dev_id) stat |= OWL_UART_STAT_RIP | OWL_UART_STAT_TIP; owl_uart_write(port, stat, OWL_UART_STAT); - uart_port_unlock_irqrestore(port, flags); + uart_unlock_and_check_sysrq(port); return IRQ_HANDLED; } @@ -508,18 +510,12 @@ static void owl_uart_port_write(struct uart_port *port, const char *s, { u32 old_ctl, val; unsigned long flags; - int locked; + int locked = 1; - local_irq_save(flags); - - if (port->sysrq) - locked = 0; - else if (oops_in_progress) - locked = uart_port_trylock(port); - else { - uart_port_lock(port); - locked = 1; - } + if (oops_in_progress) + locked = uart_port_trylock_irqsave(port, &flags); + else + uart_port_lock_irqsave(port, &flags); old_ctl = owl_uart_read(port, OWL_UART_CTL); val = old_ctl | OWL_UART_CTL_TRFS_TX; @@ -541,9 +537,7 @@ static void owl_uart_port_write(struct uart_port *port, const char *s, owl_uart_write(port, old_ctl, OWL_UART_CTL); if (locked) - uart_port_unlock(port); - - local_irq_restore(flags); + uart_port_unlock_irqrestore(port, flags); } static void owl_uart_console_write(struct console *co, const char *s, From patchwork Fri Mar 1 21:45:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 13579172 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6C632C5478C for ; Fri, 1 Mar 2024 21:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PskndyIJolUa+WSYnjLoYXlwJ1/JTZSyX6Fl1RMKnfI=; b=d0O/BqBvjXoRs4 WU6oaG6pj3SJh5V/b0c4JJPFnbRYUfBY0UYSvnv22XOI3/+FzO/+SaA/nkNnXSYqNjCOL5NiXqEbv MP2Z7XD+jM1Jq1G81plgg/4CDVZl6jmoyzpzLr4Qw1MYAAUZzk1pp77PcLLbtrqv2rkkcrRgJHaId UwTOC1ycJ2GTAkF3yNQ8MrNPLbhKmLR885lYQLarCeWDK+khGho/SkFhqyISFstUvG4xCkIWPtQ7k XOHOPZ38G8eaaE5Zx8LaHCaPKA4/sj4TYZNGj/2TYvKRabux0bgDoVMOWeg5fSYw3JjFdzS0AID4U v9lyAHWjyoUJtbXdOxXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgAoV-000000024eR-13Rz; Fri, 01 Mar 2024 21:53:07 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgAoJ-000000024ZM-2yvZ; Fri, 01 Mar 2024 21:53:03 +0000 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1709329972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tledTIFDDr1sldln/W0Iqtq8p3bbY99HUvZ3jjp5lks=; b=DYeW/M1ORa4YklCaqL330/U85u/jJ+vZdIf5XzcCr1ZY8J/qa4tkUvBtBUyrosws1Hp3ox fGCNR3vwyXJH7mvvWemhuptLbwbDMIpZNfXelPUl85mEdRWx1JZ6P/9Wws6Fk/Hfg0cbMw gfHmTsKbtOCui97hgqP+kSTDOdz40MB+Ygiql02qRl61ZregVOlBI3Uo5/Rl0d98bjlV9S i2AiEKCIeGaop0mWb1xOTnHdNeCXSPavl4SdFCES7EmT++cWQjoA8JyNAGaFt1p+GHwIXk FNCI8PqstTDTWvZEdrC4uIG6lrukcv50FKN4Ygl8Tez7tdf3V3VTZ5qT0bUZXQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1709329972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tledTIFDDr1sldln/W0Iqtq8p3bbY99HUvZ3jjp5lks=; b=VXU5xXqD7rHLIprKYFCb/dOHvMV74MKNJXd1UQwUXThVIFJHiP3eKZA1Gmxa9738uXpO2Y 8jYRQNUskQ+VH8CA== To: linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby , Thomas Gleixner , Sebastian Andrzej Siewior , Manivannan Sadhasivam , linux-arm-kernel@lists.infradead.org, linux-unisoc@lists.infradead.org Subject: [PATCH 11/18] serial: rda: Use uart_prepare_sysrq_char() to handle sysrq. Date: Fri, 1 Mar 2024 22:45:24 +0100 Message-ID: <20240301215246.891055-12-bigeasy@linutronix.de> In-Reply-To: <20240301215246.891055-1-bigeasy@linutronix.de> References: <20240301215246.891055-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240301_135255_976351_E327140B X-CRM114-Status: GOOD ( 12.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The port lock is a spinlock_t which is becomes a sleeping lock on PREEMPT_RT. The driver splits the locking function into two parts: local_irq_save() and uart_port_lock() and this breaks PREEMPT_RT. Handle sysrq requests sysrq once the port lock is dropped. Remove the special case in the console write routine an always use the complete locking function. Cc: Manivannan Sadhasivam Cc: linux-arm-kernel@lists.infradead.org Cc: linux-unisoc@lists.infradead.org Signed-off-by: Sebastian Andrzej Siewior --- drivers/tty/serial/rda-uart.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/tty/serial/rda-uart.c b/drivers/tty/serial/rda-uart.c index 13deb355cf1bc..82def9b8632a5 100644 --- a/drivers/tty/serial/rda-uart.c +++ b/drivers/tty/serial/rda-uart.c @@ -394,7 +394,8 @@ static void rda_uart_receive_chars(struct uart_port *port) val &= 0xff; port->icount.rx++; - tty_insert_flip_char(&port->state->port, val, flag); + if (!uart_prepare_sysrq_char(port, val)) + tty_insert_flip_char(&port->state->port, val, flag); status = rda_uart_read(port, RDA_UART_STATUS); } @@ -405,10 +406,9 @@ static void rda_uart_receive_chars(struct uart_port *port) static irqreturn_t rda_interrupt(int irq, void *dev_id) { struct uart_port *port = dev_id; - unsigned long flags; u32 val, irq_mask; - uart_port_lock_irqsave(port, &flags); + uart_port_lock(port); /* Clear IRQ cause */ val = rda_uart_read(port, RDA_UART_IRQ_CAUSE); @@ -425,7 +425,7 @@ static irqreturn_t rda_interrupt(int irq, void *dev_id) rda_uart_send_chars(port); } - uart_port_unlock_irqrestore(port, flags); + uart_unlock_and_check_sysrq(port); return IRQ_HANDLED; } @@ -590,18 +590,12 @@ static void rda_uart_port_write(struct uart_port *port, const char *s, { u32 old_irq_mask; unsigned long flags; - int locked; + int locked = 1; - local_irq_save(flags); - - if (port->sysrq) { - locked = 0; - } else if (oops_in_progress) { - locked = uart_port_trylock(port); - } else { - uart_port_lock(port); - locked = 1; - } + if (oops_in_progress) + locked = uart_port_trylock_irqsave(port, &flags); + else + uart_port_lock_irqsave(port, &flags); old_irq_mask = rda_uart_read(port, RDA_UART_IRQ_MASK); rda_uart_write(port, 0, RDA_UART_IRQ_MASK); @@ -615,9 +609,7 @@ static void rda_uart_port_write(struct uart_port *port, const char *s, rda_uart_write(port, old_irq_mask, RDA_UART_IRQ_MASK); if (locked) - uart_port_unlock(port); - - local_irq_restore(flags); + uart_port_unlock_irqrestore(port, flags); } static void rda_uart_console_write(struct console *co, const char *s,