Re: [PATCH] hw/sd/sdcard: Fix calculation of size when using eMMC boot partitions
On 2/11/24 12:06, Cédric Le Goater wrote: Philippe, I can take this patch through the aspeed branch. I missed this patch because it was deeply buried in a long thread. Since you mentioned this feature will be reworked in the next cycle: Acked-by: Philippe Mathieu-Daudé Thanks, C. On 10/28/24 17:23, Jan Luebbe wrote: The sd_bootpart_offset() function calculates the *runtime* offset which changes as the guest switches between accessing the main user data area and the boot partitions by writing to the EXT_CSD_PART_CONFIG_ACC_MASK bits, so it shouldn't be used to calculate the main user data area size. Instead, subtract the boot_part_size directly (twice, as there are two identical boot partitions defined by the eMMC spec). Suggested-by: Cédric Le Goater Signed-off-by: Jan Luebbe ---> hw/sd/sd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2d3467c3d956..8430d5ae361c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -826,7 +826,9 @@ static void sd_reset(DeviceState *dev) sect = 0; } size = sect << HWBLOCK_SHIFT; - size -= sd_bootpart_offset(sd); + if (sd_is_emmc(sd)) { + size -= sd->boot_part_size * 2; + } sect = sd_addr_to_wpnum(size) + 1;
[PULL 2/3] hw/nvme: add NPDAL/NPDGL
From: Ayush Mishra Add the NPDGL and NPDAL fields to support large alignment and granularities. Signed-off-by: Ayush Mishra Reviewed-by: Klaus Jensen Link: https://lore.kernel.org/r/20241001012833.3551820-1-ayush@samsung.com [k.jensen: renamed the enum values] Signed-off-by: Klaus Jensen --- hw/nvme/ns.c | 5 - include/block/nvme.h | 17 - 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index 6dbdcb49bfc1..526e15aa8018 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -30,6 +30,7 @@ void nvme_ns_init_format(NvmeNamespace *ns) { NvmeIdNs *id_ns = &ns->id_ns; +NvmeIdNsNvm *id_ns_nvm = &ns->id_ns_nvm; BlockDriverInfo bdi; int npdg, ret; int64_t nlbas; @@ -55,6 +56,8 @@ void nvme_ns_init_format(NvmeNamespace *ns) } id_ns->npda = id_ns->npdg = npdg - 1; +id_ns_nvm->npdal = npdg; +id_ns_nvm->npdgl = npdg; } static int nvme_ns_init(NvmeNamespace *ns, Error **errp) @@ -73,7 +76,7 @@ static int nvme_ns_init(NvmeNamespace *ns, Error **errp) ns->id_ns.dlfeat = 0x1; /* support DULBE and I/O optimization fields */ -id_ns->nsfeat |= (0x4 | 0x10); +id_ns->nsfeat |= (NVME_ID_NS_NSFEAT_DAE | NVME_ID_NS_NSFEAT_OPTPERF_ALL); if (ns->params.shared) { id_ns->nmic |= NVME_ID_NS_IND_NMIC_SHRNS; diff --git a/include/block/nvme.h b/include/block/nvme.h index 39955a63455f..f4d108841bf5 100644 --- a/include/block/nvme.h +++ b/include/block/nvme.h @@ -1418,7 +1418,12 @@ typedef struct QEMU_PACKED NvmeIdNsNvm { uint8_t pic; uint8_t rsvd9[3]; uint32_telbaf[NVME_MAX_NLBAF]; -uint8_t rsvd268[3828]; +uint32_tnpdgl; +uint32_tnprg; +uint32_tnpra; +uint32_tnors; +uint32_tnpdal; +uint8_t rsvd288[3808]; } NvmeIdNsNvm; typedef struct QEMU_PACKED NvmeIdNsInd { @@ -1536,6 +1541,16 @@ enum NvmeIdNsMc { NVME_ID_NS_MC_SEPARATE = 1 << 1, }; +enum NvmeIdNsNsfeat { +NVME_ID_NS_NSFEAT_THINP = 1 << 0, +NVME_ID_NS_NSFEAT_NSABPNS = 1 << 1, +NVME_ID_NS_NSFEAT_DAE = 1 << 2, +NVME_ID_NS_NSFEAT_UIDREUSE = 1 << 3, +NVME_ID_NS_NSFEAT_OPTPERF_ALL = 3 << 4, +NVME_ID_NS_NSFEAT_MAM = 1 << 6, +NVME_ID_NS_NSFEAT_OPTRPERF = 1 << 7, +}; + #define NVME_ID_NS_DPS_TYPE(dps) (dps & NVME_ID_NS_DPS_TYPE_MASK) enum NvmePIFormat { -- 2.45.2
[PULL 1/3] hw/nvme: i/o cmd set independent namespace data structure
From: Arun Kumar Add support for the I/O Command Set Independent Namespace Data Structure (CNS 8h and 1fh). Signed-off-by: Arun Kumar Reviewed-by: Klaus Jensen Link: https://lore.kernel.org/r/20240925004407.3521406-1-arun@samsung.com Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 31 +++ hw/nvme/ns.c | 6 +- hw/nvme/nvme.h | 1 + hw/nvme/trace-events | 1 + include/block/nvme.h | 23 +-- 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index f4e89203c1a6..8e4612e03567 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -5692,6 +5692,33 @@ static uint16_t nvme_identify_sec_ctrl_list(NvmeCtrl *n, NvmeRequest *req) return nvme_c2h(n, (uint8_t *)&list, sizeof(list), req); } +static uint16_t nvme_identify_ns_ind(NvmeCtrl *n, NvmeRequest *req, bool alloc) +{ +NvmeNamespace *ns; +NvmeIdentify *c = (NvmeIdentify *)&req->cmd; +uint32_t nsid = le32_to_cpu(c->nsid); + +trace_pci_nvme_identify_ns_ind(nsid); + +if (!nvme_nsid_valid(n, nsid) || nsid == NVME_NSID_BROADCAST) { +return NVME_INVALID_NSID | NVME_DNR; +} + +ns = nvme_ns(n, nsid); +if (unlikely(!ns)) { +if (alloc) { +ns = nvme_subsys_ns(n->subsys, nsid); +if (!ns) { +return nvme_rpt_empty_id_struct(n, req); +} +} else { +return nvme_rpt_empty_id_struct(n, req); +} +} + +return nvme_c2h(n, (uint8_t *)&ns->id_ns_ind, sizeof(NvmeIdNsInd), req); +} + static uint16_t nvme_identify_ns_csi(NvmeCtrl *n, NvmeRequest *req, bool active) { @@ -5946,6 +5973,10 @@ static uint16_t nvme_identify(NvmeCtrl *n, NvmeRequest *req) return nvme_identify_sec_ctrl_list(n, req); case NVME_ID_CNS_CS_NS: return nvme_identify_ns_csi(n, req, true); +case NVME_ID_CNS_CS_IND_NS: +return nvme_identify_ns_ind(n, req, false); +case NVME_ID_CNS_CS_IND_NS_ALLOCATED: +return nvme_identify_ns_ind(n, req, true); case NVME_ID_CNS_CS_NS_PRESENT: return nvme_identify_ns_csi(n, req, false); case NVME_ID_CNS_CTRL: diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index ea8db175dbd1..6dbdcb49bfc1 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -62,6 +62,7 @@ static int nvme_ns_init(NvmeNamespace *ns, Error **errp) static uint64_t ns_count; NvmeIdNs *id_ns = &ns->id_ns; NvmeIdNsNvm *id_ns_nvm = &ns->id_ns_nvm; +NvmeIdNsInd *id_ns_ind = &ns->id_ns_ind; uint8_t ds; uint16_t ms; int i; @@ -75,7 +76,9 @@ static int nvme_ns_init(NvmeNamespace *ns, Error **errp) id_ns->nsfeat |= (0x4 | 0x10); if (ns->params.shared) { -id_ns->nmic |= NVME_NMIC_NS_SHARED; +id_ns->nmic |= NVME_ID_NS_IND_NMIC_SHRNS; +id_ns_ind->nmic = NVME_ID_NS_IND_NMIC_SHRNS; +id_ns_ind->nstat = NVME_ID_NS_IND_NSTAT_NRDY; } /* Substitute a missing EUI-64 by an autogenerated one */ @@ -770,6 +773,7 @@ static void nvme_ns_realize(DeviceState *dev, Error **errp) subsys->namespaces[nsid] = ns; ns->id_ns.endgid = cpu_to_le16(0x1); +ns->id_ns_ind.endgrpid = cpu_to_le16(0x1); if (ns->params.detached) { return; diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h index 7566b316d12d..724220691057 100644 --- a/hw/nvme/nvme.h +++ b/hw/nvme/nvme.h @@ -233,6 +233,7 @@ typedef struct NvmeNamespace { int64_t moff; NvmeIdNs id_ns; NvmeIdNsNvm id_ns_nvm; +NvmeIdNsInd id_ns_ind; NvmeLBAF lbaf; unsigned int nlbaf; size_t lbasz; diff --git a/hw/nvme/trace-events b/hw/nvme/trace-events index 3a67680c6ad1..6be0bfa1c1fc 100644 --- a/hw/nvme/trace-events +++ b/hw/nvme/trace-events @@ -56,6 +56,7 @@ pci_nvme_identify(uint16_t cid, uint8_t cns, uint16_t ctrlid, uint8_t csi) "cid pci_nvme_identify_ctrl(void) "identify controller" pci_nvme_identify_ctrl_csi(uint8_t csi) "identify controller, csi=0x%"PRIx8"" pci_nvme_identify_ns(uint32_t ns) "nsid %"PRIu32"" +pci_nvme_identify_ns_ind(uint32_t nsid) "nsid %"PRIu32"" pci_nvme_identify_ctrl_list(uint8_t cns, uint16_t cntid) "cns 0x%"PRIx8" cntid %"PRIu16"" pci_nvme_identify_pri_ctrl_cap(uint16_t cntlid) "identify primary controller capabilities cntlid=%"PRIu16"" pci_nvme_identify_sec_ctrl_list(uint16_t cntlid, uint8_t numcntl) "identify secondary controller list cntlid=%"PRIu16" numcntl=%"PRIu8"" diff --git a/include/block/nvme.h b/include/block/nvme.h index a37be0d0da8e..39955a63455f 100644 --- a/include/block/nvme.h +++ b/include/block/nvme.h @@ -1077,6 +1077,7 @@ enum NvmeIdCns { NVME_ID_CNS_CS_NS = 0x05, NVME_ID_CNS_CS_CTRL = 0x06, NVME_ID_CNS_CS_NS_ACTIVE_LIST = 0x07, +NVME_ID_CNS_CS_IND_NS = 0x08, NVME_ID_CNS_NS_PRESENT_LIST = 0x10, NVME_ID_CNS_NS_PRESENT= 0x11,
[PULL 3/3] hw/nvme: remove dead code
From: Arun Kumar Remove dead code which always returns success, since PRCHK will have a value of zero. Signed-off-by: Arun Kumar Reviewed-by: Klaus Jensen Link: https://lore.kernel.org/r/2024102105.3609223-1-arun@samsung.com Signed-off-by: Klaus Jensen --- hw/nvme/dif.c | 5 - 1 file changed, 5 deletions(-) diff --git a/hw/nvme/dif.c b/hw/nvme/dif.c index 01b19c33734e..28051284984d 100644 --- a/hw/nvme/dif.c +++ b/hw/nvme/dif.c @@ -575,11 +575,6 @@ uint16_t nvme_dif_rw(NvmeCtrl *n, NvmeRequest *req) uint8_t *mbuf, *end; int16_t pil = ns->lbaf.ms - nvme_pi_tuple_size(ns); -status = nvme_check_prinfo(ns, prinfo, slba, reftag); -if (status) { -goto err; -} - flags = 0; ctx->mdata.bounce = g_malloc0(mlen); -- 2.45.2
Re: [PATCH v2] hw/nvme: fix handling of over-committed queues
On Oct 29 13:15, Klaus Jensen wrote: > From: Klaus Jensen > > If a host chooses to use the SQHD "hint" in the CQE to know if there is > room in the submission queue for additional commands, it may result in a > situation where there are not enough internal resources (struct > NvmeRequest) available to process the command. For a lack of a better > term, the host may "over-commit" the device (i.e., it may have more > inflight commands than the queue size). > > For example, assume a queue with N entries. The host submits N commands > and all are picked up for processing, advancing the head and emptying > the queue. Regardless of which of these N commands complete first, the > SQHD field of that CQE will indicate to the host that the queue is > empty, which allows the host to issue N commands again. However, if the > device has not posted CQEs for all the previous commands yet, the device > will have less than N resources available to process the commands, so > queue processing is suspended. > > And here lies an 11 year latent bug. In the absense of any additional > tail updates on the submission queue, we never schedule the processing > bottom-half again unless we observe a head update on an associated full > completion queue. This has been sufficient to handle N-to-1 SQ/CQ setups > (in the absense of over-commit of course). Incidentially, that "kick all > associated SQs" mechanism can now be killed since we now just schedule > queue processing when we return a processing resource to a non-empty > submission queue, which happens to cover both edge cases. However, we > must retain kicking the CQ if it was previously full. > > So, apparently, no previous driver tested with hw/nvme has ever used > SQHD (e.g., neither the Linux NVMe driver or SPDK uses it). But then OSv > shows up with the driver that actually does. I salute you. > > Fixes: f3c507adcd7b ("NVMe: Initial commit for new storage interface") > Cc: qemu-sta...@nongnu.org > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2388 > Reported-by: Waldemar Kozaczuk > Signed-off-by: Klaus Jensen > --- > Changes in v2: > - Retain cq kick on previously full queue > - Link to v1: > https://lore.kernel.org/r/20241025-issue-2388-v1-1-16707e0d3...@samsung.com > --- > hw/nvme/ctrl.c | 25 ++--- > 1 file changed, 14 insertions(+), 11 deletions(-) > > diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c > index > f4e89203c1a6e3b051fd7185cbf01ec9bae9684a..1185455a94c4af43a39708b1b97dba9624fc7ad3 > 100644 > --- a/hw/nvme/ctrl.c > +++ b/hw/nvme/ctrl.c > @@ -1520,9 +1520,16 @@ static void nvme_post_cqes(void *opaque) > stl_le_p(&n->bar.csts, NVME_CSTS_FAILED); > break; > } > + > QTAILQ_REMOVE(&cq->req_list, req, entry); > + > nvme_inc_cq_tail(cq); > nvme_sg_unmap(&req->sg); > + > +if (QTAILQ_EMPTY(&sq->req_list) && !nvme_sq_empty(sq)) { > +qemu_bh_schedule(sq->bh); > +} > + > QTAILQ_INSERT_TAIL(&sq->req_list, req, entry); > } > if (cq->tail != cq->head) { > @@ -7950,7 +7957,6 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr, > int val) > /* Completion queue doorbell write */ > > uint16_t new_head = val & 0x; > -int start_sqs; > NvmeCQueue *cq; > > qid = (addr - (0x1000 + (1 << 2))) >> 3; > @@ -8001,19 +8007,16 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr, > int val) > > trace_pci_nvme_mmio_doorbell_cq(cq->cqid, new_head); > > -start_sqs = nvme_cq_full(cq) ? 1 : 0; > -cq->head = new_head; > -if (!qid && n->dbbuf_enabled) { > -stl_le_pci_dma(pci, cq->db_addr, cq->head, > MEMTXATTRS_UNSPECIFIED); > -} > -if (start_sqs) { > -NvmeSQueue *sq; > -QTAILQ_FOREACH(sq, &cq->sq_list, entry) { > -qemu_bh_schedule(sq->bh); > -} > +/* scheduled deferred cqe posting if queue was previously full */ > +if (nvme_cq_full(cq)) { > qemu_bh_schedule(cq->bh); > } > > +cq->head = new_head; > +if (!qid && n->dbbuf_enabled) { > +stl_le_pci_dma(pci, cq->db_addr, cq->head, > MEMTXATTRS_UNSPECIFIED); > +} > + > if (cq->tail == cq->head) { > if (cq->irq_enabled) { > n->cq_pending--; > > --- > base-commit: fdf250e5a37830615e324017cb3a503e84b3712c > change-id: 20241025-issue-2388-bd047487f74c > > Best regards, > -- > Klaus Jensen > Ping. Tested, but would appreciate a review ;) signature.asc Description: PGP signature
Re: [PATCH v2] hw/nvme: fix handling of over-committed queues
On Tue, Oct 29, 2024 at 01:15:19PM +0100, Klaus Jensen wrote: > From: Klaus Jensen > > If a host chooses to use the SQHD "hint" in the CQE to know if there is > room in the submission queue for additional commands, it may result in a > situation where there are not enough internal resources (struct > NvmeRequest) available to process the command. For a lack of a better > term, the host may "over-commit" the device (i.e., it may have more > inflight commands than the queue size). > > ... LGTM Reviewed-by: Keith Busch
Re: [PATCH v2] hw/nvme: fix handling of over-committed queues
I have run my tests on the OSv side with small queue sizes like 3,4,5 and I could NOT replicate the issue. So it looks like the V2 version of this patch fixes the problem. Thanks a lot, Waldemar Kozaczuk On Mon, Nov 4, 2024 at 1:57 PM Keith Busch wrote: > On Tue, Oct 29, 2024 at 01:15:19PM +0100, Klaus Jensen wrote: > > From: Klaus Jensen > > > > If a host chooses to use the SQHD "hint" in the CQE to know if there is > > room in the submission queue for additional commands, it may result in a > > situation where there are not enough internal resources (struct > > NvmeRequest) available to process the command. For a lack of a better > > term, the host may "over-commit" the device (i.e., it may have more > > inflight commands than the queue size). > > > > ... > > LGTM > > Reviewed-by: Keith Busch >
[PULL 23/65] qapi: introduce device-sync-config
From: Vladimir Sementsov-Ogievskiy Add command to sync config from vhost-user backend to the device. It may be helpful when VHOST_USER_SLAVE_CONFIG_CHANGE_MSG failed or not triggered interrupt to the guest or just not available (not supported by vhost-user server). Command result is racy if allow it during migration. Let's not allow that. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Markus Armbruster Acked-by: Raphael Norwitz Message-Id: <20240920094936.450987-4-vsement...@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/qdev.json| 24 include/hw/qdev-core.h| 6 ++ hw/block/vhost-user-blk.c | 1 + hw/virtio/virtio-pci.c| 9 + system/qdev-monitor.c | 38 ++ 5 files changed, 78 insertions(+) diff --git a/qapi/qdev.json b/qapi/qdev.json index 53d147c7b4..2a581129c9 100644 --- a/qapi/qdev.json +++ b/qapi/qdev.json @@ -163,3 +163,27 @@ ## { 'event': 'DEVICE_UNPLUG_GUEST_ERROR', 'data': { '*device': 'str', 'path': 'str' } } + +## +# @device-sync-config: +# +# Synchronize device configuration from host to guest part. First, +# copy the configuration from the host part (backend) to the guest +# part (frontend). Then notify guest software that device +# configuration changed. +# +# The command may be used to notify the guest about block device +# capcity change. Currently only vhost-user-blk device supports +# this. +# +# @id: the device's ID or QOM path +# +# Features: +# +# @unstable: The command is experimental. +# +# Since: 9.1 +## +{ 'command': 'device-sync-config', + 'features': [ 'unstable' ], + 'data': {'id': 'str'} } diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index aa97c34a4b..94914858d8 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -95,6 +95,7 @@ typedef void (*DeviceUnrealize)(DeviceState *dev); typedef void (*DeviceReset)(DeviceState *dev); typedef void (*BusRealize)(BusState *bus, Error **errp); typedef void (*BusUnrealize)(BusState *bus); +typedef int (*DeviceSyncConfig)(DeviceState *dev, Error **errp); /** * struct DeviceClass - The base class for all devices. @@ -103,6 +104,9 @@ typedef void (*BusUnrealize)(BusState *bus); * property is changed to %true. * @unrealize: Callback function invoked when the #DeviceState:realized * property is changed to %false. + * @sync_config: Callback function invoked when QMP command device-sync-config + * is called. Should synchronize device configuration from host to guest part + * and notify the guest about the change. * @hotpluggable: indicates if #DeviceClass is hotpluggable, available * as readonly "hotpluggable" property of #DeviceState instance * @@ -162,6 +166,7 @@ struct DeviceClass { DeviceReset legacy_reset; DeviceRealize realize; DeviceUnrealize unrealize; +DeviceSyncConfig sync_config; /** * @vmsd: device state serialisation description for @@ -547,6 +552,7 @@ bool qdev_hotplug_allowed(DeviceState *dev, Error **errp); */ HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev); void qdev_unplug(DeviceState *dev, Error **errp); +int qdev_sync_config(DeviceState *dev, Error **errp); void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); void qdev_machine_creation_done(void); diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 48b3dabb8d..7996e49821 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -591,6 +591,7 @@ static void vhost_user_blk_class_init(ObjectClass *klass, void *data) device_class_set_props(dc, vhost_user_blk_properties); dc->vmsd = &vmstate_vhost_user_blk; +dc->sync_config = vhost_user_blk_sync_config; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); vdc->realize = vhost_user_blk_device_realize; vdc->unrealize = vhost_user_blk_device_unrealize; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 4d832fe845..c5a809b956 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -2385,6 +2385,14 @@ static void virtio_pci_dc_realize(DeviceState *qdev, Error **errp) vpciklass->parent_dc_realize(qdev, errp); } +static int virtio_pci_sync_config(DeviceState *dev, Error **errp) +{ +VirtIOPCIProxy *proxy = VIRTIO_PCI(dev); +VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); + +return qdev_sync_config(DEVICE(vdev), errp); +} + static void virtio_pci_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -2401,6 +2409,7 @@ static void virtio_pci_class_init(ObjectClass *klass, void *data) device_class_set_parent_realize(dc, virtio_pci_dc_realize, &vpciklass->parent_dc_realize); rc->phases.hold = virtio_pci_bus_reset_hold; +dc->sync_config = virtio_pci_sync_config; } static const TypeInfo
[PULL 22/65] vhost-user-blk: split vhost_user_blk_sync_config()
From: Vladimir Sementsov-Ogievskiy Split vhost_user_blk_sync_config() out from vhost_user_blk_handle_config_change(), to be reused in the following commit. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Raphael Norwitz Message-Id: <20240920094936.450987-3-vsement...@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefano Garzarella --- hw/block/vhost-user-blk.c | 26 +++--- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 5b7f46bbb0..48b3dabb8d 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -90,27 +90,39 @@ static void vhost_user_blk_set_config(VirtIODevice *vdev, const uint8_t *config) s->blkcfg.wce = blkcfg->wce; } +static int vhost_user_blk_sync_config(DeviceState *dev, Error **errp) +{ +int ret; +VirtIODevice *vdev = VIRTIO_DEVICE(dev); +VHostUserBlk *s = VHOST_USER_BLK(vdev); + +ret = vhost_dev_get_config(&s->dev, (uint8_t *)&s->blkcfg, + vdev->config_len, errp); +if (ret < 0) { +return ret; +} + +memcpy(vdev->config, &s->blkcfg, vdev->config_len); +virtio_notify_config(vdev); + +return 0; +} + static int vhost_user_blk_handle_config_change(struct vhost_dev *dev) { int ret; -VirtIODevice *vdev = dev->vdev; -VHostUserBlk *s = VHOST_USER_BLK(dev->vdev); Error *local_err = NULL; if (!dev->started) { return 0; } -ret = vhost_dev_get_config(dev, (uint8_t *)&s->blkcfg, - vdev->config_len, &local_err); +ret = vhost_user_blk_sync_config(DEVICE(dev->vdev), &local_err); if (ret < 0) { error_report_err(local_err); return ret; } -memcpy(dev->vdev->config, &s->blkcfg, vdev->config_len); -virtio_notify_config(dev->vdev); - return 0; } -- MST
Re: [PATCH v4 15/26] hw/net/fsl_etsec/miim: Reuse MII constants
On 2024/11/03 22:34, Bernhard Beschow wrote: Instead of defining redundant constants and using magic numbers reuse the existing MII constants. Signed-off-by: Bernhard Beschow cc: Akihiko Odaki Reviewed-by: Akihiko Odaki
Re: [PATCH v1 6/8] hw/sd/aspeed_sdhci: Introduce Capabilities Register 2 for SD slot 0 and 1
On 29/10/24 06:17, Jamin Lin wrote: The size of SDHCI capabilities register is 64bits, so introduces new Capabilities Register 2 for SD slot 0 (0x144) and SD slot1 (0x244). Signed-off-by: Jamin Lin --- hw/sd/aspeed_sdhci.c | 40 +--- 1 file changed, 29 insertions(+), 11 deletions(-) Reviewed-by: Philippe Mathieu-Daudé
Re: [PATCH v4 22/26] hw/i2c/smbus_eeprom: Prefer DEFINE_TYPES() macro
On Sun, Nov 03, 2024 at 02:34:08PM +0100, Bernhard Beschow wrote: > Reviewed-by: Cédric Le Goater > Signed-off-by: Bernhard Beschow Yeah, I think this is best. Acked-by: Corey Minyard > --- > hw/i2c/smbus_eeprom.c | 19 --- > 1 file changed, 8 insertions(+), 11 deletions(-) > > diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c > index 9e62c27a1a..e3e96d4a2d 100644 > --- a/hw/i2c/smbus_eeprom.c > +++ b/hw/i2c/smbus_eeprom.c > @@ -151,19 +151,16 @@ static void smbus_eeprom_class_initfn(ObjectClass > *klass, void *data) > dc->user_creatable = false; > } > > -static const TypeInfo smbus_eeprom_info = { > -.name = TYPE_SMBUS_EEPROM, > -.parent= TYPE_SMBUS_DEVICE, > -.instance_size = sizeof(SMBusEEPROMDevice), > -.class_init= smbus_eeprom_class_initfn, > +static const TypeInfo smbus_eeprom_types[] = { > +{ > +.name = TYPE_SMBUS_EEPROM, > +.parent= TYPE_SMBUS_DEVICE, > +.instance_size = sizeof(SMBusEEPROMDevice), > +.class_init= smbus_eeprom_class_initfn, > +}, > }; > > -static void smbus_eeprom_register_types(void) > -{ > -type_register_static(&smbus_eeprom_info); > -} > - > -type_init(smbus_eeprom_register_types) > +DEFINE_TYPES(smbus_eeprom_types) > > void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t > *eeprom_buf) > { > -- > 2.47.0 > >
Re: [PATCH v4 12/26] hw/i2c/mpc_i2c: Prefer DEFINE_TYPES() macro
On Sun, Nov 03, 2024 at 02:33:58PM +0100, Bernhard Beschow wrote: > Reviewed-by: Cédric Le Goater > Signed-off-by: Bernhard Beschow Acked-by: Corey Minyard > --- > hw/i2c/mpc_i2c.c | 20 > 1 file changed, 8 insertions(+), 12 deletions(-) > > diff --git a/hw/i2c/mpc_i2c.c b/hw/i2c/mpc_i2c.c > index 3d79c15653..913d044ac1 100644 > --- a/hw/i2c/mpc_i2c.c > +++ b/hw/i2c/mpc_i2c.c > @@ -20,7 +20,6 @@ > #include "qemu/osdep.h" > #include "hw/i2c/i2c.h" > #include "hw/irq.h" > -#include "qemu/module.h" > #include "hw/sysbus.h" > #include "migration/vmstate.h" > #include "qom/object.h" > @@ -345,16 +344,13 @@ static void mpc_i2c_class_init(ObjectClass *klass, void > *data) > dc->desc = "MPC I2C Controller"; > } > > -static const TypeInfo mpc_i2c_type_info = { > -.name = TYPE_MPC_I2C, > -.parent= TYPE_SYS_BUS_DEVICE, > -.instance_size = sizeof(MPCI2CState), > -.class_init= mpc_i2c_class_init, > +static const TypeInfo mpc_i2c_types[] = { > +{ > +.name = TYPE_MPC_I2C, > +.parent= TYPE_SYS_BUS_DEVICE, > +.instance_size = sizeof(MPCI2CState), > +.class_init= mpc_i2c_class_init, > +}, > }; > > -static void mpc_i2c_register_types(void) > -{ > -type_register_static(&mpc_i2c_type_info); > -} > - > -type_init(mpc_i2c_register_types) > +DEFINE_TYPES(mpc_i2c_types) > -- > 2.47.0 > >