From patchwork Thu Sep 14 18:38:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 139903 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp690278vqi; Thu, 14 Sep 2023 16:33:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJ3IaAAxgpilKWws8wuoLOXR36W0kVT3AVkWvX3oFu+atcC6n7qQ67uv5dlAMrptCNL6mW X-Received: by 2002:a17:902:dacb:b0:1c0:b8fd:9c7 with SMTP id q11-20020a170902dacb00b001c0b8fd09c7mr59789plx.43.1694734430071; Thu, 14 Sep 2023 16:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694734430; cv=none; d=google.com; s=arc-20160816; b=VjZLC5MVVWyI3UzDC9N45v5MdAgfEj8MJ0JRKAAZACBXsRDzga+CJ4uOXxmZefwbNM xEWvX9eTb9M66ISaqsdlMs7d4jCCxDQk9kLFaqkwEeUnYOSTxcNVARJB534zF7h5ry/z 1NUJR+UFuvHwtyTDioGoVRUCIDDQkJ24jY79GUaF0O5G5ekLd8PmHQV0SFwcdRQwHUSh myh57Z9Yc6PCibhAmQBGuNrcXYcoxfQ55BYroiYtF7taoz3QIXBaiar1/lSltvFrXi17 pQuOaTpnLScNNONBuIVDsWagnPHB+kYWpjp0mURjOBfoWIc72+DOwHzsH9I2o03PuZHI by9Q== 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=rrDPhfR+hcH2ulqT+tmz0NkOOAInrrikJFQ9+rrgXq4=; fh=Ag2YM50yIeAneEyz/L6HF86qJmxIutxmMGgZwXdVsb4=; b=Vi5CLwhJXkPgE+oa2P+fHBH1l0ddUMXoXU166t9k0gjPuglQyHO/2Y1We+4FAKdDAh DTKYw6BAUsiQGB5WO169L6n/gQ55EP/X40gh9vXOvkMRokC5WvsPW6lRiNiS+7uMVb9s QvSW2nxS/UDI1dzXfUgH5EAmky0si2Zph9P+6JhmmMzutb+KGpNKTQpNgkykrKcHpxU2 5dfKBXWU1mVYK0vlyc2MngjHuEPztlCof1m00dzgPdo/7rAt76RSl0KBDdkR43yx8+zU irkTESL8YU2Q+Krb4jIYG8VF0e18E4Fhw2XRN4TClnyUsJKc5lTy4vyr9XsCulv974Bw 7s8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=KfjPbYSm; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=zw8NaAfg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id q5-20020a170902a3c500b001b864e277e1si2372039plb.494.2023.09.14.16.33.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:33:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=KfjPbYSm; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=zw8NaAfg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 077A082B97B5; Thu, 14 Sep 2023 11:45:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241976AbjINSoe (ORCPT + 33 others); Thu, 14 Sep 2023 14:44:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242184AbjINSmm (ORCPT ); Thu, 14 Sep 2023 14:42:42 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C532430F6; Thu, 14 Sep 2023 11:39:11 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716750; 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=rrDPhfR+hcH2ulqT+tmz0NkOOAInrrikJFQ9+rrgXq4=; b=KfjPbYSme07Uy0HtarpcBzSFQ1/rLTznLPx3w1c4fArr0Y5kGtKzI/Ul9ouwJRXdZeU/J2 nadN6L18ZJIEZd4/qd77a5MMYgHznr/VdEX4YaV6YEVQg226CMthIInseqEgsZrt2JU/SM hrvtG4v2A0Aab0JSgQ/X2uc19tg5cN7/KsBEEnvqHijZr/ddzu7OZp4NR0MuQksSw5xf4H 1FvccofeL0vCGlTQQkCd1W6zru71arQ7y6L7TSn3XqKLX1H/RoT2P0vGRJJ8EmEGrSaGYG fykGh54wuVQ019BCJGhN5qdhXCIQatyCIpCafbGGWbvjoPvfFCdXRsxKA0zSAQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716750; 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=rrDPhfR+hcH2ulqT+tmz0NkOOAInrrikJFQ9+rrgXq4=; b=zw8NaAfgbtDwAq7EKORtMTWehRQcY0jJ9It/03eZCA4UwTMGL31oJD/g86N0no8XkSo7er qKWevdh86PM28vAg== To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-serial@vger.kernel.org, Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Rob Herring , Mukesh Ojha , Yangtao Li , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , linux-arm-kernel@lists.infradead.org Subject: [PATCH tty v1 73/74] serial: vt8500: Use port lock wrappers Date: Thu, 14 Sep 2023 20:44:30 +0206 Message-Id: <20230914183831.587273-74-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 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:45:07 -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 agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777057849703702092 X-GMAIL-MSGID: 1777057849703702092 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/vt8500_serial.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c index c5d5c2765119..78a1c1eea11b 100644 --- a/drivers/tty/serial/vt8500_serial.c +++ b/drivers/tty/serial/vt8500_serial.c @@ -227,7 +227,7 @@ static irqreturn_t vt8500_irq(int irq, void *dev_id) struct uart_port *port = dev_id; unsigned long isr; - spin_lock(&port->lock); + uart_port_lock(port); isr = vt8500_read(port, VT8500_URISR); /* Acknowledge active status bits */ @@ -240,7 +240,7 @@ static irqreturn_t vt8500_irq(int irq, void *dev_id) if (isr & TCTS) handle_delta_cts(port); - spin_unlock(&port->lock); + uart_port_unlock(port); return IRQ_HANDLED; } @@ -342,7 +342,7 @@ static void vt8500_set_termios(struct uart_port *port, unsigned int baud, lcr; unsigned int loops = 1000; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); /* calculate and set baud rate */ baud = uart_get_baud_rate(port, termios, old, 900, 921600); @@ -410,7 +410,7 @@ static void vt8500_set_termios(struct uart_port *port, vt8500_write(&vt8500_port->uart, 0x881, VT8500_URFCR); vt8500_write(&vt8500_port->uart, vt8500_port->ier, VT8500_URIER); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } static const char *vt8500_type(struct uart_port *port)