Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4101528rdb; Thu, 14 Sep 2023 11:45:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8/l2nHkDJaBY69+1d7JL06ThcKp/mBs0oNbc5XF4O6l52+vEBceosnUf9dY4+6svHPb9t X-Received: by 2002:a17:902:6a83:b0:1bf:78d:5cde with SMTP id n3-20020a1709026a8300b001bf078d5cdemr5787665plk.59.1694717150117; Thu, 14 Sep 2023 11:45:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694717150; cv=none; d=google.com; s=arc-20160816; b=HVbmoZ2sHr38E+M4MqDC6P6JcVbPPyvHySvZkOZyS6aDQsF34OKokrGQ0xikspiK72 539asP39HMV78tPCXMp0mVkaVE0wHdxAJsfLDbgQMOMOYnBtesIE0wjecMnRA5f4uWCv S0k/SG1yp+wvtOEjux+rltHax8SKe+m/+3Fl5+A5gn15O4Y61XTRYMBxtjTRBx+pBJ/V VMnWh6uIIiB9jXWvPWVtfLKkf2OYp22XPaGJrBws97dT/sVpXLd1E+R9GqDk6L6YG71k 1+cT09TFRcO+qkqlKmTXfTr1zYyJJTl/gaXzC1/GRFu9rgIelR6PjGXsMsD13oDNSwOc p2Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=Rtu6oqE59dzKnOzbdNG30qc4om/oIgRr8S/zbKifFdc=; fh=sLoG8GGafWMoIzrhP1zWZJios2vAvoRmN96U51FUg/o=; b=KIEagjRGa26H6I76pxnQ/3fKjYYcngFKfMVdOhpv7a94n3z+XjjQTU5xVGRQKsqNeu ReXaHl5dIkw86HCfw8Ln9m4IMU5gkycSc73qr2KgOhWcSR5YTPzpXbHovYnWd+FZQbVS UYijl3EueIUCMilctYnk82seGoBqp+6HiaIJ142gtPnvKjGbn1yH9pDXCCygdrEniPPX IeMXKC7SCq78NZAKN2qDQ9TAYLrCK7QmHzRbGEHiTnDy13n5AXf6xfBOVBXvgu3yA01D ZrVXKguESZvi0Hc/i/ogN3e+cmuOnXUpmf+sMwUutTvUwbRSlukD/xANknIzzdwDcf8N P/sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Ox3AVx2d; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id n1-20020a170902d2c100b001bb95a5cb9fsi2232950plc.522.2023.09.14.11.45.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 11:45:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Ox3AVx2d; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 99A0D837D4BA; Thu, 14 Sep 2023 11:43:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231881AbjINSnF (ORCPT + 99 others); Thu, 14 Sep 2023 14:43:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241825AbjINSlZ (ORCPT ); Thu, 14 Sep 2023 14:41:25 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6F192D65; Thu, 14 Sep 2023 11:39:08 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716747; 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=Rtu6oqE59dzKnOzbdNG30qc4om/oIgRr8S/zbKifFdc=; b=Ox3AVx2dzryq88igCiD0iP3QWgUJkXiwaPj9FFyKP5obEHwDkRSJvaC6guX/ZIVT17C1E/ DqC8IIdrncfuOFDGqdJq/a9VZI5Mad2edRRgfFXaVbO1a1hiDFoXWWmzXdBEo/uxsv8TGu FcY7848+U1ZX0AyaqwTnxAoHCDuuAgmHLdiycdUBGHZxt/t/eS30/NVCfzcASGe/PyxnYy NVor/6R/yuNdiyuduDI+Uz7FEHRJWR5D9n4feEQHHvbp0QMFDRfJwnx/UK/skKtekEyZ7e kImmOywWdtYt3DZ6JsbdBGn9PPp91Snbi6gKxhaA89uomCON3arVYZsMhQGvOQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716747; 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=Rtu6oqE59dzKnOzbdNG30qc4om/oIgRr8S/zbKifFdc=; b=NXJ+yaujVO6y/IuJtIGgaAgB0JGAz6vau/jQZ0o0D/rAnYe2xp0P7vUQxS89WFZpnZ3hlv 8pezu6YWNex7nZBQ== To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-serial@vger.kernel.org, Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Subject: [PATCH tty v1 65/74] serial: sunhv: Use port lock wrappers Date: Thu, 14 Sep 2023 20:44:22 +0206 Message-Id: <20230914183831.587273-66-john.ogness@linutronix.de> In-Reply-To: <20230914183831.587273-1-john.ogness@linutronix.de> References: <20230914183831.587273-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:43:24 -0700 (PDT) X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INVALID_DATE_TZ_ABSURD, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email From: Thomas Gleixner When a serial port is used for kernel console output, then all modifications to the UART registers which are done from other contexts, e.g. getty, termios, are interference points for the kernel console. So far this has been ignored and the printk output is based on the principle of hope. The rework of the console infrastructure which aims to support threaded and atomic consoles, requires to mark sections which modify the UART registers as unsafe. This allows the atomic write function to make informed decisions and eventually to restore operational state. It also allows to prevent the regular UART code from modifying UART registers while printk output is in progress. All modifications of UART registers are guarded by the UART port lock, which provides an obvious synchronization point with the console infrastructure. To avoid adding this functionality to all UART drivers, wrap the spin_[un]lock*() invocations for uart_port::lock into helper functions which just contain the spin_[un]lock*() invocations for now. In a subsequent step these helpers will gain the console synchronization mechanisms. Converted with coccinelle. No functional change. Signed-off-by: Thomas Gleixner --- drivers/tty/serial/sunhv.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/tty/serial/sunhv.c b/drivers/tty/serial/sunhv.c index c671d674bce4..5bfc0040f17b 100644 --- a/drivers/tty/serial/sunhv.c +++ b/drivers/tty/serial/sunhv.c @@ -217,10 +217,10 @@ static irqreturn_t sunhv_interrupt(int irq, void *dev_id) struct tty_port *tport; unsigned long flags; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); tport = receive_chars(port); transmit_chars(port); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); if (tport) tty_flip_buffer_push(tport); @@ -271,7 +271,7 @@ static void sunhv_send_xchar(struct uart_port *port, char ch) if (ch == __DISABLED_CHAR) return; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); while (limit-- > 0) { long status = sun4v_con_putchar(ch); @@ -280,7 +280,7 @@ static void sunhv_send_xchar(struct uart_port *port, char ch) udelay(1); } - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } /* port->lock held by caller. */ @@ -295,7 +295,7 @@ static void sunhv_break_ctl(struct uart_port *port, int break_state) unsigned long flags; int limit = 10000; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); while (limit-- > 0) { long status = sun4v_con_putchar(CON_BREAK); @@ -304,7 +304,7 @@ static void sunhv_break_ctl(struct uart_port *port, int break_state) udelay(1); } - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } } @@ -328,7 +328,7 @@ static void sunhv_set_termios(struct uart_port *port, struct ktermios *termios, unsigned int iflag, cflag; unsigned long flags; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); iflag = termios->c_iflag; cflag = termios->c_cflag; @@ -343,7 +343,7 @@ static void sunhv_set_termios(struct uart_port *port, struct ktermios *termios, uart_update_timeout(port, cflag, (port->uartclk / (16 * quot))); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } static const char *sunhv_type(struct uart_port *port) @@ -437,9 +437,9 @@ static void sunhv_console_write_paged(struct console *con, const char *s, unsign int locked = 1; if (port->sysrq || oops_in_progress) - locked = spin_trylock_irqsave(&port->lock, flags); + locked = uart_port_trylock_irqsave(port, &flags); else - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); while (n > 0) { unsigned long ra = __pa(con_write_page); @@ -470,7 +470,7 @@ static void sunhv_console_write_paged(struct console *con, const char *s, unsign } if (locked) - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } static inline void sunhv_console_putchar(struct uart_port *port, char c) @@ -492,9 +492,9 @@ static void sunhv_console_write_bychar(struct console *con, const char *s, unsig int i, locked = 1; if (port->sysrq || oops_in_progress) - locked = spin_trylock_irqsave(&port->lock, flags); + locked = uart_port_trylock_irqsave(port, &flags); else - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); for (i = 0; i < n; i++) { if (*s == '\n') @@ -503,7 +503,7 @@ static void sunhv_console_write_bychar(struct console *con, const char *s, unsig } if (locked) - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } static struct console sunhv_console = { -- 2.39.2