Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4105100rdb; Thu, 14 Sep 2023 11:53:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGxWiHqGI+1tB9ojlYhKP2bVVdK/vK4Zu80DRyCqAnkJISap2ik5xWPXp9KO+VJxfXhBr5o X-Received: by 2002:a17:90b:3ecd:b0:26d:2162:f596 with SMTP id rm13-20020a17090b3ecd00b0026d2162f596mr5912329pjb.6.1694717625706; Thu, 14 Sep 2023 11:53:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694717625; cv=none; d=google.com; s=arc-20160816; b=qYOVwCTr2HwLNZZHkrYbYq5WKSceVfFQ89q/i49TLl5koF2i4VlLpN6U4d6XfkeA90 lCyLbvPEWzfZRsqxri4iOcTk1b3QAlYZi4fBAfYZavCf7C7i1VvXYW5X9tpunpGE3b+u ZArcQfDiy0zS3hAjDwb6gsB6IA0fU2tJ/UWXm5X8X2tfffKWzLPQeHY5tixZunSwB0GS UmhiyWenIrhFbI1JiYxH9gMahmVTcf4Q5QFnn8x8dw/oAk5BUTO5ZlYNGHvHd1hMGM6R Puaj9+hMPq/EeiSg6rZK6qbBn6x7oXTt2TveIyCVu4bmMLVbHJacTtvQgtS4oC5Yf1kt +lTw== 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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id gn2-20020a17090ac78200b0024e47fae466si1971520pjb.180.2023.09.14.11.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 11:53:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; 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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 926838705E9C; Thu, 14 Sep 2023 11:39:21 -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 S241899AbjINSjU (ORCPT + 99 others); Thu, 14 Sep 2023 14:39:20 -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=20J=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 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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:39:21 -0700 (PDT) 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/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); -- 2.39.2