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 5971229A32C; Mon, 5 May 2025 22:39:02 +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=1746484743; cv=none; b=tXvWjI9aHg02rJR0qb5yN+GWVvh/Gzl9Ds0rx3VxjLmjk6T2WN2Lo/0itA/aZd+tl5j2TY3Lk3zI2k6fbaPlQN4/FCOzbCpUIy+VBayq707YFkNnuoxotyreAU7ztKo7Z703mSz1lBZHdiEb5ONaDr7ErGLvFujLZR6+j+OTgaI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746484743; c=relaxed/simple; bh=3lGIjIMND9OTu5MdA5mIsTVJLkH/I5jKgZBsA8qqLuc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sBYTZIXiWJMLlmue1uQNyvhpsmO4qF7c2kcHp1G5MTH0lYcSvhb3dQjokbU31gwGt+pY25rGEZFanSzf1J39jG4SC9p0YRzj2Z3NO2c+w+kdFpTln0hOS9WaECGEp+paJT3/NZIYhuCkaneoJB++Tfs9hz7/cR97S2c+kbiN700= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MZzST7QA; 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="MZzST7QA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83A1CC4CEE4; Mon, 5 May 2025 22:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746484742; bh=3lGIjIMND9OTu5MdA5mIsTVJLkH/I5jKgZBsA8qqLuc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MZzST7QAvt/Frs4+H+n5g+MspdjYIQC+XftvHw7FMr/TlTjeLuP5BwdCGSJxtjQ+X URsrPyUEG9i0zHBCfAikpQeJGwvoaoTSOBVDYxByRC74xZHGZVkmKkiqfa+kb8IhSO nP2sdkZi+qXENnpQRqpg97FAoFkmbzOismve9kI13nZIZaiQ8i1tX9Ge6zujRgWaDp dzbYiDYCeJgi/d6Xwne4gNC9ghlLRbd51Vx8yIjU0pyEZy68gK4k+o4wsUUuRdl+MX sluZ6jiWvIbVWCWNlBvPQFyxZP3FKrrXx1d2Op/ft9VQNzXKSTA+AslAgJScRgms3m H+e72pJiPZzVg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Geert Uytterhoeven , Claudiu Beznea , Greg Kroah-Hartman , Sasha Levin , jirislaby@kernel.org, wsa+renesas@sang-engineering.com, zack.rusin@broadcom.com, namcao@linutronix.de, prabhakar.mahadev-lad.rj@bp.renesas.com, linux-serial@vger.kernel.org Subject: [PATCH AUTOSEL 6.14 636/642] serial: sh-sci: Save and restore more registers Date: Mon, 5 May 2025 18:14:12 -0400 Message-Id: <20250505221419.2672473-636-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250505221419.2672473-1-sashal@kernel.org> References: <20250505221419.2672473-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.14.5 Content-Transfer-Encoding: 8bit From: Geert Uytterhoeven [ Upstream commit 81100b9a7b0515132996d62a7a676a77676cb6e3 ] On (H)SCIF with a Baud Rate Generator for External Clock (BRG), there are multiple ways to configure the requested serial speed. If firmware uses a different method than Linux, and if any debug info is printed after the Bit Rate Register (SCBRR) is restored, but before termios is reconfigured (which configures the alternative method), the system may lock-up during resume. Fix this by saving and restoring the contents of the BRG Frequency Division (SCDL) and Clock Select (SCCKS) registers as well. Also save and restore the HSCIF's Sampling Rate Register (HSSRR), which configures the sampling point, and the SCIFA/SCIFB's Serial Port Control and Data Registers (SCPCR/SCPDR), which configure the optional control flow signals. After this, all registers that are not saved/restored are either: - read-only, - write-only, - status registers containing flags with clear-after-set semantics, - FIFO Data Count Trigger registers, which do not matter much for the serial console. Fixes: 22a6984c5b5df8ea ("serial: sh-sci: Update the suspend/resume support") Signed-off-by: Geert Uytterhoeven Tested-by: Claudiu Beznea Reviewed-by: Claudiu Beznea Link: https://lore.kernel.org/r/11c2eab45d48211e75d8b8202cce60400880fe55.1741114989.git.geert+renesas@glider.be Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/sh-sci.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index e0ead0147bfe0..0219135caafa4 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -105,10 +105,15 @@ struct plat_sci_reg { }; struct sci_suspend_regs { + u16 scdl; + u16 sccks; u16 scsmr; u16 scscr; u16 scfcr; u16 scsptr; + u16 hssrr; + u16 scpcr; + u16 scpdr; u8 scbrr; u8 semr; }; @@ -3564,6 +3569,10 @@ static void sci_console_save(struct sci_port *s) struct sci_suspend_regs *regs = &s->suspend_regs; struct uart_port *port = &s->port; + if (sci_getreg(port, SCDL)->size) + regs->scdl = sci_serial_in(port, SCDL); + if (sci_getreg(port, SCCKS)->size) + regs->sccks = sci_serial_in(port, SCCKS); if (sci_getreg(port, SCSMR)->size) regs->scsmr = sci_serial_in(port, SCSMR); if (sci_getreg(port, SCSCR)->size) @@ -3574,6 +3583,12 @@ static void sci_console_save(struct sci_port *s) regs->scsptr = sci_serial_in(port, SCSPTR); if (sci_getreg(port, SCBRR)->size) regs->scbrr = sci_serial_in(port, SCBRR); + if (sci_getreg(port, HSSRR)->size) + regs->hssrr = sci_serial_in(port, HSSRR); + if (sci_getreg(port, SCPCR)->size) + regs->scpcr = sci_serial_in(port, SCPCR); + if (sci_getreg(port, SCPDR)->size) + regs->scpdr = sci_serial_in(port, SCPDR); if (sci_getreg(port, SEMR)->size) regs->semr = sci_serial_in(port, SEMR); } @@ -3583,6 +3598,10 @@ static void sci_console_restore(struct sci_port *s) struct sci_suspend_regs *regs = &s->suspend_regs; struct uart_port *port = &s->port; + if (sci_getreg(port, SCDL)->size) + sci_serial_out(port, SCDL, regs->scdl); + if (sci_getreg(port, SCCKS)->size) + sci_serial_out(port, SCCKS, regs->sccks); if (sci_getreg(port, SCSMR)->size) sci_serial_out(port, SCSMR, regs->scsmr); if (sci_getreg(port, SCSCR)->size) @@ -3593,6 +3612,12 @@ static void sci_console_restore(struct sci_port *s) sci_serial_out(port, SCSPTR, regs->scsptr); if (sci_getreg(port, SCBRR)->size) sci_serial_out(port, SCBRR, regs->scbrr); + if (sci_getreg(port, HSSRR)->size) + sci_serial_out(port, HSSRR, regs->hssrr); + if (sci_getreg(port, SCPCR)->size) + sci_serial_out(port, SCPCR, regs->scpcr); + if (sci_getreg(port, SCPDR)->size) + sci_serial_out(port, SCPDR, regs->scpdr); if (sci_getreg(port, SEMR)->size) sci_serial_out(port, SEMR, regs->semr); } -- 2.39.5