Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4171933rdb; Thu, 14 Sep 2023 14:10:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvEARVrAHa3ZYjTu7tUCbRrx9qnc4qt4mRvVtaWEpDFkuDiMnpcxdkaBC6UkEmtw0p4TXT X-Received: by 2002:a17:90b:1095:b0:274:7fbc:3f62 with SMTP id gj21-20020a17090b109500b002747fbc3f62mr2756306pjb.16.1694725833315; Thu, 14 Sep 2023 14:10:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694725833; cv=none; d=google.com; s=arc-20160816; b=y67aKdDdEKZzV2FCwF3c5iNevoWsiVl3yOvHm4ix8t3Pud8WUmmyOC7Fy3j41FRdJH 9p6/crLgpHFkXhp/7Hnsb+FGoomf8MjojOl8JTBE0p5G4qJBf1Ry3Pekwwg/TppMsEXd H02udcauN1E9Nhbp4g7BixvVso7PmWYrTzJLy60SwEpoGSsiHrRsvt7fwOiAt5YrsV3V r3R0KbY0vCwZRRixOQJD9Z4sdug7sYcFTONX+G9nnLalYziDykC1C+b9idX3yUzvhLw/ 9hI12zykFjqlLNezBBXJXBxY3gzQzy+dSs1DKgJj5jJXlIDJECvc9BKnq8bD5A/8pDNr y/SQ== 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=fQN7epFxbwh1qF9A3vKlWoOOC6pmuH30heIRIdUdCsw=; fh=9L1ViD0S56AkSRNSwes62XgoaIAK5K8Qs7XnpA5ZCD4=; b=c9sNf21wufz7tgci+w9KWe6+JiBLZQ1tEOYKFwm7EFBA2hct1NpLCLZxNxF/UTrvKA fEfs9oGsvnICIFyeyC00Wz4onOHtj/griP5By6H3MdwZlgQLgUv2BFQ+uCiO/l+MsMsY GzIqtZ2NxaDLg86Hg1ds8yhiJ8A7TIlqzG9CCwz3i92mCL/ufcFEBRibyqLdyM1dMOal Ca7cTYOBC6wwP2sob3SYLH49zufeAuZn5FS1gxuMsyVRCMX+APX7HB4HT2QSp4J7RHOU 4sQIFv4XDNTfKgDHJpjEPCvCw5hcX2S9NjshGu5EDOgVIgoZKmtrWZCQ2b4pB5KtQ3Je YxEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hmi62IBJ; dkim=neutral (no key) header.i=@linutronix.de; 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 76-20020a63024f000000b00574037f35dfsi2153997pgc.360.2023.09.14.14.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 14:10:33 -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=hmi62IBJ; dkim=neutral (no key) header.i=@linutronix.de; 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 E6D8D828FC2E; Thu, 14 Sep 2023 11:42:19 -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 S241981AbjINSlq (ORCPT + 99 others); Thu, 14 Sep 2023 14:41:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241980AbjINSjo (ORCPT ); Thu, 14 Sep 2023 14:39:44 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD9A8270D; Thu, 14 Sep 2023 11:39:02 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716741; 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=fQN7epFxbwh1qF9A3vKlWoOOC6pmuH30heIRIdUdCsw=; b=hmi62IBJprhrBskt+oHKNc4Krp4W/jSVkKbugl+EiEnzpg4bnHZL6tDuwSP35MvhOJqTBF Y2qIjTqZkiorNeiPqCopzo2FMj8YkX/23kq1/zgSju9fnqtV2cfdcWGQA/AtPwUxPW57Ab 4oVbbBmc8Z24NcuPQGwoujNWqBXYpC71pnzj679o/3ud01fI/bc+znMfqELboL6XUIYdP0 Px0Vb2U0dxClP0Y/t+BHowHcGm9a/kyfT4WJpf3gLYLaQD0U6oHrOsYQxdw2n//tEF5MEd 8Fi0Fy7EDg74h00xumLAfvfn2pLsMclcPViRc62XZEe6QTpNztkni3Jvpud+5A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716741; 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=fQN7epFxbwh1qF9A3vKlWoOOC6pmuH30heIRIdUdCsw=; b=kfyQuSVNlXEbogFR65EguwGNHtAhOMowXzjYr76Qoe01RXQd/iZhZ694cqLNmiITysx3Ms BDxZXp3l3vPr59BQ== To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-serial@vger.kernel.org, Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Richard GENOUD , Thierry Reding , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Lukas Bulwahn Subject: [PATCH tty v1 54/74] serial: sb1250-duart: Use port lock wrappers Date: Thu, 14 Sep 2023 20:44:11 +0206 Message-Id: <20230914183831.587273-55-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:42: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/sb1250-duart.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/tty/serial/sb1250-duart.c b/drivers/tty/serial/sb1250-duart.c index f3cd69346482..dbec29d9a6c3 100644 --- a/drivers/tty/serial/sb1250-duart.c +++ b/drivers/tty/serial/sb1250-duart.c @@ -610,7 +610,7 @@ static void sbd_set_termios(struct uart_port *uport, struct ktermios *termios, else aux &= ~M_DUART_CTS_CHNG_ENA; - spin_lock(&uport->lock); + uart_port_lock(uport); if (sport->tx_stopped) command |= M_DUART_TX_DIS; @@ -632,7 +632,7 @@ static void sbd_set_termios(struct uart_port *uport, struct ktermios *termios, write_sbdchn(sport, R_DUART_CMD, command); - spin_unlock(&uport->lock); + uart_port_unlock(uport); } @@ -839,22 +839,22 @@ static void sbd_console_write(struct console *co, const char *s, unsigned int mask; /* Disable transmit interrupts and enable the transmitter. */ - spin_lock_irqsave(&uport->lock, flags); + uart_port_lock_irqsave(uport, &flags); mask = read_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2)); write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), mask & ~M_DUART_IMR_TX); write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_EN); - spin_unlock_irqrestore(&uport->lock, flags); + uart_port_unlock_irqrestore(uport, flags); uart_console_write(&sport->port, s, count, sbd_console_putchar); /* Restore transmit interrupts and the transmitter enable. */ - spin_lock_irqsave(&uport->lock, flags); + uart_port_lock_irqsave(uport, &flags); sbd_line_drain(sport); if (sport->tx_stopped) write_sbdchn(sport, R_DUART_CMD, M_DUART_TX_DIS); write_sbdshr(sport, R_DUART_IMRREG((uport->line) % 2), mask); - spin_unlock_irqrestore(&uport->lock, flags); + uart_port_unlock_irqrestore(uport, flags); } static int __init sbd_console_setup(struct console *co, char *options) -- 2.39.2