Hi, > @@ -203,8 +202,10 @@ struct XHCIState { > uint32_t numslots; > uint32_t flags; > uint32_t max_pstreams_mask; > - OnOffAuto msi; > - OnOffAuto msix; > + void (*intr_update)(XHCIState *s, int n, bool enable); > + void (*intr_raise)(XHCIState *s, int n, bool level); > + void (*vmstate_post_load)(XHCIState *xhci);
No need to create your own post_load hook, there is one in VMStateDescription ready for use ;) take care, Gerd [ I can squash that into 3/7 if you have no objections ] diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h index 294bdc62aeaf..f859a17e73ee 100644 --- a/hw/usb/hcd-xhci.h +++ b/hw/usb/hcd-xhci.h @@ -205,7 +205,6 @@ typedef struct XHCIState { uint32_t max_pstreams_mask; void (*intr_update)(XHCIState *s, int n, bool enable); void (*intr_raise)(XHCIState *s, int n, bool level); - void (*vmstate_post_load)(XHCIState *xhci); DeviceState *hostOpaque; /* Operational Registers */ diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c index f06a2b7f4c57..77608fb78def 100644 --- a/hw/usb/hcd-xhci-pci.c +++ b/hw/usb/hcd-xhci-pci.c @@ -85,19 +85,21 @@ static void xhci_pci_reset(DeviceState *dev) device_legacy_reset(DEVICE(&s->xhci)); } -static void xhci_pci_vmstate_post_load(XHCIState *xhci) +static int xhci_pci_post_load(void *opaque, int version_id) { - XHCIPciState *s = container_of(xhci, XHCIPciState, xhci); + XHCIPciState *s = opaque; + XHCIState *xhci = &s->xhci; PCIDevice *pci_dev = PCI_DEVICE(s); int intr; - for (intr = 0; intr < xhci->numintrs; intr++) { + for (intr = 0; intr < xhci->numintrs; intr++) { if (xhci->intr[intr].msix_used) { msix_vector_use(pci_dev, intr); } else { msix_vector_unuse(pci_dev, intr); } } + return 0; } static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp) @@ -114,7 +116,6 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp) object_property_set_link(OBJECT(&s->xhci), "host", OBJECT(s), NULL); s->xhci.intr_update = xhci_pci_intr_update; s->xhci.intr_raise = xhci_pci_intr_raise; - s->xhci.vmstate_post_load = xhci_pci_vmstate_post_load; object_property_set_bool(OBJECT(&s->xhci), "realized", true, &err); if (err) { error_propagate(errp, err); @@ -176,6 +177,7 @@ static void usb_xhci_pci_exit(PCIDevice *dev) static const VMStateDescription vmstate_xhci_pci = { .name = "xhci", .version_id = 1, + .post_load = xhci_pci_post_load, .fields = (VMStateField[]) { VMSTATE_PCI_DEVICE(parent_obj, XHCIPciState), VMSTATE_MSIX(parent_obj, XHCIPciState), diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 4a6c0e7edb1a..b1b95abb9b29 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -3457,9 +3457,6 @@ static int usb_xhci_post_load(void *opaque, int version_id) } } - if (xhci->vmstate_post_load) { - xhci->vmstate_post_load(xhci); - } return 0; }