aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeuk Kim <jeuk20.kim@samsung.com>2023-10-19 23:28:06 +0900
committerJeuk Kim <jeuk20.kim@samsung.com>2023-10-30 10:28:04 +0900
commit096434fea13acd19f4ead00cdf9babea8dc7e61e (patch)
treeb0b1ceb8e14bd2c51dd817f954833188bc947422 /tests
parentc60be6e3e38cb36dc66129e757ec4b34152232be (diff)
hw/ufs: Modify lu.c to share codes with SCSI subsystem
This patch removes the code that ufs-lu was duplicating from scsi-hd and allows them to share code. It makes ufs-lu have a virtual scsi-bus and scsi-hd internally. This allows scsi related commands to be passed thorugh to the scsi-hd. The query request and nop command work the same as the existing logic. Well-known lus do not have a virtual scsi-bus and scsi-hd, and handle the necessary scsi commands by emulating them directly. Signed-off-by: Jeuk Kim <jeuk20.kim@samsung.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/qtest/ufs-test.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/tests/qtest/ufs-test.c b/tests/qtest/ufs-test.c
index 15d467630c..5daf8c9c49 100644
--- a/tests/qtest/ufs-test.c
+++ b/tests/qtest/ufs-test.c
@@ -425,6 +425,9 @@ static void ufstest_init(void *obj, void *data, QGuestAllocator *alloc)
const uint8_t test_unit_ready_cdb[UFS_CDB_SIZE] = {
TEST_UNIT_READY,
};
+ const uint8_t request_sense_cdb[UFS_CDB_SIZE] = {
+ REQUEST_SENSE,
+ };
UtpTransferReqDesc utrd;
UtpUpiuRsp rsp_upiu;
@@ -440,6 +443,12 @@ static void ufstest_init(void *obj, void *data, QGuestAllocator *alloc)
/* There is one logical unit whose lun is 0 */
g_assert_cmpuint(buf[9], ==, 0);
+ /* Clear Unit Attention */
+ ufs_send_scsi_command(ufs, 0, 0, request_sense_cdb, NULL, 0, buf,
+ sizeof(buf), &utrd, &rsp_upiu);
+ g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), ==, UFS_OCS_SUCCESS);
+ g_assert_cmpuint(rsp_upiu.header.scsi_status, ==, CHECK_CONDITION);
+
/* Check TEST_UNIT_READY */
ufs_send_scsi_command(ufs, 0, 0, test_unit_ready_cdb, NULL, 0, NULL, 0,
&utrd, &rsp_upiu);
@@ -473,6 +482,9 @@ static void ufstest_read_write(void *obj, void *data, QGuestAllocator *alloc)
0x00,
0x00
};
+ const uint8_t request_sense_cdb[UFS_CDB_SIZE] = {
+ REQUEST_SENSE,
+ };
const uint8_t read_cdb[UFS_CDB_SIZE] = {
/* READ(10) to LBA 0, transfer length 1 */
READ_10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00
@@ -484,32 +496,39 @@ static void ufstest_read_write(void *obj, void *data, QGuestAllocator *alloc)
uint32_t block_size;
UtpTransferReqDesc utrd;
UtpUpiuRsp rsp_upiu;
+ const int test_lun = 1;
ufs_init(ufs, alloc);
+ /* Clear Unit Attention */
+ ufs_send_scsi_command(ufs, 0, test_lun, request_sense_cdb, NULL, 0,
+ read_buf, sizeof(read_buf), &utrd, &rsp_upiu);
+ g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), ==, UFS_OCS_SUCCESS);
+ g_assert_cmpuint(rsp_upiu.header.scsi_status, ==, CHECK_CONDITION);
+
/* Read capacity */
- ufs_send_scsi_command(ufs, 0, 1, read_capacity_cdb, NULL, 0, read_buf,
- sizeof(read_buf), &utrd, &rsp_upiu);
+ ufs_send_scsi_command(ufs, 0, test_lun, read_capacity_cdb, NULL, 0,
+ read_buf, sizeof(read_buf), &utrd, &rsp_upiu);
g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), ==, UFS_OCS_SUCCESS);
g_assert_cmpuint(rsp_upiu.header.scsi_status, ==,
- UFS_COMMAND_RESULT_SUCESS);
+ UFS_COMMAND_RESULT_SUCCESS);
block_size = ldl_be_p(&read_buf[8]);
g_assert_cmpuint(block_size, ==, 4096);
/* Write data */
memset(write_buf, 0xab, block_size);
- ufs_send_scsi_command(ufs, 0, 1, write_cdb, write_buf, block_size, NULL, 0,
- &utrd, &rsp_upiu);
+ ufs_send_scsi_command(ufs, 0, test_lun, write_cdb, write_buf, block_size,
+ NULL, 0, &utrd, &rsp_upiu);
g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), ==, UFS_OCS_SUCCESS);
g_assert_cmpuint(rsp_upiu.header.scsi_status, ==,
- UFS_COMMAND_RESULT_SUCESS);
+ UFS_COMMAND_RESULT_SUCCESS);
/* Read data and verify */
- ufs_send_scsi_command(ufs, 0, 1, read_cdb, NULL, 0, read_buf, block_size,
- &utrd, &rsp_upiu);
+ ufs_send_scsi_command(ufs, 0, test_lun, read_cdb, NULL, 0, read_buf,
+ block_size, &utrd, &rsp_upiu);
g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), ==, UFS_OCS_SUCCESS);
g_assert_cmpuint(rsp_upiu.header.scsi_status, ==,
- UFS_COMMAND_RESULT_SUCESS);
+ UFS_COMMAND_RESULT_SUCCESS);
g_assert_cmpint(memcmp(read_buf, write_buf, block_size), ==, 0);
ufs_exit(ufs, alloc);