From patchwork Fri Mar 15 15:42:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Kronborg X-Patchwork-Id: 780813 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8770344C7E for ; Fri, 15 Mar 2024 15:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710517375; cv=none; b=AeajTbjL8DU5sSBm/3S1ZbdTQOFSphr4okNtPj64UXXuGwz+KonGQAbV+Q51lrwFJ8wEKWuIv9ROmGTHxNZvU6bXVsGvWR7hG797zEsn2bU6alzAjknOgE4GbkbrpzesalZbFs9KTQjNj5OzSdjMc4fLkaJaHbAm8vKW0Dh8B4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710517375; c=relaxed/simple; bh=fsyEjpuzw7b3BmMY75bgJU7kV32poCTX+CSZE8V0/E8=; h=Date:To:From:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=sL659Y9kStdkmGML5wS0vKlYdvUfq7PxEmLMV8jnpcPplrZmaE+AEFLdptawjSy0GU/rXe2rZSCFR+oAvKeo1347nTyVyNtGUDQ8hDCLloIs3RBWx8SrRgrn05kwpOxvjZVupvVKMPpCEStfZMVw2G6Vx4Bh7jxvaGW+uNTkjzk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com; spf=pass smtp.mailfrom=protonmail.com; dkim=pass (2048-bit key) header.d=protonmail.com header.i=@protonmail.com header.b=rWoBVUUG; arc=none smtp.client-ip=185.70.43.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=protonmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="rWoBVUUG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1710517366; x=1710776566; bh=Ey8hbUiqjXiR3zJGD+LfivZVhBQolmYLR6mAIqJ1U14=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=rWoBVUUGL3hDfLbPM4hG54IA8djFM2hbgwjbHjdXlMczCs+tTCIu/VOdLwHCWoNcx WnOgpjmfHASbi28mCnLcbtWH5MADtbC/b9xpXI5j6p8unZsS4KfaxLCiWr4Q/Y7TWM GiqRjq490ntDHtIoixozXpqSkSc1YbxCnoaFhQI3rGdu+U9uTMXmnI25r6+E4PXYDW akN80JUnyroJJwsXkFAho8mds1HXhgqM7TKVBZY8Wk1FgGIcjjD/IKlbD7DTf3MY07 5BgUUZmH3BLRi8NloCdp86ox6HmlFK+sYe7SU9gvGA4F8qSVN3hpFufTOatN58WG42 qEFLlTQGvvsvA== Date: Fri, 15 Mar 2024 15:42:29 +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 Subject: [PATCH] serial: mxs-auart: add spinlock around changing cts state Message-ID: <20240315154150.28391-1-emil.kronborg@protonmail.com> Feedback-ID: 20949900:user:proton Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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.164243] unwind_backtrace from show_stack+0x10/0x14 (...) Signed-off-by: Emil Kronborg --- 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; }