Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4217940rdb; Thu, 14 Sep 2023 16:00:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHN5G85uC7fn7yEoTTFB/m4hoEJf3Q6uExCT5HjR7vJZf0qXPlepRDSxvPCph7jepf98idt X-Received: by 2002:a05:6a20:8e19:b0:10f:be0:4dce with SMTP id y25-20020a056a208e1900b0010f0be04dcemr151791pzj.8.1694732453670; Thu, 14 Sep 2023 16:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694732453; cv=none; d=google.com; s=arc-20160816; b=QmcWQoHo2sZPsJG/IeUF7CSDVZ8Nuobxr//3x6MT8wbtXe3FbxCfJz9+mGWUDbX1+U x88fdUBtAdEOtkO8j6fTvIqe6EzdC35skoKODMThHj/PU7a4DXlENPFt8AfVlDRN0yBh xOURNyx1RjygW5X+mrX18vAY0CWbp3gkQksGtQz2qP06tw4jufIU/KVfzfl10+EfXN+R +GOTaaLMo936k+5xJR9gvf5L/UZe2Gfx0+FwvUCMY+Xb3mZdNz102JeZoD117zDGwUOb bFqQ12wN9kzsevkjpydUF44XygTnDxuF5Tw3kple+IErcrAgxj5zTKQP1TcgOHU9ZS+C kKxA== 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=W6B6UlYTFshG6RUwUjgz7+c8nYTltsRlBFw4dXdDaIc=; fh=kVFbXZ9QFrO4ZrS3HcFbyAzX9hI3EFiiOnzUxY0LSy4=; b=DMQH5ehbbBW8a17LrM6hTbgZGaq613MVDPrOX3ovCq0K7VhkYUGPXEfOxnDwYzN79u Y5ET9DufkfH8awWcgJGpNp7D7tWLQlH/twRRF9TrGeAIMy9pogmHACsiABE7OrbLIqON KB9Ui76SKsyCDl9f1RSLFhoauJLBVux/hXegcb8WHroEQwrksCUDmKTEB1z7hBKAZy6L VAsAa9D67BfDH54TJLr4iW2xuYFKxZf26A1wgeaVgwZtuYVrCaA6L8ilPLOok5KiKHK9 6YB3AQvO4wr/+RolMl1vEbdB5quMC/mwuCU/vJShB/DUelbIe1ZI47N0O9l0vABYfT7c rSbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Ulo9afi/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=47jTyQrF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id cl4-20020a056a0032c400b006901504b68esi2274318pfb.166.2023.09.14.16.00.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:00:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Ulo9afi/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=47jTyQrF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id C7EB1828DE72; Thu, 14 Sep 2023 11:41:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242011AbjINSkF (ORCPT + 99 others); Thu, 14 Sep 2023 14:40:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241712AbjINSi5 (ORCPT ); Thu, 14 Sep 2023 14:38:57 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31F101FFC; 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=1694716727; 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=W6B6UlYTFshG6RUwUjgz7+c8nYTltsRlBFw4dXdDaIc=; b=Ulo9afi/9JwAEtpEl3ZUs1+lGIMenRJFVgszhjNu6L2spjSDEOPQF8zwCH+5xN/11PJVc9 5xLX2VcVEITFFRc+mDSGZlyFSgGLSqRK2aZLwxuasSiRx8Fx7tefLvk2Ni6p9Kore8cTEL xPDiSOmddfwYTuU5a6p70NG6MdamMY3t4Ij4lcaEL7SRV8ANbX1qlixeyx3hB1MVZflFKl 5Mh/WiwwX41im6JXk6zVQQDS7rsDtZudzrbNkAwlMvUOM2xKdOowv1Hvp9z5AlXZX5FGXq cu43KLeiEpRDwU4gIYXRgOTKGKf4GZ9CkfByUJpYb3ECvOrZoY9CmEW8jCCFEA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716727; 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=W6B6UlYTFshG6RUwUjgz7+c8nYTltsRlBFw4dXdDaIc=; b=47jTyQrFEv1pP3sGvbZ8+7jaCouF0JKrnaWNtL6wtqAU1mfLoyiSVAJB5t6TTsdox9Y3VB G02+bnfuCsTBI3CQ== 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?= , Yangtao Li , Arend van Spriel Subject: [PATCH tty v1 22/74] serial: bcm63xx-uart: Use port lock wrappers Date: Thu, 14 Sep 2023 20:43:39 +0206 Message-Id: <20230914183831.587273-23-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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:41:20 -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 lipwig.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/bcm63xx_uart.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c index 0dd8cceb837c..4a08fd5ee61b 100644 --- a/drivers/tty/serial/bcm63xx_uart.c +++ b/drivers/tty/serial/bcm63xx_uart.c @@ -201,7 +201,7 @@ static void bcm_uart_break_ctl(struct uart_port *port, int ctl) unsigned long flags; unsigned int val; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); val = bcm_uart_readl(port, UART_CTL_REG); if (ctl) @@ -210,7 +210,7 @@ static void bcm_uart_break_ctl(struct uart_port *port, int ctl) val &= ~UART_CTL_XMITBRK_MASK; bcm_uart_writel(port, val, UART_CTL_REG); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } /* @@ -332,7 +332,7 @@ static irqreturn_t bcm_uart_interrupt(int irq, void *dev_id) unsigned int irqstat; port = dev_id; - spin_lock(&port->lock); + uart_port_lock(port); irqstat = bcm_uart_readl(port, UART_IR_REG); if (irqstat & UART_RX_INT_STAT) @@ -353,7 +353,7 @@ static irqreturn_t bcm_uart_interrupt(int irq, void *dev_id) estat & UART_EXTINP_DCD_MASK); } - spin_unlock(&port->lock); + uart_port_unlock(port); return IRQ_HANDLED; } @@ -451,9 +451,9 @@ static void bcm_uart_shutdown(struct uart_port *port) { unsigned long flags; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); bcm_uart_writel(port, 0, UART_IR_REG); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); bcm_uart_disable(port); bcm_uart_flush(port); @@ -470,7 +470,7 @@ static void bcm_uart_set_termios(struct uart_port *port, struct ktermios *new, unsigned long flags; int tries; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); /* Drain the hot tub fully before we power it off for the winter. */ for (tries = 3; !bcm_uart_tx_empty(port) && tries; tries--) @@ -546,7 +546,7 @@ static void bcm_uart_set_termios(struct uart_port *port, struct ktermios *new, uart_update_timeout(port, new->c_cflag, baud); bcm_uart_enable(port); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } /* @@ -712,9 +712,9 @@ static void bcm_console_write(struct console *co, const char *s, /* bcm_uart_interrupt() already took the lock */ locked = 0; } else if (oops_in_progress) { - locked = spin_trylock(&port->lock); + locked = uart_port_trylock(port); } else { - spin_lock(&port->lock); + uart_port_lock(port); locked = 1; } @@ -725,7 +725,7 @@ static void bcm_console_write(struct console *co, const char *s, wait_for_xmitr(port); if (locked) - spin_unlock(&port->lock); + uart_port_unlock(port); local_irq_restore(flags); } -- 2.39.2