Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4186662rdb; Thu, 14 Sep 2023 14:45:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOGe5cZQWnEmozzDYKisIUAs+ORoOWFqxZHDUxlkALzYsIvzIEq7owpTI4basZZtEEYLo9 X-Received: by 2002:a05:6358:71a:b0:134:28d6:be7 with SMTP id e26-20020a056358071a00b0013428d60be7mr64870rwj.9.1694727937272; Thu, 14 Sep 2023 14:45:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694727937; cv=none; d=google.com; s=arc-20160816; b=VyXC4gkIb3xFaqLuIPmyRK7/dMuVzdBCO1JwM2cFzqWOfQOeas+0IP20SciDC0tm1H FcoiG7E2luMwEp7qUnz4eaqnQZDbJK/iHCGDNfJrEuUXBNaIB80E7X9FAy6xjeHXSlYr eqA1eHyKQ7QWqvqnEEdvZoq20BHXuYVxgY89E+eXZY/7r4P5mHnezjSM/jpiBIUpPXnp ktzkFvh6qt3I0xN284FlDtOkkJm4z7fFGo5NcDTBc2llyHHSS8DYWl+rnWeUeUJ4RV1z AUoX9cLLfgobySSAjrbNKCsVHCcYOF7GGX9uYbFcid7LiuHmMsCYx8AFZL1xZk2YGMf4 iIzg== 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=OtT3qcU2XT7sBWbeVRoS4eXwomdEnzl8JI54HpXjFPk=; fh=qmZFnekuDs4T9icLmieAH3NNHXuS0/kWBnXi7iQsZPY=; b=FZkk3/qWK1xVsmXaavJWcyRgY7bnf7UA6OUqaXyH9YVbPvxa6FLxMB1XgRWO+azb0A 0SRdr5645kDTHbxd4pAeodnvE1ruR/G2QfuTRLocfMyazMxxQ0Jm+aFrICkfsY/13emD AjtIKbNle7K6i5cSZcTFZvYfj92xuwLiWmZ7tUjE7uDUfCJgWLIfJ45dnvH4hj9DvYvI MBw3mzUHdWkWnn66UKcAHNbPkHPT/yMfrAOjI4ABGbqvPnOD9qTOsvtpGCYob10af3vu g5oqJw2yF/nvI6V2n70Dr8ccRHdskn9vi7oCOgD5cKmuz+joz0jE4ln1GJO85FOUrozX vgUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=16oMLXh+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="z6TexzG/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id cm16-20020a056a020a1000b0057767db4334si2106273pgb.218.2023.09.14.14.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 14:45:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=16oMLXh+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="z6TexzG/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id C479882B4E4B; Thu, 14 Sep 2023 11:39:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241522AbjINSiv (ORCPT + 99 others); Thu, 14 Sep 2023 14:38:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231881AbjINSiq (ORCPT ); Thu, 14 Sep 2023 14:38:46 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE7501FEB; 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=1694716719; 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=OtT3qcU2XT7sBWbeVRoS4eXwomdEnzl8JI54HpXjFPk=; b=16oMLXh+x41buwFBxm6MjmScUALYnbHnctuSlnCJImDb+hw6IInt0wo8Oz7A7El5VEtrzZ ehgyfKluVVW+QLIaiBAOsZTImLOShBkB8G9EBqB7JcGNn5k48TwECuTG4UlOTZH5MSdwHs hxvPohSSTULpW9tg9xJiFxOd0ZreLZGAH4KwMbCe9li0OELjCwmLocizmQc3bfTBXr768z NUkJytLfCrs+3V3XppweqwkkFWHFWXYIwVuw54Qr2Bn/SXld+NLkJHqZYJiI4IvtWPfEKz G8bmjzQrKvBcdEOeUtWsqI2QUQyyEqkFgml+Ze2Au7tqNhW1+CyrEjoNdPbf0w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716719; 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=OtT3qcU2XT7sBWbeVRoS4eXwomdEnzl8JI54HpXjFPk=; b=z6TexzG/00l02Fbtx0bPhdCI79PStLL0Fhn/0+ixK+c/BftQZOZ2PcUkUHXgDPVF8zvEno 3ft3BN8P50LrL+BQ== 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 02/74] serial: core: Use lock wrappers Date: Thu, 14 Sep 2023 20:43:19 +0206 Message-Id: <20230914183831.587273-3-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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:39:29 -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 lipwig.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 --- include/linux/serial_core.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index f1d5c0d1568c..3091c62ec37b 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -1035,14 +1035,14 @@ static inline void uart_unlock_and_check_sysrq(struct uart_port *port) u8 sysrq_ch; if (!port->has_sysrq) { - spin_unlock(&port->lock); + uart_port_unlock(port); return; } sysrq_ch = port->sysrq_ch; port->sysrq_ch = 0; - spin_unlock(&port->lock); + uart_port_unlock(port); if (sysrq_ch) handle_sysrq(sysrq_ch); @@ -1054,14 +1054,14 @@ static inline void uart_unlock_and_check_sysrq_irqrestore(struct uart_port *port u8 sysrq_ch; if (!port->has_sysrq) { - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); return; } sysrq_ch = port->sysrq_ch; port->sysrq_ch = 0; - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); if (sysrq_ch) handle_sysrq(sysrq_ch); @@ -1077,12 +1077,12 @@ static inline int uart_prepare_sysrq_char(struct uart_port *port, u8 ch) } static inline void uart_unlock_and_check_sysrq(struct uart_port *port) { - spin_unlock(&port->lock); + uart_port_unlock(port); } static inline void uart_unlock_and_check_sysrq_irqrestore(struct uart_port *port, unsigned long flags) { - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } #endif /* CONFIG_MAGIC_SYSRQ_SERIAL */ -- 2.39.2