Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4716577rdb; Fri, 15 Sep 2023 10:04:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3SS3NRwgQidtAaHBiIt0phwX7UcfRrt31EArOfDMPQ+y2FwCPU2CdYvBSJMC8/Qx1wErc X-Received: by 2002:a17:902:e805:b0:1c0:6e92:8cc5 with SMTP id u5-20020a170902e80500b001c06e928cc5mr2622129plg.17.1694797453377; Fri, 15 Sep 2023 10:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694797453; cv=none; d=google.com; s=arc-20160816; b=DP0hb6v53Dbx+TriLTCZABkreQ+N3ZM2xvgpRqJaF04gY1nWuL2vVxD9BxQID+i8SL Se/mjHIXXkC4joPG6aMg1SBHKUg87xMpL/8tJVwUNrwVnjX31a7UvZJ1ZGDrVxy5ZqLG RDAS1mr1HmHMeAs5t13G2K/wjTtrpwlazo8Z+LPTsA/ltCL6YvTbydO82fUzRtgUoHfM zOVUH9rOH+9St5BdquW1tqX+cx2GlNRJDYxqG7C5/VDk/sDQNlt0L8OO/skSb2Hzej3j cGWMOkFLmw7jbq3vQ7Vz8HeKeJP408uC9RahdbQSj+XlaoC3jFNi06W+cwApbaTXGxJz pMYg== 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=9ljKUwev2UkcA8WCxS5wHB4jucft9QaueReQAnJLBgA=; fh=bDwPbIyK30WarEtoCxrEaltzXucXRIOv/MpgZfu7JAU=; b=EeiGg851BPqkXboZomk6PnFMJ7Nr1Kzpn+BtlVzWB5ROrK5lP9KQ8hNMAjn+a9F/LT ank/DyOvHyR41tv5Tfcv6DFoQKbpOpOpmVOA5AXCuHZIH8A4+HS3CQAqjPHgFron+VeA LHBdLdbeHMFQjF9qLlIg8jbB6RoQPSK1NSUIPcM7oaHJSMSywibMQ9ojfAH+5mMM4P22 hmXzH3UKgNKbd9cwL1BfbPjtK40fxtnGVUcpBX3M9pbsgB4lK7qEbHYl1W6DoZGWEnz9 BAFlH4wHVFrZ2LwpKKEHaRO2dsexj1K5cZQVgAF/7HOZWf3S5zva/P+KzJIa6NHX/ha0 XTJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4LBDpTPL; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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. [23.128.96.32]) by mx.google.com with ESMTPS id az1-20020a056a02004100b00565e0624182si3503496pgb.404.2023.09.15.10.04.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 10:04:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4LBDpTPL; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 4846182B899F; Thu, 14 Sep 2023 11:40:37 -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 S242029AbjINSkR (ORCPT + 99 others); Thu, 14 Sep 2023 14:40:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241724AbjINSi7 (ORCPT ); Thu, 14 Sep 2023 14:38:59 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E8532682; Thu, 14 Sep 2023 11:38:54 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716732; 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=9ljKUwev2UkcA8WCxS5wHB4jucft9QaueReQAnJLBgA=; b=4LBDpTPLhp3Mhhl4pVyJop8/w8YO125vIGMHFDGAc829iCRLFSl6X0mnCu86Xp0DKlykZQ MXfUoGbOklo8kZ7vno2kF6WSkEIFFIvGBTcq82frPQ1vcXYDd6OP7vg6a7cB6OoKGCAkfw fKDP6Ajv8OLwdQ319atwJb34QtjDpof9v9S7t56NLpZyAZyZJnQuNrxE05l8/g1GJoesLm lwGEKRQpPcSrqp5lU/Qczo2PqcPpFrhhih2JjfhMpnvo2acScgXq2FMPoFFKDsSCyfuCZw ocpglMKMTGaf/tHVHULGAUC4UImI8D22JCJD7t3sASdeP7gHPu23CWH7OKLk0g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716732; 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=9ljKUwev2UkcA8WCxS5wHB4jucft9QaueReQAnJLBgA=; b=DU48W/75T7f5tMYhQEpupILmuQfJztsBNWC4FVQumidZDa1Kg7GZ2XZ8GARLh976Uuhd0Q AFsq08hjfv2Li5Cg== To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-serial@vger.kernel.org, Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, "Maciej W. Rozycki" , Richard GENOUD , Thierry Reding Subject: [PATCH tty v1 35/74] serial: mcf: Use port lock wrappers Date: Thu, 14 Sep 2023 20:43:52 +0206 Message-Id: <20230914183831.587273-36-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:40:37 -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/mcf.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c index 1666ce012e5e..91b15243f6c6 100644 --- a/drivers/tty/serial/mcf.c +++ b/drivers/tty/serial/mcf.c @@ -135,12 +135,12 @@ static void mcf_break_ctl(struct uart_port *port, int break_state) { unsigned long flags; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); if (break_state == -1) writeb(MCFUART_UCR_CMDBREAKSTART, port->membase + MCFUART_UCR); else writeb(MCFUART_UCR_CMDBREAKSTOP, port->membase + MCFUART_UCR); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } /****************************************************************************/ @@ -150,7 +150,7 @@ static int mcf_startup(struct uart_port *port) struct mcf_uart *pp = container_of(port, struct mcf_uart, port); unsigned long flags; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); /* Reset UART, get it into known state... */ writeb(MCFUART_UCR_CMDRESETRX, port->membase + MCFUART_UCR); @@ -164,7 +164,7 @@ static int mcf_startup(struct uart_port *port) pp->imr = MCFUART_UIR_RXREADY; writeb(pp->imr, port->membase + MCFUART_UIMR); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); return 0; } @@ -176,7 +176,7 @@ static void mcf_shutdown(struct uart_port *port) struct mcf_uart *pp = container_of(port, struct mcf_uart, port); unsigned long flags; - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); /* Disable all interrupts now */ pp->imr = 0; @@ -186,7 +186,7 @@ static void mcf_shutdown(struct uart_port *port) writeb(MCFUART_UCR_CMDRESETRX, port->membase + MCFUART_UCR); writeb(MCFUART_UCR_CMDRESETTX, port->membase + MCFUART_UCR); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } /****************************************************************************/ @@ -252,7 +252,7 @@ static void mcf_set_termios(struct uart_port *port, struct ktermios *termios, mr2 |= MCFUART_MR2_TXCTS; } - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); if (port->rs485.flags & SER_RS485_ENABLED) { dev_dbg(port->dev, "Setting UART to RS485\n"); mr2 |= MCFUART_MR2_TXRTS; @@ -273,7 +273,7 @@ static void mcf_set_termios(struct uart_port *port, struct ktermios *termios, port->membase + MCFUART_UCSR); writeb(MCFUART_UCR_RXENABLE | MCFUART_UCR_TXENABLE, port->membase + MCFUART_UCR); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } /****************************************************************************/ @@ -350,7 +350,7 @@ static irqreturn_t mcf_interrupt(int irq, void *data) isr = readb(port->membase + MCFUART_UISR) & pp->imr; - spin_lock(&port->lock); + uart_port_lock(port); if (isr & MCFUART_UIR_RXREADY) { mcf_rx_chars(pp); ret = IRQ_HANDLED; @@ -359,7 +359,7 @@ static irqreturn_t mcf_interrupt(int irq, void *data) mcf_tx_chars(pp); ret = IRQ_HANDLED; } - spin_unlock(&port->lock); + uart_port_unlock(port); return ret; } -- 2.39.2