Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4239970rdb; Thu, 14 Sep 2023 16:52:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAsvzSUcHvKrq2lFJSADvdArTo2P19wdqFxgCu8LPxoMKAdFXzdgwLiq6v+mujVSOtoXbN X-Received: by 2002:a17:90a:670d:b0:271:9c57:1c9a with SMTP id n13-20020a17090a670d00b002719c571c9amr17019pjj.21.1694735567779; Thu, 14 Sep 2023 16:52:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694735567; cv=none; d=google.com; s=arc-20160816; b=UabLyLKx6XRunAc7Gm3cKhRRK1GKOjWUg+73ydDAscqAy0tx/YWeTI4EOIRJ3XcEN5 lj1ygHhl3L5iMRABn1e7ZCrlVkTKzbQuPqdnbD75WQLIFF+Of011E5MSgngF/bbRlkd/ /0ME11m9BU/+a6Q0kogmPCkLK10900CjGjECvQQGrQq0e5FhfO/EO++Rwtd6cfk1WfTj XbNNRMIzMA+SgNNd/GHWWxYLviNc3s7ypLl7HJp1xoX3MlT/krPu9lgwvLRfQKKjkP7B 7TtkW72fZxT6d56bw4HYkEbKgmgY4s5fygZ+97Jtyq6tDx9eofJrMTrknzJyyoe6FWVP B+Vw== 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=T/Nah8LG2arspIXC5ZdMzJ+r6t3A3nzbfwJRMCSZSCk=; fh=qmZFnekuDs4T9icLmieAH3NNHXuS0/kWBnXi7iQsZPY=; b=E6r6K0ASEBzKDaEJM5TmhhKVFcrtGeM/ot8b7vPJMCmOm1wHgyMCOK/xr/ef1xvIzu OTYFYcQc9Xmxh9TSyDI5PLYloZrUtiEApos3fASGOSV4fC+UZ025w50dtWQCcEu0bLxx sEO5zNmO72TOKAZCR9HT0HTYpgVAiVkMMODKeUS1ZGvsfE/ukz3kJlca5F4ceJ1bV/Gu 7opATnXlZyX2x1iUV51PZwYLEEgYiPXVZIbTJSdZt5FgSQ9EFG9CdAvU0/gpaD4QOlcE gfEUg4wWdcRMjSX5XFJ93qvo7IJoy0w+ZTP/k08+1X+o/I2vFoIQzzCj7zL1kWdWNoYf 7A8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=oxmPK29N; dkim=neutral (no key) header.i=@linutronix.de header.b=Ou4JXvI5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id ha11-20020a17090af3cb00b002747da1ef70si1468347pjb.16.2023.09.14.16.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:52:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=oxmPK29N; dkim=neutral (no key) header.i=@linutronix.de header.b=Ou4JXvI5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 1F9F480DB350; Thu, 14 Sep 2023 11:40:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241885AbjINSj5 (ORCPT + 99 others); Thu, 14 Sep 2023 14:39:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241660AbjINSi7 (ORCPT ); Thu, 14 Sep 2023 14:38:59 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8A9A2134; Thu, 14 Sep 2023 11:38:52 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716731; 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=T/Nah8LG2arspIXC5ZdMzJ+r6t3A3nzbfwJRMCSZSCk=; b=oxmPK29NQ4j8pd2D01o8mg+K0yOiMZnw2YnzETzatx1/wERmCu0FosstZcHkoJEyLFX0EF NBnn4iN/bJRAYchCphv/ylN5T85we5IOkHknSeQb4eK/Eyk6W6q7qqYGuh9lJVEZoUDcn9 gf3F/rEY2Nbj6Hw1STCVl4kS7laZ5KCHpe3XUOlZdNyHPXtxhhOXiYBhimgDZESjHO3Vc6 ZuKGsiuxPnZoU1TGmDqDiZZY5fQqK8joUj0zmdRPnTUnQvnJbQKk69LyIdJHMtVlIQCifm NJHlIqap/7M6DJNuRcbx7VLrLka0K47uqTPGEuUtbT58rBVVZb1bZy05hx2EBA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716731; 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=T/Nah8LG2arspIXC5ZdMzJ+r6t3A3nzbfwJRMCSZSCk=; b=Ou4JXvI5/rF2X+xvNjTB7VuG7W/1UXFOV3B7seNGK+VIj2IC6C+6QxfRzjKVN/kAzeVGGR yu4a6caUgwydhoAg== To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-serial@vger.kernel.org, Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH tty v1 31/74] serial: jsm: Use port lock wrappers Date: Thu, 14 Sep 2023 20:43:48 +0206 Message-Id: <20230914183831.587273-32-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 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:40:33 -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 morse.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/jsm/jsm_neo.c | 4 ++-- drivers/tty/serial/jsm/jsm_tty.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c index 0c78f66276cd..2bd640428970 100644 --- a/drivers/tty/serial/jsm/jsm_neo.c +++ b/drivers/tty/serial/jsm/jsm_neo.c @@ -816,9 +816,9 @@ static void neo_parse_isr(struct jsm_board *brd, u32 port) /* Parse any modem signal changes */ jsm_dbg(INTR, &ch->ch_bd->pci_dev, "MOD_STAT: sending to parse_modem_sigs\n"); - spin_lock_irqsave(&ch->uart_port.lock, lock_flags); + uart_port_lock_irqsave(&ch->uart_port, &lock_flags); neo_parse_modem(ch, readb(&ch->ch_neo_uart->msr)); - spin_unlock_irqrestore(&ch->uart_port.lock, lock_flags); + uart_port_unlock_irqrestore(&ch->uart_port, lock_flags); } } diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c index 222afc270c88..ce0fef7e2c66 100644 --- a/drivers/tty/serial/jsm/jsm_tty.c +++ b/drivers/tty/serial/jsm/jsm_tty.c @@ -152,14 +152,14 @@ static void jsm_tty_send_xchar(struct uart_port *port, char ch) container_of(port, struct jsm_channel, uart_port); struct ktermios *termios; - spin_lock_irqsave(&port->lock, lock_flags); + uart_port_lock_irqsave(port, &lock_flags); termios = &port->state->port.tty->termios; if (ch == termios->c_cc[VSTART]) channel->ch_bd->bd_ops->send_start_character(channel); if (ch == termios->c_cc[VSTOP]) channel->ch_bd->bd_ops->send_stop_character(channel); - spin_unlock_irqrestore(&port->lock, lock_flags); + uart_port_unlock_irqrestore(port, lock_flags); } static void jsm_tty_stop_rx(struct uart_port *port) @@ -176,13 +176,13 @@ static void jsm_tty_break(struct uart_port *port, int break_state) struct jsm_channel *channel = container_of(port, struct jsm_channel, uart_port); - spin_lock_irqsave(&port->lock, lock_flags); + uart_port_lock_irqsave(port, &lock_flags); if (break_state == -1) channel->ch_bd->bd_ops->send_break(channel); else channel->ch_bd->bd_ops->clear_break(channel); - spin_unlock_irqrestore(&port->lock, lock_flags); + uart_port_unlock_irqrestore(port, lock_flags); } static int jsm_tty_open(struct uart_port *port) @@ -241,7 +241,7 @@ static int jsm_tty_open(struct uart_port *port) channel->ch_cached_lsr = 0; channel->ch_stops_sent = 0; - spin_lock_irqsave(&port->lock, lock_flags); + uart_port_lock_irqsave(port, &lock_flags); termios = &port->state->port.tty->termios; channel->ch_c_cflag = termios->c_cflag; channel->ch_c_iflag = termios->c_iflag; @@ -261,7 +261,7 @@ static int jsm_tty_open(struct uart_port *port) jsm_carrier(channel); channel->ch_open_count++; - spin_unlock_irqrestore(&port->lock, lock_flags); + uart_port_unlock_irqrestore(port, lock_flags); jsm_dbg(OPEN, &channel->ch_bd->pci_dev, "finish\n"); return 0; @@ -307,7 +307,7 @@ static void jsm_tty_set_termios(struct uart_port *port, struct jsm_channel *channel = container_of(port, struct jsm_channel, uart_port); - spin_lock_irqsave(&port->lock, lock_flags); + uart_port_lock_irqsave(port, &lock_flags); channel->ch_c_cflag = termios->c_cflag; channel->ch_c_iflag = termios->c_iflag; channel->ch_c_oflag = termios->c_oflag; @@ -317,7 +317,7 @@ static void jsm_tty_set_termios(struct uart_port *port, channel->ch_bd->bd_ops->param(channel); jsm_carrier(channel); - spin_unlock_irqrestore(&port->lock, lock_flags); + uart_port_unlock_irqrestore(port, lock_flags); } static const char *jsm_tty_type(struct uart_port *port) -- 2.39.2