Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4272790rdb; Thu, 14 Sep 2023 18:16:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrwXs78u8HF85aMvtfh5MrIQKW+bHTYCz8CbJZqPD1gHnKqFdhCXkyyZW+9mgQvZ+OLzmx X-Received: by 2002:a17:902:e84c:b0:1c3:eb95:2d27 with SMTP id t12-20020a170902e84c00b001c3eb952d27mr341915plg.48.1694740599275; Thu, 14 Sep 2023 18:16:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694740599; cv=none; d=google.com; s=arc-20160816; b=dgTjrHTgxHghJVPVUDvvYgIFRYIIsyb4+hZW2cF4wqVzrAarHR8JONGfAF4WpeZzoW UShZd4QVPo8BtWsr5PWQs+VVMiFfBRGednPD42GAqkqOAYmeigrO8QFwlMTQhd4KEMJw 6n95fMU8K4RHQf4r730x7XZ/+NDjPbukul4G6K04q59IZhOVp8LOn7QnY9+D4Gn90dpd hV0xByiZFBZ6j0Dzxk3q1tv4BlTIMGiEsVrPKFLJIYVee7sCDZUomemMPfQ71AI6Rlvt WLCZ5hjOAWJqATyd3QjZ6y5kitQi1Hh5kfGT4pxjMQz4Gw6AdSA498+RT2JAHM2y2Hmy qFCQ== 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=YJInWHcVqt4j3eK/rdEfaKxcD8K2U9aP/8B1IuSlnT4=; fh=RUyiOqeKMP7+K9FejTnsNEn0ysRmrGkcmf9Ci28CiUU=; b=TAXWQlxhGWqz8uBPt8VtUKe1dvpjvbDTKPjPDOTsKP2sng5aOpJ//z9O2x5U/gGHNP k1wmsUnIS2DOvIqs273JlOetH5e5S8/5Zrp98oKflhocFEw11XaJhEIU2IVbpUyUuDXF 96tKMYGasYLIt7REmTg55QRRm3v2dsfp0ZW/QLJs6iy9a86BBqHBv01Gj9e7rKYebmpu w62oYeiongz9oh/E9y9JDJ34BUqX+j0mVbnvz9+4AtiyWknup2ITMnf6QcyHbsj7C9W5 7mrcMAlKGatOoi9SjupH1yyeH1qMgLYxzRh97ds67uAmuCDXsrSANkTiIL74WZJtSmqN 68Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="WJ4kvtW/"; dkim=neutral (no key) header.i=@linutronix.de header.b=qzZ73KVl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id y10-20020a170902864a00b001bc836180dcsi2436296plt.520.2023.09.14.18.16.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 18:16:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="WJ4kvtW/"; dkim=neutral (no key) header.i=@linutronix.de header.b=qzZ73KVl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id DE94081DF242; Thu, 14 Sep 2023 11:39:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241988AbjINSjw (ORCPT + 99 others); Thu, 14 Sep 2023 14:39:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241716AbjINSi5 (ORCPT ); Thu, 14 Sep 2023 14:38:57 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87C912118; Thu, 14 Sep 2023 11:38:49 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716728; 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=YJInWHcVqt4j3eK/rdEfaKxcD8K2U9aP/8B1IuSlnT4=; b=WJ4kvtW/Klk/02gMpc/36dTKSEBiKrsPeyQpTm47TyugrlRa3xSvyphTVBdLWkj9HyCEXy Qe6cvcJeo0g78iUJIHJ59KvdU2Tzmku8IDNIqcDv98mhoyIy4h4P7uN8ZayAi7WW0zbV3S QLxLZhkPt7PiZqd3EdZYLSDFyPr+PkYSQDb4G7uhGDD3CMBUYreQygN79bpiL40W4Rs9Y6 ocWTdUS6+trFldWScC3epmB+dXCmQ4s+Q3VTeSUyjKard3ZefZVNEQbNoq/YVy7oXenGlw 1Yelc3nlPF6ymmmW123ooVQ6AUTo5qZjHXN+fLKHHED4EBKaYfKDxSp09jt9ww== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716728; 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=YJInWHcVqt4j3eK/rdEfaKxcD8K2U9aP/8B1IuSlnT4=; b=qzZ73KVlbH94C0/unIwHIzsufL+EDGFyJaBMYq/cOVMeReYLKBF1RMmw+o04bW9Lq3Rw26 oUJdipfVYni+ihDg== To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-serial@vger.kernel.org, Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Christophe Leroy , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Subject: [PATCH tty v1 23/74] serial: cpm_uart: Use port lock wrappers Date: Thu, 14 Sep 2023 20:43:40 +0206 Message-Id: <20230914183831.587273-24-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 (pete.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:39:58 -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 pete.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/cpm_uart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/cpm_uart.c b/drivers/tty/serial/cpm_uart.c index 626423022d62..be4af6eda4c2 100644 --- a/drivers/tty/serial/cpm_uart.c +++ b/drivers/tty/serial/cpm_uart.c @@ -569,7 +569,7 @@ static void cpm_uart_set_termios(struct uart_port *port, if ((termios->c_cflag & CREAD) == 0) port->read_status_mask &= ~BD_SC_EMPTY; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); if (IS_SMC(pinfo)) { unsigned int bits = tty_get_frame_size(termios->c_cflag); @@ -609,7 +609,7 @@ static void cpm_uart_set_termios(struct uart_port *port, clk_set_rate(pinfo->clk, baud); else cpm_setbrg(pinfo->brg - 1, baud); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } static const char *cpm_uart_type(struct uart_port *port) @@ -1386,9 +1386,9 @@ static void cpm_uart_console_write(struct console *co, const char *s, cpm_uart_early_write(pinfo, s, count, true); local_irq_restore(flags); } else { - spin_lock_irqsave(&pinfo->port.lock, flags); + uart_port_lock_irqsave(&pinfo->port, &flags); cpm_uart_early_write(pinfo, s, count, true); - spin_unlock_irqrestore(&pinfo->port.lock, flags); + uart_port_unlock_irqrestore(&pinfo->port, flags); } } -- 2.39.2