Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4261219rdb; Thu, 14 Sep 2023 17:46:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqnwMMNKtwkDWQxDkvnAiFFEMuGQ31AtDZX7JdCIiNC6P9BKemfhj787KyTW0ojMFfUd73 X-Received: by 2002:a05:6a20:100c:b0:157:eb44:fd2e with SMTP id gs12-20020a056a20100c00b00157eb44fd2emr333594pzc.19.1694738790128; Thu, 14 Sep 2023 17:46:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694738790; cv=none; d=google.com; s=arc-20160816; b=r1EsV7yQNdzus7Q3YdzJ9ZqwtYQ5a3CRZ5NhNZM7Hjb4epWbcOH8FD4L2vRpREeCHn s3txBvJRul49v5JPVeP0BtRfkmt0idt6ol7aEBuavKIIWfStQ8p65nQ/Xq5u7wEEVS8g buio/VH9QABYmmuVfDPE+3A88YLpvzH7b7K/wLlwPR5b8ImpqkN6kKWVz+VhOnCZ2JUi rxbGuIhlYQIDbBtYmfMH5kOsQTvSyTPFOgSlAGC0Mt2YQYBZiYuYIbAyDbPo7Xjq2es1 yVyXfH+/BmuL2JMVgbdahHMVBfaTzYX+lp8TDq/FM2n66y0yDMLVFy3QZu863BOGTUTZ SR4g== 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=scaU8Ke6aOSrJaDl+5gO/v/Oetd46gqnVkH3I+dMdgg=; fh=iD9IPHmIjHEyjotGeWacNQqSU9sb8zaltRMmpITIsIk=; b=Z1bSz8VVzSo1hGnprlNiYJ/qHutZiSdc/a5lk5GE3VIOP94c3gVJmJx3XWNKupQzCx xIQ49kl/kdcZcvrXwSyUnnao7Jrey8afKaRkkLlH1qIsE4wwYrmYX1aT/XlvmNNPacgS s0GS1UaPPGBavuwSdLx+0F4tckTNjdMI5tB8G6CdvWSQOi5AiRUoi5i3iqKCApyJeeNW +QEZ/Vzq/dpOQRfKpsyg8o9N+M97rqXTQ7/aAp4wdTKPXakZPsoUe1HbwBjaG305PJ9W UIV2ihF5j0HpgWr+9EWAl4LFoadX4pCIZpnurjVWkMCv+q7nczIA4a/9tkNbu1mIGGL/ i5/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Mj0+Pe00; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id ea21-20020a056a004c1500b0068fc261dddfsi2373165pfb.307.2023.09.14.17.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 17:46:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Mj0+Pe00; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 1A2A5836FFFD; Thu, 14 Sep 2023 11:45:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242076AbjINSmv (ORCPT + 99 others); Thu, 14 Sep 2023 14:42:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241893AbjINSkt (ORCPT ); Thu, 14 Sep 2023 14:40:49 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AE482D46; Thu, 14 Sep 2023 11:39:07 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716745; 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=scaU8Ke6aOSrJaDl+5gO/v/Oetd46gqnVkH3I+dMdgg=; b=Mj0+Pe00fFVsZ6+hpkjEb3RIQOukUDP/nj1KpIONzsm0lww8nBluFaZ+8hIg2znuQmiWH4 vNAWfweVOIIC3hs2ouo/HTGnWFvKQTHnVTL06YlCaX7vMbezkTePgE6J74dkWomiuMqOQQ ru3qVZ30o2933msd35CcKWgDiDbRkpKnZ6kwgeMewj8MJZ46Z7eU9Rt60frRbKszO1uaTA hpQQwZs7tW5WJhj9LsMLqxu+1k4qsB1GmAK5HGTKrdsk7r+VxD8/eIDo1aoHemxCxRLDYZ g0ZJ1ORRCqncjJTriPe2+NnN37tZDQIFBOsGczeAAbY8U4yjZCiTZl5ndWA/ww== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716745; 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=scaU8Ke6aOSrJaDl+5gO/v/Oetd46gqnVkH3I+dMdgg=; b=QKNzNzgHqgZN0A8MG25uklYWnJo/RRItn+QWlEUJLX2q9Iyh5vLVHi37d5Blz4HXcuFPVr fGe1OYlr4ZvZWSBQ== To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-serial@vger.kernel.org, Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Patrice Chotard , linux-arm-kernel@lists.infradead.org Subject: [PATCH tty v1 63/74] serial: st-asc: Use port lock wrappers Date: Thu, 14 Sep 2023 20:44:20 +0206 Message-Id: <20230914183831.587273-64-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 (groat.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:45:26 -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 groat.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/st-asc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c index 92b9f6894006..a821f5d76a26 100644 --- a/drivers/tty/serial/st-asc.c +++ b/drivers/tty/serial/st-asc.c @@ -319,7 +319,7 @@ static irqreturn_t asc_interrupt(int irq, void *ptr) struct uart_port *port = ptr; u32 status; - spin_lock(&port->lock); + uart_port_lock(port); status = asc_in(port, ASC_STA); @@ -334,7 +334,7 @@ static irqreturn_t asc_interrupt(int irq, void *ptr) asc_transmit_chars(port); } - spin_unlock(&port->lock); + uart_port_unlock(port); return IRQ_HANDLED; } @@ -452,10 +452,10 @@ static void asc_pm(struct uart_port *port, unsigned int state, * we can come to turning it off. Note this is not called with * the port spinlock held. */ - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); ctl = asc_in(port, ASC_CTL) & ~ASC_CTL_RUN; asc_out(port, ASC_CTL, ctl); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); clk_disable_unprepare(ascport->clk); break; } @@ -480,7 +480,7 @@ static void asc_set_termios(struct uart_port *port, struct ktermios *termios, baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); cflag = termios->c_cflag; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); /* read control register */ ctrl_val = asc_in(port, ASC_CTL); @@ -594,7 +594,7 @@ static void asc_set_termios(struct uart_port *port, struct ktermios *termios, /* write final value and enable port */ asc_out(port, ASC_CTL, (ctrl_val | ASC_CTL_RUN)); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } static const char *asc_type(struct uart_port *port) @@ -849,9 +849,9 @@ static void asc_console_write(struct console *co, const char *s, unsigned count) if (port->sysrq) locked = 0; /* asc_interrupt has already claimed the lock */ else if (oops_in_progress) - locked = spin_trylock_irqsave(&port->lock, flags); + locked = uart_port_trylock_irqsave(port, &flags); else - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); /* * Disable interrupts so we don't get the IRQ line bouncing @@ -869,7 +869,7 @@ static void asc_console_write(struct console *co, const char *s, unsigned count) asc_out(port, ASC_INTEN, intenable); if (locked) - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } static int asc_console_setup(struct console *co, char *options) -- 2.39.2