Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6B224247291 for ; Mon, 18 Aug 2025 19:07:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755544039; cv=none; b=iSPPfY0VDEG0kSVjlbNVUmVJsqEiG+yoHYS3zwUy9U8vlQ4/nqfdwh82z+dXC2SLmfLakDhZ3pkBbmtClYQFAcFpmI7DFOFQOR4iFcgEgiEFEw+Ez/q+sasPCnGiRvnjSq3BvYpVGZCRp2Ts0MmVygYkxK5tEg1w/93ptfsiAko= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755544039; c=relaxed/simple; bh=haY1zNBku6ED4wRobpYhv9y5a428/PSETfzBLmEvoBI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bMpMuZOpzhi2ZAVm1nKZ71500KuatFvvtbKpd7//aqq/Pjc4Tq/xG2RRYyFHtQJ8c/6fJEv2mhbB4Drm6af7fhoOeICPFfiz4hzGcBYn3TOoNf8N7lq1Lt+Dqj02QzlYcqrlFqdSVcv8+KI9Dnjtc6Rwl9jwiSiyDknFqNwaLAA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=duNr4ghQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="duNr4ghQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18130C4CEF1; Mon, 18 Aug 2025 19:07:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755544038; bh=haY1zNBku6ED4wRobpYhv9y5a428/PSETfzBLmEvoBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=duNr4ghQbZ7df/5OwIaldekQAp3qvz2/Ss409fWus7DG/WgsgstG9b3rFRqkJGeBD +MrPgZY9C1rfE3Pb/dZO4eAEgjqp+G6Op7s2u4vHwg4ZNtYggKUDWNh0gpPFcc8t23 2lAQGZN/S5WyYqKvbRdTgkB7Xl5QJCzExHGZBJWVNGLGdltBqztbMBXnmTqNvFjYyp dppFQdhfwlmY3np1seLnfoHBc9x0YVw/bwVYD0yKGc1NFZS3GL68ucZhYz4CDbB2zk ygPVcqZWYHMlGqA+Qn/hh2Daux5olq2l/uKqC1KR5OgtWEj9J0+y7vwS3gsugGPaDI BgEslzGU+Lo5w== From: Sasha Levin To: stable@vger.kernel.org Cc: Yunhui Cui , John Ogness , stable , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 6.16.y] serial: 8250: fix panic due to PSLVERR Date: Mon, 18 Aug 2025 15:07:15 -0400 Message-ID: <20250818190715.38052-1-sashal@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <2025081844-wimp-jubilance-539e@gregkh> References: <2025081844-wimp-jubilance-539e@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Yunhui Cui [ Upstream commit 7f8fdd4dbffc05982b96caf586f77a014b2a9353 ] When the PSLVERR_RESP_EN parameter is set to 1, the device generates an error response if an attempt is made to read an empty RBR (Receive Buffer Register) while the FIFO is enabled. In serial8250_do_startup(), calling serial_port_out(port, UART_LCR, UART_LCR_WLEN8) triggers dw8250_check_lcr(), which invokes dw8250_force_idle() and serial8250_clear_and_reinit_fifos(). The latter function enables the FIFO via serial_out(p, UART_FCR, p->fcr). Execution proceeds to the serial_port_in(port, UART_RX). This satisfies the PSLVERR trigger condition. When another CPU (e.g., using printk()) is accessing the UART (UART is busy), the current CPU fails the check (value & ~UART_LCR_SPAR) == (lcr & ~UART_LCR_SPAR) in dw8250_check_lcr(), causing it to enter dw8250_force_idle(). Put serial_port_out(port, UART_LCR, UART_LCR_WLEN8) under the port->lock to fix this issue. Panic backtrace: [ 0.442336] Oops - unknown exception [#1] [ 0.442343] epc : dw8250_serial_in32+0x1e/0x4a [ 0.442351] ra : serial8250_do_startup+0x2c8/0x88e ... [ 0.442416] console_on_rootfs+0x26/0x70 Fixes: c49436b657d0 ("serial: 8250_dw: Improve unwritable LCR workaround") Link: https://lore.kernel.org/all/84cydt5peu.fsf@jogness.linutronix.de/T/ Signed-off-by: Yunhui Cui Reviewed-by: John Ogness Cc: stable Link: https://lore.kernel.org/r/20250723023322.464-2-cuiyunhui@bytedance.com Signed-off-by: Greg Kroah-Hartman [ adapted to inline code structure without separate serial8250_initialize helper function ] Signed-off-by: Sasha Levin --- drivers/tty/serial/8250/8250_port.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 6d7b8c4667c9..db26cf5a5c02 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -2376,9 +2376,8 @@ int serial8250_do_startup(struct uart_port *port) /* * Now, initialize the UART */ - serial_port_out(port, UART_LCR, UART_LCR_WLEN8); - uart_port_lock_irqsave(port, &flags); + serial_port_out(port, UART_LCR, UART_LCR_WLEN8); if (up->port.flags & UPF_FOURPORT) { if (!up->port.irq) up->port.mctrl |= TIOCM_OUT1; -- 2.50.1