Message ID | 20230525093159.223817-8-john.ogness@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> 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 <rfc822;ahmedalshaiji.dev@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <john.ogness@linutronix.de> 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 <gregkh@linuxfoundation.org> Cc: Petr Mladek <pmladek@suse.com>, Thomas Gleixner <tglx@linutronix.de>, linux-kernel@vger.kernel.org, Jiri Slaby <jirislaby@kernel.org>, =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>, Tony Lindgren <tony@atomide.com>, Lukas Wunner <lukas@wunner.de>, Matthias Schiffer <matthias.schiffer@ew.tq-group.com>, 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 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> 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?= |
Series |
synchronize UART_IER access against console write
|
|
Commit Message
John Ogness
May 25, 2023, 9:31 a.m. UTC
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 <john.ogness@linutronix.de>
---
drivers/tty/serial/8250/8250_omap.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Comments
* John Ogness <john.ogness@linutronix.de> [230525 09:34]: > 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 <john.ogness@linutronix.de> Reviewed-by: Tony Lindgren <tony@atomide.com> > --- > 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); > -- > 2.30.2 >
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);