From patchwork Thu Sep 14 18:37:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 139829 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp614411vqi; Thu, 14 Sep 2023 13:43:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZJFQZKpDjIfYGYYhJozHMP3uXmipntPT+zRpshGpeedMZ/NN/VBnMtqO34kDy2M/JxSd/ X-Received: by 2002:a05:6a00:2d18:b0:68e:4653:2a2b with SMTP id fa24-20020a056a002d1800b0068e46532a2bmr7141014pfb.24.1694724194139; Thu, 14 Sep 2023 13:43:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694724194; cv=none; d=google.com; s=arc-20160816; b=frTSkmpLTFV3TTFJVPhRB+XBQ0PkG1fww8srhYKSl9BAuncDM8uJerL0VTTWvACXyG WzFNM28iKkI7GpMSma6N4r+tka/ELLAlyQyn0tq7vtI2KFfNUAO1ienfOYmsw/0z/04z HMmw0LRq5hEwxPk8XFfMUJwZ+CYceJXVyhiv6RVLM8ix8mfD9rxaXHUPdvv0VN1VmOa1 UF+8+FKD/bdlol/PZfxGmNvsQT3sdt4fs4aN9kxD1DxmwLB+St57Sexn9OiUHbDbhkVg WmL+hdQXkorhRS9/AAOGtTMJYYJJhy1o45vgUy5jU3QzWi3c2MsohLt42u1d/rdI0ddh GgWg== 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.s=2020e header.b=qzZ73KVl; 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id u9-20020a056a00158900b0068fb895055esi2197802pfk.351.2023.09.14.13.43.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:43:14 -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="WJ4kvtW/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=qzZ73KVl; 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 77F8D83F38D4; Thu, 14 Sep 2023 11:39:53 -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 S241522AbjINSjw (ORCPT + 33 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_J=C3=A4rvinen?= , =?utf-8?q?U?= =?utf-8?q?we_Kleine-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 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:39:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777047116256512806 X-GMAIL-MSGID: 1777047116256512806 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); } }