Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4235199rdb; Thu, 14 Sep 2023 16:39:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGvDSEPE4RTITNK3nQNDa2PT6Pd7v1zrgAMlIDiZbYl5Rp4AXnbWFk52cNtkTzYBX8+qJdh X-Received: by 2002:a17:902:dac1:b0:1c3:6667:5ff1 with SMTP id q1-20020a170902dac100b001c366675ff1mr111507plx.27.1694734791994; Thu, 14 Sep 2023 16:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694734791; cv=none; d=google.com; s=arc-20160816; b=QgDOE1d+QvhDUKFit0WxjrtQSatVq7J9X0RtbwwHgcyr+3GnxmM3ypDF1OzgYD+lQN deRHUfNyb6JOfPGABrA0OQD3UblqP5Bd2ua/5jwoUR4xHrDmodWAgbR1fDBBxEIfrDv4 41Y9TTLesMBgy3Ca+c/RwTgJ5pCn9WF13N4CAS2Pyb4QSALb5F1UWYfuFiWm3F+qPXuY y/tKow49shj5XRj8DmvaVxTUmLFmLp+IwZDJ0qGi69qq/HMEazPwIvfQQi+Gz3PU82EY jy/zQfeudNF+sGPwS4ljiEv5HtJ3RVRVVUs0dOpvvvXxKzeh6tfewXMeknaFom0LkD+1 NAiQ== 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=17zj637DQkryRYGb4/9wkWuly22RRdW4LfXIGp3ap80=; fh=0LOfe5/7CFEUU2EMsh3NdRGu1a/ZmXIWucVOCdu1J6k=; b=juxDX3p807nqrVtr3GzPCWX6bSUJPrjJPR/Ra0UJtv7B+uyJOdyRW4vhtyjtB46SVX q07ORDNKIvH4kFWXOQFvXRNrj8L3+tcnXAMsZ9B5PRYIl9/u+2Z0z1br63XIo8/3gbKL kzlJjGY/g8BCfXO+1LTl/eIVu+oN1B+wjWfotArIaIMkP2j8bHhEoAsNYjR4IrsLosBM f7q55oZiAHWn4HUlnidvugy7amXXxQ+/PIqdTGN3HMyaPca7KDe73lvW0pjw7Kr4ac6Y PB1xLSjOaOqgRNBL8GjzevN5Wxh0TSRUcb8HyGUq66dB5e8wDAsANdr44+a7ihXfLZYr QIOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gJJt8ECp; 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:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ij4-20020a170902ab4400b001b3d6d125f9si2254769plb.524.2023.09.14.16.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:39:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gJJt8ECp; 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:2 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 agentk.vger.email (Postfix) with ESMTP id D7ED881ADB43; Thu, 14 Sep 2023 11:42:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241794AbjINSlb (ORCPT + 99 others); Thu, 14 Sep 2023 14:41:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241947AbjINSjf (ORCPT ); Thu, 14 Sep 2023 14:39:35 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D38CC26B3; Thu, 14 Sep 2023 11:39:00 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716739; 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=17zj637DQkryRYGb4/9wkWuly22RRdW4LfXIGp3ap80=; b=gJJt8ECptIei3pjqa8XEVI+Fwjnumc3jdwgKHE1l8lrc9aoruj1uhfU5thGoUQktKtVykB i9R0cnq6YsLdnagbYQxc7STHZFFZgEdYBFjDL/zlU1nFx1KTdKV1QqmYZND5Suu3uV8NBj e5GZbEMgaCAS2mUB2re+7iJgGrmGCxjoDuVMlC5AiBvUn2LnOt/r+bI1n7lVDOxE2NPcll bGvchLP71BEje107RFPk4AJD8Nbi/r5tYyiUXkKmPxwGPVyD5j++W5xMPY1FyGWqKhncW2 wPHWMbjrp4EJyL6zrnGddSIClo6BeuWKR12+6RqpXNt2sS6CIYakWxIy9AFx1A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716739; 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=17zj637DQkryRYGb4/9wkWuly22RRdW4LfXIGp3ap80=; b=trnfmLCq598rEijUt+3jLrOeWMN5bTzCu2nDNdwBc7BKdrhgvOzyjV0oc1f/S8ypF8LsKA gYEZTR+YnQA9qxDg== To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-serial@vger.kernel.org, Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Andy Gross , Bjorn Andersson , Konrad Dybcio , linux-arm-msm@vger.kernel.org Subject: [PATCH tty v1 49/74] serial: qcom-geni: Use port lock wrappers Date: Thu, 14 Sep 2023 20:44:06 +0206 Message-Id: <20230914183831.587273-50-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 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:42:36 -0700 (PDT) X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INVALID_DATE_TZ_ABSURD, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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/qcom_geni_serial.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index b8aa4c1293ba..7e78f97e8f43 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -482,9 +482,9 @@ static void qcom_geni_serial_console_write(struct console *co, const char *s, uport = &port->uport; if (oops_in_progress) - locked = spin_trylock_irqsave(&uport->lock, flags); + locked = uart_port_trylock_irqsave(uport, &flags); else - spin_lock_irqsave(&uport->lock, flags); + uart_port_lock_irqsave(uport, &flags); geni_status = readl(uport->membase + SE_GENI_STATUS); @@ -520,7 +520,7 @@ static void qcom_geni_serial_console_write(struct console *co, const char *s, qcom_geni_serial_setup_tx(uport, port->tx_remaining); if (locked) - spin_unlock_irqrestore(&uport->lock, flags); + uart_port_unlock_irqrestore(uport, flags); } static void handle_rx_console(struct uart_port *uport, u32 bytes, bool drop) @@ -970,7 +970,7 @@ static irqreturn_t qcom_geni_serial_isr(int isr, void *dev) if (uport->suspended) return IRQ_NONE; - spin_lock(&uport->lock); + uart_port_lock(uport); m_irq_status = readl(uport->membase + SE_GENI_M_IRQ_STATUS); s_irq_status = readl(uport->membase + SE_GENI_S_IRQ_STATUS); -- 2.39.2