|
|
9ae3a8 |
From 36b1f983a244521a4dd7293b36b152222aa953ed Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
Date: Fri, 11 Jul 2014 14:20:44 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 10/43] xhci: Add xhci_epid_to_usbep helper function
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1405088470-24115-12-git-send-email-kraxel@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 59837
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.1 qemu-kvm PATCH 11/37] xhci: Add xhci_epid_to_usbep helper function
|
|
|
9ae3a8 |
Bugzilla: 980833
|
|
|
9ae3a8 |
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Hans de Goede <hdegoede@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
And use it instead of prying the USBEndpoint out of the packet struct
|
|
|
9ae3a8 |
in various places.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 518ad5f2a0754f0a5ce4e478b79f4926ce46111b)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/usb/hcd-xhci.c | 32 ++++++++++++++++++++++----------
|
|
|
9ae3a8 |
1 file changed, 22 insertions(+), 10 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/usb/hcd-xhci.c | 32 ++++++++++++++++++++++----------
|
|
|
9ae3a8 |
1 file changed, 22 insertions(+), 10 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
|
|
|
9ae3a8 |
index 2daf334..56145a5 100644
|
|
|
9ae3a8 |
--- a/hw/usb/hcd-xhci.c
|
|
|
9ae3a8 |
+++ b/hw/usb/hcd-xhci.c
|
|
|
9ae3a8 |
@@ -511,6 +511,8 @@ static TRBCCode xhci_disable_ep(XHCIState *xhci, unsigned int slotid,
|
|
|
9ae3a8 |
unsigned int epid);
|
|
|
9ae3a8 |
static void xhci_event(XHCIState *xhci, XHCIEvent *event, int v);
|
|
|
9ae3a8 |
static void xhci_write_event(XHCIState *xhci, XHCIEvent *event, int v);
|
|
|
9ae3a8 |
+static USBEndpoint *xhci_epid_to_usbep(XHCIState *xhci,
|
|
|
9ae3a8 |
+ unsigned int slotid, unsigned int epid);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static const char *TRBType_names[] = {
|
|
|
9ae3a8 |
[TRB_RESERVED] = "TRB_RESERVED",
|
|
|
9ae3a8 |
@@ -1363,13 +1365,12 @@ static int xhci_ep_nuke_xfers(XHCIState *xhci, unsigned int slotid,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
xferi = epctx->next_xfer;
|
|
|
9ae3a8 |
for (i = 0; i < TD_QUEUE; i++) {
|
|
|
9ae3a8 |
- if (epctx->transfers[xferi].packet.ep) {
|
|
|
9ae3a8 |
- ep = epctx->transfers[xferi].packet.ep;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
killed += xhci_ep_nuke_one_xfer(&epctx->transfers[xferi]);
|
|
|
9ae3a8 |
epctx->transfers[xferi].packet.ep = NULL;
|
|
|
9ae3a8 |
xferi = (xferi + 1) % TD_QUEUE;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ ep = xhci_epid_to_usbep(xhci, slotid, epid);
|
|
|
9ae3a8 |
if (ep) {
|
|
|
9ae3a8 |
usb_device_ep_stopped(ep->dev, ep);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -1701,7 +1702,6 @@ static int xhci_submit(XHCIState *xhci, XHCITransfer *xfer,
|
|
|
9ae3a8 |
static int xhci_setup_packet(XHCITransfer *xfer)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
XHCIState *xhci = xfer->xhci;
|
|
|
9ae3a8 |
- USBDevice *dev;
|
|
|
9ae3a8 |
USBEndpoint *ep;
|
|
|
9ae3a8 |
int dir;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -1709,15 +1709,13 @@ static int xhci_setup_packet(XHCITransfer *xfer)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (xfer->packet.ep) {
|
|
|
9ae3a8 |
ep = xfer->packet.ep;
|
|
|
9ae3a8 |
- dev = ep->dev;
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
- if (!xhci->slots[xfer->slotid-1].uport) {
|
|
|
9ae3a8 |
+ ep = xhci_epid_to_usbep(xhci, xfer->slotid, xfer->epid);
|
|
|
9ae3a8 |
+ if (!ep) {
|
|
|
9ae3a8 |
fprintf(stderr, "xhci: slot %d has no device\n",
|
|
|
9ae3a8 |
xfer->slotid);
|
|
|
9ae3a8 |
return -1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
- dev = xhci->slots[xfer->slotid-1].uport->dev;
|
|
|
9ae3a8 |
- ep = usb_ep_get(dev, dir, xfer->epid >> 1);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
xhci_xfer_create_sgl(xfer, dir == USB_TOKEN_IN); /* Also sets int_req */
|
|
|
9ae3a8 |
@@ -1725,7 +1723,7 @@ static int xhci_setup_packet(XHCITransfer *xfer)
|
|
|
9ae3a8 |
xfer->trbs[0].addr, false, xfer->int_req);
|
|
|
9ae3a8 |
usb_packet_map(&xfer->packet, &xfer->sgl);
|
|
|
9ae3a8 |
DPRINTF("xhci: setup packet pid 0x%x addr %d ep %d\n",
|
|
|
9ae3a8 |
- xfer->packet.pid, dev->addr, ep->nr);
|
|
|
9ae3a8 |
+ xfer->packet.pid, ep->dev->addr, ep->nr);
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -2077,7 +2075,6 @@ static void xhci_kick_ep(XHCIState *xhci, unsigned int slotid,
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
if (xhci_fire_transfer(xhci, xfer, epctx) >= 0) {
|
|
|
9ae3a8 |
epctx->next_xfer = (epctx->next_xfer + 1) % TD_QUEUE;
|
|
|
9ae3a8 |
- ep = xfer->packet.ep;
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
if (!xfer->timed_xfer) {
|
|
|
9ae3a8 |
fprintf(stderr, "xhci: error firing data transfer\n");
|
|
|
9ae3a8 |
@@ -2094,6 +2091,8 @@ static void xhci_kick_ep(XHCIState *xhci, unsigned int slotid,
|
|
|
9ae3a8 |
break;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ ep = xhci_epid_to_usbep(xhci, slotid, epid);
|
|
|
9ae3a8 |
if (ep) {
|
|
|
9ae3a8 |
usb_device_flush_ep_queue(ep->dev, ep);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -3331,6 +3330,19 @@ static int xhci_find_epid(USBEndpoint *ep)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static USBEndpoint *xhci_epid_to_usbep(XHCIState *xhci,
|
|
|
9ae3a8 |
+ unsigned int slotid, unsigned int epid)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ assert(slotid >= 1 && slotid <= xhci->numslots);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (!xhci->slots[slotid - 1].uport) {
|
|
|
9ae3a8 |
+ return NULL;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ return usb_ep_get(xhci->slots[slotid - 1].uport->dev,
|
|
|
9ae3a8 |
+ (epid & 1) ? USB_TOKEN_IN : USB_TOKEN_OUT, epid >> 1);
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static void xhci_wakeup_endpoint(USBBus *bus, USBEndpoint *ep,
|
|
|
9ae3a8 |
unsigned int stream)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|