Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4617333rdb; Fri, 15 Sep 2023 07:33:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwU7wJsQSKO896v1pIZssjCIx2TioosJ8eqozfWvrYj+X58KL5GlsFee8jSikv4Xd6azUL X-Received: by 2002:a05:6a20:5488:b0:14c:a2e1:65fd with SMTP id i8-20020a056a20548800b0014ca2e165fdmr2643184pzk.9.1694788422652; Fri, 15 Sep 2023 07:33:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694788422; cv=none; d=google.com; s=arc-20160816; b=NXSoATzHE3L8cEEKQ/Y/OEVSrSb4CbamDpE2cQc4vVm6dTgqGH+3hu7bnTe2GAOLGy Ug6qh0Dm3gT3TmD+OsM/ryg/oRJJC3ODfOcBX9dPeLUtfafj445SZpJacx9Eyc0eJpq0 NNv+SjwereLvFsGmCG4sg5C8gloQCoLN6EPqqe85bALKO5x84n2ddcK+mznElF/9MbV/ YRg1DCT74dmoF5nsrdo5ZlqEazwoaJoOrucbgNur7tKCSKPHarhVq5ixxsp+YO7C+LUl XQzW6H4nXYBiDBE0EcXntOPpAe36slbibOn9B2q6XkxrkN3gwWF3Dg8xqd5TjvVtgdVM bRFA== 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=LIgEmBRygWlWYq6zDaryhqi8PdqWfUxAJ5u9Q//8KAY=; fh=roavyBW30WIrfp2zUga7By4lEarjzGbevymZZ4R5sAE=; b=GaUsN2azbXmpsaLn34eaJ8EbmhTHZArBmfBjH6GfUUDhaoJx0Iw6Df6HL9EO0nUB3I Jslfs138LQ96BaX1KCtzgplIQBlvYoC/jwVLH3Ex+T6jnhwyTuBhA0S+iPgezOOwyf+c z1IG2Aj87JZHedKZSkv/YhvsJ2qZUHITjEvr6IkYjngxme9/wsKBk1WRJZZwe669FVm0 HvKX7qy2a/DSzAA8oSpwwFxxhuPjgt4sPuNtnPqEM90wACoKS+TW8WiNEWnvab3Ny73P gWHs3YDT802NNdaPb0vc6PAvpdD2XQgqfvqqv7Wo4oGNn9O1um5SsGgablCLpmUdtMvk r6BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gRO2s7jo; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id bg26-20020a056a02011a00b00573f885c4easi3199670pgb.753.2023.09.15.07.33.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 07:33:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gRO2s7jo; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 44BA0836FFCA; Thu, 14 Sep 2023 11:43:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241930AbjINSlB (ORCPT + 99 others); Thu, 14 Sep 2023 14:41:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241792AbjINSjb (ORCPT ); Thu, 14 Sep 2023 14:39:31 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33BC526A9; Thu, 14 Sep 2023 11:38:59 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716737; 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=LIgEmBRygWlWYq6zDaryhqi8PdqWfUxAJ5u9Q//8KAY=; b=gRO2s7joD8nbugkWdaI7LOhIYz5xn3GZfDZuZpvpZ6MHdZJ26/SJzt0szg/AQ6E1v2+VAo Zoo3d7o/Jp5IxIBA7XGqE4dDWci3vhmUxUzNY5QIkkh99LwTRVQGyW7uKuF37sb9DIgawL Km/1GYpDRxXg7sjjee87eZP+FRGj139SDmrHpCy4VU8lQ0bskpyf8zKEUkpOKvMyoK7uw3 BkCLCALtZw3Beh9T69HF/g81VorzF918kB8WHO6wGYfRxfrCqFYpAKXSx0HvK9ZnS9sBZo wlBfbeAlYbSBWApl9lPqVUT1GkCHGAvS1BT80LcIbX12e+fGvVnusblf+94v3Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716737; 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=LIgEmBRygWlWYq6zDaryhqi8PdqWfUxAJ5u9Q//8KAY=; b=bK0I4A7t7020RZDbb5VCqF9wJQeobL5ue1tpocpk3N+yVYK2sg6AikqLjJrb9YGlY4lfZ0 ITrmNhRMS4dEwhDQ== To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-serial@vger.kernel.org, Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Xiongfeng Wang , Andy Shevchenko Subject: [PATCH tty v1 45/74] serial: pch: Use port lock wrappers Date: Thu, 14 Sep 2023 20:44:02 +0206 Message-Id: <20230914183831.587273-46-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 (groat.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:43:03 -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 groat.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/pch_uart.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index cc83b772b7ca..436cc6d52a11 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c @@ -1347,7 +1347,7 @@ static void pch_uart_set_termios(struct uart_port *port, baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16); spin_lock_irqsave(&priv->lock, flags); - spin_lock(&port->lock); + uart_port_lock(port); uart_update_timeout(port, termios->c_cflag, baud); rtn = pch_uart_hal_set_line(priv, baud, parity, bits, stb); @@ -1360,7 +1360,7 @@ static void pch_uart_set_termios(struct uart_port *port, tty_termios_encode_baud_rate(termios, baud, baud); out: - spin_unlock(&port->lock); + uart_port_unlock(port); spin_unlock_irqrestore(&priv->lock, flags); } @@ -1581,10 +1581,10 @@ pch_console_write(struct console *co, const char *s, unsigned int count) port_locked = 0; } else if (oops_in_progress) { priv_locked = spin_trylock(&priv->lock); - port_locked = spin_trylock(&priv->port.lock); + port_locked = uart_port_trylock(&priv->port); } else { spin_lock(&priv->lock); - spin_lock(&priv->port.lock); + uart_port_lock(&priv->port); } /* @@ -1604,7 +1604,7 @@ pch_console_write(struct console *co, const char *s, unsigned int count) iowrite8(ier, priv->membase + UART_IER); if (port_locked) - spin_unlock(&priv->port.lock); + uart_port_unlock(&priv->port); if (priv_locked) spin_unlock(&priv->lock); local_irq_restore(flags); -- 2.39.2