|
Hans de Goede |
c8dfc6 |
From 76d49f5c5abc30f33f5b9288df68d53dba9e10f0 Mon Sep 17 00:00:00 2001
|
|
Hans de Goede |
c8dfc6 |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
Hans de Goede |
c8dfc6 |
Date: Fri, 24 Aug 2012 14:21:39 +0200
|
|
Hans de Goede |
c8dfc6 |
Subject: [PATCH 333/366] xhci: move device lookup into xhci_setup_packet
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
Hans de Goede |
c8dfc6 |
---
|
|
Hans de Goede |
c8dfc6 |
hw/usb/hcd-xhci.c | 74 ++++++++++++++++++++++++++++---------------------------
|
|
Hans de Goede |
c8dfc6 |
1 file changed, 38 insertions(+), 36 deletions(-)
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
|
|
Hans de Goede |
c8dfc6 |
index c858b6d..303e1ac 100644
|
|
Hans de Goede |
c8dfc6 |
--- a/hw/usb/hcd-xhci.c
|
|
Hans de Goede |
c8dfc6 |
+++ b/hw/usb/hcd-xhci.c
|
|
Hans de Goede |
c8dfc6 |
@@ -1196,13 +1196,38 @@ static void xhci_stall_ep(XHCITransfer *xfer)
|
|
Hans de Goede |
c8dfc6 |
static int xhci_submit(XHCIState *xhci, XHCITransfer *xfer,
|
|
Hans de Goede |
c8dfc6 |
XHCIEPContext *epctx);
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
-static int xhci_setup_packet(XHCITransfer *xfer, USBDevice *dev)
|
|
Hans de Goede |
c8dfc6 |
+static USBDevice *xhci_find_device(XHCIPort *port, uint8_t addr)
|
|
Hans de Goede |
c8dfc6 |
{
|
|
Hans de Goede |
c8dfc6 |
+ if (!(port->portsc & PORTSC_PED)) {
|
|
Hans de Goede |
c8dfc6 |
+ return NULL;
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
+ return usb_find_device(&port->port, addr);
|
|
Hans de Goede |
c8dfc6 |
+}
|
|
Hans de Goede |
c8dfc6 |
+
|
|
Hans de Goede |
c8dfc6 |
+static int xhci_setup_packet(XHCITransfer *xfer)
|
|
Hans de Goede |
c8dfc6 |
+{
|
|
Hans de Goede |
c8dfc6 |
+ XHCIState *xhci = xfer->xhci;
|
|
Hans de Goede |
c8dfc6 |
+ XHCIPort *port;
|
|
Hans de Goede |
c8dfc6 |
+ USBDevice *dev;
|
|
Hans de Goede |
c8dfc6 |
USBEndpoint *ep;
|
|
Hans de Goede |
c8dfc6 |
int dir;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
dir = xfer->in_xfer ? USB_TOKEN_IN : USB_TOKEN_OUT;
|
|
Hans de Goede |
c8dfc6 |
- ep = usb_ep_get(dev, dir, xfer->epid >> 1);
|
|
Hans de Goede |
c8dfc6 |
+
|
|
Hans de Goede |
c8dfc6 |
+ if (xfer->packet.ep) {
|
|
Hans de Goede |
c8dfc6 |
+ ep = xfer->packet.ep;
|
|
Hans de Goede |
c8dfc6 |
+ dev = ep->dev;
|
|
Hans de Goede |
c8dfc6 |
+ } else {
|
|
Hans de Goede |
c8dfc6 |
+ port = &xhci->ports[xhci->slots[xfer->slotid-1].port-1];
|
|
Hans de Goede |
c8dfc6 |
+ dev = xhci_find_device(port, xhci->slots[xfer->slotid-1].devaddr);
|
|
Hans de Goede |
c8dfc6 |
+ if (!dev) {
|
|
Hans de Goede |
c8dfc6 |
+ fprintf(stderr, "xhci: slot %d port %d has no device\n",
|
|
Hans de Goede |
c8dfc6 |
+ xfer->slotid, xhci->slots[xfer->slotid-1].port);
|
|
Hans de Goede |
c8dfc6 |
+ return -1;
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
+ ep = usb_ep_get(dev, dir, xfer->epid >> 1);
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
+
|
|
Hans de Goede |
c8dfc6 |
usb_packet_setup(&xfer->packet, dir, ep, xfer->trbs[0].addr);
|
|
Hans de Goede |
c8dfc6 |
xhci_xfer_map(xfer);
|
|
Hans de Goede |
c8dfc6 |
DPRINTF("xhci: setup packet pid 0x%x addr %d ep %d\n",
|
|
Hans de Goede |
c8dfc6 |
@@ -1260,21 +1285,11 @@ static int xhci_complete_packet(XHCITransfer *xfer, int ret)
|
|
Hans de Goede |
c8dfc6 |
return 0;
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
-static USBDevice *xhci_find_device(XHCIPort *port, uint8_t addr)
|
|
Hans de Goede |
c8dfc6 |
-{
|
|
Hans de Goede |
c8dfc6 |
- if (!(port->portsc & PORTSC_PED)) {
|
|
Hans de Goede |
c8dfc6 |
- return NULL;
|
|
Hans de Goede |
c8dfc6 |
- }
|
|
Hans de Goede |
c8dfc6 |
- return usb_find_device(&port->port, addr);
|
|
Hans de Goede |
c8dfc6 |
-}
|
|
Hans de Goede |
c8dfc6 |
-
|
|
Hans de Goede |
c8dfc6 |
static int xhci_fire_ctl_transfer(XHCIState *xhci, XHCITransfer *xfer)
|
|
Hans de Goede |
c8dfc6 |
{
|
|
Hans de Goede |
c8dfc6 |
XHCITRB *trb_setup, *trb_status;
|
|
Hans de Goede |
c8dfc6 |
uint8_t bmRequestType;
|
|
Hans de Goede |
c8dfc6 |
uint16_t wLength;
|
|
Hans de Goede |
c8dfc6 |
- XHCIPort *port;
|
|
Hans de Goede |
c8dfc6 |
- USBDevice *dev;
|
|
Hans de Goede |
c8dfc6 |
int ret;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
trb_setup = &xfer->trbs[0];
|
|
Hans de Goede |
c8dfc6 |
@@ -1311,21 +1326,15 @@ static int xhci_fire_ctl_transfer(XHCIState *xhci, XHCITransfer *xfer)
|
|
Hans de Goede |
c8dfc6 |
bmRequestType = trb_setup->parameter;
|
|
Hans de Goede |
c8dfc6 |
wLength = trb_setup->parameter >> 48;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
- port = &xhci->ports[xhci->slots[xfer->slotid-1].port-1];
|
|
Hans de Goede |
c8dfc6 |
- dev = xhci_find_device(port, xhci->slots[xfer->slotid-1].devaddr);
|
|
Hans de Goede |
c8dfc6 |
- if (!dev) {
|
|
Hans de Goede |
c8dfc6 |
- fprintf(stderr, "xhci: slot %d port %d has no device\n", xfer->slotid,
|
|
Hans de Goede |
c8dfc6 |
- xhci->slots[xfer->slotid-1].port);
|
|
Hans de Goede |
c8dfc6 |
- return -1;
|
|
Hans de Goede |
c8dfc6 |
- }
|
|
Hans de Goede |
c8dfc6 |
-
|
|
Hans de Goede |
c8dfc6 |
xfer->in_xfer = bmRequestType & USB_DIR_IN;
|
|
Hans de Goede |
c8dfc6 |
xfer->iso_xfer = false;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
- xhci_setup_packet(xfer, dev);
|
|
Hans de Goede |
c8dfc6 |
+ if (xhci_setup_packet(xfer) < 0) {
|
|
Hans de Goede |
c8dfc6 |
+ return -1;
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
xfer->packet.parameter = trb_setup->parameter;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
- ret = usb_handle_packet(dev, &xfer->packet);
|
|
Hans de Goede |
c8dfc6 |
+ ret = usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
xhci_complete_packet(xfer, ret);
|
|
Hans de Goede |
c8dfc6 |
if (!xfer->running_async && !xfer->running_retry) {
|
|
Hans de Goede |
c8dfc6 |
@@ -1336,8 +1345,6 @@ static int xhci_fire_ctl_transfer(XHCIState *xhci, XHCITransfer *xfer)
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
static int xhci_submit(XHCIState *xhci, XHCITransfer *xfer, XHCIEPContext *epctx)
|
|
Hans de Goede |
c8dfc6 |
{
|
|
Hans de Goede |
c8dfc6 |
- XHCIPort *port;
|
|
Hans de Goede |
c8dfc6 |
- USBDevice *dev;
|
|
Hans de Goede |
c8dfc6 |
int ret;
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
DPRINTF("xhci_submit(slotid=%d,epid=%d)\n", xfer->slotid, xfer->epid);
|
|
Hans de Goede |
c8dfc6 |
@@ -1350,16 +1357,6 @@ static int xhci_submit(XHCIState *xhci, XHCITransfer *xfer, XHCIEPContext *epctx
|
|
Hans de Goede |
c8dfc6 |
xfer->pkts = 0;
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
- port = &xhci->ports[xhci->slots[xfer->slotid-1].port-1];
|
|
Hans de Goede |
c8dfc6 |
- dev = xhci_find_device(port, xhci->slots[xfer->slotid-1].devaddr);
|
|
Hans de Goede |
c8dfc6 |
- if (!dev) {
|
|
Hans de Goede |
c8dfc6 |
- fprintf(stderr, "xhci: slot %d port %d has no device\n", xfer->slotid,
|
|
Hans de Goede |
c8dfc6 |
- xhci->slots[xfer->slotid-1].port);
|
|
Hans de Goede |
c8dfc6 |
- return -1;
|
|
Hans de Goede |
c8dfc6 |
- }
|
|
Hans de Goede |
c8dfc6 |
-
|
|
Hans de Goede |
c8dfc6 |
- xhci_setup_packet(xfer, dev);
|
|
Hans de Goede |
c8dfc6 |
-
|
|
Hans de Goede |
c8dfc6 |
switch(epctx->type) {
|
|
Hans de Goede |
c8dfc6 |
case ET_INTR_OUT:
|
|
Hans de Goede |
c8dfc6 |
case ET_INTR_IN:
|
|
Hans de Goede |
c8dfc6 |
@@ -1377,7 +1374,10 @@ static int xhci_submit(XHCIState *xhci, XHCITransfer *xfer, XHCIEPContext *epctx
|
|
Hans de Goede |
c8dfc6 |
return -1;
|
|
Hans de Goede |
c8dfc6 |
}
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
- ret = usb_handle_packet(dev, &xfer->packet);
|
|
Hans de Goede |
c8dfc6 |
+ if (xhci_setup_packet(xfer) < 0) {
|
|
Hans de Goede |
c8dfc6 |
+ return -1;
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
+ ret = usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
xhci_complete_packet(xfer, ret);
|
|
Hans de Goede |
c8dfc6 |
if (!xfer->running_async && !xfer->running_retry) {
|
|
Hans de Goede |
c8dfc6 |
@@ -1420,7 +1420,9 @@ static void xhci_kick_ep(XHCIState *xhci, unsigned int slotid, unsigned int epid
|
|
Hans de Goede |
c8dfc6 |
|
|
Hans de Goede |
c8dfc6 |
trace_usb_xhci_xfer_retry(xfer);
|
|
Hans de Goede |
c8dfc6 |
assert(xfer->running_retry);
|
|
Hans de Goede |
c8dfc6 |
- xhci_setup_packet(xfer, xfer->packet.ep->dev);
|
|
Hans de Goede |
c8dfc6 |
+ if (xhci_setup_packet(xfer) < 0) {
|
|
Hans de Goede |
c8dfc6 |
+ return;
|
|
Hans de Goede |
c8dfc6 |
+ }
|
|
Hans de Goede |
c8dfc6 |
result = usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);
|
|
Hans de Goede |
c8dfc6 |
if (result == USB_RET_NAK) {
|
|
Hans de Goede |
c8dfc6 |
return;
|
|
Hans de Goede |
c8dfc6 |
--
|
|
Hans de Goede |
c8dfc6 |
1.7.12
|
|
Hans de Goede |
c8dfc6 |
|