|
|
9ae3a8 |
From e955b37a28ff1f10035dc9c96a083bf93e8ca895 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 7 Aug 2013 09:22:46 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 15/28] xhci: add xhci_alloc_epctx
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1375867368-18979-4-git-send-email-kraxel@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 53036
|
|
|
9ae3a8 |
O-Subject: [RHEL-7 qemu-kvm PATCH 3/5] xhci: add xhci_alloc_epctx
|
|
|
9ae3a8 |
Bugzilla: 838170
|
|
|
9ae3a8 |
RH-Acked-by: Hans de Goede <hdegoede@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Factor out endpoint context allocation to a separate function.
|
|
|
9ae3a8 |
xhci live migration will need that too, in post_load.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 492b21f63fa655e0271abef4784cc337dd1d3fe7)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/usb/hcd-xhci.c | 32 +++++++++++++++++++++-----------
|
|
|
9ae3a8 |
1 file changed, 21 insertions(+), 11 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/usb/hcd-xhci.c | 32 +++++++++++++++++++++-----------
|
|
|
9ae3a8 |
1 files changed, 21 insertions(+), 11 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
|
|
|
9ae3a8 |
index 4111e68..7f46ccc 100644
|
|
|
9ae3a8 |
--- a/hw/usb/hcd-xhci.c
|
|
|
9ae3a8 |
+++ b/hw/usb/hcd-xhci.c
|
|
|
9ae3a8 |
@@ -1198,6 +1198,26 @@ static void xhci_ep_kick_timer(void *opaque)
|
|
|
9ae3a8 |
xhci_kick_ep(epctx->xhci, epctx->slotid, epctx->epid, 0);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static XHCIEPContext *xhci_alloc_epctx(XHCIState *xhci,
|
|
|
9ae3a8 |
+ unsigned int slotid,
|
|
|
9ae3a8 |
+ unsigned int epid)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ XHCIEPContext *epctx;
|
|
|
9ae3a8 |
+ int i;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ epctx = g_new0(XHCIEPContext, 1);
|
|
|
9ae3a8 |
+ epctx->xhci = xhci;
|
|
|
9ae3a8 |
+ epctx->slotid = slotid;
|
|
|
9ae3a8 |
+ epctx->epid = epid;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ for (i = 0; i < ARRAY_SIZE(epctx->transfers); i++) {
|
|
|
9ae3a8 |
+ usb_packet_init(&epctx->transfers[i].packet);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ epctx->kick_timer = qemu_new_timer_ns(vm_clock, xhci_ep_kick_timer, epctx);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ return epctx;
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static TRBCCode xhci_enable_ep(XHCIState *xhci, unsigned int slotid,
|
|
|
9ae3a8 |
unsigned int epid, dma_addr_t pctx,
|
|
|
9ae3a8 |
uint32_t *ctx)
|
|
|
9ae3a8 |
@@ -1205,7 +1225,6 @@ static TRBCCode xhci_enable_ep(XHCIState *xhci, unsigned int slotid,
|
|
|
9ae3a8 |
XHCISlot *slot;
|
|
|
9ae3a8 |
XHCIEPContext *epctx;
|
|
|
9ae3a8 |
dma_addr_t dequeue;
|
|
|
9ae3a8 |
- int i;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
trace_usb_xhci_ep_enable(slotid, epid);
|
|
|
9ae3a8 |
assert(slotid >= 1 && slotid <= xhci->numslots);
|
|
|
9ae3a8 |
@@ -1216,12 +1235,7 @@ static TRBCCode xhci_enable_ep(XHCIState *xhci, unsigned int slotid,
|
|
|
9ae3a8 |
xhci_disable_ep(xhci, slotid, epid);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- epctx = g_malloc(sizeof(XHCIEPContext));
|
|
|
9ae3a8 |
- memset(epctx, 0, sizeof(XHCIEPContext));
|
|
|
9ae3a8 |
- epctx->xhci = xhci;
|
|
|
9ae3a8 |
- epctx->slotid = slotid;
|
|
|
9ae3a8 |
- epctx->epid = epid;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
+ epctx = xhci_alloc_epctx(xhci, slotid, epid);
|
|
|
9ae3a8 |
slot->eps[epid-1] = epctx;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
dequeue = xhci_addr64(ctx[2] & ~0xf, ctx[3]);
|
|
|
9ae3a8 |
@@ -1241,13 +1255,9 @@ static TRBCCode xhci_enable_ep(XHCIState *xhci, unsigned int slotid,
|
|
|
9ae3a8 |
xhci_ring_init(xhci, &epctx->ring, dequeue);
|
|
|
9ae3a8 |
epctx->ring.ccs = ctx[2] & 1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
- for (i = 0; i < ARRAY_SIZE(epctx->transfers); i++) {
|
|
|
9ae3a8 |
- usb_packet_init(&epctx->transfers[i].packet);
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
epctx->interval = 1 << (ctx[0] >> 16) & 0xff;
|
|
|
9ae3a8 |
epctx->mfindex_last = 0;
|
|
|
9ae3a8 |
- epctx->kick_timer = qemu_new_timer_ns(vm_clock, xhci_ep_kick_timer, epctx);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
epctx->state = EP_RUNNING;
|
|
|
9ae3a8 |
ctx[0] &= ~EP_STATE_MASK;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|