From patchwork Thu Sep 14 18:38:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 139779 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp553408vqi; Thu, 14 Sep 2023 11:48:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHyRCZkaV+oBE4r2dFTeFs1dKVC+dqhx9+D+DGVGN0DmR4wInwMZVL1Q6++TKH/Wcfj7hGg X-Received: by 2002:a05:6a00:a08:b0:68e:3def:c3cd with SMTP id p8-20020a056a000a0800b0068e3defc3cdmr6623978pfh.17.1694717321359; Thu, 14 Sep 2023 11:48:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694717321; cv=none; d=google.com; s=arc-20160816; b=C1Id8JRxCpwX6p5EFD9RIkiIcM0U+d88FYqQtuSzGpl839KG3EUBES/F0UN63HNFIw 7N/W+B/anKXj4L2+VYU/sG1FjN3a4qoAd/x8s2ffdoCK6M80edcsf8LEFVLEz6Cv2AXv jr5tCEBcJ8xWbkhx0gnHOd0+bRU4iRq1IWI1fFNVlTvmsSkg/yB7uqLLTRdd/KieBDlY M0iiTVsjwWpH19zdivMiQc3HLv/ZPTOoFVtX5wprnw1ES+fDCZ+uRAl1+Otr+DjIWerr xHLVbkadi06p1gp2MPGCQrKG0sdJ5/hTCVxObWPIXkFqyMfmNDXopnGz2GMmsJ3yWPhE p/1A== 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=h4vNSSSfbKzMTl5dIaX+nKFLqtsf/7qFsjWyC6l0EH0=; fh=hOT9LyJHY52SzfFWBjnD623R/IMva4HnaOqJDvo7p7k=; b=vZA9kMGz6GDwPR644xDJ3ebefnqmdI+iJpDtJZeIwUUhDaMYwj1oXM+VR4qEDUz4+R qkQb4jXAUHMUeFa8mk7RzcxuLBna35U8hPFpFPNgXjf84AwKUVZNRpCy6HoSsv7n80Zc 1XlTud8GhZdSEuZE8jyCLavDKs1VrWP+678iRf7UiyLiNSnQh246Fcjzz2omLuAM/q6n Ck+BL3CwzdhrwwzafMuJnAIRVIRbq+GZuHTAlGgF7msLtyaGrXEOh01ecW4xy+Z4xRrr H1t+Rcoi274ZdD8EDPtVgjUN/22DgrDEGiHoDA7tHLz7sfsONQPYKLddFtCxBE7JkjwK GA3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Btvxqnk4; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=skOOWWSl; 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id k3-20020a6568c3000000b0056f8fdb4430si1967254pgt.893.2023.09.14.11.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 11:48:41 -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=Btvxqnk4; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=skOOWWSl; 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 8064382B89B6; Thu, 14 Sep 2023 11:44:56 -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 S241920AbjINSoa (ORCPT + 33 others); Thu, 14 Sep 2023 14:44:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241770AbjINSm3 (ORCPT ); Thu, 14 Sep 2023 14:42:29 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B8CF30F0; Thu, 14 Sep 2023 11:39:11 -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=h4vNSSSfbKzMTl5dIaX+nKFLqtsf/7qFsjWyC6l0EH0=; b=Btvxqnk4X2os6S5PrOaEvdQj5QO8ypBR/vcabWe3Gj5lhywtI34HkX9oqmk/uN8pbMIMfW I36GzlO0wMYRThI7KH1lMM/7nxcrYd1F9UhOwQDEjh8Ro10ODzExtzippTDQ7xkrpGTQ8R /afpljVJSX4wsuCyOws5j7Ay2eYLJtPePh3JpHOCtohYDUa24cIVB6b+2rSG/THHGoxEo1 2yJvl9M2jPGFBw6rEt9JljlPfa80dVAzz7Tk3ynReIsFt0hbRYD3tY6LfhhqbzzK8gEI+b 2P2Z7R5JL0rdoozdGeXCuCLpQ6NHXbmemuyVTCAScZ9i7ZcbmJfp99qRUiG8Jw== 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=h4vNSSSfbKzMTl5dIaX+nKFLqtsf/7qFsjWyC6l0EH0=; b=skOOWWSloirPh2qLF10hQ5qRfe3vdZMKCUw5YKRzGtn51G9SzuSd9vTdeNuK3ueDbstJiR QFsCirT45QgYgiBA== To: Greg Kroah-Hartman Cc: Jiri Slaby , linux-serial@vger.kernel.org, Petr Mladek , Thomas Gleixner , linux-kernel@vger.kernel.org, Timur Tabi , linuxppc-dev@lists.ozlabs.org Subject: [PATCH tty v1 72/74] serial: ucc_uart: Use port lock wrappers Date: Thu, 14 Sep 2023 20:44:29 +0206 Message-Id: <20230914183831.587273-73-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 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:44:56 -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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777039909953545391 X-GMAIL-MSGID: 1777039909953545391 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 Acked-by: Timur Tabi --- drivers/tty/serial/ucc_uart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c index b06661b80f41..ed7a6bb5596a 100644 --- a/drivers/tty/serial/ucc_uart.c +++ b/drivers/tty/serial/ucc_uart.c @@ -931,7 +931,7 @@ static void qe_uart_set_termios(struct uart_port *port, baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16); /* Do we really need a spinlock here? */ - spin_lock_irqsave(&port->lock, flags); + uart_port_lock_irqsave(port, &flags); /* Update the per-port timeout. */ uart_update_timeout(port, termios->c_cflag, baud); @@ -949,7 +949,7 @@ static void qe_uart_set_termios(struct uart_port *port, qe_setbrg(qe_port->us_info.tx_clock, baud, 16); } - spin_unlock_irqrestore(&port->lock, flags); + uart_port_unlock_irqrestore(port, flags); } /*