[PATCH v2 2/2] scsi: ufs: exynos: use BIT() for the nexus type tag mask
From: shao.mingyin
Date: Tue Nov 03 2026 - 14:05:40 EST
exynos_ufs_specify_nexus_t_xfer_req() and
exynos_ufs_specify_nexus_t_tm_req() set and clear the task tag bit with
'(1 << tag)'. tag is an int in the range 0..nutrs-1 supplied by the UFS
core, and controllers can have 32 unified task tags, so tag == 31 shifts a
32-bit int into its sign bit, which is undefined behaviour. GCC happens
to wrap the result to 0x80000000 with the kernel's -fno-strict-overflow,
so there is no runtime symptom today, but the expression is not well
defined.
Commit 01aad16c2257 ("scsi: ufs: exynos: Fix programming of
HCI_UTRL_NEXUS_TYPE") fixed the same pattern in exynos_ufs_post_link()
with BIT() and noted that the UTMRL access should be changed as well; the
four remaining mask computations were missed. Use BIT(tag) there too.
Fixes: 55f4b1f73631 ("scsi: ufs: ufs-exynos: Add UFS host support for Exynos SoCs")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
---
v2: rebased onto v7.4-rc1 (for-next); no code changes.
drivers/ufs/host/ufs-exynos.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
index 3bcbc9ebbb28..ee47958253bb 100644
--- a/drivers/ufs/host/ufs-exynos.c
+++ b/drivers/ufs/host/ufs-exynos.c
@@ -997,9 +997,9 @@ static void exynos_ufs_specify_nexus_t_xfer_req(struct ufs_hba *hba,
type = hci_readl(ufs, HCI_UTRL_NEXUS_TYPE);
if (is_scsi_cmd)
- hci_writel(ufs, type | (1 << tag), HCI_UTRL_NEXUS_TYPE);
+ hci_writel(ufs, type | BIT(tag), HCI_UTRL_NEXUS_TYPE);
else
- hci_writel(ufs, type & ~(1 << tag), HCI_UTRL_NEXUS_TYPE);
+ hci_writel(ufs, type & ~BIT(tag), HCI_UTRL_NEXUS_TYPE);
}
static void exynos_ufs_specify_nexus_t_tm_req(struct ufs_hba *hba,
@@ -1013,13 +1013,13 @@ static void exynos_ufs_specify_nexus_t_tm_req(struct ufs_hba *hba,
switch (func) {
case UFS_ABORT_TASK:
case UFS_QUERY_TASK:
- hci_writel(ufs, type | (1 << tag), HCI_UTMRL_NEXUS_TYPE);
+ hci_writel(ufs, type | BIT(tag), HCI_UTMRL_NEXUS_TYPE);
break;
case UFS_ABORT_TASK_SET:
case UFS_CLEAR_TASK_SET:
case UFS_LOGICAL_RESET:
case UFS_QUERY_TASK_SET:
- hci_writel(ufs, type & ~(1 << tag), HCI_UTMRL_NEXUS_TYPE);
+ hci_writel(ufs, type & ~BIT(tag), HCI_UTMRL_NEXUS_TYPE);
break;
}
}