Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5177370rdb; Sat, 16 Sep 2023 06:12:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvPLkJ910HwwLYHEeXvjCIZo48D/jw216Yqr8/jv7UwIwsOqjYyYiacJ/O+feFaK0IBw7U X-Received: by 2002:a05:6e02:e45:b0:34c:c518:a045 with SMTP id l5-20020a056e020e4500b0034cc518a045mr4593146ilk.20.1694869938516; Sat, 16 Sep 2023 06:12:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694869938; cv=none; d=google.com; s=arc-20160816; b=CGz7Li5OElgD0s2X1oMFezYPQa2wSKeJ+Ctx3pQJ4jQo2P9sfHz/Uw/Bn4HV6OWyHl 6zIuQzYY3HHKDvv5X1W1nCWFTcxhM9yP6HJnXOMWDzbd6VKbWj0SCfMJISMH30uLnX+Q tf6cDc76Bxott3WtwQ/mj9IpsDqFzoNuQAZiwi/R3n8m5uX/etSOWYuHzjxOYa65lUgm XufDVbrF8N+95vRixZHEaG5xJ5NGLaGjmopgQMh130OtPyiqRN7JRT2Mp01pFCkQdDtB O7JP5e0cL/LLCdgnR22gNGmbUofn8VTdU4OjFKPrIpN3Iy0jmWtPDKbHoEEDZdDSiyDa Sx5g== 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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l10-20020a654c4a000000b00573f9dbef8asi4711901pgr.266.2023.09.16.06.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 06:12:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; 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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id E91B582F9279; Thu, 14 Sep 2023 11:40:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241866AbjINSkb (ORCPT + 99 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=20J=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 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 (snail.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:40:59 -0700 (PDT) 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; } -- 2.39.2