Re: [PATCH v5 2/2] ufs: mcq: poll OCS after sq cleanup for device management commands

From: Bean Huo

Date: Wed Nov 04 2026 - 19:11:08 EST


On Wed, 2026-11-04 at 18:49 +0900, Kiwoong Kim wrote:
> Signed-off-by: Kiwoong Kim <kwmad.kim@xxxxxxxxxxx>
> ---
>  drivers/ufs/core/ufs-mcq.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>
> diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
> index 8106d55f4041..100295d02c62 100644
> --- a/drivers/ufs/core/ufs-mcq.c
> +++ b/drivers/ufs/core/ufs-mcq.c
> @@ -609,6 +609,24 @@ int ufshcd_mcq_sq_cleanup(struct ufs_hba *hba, int
> task_tag)
>                          __func__, id,
>                          FIELD_GET(SQ_ICU_ERR_CODE_MASK, readl(reg)));
>  
> +       /*
> +        * For device management commands, there is no order guaranteed
> between
> +        * OCS update and CUS update, which is why we need to wait here. SCSI
> +        * commands are excluded because the OCS in their UTRD is not updated
> +        * from the CQE.
> +        */
> +       if (!err && blk_mq_is_reserved_rq(rq)) {
> +               enum utp_ocs ocs;
> +
> +               err = read_poll_timeout(READ_ONCE, ocs,

Bart, 

READ_ONCE() is enough to read OCS, but the lock also is to make sure
ufshcd_compl_one_cqe() has finished? the window is very small, and the lock
only costs something on this error handling path. 

tell me if I missed something.

Kind regards,
Bean