Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4279459rdb; Thu, 14 Sep 2023 18:36:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmWynsaLhOppmR3Zl5tbaJNQDSc0HGrUBNgXdrnykZhp9XTfSqhIII41fCEDeOGTVP1KzV X-Received: by 2002:a17:902:f68f:b0:1c1:fc5c:b34a with SMTP id l15-20020a170902f68f00b001c1fc5cb34amr306015plg.3.1694741811207; Thu, 14 Sep 2023 18:36:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694741811; cv=none; d=google.com; s=arc-20160816; b=XH/OOLiileiZIUHwdcm2DFz7wd/7vJ9QeJL4sSgmHKV6rQ9y9M+NEgJ4RF8HORCiFC osMTMGJMsWhOV+VeeGlroSJ9pB5SQEavzu894vu5Oarz6Pr6ZiQJHicPZmlvG8hupER7 Mu40bkQwyIAQyFKz3gQr33dgKUlhKdZHmsHRJP+tKkYn7ZPDWvWW8mDG+k3yJSQ7eyYT 0gJNx8Nwj9mJHHtojhdgaxzdjSR+eIkOZKon/ceyE0SqPcPUmpoX+0TmEuvsQZE4bVJz Ncq+evTwplIW5OOlCsleV8rFxM544HV3lmqVuC21dONUP+0BEu0V9KzOCsUUUGKrHmJs d4+Q== 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=SN1m+sQgeewvT16dEWJcKSrjCp4ddLkdrzOmS932/1c=; fh=CIDI4LdBKZbA2CysVFGtmnVrdw/j4IIGdeK9NM0czPM=; b=vhMOvZeoy2R3fIBY66bwsjDsORBJAu9jdGUEbdJ0oo3GYyL+Wh3q1SMsynr0/DMeAc VC5/ntNb/RQBCslcGAA7gi4gUC5P4pN2PpNMC1IcN//VsckwUkmfglWg7siAZG0x/aRE pG1O5F95zf+7HgpJpxpEMbUCqwsu9Pjcs/z3eAW9bNY6VWmt6LfXjvQCCjvxp64yBvuE ZgOgXT33deoZGSj2CDv7mR1QdkEuKmS2JzcO4+qGU1P8HFxITgtXsTLwzDSDtccCiSHV nWaj3vGtTXr++8q2DnSmUstWkaixiMmuzsxcqvB2uipS9wGlOmzI7QeWYnT3QhztAZZn /iuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=T2+nJtqF; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=GQ4AT7dp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id v10-20020a170902d08a00b001b9eb349550si2402978plv.391.2023.09.14.18.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 18:36:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=T2+nJtqF; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=GQ4AT7dp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 9EC068331E29; Thu, 14 Sep 2023 11:39:36 -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 S241843AbjINSjf (ORCPT + 99 others); Thu, 14 Sep 2023 14:39:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241653AbjINSix (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 83451210A; Thu, 14 Sep 2023 11:38:47 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716726; 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=SN1m+sQgeewvT16dEWJcKSrjCp4ddLkdrzOmS932/1c=; b=T2+nJtqFHK05/tM4MSOXTG0QEMWzm7dci51Lnw0aYytoCX/b+7AuMkFiu1PbFgG9imA4uk B2kOwsnzIg07yBXTnAtEye+O1CWkfLiDiP4wioM6jGNZ3sXID24JoP3waGuQwzgiFaVSqo 5QVF6oI1wtFfzxrvHKA8vi9aU+u2T1eupWzb0RTs6XHvIJnrCz6J1TeJratDX4HI7KQKHU jr9bmor/75Bb4cnokJXTPSjpwtG5gBuZWs7Ue4KUkQutBWO/7cFMJo25ZWpH5ugDtjYINj fbduXBudQtprxvZRd/MIhyr4IZIww66j0DnbzrZn4I93U+828kcVZTn09qE5YQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716726; 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=SN1m+sQgeewvT16dEWJcKSrjCp4ddLkdrzOmS932/1c=; b=GQ4AT7dpwj6KdWTSvLHa6Iv58kWfyk7q6vILB5b0vKY5MPYKmqRhTOU1r+F/DfpZzSfmwk 0VrqhxSNFO63RJCA== To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-serial@vger.kernel.org, Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Tobias Klauser , Rob Herring , "Maciej W. Rozycki" Subject: [PATCH tty v1 18/74] serial: apb: Use port lock wrappers Date: Thu, 14 Sep 2023 20:43:35 +0206 Message-Id: <20230914183831.587273-19-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:36 -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/apbuart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/apbuart.c b/drivers/tty/serial/apbuart.c index d7658f380838..716cb014c028 100644 --- a/drivers/tty/serial/apbuart.c +++ b/drivers/tty/serial/apbuart.c @@ -133,7 +133,7 @@ static irqreturn_t apbuart_int(int irq, void *dev_id) struct uart_port *port = dev_id; unsigned int status; - spin_lock(&port->lock); + uart_port_lock(port); status = UART_GET_STATUS(port); if (status & UART_STATUS_DR) @@ -141,7 +141,7 @@ static irqreturn_t apbuart_int(int irq, void *dev_id) if (status & UART_STATUS_THE) apbuart_tx_chars(port); - spin_unlock(&port->lock); + uart_port_unlock(port); return IRQ_HANDLED; } @@ -228,7 +228,7 @@ static void apbuart_set_termios(struct uart_port *port, if (termios->c_cflag & CRTSCTS) cr |= UART_CTRL_FL; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); /* Update the per-port timeout. */ uart_update_timeout(port, termios->c_cflag, baud); @@ -251,7 +251,7 @@ static void apbuart_set_termios(struct uart_port *port, UART_PUT_SCAL(port, quot); UART_PUT_CTRL(port, cr); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } static const char *apbuart_type(struct uart_port *port) -- 2.39.2