* [PULL 0/2] ufs queue
@ 2026-07-01 5:19 Jeuk Kim
2026-07-01 5:19 ` [PULL 1/2] hw/ufs: Emulate DME_GET/SET for PA layer attributes Jeuk Kim
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jeuk Kim @ 2026-07-01 5:19 UTC (permalink / raw)
To: qemu-devel, stefanha; +Cc: kwolf, hreitz, qemu-block, jeuk20.kim, j-young.choi
From: Jeuk Kim <jeuk20.kim@samsung.com>
The following changes since commit 30e8a06b64aa58a3990ba39cb5d09531e7d265e0:
Merge tag 'net-pull-request' of https://github.com/jasowang/qemu into staging (2026-06-29 17:41:42 +0200)
are available in the Git repository at:
https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20260701
for you to fetch changes up to 20c03709b353d6c985bfa3174c4563d57ff47275:
hw/ufs: Populate cqe.task_tag for UFSHCI 4.1 tag decoding (2026-07-01 10:19:10 +0900)
----------------------------------------------------------------
ufs queue
- Add minimal PA-layer DME command emulation needed by newer Linux UFS probe.
- Populate UFSHCI 4.1 MCQ CQE tag fields used by newer Linux completion handling.
----------------------------------------------------------------
Jeuk Kim (2):
hw/ufs: Emulate DME_GET/SET for PA layer attributes
hw/ufs: Populate cqe.task_tag for UFSHCI 4.1 tag decoding
hw/ufs/ufs.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
include/block/ufs.h | 18 +++++++++++++++++-
2 files changed, 63 insertions(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 7+ messages in thread* [PULL 1/2] hw/ufs: Emulate DME_GET/SET for PA layer attributes
2026-07-01 5:19 [PULL 0/2] ufs queue Jeuk Kim
@ 2026-07-01 5:19 ` Jeuk Kim
2026-07-01 5:19 ` [PULL 2/2] hw/ufs: Populate cqe.task_tag for UFSHCI 4.1 tag decoding Jeuk Kim
2026-07-02 10:31 ` [PULL 0/2] ufs queue Stefan Hajnoczi
2 siblings, 0 replies; 7+ messages in thread
From: Jeuk Kim @ 2026-07-01 5:19 UTC (permalink / raw)
To: qemu-devel, stefanha; +Cc: kwolf, hreitz, qemu-block, jeuk20.kim, j-young.choi
From: Jeuk Kim <jeuk20.kim@samsung.com>
After DME_LINK_STARTUP a UFSHCI host typically negotiates the link power
mode: it reads PA layer attributes (connected RX/TX data lanes, max RX
HS/PWM gears) via DME_GET and then issues DME_SET(PA_PWRMODE), waiting for
the UIC power-mode-change completion (IS.UPMS / HCS.UPMCRS). The device
only handled DME_LINK_STARTUP and DME_HIBER_{ENTER,EXIT} and returned
FAILURE for every other DME command, so a host that performs power-mode
change could never complete it.
Return canned PA attribute values (1 lane, HS-G4, FAST_MODE) on
DME_GET/PEER_GET and acknowledge DME_SET/PEER_SET. For DME_SET(PA_PWRMODE)
also raise IS.UPMS and set HCS.UPMCRS=PWR_LOCAL so the power-mode change
completes. The emulated link has no PHY, so no state is persisted.
For example, the Linux ufshcd driver reads these attributes during probe
and otherwise aborts with "invalid connected lanes value".
Signed-off-by: Jeuk Kim <jeuk20.kim@samsung.com>
---
hw/ufs/ufs.c | 40 ++++++++++++++++++++++++++++++++++++++++
include/block/ufs.h | 12 ++++++++++++
2 files changed, 52 insertions(+)
diff --git a/hw/ufs/ufs.c b/hw/ufs/ufs.c
index 35c2444385..ee7eba6793 100644
--- a/hw/ufs/ufs.c
+++ b/hw/ufs/ufs.c
@@ -363,8 +363,32 @@ static void ufs_process_db(UfsHc *u, uint32_t val)
qemu_bh_schedule(u->doorbell_bh);
}
+/*
+ * Return canned PA layer attribute values. The emulated link has no PHY,
+ * so these are purely declarative: a single lane in HS-Gear 4, FAST_MODE.
+ */
+static uint32_t ufs_uic_dme_get_value(uint16_t attr_id)
+{
+ switch (attr_id) {
+ case UFS_ATTR_PA_AVAILTXDATALANES:
+ case UFS_ATTR_PA_AVAILRXDATALANES:
+ case UFS_ATTR_PA_CONNECTEDTXDATALANES:
+ case UFS_ATTR_PA_CONNECTEDRXDATALANES:
+ return 1;
+ case UFS_ATTR_PA_MAXRXHSGEAR:
+ case UFS_ATTR_PA_MAXRXPWMGEAR:
+ return 4;
+ case UFS_ATTR_PA_PWRMODE:
+ return (1 << 4) | 1;
+ default:
+ return 0;
+ }
+}
+
static void ufs_process_uiccmd(UfsHc *u, uint32_t val)
{
+ uint16_t attr_id;
+
trace_ufs_process_uiccmd(val, u->reg.ucmdarg1, u->reg.ucmdarg2,
u->reg.ucmdarg3);
/*
@@ -378,6 +402,22 @@ static void ufs_process_uiccmd(UfsHc *u, uint32_t val)
u->reg.hcs = FIELD_DP32(u->reg.hcs, HCS, UTMRLRDY, 1);
u->reg.ucmdarg2 = UFS_UIC_CMD_RESULT_SUCCESS;
break;
+ case UFS_UIC_CMD_DME_GET:
+ case UFS_UIC_CMD_DME_PEER_GET:
+ attr_id = (u->reg.ucmdarg1 >> 16) & 0xFFFF;
+ u->reg.ucmdarg3 = ufs_uic_dme_get_value(attr_id);
+ u->reg.ucmdarg2 = UFS_UIC_CMD_RESULT_SUCCESS;
+ break;
+ case UFS_UIC_CMD_DME_SET:
+ case UFS_UIC_CMD_DME_PEER_SET:
+ attr_id = (u->reg.ucmdarg1 >> 16) & 0xFFFF;
+ u->reg.ucmdarg2 = UFS_UIC_CMD_RESULT_SUCCESS;
+ /* DME_SET(PA_PWRMODE) is a power-mode-change trigger. */
+ if (val == UFS_UIC_CMD_DME_SET && attr_id == UFS_ATTR_PA_PWRMODE) {
+ u->reg.is = FIELD_DP32(u->reg.is, IS, UPMS, 1);
+ u->reg.hcs = FIELD_DP32(u->reg.hcs, HCS, UPMCRS, UFS_PWR_LOCAL);
+ }
+ break;
/*
* TODO: Revisit after PM implementation
* Power Management is not supported in current QEMU-UFS,
diff --git a/include/block/ufs.h b/include/block/ufs.h
index 6dd91181e5..66e8f35c0e 100644
--- a/include/block/ufs.h
+++ b/include/block/ufs.h
@@ -628,6 +628,18 @@ enum {
#define UFS_MASK_UIC_COMMAND_RESULT 0xFF
+/*
+ * MIPI UniPro PHY Adapter (PA) layer attribute IDs accessed via
+ * DME_GET / DME_SET / DME_PEER_{GET,SET} UIC commands.
+ */
+#define UFS_ATTR_PA_AVAILTXDATALANES 0x1520
+#define UFS_ATTR_PA_AVAILRXDATALANES 0x1540
+#define UFS_ATTR_PA_CONNECTEDTXDATALANES 0x1561
+#define UFS_ATTR_PA_PWRMODE 0x1571
+#define UFS_ATTR_PA_CONNECTEDRXDATALANES 0x1581
+#define UFS_ATTR_PA_MAXRXPWMGEAR 0x1586
+#define UFS_ATTR_PA_MAXRXHSGEAR 0x1587
+
/*
* Request Descriptor Definitions
*/
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PULL 2/2] hw/ufs: Populate cqe.task_tag for UFSHCI 4.1 tag decoding
2026-07-01 5:19 [PULL 0/2] ufs queue Jeuk Kim
2026-07-01 5:19 ` [PULL 1/2] hw/ufs: Emulate DME_GET/SET for PA layer attributes Jeuk Kim
@ 2026-07-01 5:19 ` Jeuk Kim
2026-07-02 10:31 ` [PULL 0/2] ufs queue Stefan Hajnoczi
2 siblings, 0 replies; 7+ messages in thread
From: Jeuk Kim @ 2026-07-01 5:19 UTC (permalink / raw)
To: qemu-devel, stefanha; +Cc: kwolf, hreitz, qemu-block, jeuk20.kim, j-young.choi
From: Jeuk Kim <jeuk20.kim@samsung.com>
In UFSHCI 4.1 the MCQ completion queue entry carries the request tag in
the cqe.task_tag field (DW5), whereas 4.0 hosts derive it from the UTP
command descriptor base address. The device reports version 4.1 in the VER
register but left task_tag/lun zero in the completion path, so a
4.1-compliant host reads tag 0 for every completion and cannot match it to
the outstanding request.
Add the task_tag/lun/iid fields to UfsCqEntry per the UFSHCI 4.1 CQE
layout and populate them from the request UPIU header.
For example, the Linux ufshcd_mcq_get_tag() uses cqe.task_tag for
version >= 4.1, so without this SCSI commands hung (e.g. INQUIRY to the
device W-LUN) while device-management commands still completed.
Signed-off-by: Jeuk Kim <jeuk20.kim@samsung.com>
---
hw/ufs/ufs.c | 6 ++++++
include/block/ufs.h | 6 +++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/hw/ufs/ufs.c b/hw/ufs/ufs.c
index ee7eba6793..464fd465b3 100644
--- a/hw/ufs/ufs.c
+++ b/hw/ufs/ufs.c
@@ -520,6 +520,12 @@ static void ufs_mcq_process_cq(void *opaque)
req->cqe.prdt_off = cpu_to_le16(prdt_off);
req->cqe.status = status;
req->cqe.error = 0;
+ /*
+ * From UFSHCI 4.1 the host derives the request tag from cqe.task_tag
+ * rather than decoding it from utp_addr.
+ */
+ req->cqe.task_tag = req->req_upiu.header.task_tag;
+ req->cqe.lun = req->req_upiu.header.lun;
ret = ufs_addr_write(u, cq->addr + tail, &req->cqe, sizeof(req->cqe));
if (ret) {
diff --git a/include/block/ufs.h b/include/block/ufs.h
index 66e8f35c0e..d19b3c65ef 100644
--- a/include/block/ufs.h
+++ b/include/block/ufs.h
@@ -1333,7 +1333,11 @@ typedef struct QEMU_PACKED UfsCqEntry {
uint8_t status;
uint8_t error;
uint16_t rsvd1;
- uint32_t rsvd2[3];
+ uint8_t task_tag;
+ uint8_t lun;
+ uint8_t iid_ext_iid;
+ uint8_t rsvd2;
+ uint32_t rsvd3[2];
} UfsCqEntry;
static inline void _ufs_check_size(void)
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PULL 0/2] ufs queue
2026-07-01 5:19 [PULL 0/2] ufs queue Jeuk Kim
2026-07-01 5:19 ` [PULL 1/2] hw/ufs: Emulate DME_GET/SET for PA layer attributes Jeuk Kim
2026-07-01 5:19 ` [PULL 2/2] hw/ufs: Populate cqe.task_tag for UFSHCI 4.1 tag decoding Jeuk Kim
@ 2026-07-02 10:31 ` Stefan Hajnoczi
2 siblings, 0 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2026-07-02 10:31 UTC (permalink / raw)
To: Jeuk Kim
Cc: qemu-devel, stefanha, kwolf, hreitz, qemu-block, jeuk20.kim,
j-young.choi
[-- Attachment #1: Type: text/plain, Size: 116 bytes --]
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/11.1 for any user-visible changes.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PULL 0/2] ufs queue
@ 2026-06-12 0:29 Jeuk Kim
2026-06-12 14:38 ` Stefan Hajnoczi
0 siblings, 1 reply; 7+ messages in thread
From: Jeuk Kim @ 2026-06-12 0:29 UTC (permalink / raw)
To: qemu-devel, stefanha
Cc: kwolf, hreitz, farosas, lvivier, pbonzini, qemu-block, jeuk20.kim,
j-young.choi
From: Jeuk Kim <jeuk20.kim@samsung.com>
The following changes since commit ec6a1f43989c6bbf2de1ab84959a70ee35fa1b57:
Merge tag 'linux-user-pull-request' of https://github.com/hdeller/qemu-hppa into staging (2026-06-11 13:22:50 -0400)
are available in the Git repository at:
https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20260612
for you to fetch changes up to 6b1215d82f7cd8a0b562a02a1473aa6714759eed:
tests/qtest: Add UFS HID qtest (2026-06-12 09:21:28 +0900)
----------------------------------------------------------------
ufs queue
- Add Host Initiated Defragmentation (HID) support
----------------------------------------------------------------
Keoseong Park (2):
hw/ufs: Add Host Initiated Defragmentation (HID) support
tests/qtest: Add UFS HID qtest
hw/ufs/lu.c | 16 ++-
hw/ufs/trace-events | 4 +
hw/ufs/ufs.c | 154 +++++++++++++++++++++++++--
hw/ufs/ufs.h | 4 +
include/block/ufs.h | 18 ++++
tests/qtest/ufs-test.c | 275 +++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 463 insertions(+), 8 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PULL 0/2] ufs queue
2026-06-12 0:29 Jeuk Kim
@ 2026-06-12 14:38 ` Stefan Hajnoczi
0 siblings, 0 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2026-06-12 14:38 UTC (permalink / raw)
To: Jeuk Kim
Cc: qemu-devel, stefanha, kwolf, hreitz, farosas, lvivier, pbonzini,
qemu-block, jeuk20.kim, j-young.choi
[-- Attachment #1: Type: text/plain, Size: 116 bytes --]
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/11.1 for any user-visible changes.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PULL 0/2] ufs queue
@ 2024-05-28 6:12 Jeuk Kim
0 siblings, 0 replies; 7+ messages in thread
From: Jeuk Kim @ 2024-05-28 6:12 UTC (permalink / raw)
To: qemu-devel, richard.henderson
Cc: fam, pbonzini, qemu-block, jeuk20.kim, j-young.choi, minwoo.im
From: Jeuk Kim <jeuk20.kim@samsung.com>
The following changes since commit ad10b4badc1dd5b28305f9b9f1168cf0aa3ae946:
Merge tag 'pull-error-2024-05-27' of https://repo.or.cz/qemu/armbru into staging (2024-05-27 06:40:42 -0700)
are available in the Git repository at:
https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20240528
for you to fetch changes up to 71a82d3f0555e65c98df129ce0e38b2aa5681ec0:
hw/ufs: Add support MCQ of UFSHCI 4.0 (2024-05-28 14:42:32 +0900)
----------------------------------------------------------------
Add support MCQ of UFSHCI 4.0
----------------------------------------------------------------
Minwoo Im (2):
hw/ufs: Update MCQ-related fields to block/ufs.h
hw/ufs: Add support MCQ of UFSHCI 4.0
hw/ufs/trace-events | 17 ++
hw/ufs/ufs.c | 475 ++++++++++++++++++++++++++++++++++++++++++++++++++--
hw/ufs/ufs.h | 98 ++++++++++-
include/block/ufs.h | 131 ++++++++++++++-
4 files changed, 699 insertions(+), 22 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-07-02 10:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-01 5:19 [PULL 0/2] ufs queue Jeuk Kim
2026-07-01 5:19 ` [PULL 1/2] hw/ufs: Emulate DME_GET/SET for PA layer attributes Jeuk Kim
2026-07-01 5:19 ` [PULL 2/2] hw/ufs: Populate cqe.task_tag for UFSHCI 4.1 tag decoding Jeuk Kim
2026-07-02 10:31 ` [PULL 0/2] ufs queue Stefan Hajnoczi
-- strict thread matches above, loose matches on Subject: below --
2026-06-12 0:29 Jeuk Kim
2026-06-12 14:38 ` Stefan Hajnoczi
2024-05-28 6:12 Jeuk Kim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.