From: Jorge Ramirez-Ortiz via U-Boot <u-boot@lists.u-boot-project.org>
To: jorge.ramirez@oss.qualcomm.com, neil.armstrong@linaro.org,
trini@konsulko.com, jens.wiklander@linaro.org,
ilias.apalodimas@linaro.org, peng.fan@nxp.com,
jh80.chung@samsung.com, bhupesh.linux@gmail.com,
n-francis@ti.com, marek.vasut+renesas@mailbox.org,
igor.belwon@mentallysanemainliners.org, shawn.lin@rock-chips.com,
alchark@gmail.com, tuyen.dang.xa@renesas.com,
yoshihiro.shimoda.uh@renesas.com, padmarao.begari@amd.com,
jstephan@baylibre.com, hayashi.kunihiko@socionext.com,
macpaul.lin@mediatek.com, venkyada@qti.qualcomm.com,
j-mcarthur@ti.com, dlechner@baylibre.com, u-boot@lists.denx.de
Subject: [PATCH v3 1/5] ufs: decode string descriptors as UTF-16 big-endian
Date: Thu, 23 Jul 2026 16:38:18 +0200 [thread overview]
Message-ID: <20260723143852.2287208-2-jorge.ramirez@oss.qualcomm.com> (raw)
In-Reply-To: <20260723143852.2287208-1-jorge.ramirez@oss.qualcomm.com>
UFS string descriptors are UTF-16 big-endian (JESD220), but
ufshcd_read_string_desc() fed the raw bytes to utf16_to_utf8(), which reads
host-endian code units, leaving dev_desc->model blank. Byte-swap to host
order before decoding, matching the kernel.
Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez@oss.qualcomm.com>
---
drivers/ufs/ufs-uclass.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/ufs/ufs-uclass.c b/drivers/ufs/ufs-uclass.c
index 6a51f337e47..8f120fbbee8 100644
--- a/drivers/ufs/ufs-uclass.c
+++ b/drivers/ufs/ufs-uclass.c
@@ -1533,6 +1533,19 @@ static inline void ufshcd_remove_non_printable(uint8_t *val)
*val = ' ';
}
+static inline void ufshcd_str_desc_to_cpu(u8 *desc, u32 size)
+{
+ u16 *p = (u16 *)&desc[QUERY_DESC_HDR_SIZE];
+ u32 len = desc[QUERY_DESC_LENGTH_OFFSET];
+ u32 i;
+
+ if (len > size)
+ len = size;
+
+ for (i = QUERY_DESC_HDR_SIZE; i + 1 < len; i += 2, p++)
+ *p = be16_to_cpu(*p);
+}
+
/**
* ufshcd_uic_pwr_ctrl - executes UIC commands (which affects the link power
* state) and waits for it to take effect.
@@ -1765,6 +1778,8 @@ static int ufshcd_read_string_desc(struct ufs_hba *hba, int desc_index,
goto out;
}
+ ufshcd_str_desc_to_cpu(buf, size);
+
/*
* the descriptor contains string in UTF16 format
* we need to convert to utf-8 so it can be displayed
--
2.54.0
next prev parent reply other threads:[~2026-07-23 14:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 14:38 [PATCH v3 0/5] ufs: rpmb: route OP-TEE RPMB secure storage over UFS Jorge Ramirez-Ortiz via U-Boot
2026-07-23 14:38 ` Jorge Ramirez-Ortiz via U-Boot [this message]
2026-07-29 21:51 ` [PATCH v3 1/5] ufs: decode string descriptors as UTF-16 big-endian David Lechner
2026-07-23 14:38 ` [PATCH v3 2/5] ufs: add RPMB transport over SCSI SECURITY PROTOCOL Jorge Ramirez-Ortiz via U-Boot
2026-07-29 22:27 ` David Lechner
2026-07-23 14:38 ` [PATCH v3 3/5] ufs: derive the per-region RPMB CID and size for OP-TEE Jorge Ramirez-Ortiz via U-Boot
2026-07-29 22:40 ` David Lechner
2026-07-23 14:38 ` [PATCH v3 4/5] optee: rename rpmb.c to rpmb_emmc.c Jorge Ramirez-Ortiz via U-Boot
2026-07-23 14:38 ` [PATCH v3 5/5] optee: implement the RPMB subsystem interface for UFS Jorge Ramirez-Ortiz via U-Boot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260723143852.2287208-2-jorge.ramirez@oss.qualcomm.com \
--to=u-boot@lists.u-boot-project.org \
--cc=alchark@gmail.com \
--cc=bhupesh.linux@gmail.com \
--cc=dlechner@baylibre.com \
--cc=hayashi.kunihiko@socionext.com \
--cc=igor.belwon@mentallysanemainliners.org \
--cc=ilias.apalodimas@linaro.org \
--cc=j-mcarthur@ti.com \
--cc=jens.wiklander@linaro.org \
--cc=jh80.chung@samsung.com \
--cc=jorge.ramirez@oss.qualcomm.com \
--cc=jstephan@baylibre.com \
--cc=macpaul.lin@mediatek.com \
--cc=marek.vasut+renesas@mailbox.org \
--cc=n-francis@ti.com \
--cc=neil.armstrong@linaro.org \
--cc=padmarao.begari@amd.com \
--cc=peng.fan@nxp.com \
--cc=shawn.lin@rock-chips.com \
--cc=trini@konsulko.com \
--cc=tuyen.dang.xa@renesas.com \
--cc=u-boot@lists.denx.de \
--cc=venkyada@qti.qualcomm.com \
--cc=yoshihiro.shimoda.uh@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox