From patchwork Thu May 25 09:31:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 98930 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp241501vqr; Thu, 25 May 2023 02:58:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7mugaLDjaUwUp8J3wYMxOKhmLV/4RG6DCyx6j+7FUzls7AmGXur+0NiCFlwzDQ4pFb7mHW X-Received: by 2002:a05:6a20:4287:b0:10c:96f0:5f63 with SMTP id o7-20020a056a20428700b0010c96f05f63mr9900121pzj.28.1685008693263; Thu, 25 May 2023 02:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685008693; cv=none; d=google.com; s=arc-20160816; b=A9Ytc+CD7t0QVWJCmqA71sCM6GNKMt7NtDp9Lk6TX4qWd+RWrdYVL6nuR3Ma3/4kp/ LkCLyx0ciXmACq2SYwrTYigSpGATEAIGpuc5fl8ai9NLjWRnrNcDLBB6JGZY1KoyFabH xMrnl12PgQweXGwCCkea5tOvM+GB7vr7vWLpQOFoC+vNlhb7F66Xx9GFDQsrm5CcoImU ig/FxpRJf7M6+cwUwBJqAMCZlafjSbmTvpCnpiyOV6hJf7Ey00HAhLxf1Dt6xk3Ya0FR UZPDtTRKcrqE7wxOmAo/4hk0ZznjDxwfYjTKByjSzvfC9GU75TbyostthaxwNBrr5kGD /BDg== 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=4NGWDH2m9xz3zGie63zl1kcLGjTJ0fX1VflVrGzz2ZQ=; b=Hd0/vxzursKGZxmI2S0wR38tdqj5MO6rFcmqUhMiePccEopmOq/A5C+V3+h4AFWaUW 1HAIadyiKw+ZgEyQVB3yHtyCAWRFOFmumM7Dx+GJppKG4qAzZLzwHL9jpAGYD48Vgb23 T7FCCAhI9umy9AABbATtb/e0SuaK0KVk0ZkP+OaoyTCOVi0plkk6KpAARMxRBewy/jq4 PlK1L7rHXZ/15kuNx1Crzjq2Up+BDzphaEns8MsOMXQnW5NRSPen2qX0iaD8zJ9Kkwqj Jdt3jR0PJXKE8WxxgqeFkeyF9hcIhurW7EemySdflLUQrZGu1yHbMJxDL5O9lhDErvfE LWhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Kja8EByG; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i64-20020a638743000000b00528948f640bsi849670pge.12.2023.05.25.02.58.00; Thu, 25 May 2023 02:58:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Kja8EByG; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240759AbjEYJe4 (ORCPT + 99 others); Thu, 25 May 2023 05:34:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240503AbjEYJek (ORCPT ); Thu, 25 May 2023 05:34:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF70919C; Thu, 25 May 2023 02:34:30 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685007268; 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=4NGWDH2m9xz3zGie63zl1kcLGjTJ0fX1VflVrGzz2ZQ=; b=Kja8EByGHMg80rkSKT9+A6oAP7Ytw5mSKQu0+uGfVfwe5tVdGCEi5josuEM1SwN606+mom tJOhrFWIt2zJG+DlK5DjPmWfVz6loRqSChpbkp8HXvZab2zEzJXhmgL0k+AWUZunXGh4bK ZB+SftTZW59pKhVFlzUNZNYOpZMdX8zxvpepVbJv55/P+jYmWnd8ln/AejbG3dDoZJevAa J7Qto8rkUPaEA13Qh78iauHtxD9/MNjhQsamwocWO64h7fGgSzp5rGrAHv5Xn4mRXNmpig fi0pD7NC4PYFiEdTiZBJclw3eqzxfLzFQqzujGa99ba9O296DwZrG+8YpmfJ+w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685007268; 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=4NGWDH2m9xz3zGie63zl1kcLGjTJ0fX1VflVrGzz2ZQ=; b=mmiTP6jCW1+KvC8QM+LWeB5WcVHbyStKgJqzDNEQsZrG0o3PYsrEqd/a7KE5S+4YPNPZjx 20P+WWxS57IdbmBQ== To: Greg Kroah-Hartman Cc: Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Al Cooper , Broadcom internal kernel review list , Jiri Slaby , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Lino Sanfilippo , Matthew Howell , Tony Lindgren , Lukas Wunner , Matthias Schiffer , Andy Shevchenko , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , linux-serial@vger.kernel.org Subject: [PATCH tty v1 1/8] serial: 8250: lock port in startup() callbacks Date: Thu, 25 May 2023 11:37:52 +0206 Message-Id: <20230525093159.223817-2-john.ogness@linutronix.de> In-Reply-To: <20230525093159.223817-1-john.ogness@linutronix.de> References: <20230525093159.223817-1-john.ogness@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766859675199921612?= X-GMAIL-MSGID: =?utf-8?q?1766859675199921612?= uart_ops startup() callback is called without interrupts disabled and without port->lock locked, relatively late during the boot process (from the call path of console_on_rootfs()). If the device is a console, it was already previously registered and could be actively printing messages. The console printing function serial8250_console_write() modifies the interrupt register (UART_IER) under the port->lock with the pattern: read, clear, restore. Since some startup() callbacks are modifying UART_IER without the port->lock locked, it is possible that the value intended to be written by the startup() callback will get overwritten and be lost. CPU0 CPU1 serial8250_console_write omap_8250_startup -------------------------- ----------------- spin_lock(port->lock) oldval = read(UART_IER) uart_console_write() write(newval, UART_IER) write(oldval, UART_IER) spin_unlock(port->lock) Add port->lock synchronization to the 8250 startup() callbacks where they need to access UART_IER. This avoids racing with serial8250_console_write(). Signed-off-by: John Ogness --- drivers/tty/serial/8250/8250_bcm7271.c | 4 ++++ drivers/tty/serial/8250/8250_exar.c | 4 ++++ drivers/tty/serial/8250/8250_omap.c | 3 +++ drivers/tty/serial/8250/8250_port.c | 18 ++++++++++++++++-- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_bcm7271.c b/drivers/tty/serial/8250/8250_bcm7271.c index f801b1f5b46c..2b38bcc5112e 100644 --- a/drivers/tty/serial/8250/8250_bcm7271.c +++ b/drivers/tty/serial/8250/8250_bcm7271.c @@ -605,9 +605,13 @@ static int brcmuart_startup(struct uart_port *port) /* * Disable the Receive Data Interrupt because the DMA engine * will handle this. + * + * Synchronize UART_IER access against the console. */ + spin_lock_irq(&port->lock); up->ier &= ~UART_IER_RDI; serial_port_out(port, UART_IER, up->ier); + spin_unlock_irq(&port->lock); priv->tx_running = false; priv->dma.rx_dma = NULL; diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c index 64770c62bbec..ae66ef9d863c 100644 --- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c @@ -194,8 +194,12 @@ static int xr17v35x_startup(struct uart_port *port) /* * Make sure all interrups are masked until initialization is * complete and the FIFOs are cleared + * + * Synchronize UART_IER access against the console. */ + spin_lock_irq(&port->lock); serial_port_out(port, UART_IER, 0); + spin_unlock_irq(&port->lock); return serial8250_do_startup(port); } diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c index 5c093dfcee1d..fbca0692aa51 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -710,8 +710,11 @@ static int omap_8250_startup(struct uart_port *port) up->dma = NULL; } + /* Synchronize UART_IER access against the console. */ + spin_lock_irq(&port->lock); up->ier = UART_IER_RLSI | UART_IER_RDI; serial_out(up, UART_IER, up->ier); + spin_unlock_irq(&port->lock); #ifdef CONFIG_PM up->capabilities |= UART_CAP_RPM; diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 0cef9bfd0471..b3971302d8e5 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -2149,7 +2149,12 @@ int serial8250_do_startup(struct uart_port *port) serial8250_rpm_get(up); if (port->type == PORT_16C950) { - /* Wake up and initialize UART */ + /* + * Wake up and initialize UART + * + * Synchronize UART_IER access against the console. + */ + spin_lock_irqsave(&port->lock, flags); up->acr = 0; serial_port_out(port, UART_LCR, UART_LCR_CONF_MODE_B); serial_port_out(port, UART_EFR, UART_EFR_ECB); @@ -2159,12 +2164,19 @@ int serial8250_do_startup(struct uart_port *port) serial_port_out(port, UART_LCR, UART_LCR_CONF_MODE_B); serial_port_out(port, UART_EFR, UART_EFR_ECB); serial_port_out(port, UART_LCR, 0); + spin_unlock_irqrestore(&port->lock, flags); } if (port->type == PORT_DA830) { - /* Reset the port */ + /* + * Reset the port + * + * Synchronize UART_IER access against the console. + */ + spin_lock_irqsave(&port->lock, flags); serial_port_out(port, UART_IER, 0); serial_port_out(port, UART_DA830_PWREMU_MGMT, 0); + spin_unlock_irqrestore(&port->lock, flags); mdelay(10); /* Enable Tx, Rx and free run mode */ @@ -2275,6 +2287,8 @@ int serial8250_do_startup(struct uart_port *port) * this interrupt whenever the transmitter is idle and * the interrupt is enabled. Delays are necessary to * allow register changes to become visible. + * + * Synchronize UART_IER access against the console. */ spin_lock_irqsave(&port->lock, flags); From patchwork Thu May 25 09:31:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 98923 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp232633vqr; Thu, 25 May 2023 02:36:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7E7Fq2udxTamYtmKxXkIuZCGgFTQ4EBZAa2y1YJyQfUioIFFSvy5lRIPRNd41cCpgSwljK X-Received: by 2002:a05:6a00:1a56:b0:64d:3227:b800 with SMTP id h22-20020a056a001a5600b0064d3227b800mr7669458pfv.16.1685007383915; Thu, 25 May 2023 02:36:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685007383; cv=none; d=google.com; s=arc-20160816; b=ZcLJ1JCnADYi4vPhOT/Mzo/ONCkgi2euT0F8J5I2exHAACYXi6gsiUAvebJgk1JbUt +PHzMgiZtVmowFIbGlXYD++4HRd572htz70QghVTbfGm95FA50jeee8SoxZJzLmZB9G/ JSGoIhvm8q8lzErQrXrwn9v4Pg3FSmrJlGb5goQGQCVFBQqyzqPJXH9TOc8EpeNK66jt /0uZjnT4Cu3cFvCNQwbtz9+jjgK+kGAYsRwMoZYqnS3jaNNqVYMXR17bK7MJn1dHnKo3 NrDR+u8aRCahdSvMIl7JlCK7sENhm2ghtr2J88VzKOTyIKmMqtTQl7yPJaUPgE1wrwms QpHw== 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=GfgGfHa1/jsadbpGlnKJSGFRiVJrywAA/VFxC+Yj2dA=; b=lMly6tU5/sbW/zFMPN1UJg7/DRBKObR+b4KbV2boOIn46YbHzIPXgVz54cJBl1+YPf 5Ex1vABuAB+aKgKuJkF8bslys5Piy6lsx4eGaoy93OP7FWKwfy/QiDCm1lbGTfgfBQYK 9+6PPGUIbXiTG/8HY6Og/gWXJnTQhwtLdW6jpCn7UQH1xWGGnzSe36aUgnRaBzx/PTec U0y/q9LVv0MxDDrQ3k+h9MUahONVBRa+kn+36bVZC721qUSZilW0bgAYF/rj3Eazcznd WBxLUfSpjFHgjfbZ+rrhf3bC0s7ZZhNfhonJMfiNkjwuMR9ivYkJDJ00VezR7gXem41a NK1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1XqeSoef; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q20-20020a638c54000000b0053072cbae67si704571pgn.379.2023.05.25.02.36.11; Thu, 25 May 2023 02:36:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1XqeSoef; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240732AbjEYJev (ORCPT + 99 others); Thu, 25 May 2023 05:34:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240547AbjEYJeg (ORCPT ); Thu, 25 May 2023 05:34:36 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF59B197; Thu, 25 May 2023 02:34:30 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685007269; 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=GfgGfHa1/jsadbpGlnKJSGFRiVJrywAA/VFxC+Yj2dA=; b=1XqeSoefdhJJALM506iJsLxxiP33wRzEY/RsMT3xMOtbbwSIZJfn7afMjs2zCnNlZFm+MY 4C4cM0CGhUpbyB2kwn0lz5YTvF/Pt/sQyJPQpL7ICrDoCw7ifmLRZAs55sTnQ6JhTjOZvH P8ygMFRT+3hgG5MJYXN/psukiO3zfw/8WXpvUVy5s/XmOzO/zRZyDvBPeRwWAo7b82kTg8 RQIPSeXcpQpG51Ta2ARcV0PQgJ0IGjyzvmZR59/tZ1sW5mPAgFgBa6+E6wzg55gRrk/i9r Wr2sPsBgf4RtvEO2LM/yU3WOLQ94jsK5nTTOYFi3lG4gpbvRbCWh7zCaCkGkzQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685007269; 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=GfgGfHa1/jsadbpGlnKJSGFRiVJrywAA/VFxC+Yj2dA=; b=Fyn+5UtOwFlmls5SvZ5Pshw2Y2RG5/lrcgn39nVFzwqUwJW/1dghAip25QPfmh228+BFEH xBccxteWawp6g4AQ== To: Greg Kroah-Hartman Cc: Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Jiri Slaby , Vijaya Krishna Nivarthi , linux-serial@vger.kernel.org Subject: [PATCH tty v1 2/8] serial: core: lock port for stop_rx() in uart_suspend_port() Date: Thu, 25 May 2023 11:37:53 +0206 Message-Id: <20230525093159.223817-3-john.ogness@linutronix.de> In-Reply-To: <20230525093159.223817-1-john.ogness@linutronix.de> References: <20230525093159.223817-1-john.ogness@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766858302599312461?= X-GMAIL-MSGID: =?utf-8?q?1766858302599312461?= The uarts_ops stop_rx() callback expects that the port->lock is taken and interrupts are disabled. Fixes: c9d2325cdb92 ("serial: core: Do stop_rx in suspend path for console if console_suspend is disabled") Signed-off-by: John Ogness Reviewed-by: Douglas Anderson --- drivers/tty/serial/serial_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 4b98d13555c0..37ad53616372 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2333,8 +2333,11 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport) * able to Re-start_rx later. */ if (!console_suspend_enabled && uart_console(uport)) { - if (uport->ops->start_rx) + if (uport->ops->start_rx) { + spin_lock_irq(&uport->lock); uport->ops->stop_rx(uport); + spin_unlock_irq(&uport->lock); + } goto unlock; } From patchwork Thu May 25 09:31:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 98929 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp237862vqr; Thu, 25 May 2023 02:48:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5h/dAciohCLTshKCpzOd7rEF7iugLjKnLitwXIFMEThqQvU+rx4S63bAFXzuwFBA1Kk1Gq X-Received: by 2002:a05:6a00:1a93:b0:647:1cb7:b714 with SMTP id e19-20020a056a001a9300b006471cb7b714mr8204532pfv.3.1685008125737; Thu, 25 May 2023 02:48:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685008125; cv=none; d=google.com; s=arc-20160816; b=K42BpyuLdGuSfTxni/JSaYwcVc2Vj+bj904rj/WiMqRIygHZKM5ZfVjOSuNFmuIrJv OG1TPxbYRzcxWo1jKiJZrP4QNJtEc3uKcA4YJOA98IrGbPRUl/eY3B2YVPYmS/doLah7 2xxRhHMvjIzuLxv2OQx81DfDRehn8hUCM4gdFXDWBMnRZqH5yVe0ch5lgD5VVPEARIiq QdRqVVavRHwrG3NTy1A6cma1lBF2Xh3MqrkZcYyveho2dilCI+CRRb3iLNdoe2JguBFZ VXniUlfdD5xrZvBwIVcFRRplKfLO4IvHxt6t/b12xHjzDMB4L5QzLLHnWh7x22HTqfUg 6Z2Q== 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=ja3DzHE65weLmaEmyLLj0yo4U8LIunOOQtWnThWK8is=; b=D0nqno8TvTM7HPDHDgOrBFaBch7GukYnd5wIWK2bXe6Ep0lUxpSsbYHKyH3oVkRHqy fyodWbLlRalbTf+jBogihUkUUdFAjWtQhTnCGo+2pOVToidtnjX6a9QDdwTBZ2uC9sKM r4FSya8QcJgCx0IRr1r8lH33scTb5ZYbM2NULQRTYKm/o9zpRWUYVL6MKUADL5uuH9iG LgB1oNed3sjQ8BNbiyIUOmLzlrIoeOoAGzpMmEKi90tGuclJ/57AebGelEaZCpWpUmgm 0yXGSSuTNiy/28VQWaGRB4Rxqktyspa3z3cOmBxCL/8hL3waHIFzdy991hsEGDyVuANt YM8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=uFW1cntd; dkim=neutral (no key) header.i=@linutronix.de header.b=XMnjW0U5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k76-20020a62844f000000b0064378fd1d54si1082669pfd.258.2023.05.25.02.48.31; Thu, 25 May 2023 02:48:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=uFW1cntd; dkim=neutral (no key) header.i=@linutronix.de header.b=XMnjW0U5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240564AbjEYJem (ORCPT + 99 others); Thu, 25 May 2023 05:34:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240513AbjEYJeg (ORCPT ); Thu, 25 May 2023 05:34:36 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0001519D; Thu, 25 May 2023 02:34:30 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685007269; 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=ja3DzHE65weLmaEmyLLj0yo4U8LIunOOQtWnThWK8is=; b=uFW1cntdseBw4Nlcii3FUzxCE96sV9v1tVE5rbCJukpWARo0YvyDW7fNUPGg0FvNu6s1L4 t6We7a+2Z00Cq4YA+JMYTYuZrCzXPGgGyJu+VA6wDf9iXY1rTSJq2gin2OAdXzi4jlhSJJ 3e5VGO1cy8G/CiPauZwJFH61Mzyo8Z20iM27bMRS7h9OvjQ2RdwbjGLpOPPL6ZUXBR4I36 1Ejn83BGTNE4mxbHsoFkj+NO3zwSvdZ1CAdcexT1vBAsCmHNCuGvOHisxD7cSP9Gs2xDTE 1RW8HccAkhT8ktSDbML28YHUcHpu+Y80gH4/AE+K4LHshnnL6lSWW05OlabDBA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685007269; 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=ja3DzHE65weLmaEmyLLj0yo4U8LIunOOQtWnThWK8is=; b=XMnjW0U55afe9vxq3aGUAviz6nfwdyywSmRFA3DlpYPJOAS2TclvYZK+gOQ4tF0Z+gwo/b sCv7GuZAsSdAu5AA== To: Greg Kroah-Hartman Cc: Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Jiri Slaby , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Tony Lindgren , Lukas Wunner , Matthias Schiffer , linux-serial@vger.kernel.org Subject: [PATCH tty v1 3/8] serial: 8250: lock port for stop_rx() in omap8250_irq() Date: Thu, 25 May 2023 11:37:54 +0206 Message-Id: <20230525093159.223817-4-john.ogness@linutronix.de> In-Reply-To: <20230525093159.223817-1-john.ogness@linutronix.de> References: <20230525093159.223817-1-john.ogness@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766859080603968781?= X-GMAIL-MSGID: =?utf-8?q?1766859080603968781?= The uarts_ops stop_rx() callback expects that the port->lock is taken and interrupts are disabled. Fixes: 1fe0e1fa3209 ("serial: 8250_omap: Handle optional overrun-throttle-ms property") Signed-off-by: John Ogness Reviewed-by: Tony Lindgren --- drivers/tty/serial/8250/8250_omap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c index fbca0692aa51..c17d98161d5e 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -658,7 +658,9 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id) up->ier = port->serial_in(port, UART_IER); if (up->ier & (UART_IER_RLSI | UART_IER_RDI)) { + spin_lock(&port->lock); port->ops->stop_rx(port); + spin_unlock(&port->lock); } else { /* Keep restarting the timer until * the input overrun subsides. From patchwork Thu May 25 09:31:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 98927 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp235455vqr; Thu, 25 May 2023 02:43:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4u6fad11LWulHIuGxbIeGvTkv1frv79dZYCADyayA1Mo3v1K4Waj5TRWJQHncMsgma8djP X-Received: by 2002:a17:90a:6b41:b0:255:b1d3:5220 with SMTP id x1-20020a17090a6b4100b00255b1d35220mr1014738pjl.20.1685007780946; Thu, 25 May 2023 02:43:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685007780; cv=none; d=google.com; s=arc-20160816; b=RGRjYhnXTPtO3KAw7eyJ9B0j9zskWFgh5RiW7Mr91RrNlCSvnFOdSDvn5jqQrOB4y+ ecX660IMiT8ZHQ4P6CGn0PgJEjLocdQjNWg18Vq36wzBhXrHEx0qdDS1NigjS9OYi15q szhuxnGjWWrjqTKfCX5vE6z+IqMUhCIPw/C0NM5h9fz6KOm8PxxskAdXoFEWzBl9m0x/ wDWXxZPLaFlvXTZzn4NKgSW9NxBo+9N+PBuigiK0S6B3AboAl7Zay1UidBo/8vr9LLpG DEkV34et2ff/9Kh5jZKimyxbajpXNP8f+/GCDxxO8x6JLxf1yafP88TYLD9gSs7IbuQI UUaQ== 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=4e3/MmglhQzDhzxZKmrh29ltZzGLtHjU6m+4lcF3Ohc=; b=XZmYyt8RB8SfWFjpTxrIP9GlBokSIY3SfVB6rG2QBinorv+Vm8m2LhqIBiBcJpWfNt HlOygyzC0ktglpULAQRdLguD8Gg0ILFXIDFvT+/N/ZQfusojub/5So8BUFZ5GQHb1Apn K1XweF/CPwvdFcEsPEzM65IMWTaPhqFyLUs3pSolIeOAlA7hiBoanI+jUtzykbiiuwB3 7vWpFKTHwJy89mafI4OllMBGUCLrluyeFt4qgKLQtVtOTwrOh1+FlAshd4kL3B8gqp1c KYKCSsCh8pzeDtQxpPTTKzESvxRyDGvp3rZfnKwIOsS1B5NQ6xmK9GvlKylyeksrLmsl +M3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NTr1IkyQ; dkim=neutral (no key) header.i=@linutronix.de header.b="OQ/ky65D"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gz24-20020a17090b0ed800b0024e2c5e3a4asi1149052pjb.132.2023.05.25.02.42.46; Thu, 25 May 2023 02:43:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NTr1IkyQ; dkim=neutral (no key) header.i=@linutronix.de header.b="OQ/ky65D"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240681AbjEYJep (ORCPT + 99 others); Thu, 25 May 2023 05:34:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240519AbjEYJeg (ORCPT ); Thu, 25 May 2023 05:34:36 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 548C71A2; Thu, 25 May 2023 02:34:31 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685007269; 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=4e3/MmglhQzDhzxZKmrh29ltZzGLtHjU6m+4lcF3Ohc=; b=NTr1IkyQZ3OjcNlK4kp6xH1FWtIZitO+012FKXjtrrK1TncJzHvVRCKB2HJMfrJeLNwbdv JqTB4lbCkHpWdmGVU5IV0oSMOrnCgco1IrJYFalyMgIYhkmoF+ls8sWoIXWwGHBTvAv2VM AsESQbtcYDRinZpSMAv2lQTsnptfIbem7K8AtFoGqFwud1/rfvw7F05ZvxvRy0LATu+F8T D+EFAcJK7ms+VnYmR2p2r9Qpx1ZLFq6Z0RTlRc1a0UNByZ9v138z6/F1HL5D3TdYva9DEW wga+ysXcWpNnhcGd/bCi+WRLYUf/VVV3R00jadPPgDtnIqKZbThruZgML7Vlfw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685007269; 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=4e3/MmglhQzDhzxZKmrh29ltZzGLtHjU6m+4lcF3Ohc=; b=OQ/ky65DAwfr8I0FKrHj0L+b/kkpcdBW/cvTc4v+Gja6TPoPnsWTFi/SGx6YP134mMOLhZ Z42apekShbMWanBQ== To: Greg Kroah-Hartman Cc: Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Jiri Slaby , Vijaya Krishna Nivarthi , Douglas Anderson , linux-serial@vger.kernel.org Subject: [PATCH tty v1 4/8] serial: core: lock port for start_rx() in uart_resume_port() Date: Thu, 25 May 2023 11:37:55 +0206 Message-Id: <20230525093159.223817-5-john.ogness@linutronix.de> In-Reply-To: <20230525093159.223817-1-john.ogness@linutronix.de> References: <20230525093159.223817-1-john.ogness@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766858719087730823?= X-GMAIL-MSGID: =?utf-8?q?1766858719087730823?= The only user of the start_rx() callback (qcom_geni) directly calls its own stop_rx() callback. Since stop_rx() requires that the port->lock is taken and interrupts are disabled, the start_rx() callback has the same requirement. Fixes: cfab87c2c271 ("serial: core: Introduce callback for start_rx and do stop_rx in suspend only if this callback implementation is present.") Signed-off-by: John Ogness Reviewed-by: Douglas Anderson --- drivers/tty/serial/serial_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 37ad53616372..f856c7fae2fd 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2430,8 +2430,11 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport) if (console_suspend_enabled) uart_change_pm(state, UART_PM_STATE_ON); uport->ops->set_termios(uport, &termios, NULL); - if (!console_suspend_enabled && uport->ops->start_rx) + if (!console_suspend_enabled && uport->ops->start_rx) { + spin_lock_irq(&uport->lock); uport->ops->start_rx(uport); + spin_unlock_irq(&uport->lock); + } if (console_suspend_enabled) console_start(uport->cons); } From patchwork Thu May 25 09:31: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: 98924 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp233109vqr; Thu, 25 May 2023 02:37:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6HjIx4YvGOK64Ybqu+XG5q4DLvakG6/umy1+z+F0ZFN1U5ZeNA/RxLF7Ir5SHGhO9MgR5H X-Received: by 2002:a17:90b:3802:b0:253:3975:7a37 with SMTP id mq2-20020a17090b380200b0025339757a37mr1216747pjb.9.1685007454813; Thu, 25 May 2023 02:37:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685007454; cv=none; d=google.com; s=arc-20160816; b=BXoILAM8kz5SWRnSzp5r2fS6ch1cTe7PRyPKrgnBwT8Zos3ECaUT7Djg6xxIpAxiYe 08acFWisSXKa3NP+YxYZJBpM6MHXdxV7dVfS+fTCFEgUlHoVPZVIAwXhTwpOtO+nE12h vwiwlULnySuyb/5a/WvM3l2bbLeSwMN7yD9xG3Cu6DBn3+RQJGsfUvIh/2nvPbM/NLUD 1pFtYeHnKWDjJ7T8kvV+hIKHuJyYqWAVu2wVD+G24YeR84Dd/l2o0ZPrhT3KHcSCHjKg 4ygHje18of9Cc4LRGgvxBB+UyIijlDAUSRcDxwlEjlLpAFTo2OlWgexDSmmYo6WCClOl tPGQ== 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=TAVFpLxJcM8gO8l/0bCuwkiWYAOYDDSeRboLXbR9Aek=; b=BvYB3yKP+AZWeVTsVPanR4UwfIseyqu4Npc2U7EoqDWtWVT98Djd809TcEZbqAnoWu uV1WPk/13w37Q5yE3i+cfMrLpGYDpBCqAMT1vxusL0vkPQqVNZjYtooqsSBiJtgI44/O Wx+LOUSQj9hRVeB7UUc7XYOlCx38Kk7yUJz6RjGz5+vgovq3drSqY2VGST3KaETnSwEh Yw8WEn03JFt3eB+UFFMgMAFEqwAz8AdAkuohgDhvuYwICJPVd4CEzrt558qim1fRZjTI uvb6zJ42cfeERDjEyTqTv63yiDDup3UX5e6R3A9YzZl7mMZjoonlMqQmuC9BOo1SjdcF XUYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ykmKrFJz; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=gCBfiyyG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q20-20020a638c54000000b0053072cbae67si704571pgn.379.2023.05.25.02.37.21; Thu, 25 May 2023 02:37:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ykmKrFJz; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=gCBfiyyG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240658AbjEYJfJ (ORCPT + 99 others); Thu, 25 May 2023 05:35:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240605AbjEYJek (ORCPT ); Thu, 25 May 2023 05:34:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07D0A1B4; Thu, 25 May 2023 02:34:33 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685007270; 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=TAVFpLxJcM8gO8l/0bCuwkiWYAOYDDSeRboLXbR9Aek=; b=ykmKrFJzIEPB1IJaAecFMnbuPRNqq8W4v0ilizJRs2eB4zd7ETFHwUxbF6Df2nqmYD3Iq+ fVFjwJfAyXYbyQ05LIMuNPGD+V8a3Qfq+DoyY8wFHmCWzMRxEySwmgevQYbQSAebVZ88wu sda0dyy9wmEABP85uFpf+hZ2J1e7hZFZpvTZi6Vacwpz2CIeNzQvnrJDeaJlwwdrf2ERWc qT0fokVrR9JnRGf0lWBhxElkKlDcyksM6NBA/+ksbX+eoOEuwM9K7cf8p0ox724pBIn+Ho qsqu64ECv7iV41bH5ziiJqXDxAN8+hvvf2wTF8cDXJ/PW6fNBRIYGFAvWGKNHw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685007270; 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=TAVFpLxJcM8gO8l/0bCuwkiWYAOYDDSeRboLXbR9Aek=; b=gCBfiyyGHO59EVDJPrbMzAqqpgW3m+JHu7zU/NjqtshBqw/l5TgEsDdTfEc/lNCqnfW0rW 3RBdS105E0pyplAw== To: Greg Kroah-Hartman Cc: Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Jiri Slaby , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Tony Lindgren , Lukas Wunner , Matthias Schiffer , linux-serial@vger.kernel.org Subject: [PATCH tty v1 5/8] serial: 8250: lock port for rx_dma() callback Date: Thu, 25 May 2023 11:37:56 +0206 Message-Id: <20230525093159.223817-6-john.ogness@linutronix.de> In-Reply-To: <20230525093159.223817-1-john.ogness@linutronix.de> References: <20230525093159.223817-1-john.ogness@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766858377043284589?= X-GMAIL-MSGID: =?utf-8?q?1766858377043284589?= The rx_dma() callback (omap_8250_rx_dma) accesses UART_IER. This register is modified twice by each console write (serial8250_console_write()) under the port lock. However, not all calls to the rx_dma() callback are under the port lock. Add the missing port locking around rx_dma() callback calls. Add lockdep notation to the omap_8250_rx_dma(). Note that this is not fixing a real problem because: 1. Currently DMA is forced off for 8250_omap consoles. 2. The serial devices are resumed before console printing is enabled. However, adding this locking allows for clean locking semantics for the rx_dma() callback so that lockdep can be used to identify possible problems in the future. It also simplifies synchronization of UART_IER in general by not needing to rely on implementation details such as 1 and 2. Signed-off-by: John Ogness --- drivers/tty/serial/8250/8250_omap.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c index c17d98161d5e..3cb9cfa62331 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -728,8 +728,11 @@ static int omap_8250_startup(struct uart_port *port) priv->wer |= OMAP_UART_TX_WAKEUP_EN; serial_out(up, UART_OMAP_WER, priv->wer); - if (up->dma && !(priv->habit & UART_HAS_EFR2)) + if (up->dma && !(priv->habit & UART_HAS_EFR2)) { + spin_lock_irq(&port->lock); up->dma->rx_dma(up); + spin_unlock_irq(&port->lock); + } enable_irq(up->port.irq); @@ -1003,6 +1006,9 @@ static int omap_8250_rx_dma(struct uart_8250_port *p) unsigned long flags; u32 reg; + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&p->port.lock); + if (priv->rx_dma_broken) return -EINVAL; @@ -1736,8 +1742,11 @@ static int omap8250_runtime_resume(struct device *dev) if (up && omap8250_lost_context(up)) omap8250_restore_regs(up); - if (up && up->dma && up->dma->rxchan && !(priv->habit & UART_HAS_EFR2)) + if (up && up->dma && up->dma->rxchan && !(priv->habit & UART_HAS_EFR2)) { + spin_lock_irq(&up->port.lock); omap_8250_rx_dma(up); + spin_unlock_irq(&up->port.lock); + } priv->latency = priv->calc_latency; schedule_work(&priv->qos_work); From patchwork Thu May 25 09:31:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 98928 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp237589vqr; Thu, 25 May 2023 02:48:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5lnpzzK4gO2dPuN8lQVYKZWe0Yvm9MRXlAXrWU0HZ18Ls40EU+VzL1hTRNDmdAixx3Pzs5 X-Received: by 2002:a05:6a21:78a5:b0:10e:e58d:ce85 with SMTP id bf37-20020a056a2178a500b0010ee58dce85mr2735475pzc.10.1685008084824; Thu, 25 May 2023 02:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685008084; cv=none; d=google.com; s=arc-20160816; b=pMdtabyrROxXvVfAK7IlKNN53biJ/gGe5/tp9Owxz9pxftUWGj19GsbURPR6XN7lGA vfT4hk5vkyDVb2hWMA8dHd8uYYG3xbBEHW56UK5L5XHDvT2nYEh8yzDhTXeeWCN3uXOE pe4NN/Fb+dDjkychy3mMhczh0hpo8PcxIDmr4xKy0A6RHGsqZERTNGr7z91D3rTx1/9d 8QNMr3gL7qTcnUd0wO52xxi8e+0cc9iXgbdo8fNRV600C1Gpv1/mqqOQgRNIJ9jeS/qn q0h7wP77FUhTuPDgK+4mFs6x7nwdViREDWF1Ly6IgSXnKzCgE+egXYJFFoK8gwFmB12c /YNg== 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=nPDJHm4lU4uW5PYPRilpSR3PUXlYNGeyc1k5gm2WMrg=; b=DWRCnBMRT00T+9fmnpkda3A/Vv0pUh5FUT2oJ7LEeMtiHEtiA4VNcX2yLyELj3JvBG jLmpgPHD00sfi52/efTv1tGahwUhLzrzEeqyZ0wuIyEZViRIJRT1QDf6mSyLNsJxQAW7 R2rEz60II0+wxxiXq5/auzKFdquBSSQhAeasc7QOW3mmxxwG0VIaeBd2si6xVIiZLD2s iQIdSSqPH+BH/eVbPrLxUmLn18SY5cFONmyVnjXJngvl3sdKLY6YJp2GrQMJJSYp7xlu DW1d3mbvry8iRWO8ayZjnLHwrWI5YUILbVgDtxYzM97fLEECpnFF6f71NuKy9dmkfBnR 64kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Bn9RR6tF; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k76-20020a62844f000000b0064378fd1d54si1082669pfd.258.2023.05.25.02.47.49; Thu, 25 May 2023 02:48:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Bn9RR6tF; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240726AbjEYJfP (ORCPT + 99 others); Thu, 25 May 2023 05:35:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240627AbjEYJel (ORCPT ); Thu, 25 May 2023 05:34:41 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 074271B1; Thu, 25 May 2023 02:34:33 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685007270; 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=nPDJHm4lU4uW5PYPRilpSR3PUXlYNGeyc1k5gm2WMrg=; b=Bn9RR6tFw4VHxMRtNu5ITPrZWhJi9VsTk3Ief2f7HcBlEtLMBnVNouWr0IM4OCsP02Dq7Q gdWxPPKFD6kokGHfylzCLf1elFujWvrjGvnJqujbqfHuADfuMLyd6ENik68sarNNrhQFuE c4RkxSMLo7Jg4Ctn+oJapV4snGobAEx0h5zm/6LKkgV48KMBlXtUQ7u4cf07BFSCaEYVjs CLVHT/h0C+zTSycU3IFxqCaSwRZY02Qgl4LpRpu15aLv5QBON8m6QA+BXf3T7MUmdcMh/v tARTQSo+S9rmvPFdJm8rCofDsynBzdEdXV+R9vlJp9w5Fe5d9Bc6DCZitRM3iw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685007270; 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=nPDJHm4lU4uW5PYPRilpSR3PUXlYNGeyc1k5gm2WMrg=; b=D7c8sfO9B0xWafdKccZQxoeJ+NYAiCmP6zJoGfo+FNhKFSWjUhH4xcqrDjjtHasOyuCFUa o6+70hF7B7N+QMDA== To: Greg Kroah-Hartman Cc: Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Jiri Slaby , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Tony Lindgren , Lukas Wunner , Matthias Schiffer , linux-serial@vger.kernel.org Subject: [PATCH tty v1 6/8] serial: 8250: lock port for omap8250_restore_regs() Date: Thu, 25 May 2023 11:37:57 +0206 Message-Id: <20230525093159.223817-7-john.ogness@linutronix.de> In-Reply-To: <20230525093159.223817-1-john.ogness@linutronix.de> References: <20230525093159.223817-1-john.ogness@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766859037210675749?= X-GMAIL-MSGID: =?utf-8?q?1766859037210675749?= omap8250_restore_regs() accesses UART_IER. This register is modified twice by each console write (serial8250_console_write()) under the port lock. However, not all calls to omap8250_restore_regs() are under the port lock. Add the missing port locking around omap8250_restore_regs() calls. Add lockdep notation to the omap8250_restore_regs(). Note that this is not fixing a real problem because the serial devices are resumed before console printing is enabled. However, adding this locking allows for clean locking semantics for omap8250_restore_regs() so that lockdep can be used to identify possible problems in the future. It also simplifies synchronization of UART_IER in general by not needing to rely on such implementation details. Signed-off-by: John Ogness --- drivers/tty/serial/8250/8250_omap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c index 3cb9cfa62331..34939462fd69 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -309,6 +309,9 @@ static void omap8250_restore_regs(struct uart_8250_port *up) struct uart_8250_dma *dma = up->dma; u8 mcr = serial8250_in_MCR(up); + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&up->port.lock); + if (dma && dma->tx_running) { /* * TCSANOW requests the change to occur immediately however if @@ -1739,8 +1742,11 @@ static int omap8250_runtime_resume(struct device *dev) if (priv->line >= 0) up = serial8250_get_port(priv->line); - if (up && omap8250_lost_context(up)) + if (up && omap8250_lost_context(up)) { + spin_lock_irq(&up->port.lock); omap8250_restore_regs(up); + spin_unlock_irq(&up->port.lock); + } if (up && up->dma && up->dma->rxchan && !(priv->habit & UART_HAS_EFR2)) { spin_lock_irq(&up->port.lock); From patchwork Thu May 25 09:31:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 98925 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp233614vqr; Thu, 25 May 2023 02:38:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6GYoono2SbpkZEtb2ghnOlEr2BRYSngKgi65z7uxRnVyvJ90QC3mumnfvdIJA9tZz5MBnH X-Received: by 2002:a17:90b:4a4f:b0:255:3b09:6ef5 with SMTP id lb15-20020a17090b4a4f00b002553b096ef5mr1063984pjb.44.1685007524060; Thu, 25 May 2023 02:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685007524; cv=none; d=google.com; s=arc-20160816; b=N/goR1My74zviF6A1AeH4KXglX5QrbIKxXXQ0n5joyt7W1v+lpjh8UbeCb7mF0imZt yF/av5NMgEu0xM/91i2SPWybY3EifCI0OI4jf76b6OMQ0i2QjwBSGXsjQuBx5wCByk+M NTx15YeuK1FDoz242QXeVqgQj01S+nIKQYqnNYKMjodA4F4TrEoMdmsDtQPgwCLExHlS F9+PekK8uUdJ5DXI2zLvcsx1O1w8UMsgEf7yZArSMqBv/bHAbVxxViR/iA/PTBgCI1As wTzC1fss3G5aVlhVwAXG0DO3ulXF0U1GOnuUC/6kxdDiCJbM5eNyFtSR2q5SdrlE1wCH Q4dg== 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=6UePhmuOlccQPrukH0wHmWv4ftbqOBpeN2xQeS1c0hQ=; b=CK/0+MJAwkvCk/phsHNw9s/VlVoTUQNEYvDLX2T9+EXek8Nu3mTjKPCM8PzS1n9eoZ +fw2svLpn0ZeBqJIUDgFe8Fsrp7FsKbn/1WEc/8A4WCkGXfFOQFkac2m8lSqPynRHb1W 21B2p1HkwR2QIWqHnlv8ooTCHwlo+5E0pMcMwDdD9+SCWO/NPCWuDdkj76OfqRFF7Fqn W3Zn2yLgBmRUq7D3mKXncGDKOTY9y28Q8zCLW7veoyti7QLcGRXM7dnyHSeJmJuKMppB kM3b66QV9j40VKBXzM/tfFDmAGkmk/vaASVWZuGlEmpUXdyaPVr3aSkEDSPRHJc1TDD9 oAjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=MQzqE+Yw; dkim=neutral (no key) header.i=@linutronix.de header.b=1cZB2z7J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s23-20020a17090aba1700b0024bda568513si1098267pjr.123.2023.05.25.02.38.30; Thu, 25 May 2023 02:38:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=MQzqE+Yw; dkim=neutral (no key) header.i=@linutronix.de header.b=1cZB2z7J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240737AbjEYJfT (ORCPT + 99 others); Thu, 25 May 2023 05:35:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240507AbjEYJem (ORCPT ); Thu, 25 May 2023 05:34: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 57268E43; Thu, 25 May 2023 02:34:37 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685007271; 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=6UePhmuOlccQPrukH0wHmWv4ftbqOBpeN2xQeS1c0hQ=; b=MQzqE+YwkU6EWfWTwWtWZv/w8j/DF13mM+sZsxWgRUqQWoda//KIf2ceBm4fX/z018WnnR 3S2l0ZIg/rzqINrnbsv4+/Xj9K8d2iYpoQEV4V8I9U5na8tc/9aSrHtIAwsVxtzAP9qkwI r5g0YpjrPlXGuFz4EDwggFCuB8C2COz4vpaGhgol/nVsEaEeQxOPu502kLiBAXK3AQ/j/f xyUHqLUz+feUuKjUlKSFG6JK5TR3Gu/ziDkw22pV7EMwR6oBxa9oQEnOJkFc3zJdJlQIaO hjswhAOvU/qvv6rfvmy1H1FJPTKHCPJlOuPucYSnpT64gt7ejhmmWAe5lnKkaw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685007271; 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=6UePhmuOlccQPrukH0wHmWv4ftbqOBpeN2xQeS1c0hQ=; b=1cZB2z7Jl8jwfFvDISRhYZME1R2qmyJNn3L7OjY1A10/Y+u1VlvnKA+PHjTQQgZ+m+tAJw IVG+702no0FxTaAQ== To: Greg Kroah-Hartman Cc: Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Jiri Slaby , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Tony Lindgren , Lukas Wunner , Matthias Schiffer , linux-serial@vger.kernel.org Subject: [PATCH tty v1 7/8] serial: 8250: lock port for UART_IER access in omap8250_irq() Date: Thu, 25 May 2023 11:37:58 +0206 Message-Id: <20230525093159.223817-8-john.ogness@linutronix.de> In-Reply-To: <20230525093159.223817-1-john.ogness@linutronix.de> References: <20230525093159.223817-1-john.ogness@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766858449732972272?= X-GMAIL-MSGID: =?utf-8?q?1766858449732972272?= omap8250_irq() accesses UART_IER. This register is modified twice by each console write (serial8250_console_write()) under the port lock. omap8250_irq() must also take the port lock to guanentee synchronized access to UART_IER. Since the port lock is already being taken for the stop_rx() callback and since it is safe to call cancel_delayed_work() while holding the port lock, simply extend the port lock region to include UART_IER access. Fixes: 1fe0e1fa3209 ("serial: 8250_omap: Handle optional overrun-throttle-ms property") Signed-off-by: John Ogness Reviewed-by: Tony Lindgren --- drivers/tty/serial/8250/8250_omap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c index 34939462fd69..3225c95fde1d 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -659,17 +659,18 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id) if ((lsr & UART_LSR_OE) && up->overrun_backoff_time_ms > 0) { unsigned long delay; + /* Synchronize UART_IER access against the console. */ + spin_lock(&port->lock); up->ier = port->serial_in(port, UART_IER); if (up->ier & (UART_IER_RLSI | UART_IER_RDI)) { - spin_lock(&port->lock); port->ops->stop_rx(port); - spin_unlock(&port->lock); } else { /* Keep restarting the timer until * the input overrun subsides. */ cancel_delayed_work(&up->overrun_backoff); } + spin_unlock(&port->lock); delay = msecs_to_jiffies(up->overrun_backoff_time_ms); schedule_delayed_work(&up->overrun_backoff, delay); From patchwork Thu May 25 09:31:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 98926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp233844vqr; Thu, 25 May 2023 02:39:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4IQGA1Nq9WEw/1Ay4YK+M6lJpFhBDwwIzDl8Qubip9GCEdUoanO4O9zmNoH93gRSyQR8Tc X-Received: by 2002:a17:90b:11c9:b0:253:3eb5:3ade with SMTP id gv9-20020a17090b11c900b002533eb53ademr844875pjb.8.1685007561739; Thu, 25 May 2023 02:39:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685007561; cv=none; d=google.com; s=arc-20160816; b=fgJv5XwDBkuZqYJys1udMGHbYtRd5MvRNIFbOmpV+q8aKSNADKw/I01TJOJQcDL1Hy c1h2vbTM2SzanTgXhyBr825OGnnGUaOHuAQqztcP6Kj9JAhuET0bua8uwCwWIwOgw60t CCLKXDpQ8clmuwkDC6DsX6GCFZantjn4ecGEhcO5zglYJUZ9bJY/3XGnNjyqq+mfNzfz qe97YGAK7P5qGByy+8PqgiwQgTUyvIGsPK1zJQWzyBd1GAPFilde7kdbBRgHGY0i9giT bkmSipVeTxyGKLZR+ZQSElIz72WBC2fBEgXAau3iVbswrv2nC0nreqB7aGc7YMxBj0vg 694w== 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=vZVepLjGQmA8Sd7Dsoz91hGyNnRRVtsxo9tL/VycGyM=; b=R1sZ1ZELfRR+2GS0voUKJSxA+cuWv4oT0bFpMqvKW4BubR/HR2E8iY+Hmwjugt1+E9 C7/VZo5PG5xlBlbuwIoMm6wefuDjPG3ARwvuEJaIMAPSjki1ot6Q8AlYAhMWaOcEXN9V rNIJ7ebwN5eGWsrA1Ye6xHx0OtVhYEwdxQUXKh5HA5FeeKvUNMCaSr/xjbB+ubuA+3d1 UEA2cEffoH4Gc/QNwzTURiZUhBaEEvIoYdiDHYm7iuqk/YJBsl5n0maA1WxS4HFtQlOs Xqof2cNqh0/znvU2fUuCN8m3dNNOptNvzNfhZOVu9iZGc6rpZrwd1lNp4E8ACUFtbNGd dVKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=uZ3fJDvn; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r30-20020a638f5e000000b005030eb175d1si846668pgn.107.2023.05.25.02.39.09; Thu, 25 May 2023 02:39:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=uZ3fJDvn; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240743AbjEYJfX (ORCPT + 99 others); Thu, 25 May 2023 05:35:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240660AbjEYJem (ORCPT ); Thu, 25 May 2023 05:34:42 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 529FEE42; Thu, 25 May 2023 02:34:37 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685007271; 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=vZVepLjGQmA8Sd7Dsoz91hGyNnRRVtsxo9tL/VycGyM=; b=uZ3fJDvn3TkdggxynrSMSfRfldyWS4BjQknTKnFLPsovz8j7ATjj9wKY0YrNVgjmstnPDp RpaZS25BsNwZGpaoJ/p7EJJ0uIbBlS2FUZb7JOxDaj01/dymaraJMQq3HMBNo8AdoDtjj9 zicPN9Y+n59Eio5tvFDuMNg3FqCmngFYk44jhQfhJmmgYQqabA/sWVdNy5FxqS89PuRfOd aIlGwXIVvB3HqG5QjnSzYqSFoy17PnFrpG0S42MoYhVVriluyO/v7qDu49txvu1bQtu0UR T/hMyr5UmoePZahxw43d/YnRICYxjiOuqkO5KdkecSSs27EigiIE7kgVE4e+xA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685007271; 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=vZVepLjGQmA8Sd7Dsoz91hGyNnRRVtsxo9tL/VycGyM=; b=sSWawuGzshyC+A1UZwduoT3u0VBy5TcXDOddQy8qoXvVAcuzGJyKZcT9rD6R+qnYz6FWGe gQLD6b6k+lHbNkAw== To: Greg Kroah-Hartman Cc: Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Jiri Slaby , Joel Stanley , Andrew Jeffery , Matthias Brugger , AngeloGioacchino Del Regno , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Tony Lindgren , Lukas Wunner , Matthias Schiffer , =?utf-8?q?Uwe_Kleine?= =?utf-8?q?-K=C3=B6nig?= , linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-mediatek@lists.infradead.org Subject: [PATCH tty v1 8/8] serial: 8250: synchronize and annotate UART_IER access Date: Thu, 25 May 2023 11:37:59 +0206 Message-Id: <20230525093159.223817-9-john.ogness@linutronix.de> In-Reply-To: <20230525093159.223817-1-john.ogness@linutronix.de> References: <20230525093159.223817-1-john.ogness@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766858488724191364?= X-GMAIL-MSGID: =?utf-8?q?1766858488724191364?= The UART_IER register is modified twice by each console write (serial8250_console_write()) under the port lock. Any driver code that accesses UART_IER must do so with the port locked in order to ensure consistent values, even when for read accesses. Add locking, lockdep notation, and/or comments everywhere UART_IER is accessed. The added locking is not fixing a real problem because it occurs where the console is not active. However, adding the locking to these non-critical paths greatly simplifies UART_IER access tracking by establishing a general policy that all UART_IER access is performed with the port locked. Signed-off-by: John Ogness --- drivers/tty/serial/8250/8250.h | 6 +++ drivers/tty/serial/8250/8250_aspeed_vuart.c | 3 ++ drivers/tty/serial/8250/8250_mtk.c | 9 ++++ drivers/tty/serial/8250/8250_omap.c | 14 ++++++ drivers/tty/serial/8250/8250_port.c | 53 +++++++++++++++++++++ 5 files changed, 85 insertions(+) diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index 5418708f4631..471c6bc5f78f 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h @@ -179,6 +179,9 @@ static inline void serial_dl_write(struct uart_8250_port *up, u32 value) static inline bool serial8250_set_THRI(struct uart_8250_port *up) { + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&up->port.lock); + if (up->ier & UART_IER_THRI) return false; up->ier |= UART_IER_THRI; @@ -188,6 +191,9 @@ static inline bool serial8250_set_THRI(struct uart_8250_port *up) static inline bool serial8250_clear_THRI(struct uart_8250_port *up) { + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&up->port.lock); + if (!(up->ier & UART_IER_THRI)) return false; up->ier &= ~UART_IER_THRI; diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c index 9d2a7856784f..4a9e71b2dbbc 100644 --- a/drivers/tty/serial/8250/8250_aspeed_vuart.c +++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c @@ -275,6 +275,9 @@ static void __aspeed_vuart_set_throttle(struct uart_8250_port *up, { unsigned char irqs = UART_IER_RLSI | UART_IER_RDI; + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&up->port.lock); + up->ier &= ~irqs; if (!throttle) up->ier |= irqs; diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c index fb1d5ec0940e..aa8e98164d68 100644 --- a/drivers/tty/serial/8250/8250_mtk.c +++ b/drivers/tty/serial/8250/8250_mtk.c @@ -222,11 +222,17 @@ static void mtk8250_shutdown(struct uart_port *port) static void mtk8250_disable_intrs(struct uart_8250_port *up, int mask) { + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&up->port.lock); + serial_out(up, UART_IER, serial_in(up, UART_IER) & (~mask)); } static void mtk8250_enable_intrs(struct uart_8250_port *up, int mask) { + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&up->port.lock); + serial_out(up, UART_IER, serial_in(up, UART_IER) | mask); } @@ -235,6 +241,9 @@ static void mtk8250_set_flow_ctrl(struct uart_8250_port *up, int mode) struct uart_port *port = &up->port; int lcr = serial_in(up, UART_LCR); + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&port->lock); + serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); serial_out(up, MTK_UART_EFR, UART_EFR_ECB); serial_out(up, UART_LCR, lcr); diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c index 3225c95fde1d..0498b9b0e4e9 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -533,6 +533,10 @@ static void omap_8250_pm(struct uart_port *port, unsigned int state, u8 efr; pm_runtime_get_sync(port->dev); + + /* Synchronize UART_IER access against the console. */ + spin_lock_irq(&port->lock); + serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); efr = serial_in(up, UART_EFR); serial_out(up, UART_EFR, efr | UART_EFR_ECB); @@ -543,6 +547,8 @@ static void omap_8250_pm(struct uart_port *port, unsigned int state, serial_out(up, UART_EFR, efr); serial_out(up, UART_LCR, 0); + spin_unlock_irq(&port->lock); + pm_runtime_mark_last_busy(port->dev); pm_runtime_put_autosuspend(port->dev); } @@ -760,8 +766,11 @@ static void omap_8250_shutdown(struct uart_port *port) if (priv->habit & UART_HAS_EFR2) serial_out(up, UART_OMAP_EFR2, 0x0); + /* Synchronize UART_IER access against the console. */ + spin_lock_irq(&port->lock); up->ier = 0; serial_out(up, UART_IER, 0); + spin_unlock_irq(&port->lock); disable_irq_nosync(up->port.irq); dev_pm_clear_wake_irq(port->dev); @@ -803,6 +812,7 @@ static void omap_8250_unthrottle(struct uart_port *port) pm_runtime_get_sync(port->dev); + /* Synchronize UART_IER access against the console. */ spin_lock_irqsave(&port->lock, flags); priv->throttled = false; if (up->dma) @@ -953,6 +963,7 @@ static void __dma_rx_complete(void *param) struct dma_tx_state state; unsigned long flags; + /* Synchronize UART_IER access against the console. */ spin_lock_irqsave(&p->port.lock, flags); /* @@ -1227,6 +1238,9 @@ static u16 omap_8250_handle_rx_dma(struct uart_8250_port *up, u8 iir, u16 status static void am654_8250_handle_rx_dma(struct uart_8250_port *up, u8 iir, u16 status) { + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&up->port.lock); + /* * Queue a new transfer if FIFO has data. */ diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index b3971302d8e5..4b7bbd8b3305 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -539,6 +539,9 @@ EXPORT_SYMBOL_GPL(serial8250_rpm_put); */ static int serial8250_em485_init(struct uart_8250_port *p) { + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&p->port.lock); + if (p->em485) goto deassert_rts; @@ -676,6 +679,8 @@ static void serial8250_set_sleep(struct uart_8250_port *p, int sleep) serial8250_rpm_get(p); if (p->capabilities & UART_CAP_SLEEP) { + /* Synchronize UART_IER access against the console. */ + spin_lock_irq(&p->port.lock); if (p->capabilities & UART_CAP_EFR) { lcr = serial_in(p, UART_LCR); efr = serial_in(p, UART_EFR); @@ -689,6 +694,7 @@ static void serial8250_set_sleep(struct uart_8250_port *p, int sleep) serial_out(p, UART_EFR, efr); serial_out(p, UART_LCR, lcr); } + spin_unlock_irq(&p->port.lock); } serial8250_rpm_put(p); @@ -696,6 +702,9 @@ static void serial8250_set_sleep(struct uart_8250_port *p, int sleep) static void serial8250_clear_IER(struct uart_8250_port *up) { + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&up->port.lock); + if (up->capabilities & UART_CAP_UUE) serial_out(up, UART_IER, UART_IER_UUE); else @@ -968,6 +977,9 @@ static void autoconfig_16550a(struct uart_8250_port *up) unsigned char status1, status2; unsigned int iersave; + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&up->port.lock); + up->port.type = PORT_16550A; up->capabilities |= UART_CAP_FIFO; @@ -1151,6 +1163,8 @@ static void autoconfig(struct uart_8250_port *up) /* * We really do need global IRQs disabled here - we're going to * be frobbing the chips IRQ enable register to see if it exists. + * + * Synchronize UART_IER access against the console. */ spin_lock_irqsave(&port->lock, flags); @@ -1323,7 +1337,10 @@ static void autoconfig_irq(struct uart_8250_port *up) /* forget possible initially masked and pending IRQ */ probe_irq_off(probe_irq_on()); save_mcr = serial8250_in_MCR(up); + /* Synchronize UART_IER access against the console. */ + spin_lock_irq(&port->lock); save_ier = serial_in(up, UART_IER); + spin_unlock_irq(&port->lock); serial8250_out_MCR(up, UART_MCR_OUT1 | UART_MCR_OUT2); irqs = probe_irq_on(); @@ -1335,7 +1352,10 @@ static void autoconfig_irq(struct uart_8250_port *up) serial8250_out_MCR(up, UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2); } + /* Synchronize UART_IER access against the console. */ + spin_lock_irq(&port->lock); serial_out(up, UART_IER, UART_IER_ALL_INTR); + spin_unlock_irq(&port->lock); serial_in(up, UART_LSR); serial_in(up, UART_RX); serial_in(up, UART_IIR); @@ -1345,7 +1365,10 @@ static void autoconfig_irq(struct uart_8250_port *up) irq = probe_irq_off(irqs); serial8250_out_MCR(up, save_mcr); + /* Synchronize UART_IER access against the console. */ + spin_lock_irq(&port->lock); serial_out(up, UART_IER, save_ier); + spin_unlock_irq(&port->lock); if (port->flags & UPF_FOURPORT) outb_p(save_ICP, ICP); @@ -1360,6 +1383,9 @@ static void serial8250_stop_rx(struct uart_port *port) { struct uart_8250_port *up = up_to_u8250p(port); + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&port->lock); + serial8250_rpm_get(up); up->ier &= ~(UART_IER_RLSI | UART_IER_RDI); @@ -1379,6 +1405,9 @@ void serial8250_em485_stop_tx(struct uart_8250_port *p) { unsigned char mcr = serial8250_in_MCR(p); + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&p->port.lock); + if (p->port.rs485.flags & SER_RS485_RTS_AFTER_SEND) mcr |= UART_MCR_RTS; else @@ -1428,6 +1457,9 @@ static void __stop_tx_rs485(struct uart_8250_port *p, u64 stop_delay) { struct uart_8250_em485 *em485 = p->em485; + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&p->port.lock); + stop_delay += (u64)p->port.rs485.delay_rts_after_send * NSEC_PER_MSEC; /* @@ -1607,6 +1639,9 @@ static void serial8250_start_tx(struct uart_port *port) struct uart_8250_port *up = up_to_u8250p(port); struct uart_8250_em485 *em485 = up->em485; + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&port->lock); + if (!port->x_char && uart_circ_empty(&port->state->xmit)) return; @@ -1634,6 +1669,9 @@ static void serial8250_disable_ms(struct uart_port *port) { struct uart_8250_port *up = up_to_u8250p(port); + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&port->lock); + /* no MSR capabilities */ if (up->bugs & UART_BUG_NOMSR) return; @@ -1648,6 +1686,9 @@ static void serial8250_enable_ms(struct uart_port *port) { struct uart_8250_port *up = up_to_u8250p(port); + /* Port locked to synchronize UART_IER access against the console. */ + lockdep_assert_held_once(&port->lock); + /* no MSR capabilities */ if (up->bugs & UART_BUG_NOMSR) return; @@ -2104,6 +2145,14 @@ static void serial8250_put_poll_char(struct uart_port *port, unsigned int ier; struct uart_8250_port *up = up_to_u8250p(port); + /* + * Normally the port is locked to synchronize UART_IER access + * against the console. However, this function is only used by + * KDB/KGDB, where it may not be possible to acquire the port + * lock because all other CPUs are quiesced. The quiescence + * should allow safe lockless usage here. + */ + serial8250_rpm_get(up); /* * First save the IER then disable the interrupts @@ -2439,6 +2488,8 @@ void serial8250_do_shutdown(struct uart_port *port) serial8250_rpm_get(up); /* * Disable interrupts from this port + * + * Synchronize UART_IER access against the console. */ spin_lock_irqsave(&port->lock, flags); up->ier = 0; @@ -2738,6 +2789,8 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, /* * Ok, we're now changing the port state. Do it with * interrupts disabled. + * + * Synchronize UART_IER access against the console. */ serial8250_rpm_get(up); spin_lock_irqsave(&port->lock, flags);