From: "Michael S. Tsirkin" <mst@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 5/6] xhci: add vmstate
Date: Tue, 7 May 2013 17:06:01 +0300 [thread overview]
Message-ID: <20130507140601.GB22422@redhat.com> (raw)
In-Reply-To: <1367933676-21854-6-git-send-email-kraxel@redhat.com>
On Tue, May 07, 2013 at 03:34:35PM +0200, Gerd Hoffmann wrote:
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> hw/usb/hcd-xhci.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 144 insertions(+), 1 deletion(-)
>
> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
> index 9b90067..426478c 100644
> --- a/hw/usb/hcd-xhci.c
> +++ b/hw/usb/hcd-xhci.c
> @@ -3386,9 +3386,152 @@ static int usb_xhci_initfn(struct PCIDevice *dev)
> return 0;
> }
>
> +static int usb_xhci_post_load(void *opaque, int version_id)
> +{
> + XHCIState *xhci = opaque;
> + XHCISlot *slot;
> + XHCIEPContext *epctx;
> + dma_addr_t dcbaap, pctx;
> + uint32_t slot_ctx[4];
> + uint32_t ep_ctx[5];
> + int slotid, epid, state, intr;
> +
> + dcbaap = xhci_addr64(xhci->dcbaap_low, xhci->dcbaap_high);
> +
> + for (slotid = 1; slotid <= xhci->numslots; slotid++) {
> + slot = &xhci->slots[slotid-1];
> + if (!slot->addressed) {
> + continue;
> + }
> + slot->ctx =
> + xhci_mask64(ldq_le_pci_dma(&xhci->pci_dev, dcbaap + 8*slotid));
> + xhci_dma_read_u32s(xhci, slot->ctx, slot_ctx, sizeof(slot_ctx));
> + slot->uport = xhci_lookup_uport(xhci, slot_ctx);
> + assert(slot->uport && slot->uport->dev);
> +
> + for (epid = 1; epid <= 32; epid++) {
> + pctx = slot->ctx + 32 * epid;
> + xhci_dma_read_u32s(xhci, pctx, ep_ctx, sizeof(ep_ctx));
> + state = ep_ctx[0] & EP_STATE_MASK;
> + if (state == EP_DISABLED) {
> + continue;
> + }
> + epctx = xhci_alloc_epctx(xhci, slotid, epid);
> + slot->eps[epid-1] = epctx;
> + xhci_init_epctx(epctx, pctx, ep_ctx);
> + epctx->state = state;
> + if (state == EP_RUNNING) {
> + /* kick endpoint after vmload is finished */
> + qemu_mod_timer(epctx->kick_timer, qemu_get_clock_ns(vm_clock));
> + }
> + }
> + }
> +
> + for (intr = 0; intr < xhci->numintrs; intr++) {
> + if (xhci->intr[intr].msix_used) {
> + msix_vector_use(&xhci->pci_dev, intr);
> + } else {
> + msix_vector_unuse(&xhci->pci_dev, intr);
> + }
> + }
> +
> + return 0;
> +}
> +
> +static const VMStateDescription vmstate_xhci_ring = {
> + .name = "xhci-ring",
> + .version_id = 1,
> + .fields = (VMStateField[]) {
> + VMSTATE_UINT64(dequeue, XHCIRing),
> + VMSTATE_BOOL(ccs, XHCIRing),
> + VMSTATE_END_OF_LIST()
> + }
> +};
> +
> +static const VMStateDescription vmstate_xhci_port = {
> + .name = "xhci-port",
> + .version_id = 1,
> + .fields = (VMStateField[]) {
> + VMSTATE_UINT32(portsc, XHCIPort),
> + VMSTATE_END_OF_LIST()
> + }
> +};
> +
> +static const VMStateDescription vmstate_xhci_slot = {
> + .name = "xhci-slot",
> + .version_id = 1,
> + .fields = (VMStateField[]) {
> + VMSTATE_BOOL(enabled, XHCISlot),
> + VMSTATE_BOOL(addressed, XHCISlot),
> + VMSTATE_END_OF_LIST()
> + }
> +};
> +
> +static const VMStateDescription vmstate_xhci_intr = {
> + .name = "xhci-intr",
> + .version_id = 1,
> + .fields = (VMStateField[]) {
> + /* registers */
> + VMSTATE_UINT32(iman, XHCIInterrupter),
> + VMSTATE_UINT32(imod, XHCIInterrupter),
> + VMSTATE_UINT32(erstsz, XHCIInterrupter),
> + VMSTATE_UINT32(erstba_low, XHCIInterrupter),
> + VMSTATE_UINT32(erstba_high, XHCIInterrupter),
> + VMSTATE_UINT32(erdp_low, XHCIInterrupter),
> + VMSTATE_UINT32(erdp_high, XHCIInterrupter),
> +
> + /* state */
> + VMSTATE_BOOL(msix_used, XHCIInterrupter),
> + VMSTATE_BOOL(er_pcs, XHCIInterrupter),
> + VMSTATE_UINT64(er_start, XHCIInterrupter),
> + VMSTATE_UINT32(er_size, XHCIInterrupter),
> + VMSTATE_UINT32(er_ep_idx, XHCIInterrupter),
> +
> +#if 0
should have a comment explaining why is this
commented out.
Or just drop this section.
> + /* event queue (used if ring is full) */
> + VMSTATE_BOOL(er_full, XHCIInterrupter),
> + VMSTATE_UINT32(ev_buffer_put, XHCIInterrupter),
> + VMSTATE_UINT32(ev_buffer_get, XHCIInterrupter),
> + /* TODO */ XHCIEvent ev_buffer[EV_QUEUE];
> +#endif
> +
> + VMSTATE_END_OF_LIST()
> + }
> +};
> +
> static const VMStateDescription vmstate_xhci = {
> .name = "xhci",
> - .unmigratable = 1,
> + .unmigratable = 1, /* not finished yet */
> + .version_id = 1,
> + .post_load = usb_xhci_post_load,
> + .fields = (VMStateField[]) {
> + VMSTATE_PCIE_DEVICE(pci_dev, XHCIState),
> + VMSTATE_MSIX(pci_dev, XHCIState),
> +
> + VMSTATE_STRUCT_ARRAY(ports, XHCIState, MAXPORTS, 1,
> + vmstate_xhci_port, XHCIPort),
> + VMSTATE_STRUCT_ARRAY(slots, XHCIState, MAXSLOTS, 1,
> + vmstate_xhci_slot, XHCISlot),
> + VMSTATE_STRUCT_ARRAY(intr, XHCIState, MAXINTRS, 1,
> + vmstate_xhci_intr, XHCIInterrupter),
> +
> + /* Operational Registers */
> + VMSTATE_UINT32(usbcmd, XHCIState),
> + VMSTATE_UINT32(usbsts, XHCIState),
> + VMSTATE_UINT32(dnctrl, XHCIState),
> + VMSTATE_UINT32(crcr_low, XHCIState),
> + VMSTATE_UINT32(crcr_high, XHCIState),
> + VMSTATE_UINT32(dcbaap_low, XHCIState),
> + VMSTATE_UINT32(dcbaap_high, XHCIState),
> + VMSTATE_UINT32(config, XHCIState),
> +
> + /* Runtime Registers & state */
> + VMSTATE_INT64(mfindex_start, XHCIState),
> + VMSTATE_TIMER(mfwrap_timer, XHCIState),
> + VMSTATE_STRUCT(cmd_ring, XHCIState, 1, vmstate_xhci_ring, XHCIRing),
> +
> + VMSTATE_END_OF_LIST()
> + }
> };
>
> static Property xhci_properties[] = {
> --
> 1.7.9.7
>
next prev parent reply other threads:[~2013-05-07 14:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-07 13:34 [Qemu-devel] [PATCH 0/6] xhci: add live migration support Gerd Hoffmann
2013-05-07 13:34 ` [Qemu-devel] [PATCH 1/6] pci: add VMSTATE_MSIX Gerd Hoffmann
2013-05-07 14:05 ` Michael S. Tsirkin
2013-05-07 14:08 ` Gerd Hoffmann
2013-05-07 14:10 ` Michael S. Tsirkin
2013-05-07 13:34 ` [Qemu-devel] [PATCH 2/6] xhci: add XHCISlot->addressed Gerd Hoffmann
2013-05-07 13:34 ` [Qemu-devel] [PATCH 3/6] xhci: add xhci_alloc_epctx Gerd Hoffmann
2013-05-07 13:34 ` [Qemu-devel] [PATCH 4/6] xhci: add xhci_init_epctx Gerd Hoffmann
2013-05-07 13:34 ` [Qemu-devel] [PATCH 5/6] xhci: add vmstate Gerd Hoffmann
2013-05-07 14:06 ` Michael S. Tsirkin [this message]
2013-05-07 14:14 ` Gerd Hoffmann
2013-05-07 15:05 ` Michael S. Tsirkin
2013-05-07 13:34 ` [Qemu-devel] [PATCH 6/6] [debug] xhci: remove unmigratable flag Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130507140601.GB22422@redhat.com \
--to=mst@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.