From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6917628001A for ; Mon, 9 Jun 2025 07:44:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749455050; cv=none; b=jRqTmb4YmvgVG/RBa1Dwy3bXYjYYf4KMXLasyA7a/rwERWhG7b2zlc/foXAcjgQ/acZ0qd5vQ1XMZvcbCwDvDanoKhvB2sixm5HOsaEXxn3LeipHizUfuY0i3qK72rYV0eOEijbgYN1P3ZiHJWIF2hBJ/hcIJ69K4ppdXDq7zkw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749455050; c=relaxed/simple; bh=Yay0E1IktJ5U3dv9Jr5sXBr5qazP/zu1WzMA4ShslGg=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=EGG6wY0HwNS5iRXikTPpaoPS1XTNu3nO9ob7HbP6EYnCEqahZY2s9ajNEjcbQcLf++oxJqfqK1l8Wdp86u08wgTYJCH65IfBp6yHrG3g7pMPeWIgekB3mmfTBQPZ0v/DjOgddtd67wrHB0iz+FR6p8FAmA2PaxWxCQ+nZm1TjbI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=Zjw2bvIG; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="Zjw2bvIG" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-235d6de331fso47151455ad.3 for ; Mon, 09 Jun 2025 00:44:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1749455048; x=1750059848; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Inkjt4Nq2XV942wyB2oCSN3ntPshT/X6vryIjMwcT1A=; b=Zjw2bvIGPVF1gEa3KglU/w+QSyYvW9e6HVircu3B5lvU5QaEglyDT7CIAtU85a6lKV 2F0u5ll9HNhfs6Onpryu4q3uee3ZOOMLPV+3CgSDyoFTXw8hdTDrwXZw10mmikQ1vLJN dCvIKgOcKU9ujVqSb/Wlgy5I+WyYL5J4mkTEyDj7GEx2ptth9Et+xTs/8TRpW0kjwnYv fzKhFa8Kt7jSTJq8pVjw6vKamI2WTqH0xOqIT7E8oaKdQEzV/wHwTl/wUs7YRh2Qhe9K Ocn+ee7mY2NvmSlSHl+8aJtHjAYOSRiFRfEaSFL4GygTEOe1fojJ/uvniohKKzSIIgdc kU+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749455048; x=1750059848; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Inkjt4Nq2XV942wyB2oCSN3ntPshT/X6vryIjMwcT1A=; b=mp8vSBSl8iIvZ2BOfYZxWDFrydFGWnt7uhZ2DL6E50nnVufdi6/lhnhuPKcWx/yjlQ YhD2TS03HhSSJXW+aEEcfgQ8G//t4kmS2oyVRjTph2DC0Ya0pUFyaOvTV+qLuc8rq0Pu s1vJ/C4AXqqktxvfXAwfJNs3bIQFWutuAm+0lcQNea6SfU3MstMQ8lT1wUssDa8MgeeR NbcSju5LVVmR4scSUszOlRZgTekobZt0NSKemRsf8X4gq2bKe7CTVKVMI772yHevsPN4 syGi9/WD46FP4j5BN/gl/c3imY1ItSB01O1GCO67SgjKk8LSigRW6CHtHBakju8oUJXS Zhng== X-Forwarded-Encrypted: i=1; AJvYcCXsC/laINyclT/gtEUjx5qB8sRMHH23bkIXsKU8WtM0vtjG0ia2FW0h4WZCxPrl9vGc+DAeas8+YWQmGeY=@vger.kernel.org X-Gm-Message-State: AOJu0YyI/+mGsRDX6WeOfCKrtD0VxWhl9DeUGJ+PM635CjspN3/yYqPE P8GH4OEeJKEM6Llawg8jaq6GKk/tHzpuLDfVmxIswevE99yq3yS3vEOzsyLlO6aBUUE= X-Gm-Gg: ASbGncvpDx73Kp1ug97SDxeYSdYL9zYVlcUn1Xp4Qi7/WD7gxPC9B2Sbvt+suh5xCrk 0RvhNUuycP1pCz2SH1mhimKpht5CQ2gnnbkzuw+WD8Xb6e5dg6bs2ih8dD5USKOQPonut7P4bMl QFcOfBZkAvWatnFgkquGxda8Xb/sL+akPDkybgPJcCpUV/MeHS+WG1PaZiu841Xd4c0wbQp/TjN kRU8D+/y9N4f/Tlr6+ezRgTSW2XbXRb22EdRSsEjni6WqjiBJnxwIjArqn4W/6q7gI/gRh+gyHX gkZeMTIuzDfiRDaDrRHyrEQCYyYQ7mWCRr1t/G7+SF182jxXzl/A2QWREnTur9A2aozwcqkbj/h tHPofWV8RZ7agle/M5d8wMpNIegA4cW9Pyi9JIFkksQ== X-Google-Smtp-Source: AGHT+IGfhLJOOr7W048JUz9Br7St9/rblBkEeqaO1eS84wCT9RHG7Sx6FmIfAdyIRIjtaw9ZkajVEg== X-Received: by 2002:a17:902:d50c:b0:234:de0a:b36e with SMTP id d9443c01a7336-23601da6138mr183133125ad.49.1749455047769; Mon, 09 Jun 2025 00:44:07 -0700 (PDT) Received: from L6YN4KR4K9.bytedance.net ([61.213.176.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-236030969ebsm48573715ad.72.2025.06.09.00.44.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Jun 2025 00:44:06 -0700 (PDT) From: Yunhui Cui To: arnd@arndb.de, andriy.shevchenko@linux.intel.com, benjamin.larsson@genexis.eu, cuiyunhui@bytedance.com, gregkh@linuxfoundation.org, heikki.krogerus@linux.intel.com, ilpo.jarvinen@linux.intel.com, jirislaby@kernel.org, jkeeping@inmusicbrands.com, john.ogness@linutronix.de, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, markus.mayer@linaro.org, matt.porter@linaro.org, namcao@linutronix.de, paulmck@kernel.org, pmladek@suse.com, schnelle@linux.ibm.com, sunilvl@ventanamicro.com, tim.kryger@linaro.org, stable@vger.kernel.org Subject: [PATCH v8 1/4] serial: 8250: fix panic due to PSLVERR Date: Mon, 9 Jun 2025 15:43:45 +0800 Message-Id: <20250609074348.54899-1-cuiyunhui@bytedance.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: stable@vger.kernel.org --- drivers/tty/serial/8250/8250_port.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 6d7b8c4667c9c..07fe818dffa34 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -2376,9 +2376,10 @@ 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.39.5