lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251025160905.3857885-136-sashal@kernel.org>
Date: Sat, 25 Oct 2025 11:56:07 -0400
From: Sasha Levin <sashal@...nel.org>
To: patches@...ts.linux.dev,
	stable@...r.kernel.org
Cc: Peter Wang <peter.wang@...iatek.com>,
	"Martin K. Petersen" <martin.petersen@...cle.com>,
	Sasha Levin <sashal@...nel.org>,
	matthias.bgg@...il.com,
	angelogioacchino.delregno@...labora.com,
	linux-scsi@...r.kernel.org,
	linux-mediatek@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org
Subject: [PATCH AUTOSEL 6.17-6.1] scsi: ufs: host: mediatek: Change reset sequence for improved stability

From: Peter Wang <peter.wang@...iatek.com>

[ Upstream commit 878ed88c50bfb14d972dd3b86a1c8188c58de4e5 ]

Modify the reset sequence to ensure that the device reset pin is set low
before the host is disabled. This change enhances the stability of the
reset process by ensuring the correct order of operations.

Signed-off-by: Peter Wang <peter.wang@...iatek.com>
Link: https://lore.kernel.org/r/20250811131423.3444014-10-peter.wang@mediatek.com
Signed-off-by: Martin K. Petersen <martin.petersen@...cle.com>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---

LLM Generated explanations, may be completely bogus:

YES

- What changed: In `drivers/ufs/host/ufs-mediatek.c:1257`, the reset
  sequence in `ufs_mtk_device_reset()` currently disables the HBA before
  asserting the device reset pin low:
  - Calls `ufshcd_hba_stop(hba)` first (drivers/ufs/host/ufs-
    mediatek.c:1261–1262).
  - Then asserts reset low via `ufs_mtk_device_reset_ctrl(0, res)`
    (drivers/ufs/host/ufs-mediatek.c:1264).
  - Holds low for ≥10µs (drivers/ufs/host/ufs-mediatek.c:1273).
  - Deasserts reset high (drivers/ufs/host/ufs-mediatek.c:1275) and
    waits 10–15ms for device settle (drivers/ufs/host/ufs-
    mediatek.c:1277–1278).
  The new commit swaps the first two steps (assert reset low first, then
`ufshcd_hba_stop(hba)`), explicitly noting “disable hba in middle of
device reset”.

- Why it matters: This is a precise order-of-operations fix to a
  hardware reset sequence. Asserting the device’s reset (RST_n active
  low) before disabling the host controller avoids a race/ordering
  hazard during reset, which can manifest as sporadic reset instability.
  The risk window between asserting low and disabling the HBA is tiny
  (immediately followed by `ufshcd_hba_stop()` and a 10–15µs hold), and
  the device is already in reset during that window.

- Consistency within the driver: The driver already asserts reset
  independently of HBA disable in other flows, e.g., on suspend when the
  link is off it calls `ufs_mtk_device_reset_ctrl(0, res)` without a
  preceding `ufshcd_hba_stop()` (drivers/ufs/host/ufs-
  mediatek.c:1445–1449). The new ordering in `ufs_mtk_device_reset()`
  makes the device-reset behavior consistent within the driver.

- Scope and risk:
  - Change is small and contained to a single function
    (`ufs_mtk_device_reset()`), no API or structural changes.
  - No new features; it purely reorders two existing calls and updates a
    comment.
  - The function is invoked through the variant op hook
    `vops->device_reset` (drivers/ufs/host/ufs-mediatek.c:1792–1803), so
    the behavior change is localized to Mediatek platforms only.
  - `ufshcd_hba_stop()` (drivers/ufs/core/ufshcd.c:4842–4854) simply
    disables the controller and waits for it to quiesce; performing it
    after the device is already in reset is benign and avoids mid-reset
    interactions.

- User impact: Improves reset stability on Mediatek UFS hosts, which
  affects error recovery and some power management transitions (device
  reset is used by `ufshcd_device_reset()` in error handling;
  drivers/ufs/core/ufshcd.c:726–742). This is a real-world reliability
  fix rather than a feature.

- Stable criteria:
  - Fixes a practical bug (unstable/fragile reset behavior) that can
    affect users.
  - Minimal, self-contained change with low regression risk.
  - No architectural churn; confined to UFS Mediatek host driver.
  - Although the commit message lacks “Fixes:”/“Cc: stable”, the change
    meets stable rules as a targeted reliability fix in a vendor driver.

Given the above, this is a good candidate for backporting to stable
trees that ship the Mediatek UFS host driver.

 drivers/ufs/host/ufs-mediatek.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index ada21360aa270..82160da8ec71b 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -1503,11 +1503,11 @@ static int ufs_mtk_device_reset(struct ufs_hba *hba)
 {
 	struct arm_smccc_res res;
 
-	/* disable hba before device reset */
-	ufshcd_hba_stop(hba);
-
 	ufs_mtk_device_reset_ctrl(0, res);
 
+	/* disable hba in middle of device reset */
+	ufshcd_hba_stop(hba);
+
 	/*
 	 * The reset signal is active low. UFS devices shall detect
 	 * more than or equal to 1us of positive or negative RST_n
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ