* [PATCH v6] scsi: ufs: Change the error check sequence for auto hibern8
[not found] <CGME20261027110813epcas2p4011de6cde600db5c995d3a3e45b056fb@epcas2p4.samsung.com>
@ 2026-10-27 11:03 ` HOYOUNG SEO
2026-10-27 18:12 ` Bean Huo
2026-10-28 4:09 ` Bart Van Assche
0 siblings, 2 replies; 3+ messages in thread
From: HOYOUNG SEO @ 2026-10-27 11:03 UTC (permalink / raw)
To: linux-scsi, linux-kernel, alim.akhtar, avri.altman, jejb,
martin.petersen, bvanassche, kwangwon.min, kwmad.kim, cpgs,
h10.kim
Cc: HOYOUNG SEO, stable, Stanley Jhu
Auto-hibern8 enter and exit are performed by the host controller without
a UIC command, and the auto-hibern8 idle timer only runs while no UIC
command is outstanding. An auto-hibern8 error (IS.UHES or IS.UHXS) is
therefore usually reported while hba->active_uic_cmd is NULL.
Since commit fcd8b0450a9a ("scsi: ufs: core: Make ufshcd_uic_cmd_compl()
easier to analyze"), ufshcd_uic_cmd_compl() returns early when
hba->active_uic_cmd is NULL, before ufshcd_is_auto_hibern8_error() is
called. Such auto-hibern8 errors are no longer recorded in hba->errors,
so ufshcd_check_errors() is not called for them and the error handler is
not scheduled.
Check for auto-hibern8 errors before checking for an active UIC command,
as was done before that commit, but keep returning early when there is
no active UIC command so that a NULL cmd is never dereferenced. Only
report the missing UIC command if no auto-hibern8 error was found.
Fixes: fcd8b0450a9a ("scsi: ufs: core: Make ufshcd_uic_cmd_compl() easier to analyze")
Cc: stable@vger.kernel.org # v6.13+
Signed-off-by: HOYOUNG SEO <hy50.seo@samsung.com>
Reviewed-by: Stanley Jhu <stanleyjhu@google.com>
---
Changes in v6:
- Add the missing "Cc: stable@vger.kernel.org" tag next to the Fixes tag
and keep the tags in one block (Bart Van Assche, Stanley Jhu).
- Add Stanley's Reviewed-by. No code change.
Changes in v5:
- Fix the unmatched brace in ufshcd_uic_cmd_compl() that broke the build
in v4 (Stanley Jhu, Sashiko, kernel test robot).
- Use a local bool for the ufshcd_is_auto_hibern8_error() result instead
of testing hba->errors (Bart Van Assche).
- Move the Signed-off-by above the "---" line and Cc stable.
- Link to all previous versions.
Changes in v4:
- Changed patch version
Changes in v3:
- Check auto-hibern8 errors before the NULL check again, so that errors
reported while a non-hibernate UIC command is active are still
detected (Sashiko review).
- Return early when no UIC command is active instead of falling
through, to avoid dereferencing a NULL cmd (Sashiko review).
- Add Fixes tag, reword subject and commit message.
Changes in v2:
- Check UFSHCD_UIC_HIBERN8_MASK for auto-hibern8 only when cmd is NULL.
v1: https://lore.kernel.org/linux-scsi/20261021051951.1687479-1-hy50.seo@samsung.com/
v2: https://lore.kernel.org/linux-scsi/20261022074249.3098100-1-hy50.seo@samsung.com/
v3: https://lore.kernel.org/linux-scsi/20261026051851.1845934-1-hy50.seo@samsung.com/
v4: https://lore.kernel.org/linux-scsi/20261026052632.1848929-1-hy50.seo@samsung.com/
v5: https://lore.kernel.org/linux-scsi/20261027021037.3398180-1-hy50.seo@samsung.com/
drivers/ufs/core/ufshcd.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index d085d394858f..c08278a2e43e 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -5939,18 +5939,26 @@ static irqreturn_t ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status)
{
irqreturn_t retval = IRQ_NONE;
struct uic_command *cmd;
+ bool ah8_err;
guard(spinlock_irqsave)(&hba->host->host_lock);
+
+ /*
+ * Auto-hibern8 is performed without a UIC command, so check for
+ * auto-hibern8 errors before checking for an active UIC command.
+ */
+ ah8_err = ufshcd_is_auto_hibern8_error(hba, intr_status);
+ if (ah8_err)
+ hba->errors |= (UFSHCD_UIC_HIBERN8_MASK & intr_status);
+
cmd = hba->active_uic_cmd;
if (!cmd) {
- dev_err(hba->dev,
- "No active UIC command. Maybe a timeout occurred?\n");
+ if (!ah8_err)
+ dev_err(hba->dev,
+ "No active UIC command. Maybe a timeout occurred?\n");
return retval;
}
- if (ufshcd_is_auto_hibern8_error(hba, intr_status))
- hba->errors |= (UFSHCD_UIC_HIBERN8_MASK & intr_status);
-
if (intr_status & UIC_COMMAND_COMPL) {
/*
* Store the UIC command result in the lowest byte of
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v6] scsi: ufs: Change the error check sequence for auto hibern8
2026-10-27 11:03 ` [PATCH v6] scsi: ufs: Change the error check sequence for auto hibern8 HOYOUNG SEO
@ 2026-10-27 18:12 ` Bean Huo
2026-10-28 4:09 ` Bart Van Assche
1 sibling, 0 replies; 3+ messages in thread
From: Bean Huo @ 2026-10-27 18:12 UTC (permalink / raw)
To: HOYOUNG SEO, linux-scsi, linux-kernel, alim.akhtar, avri.altman,
jejb, martin.petersen, bvanassche, kwangwon.min, kwmad.kim, cpgs,
h10.kim
Cc: stable, Stanley Jhu
On Tue, 2026-10-27 at 20:03 +0900, HOYOUNG SEO wrote:
> Auto-hibern8 enter and exit are performed by the host controller without
> a UIC command, and the auto-hibern8 idle timer only runs while no UIC
> command is outstanding. An auto-hibern8 error (IS.UHES or IS.UHXS) is
> therefore usually reported while hba->active_uic_cmd is NULL.
>
> Since commit fcd8b0450a9a ("scsi: ufs: core: Make ufshcd_uic_cmd_compl()
> easier to analyze"), ufshcd_uic_cmd_compl() returns early when
> hba->active_uic_cmd is NULL, before ufshcd_is_auto_hibern8_error() is
> called. Such auto-hibern8 errors are no longer recorded in hba->errors,
> so ufshcd_check_errors() is not called for them and the error handler is
> not scheduled.
>
> Check for auto-hibern8 errors before checking for an active UIC command,
> as was done before that commit, but keep returning early when there is
> no active UIC command so that a NULL cmd is never dereferenced. Only
> report the missing UIC command if no auto-hibern8 error was found.
>
> Fixes: fcd8b0450a9a ("scsi: ufs: core: Make ufshcd_uic_cmd_compl() easier to
> analyze")
> Cc: stable@vger.kernel.org # v6.13+
> Signed-off-by: HOYOUNG SEO <hy50.seo@samsung.com>
> Reviewed-by: Stanley Jhu <stanleyjhu@google.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v6] scsi: ufs: Change the error check sequence for auto hibern8
2026-10-27 11:03 ` [PATCH v6] scsi: ufs: Change the error check sequence for auto hibern8 HOYOUNG SEO
2026-10-27 18:12 ` Bean Huo
@ 2026-10-28 4:09 ` Bart Van Assche
1 sibling, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2026-10-28 4:09 UTC (permalink / raw)
To: HOYOUNG SEO, linux-scsi, linux-kernel, alim.akhtar, avri.altman,
jejb, martin.petersen, kwangwon.min, kwmad.kim, cpgs, h10.kim
Cc: stable, Stanley Jhu
On 10/27/26 4:03 AM, HOYOUNG SEO wrote:
> Auto-hibern8 enter and exit are performed by the host controller without
> a UIC command, and the auto-hibern8 idle timer only runs while no UIC
> command is outstanding. An auto-hibern8 error (IS.UHES or IS.UHXS) is
> therefore usually reported while hba->active_uic_cmd is NULL.
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-28 4:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20261027110813epcas2p4011de6cde600db5c995d3a3e45b056fb@epcas2p4.samsung.com>
2026-10-27 11:03 ` [PATCH v6] scsi: ufs: Change the error check sequence for auto hibern8 HOYOUNG SEO
2026-10-27 18:12 ` Bean Huo
2026-10-28 4:09 ` Bart Van Assche
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®