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 EE7833451AA for ; Mon, 18 Aug 2025 19:14:54 +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=1755544496; cv=none; b=HUjt6bD7ODu5l2VujmA3AquKIVquehkMY0Y3uGHiuMmOujdlw09D1/DtJpVgRVBW+pNO0L5Lnzkqg4o5v+JwigUerYlPHPmLB4OdjckZzKfxX1eMDi4eQrqCpNLdZhnPGvKqahkMSfOoi7juPoZhgWW+t2HtPYnEVXz09spakPM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755544496; c=relaxed/simple; bh=uOEhxqOUWi1lhposCqSA2yzaCWNLRQUm0gqgXo1mHY0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lIiEjOS/p+9aaSCUOBr92addGj32j2sRdOIlB7hqkT2Nu6yc7cX93k3IAfCRbqTMP/ngBnEVkAlPPxPsI2YSKXaeEgrXHxK5oQRIpL8i2UqW38LYmVFOaOSsq1589yLknkUJU0rqb4XcGb7vb6csLh6SDTpEj6NlFIU/oMaLLCw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N/cz9r+F; 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="N/cz9r+F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79624C4CEEB; Mon, 18 Aug 2025 19:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755544494; bh=uOEhxqOUWi1lhposCqSA2yzaCWNLRQUm0gqgXo1mHY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N/cz9r+Fs0TTnW0Ge8FRRPCJs99JLukZNObGwsjJhGQtsQAeQcfJv4YWjkIY2UohG TMtZU7flt4s6m7sOkgH8Y8s5BpWPWptsC0ay84GNHnbaYDNRJ40boO2Gtc+xDRNNgq 1PbMFkpSfoBtZuTw5rNMaZ9FVGSQsHp0mM2KdYxJSxC6hcqJmFdrDPthuL/+LCVQuY lP7IkoqZ+8vIXM5/V+svBv3sTLk/Rs2qLTrFvw/2NnXu9M413EPKntW5gm7zoY1lMC Fwad3CyPrS1HG2cLp1mNz7WF3nmevFxHkIGA0LcaA2tddsvjEgX6wA0Vk1wkQJ1qYi 0XLM8TWy81Opg== From: Sasha Levin To: stable@vger.kernel.org Cc: Yunhui Cui , John Ogness , stable , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 6.15.y] serial: 8250: fix panic due to PSLVERR Date: Mon, 18 Aug 2025 15:14:51 -0400 Message-ID: <20250818191451.40769-1-sashal@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <2025081845-enlarging-goldsmith-455a@gregkh> References: <2025081845-enlarging-goldsmith-455a@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 8ac452cea36c..3b93b6e502b9 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -2380,9 +2380,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