From patchwork Thu Sep 14 18:37:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 140618 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1249414vqi; Fri, 15 Sep 2023 11:43:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGModZSYWK1/ClPbtfLLDwSmBQM0+gWYPuLGd8o/r2735NfbeJUQrFBOKJzu6eXiNRaWYzu X-Received: by 2002:a17:903:2352:b0:1c3:aee0:7d27 with SMTP id c18-20020a170903235200b001c3aee07d27mr3005416plh.24.1694803417197; Fri, 15 Sep 2023 11:43:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694803417; cv=none; d=google.com; s=arc-20160816; b=0FEMk/bIOl/zmibGYNFZZgW22IXqAKQY9yL1+srX5LdJ19zhBuOkRVV3CL+AVJDGy1 CPuSdAjOrWSbGZjSviC1mvbUpVdN3Kj5/zub9Hzm7CRXu6u/ZoAw7pcVons+44vHlTVN /Gm95IbtMHNaZgdiYLdB1Pet4IhA58IhqGlSD8AUh0lzzPUv3L0+vjWQbumlgYcDKTac vfRxQRREZyQOq/DTke3kn7vzLTXNFai4mcdhtA6D2v9IAy0jyzttReEzv0CgjQtkn85p wLG+JkSy9jLjtWVles1Vv14VQd2FjTsTwBItKjOqeL/Ovgf+jNPHxU6PEBnS52kGwMKf x5CQ== 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=LC6ee95LLgICXwmE0USSEBuHjBCWJtZsDUgyx/Ctu9I=; fh=j5wT0mxN/lJnEMYlnozdD/vTzhiE0zz05sQ66hfCdZc=; b=f3CSDBxhKbj1sOBtp90+3P+psmiivtimFfPP8YYowf/eHXEfdYL9jfdgbDvBXASuPo 7rBYgnDB9ArNV2pahKf3kzHrk9JHTCKf3QAGSCeR/0mH0wk09m3MQBrHlQ02dvUMC+go 74KuCw/RRLdmpRX2KGMJ4NHTrKM/4hgjqE+SVMNHEAK1Rl93QCSb/W7bUIhjsT0UCByR IoyrhdcwGo8aRziVcTnZXt5tRrvY5fX6rqIoXuXPkfukBPYxDJXs4QTpFlJuJ1obacqH OO66Tt+EDAY9fRe790GVVg8i+524Ogka+b76JhV9NchJZSw/uoCC0VJ66Mm7hqt7jFwg pM3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=R1TuVbNo; dkim=neutral (no key) header.i=@linutronix.de header.b=CZYVJekg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l9-20020a170902f68900b001bf88e777f9si4099291plg.33.2023.09.15.11.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 11:43:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=R1TuVbNo; dkim=neutral (no key) header.i=@linutronix.de header.b=CZYVJekg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 6B1B08331E0E; Thu, 14 Sep 2023 11:39:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241787AbjINSjL (ORCPT + 33 others); Thu, 14 Sep 2023 14:39:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241609AbjINSix (ORCPT ); Thu, 14 Sep 2023 14:38:53 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 871682101; Thu, 14 Sep 2023 11:38:45 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716724; 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=LC6ee95LLgICXwmE0USSEBuHjBCWJtZsDUgyx/Ctu9I=; b=R1TuVbNostHa0wM4yepEE7v6WHYuLqdxHUqaYn+qB5pl6tCd4QoP0ouCPBj/gYuUjWU2Hl qZSxgx+XXc/VQiIbUuVilNn3nM35W92GRgdyC6GzHPzgXIzngraczIF+lQGD9zNMwJBoVE orO2MdWxWEsso3g+/W+4DPjj1PAxTEk4Ngx2Oi+rIWTZF+orsNP2nKu4Q3yVlYIW1gI/to QdnLyyvD3oIXml7AgZqrVHTRaq5qTQuWRRt2xEKRNBtXo5LM/raiC8Fp2QnzPPv8+4HCmj PiYmbhKFmSLs+5ksgnA4L6VU/drWEG5TNzjchepMiTwFo+4Ae8GZ2/3YVbPhzw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716724; 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=LC6ee95LLgICXwmE0USSEBuHjBCWJtZsDUgyx/Ctu9I=; b=CZYVJekgCab/O5x5km8To1UaDf+NZCMKRy3KHKXP+YTu0UQJ7PUVdCpMdSS2HphSeJTuVJ /2B0cSEgLlc3bHDA== To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-serial@vger.kernel.org, Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Kumaravel Thiagarajan , Tharun Kumar P Subject: [PATCH tty v1 13/74] serial: 8250_pci1xxxx: Use port lock wrappers Date: Thu, 14 Sep 2023 20:43:30 +0206 Message-Id: <20230914183831.587273-14-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 (snail.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:39:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777130187881297033 X-GMAIL-MSGID: 1777130187881297033 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_pci1xxxx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/8250/8250_pci1xxxx.c b/drivers/tty/serial/8250/8250_pci1xxxx.c index a3b25779d921..53e238c8cc89 100644 --- a/drivers/tty/serial/8250/8250_pci1xxxx.c +++ b/drivers/tty/serial/8250/8250_pci1xxxx.c @@ -225,10 +225,10 @@ static bool pci1xxxx_port_suspend(int line) if (port->suspended == 0 && port->dev) { wakeup_mask = readb(up->port.membase + UART_WAKE_MASK_REG); - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); port->mctrl &= ~TIOCM_OUT2; port->ops->set_mctrl(port, port->mctrl); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); ret = (wakeup_mask & UART_WAKE_SRCS) != UART_WAKE_SRCS; } @@ -251,10 +251,10 @@ static void pci1xxxx_port_resume(int line) writeb(UART_WAKE_SRCS, port->membase + UART_WAKE_REG); if (port->suspended == 0) { - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); port->mctrl |= TIOCM_OUT2; port->ops->set_mctrl(port, port->mctrl); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } mutex_unlock(&tport->mutex); }