* [PULL 0/1] ufs queue
@ 2023-10-30 4:02 Jeuk Kim
2023-10-31 7:50 ` Stefan Hajnoczi
0 siblings, 1 reply; 15+ messages in thread
From: Jeuk Kim @ 2023-10-30 4:02 UTC (permalink / raw)
To: qemu-devel, stefanha; +Cc: jeuk20.kim, pbonzini, fam, qemu-block
From: Jeuk Kim <jeuk20.kim@samsung.com>
The following changes since commit c60be6e3e38cb36dc66129e757ec4b34152232be:
Merge tag 'pull-sp-20231025' of https://gitlab.com/rth7680/qemu into staging (2023-10-27 09:43:53 +0900)
are available in the Git repository at:
https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20231030
for you to fetch changes up to 096434fea13acd19f4ead00cdf9babea8dc7e61e:
hw/ufs: Modify lu.c to share codes with SCSI subsystem (2023-10-30 10:28:04 +0900)
----------------------------------------------------------------
ufs queue:
* Modify lu.c to share codes with SCSI
----------------------------------------------------------------
Jeuk Kim (1):
hw/ufs: Modify lu.c to share codes with SCSI subsystem
hw/ufs/lu.c | 1473 ++++++++----------------------------------------
hw/ufs/trace-events | 25 -
hw/ufs/ufs.c | 202 +------
hw/ufs/ufs.h | 36 +-
include/block/ufs.h | 2 +-
tests/qtest/ufs-test.c | 37 +-
6 files changed, 315 insertions(+), 1460 deletions(-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PULL 0/1] ufs queue
2023-10-30 4:02 Jeuk Kim
@ 2023-10-31 7:50 ` Stefan Hajnoczi
0 siblings, 0 replies; 15+ messages in thread
From: Stefan Hajnoczi @ 2023-10-31 7:50 UTC (permalink / raw)
To: Jeuk Kim; +Cc: qemu-devel, stefanha, jeuk20.kim, pbonzini, fam, qemu-block
[-- Attachment #1: Type: text/plain, Size: 115 bytes --]
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PULL 0/1] ufs queue
@ 2024-04-29 3:25 Jeuk Kim
2024-04-29 13:41 ` Stefan Hajnoczi
2024-05-01 22:15 ` Richard Henderson
0 siblings, 2 replies; 15+ messages in thread
From: Jeuk Kim @ 2024-04-29 3:25 UTC (permalink / raw)
To: qemu-devel, stefanha
Cc: fam, pbonzini, qemu-block, jeuk20.kim, j-young.choi, zheyuma97
From: Jeuk Kim <jeuk20.kim@samsung.com>
The following changes since commit fd87be1dada5672f877e03c2ca8504458292c479:
Merge tag 'accel-20240426' of https://github.com/philmd/qemu into staging (2024-04-26 15:28:13 -0700)
are available in the Git repository at:
https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20240429
for you to fetch changes up to f2c8aeb1afefcda92054c448b21fc59cdd99db30:
hw/ufs: Fix buffer overflow bug (2024-04-29 12:13:35 +0900)
----------------------------------------------------------------
ufs queue
- Fix ufs sanitizer vulnerability
----------------------------------------------------------------
Jeuk Kim (1):
hw/ufs: Fix buffer overflow bug
hw/ufs/ufs.c | 8 ++++++++
1 file changed, 8 insertions(+)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PULL 0/1] ufs queue
2024-04-29 3:25 Jeuk Kim
@ 2024-04-29 13:41 ` Stefan Hajnoczi
2024-04-29 14:02 ` Richard Henderson
2024-05-01 22:15 ` Richard Henderson
1 sibling, 1 reply; 15+ messages in thread
From: Stefan Hajnoczi @ 2024-04-29 13:41 UTC (permalink / raw)
To: Jeuk Kim
Cc: qemu-devel, fam, pbonzini, qemu-block, jeuk20.kim, j-young.choi,
zheyuma97
[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]
On Mon, Apr 29, 2024 at 12:25:37PM +0900, Jeuk Kim wrote:
> From: Jeuk Kim <jeuk20.kim@samsung.com>
>
> The following changes since commit fd87be1dada5672f877e03c2ca8504458292c479:
>
> Merge tag 'accel-20240426' of https://github.com/philmd/qemu into staging (2024-04-26 15:28:13 -0700)
>
> are available in the Git repository at:
>
> https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20240429
>
> for you to fetch changes up to f2c8aeb1afefcda92054c448b21fc59cdd99db30:
>
> hw/ufs: Fix buffer overflow bug (2024-04-29 12:13:35 +0900)
>
> ----------------------------------------------------------------
> ufs queue
>
> - Fix ufs sanitizer vulnerability
>
> ----------------------------------------------------------------
> Jeuk Kim (1):
> hw/ufs: Fix buffer overflow bug
>
> hw/ufs/ufs.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
Thanks, applied to my block tree:
https://gitlab.com/stefanha/qemu/commits/block
It will be included in my next block pull request.
You are welcome to send pull requests directly to the qemu.git/master
maintainer (Richard Henderson is on duty for this release cycle). If you
do that, make sure to GPG sign your pull request.
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PULL 0/1] ufs queue
2024-04-29 13:41 ` Stefan Hajnoczi
@ 2024-04-29 14:02 ` Richard Henderson
0 siblings, 0 replies; 15+ messages in thread
From: Richard Henderson @ 2024-04-29 14:02 UTC (permalink / raw)
To: Stefan Hajnoczi, Jeuk Kim
Cc: qemu-devel, fam, pbonzini, qemu-block, jeuk20.kim, j-young.choi,
zheyuma97
On 4/29/24 06:41, Stefan Hajnoczi wrote:
> On Mon, Apr 29, 2024 at 12:25:37PM +0900, Jeuk Kim wrote:
>> From: Jeuk Kim <jeuk20.kim@samsung.com>
>>
>> The following changes since commit fd87be1dada5672f877e03c2ca8504458292c479:
>>
>> Merge tag 'accel-20240426' of https://github.com/philmd/qemu into staging (2024-04-26 15:28:13 -0700)
>>
>> are available in the Git repository at:
>>
>> https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20240429
>>
>> for you to fetch changes up to f2c8aeb1afefcda92054c448b21fc59cdd99db30:
>>
>> hw/ufs: Fix buffer overflow bug (2024-04-29 12:13:35 +0900)
>>
>> ----------------------------------------------------------------
>> ufs queue
>>
>> - Fix ufs sanitizer vulnerability
>>
>> ----------------------------------------------------------------
>> Jeuk Kim (1):
>> hw/ufs: Fix buffer overflow bug
>>
>> hw/ufs/ufs.c | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>
> Thanks, applied to my block tree:
> https://gitlab.com/stefanha/qemu/commits/block
>
> It will be included in my next block pull request.
>
> You are welcome to send pull requests directly to the qemu.git/master
> maintainer (Richard Henderson is on duty for this release cycle). If you
> do that, make sure to GPG sign your pull request.
He did. I have
Merge tag 'pull-ufs-20240429' of https://gitlab.com/jeuk20.kim/qemu into staging
ufs queue
# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEUBfYMVl8eKPZB+73EuIgTA5dtgIFAmYvEScACgkQEuIgTA5d
# tgL3Qg//R3IcISQqqDaJ/ySzKGmkyohJSc6ySLYvla4Aki7PV+um2Dx/XNS7uG2b
# d3Qz4m6QaOKsocLfldRTn2FxVK238Rp5HNny5vc0kGRdwpR514B7aU0FhpT7qObS
# wbbgRdDddIBIiCFLhtXtg5/TK2h32VxGrVI6llX4gmd2VzqM0e4xeG1Oj8rZseOY
# SAgvDv68s1YwlO1p1vPvst/H+mUKYkqtPN1mjfCIn5tM6ss8kCLUnKjqGAg1BnSN
# xwaGrqqOlzQK2+aV02eiItiow8evU/h+c9eiTnBo/EvBwjoBn6flNXABWXFENnmP
# JjVIFeiNzSFhBPDzO23GXviuEt96j5lrcGYR48HYMZfEbJNpblXzWvEGMZWnXNgx
# Q3cpcarZ4vSWIflR9OnCSQaGLA0Ny6YqLbmrM/oD+v67EITafKKc+flmiF7DBASB
# fUoEsdffdA37LDtygJb7hfUhvPQWWAujmGzZ1cDP8Oa0MhT7aiD0Z/WqhhjVQbM0
# iLiCDDD0cc0pmT3vw3EnEjKjnSkY3H62Q7pnYHiQgij4Ls/Rdd/P7OkSd0aI82t0
# TooWGZJnyf8rjAzY2cEB1Twrhmhuyt9NnGxip9W8JsQBZMLabD2CahOm83zsk7jZ
# 3fOONz6XrW2ttFkLZcRd4x4YjKONjEXsSX2ZrXTZ5t3USz/VNvY=
# =Vwyi
# -----END PGP SIGNATURE-----
# gpg: Signature made Sun 28 Apr 2024 08:16:55 PM PDT
# gpg: using RSA key 5017D831597C78A3D907EEF712E2204C0E5DB602
# gpg: Good signature from "Jeuk Kim <jeuk20.kim@samsung.com>" [unknown]
# gpg: aka "Jeuk Kim <jeuk20.kim@gmail.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg: There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 5017 D831 597C 78A3 D907 EEF7 12E2 204C 0E5D B602
queued for the next merge.
r~
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PULL 0/1] ufs queue
2024-04-29 3:25 Jeuk Kim
2024-04-29 13:41 ` Stefan Hajnoczi
@ 2024-05-01 22:15 ` Richard Henderson
1 sibling, 0 replies; 15+ messages in thread
From: Richard Henderson @ 2024-05-01 22:15 UTC (permalink / raw)
To: Jeuk Kim, qemu-devel, stefanha
Cc: fam, pbonzini, qemu-block, jeuk20.kim, j-young.choi, zheyuma97
On 4/28/24 20:25, Jeuk Kim wrote:
> From: Jeuk Kim<jeuk20.kim@samsung.com>
>
> The following changes since commit fd87be1dada5672f877e03c2ca8504458292c479:
>
> Merge tag 'accel-20240426' ofhttps://github.com/philmd/qemu into staging (2024-04-26 15:28:13 -0700)
>
> are available in the Git repository at:
>
> https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20240429
>
> for you to fetch changes up to f2c8aeb1afefcda92054c448b21fc59cdd99db30:
>
> hw/ufs: Fix buffer overflow bug (2024-04-29 12:13:35 +0900)
>
> ----------------------------------------------------------------
> ufs queue
>
> - Fix ufs sanitizer vulnerability
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/9.1 as appropriate.
r~
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PULL 0/1] ufs queue
@ 2024-06-30 3:52 Jeuk Kim
2024-06-30 23:11 ` Richard Henderson
0 siblings, 1 reply; 15+ messages in thread
From: Jeuk Kim @ 2024-06-30 3:52 UTC (permalink / raw)
To: qemu-devel, richard.henderson
Cc: fam, pbonzini, qemu-block, jeuk20.kim, j-young.choi
From: Jeuk Kim <jeuk20.kim@samsung.com>
The following changes since commit 3665dd6bb9043bef181c91e2dce9e1efff47ed51:
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2024-06-28 16:09:38 -0700)
are available in the Git repository at:
https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20240630
for you to fetch changes up to e12b11f6f29272ee31ccde6b0db1a10139e87083:
hw/ufs: Fix potential bugs in MMIO read|write (2024-06-30 12:44:32 +0900)
----------------------------------------------------------------
hw/ufs: fix coverity issue
----------------------------------------------------------------
Minwoo Im (1):
hw/ufs: Fix potential bugs in MMIO read|write
hw/ufs/ufs.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PULL 0/1] ufs queue
2024-06-30 3:52 Jeuk Kim
@ 2024-06-30 23:11 ` Richard Henderson
0 siblings, 0 replies; 15+ messages in thread
From: Richard Henderson @ 2024-06-30 23:11 UTC (permalink / raw)
To: Jeuk Kim, qemu-devel; +Cc: fam, pbonzini, qemu-block, jeuk20.kim, j-young.choi
On 6/29/24 20:52, Jeuk Kim wrote:
> From: Jeuk Kim<jeuk20.kim@samsung.com>
>
> The following changes since commit 3665dd6bb9043bef181c91e2dce9e1efff47ed51:
>
> Merge tag 'for-upstream' ofhttps://gitlab.com/bonzini/qemu into staging (2024-06-28 16:09:38 -0700)
>
> are available in the Git repository at:
>
> https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20240630
>
> for you to fetch changes up to e12b11f6f29272ee31ccde6b0db1a10139e87083:
>
> hw/ufs: Fix potential bugs in MMIO read|write (2024-06-30 12:44:32 +0900)
>
> ----------------------------------------------------------------
> hw/ufs: fix coverity issue
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/9.1 as appropriate.
r~
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PULL 0/1] ufs queue
@ 2024-07-08 1:31 Jeuk Kim
2024-07-08 10:00 ` Jeuk Kim
0 siblings, 1 reply; 15+ messages in thread
From: Jeuk Kim @ 2024-07-08 1:31 UTC (permalink / raw)
To: qemu-devel, richard.henderson
Cc: fam, pbonzini, qemu-block, jeuk20.kim, j-young.choi
From: Jeuk Kim <jeuk20.kim@samsung.com>
The following changes since commit b9ee1387e0cf0fba5a73a610d31cb9cead457dc0:
Merge tag 'sdmmc-20240706' of https://github.com/philmd/qemu into staging (2024-07-07 10:34:52 -0700)
are available in the Git repository at:
https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20240708
for you to fetch changes up to 6db492596dd9204e8fe341b2396472271cf15023:
hw/ufs: Fix mcq register range determination logic (2024-07-08 10:25:20 +0900)
----------------------------------------------------------------
hw/ufs:
- Fix invalid address access in ufs_is_mcq_reg()
----------------------------------------------------------------
Jeuk Kim (1):
hw/ufs: Fix mcq register range determination logic
hw/ufs/ufs.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PULL 0/1] ufs queue
2024-07-08 1:31 Jeuk Kim
@ 2024-07-08 10:00 ` Jeuk Kim
0 siblings, 0 replies; 15+ messages in thread
From: Jeuk Kim @ 2024-07-08 10:00 UTC (permalink / raw)
To: qemu-devel, richard.henderson
Cc: fam, pbonzini, qemu-block, jeuk20.kim, j-young.choi
I'm so sorry. I forgot to add something to the patch, I'll add it and
resend it to you.
Sorry again.
On 7/8/2024 10:31 AM, Jeuk Kim wrote:
> From: Jeuk Kim <jeuk20.kim@samsung.com>
>
> The following changes since commit b9ee1387e0cf0fba5a73a610d31cb9cead457dc0:
>
> Merge tag 'sdmmc-20240706' of https://github.com/philmd/qemu into staging (2024-07-07 10:34:52 -0700)
>
> are available in the Git repository at:
>
> https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20240708
>
> for you to fetch changes up to 6db492596dd9204e8fe341b2396472271cf15023:
>
> hw/ufs: Fix mcq register range determination logic (2024-07-08 10:25:20 +0900)
>
> ----------------------------------------------------------------
> hw/ufs:
> - Fix invalid address access in ufs_is_mcq_reg()
>
> ----------------------------------------------------------------
> Jeuk Kim (1):
> hw/ufs: Fix mcq register range determination logic
>
> hw/ufs/ufs.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PULL 0/1] ufs queue
@ 2026-07-08 23:22 Jeuk Kim
2026-07-10 4:48 ` Stefan Hajnoczi
0 siblings, 1 reply; 15+ messages in thread
From: Jeuk Kim @ 2026-07-08 23:22 UTC (permalink / raw)
To: qemu-devel, qemu-stable, stefanha
Cc: pbonzini, farosas, lvivier, qemu-block, jeuk20.kim, j-young.choi
From: Jeuk Kim <jeuk20.kim@samsung.com>
The following changes since commit f893c46c3931b3684d235d221bf8b7844ddbf1d7:
Merge tag 'qemu-openbios-20260707' of https://github.com/mcayland/qemu into staging (2026-07-08 16:01:29 +0200)
are available in the Git repository at:
https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20260709
for you to fetch changes up to 90aacd5bc405cb71f77472616093f9e5ad9afd2b:
hw/ufs: avoid double unref of wrapped scsi-hd (2026-07-09 07:58:38 +0900)
----------------------------------------------------------------
hw/ufs: fix double unref of wrapped scsi-hd
----------------------------------------------------------------
Jia Jia (1):
hw/ufs: avoid double unref of wrapped scsi-hd
hw/ufs/lu.c | 5 +----
tests/qtest/ufs-test.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 4 deletions(-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PULL 0/1] ufs queue
2026-07-08 23:22 Jeuk Kim
@ 2026-07-10 4:48 ` Stefan Hajnoczi
0 siblings, 0 replies; 15+ messages in thread
From: Stefan Hajnoczi @ 2026-07-10 4:48 UTC (permalink / raw)
To: Jeuk Kim
Cc: qemu-devel, qemu-stable, stefanha, pbonzini, farosas, lvivier,
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] 15+ messages in thread
* [PULL 0/1] ufs queue
@ 2026-09-18 0:08 Jeuk Kim
2026-09-18 0:08 ` [PULL 1/1] hw/ufs: Reset controller and MCQ state on HCE transition to 0 Jeuk Kim
2026-09-18 4:07 ` [PULL 0/1] ufs queue Richard Henderson
0 siblings, 2 replies; 15+ messages in thread
From: Jeuk Kim @ 2026-09-18 0:08 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, jeuk20.kim, j-young.choi, stanleyjhu,
richard.henderson, stefanha
From: Jeuk Kim <jeuk20.kim@samsung.com>
The following changes since commit c66824ffb01931be0ddfe49a1642a78570abf44b:
Merge tag 'misc-fixes-pull-request' of https://gitlab.com/berrange/qemu into staging (2026-09-17 10:21:06 -1000)
are available in the Git repository at:
https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20260918
for you to fetch changes up to cc1d72231c925a632f360937d9eb48ea12bd539c:
hw/ufs: Reset controller and MCQ state on HCE transition to 0 (2026-09-18 08:59:52 +0900)
----------------------------------------------------------------
ufs queue
----------------------------------------------------------------
Stanley Jhu (1):
hw/ufs: Reset controller and MCQ state on HCE transition to 0
hw/ufs/lu.c | 7 ++++
hw/ufs/trace-events | 1 +
hw/ufs/ufs.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
hw/ufs/ufs.h | 2 ++
4 files changed, 105 insertions(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PULL 1/1] hw/ufs: Reset controller and MCQ state on HCE transition to 0
2026-09-18 0:08 [PULL 0/1] ufs queue Jeuk Kim
@ 2026-09-18 0:08 ` Jeuk Kim
2026-09-18 4:07 ` [PULL 0/1] ufs queue Richard Henderson
1 sibling, 0 replies; 15+ messages in thread
From: Jeuk Kim @ 2026-09-18 0:08 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, jeuk20.kim, j-young.choi, stanleyjhu,
richard.henderson, stefanha
From: Stanley Jhu <stanleyjhu@google.com>
According to the JEDEC Universal Flash Storage Host Controller Interface
(UFSHCI) specification (Section 5.2.1 "Host Controller Enable"):
when Host Controller Enable (HCE) transitions from 1 to 0, a host
controller reset is initiated. The host controller shall abort all
active transfers, return internal state machines to idle, and de-assert
all interrupts.
Currently, QEMU's UFS emulator only clears HCS and HCE registers upon
HCE=0, leaving internal state active. Specifically:
- Outstanding SCSI requests in the block layer are not purged.
- Active bottom halves (doorbell_bh, complete_bh, and MCQ sq/cq BHs)
remain scheduled.
- Allocated MCQ Submission and Completion Queues (sq and cq) are
not freed.
- Dynamic MCQ queue registers, legacy UTRL request states, and status
registers (UTRLCNR, UTRLRSR) remain stale.
Implement ufs_hce_reset() to:
1. Implement .cancel callback in ufs_scsi_info to properly unref
scsi_req and prevent reference leaks when SCSI requests are purged.
2. Cancel active bottom halves (doorbell_bh, complete_bh, and MCQ sq/cq
BHs) and guard them with a resetting flag before purging requests,
ensuring blk_drain() cannot run or reschedule request-producing BHs.
3. Purge outstanding SCSI requests for all logical units via
scsi_device_purge_requests().
4. Clear standard request list slots and release SGLs via
ufs_clear_req(), and clear doorbells and status registers (UTRLCNR,
UTRLRSR).
5. Free allocated MCQ queues and clear dynamic queue registers while
preserving static capability offsets.
6. De-assert interrupts via ufs_irq_check().
7. Add a trace_ufs_hce_reset() trace event.
Signed-off-by: Stanley Jhu <stanleyjhu@google.com>
Reviewed-by: Jeuk Kim <jeuk20.kim@samsung.com>
Signed-off-by: Jeuk Kim <jeuk20.kim@samsung.com>
---
hw/ufs/lu.c | 7 ++++
hw/ufs/trace-events | 1 +
hw/ufs/ufs.c | 96 ++++++++++++++++++++++++++++++++++++++++++++-
hw/ufs/ufs.h | 2 +
4 files changed, 105 insertions(+), 1 deletion(-)
diff --git a/hw/ufs/lu.c b/hw/ufs/lu.c
index eeca865eb5..bdb1650851 100644
--- a/hw/ufs/lu.c
+++ b/hw/ufs/lu.c
@@ -188,6 +188,12 @@ static void ufs_scsi_command_complete(SCSIRequest *scsi_req, size_t resid)
scsi_req_unref(scsi_req);
}
+static void ufs_scsi_command_cancelled(SCSIRequest *scsi_req)
+{
+ scsi_req->hba_private = NULL;
+ scsi_req_unref(scsi_req);
+}
+
static QEMUSGList *ufs_get_sg_list(SCSIRequest *scsi_req)
{
UfsRequest *req = scsi_req->hba_private;
@@ -202,6 +208,7 @@ static const struct SCSIBusInfo ufs_scsi_info = {
.get_sg_list = ufs_get_sg_list,
.complete = ufs_scsi_command_complete,
+ .cancel = ufs_scsi_command_cancelled,
};
static int ufs_emulate_report_luns(UfsRequest *req, uint8_t *outbuf,
diff --git a/hw/ufs/trace-events b/hw/ufs/trace-events
index 0cd3ba9b02..922293355b 100644
--- a/hw/ufs/trace-events
+++ b/hw/ufs/trace-events
@@ -14,6 +14,7 @@ ufs_process_uiccmd(uint32_t uiccmd, uint32_t ucmdarg1, uint32_t ucmdarg2, uint32
ufs_mcq_complete_req(uint8_t qid) "sqid %"PRIu8""
ufs_mcq_create_sq(uint8_t sqid, uint8_t cqid, uint64_t addr, uint16_t size) "mcq create sq sqid %"PRIu8", cqid %"PRIu8", addr 0x%"PRIx64", size %"PRIu16""
ufs_mcq_create_cq(uint8_t cqid, uint64_t addr, uint16_t size) "mcq create cq cqid %"PRIu8", addr 0x%"PRIx64", size %"PRIu16""
+ufs_hce_reset(void) "HCE 1 -> 0 reset: cancelling BHs, resetting MCQ and request lists"
# error condition
ufs_err_dma_read_utrd(uint32_t slot, uint64_t addr) "failed to read utrd. UTRLDBR slot %"PRIu32", UTRD dma addr %"PRIu64""
diff --git a/hw/ufs/ufs.c b/hw/ufs/ufs.c
index 160a4ac4f3..3c4d7424da 100644
--- a/hw/ufs/ufs.c
+++ b/hw/ufs/ufs.c
@@ -452,6 +452,10 @@ static void ufs_mcq_process_sq(void *opaque)
uint16_t head = ufs_mcq_sq_head(u, sq->sqid);
int err;
+ if (u->resetting) {
+ return;
+ }
+
while (!(ufs_mcq_sq_empty(u, sq->sqid) || QTAILQ_EMPTY(&sq->req_list))) {
addr = sq->addr + head;
err = ufs_addr_read(sq->u, addr, (void *)&sqe, sizeof(sqe));
@@ -525,7 +529,7 @@ static void ufs_mcq_process_cq(void *opaque)
tail = (tail + sizeof(req->cqe)) % (cq->size * sizeof(req->cqe));
ufs_mcq_update_cq_tail(u, cq->cqid, tail);
- if (QTAILQ_EMPTY(&req->sq->req_list) &&
+ if (!u->resetting && QTAILQ_EMPTY(&req->sq->req_list) &&
!ufs_mcq_sq_empty(u, req->sq->sqid)) {
/* Dequeueing from SQ was blocked due to lack of free requests */
qemu_bh_schedule(req->sq->bh);
@@ -722,6 +726,87 @@ static bool ufs_mcq_delete_cq(UfsHc *u, uint8_t qid)
return true;
}
+static void ufs_hce_reset(UfsHc *u)
+{
+ int i;
+
+ trace_ufs_hce_reset();
+
+ u->resetting = true;
+
+ /* 1. Cancel active Bottom Halves before purging requests */
+ if (u->doorbell_bh) {
+ qemu_bh_cancel(u->doorbell_bh);
+ }
+ if (u->complete_bh) {
+ qemu_bh_cancel(u->complete_bh);
+ }
+ if (u->params.mcq) {
+ for (i = 0; i < ARRAY_SIZE(u->sq); i++) {
+ if (u->sq[i] && u->sq[i]->bh) {
+ qemu_bh_cancel(u->sq[i]->bh);
+ }
+ }
+ for (i = 0; i < ARRAY_SIZE(u->cq); i++) {
+ if (u->cq[i] && u->cq[i]->bh) {
+ qemu_bh_cancel(u->cq[i]->bh);
+ }
+ }
+ }
+
+ /* 2. Purge outstanding SCSI requests for all logical units */
+ for (i = 0; i < UFS_MAX_LUS; i++) {
+ if (u->lus[i] && u->lus[i]->scsi_dev) {
+ scsi_device_purge_requests(u->lus[i]->scsi_dev, SENSE_CODE(RESET));
+ }
+ }
+
+ /* 3. Reset standard request list slots, doorbells, and status registers */
+ for (i = 0; i < u->params.nutrs; i++) {
+ ufs_clear_req(&u->req_list[i]);
+ u->req_list[i].state = UFS_REQUEST_IDLE;
+ }
+ u->reg.utrldbr = 0;
+ u->reg.utmrldbr = 0;
+ u->reg.utrlcnr = 0;
+ u->reg.utrlrsr = 0;
+ u->reg.is = 0;
+
+ /* 4. Free MCQ Queues and reset MCQ dynamic registers */
+ if (u->params.mcq) {
+ for (i = 0; i < ARRAY_SIZE(u->sq); i++) {
+ if (u->sq[i]) {
+ ufs_mcq_free_sq(u->sq[i]);
+ u->sq[i] = NULL;
+ }
+ }
+ for (i = 0; i < ARRAY_SIZE(u->cq); i++) {
+ if (u->cq[i]) {
+ ufs_mcq_free_cq(u->cq[i]);
+ u->cq[i] = NULL;
+ }
+ }
+
+ /* Clear dynamic queue configuration registers without overwriting static capability offsets */
+ for (i = 0; i < ARRAY_SIZE(u->mcq_reg); i++) {
+ u->mcq_reg[i].sqattr = 0;
+ u->mcq_reg[i].sqlba = 0;
+ u->mcq_reg[i].squba = 0;
+ u->mcq_reg[i].sqcfg = 0;
+ u->mcq_reg[i].cqattr = 0;
+ u->mcq_reg[i].cqlba = 0;
+ u->mcq_reg[i].cquba = 0;
+ u->mcq_reg[i].cqcfg = 0;
+ }
+ memset(u->mcq_op_reg, 0, sizeof(u->mcq_op_reg));
+ }
+
+ u->resetting = false;
+
+ /* 5. De-assert IRQ */
+ ufs_irq_check(u);
+}
+
static void ufs_write_reg(UfsHc *u, hwaddr offset, uint32_t data, unsigned size)
{
switch (offset) {
@@ -739,6 +824,7 @@ static void ufs_write_reg(UfsHc *u, hwaddr offset, uint32_t data, unsigned size)
u->reg.hce = FIELD_DP32(u->reg.hce, HCE, HCE, 1);
} else if (FIELD_EX32(u->reg.hce, HCE, HCE) &&
!FIELD_EX32(data, HCE, HCE)) {
+ ufs_hce_reset(u);
u->reg.hcs = 0;
u->reg.hce = FIELD_DP32(u->reg.hce, HCE, HCE, 0);
}
@@ -2089,6 +2175,10 @@ static void ufs_process_req(void *opaque)
UfsRequest *req;
int slot;
+ if (u->resetting) {
+ return;
+ }
+
for (slot = 0; slot < u->params.nutrs; slot++) {
req = &u->req_list[slot];
@@ -2115,6 +2205,10 @@ void ufs_complete_req(UfsRequest *req, UfsReqResult req_result)
req->state = UFS_REQUEST_COMPLETE;
+ if (u->resetting) {
+ return;
+ }
+
if (ufs_mcq_req(req)) {
trace_ufs_mcq_complete_req(req->sq->sqid);
QTAILQ_INSERT_TAIL(&req->sq->cq->req_list, req, entry);
diff --git a/hw/ufs/ufs.h b/hw/ufs/ufs.h
index aa8361d93d..6f2693b7ca 100644
--- a/hw/ufs/ufs.h
+++ b/hw/ufs/ufs.h
@@ -173,6 +173,8 @@ typedef struct UfsHc {
UfsSq *sq[UFS_MAX_MCQ_QNUM];
UfsCq *cq[UFS_MAX_MCQ_QNUM];
+ bool resetting;
+
/* Extended features */
UfsWb wb;
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PULL 0/1] ufs queue
2026-09-18 0:08 [PULL 0/1] ufs queue Jeuk Kim
2026-09-18 0:08 ` [PULL 1/1] hw/ufs: Reset controller and MCQ state on HCE transition to 0 Jeuk Kim
@ 2026-09-18 4:07 ` Richard Henderson
1 sibling, 0 replies; 15+ messages in thread
From: Richard Henderson @ 2026-09-18 4:07 UTC (permalink / raw)
To: Jeuk Kim, qemu-devel
Cc: qemu-block, jeuk20.kim, j-young.choi, stanleyjhu, stefanha
On 9/17/26 14:08, Jeuk Kim wrote:
> From: Jeuk Kim<jeuk20.kim@samsung.com>
>
> The following changes since commit c66824ffb01931be0ddfe49a1642a78570abf44b:
>
> Merge tag 'misc-fixes-pull-request' ofhttps://gitlab.com/berrange/qemu into staging (2026-09-17 10:21:06 -1000)
>
> are available in the Git repository at:
>
> https://gitlab.com/jeuk20.kim/qemu.git tags/pull-ufs-20260918
>
> for you to fetch changes up to cc1d72231c925a632f360937d9eb48ea12bd539c:
>
> hw/ufs: Reset controller and MCQ state on HCE transition to 0 (2026-09-18 08:59:52 +0900)
>
> ----------------------------------------------------------------
> ufs queue
Applied, thanks.
r~
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-09-18 4:08 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-18 0:08 [PULL 0/1] ufs queue Jeuk Kim
2026-09-18 0:08 ` [PULL 1/1] hw/ufs: Reset controller and MCQ state on HCE transition to 0 Jeuk Kim
2026-09-18 4:07 ` [PULL 0/1] ufs queue Richard Henderson
-- strict thread matches above, loose matches on Subject: below --
2026-07-08 23:22 Jeuk Kim
2026-07-10 4:48 ` Stefan Hajnoczi
2024-07-08 1:31 Jeuk Kim
2024-07-08 10:00 ` Jeuk Kim
2024-06-30 3:52 Jeuk Kim
2024-06-30 23:11 ` Richard Henderson
2024-04-29 3:25 Jeuk Kim
2024-04-29 13:41 ` Stefan Hajnoczi
2024-04-29 14:02 ` Richard Henderson
2024-05-01 22:15 ` Richard Henderson
2023-10-30 4:02 Jeuk Kim
2023-10-31 7:50 ` Stefan Hajnoczi
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.