From patchwork Thu Sep 14 18:37:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 139769 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp548607vqi; Thu, 14 Sep 2023 11:39:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsSB5877bzZabTS/2J/YGaEsLPe1ij5NVIt7vkKZcn5FDqEOB1hkFBy+WOwUPwhRYWV7mh X-Received: by 2002:a05:6a20:3ca9:b0:145:47af:57d8 with SMTP id b41-20020a056a203ca900b0014547af57d8mr7065951pzj.2.1694716758514; Thu, 14 Sep 2023 11:39:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694716758; cv=none; d=google.com; s=arc-20160816; b=lA9U4fOtmMsneP7szz37I3x4q8F6Arw8o/eJGzGeGf3q3WsliB8rWspVovNkYr7IE1 Bnt/03z0dET8X4YKYAdEJMzZY4COQ4WVZX7ywnBRgbd6iixEfYAXk94WtfIEijIqYmk7 0au14bVPPZnTqtEsiLujXLge1GBtfjpaKZ4CdIBXSGoJZQBC4ZHxZ0A5OgF7rA29rrai hZs9qmTsJOUcHUTYjbDNKN20PdQgYFGX4xmAMlotbqCAT59uZBTMm3QG4pUvaAU3vUFZ /mFWKEnd3PVmBmooPnV9kJjk4jCrPSk3nUf8hkmDbwc6tsFZgxjJulMhQe6BSz76QK7P /Kiw== 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; 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id l19-20020a656813000000b005777125ed83si1933741pgt.238.2023.09.14.11.39.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 11:39:18 -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=g+dINB6i; 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 ECEC583457FD; Thu, 14 Sep 2023 11:39:09 -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 S241578AbjINSix (ORCPT + 33 others); Thu, 14 Sep 2023 14:38:53 -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 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:39:10 -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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777039319707143707 X-GMAIL-MSGID: 1777039319707143707 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)