From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A933FC54E58 for ; Wed, 20 Mar 2024 12:16:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:Cc:From :To:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=KabmE2IM2jJ+bWpPxm6yrOg3++IdoAn9vGJvO48/STA=; b=XX3y19Nk4J0b99 iPDT7B+k5pfxY9Elf+jVekIIfSqGl0YKqTO9HddXriay3WVfK15hAvNqDsHPPa6ZoBDcu9ic56wQX xWb5OqHYVncf7eyil3zJdYFcAqUc5ZtoBPmKgIFDLpaN6aXDZCupDaTCn5CQzaxj65u9zyrJidiy+ itEYAV9AAJCU0fMY1211eBs85CPobtdUjbXqK0M2WyQLS2ORRJIziiQkDyq+quQguuKhSeTxc74GS /aJ1xfSz5gTA/HixQc4nNLcInzk1L1mlRXw3crICUTslBL9sX0Ld+7JMkC3+rtF095f8XVHbYbh0b znwuaT+e8sMnBdRTZ44w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmurK-0000000H5S9-0o5i; Wed, 20 Mar 2024 12:15:54 +0000 Received: from mail-4322.protonmail.ch ([185.70.43.22]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmurH-0000000H5RZ-159e for linux-arm-kernel@lists.infradead.org; Wed, 20 Mar 2024 12:15:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1710936946; x=1711196146; bh=hrhEkdmz0bda6xif5V4a29xg5PpADmwyOkTCS+waL7s=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=ceFRikTm1IiNNVPOhnISV8qVpdelqJ33F15DUsJLpI3RJgisESC+j4UatluzI5o1H qu1I82s9WkMamYRmCENMdU08ypS8966hc3CMA84IyoEoToOPCSv4Pbn29tdj6fpmVC tXKpRkRFKQGi2W9oiG5bPSeSNf3VdVqDtTgx1loJiucbhEC22aqKYcAoWN+ohmigqW A0K9OZXrnYEO0oA5A2nL3UKjwT1PQzbNjN8j6JtxLMVjxtqahsyV2webvQQC2ZU9Cs 2hSXssimo2RqG09dnVX/KLw+uNlRfaubijK3ipwMhkCbCUYdSFQWtorcGi10cK9AZ/ 7rp8OsheUX/cA== Date: Wed, 20 Mar 2024 12:15:36 +0000 To: jirislaby@kernel.org, gregkh@linuxfoundation.org From: Emil Kronborg Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, Emil Kronborg , stable@vger.kernel.org, Frank Li Subject: [PATCH v3] serial: mxs-auart: add spinlock around changing cts state Message-ID: <20240320121530.11348-1-emil.kronborg@protonmail.com> Feedback-ID: 20949900:user:proton MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240320_051551_734135_75594DA6 X-CRM114-Status: GOOD ( 11.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The uart_handle_cts_change() function in serial_core expects the caller to hold uport->lock. For example, I have seen the below kernel splat, when the Bluetooth driver is loaded on an i.MX28 board. [ 85.119255] ------------[ cut here ]------------ [ 85.124413] WARNING: CPU: 0 PID: 27 at /drivers/tty/serial/serial_core.c:3453 uart_handle_cts_change+0xb4/0xec [ 85.134694] Modules linked in: hci_uart bluetooth ecdh_generic ecc wlcore_sdio configfs [ 85.143314] CPU: 0 PID: 27 Comm: kworker/u3:0 Not tainted 6.6.3-00021-gd62a2f068f92 #1 [ 85.151396] Hardware name: Freescale MXS (Device Tree) [ 85.156679] Workqueue: hci0 hci_power_on [bluetooth] (...) [ 85.191765] uart_handle_cts_change from mxs_auart_irq_handle+0x380/0x3f4 [ 85.198787] mxs_auart_irq_handle from __handle_irq_event_percpu+0x88/0x210 (...) Cc: stable@vger.kernel.org Fixes: 4d90bb147ef6 ("serial: core: Document and assert lock requirements for irq helpers") Reviewed-by: Frank Li Signed-off-by: Emil Kronborg --- Changes in v3: I misunderstood how additional instructions for the stable team work; sorry about that. Therefore, the only change in this version is the removal of the "Cc" tag, which no longer includes v6.1+ as a prerequisite. Additionally, I included Frank's Reviewed-by in the patch. Since the Fixes commit has been included since v3.18, this patch should be backported to all currently maintained stable kernels. However, for backporting to v6.6 and earlier, either b0af4bcb4946 ("serial: core: Provide port lock wrappers") needs to be included, or those helpers must be open-coded, i.e. doing spin_lock(&s->port.lock); instead of uart_port_lock(&s->port);. drivers/tty/serial/mxs-auart.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c index 4749331fe618..1e8853eae504 100644 --- a/drivers/tty/serial/mxs-auart.c +++ b/drivers/tty/serial/mxs-auart.c @@ -1086,11 +1086,13 @@ static void mxs_auart_set_ldisc(struct uart_port *port, static irqreturn_t mxs_auart_irq_handle(int irq, void *context) { - u32 istat; + u32 istat, stat; struct mxs_auart_port *s = context; u32 mctrl_temp = s->mctrl_prev; - u32 stat = mxs_read(s, REG_STAT); + uart_port_lock(&s->port); + + stat = mxs_read(s, REG_STAT); istat = mxs_read(s, REG_INTR); /* ack irq */ @@ -1126,6 +1128,8 @@ static irqreturn_t mxs_auart_irq_handle(int irq, void *context) istat &= ~AUART_INTR_TXIS; } + uart_port_unlock(&s->port); + return IRQ_HANDLED; } -- 2.44.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel