]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
ufs: Fix wrong bitfield usage for Data Direction in Transfer Request
authorKunihiko Hayashi <hayashi.kunihiko@socionext.com>
Fri, 10 Oct 2025 02:45:57 +0000 (11:45 +0900)
committerNeil Armstrong <neil.armstrong@linaro.org>
Tue, 28 Oct 2025 16:10:46 +0000 (17:10 +0100)
Commit d232d7fdbf6f ("ufs: core: sync ufshci.h with Linux v6.12") updated
the Data Direction values from bitmask values to simple enumerations.

Before:
    enum {
        UTP_NO_DATA_TRANSFER    = 0x00000000,
        UTP_HOST_TO_DEVICE      = 0x02000000,
        UTP_DEVICE_TO_HOST      = 0x04000000,
    };

Updated:
    enum utp_data_direction {
        UTP_NO_DATA_TRANSFER    = 0,
        UTP_HOST_TO_DEVICE      = 1,
        UTP_DEVICE_TO_HOST      = 2,
    };

However, the U-Boot code still uses these values directly without shifting,
and resulting in wrong bitfield placement in the Transfer Request
Descriptor.

This fixes the issue by applying the necessary shift to align the value.

Fixes: d232d7fdbf6f ("ufs: core: sync ufshci.h with Linux v6.12")
Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patch.msgid.link/20251010024557.673787-1-hayashi.kunihiko@socionext.com
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
drivers/ufs/ufs.c
drivers/ufs/ufs.h

index 57e6e8c013bdce8c23b40783d75fbb869629d6e3..1d52ff64a4a3169cd8bd1e449bcfde2a8cb39c55 100644 (file)
@@ -761,7 +761,8 @@ static void ufshcd_prepare_req_desc_hdr(struct ufs_hba *hba,
                *upiu_flags = UPIU_CMD_FLAGS_NONE;
        }
 
-       dword_0 = data_direction | (0x1 << UPIU_COMMAND_TYPE_OFFSET);
+       dword_0 = (data_direction << UPIU_DATA_DIRECTION_OFFSET)
+               | (0x1 << UPIU_COMMAND_TYPE_OFFSET);
 
        /* Enable Interrupt for command */
        dword_0 |= UTP_REQ_DESC_INT_CMD;
index 0337ac5996bb1319bac46a1208bd6d8237af5161..8dfa4eaa3be28176b7be247e13d7dfd3176da21d 100644 (file)
@@ -77,6 +77,9 @@ enum {
 /* UTP Transfer Request Command Offset */
 #define UPIU_COMMAND_TYPE_OFFSET       28
 
+/* UTP Transfer Request Data Direction Offset */
+#define UPIU_DATA_DIRECTION_OFFSET     25
+
 /* Offset of the response code in the UPIU header */
 #define UPIU_RSP_CODE_OFFSET           8