From patchwork Thu Sep 14 18:37:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 139999 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp751793vqi; Thu, 14 Sep 2023 19:12:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFMQ4/jNXH6Nm1pl57fubQE4ob88PI+MHVsT2r7VopZZLI7BMDaS2jWh3AcrrLV1fwDCPP X-Received: by 2002:a05:6870:a117:b0:1bf:12ab:e16b with SMTP id m23-20020a056870a11700b001bf12abe16bmr515510oae.2.1694743967673; Thu, 14 Sep 2023 19:12:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694743967; cv=none; d=google.com; s=arc-20160816; b=Mh7QT5axR8vdOSclVQ0UpWyIixbBk/OSyudhhfWIhIZphygZQejoLVFlY/KZQ9Be8x wUFh6sqFsaYj1azJfBWoY/oevm3YaChPRjhmqyuq0da9H8uE7mxTT4I7WvJddB3WGRWP QCIH1/gwMe1PcpSCpNTqbDSLqtDIqPlk4Yi/YLjYrBnu6praFMUO4uUQHQ+vUXVGoHvd VvpTCmSmrpoMbfuONc8tczCW8f+0MeLACLEJoZufkljWiNl1UPXvWoVnQeUAYkhsw2bV T/QWOW4moAiKrGE1RxRYkFBDE/abFn1QHSEnvJz4xbM5sbU+QirQ6n/2kqUDiGpLQEeV ekPg== 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=PXwtr2mW476CJCdf6sAfvEGFu2EeqfcOEBZTv7wDsVo=; fh=PzcPxI7PZN8NUqsfz6j94KyRNSZSXRFV1MImXRvnVpM=; b=vTt79EuOnjDNyDLZQMvnJ0XB6gTUqJPx//xwcpgdE9XiPIi8LtWbokSbakoawRlJFf jEePKRBL0B1xWp2mi95t52b0lxIC1B8XxwzQNRO1Kvh7RDbRZHTJlYqP6zWQmkVxiEeQ pZ/uKQehxPO8EeRamomjD9xWcPNDU2/5rNZfetaGTp9W9d1iz8/X0tnAu1IYsXtTRwFw bgUN1hbxo4sHCRMFal2inhnlHDCev0Xr51lAgOZabIoxvUgQX3IqOksN+HgmEk+3JrAs y6n0QnrpxmBXV3EZRXOKEKydKD0xUVU2E0d00ideBFkz6ndEPdKmsh7bQBDDhdUS56co 6H/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=c1gwWfZ3; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=sjTEfi6d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id r22-20020a638f56000000b005648d3f2031si2377850pgn.362.2023.09.14.19.12.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 19:12:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=c1gwWfZ3; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=sjTEfi6d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 5AB7E8705EA7; Thu, 14 Sep 2023 11:39:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240512AbjINSjW (ORCPT + 33 others); Thu, 14 Sep 2023 14:39:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241416AbjINSis (ORCPT ); Thu, 14 Sep 2023 14:38:48 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99DC31FFB; Thu, 14 Sep 2023 11:38:43 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716722; 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=PXwtr2mW476CJCdf6sAfvEGFu2EeqfcOEBZTv7wDsVo=; b=c1gwWfZ3idwytcqe6fJhqyNiv3t6Pusd87FKIhNv0oWPhu+BmM/2E4anqWcY0na/ZUldT6 sNYbV/ZvM0mwNMtNCrB9B3dtS9jAB/5kD7pjTBcHsERisrEwuP05sjUSWF7jdDzztnH2YH 0ys8kB0nJxtqKp4R0XcMqieoKVpdlckgN+Qs/wk3NNJqdQYEJ2ZHvviXMwDJoiUOmmeqbt 29rEQUEoy1OZolPsESyuxTM99xwdU6EhKu1PmtdrDSbRtnPiHinMkVyA+QwsM/ByRbO0JQ iOSic1s5XDeQ4bW4bGiL3ht2jpP1EzluHoOQZ4X93cbrkcsx7HFi+lL1OJMgQw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716722; 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=PXwtr2mW476CJCdf6sAfvEGFu2EeqfcOEBZTv7wDsVo=; b=sjTEfi6dtWs2B6G3uIcUDZx1XVnxac0F5QU5fMLyrvnsap7tRuPup04Jh63unPNqP3+aoy wvUJL9BSJmK5UuAg== 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_J=C3=A4rvinen?= , Andy Shevchenko Subject: [PATCH tty v1 08/74] serial: 8250_dw: Use port lock wrappers Date: Thu, 14 Sep 2023 20:43:25 +0206 Message-Id: <20230914183831.587273-9-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 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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:39:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777067850471624519 X-GMAIL-MSGID: 1777067850471624519 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 Reviewed-by: Ilpo Järvinen --- drivers/tty/serial/8250/8250_dw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index f4cafca1a7da..95d45dce0880 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -263,20 +263,20 @@ static int dw8250_handle_irq(struct uart_port *p) * so we limit the workaround only to non-DMA mode. */ if (!up->dma && rx_timeout) { - spin_lock_irqsave(&p->lock, flags); + uart_port_lock_irqsave(p, &flags); status = serial_lsr_in(up); if (!(status & (UART_LSR_DR | UART_LSR_BI))) (void) p->serial_in(p, UART_RX); - spin_unlock_irqrestore(&p->lock, flags); + uart_port_unlock_irqrestore(p, flags); } /* Manually stop the Rx DMA transfer when acting as flow controller */ if (quirks & DW_UART_QUIRK_IS_DMA_FC && up->dma && up->dma->rx_running && rx_timeout) { - spin_lock_irqsave(&p->lock, flags); + uart_port_lock_irqsave(p, &flags); status = serial_lsr_in(up); - spin_unlock_irqrestore(&p->lock, flags); + uart_port_unlock_irqrestore(p, flags); if (status & (UART_LSR_DR | UART_LSR_BI)) { dw8250_writel_ext(p, RZN1_UART_RDMACR, 0);