* Re: [PATCH] scsi: ufs: core: Use ufshcd_query_attr_retry() for RTC update
2026-11-16 13:39 [PATCH] scsi: ufs: core: Use ufshcd_query_attr_retry() for RTC update Enric Balletbo i Serra
@ 2026-11-16 13:51 ` sashiko-bot
2026-11-16 14:38 ` Larisa Ileana Grigore
2026-11-16 22:27 ` Bean Huo
2 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-16 13:51 UTC (permalink / raw)
To: Enric Balletbo i Serra; +Cc: linux-scsi
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] scsi: ufs: core: ufshcd_query_attr_retry() still logs dev_err on
transient error
--
commit 9b18c975bcb0273e30706599adab61914367c5c2
Author: Enric Balletbo i Serra <eballetb@redhat.com>
scsi: ufs: core: Use ufshcd_query_attr_retry() for RTC update
This commit switches ufshcd_update_rtc() from ufshcd_query_attr() to
ufshcd_query_attr_retry() when writing QUERY_ATTR_IDN_SECONDS_PASSED.
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 3c28bc67c65f1..1cd32b7cc9674 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -8821,8 +8821,8 @@ static void ufshcd_update_rtc(struct ufs_hba *hba)
> if (ufshcd_rpm_get_if_active(hba) <= 0)
> return;
>
> - err = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_WRITE_ATTR, QUERY_ATTR_IDN_SECONDS_PASSED,
> - 0, 0, &val);
> + err = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR,
> + QUERY_ATTR_IDN_SECONDS_PASSED, 0, 0, &val);
[Severity: Low]
Does ufshcd_query_attr_retry() avoid escalating to dev_err() on transient
failures as described in the commit message?
ufshcd_query_attr_retry() calls ufshcd_query_attr() on every attempt, and
ufshcd_query_attr() logs dev_err() unconditionally on any error other than
-EOPNOTSUPP:
drivers/ufs/core/ufshcd.c:ufshcd_query_attr() {
...
err = ufshcd_exec_dev_cmd(hba, DEV_CMD_TYPE_QUERY, dev_cmd_timeout);
if (err == -EOPNOTSUPP)
goto out_unlock;
if (err) {
dev_err(hba->dev, "%s: opcode 0x%.2x for idn %d failed, index %d, err = %d\n",
__func__, opcode, idn, index, err);
goto out_unlock;
}
...
}
Retrying allows a transient OCS_INVALID_COMMAND_STATUS failure to recover
and avoids the "ufshcd_update_rtc: Failed to update rtc 15" message, but
"ufshcd_query_attr: opcode 0x04 for idn 15 failed, index 0, err = 15" is
still logged at dev_err level on the initial failed attempt.
Also, callers in ufs-hwmon.c, ufs-sysfs.c, and ufs-txeq.c call
ufshcd_query_attr() directly, so ufshcd_update_rtc() is not the only direct
caller in drivers/ufs/core/.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-ufs-rtc-query-retry-v1-1-4de69b175e8d@redhat.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] scsi: ufs: core: Use ufshcd_query_attr_retry() for RTC update
2026-11-16 13:39 [PATCH] scsi: ufs: core: Use ufshcd_query_attr_retry() for RTC update Enric Balletbo i Serra
2026-11-16 13:51 ` sashiko-bot
@ 2026-11-16 14:38 ` Larisa Ileana Grigore
2026-11-16 22:27 ` Bean Huo
2 siblings, 0 replies; 5+ messages in thread
From: Larisa Ileana Grigore @ 2026-11-16 14:38 UTC (permalink / raw)
To: Enric Balletbo i Serra, Alim Akhtar, Bart Van Assche, Bean Huo,
Stanley Jhu, James E.J. Bottomley, Martin K. Petersen, Mike Bi,
Avri Altman, Thomas Weißschuh
Cc: Luca Porzio, linux-scsi, linux-kernel, NXP S32 Linux Team,
linux-arm-kernel, Frank Li
On 11/16/2026 3:39 PM, Enric Balletbo i Serra wrote:
> ufshcd_update_rtc() uses ufshcd_query_attr() directly to write the
> bSecondsPassed attribute, making it the only query attribute caller in
> the UFS core that does not use the retry variant. All other callers use
> ufshcd_query_attr_retry(), which retries up to three times on transient
> failures before escalating to dev_err.
>
> This causes spurious error messages during boot on some platforms when
> the write-attribute command hits a transient OCS_INVALID_COMMAND_STATUS
> error:
>
> ufs-s32n7 4ac80000.ufs: ufshcd_query_attr: opcode 0x04 for idn 15 failed, index 0, err = 15
> ufs-s32n7 4ac80000.ufs: ufshcd_update_rtc: Failed to update rtc 15
>
> Switch to ufshcd_query_attr_retry() to handle transient failures
> gracefully, consistent with every other attribute query in the driver.
>
> Fixes: 6bf999e0eb41 ("scsi: ufs: core: Add UFS RTC support")
> Signed-off-by: Enric Balletbo i Serra <eballetb@redhat.com>
> ---
> drivers/ufs/core/ufshcd.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 3c28bc67c65f..1cd32b7cc967 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -8821,8 +8821,8 @@ static void ufshcd_update_rtc(struct ufs_hba *hba)
> if (ufshcd_rpm_get_if_active(hba) <= 0)
> return;
>
> - err = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_WRITE_ATTR, QUERY_ATTR_IDN_SECONDS_PASSED,
> - 0, 0, &val);
> + err = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR,
> + QUERY_ATTR_IDN_SECONDS_PASSED, 0, 0, &val);
> ufshcd_rpm_put(hba);
>
> if (err)
>
> ---
> base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
> change-id: 20261116-ufs-rtc-query-retry-3f27084f878f
>
> Best regards,
Hello Enric,
Regarding the OCS_INVALID_COMMAND_STATUS seen on S32N79RDB, this
behavior is related to known errata that will be documented in the
future. I plan to submit a separate patch series to address these errata.
For this issue, OCS values 0xf and 0x3 are expected.
Best regards,
Larisa
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] scsi: ufs: core: Use ufshcd_query_attr_retry() for RTC update
2026-11-16 13:39 [PATCH] scsi: ufs: core: Use ufshcd_query_attr_retry() for RTC update Enric Balletbo i Serra
2026-11-16 13:51 ` sashiko-bot
2026-11-16 14:38 ` Larisa Ileana Grigore
@ 2026-11-16 22:27 ` Bean Huo
2026-11-17 7:49 ` Enric Balletbo i Serra
2 siblings, 1 reply; 5+ messages in thread
From: Bean Huo @ 2026-11-16 22:27 UTC (permalink / raw)
To: Enric Balletbo i Serra, Alim Akhtar, Bart Van Assche, Bean Huo,
Stanley Jhu, James E.J. Bottomley, Martin K. Petersen, Mike Bi,
Avri Altman, Thomas Weißschuh
Cc: Luca Porzio, linux-scsi, linux-kernel, NXP S32 Linux Team,
linux-arm-kernel, Frank Li, Larisa Grigore
Thanks for the patch. A few comments:
On Mon, 2026-11-16 at 14:39 +0100, Enric Balletbo i Serra wrote:
> ufshcd_update_rtc() uses ufshcd_query_attr() directly to write the
> bSecondsPassed attribute, making it the only query attribute caller in
> the UFS core that does not use the retry variant. All other callers use
> ufshcd_query_attr_retry(), which retries up to three times on transient
> failures before escalating to dev_err.
>
> This causes spurious error messages during boot on some platforms when
> the write-attribute command hits a transient OCS_INVALID_COMMAND_STATUS
> error:
>
> ufs-s32n7 4ac80000.ufs: ufshcd_query_attr: opcode 0x04 for idn 15 failed,
> index 0, err = 15
this is printed by ufshcd_query_attr() itself at dev_err level, so it will still
show up with this patch. Could you share the log with the patch applied?
and err = 15 is OCS_INVALID_COMMAND_STATUS, the value the driver puts in the
UTRD before sending. So the request was completed but the host controller did
not update OCS. This looks like a host side problem? not a transient device
failure, and a retry here would only hide it. Is this SDB or MCQ? Does it only
happen on the first RTC update after probe?
> ufs-s32n7 4ac80000.ufs: ufshcd_update_rtc: Failed to update rtc 15
> Switch to ufshcd_query_attr_retry() to handle transient failures
> gracefully, consistent with every other attribute query in the driver.
>
ufshcd_update_rtc() is not the only caller without retry. ufs-sysfs.c, ufs-
hwmon.c and ufs-txeq.c also call ufshcd_query_attr() directly, so the commit
message is wrong.
> Fixes: 6bf999e0eb41 ("scsi: ufs: core: Add UFS RTC support")
> Signed-off-by: Enric Balletbo i Serra <eballetb@redhat.com>
I would like to understand the root cause first.
Kind regards,
Bean
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] scsi: ufs: core: Use ufshcd_query_attr_retry() for RTC update
2026-11-16 22:27 ` Bean Huo
@ 2026-11-17 7:49 ` Enric Balletbo i Serra
0 siblings, 0 replies; 5+ messages in thread
From: Enric Balletbo i Serra @ 2026-11-17 7:49 UTC (permalink / raw)
To: Bean Huo
Cc: Alim Akhtar, Bart Van Assche, Bean Huo, Stanley Jhu,
James E.J. Bottomley, Martin K. Petersen, Mike Bi, Avri Altman,
Thomas Weißschuh, Luca Porzio, linux-scsi, linux-kernel,
NXP S32 Linux Team, linux-arm-kernel, Frank Li, Larisa Grigore
Hi,
On Mon, Nov 16, 2026 at 11:28 PM Bean Huo <beanhuo@iokpp.de> wrote:
>
> Thanks for the patch. A few comments:
>
> On Mon, 2026-11-16 at 14:39 +0100, Enric Balletbo i Serra wrote:
> > ufshcd_update_rtc() uses ufshcd_query_attr() directly to write the
> > bSecondsPassed attribute, making it the only query attribute caller in
> > the UFS core that does not use the retry variant. All other callers use
> > ufshcd_query_attr_retry(), which retries up to three times on transient
> > failures before escalating to dev_err.
> >
> > This causes spurious error messages during boot on some platforms when
> > the write-attribute command hits a transient OCS_INVALID_COMMAND_STATUS
> > error:
> >
> > ufs-s32n7 4ac80000.ufs: ufshcd_query_attr: opcode 0x04 for idn 15 failed,
> > index 0, err = 15
>
> this is printed by ufshcd_query_attr() itself at dev_err level, so it will still
> show up with this patch. Could you share the log with the patch applied?
>
I assume I got confused because after applying the patch both messages
disappeared, but what you mention, and sashiko also pointed, is right,
from code I should have still see the ufshcd_query_attr: opcode 0x04
... message
The fact that I didn't see those messages after applying the patch
likely means it showed a case where the first attempt succeeded. I
didn't perform a lot of boots.
> and err = 15 is OCS_INVALID_COMMAND_STATUS, the value the driver puts in the
> UTRD before sending. So the request was completed but the host controller did
> not update OCS. This looks like a host side problem? not a transient device
> failure, and a retry here would only hide it. Is this SDB or MCQ? Does it only
> happen on the first RTC update after probe?
>
Answering your last question, yes, it seems to happen on the first RTC
update after probe.
Larisa mentioned there is a known errata that will be documented in
the future that could be related. We should probably wait for that
errata to better understand the problem.
>
> > ufs-s32n7 4ac80000.ufs: ufshcd_update_rtc: Failed to update rtc 15
> > Switch to ufshcd_query_attr_retry() to handle transient failures
> > gracefully, consistent with every other attribute query in the driver.
> >
>
> ufshcd_update_rtc() is not the only caller without retry. ufs-sysfs.c, ufs-
> hwmon.c and ufs-txeq.c also call ufshcd_query_attr() directly, so the commit
> message is wrong.
>
Right, I used the wrong wording here and made the mistake of only
looking at core/ufshcd.c, not the full core files.c not the full core
files.
>
> > Fixes: 6bf999e0eb41 ("scsi: ufs: core: Add UFS RTC support")
>
> > Signed-off-by: Enric Balletbo i Serra <eballetb@redhat.com>
>
>
> I would like to understand the root cause first.
>
Agree, let's wait for Larisa patches.
Thanks,
Enric
> Kind regards,
> Bean
>
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread