From mboxrd@z Thu Jan 1 00:00:00 1970 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 6D14A226CE6; Mon, 23 Jun 2025 22:16:44 +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=1750717006; cv=none; b=e8kaxnblUiZXWjPutU1zwj0vLe4OaJcCUPv/TryCNJCNc0BNg7CBwe1qi70yMXROcoX10GiSFpyomMlRhgh4Mtz5K/ngXDVwL2jnrTtYIS7XqOmSswzQjnG1/B901Sm2brcV+LBcEQBNtiXPng8tYboBMKA2ikcXRwjN1j88W9E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750717006; c=relaxed/simple; bh=cutWAfCuMtpW5+fer1O5yysKQRdoqdtpFCcYRyn+/xo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UmgaAJjODPg5+lXPfpdKkqTLC590Vo+qQNA+K+py9nuFdrVvWJf3/KtHYMZN0lVCDYcKoe/podU3yHMGt+rcoggwIOACBu7f+tGIjqkwJeI6g7YYT1QTHV1wdi+zsKXwVQIkR7OpDQL8RWubWtn1IZaDtEUOZ45VlpM2ym4+Vl0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TxV+b6l8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="TxV+b6l8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3D85C4CEF2; Mon, 23 Jun 2025 22:16:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750717004; bh=cutWAfCuMtpW5+fer1O5yysKQRdoqdtpFCcYRyn+/xo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TxV+b6l8v7q5hhU4j5rU+gyS1ztNQUaODiFTxABh6mdVWkKw3jRyNuN0CmITSoIR+ U59Nvc5S4Prlp4olRfi1kUYr/3tiY9nLdpQ/kElPTi6fHUHrRYEHXku/JamqNDZrTs iFKv8zxW3rM9kHlvD1skFSJ5W+VY+xHFDGcwCDMs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Claudiu Beznea Subject: [PATCH 5.15 386/411] serial: sh-sci: Increment the runtime usage counter for the earlycon device Date: Mon, 23 Jun 2025 15:08:50 +0200 Message-ID: <20250623130643.374026221@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130632.993849527@linuxfoundation.org> References: <20250623130632.993849527@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Claudiu Beznea commit 651dee03696e1dfde6d9a7e8664bbdcd9a10ea7f upstream. In the sh-sci driver, serial ports are mapped to the sci_ports[] array, with earlycon mapped at index zero. The uart_add_one_port() function eventually calls __device_attach(), which, in turn, calls pm_request_idle(). The identified code path is as follows: uart_add_one_port() -> serial_ctrl_register_port() -> serial_core_register_port() -> serial_core_port_device_add() -> serial_base_port_add() -> device_add() -> bus_probe_device() -> device_initial_probe() -> __device_attach() -> // ... if (dev->p->dead) { // ... } else if (dev->driver) { // ... } else { // ... pm_request_idle(dev); // ... } The earlycon device clocks are enabled by the bootloader. However, the pm_request_idle() call in __device_attach() disables the SCI port clocks while earlycon is still active. The earlycon write function, serial_console_write(), calls sci_poll_put_char() via serial_console_putchar(). If the SCI port clocks are disabled, writing to earlycon may sometimes cause the SR.TDFE bit to remain unset indefinitely, causing the while loop in sci_poll_put_char() to never exit. On single-core SoCs, this can result in the system being blocked during boot when this issue occurs. To resolve this, increment the runtime PM usage counter for the earlycon SCI device before registering the UART port. Fixes: 0b0cced19ab1 ("serial: sh-sci: Add CONFIG_SERIAL_EARLYCON support") Cc: stable@vger.kernel.org Signed-off-by: Claudiu Beznea Link: https://lore.kernel.org/r/20250116182249.3828577-6-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/sh-sci.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -3335,6 +3335,22 @@ static int sci_probe_single(struct platf if (sci_uart_earlycon && sci_ports[0].port.mapbase == sci_res->start) { /* + * In case: + * - this is the earlycon port (mapped on index 0 in sci_ports[]) and + * - it now maps to an alias other than zero and + * - the earlycon is still alive (e.g., "earlycon keep_bootcon" is + * available in bootargs) + * + * we need to avoid disabling clocks and PM domains through the runtime + * PM APIs called in __device_attach(). For this, increment the runtime + * PM reference counter (the clocks and PM domains were already enabled + * by the bootloader). Otherwise the earlycon may access the HW when it + * has no clocks enabled leading to failures (infinite loop in + * sci_poll_put_char()). + */ + pm_runtime_get_noresume(&dev->dev); + + /* * Skip cleanup the sci_port[0] in early_console_exit(), this * port is the same as the earlycon one. */