From patchwork Thu Sep 14 18:38:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 140174 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp859513vqi; Fri, 15 Sep 2023 00:09:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHy5YCDXJL4beiseq7m+B+EEObPIXY3r5bYuU9C63b80T3JY/3K8+pbIhtNKI1LVOTmE5uA X-Received: by 2002:a17:90a:cf17:b0:274:9a85:2596 with SMTP id h23-20020a17090acf1700b002749a852596mr620270pju.32.1694761789849; Fri, 15 Sep 2023 00:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694761789; cv=none; d=google.com; s=arc-20160816; b=njdVT/eUDilYCqM+jqv6dCzRfmJyu2zLFcpg5WEswZJ4ZdGxM03iweflJSNtJSYmwx Fde06TlLYDf1OnwR9lmf8FO9I42yaztCrIgKTkpCFyYj5hVHj/jwj+gq7ufCV7Gojrux LbzjsAYEiamL/PPGbdTGGyUi6ofrDdQTejVGmoXQ0yMjTiOjGxqOIWFIK8xwplu2xulg SkHZX/wAiNJ6Q70RBnotyAQF3VJr6AISh51PpZdgkKfRwJVpnbk7M3W7OklEtzAzS98c wLzbDyewlMAStG0eX8bhmagJRLEIDkAGuLotXvsGgC1uyOJc2pFXJYCpQ1mCFs28ImmX uDKA== 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=0VJ6CgzcUt97Sq6jT/T/98yELCXXHkc/OLg8MuGFujM=; fh=qmZFnekuDs4T9icLmieAH3NNHXuS0/kWBnXi7iQsZPY=; b=VNVT7gewGsOq9M/CKju8xQngiDah96E3XX1YtdMLFOKiCm3KY98Hxc7r0lEcD9+gHP MZzKDZAbIeARbh6krX2AMfM+etAoWvLS/d/W3/WHOXLDjLx/un4t+lm+UVUEMAAkTUk+ B38aIYDdnuqH2sz9Uxgtl/BGSZZT5FoPn6bPYtBJZAdCIu2RZFjnjwKShnN11dlVbaFM gu9KQoc8z/BDfSr4K/nGvYuyv6wyG2/RFQO5/xaZnYcO2us68tweGbKw3LHY9FMwnkQU IyKARe4GHPQ728o1WlN8WgEJ5fmA/B0sjk6HYIip0SkDtIGkob1y1KS7PI9vK8QbQk1Q 9bKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=2Q8ZWVVt; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=vwvzaoth; 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id lb4-20020a17090b4a4400b0026b0b359a82si3234917pjb.4.2023.09.15.00.09.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 00:09:49 -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=2Q8ZWVVt; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=vwvzaoth; 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 3B6978338171; Thu, 14 Sep 2023 11:42:15 -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 S241988AbjINSmH (ORCPT + 33 others); Thu, 14 Sep 2023 14:42:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242004AbjINSj6 (ORCPT ); Thu, 14 Sep 2023 14:39:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A88B2139; Thu, 14 Sep 2023 11:39:05 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716743; 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=0VJ6CgzcUt97Sq6jT/T/98yELCXXHkc/OLg8MuGFujM=; b=2Q8ZWVVt4nOO784XYJxgw1TUsfcdKAz0Y5+p60KtUyCRIsGYdCIskPFE+osS7+MkxwviQt UML2Y73woxFqdZHm6y94vd3WGC56kpgzzzbF2i5Ubc0Aro/OmrgD0CxWgcpFi347G+NQZH h90Lof0AlZsIu85LlPQevIPzRFfD7CrqttJtuQU3DYChU+D751il2UBumt99HaTKqunct/ 26LmtSeaqPDLr1pPNjDhaxBC8MMUkiG9VtRP+NG14Ke6NMcQ0DamBJBgpShKTO0+/7MQDj l510AATKDexz0xJw6MogQYOHDTzUhEwMvTmC02EXbku1B63xHHV0/JriASW0lA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716743; 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=0VJ6CgzcUt97Sq6jT/T/98yELCXXHkc/OLg8MuGFujM=; b=vwvzaothGm7O+kiuENFNt17TWnYKIc4YDYnd1sfg4ZHwAk6rFlSpEEbCz+oonZ6Z7p4V0g 2/A7G8m1pzZF8rBQ== To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-serial@vger.kernel.org, Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH tty v1 58/74] serial: mctrl_gpio: Use port lock wrappers Date: Thu, 14 Sep 2023 20:44:15 +0206 Message-Id: <20230914183831.587273-59-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:42:15 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777086538585133511 X-GMAIL-MSGID: 1777086538585133511 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/serial_mctrl_gpio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/serial_mctrl_gpio.c b/drivers/tty/serial/serial_mctrl_gpio.c index 7d5aaa8d422b..e51ca593ab86 100644 --- a/drivers/tty/serial/serial_mctrl_gpio.c +++ b/drivers/tty/serial/serial_mctrl_gpio.c @@ -184,7 +184,7 @@ static irqreturn_t mctrl_gpio_irq_handle(int irq, void *context) mctrl_gpio_get(gpios, &mctrl); - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); mctrl_diff = mctrl ^ gpios->mctrl_prev; gpios->mctrl_prev = mctrl; @@ -205,7 +205,7 @@ static irqreturn_t mctrl_gpio_irq_handle(int irq, void *context) wake_up_interruptible(&port->state->port.delta_msr_wait); } - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); return IRQ_HANDLED; }