From patchwork Thu Sep 14 18:37:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 139895 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp685191vqi; Thu, 14 Sep 2023 16:21:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHl8m11bG2T5iOO6BqXJxmFaelkKtPVdc7cLc4GZxoXm5Vb0NXNro8+aZuDTrRDLwo4X/g6 X-Received: by 2002:a05:6a00:1882:b0:68b:f3a4:ff6b with SMTP id x2-20020a056a00188200b0068bf3a4ff6bmr94301pfh.9.1694733700476; Thu, 14 Sep 2023 16:21:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694733700; cv=none; d=google.com; s=arc-20160816; b=GJ3OW5TzE6Kve71EdjJN21TxxZ84RoIV11zIXr5hEEZmPSDFSj6ruuZpm4v366xCEy GpBGklUnHTFjNhiGY6JFTO0S7DYgpRZOspKkmj4eLPm8A0/Xx5fhYGP7QC+mZpSbsHXy 7+8glYRq1bcenryVL7LL7P4UFb1e1kqmnhJg+ANDGsoZjRAXCmODwEUT/L/cgidrwhtd 7QPyy0J6rLoAwtJoYnRiGUZqFEHk4ISUWmE0Xtych+TajIGcyx3oji1eV+0AF04bs46L DXM7gf0bhZk3Y4U+21lzP+vT/EcueRIdeb+8oNDbVHE4RKHnYVnCXFWjzVPf89BVd/yb KyUw== 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=hpMKqxP39Aj1OlB9VqwDRJumN0r6uN84lHL1pDkCQeE=; fh=N8GgyB99GP1x9ZEOudkqT+MO08NoYIiycAS3VZg0Bx0=; b=q56XYO4GWK2BM+u1FXBhy9ewE+wiMQpf2Jj2EpATagV48fvxM8LaN1QgyjwGhgwfY7 tPmO7FxhFJhPS2VS7qM3oOA6I6omIFY/MuNtr6tro2OEYe3xTOnEh4e+sAh+UAmLvvtC 05bon7Znu/pIbQMJ+YyoA4/zbRfDomYoa60ozMgpRoSKbz29a88lW+CDTymZpLTUj2ls C6oYDzEPoH7OOATq2klJzBHAIo/CzoJk17b5jLdXr8uO5DAlGuGUtjFLcVXqr+Blb06w W2HccjWxFiU88ZI4YjoMEg9g1b+IDQzq7Ux+SI/8IQAP2lYGqNYBY9gHWAmMNjsvmQft Me5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Pp/OGmDj"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id u25-20020a62d459000000b0068896ba4a3fsi2241794pfl.129.2023.09.14.16.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:21:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Pp/OGmDj"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id B7E408325420; Thu, 14 Sep 2023 11:41:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241868AbjINSkb (ORCPT + 33 others); Thu, 14 Sep 2023 14:40:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241837AbjINSjB (ORCPT ); Thu, 14 Sep 2023 14:39:01 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87F152101; Thu, 14 Sep 2023 11:38:56 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716735; 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=hpMKqxP39Aj1OlB9VqwDRJumN0r6uN84lHL1pDkCQeE=; b=Pp/OGmDj8bMmAT9eZ1ySXB//R2G1FfxBh2rCko4qVh2BdTqpXFvZH3XdSA8/Dt5Rmy8Xmf Au2vkXb+sOqd+lUM/wW0LbwmWUmMOItZJ8aipSq6my6kzxRdncDlAzKGX/5t978GKcPpId vZuu2M33td/NUSKgQytJNEGeKqPiPmbK4DA/bL/wwv3GrvnJEBHahKvpM5Yf3n4o/QOkdO m4wjj2Hih6J8cHfLNftCsYGbNH7EWimZgfNjdcCDHyZIyg2Fjvpwj4604kGsuT3NG6etBN JVkGl0gcbLCwXXpWEhYVVwheb41Efq8+HkhAIy2JqF9LjKS6d7HlbaqVUwU6mA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716735; 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=hpMKqxP39Aj1OlB9VqwDRJumN0r6uN84lHL1pDkCQeE=; b=uwgakoj7fG2f6H2ApkMwkAjT0yD56cfGqEkV4wd0dDYU1DBAjq1VStA47ABhHB07vJ5t/R jbBg9GaiGCJPACDg== 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 Subject: [PATCH tty v1 39/74] serial: mpc52xx: Use port lock wrappers Date: Thu, 14 Sep 2023 20:43:56 +0206 Message-Id: <20230914183831.587273-40-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 (groat.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:41:14 -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 groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777057084722454099 X-GMAIL-MSGID: 1777057084722454099 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/mpc52xx_uart.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c index 916507b8f31d..a252465e745f 100644 --- a/drivers/tty/serial/mpc52xx_uart.c +++ b/drivers/tty/serial/mpc52xx_uart.c @@ -1096,14 +1096,14 @@ static void mpc52xx_uart_break_ctl(struct uart_port *port, int ctl) { unsigned long flags; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); if (ctl == -1) psc_ops->command(port, MPC52xx_PSC_START_BRK); else psc_ops->command(port, MPC52xx_PSC_STOP_BRK); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } static int @@ -1214,7 +1214,7 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct ktermios *new, } /* Get the lock */ - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); /* Do our best to flush TX & RX, so we don't lose anything */ /* But we don't wait indefinitely ! */ @@ -1250,7 +1250,7 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct ktermios *new, psc_ops->command(port, MPC52xx_PSC_RX_ENABLE); /* We're all set, release the lock */ - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } static const char * @@ -1477,11 +1477,11 @@ mpc52xx_uart_int(int irq, void *dev_id) struct uart_port *port = dev_id; irqreturn_t ret; - spin_lock(&port->lock); + uart_port_lock(port); ret = psc_ops->handle_irq(port); - spin_unlock(&port->lock); + uart_port_unlock(port); return ret; }