From patchwork Thu Sep 14 18:38:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 139832 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp618177vqi; Thu, 14 Sep 2023 13:51:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFn2keHcDLjjI5qOtE3rpXmv27UupWa9FMPgu7L/p8tNL8/mqdPuUhiz3siZEehpmtsBFdX X-Received: by 2002:a05:6a00:2346:b0:690:3a0f:4165 with SMTP id j6-20020a056a00234600b006903a0f4165mr2549711pfj.32.1694724682968; Thu, 14 Sep 2023 13:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694724682; cv=none; d=google.com; s=arc-20160816; b=EvhzsqFNw229hT0RGXG03K8drAbzfiZLlSPL2U5y9z6sZLEF5TMU5vjYq2annK+K4K 3YrGZBkrGunbxBcCnmGxjjnSJxC+luaLOmIgVuAIdIe3DUZ/GgHgieenM1bpA1jhTEn/ tYNE+jMCO/9gvpcauaf4Kyo7zp1RC462uf6HEcQ3A2sa0T0lOsYzHyzF7B8/5qHYuftu TnYGY5vn6ZoTJ0MBnM6SEWOTtuYDNoIL7+1mpw2bZzYbkRpQNi06J6DcPn8WI4jtLU+f t8CrPON4gx1fYhAeM5bVI0qtLlXadjzeUGFfW5W6xW8CB11kOxTeQF3BpkgJpUfWuHK8 UN7A== 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=pan/Otko80+kx5GwrdBzH5rqxtGnDYcelX/t2yRhZyw=; fh=aN2DPxk99Ukxd3gs+JIEi5p6SsRUChAtxhm8Hk0TA5E=; b=gkZ64HOLuXhshHlhzeH2GoqAaLdXur39Q2B/5BU9EZtlfj4CuNNi3y/wTM7MQiFk5m 2thiWW2MUfEe5E4QtYva+iklCcHm7G1+X/yKSJgxwjoU8xQA/ayalPUTEninKa24/mD3 CeJ7AHANGC6vDV5yxf9k3bKHPJVPUyOJgOJRQ1FOniRSvuqs0MBKXYap/liCqqx764Ez QPNzBcwMMN0cx7kfOpb6cTkTBkWktjuWK/UY/wh6WxkUFHFMNpy0BtWzH6MnlBh86UQt q0/zqeT1UlQljSKnOhqsBw5uaT5cL1v87XpQqGnqHB+e31EcROlpJWQnHNv2RzlOdf3Y X4aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zpUU9dct; dkim=neutral (no key) header.i=@linutronix.de header.b=h4GrYv7O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id d9-20020a056a0010c900b0068255c2b8a8si2167229pfu.151.2023.09.14.13.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 13:51:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zpUU9dct; dkim=neutral (no key) header.i=@linutronix.de header.b=h4GrYv7O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 063DB826F7F7; Thu, 14 Sep 2023 11:44:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241731AbjINSoK (ORCPT + 33 others); Thu, 14 Sep 2023 14:44:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241670AbjINSmM (ORCPT ); Thu, 14 Sep 2023 14:42:12 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A3A330DD; Thu, 14 Sep 2023 11:39:10 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716749; 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=pan/Otko80+kx5GwrdBzH5rqxtGnDYcelX/t2yRhZyw=; b=zpUU9dctskVd4WufCbynS94+Ovx8KK1h4oYx/VysK2/dpx9kiRW4O/QxyeZooQF1eBJlYg zU3LU+Bh7QFa5pfsMSJ8KHpSkpf/gsyL67K87tpZ6AJbvTog7UvJKenbn8hDcHEE9p+jFM FHVu3GMxb6FaLdoRVy1KsU/BkBLLsWVH2MakIP6ye29Hl9LWhxcFMDGUzhILqB6/Izolr4 jehJ0JjYJP4OsrVERl7wOiyFiw2ERZPHYR0zK3OIu4M0iKW7iKuXtPt25ngJMqCNPhC8Oc MaVs9NHEsal5rbJya1yYTrlxJsFtEhZUKqNx7kXV7SDtGvorFSTBlM6pivDgIA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716749; 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=pan/Otko80+kx5GwrdBzH5rqxtGnDYcelX/t2yRhZyw=; b=h4GrYv7OIG3dE8qwnp/pMYJXI0g1EyToxTcSzaqK+cHIYOtxHObwnYxOf/KaP9TALJI2vI I/ttHd7kyn1pyGAg== To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-serial@vger.kernel.org, Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH tty v1 70/74] serial: timbuart: Use port lock wrappers Date: Thu, 14 Sep 2023 20:44:27 +0206 Message-Id: <20230914183831.587273-71-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 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:44:57 -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 morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777047629290977156 X-GMAIL-MSGID: 1777047629290977156 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/timbuart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/timbuart.c b/drivers/tty/serial/timbuart.c index 0859394a78cd..0cc6524f5e8b 100644 --- a/drivers/tty/serial/timbuart.c +++ b/drivers/tty/serial/timbuart.c @@ -174,7 +174,7 @@ static void timbuart_tasklet(struct tasklet_struct *t) struct timbuart_port *uart = from_tasklet(uart, t, tasklet); u32 isr, ier = 0; - spin_lock(&uart->port.lock); + uart_port_lock(&uart->port); isr = ioread32(uart->port.membase + TIMBUART_ISR); dev_dbg(uart->port.dev, "%s ISR: %x\n", __func__, isr); @@ -189,7 +189,7 @@ static void timbuart_tasklet(struct tasklet_struct *t) iowrite32(ier, uart->port.membase + TIMBUART_IER); - spin_unlock(&uart->port.lock); + uart_port_unlock(&uart->port); dev_dbg(uart->port.dev, "%s leaving\n", __func__); } @@ -295,10 +295,10 @@ static void timbuart_set_termios(struct uart_port *port, tty_termios_copy_hw(termios, old); tty_termios_encode_baud_rate(termios, baud, baud); - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); iowrite8((u8)bindex, port->membase + TIMBUART_BAUDRATE); uart_update_timeout(port, termios->c_cflag, baud); - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } static const char *timbuart_type(struct uart_port *port)