Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5057705rdb; Sat, 16 Sep 2023 00:44:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPelUFUhlZbb6ks8lWREWGUGAzCK59fXgvqEkzveY1dJXDaNrIjGI4Eyr1lnY+uzuNz1ux X-Received: by 2002:a17:902:f68f:b0:1c0:bf60:ba4f with SMTP id l15-20020a170902f68f00b001c0bf60ba4fmr4215414plg.4.1694850280190; Sat, 16 Sep 2023 00:44:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694850280; cv=none; d=google.com; s=arc-20160816; b=V/3TF59KNF6akUR9IwQWp9JLslZ+vWRZK2ntvAyJM49m5+RfloF3rVzsqhZVDG/+zM hqKGX75zpqICqhOlfTYiibYsuzOHSnzEWINR4us8718047A/p0pw9dS8IebOikOlfBIu y0AY/lix3XaJsKNmRKTDQbJ02YXH344DNXhLPUSXVrCRY+2bDiBqIApRx5kvie9vtX6z hWJIw1W4H5c4jg7rH+ns4hL5igDjGkgmFFAJ504lpu2+l+NaLRcxB2nFs/1jA0By449R i99uGcomJKG6jbUEAEv96VbzrtSxYNWOjFxDqHyZaasLjKuI8k0AYBBLMkRCZvkNpdiL js3w== 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.s=2020e 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 Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id f10-20020a170902ce8a00b001bda93595d9si4861730plg.604.2023.09.16.00.44.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 00:44:40 -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.s=2020e 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 D40C38275E6E; Thu, 14 Sep 2023 11:39:12 -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 S241786AbjINSjK (ORCPT + 99 others); Thu, 14 Sep 2023 14:39:10 -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 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 (snail.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:39:13 -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_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); } -- 2.39.2