Skip to content

Commit

Permalink
Merge tag 'pull-ufs-20231013' of https://gitlab.com/jeuk20.kim/qemu i…
Browse files Browse the repository at this point in the history
…nto staging

hw/ufs: fixes

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEUBfYMVl8eKPZB+73EuIgTA5dtgIFAmUozswACgkQEuIgTA5d
# tgITExAAo0BSNir4I5MfeNIjZTNNdxLXDl0+92JyairB2m/gWH/02jGtrJBYp5On
# ELnixKj2Ntn9IIRr3NwQHNTnDOZHRkUBH+pRVeMbZ+IWLjEoWQdl03ge7e9sHai3
# CLXB4HPSnXddy1SmS9FEkdBWopqxKF4BLZnpAfwh/dj2fzSyDyNIMmGoRimRQhph
# 9A90304ERUdpREAXncTgSdXeDZz+lScadzUJZrPPiG2ZHXL+qzDCX7ojEnNaUFxz
# W1IfriI8oeeORfCQaNEOncLKhSwE1WscGxP0vILPApKOu251tObgSbK90QlQR2qT
# BMl7k4BDfYeksXMGc0BXVFrOfv1ud86NlCE2OokK6HBZVuHio4C6TU/t65MC4Rw5
# mJ8CPgbN+7sgVmAGo0sLYzI6GiRR27VqqLh6KXVAa5c/fAdt5pHSkakwSvxiXsAl
# EqskmOY2em5O//+7CWN1CtY+I2pHyltMXAi3Cb2vjweNx88kuhmxFQWeZVI10/H3
# gNrNfu32+ihDLMqR7uQamdAZV0lnIwp97nCbf3LzpM0btjl70QvGZhsbiCDiLQrG
# mJjnaix4xDb8T21WKrI8DKcwR4rvD8hZsCUp31XJnA8HWtdPnEQldK8NEGNlU5ye
# lrGc6gxiwZLCBBIj9lwbZW3Zv9Vz9jNWISOmY+KWLCIus98DBxQ=
# =XXsQ
# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 13 Oct 2023 00:59:56 EDT
# 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

* tag 'pull-ufs-20231013' of https://gitlab.com/jeuk20.kim/qemu:
  hw/ufs: Fix incorrect register fields
  hw/ufs: Fix code coverity issues

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
stefanhaRH committed Oct 16, 2023
2 parents 6cfa2ec + ebca80b commit 4395a47
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
16 changes: 7 additions & 9 deletions hw/ufs/lu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1345,13 +1345,12 @@ static void ufs_lu_realize(SCSIDevice *dev, Error **errp)
return;
}

if (lu->qdev.conf.blk) {
ctx = blk_get_aio_context(lu->qdev.conf.blk);
aio_context_acquire(ctx);
if (!blkconf_blocksizes(&lu->qdev.conf, errp)) {
goto out;
}
ctx = blk_get_aio_context(lu->qdev.conf.blk);
aio_context_acquire(ctx);
if (!blkconf_blocksizes(&lu->qdev.conf, errp)) {
goto out;
}

lu->qdev.blocksize = UFS_BLOCK_SIZE;
blk_get_geometry(lu->qdev.conf.blk, &nb_sectors);
nb_blocks = nb_sectors / (lu->qdev.blocksize / BDRV_SECTOR_SIZE);
Expand All @@ -1367,10 +1366,9 @@ static void ufs_lu_realize(SCSIDevice *dev, Error **errp)
}

ufs_lu_brdv_init(lu, errp);

out:
if (ctx) {
aio_context_release(ctx);
}
aio_context_release(ctx);
}

static void ufs_lu_unrealize(SCSIDevice *dev)
Expand Down
10 changes: 5 additions & 5 deletions hw/ufs/ufs.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static void ufs_irq_check(UfsHc *u)

static void ufs_process_db(UfsHc *u, uint32_t val)
{
unsigned long doorbell;
DECLARE_BITMAP(doorbell, UFS_MAX_NUTRS);
uint32_t slot;
uint32_t nutrs = u->params.nutrs;
UfsRequest *req;
Expand All @@ -268,8 +268,8 @@ static void ufs_process_db(UfsHc *u, uint32_t val)
return;
}

doorbell = val;
slot = find_first_bit(&doorbell, nutrs);
doorbell[0] = val;
slot = find_first_bit(doorbell, nutrs);

while (slot < nutrs) {
req = &u->req_list[slot];
Expand All @@ -285,7 +285,7 @@ static void ufs_process_db(UfsHc *u, uint32_t val)

trace_ufs_process_db(slot);
req->state = UFS_REQUEST_READY;
slot = find_next_bit(&doorbell, nutrs, slot + 1);
slot = find_next_bit(doorbell, nutrs, slot + 1);
}

qemu_bh_schedule(u->doorbell_bh);
Expand Down Expand Up @@ -838,7 +838,7 @@ static QueryRespCode ufs_read_unit_desc(UfsRequest *req)
uint8_t lun = req->req_upiu.qr.index;

if (lun != UFS_UPIU_RPMB_WLUN &&
(lun > UFS_MAX_LUS || u->lus[lun] == NULL)) {
(lun >= UFS_MAX_LUS || u->lus[lun] == NULL)) {
trace_ufs_err_query_invalid_index(req->req_upiu.qr.opcode, lun);
return UFS_QUERY_RESULT_INVALID_INDEX;
}
Expand Down
4 changes: 2 additions & 2 deletions include/block/ufs.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ REG32(UECT, offsetof(UfsReg, uect))
REG32(UECDME, offsetof(UfsReg, uecdme))
REG32(UTRIACR, offsetof(UfsReg, utriacr))
REG32(UTRLBA, offsetof(UfsReg, utrlba))
FIELD(UTRLBA, UTRLBA, 9, 22)
FIELD(UTRLBA, UTRLBA, 10, 22)
REG32(UTRLBAU, offsetof(UfsReg, utrlbau))
REG32(UTRLDBR, offsetof(UfsReg, utrldbr))
REG32(UTRLCLR, offsetof(UfsReg, utrlclr))
REG32(UTRLRSR, offsetof(UfsReg, utrlrsr))
REG32(UTRLCNR, offsetof(UfsReg, utrlcnr))
REG32(UTMRLBA, offsetof(UfsReg, utmrlba))
FIELD(UTMRLBA, UTMRLBA, 9, 22)
FIELD(UTMRLBA, UTMRLBA, 10, 22)
REG32(UTMRLBAU, offsetof(UfsReg, utmrlbau))
REG32(UTMRLDBR, offsetof(UfsReg, utmrldbr))
REG32(UTMRLCLR, offsetof(UfsReg, utmrlclr))
Expand Down
2 changes: 1 addition & 1 deletion tests/qtest/ufs-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ static void ufstest_read_write(void *obj, void *data, QGuestAllocator *alloc)
g_assert_cmpuint(block_size, ==, 4096);

/* Write data */
memset(write_buf, rand() % 255 + 1, block_size);
memset(write_buf, 0xab, block_size);
ufs_send_scsi_command(ufs, 0, 1, write_cdb, write_buf, block_size, NULL, 0,
&utrd, &rsp_upiu);
g_assert_cmpuint(le32_to_cpu(utrd.header.dword_2), ==, UFS_OCS_SUCCESS);
Expand Down

0 comments on commit 4395a47

Please sign in to comment.