On 30.10.2026 11:14, Jeuk Kim wrote:
From: Daejun Park <[email protected]>
scsi-hd moves as many bytes as the SG list of a request holds, and
ufs-lu builds that list from the whole PRDT. When the PRDT is larger
than the transfer length in the CDB, a WRITE writes more blocks than
the CDB names and a READ reads more. A one-block WRITE(10) at LBA 0
with an 8 KiB PRDT also wrote LBA 1, and its response reported no
residual. A UFS device transfers what the CDB asks for and reports the
rest of the Expected Data Transfer Length as a residual.
The commands that scsi-hd emulates had their residual computed against
the PRDT too: an INQUIRY with an allocation length of 36, a 4 KiB PRDT
and an Expected Data Transfer Length of 4096 reported an overflow of
4294959176 bytes. It now reports an underflow of 4060.
When the PRDT is smaller than the transfer length, scsi-hd moved what it
holds and the request completed without an error, for example a
two-block WRITE(10) with a 4 KiB PRDT. Such a request now fails with OCS
MISMATCH DATA BUFFER SIZE, as one without a PRDT does. As in
virtio-scsi, the PRDT is compared with the transfer length of the CDB,
which for commands that return data is the allocation length, and before
scsi-hd checks the CDB.
The new ufs_fit_data_buffer() in ufs.c, where the SG list is built from
the PRDT, cuts a longer list and reports a shorter one; ufs-lu passes it
the transfer length that scsi_req_new() parsed. The HID qtest wrote
eight blocks from a one-block buffer, so give it eight blocks. The new
long-prdt and short-prdt qtests failed before this change.
Fixes: 2a8b36a4967d ("hw/ufs: Support for UFS logical unit")
Cc: [email protected]
Signed-off-by: Daejun Park <[email protected]>
Reviewed-by: Stanley Jhu <[email protected]>
Reviewed-by: Jeuk Kim <[email protected]>
Signed-off-by: Jeuk Kim <[email protected]>
---
hw/ufs/lu.c | 20 +++---
hw/ufs/trace-events | 1 +
hw/ufs/ufs.c | 35 ++++++++++
hw/ufs/ufs.h | 1 +
tests/qtest/ufs-test.c | 141 ++++++++++++++++++++++++++++++++++++++++-
5 files changed, 189 insertions(+), 9 deletions(-)
Hi!
This patch is tagged for-stable. When trying to cherry-pick it to 10.0.x
series, I notieced the change to ufs-test.c does not apply, this one:
--- a/tests/qtest/ufs-test.c
+++ b/tests/qtest/ufs-test.c
@@ -1577,7 +1713,8 @@ static void ufstest_hid(void *obj, void *data,
QGuestAllocator *alloc)
/* WRITE(10) to LBA 0, transfer length 8 sectors = 1 fragment */
WRITE_10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00
};
- uint8_t write_buf[4096];
+ /* The PRDT must hold the eight blocks that the WRITE(10) moves */
+ uint8_t write_buf[8 * 4096];
uint8_t read_buf[4096];
int i;
This is because 10.0.x has no UFS HID support.
So, it is not the test itself which does not apply, but modifying parameters
for another test, which, apparently, triggers this PRDT one.
Without knowing all the details about all hardware specifics involved,
I can't say for sure what's going on here. How the two (HID & this
PRTD change) are related and what should be the test for 10.0.x ?
Thanks!
/mjt