From patchwork Thu Sep 14 18:37:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 139894 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp683846vqi; Thu, 14 Sep 2023 16:18:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHnAMEHAY9v5TUK88VrZ1vQ2/I/r3n19LzAbtsms1Goz5lsSQdmRY0QydJ6EVq8TNkbxdds X-Received: by 2002:a05:6a00:2283:b0:68f:ea5d:1f70 with SMTP id f3-20020a056a00228300b0068fea5d1f70mr85207pfe.14.1694733498772; Thu, 14 Sep 2023 16:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694733498; cv=none; d=google.com; s=arc-20160816; b=gUS1eFMsrhMhSNIlRqLYBH/OqLbSW2GpFLPW7TVl46a6kBsshtXGhc79IqdVPt8hmZ OntpkIw63quR8wTxLASseUwzvKOHefp7PYo/QN4ZojkqqyfdxFYcI4WzKMWTOWWR4fDo ldqSnJUBpp74KvUFNoyGOsMd4pgZK0ROwiKfEGcN9V1np1pxb2m+H0uehRcLPlxaDKlB Os4L8epyErM37NjB8rQYWSQRBcUBeNak4qgUYVAQ61BadWeh2wsvZPxBwEKi7opGO8tu +YIkS5aiSp35aQJ+6AElYagUTAEzF9sy7zYbfZjXSvj9Vfim7FfSI8PQsBt/eDHk3inh qLRg== 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=CzZ2M7Ay+uoSpWDNXt2IF108PlOFaDB0Gl5ZSfxIoKA=; fh=PzcPxI7PZN8NUqsfz6j94KyRNSZSXRFV1MImXRvnVpM=; b=SKtegu88/M44JEAPRfzc6RpxfbVzgz6Xv1WraLH3YNpQGTmNohg1Pw5kBcmY3x+S4C tVERSUxTCkpYh9KoiVvLwBsnlH5zF1lsJQ7IORq9D/NzXMZjN7YlKfRXaiOdx2rFMEyq m2zJTKSoiDYHA0yKKXzcHs/e1zTnSftBlDOGTrk6lSsi+9OQDVuoCFMMPhWXrVttMH8T 4jg40Za1NotcwDpjX3GK8wmU93s/2pSgSuTuMdA/Z3nSQBnCNQ7S4wHXM3jFYt+fvJ1h pYzjGiBh0Kcz9yGLQ81lFdwS7kbkUe4ScISaorEiieWatoq6eLtd2BFm2r55N4w3RObS STbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=MN04YVr9; 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:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id c5-20020a6566c5000000b00577808bf793si2180840pgw.795.2023.09.14.16.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:18:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=MN04YVr9; 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:4 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 howler.vger.email (Postfix) with ESMTP id 7A8448705EA0; Thu, 14 Sep 2023 11:39:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241890AbjINSjR (ORCPT + 33 others); Thu, 14 Sep 2023 14:39:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241400AbjINSis (ORCPT ); Thu, 14 Sep 2023 14:38:48 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97BB21FF9; Thu, 14 Sep 2023 11:38:43 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694716721; 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=CzZ2M7Ay+uoSpWDNXt2IF108PlOFaDB0Gl5ZSfxIoKA=; b=MN04YVr9XpiH+REY6l7sFIUGI/otQWeRx+CKe/J4+jMfCS0h0U6aIm01i3LOSc/jBKZ4lL XTInMSjAR/ywP2wrgbrAtW4+AKEkb/ExW/V2qne+n4kXbGFT1vswV4l3nARA/jtnvknOxh jiaUIX8aUYihEu7/LSXCaQcmM6LcClRkIv6ACbTowKQvmPN6ErddahwcH7LNL9ibjbD3gC 2MamTfJD3//3CTP1OMZtoXs5K/TWjqPaxcxAgxnf37Lgae3nJP3KXUPCSpx/q4BeLm11JQ l53K51Y5jNK1jpi/XFuhvi2+qzo/Sd/erXOzxvJplGgq4Qg4g9KImV9kXWNcqA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694716721; 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=CzZ2M7Ay+uoSpWDNXt2IF108PlOFaDB0Gl5ZSfxIoKA=; b=7AP6OHdmQkAf45CIbcjDpOnJQIa7Mil7nBAtO0WArIZaqyFG/TyjfxMEofUIZB8/cnTr7G Cv7UMdHf9PI0DHCQ== 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?= , Andy Shevchenko Subject: [PATCH tty v1 07/74] serial: 8250_dma: Use port lock wrappers Date: Thu, 14 Sep 2023 20:43:24 +0206 Message-Id: <20230914183831.587273-8-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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 11:39:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777056872943848942 X-GMAIL-MSGID: 1777056872943848942 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 Reviewed-by: Ilpo Järvinen --- drivers/tty/serial/8250/8250_dma.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c index 7fa66501792d..8b30ca8fdd3f 100644 --- a/drivers/tty/serial/8250/8250_dma.c +++ b/drivers/tty/serial/8250/8250_dma.c @@ -22,7 +22,7 @@ static void __dma_tx_complete(void *param) dma_sync_single_for_cpu(dma->txchan->device->dev, dma->tx_addr, UART_XMIT_SIZE, DMA_TO_DEVICE); - spin_lock_irqsave(&p->port.lock, flags); + uart_port_lock_irqsave(&p->port, &flags); dma->tx_running = 0; @@ -35,7 +35,7 @@ static void __dma_tx_complete(void *param) if (ret || !dma->tx_running) serial8250_set_THRI(p); - spin_unlock_irqrestore(&p->port.lock, flags); + uart_port_unlock_irqrestore(&p->port, flags); } static void __dma_rx_complete(struct uart_8250_port *p) @@ -70,7 +70,7 @@ static void dma_rx_complete(void *param) struct uart_8250_dma *dma = p->dma; unsigned long flags; - spin_lock_irqsave(&p->port.lock, flags); + uart_port_lock_irqsave(&p->port, &flags); if (dma->rx_running) __dma_rx_complete(p); @@ -80,7 +80,7 @@ static void dma_rx_complete(void *param) */ if (!dma->rx_running && (serial_lsr_in(p) & UART_LSR_DR)) p->dma->rx_dma(p); - spin_unlock_irqrestore(&p->port.lock, flags); + uart_port_unlock_irqrestore(&p->port, flags); } int serial8250_tx_dma(struct uart_8250_port *p)