Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4195945rdb; Thu, 14 Sep 2023 15:06:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLv3yoRReu/tahZZ1kdjb6ZcKrUAU36rrUA+iCT5QCDZwe/H5fPu+sFjItKbJhyrdqSe2j X-Received: by 2002:a17:902:db09:b0:1bf:4582:90d with SMTP id m9-20020a170902db0900b001bf4582090dmr7631020plx.46.1694729201753; Thu, 14 Sep 2023 15:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694729201; cv=none; d=google.com; s=arc-20160816; b=wEkX0kXdQpZI1XHQrNhWKxsnMHhmbpb1dZMrvbTPA0fD6Dbefgr/OBIGKdozf5pIbw Mm0R68cA6Nl1ZkgMl8935QuIe2nr2KAELpWBbWeTq6QKkKR0e66SpD2bZwXwja3KVNCH FpQDQkXQN5erASE6ipak/EMPk+JTbteFqGvMdQhZdL01e60REowQ0QMYomUwIbKC8w10 M+a4I2TiVCaUxXpR+pV3nasqlyn7em0rpxBfjxnpm6LUIFtwta6pmsfAzmM1lBTtbH+S rzUgDpMhG3kHFWd34DMUen2QnX+P5+4FXV/JmVrGxhyQFTTofK3Ew9h6rYr9MhnIt/F/ pCLg== 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=rtv2ooAyzSE0YQWAS7XlGsZho6T7ZcwOVdsZs7LIu1E=; fh=6OVUqJJ9RmtKmXiCGkittoeo83v4SEMI/jDQjp6HBR0=; b=HD7n0JwH2Vrn83aFNmo2jJ3b43lzQQSfS9lkA0hqe+73aoZd8awb17xSWDZkff1ZlQ m1v5CYQftUBRNFfR2K8bAR3wm+dIPcfBgdfSC3sHy7RzvMPlfsXnsawInDTci3sW4vPP /zweWXSIEzVX5y5TqxuD7dRy6czCX0B4V9tnWq6zv7NX/zmOJ5diSdOHMaQrDa+qaruA /gxVV4pN/TSAw+iE6kzy5cMe7vnH2pHSHv+s7yJHtA9UB/D0mrxgzwfw6mhkgTI/PWdp S0nPYV9zSLYm5EFzZmbywPIZik5nnq7+XS+DIBrzQ8l/P4X+iqASr/JZ/uY3f8Ehjxsi lrBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=g+dINB6i; dkim=neutral (no key) header.i=@linutronix.de header.b=PhIqp92k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id l7-20020a170903244700b001b3d6c68bd1si2450955pls.643.2023.09.14.15.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 15:06:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=g+dINB6i; dkim=neutral (no key) header.i=@linutronix.de header.b=PhIqp92k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 062FE8286EB6; Thu, 14 Sep 2023 11:38:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241560AbjINSiw (ORCPT + 99 others); Thu, 14 Sep 2023 14:38:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237683AbjINSiq (ORCPT ); Thu, 14 Sep 2023 14:38:46 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB1341FFB; Thu, 14 Sep 2023 11:38:41 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716720; 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=rtv2ooAyzSE0YQWAS7XlGsZho6T7ZcwOVdsZs7LIu1E=; b=g+dINB6iW64ACyGaujJ1o1fmjmZZbggm+6IGvHEYyUBn1NzpRPs7TAlZjj6IsoY1R6uRqA l02QK0APIRRJEGEHzLmuA3KNxtug5g+ZiMeicDYNS16St1i3YebOJpD8Th+Ih0YDcly03Y 88NV2gWch783aKq55g9nJrpFBkOUi+kX5aDhtwbssvlMaTyqZEhO4g9OM0wPPxDm3k2Dd1 WLbM9DkVbWc/Pmo0rWfMA0lismVw25oXL6aNdf3ZGpKv2Oq7ytfCJtWuGu+AbLDTWO10uR b0MdDi4MZRShdMearsckOqhJOJsQAj23J0JWA6Mgza8OCdfmiqjky48X7C7X3g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716720; 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=rtv2ooAyzSE0YQWAS7XlGsZho6T7ZcwOVdsZs7LIu1E=; b=PhIqp92kh8QdxyU/WhDvrm3+buau2QJZp8tIjUyzIecq6jH+ypbOUQF51L77DTojwzBhYS 2sI3D1mGczaDbsBw== To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-serial@vger.kernel.org, Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Tobias Klauser , Thierry Reding Subject: [PATCH tty v1 03/74] serial: 21285: Use port lock wrappers Date: Thu, 14 Sep 2023 20:43:20 +0206 Message-Id: <20230914183831.587273-4-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:38:54 -0700 (PDT) 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/21285.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/21285.c b/drivers/tty/serial/21285.c index d756fcc884cb..4de0c975ebdc 100644 --- a/drivers/tty/serial/21285.c +++ b/drivers/tty/serial/21285.c @@ -185,14 +185,14 @@ static void serial21285_break_ctl(struct uart_port *port, int break_state) unsigned long flags; unsigned int h_lcr; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); h_lcr = *CSR_H_UBRLCR; if (break_state) h_lcr |= H_UBRLCR_BREAK; else h_lcr &= ~H_UBRLCR_BREAK; *CSR_H_UBRLCR = h_lcr; - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } static int serial21285_startup(struct uart_port *port) @@ -272,7 +272,7 @@ serial21285_set_termios(struct uart_port *port, struct ktermios *termios, if (port->fifosize) h_lcr |= H_UBRLCR_FIFO; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); /* * Update the per-port timeout. @@ -309,7 +309,7 @@ serial21285_set_termios(struct uart_port *port, struct ktermios *termios, *CSR_H_UBRLCR = h_lcr; *CSR_UARTCON = 1; - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } static const char *serial21285_type(struct uart_port *port) -- 2.39.2