From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 12/12] usb: link packets to endpoints not devices
Date: Fri, 6 Jan 2012 14:59:06 +0100 [thread overview]
Message-ID: <1325858346-1071-13-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1325858346-1071-1-git-send-email-kraxel@redhat.com>
Add USBEndpoint for the control endpoint to USBDevices. Link async
packets to the USBEndpoint instead of the USBDevice.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/usb-ehci.c | 3 ++-
hw/usb-musb.c | 3 ++-
hw/usb-ohci.c | 4 +++-
hw/usb-uhci.c | 3 ++-
hw/usb.c | 12 ++++++++++--
hw/usb.h | 4 +++-
6 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index 7c926c0..a305661 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -715,7 +715,8 @@ static void ehci_queues_rip_device(EHCIState *ehci, USBDevice *dev)
EHCIQueue *q, *tmp;
QTAILQ_FOREACH_SAFE(q, &ehci->queues, next, tmp) {
- if (q->packet.owner != dev) {
+ if (q->packet.owner == NULL ||
+ q->packet.owner->dev != dev) {
continue;
}
ehci_free_queue(q);
diff --git a/hw/usb-musb.c b/hw/usb-musb.c
index 01e2e7c..4f528d2 100644
--- a/hw/usb-musb.c
+++ b/hw/usb-musb.c
@@ -812,7 +812,8 @@ static void musb_async_cancel_device(MUSBState *s, USBDevice *dev)
for (ep = 0; ep < 16; ep++) {
for (dir = 0; dir < 2; dir++) {
- if (s->ep[ep].packey[dir].p.owner != dev) {
+ if (s->ep[ep].packey[dir].p.owner == NULL ||
+ s->ep[ep].packey[dir].p.owner->dev != dev) {
continue;
}
usb_cancel_packet(&s->ep[ep].packey[dir].p);
diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c
index 81488c4..69463d2 100644
--- a/hw/usb-ohci.c
+++ b/hw/usb-ohci.c
@@ -1707,7 +1707,9 @@ static void ohci_mem_write(void *opaque,
static void ohci_async_cancel_device(OHCIState *ohci, USBDevice *dev)
{
- if (ohci->async_td && ohci->usb_packet.owner == dev) {
+ if (ohci->async_td &&
+ ohci->usb_packet.owner != NULL &&
+ ohci->usb_packet.owner->dev == dev) {
usb_cancel_packet(&ohci->usb_packet);
ohci->async_td = 0;
}
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index f8912e2..c6f4bf5 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -245,7 +245,8 @@ static void uhci_async_cancel_device(UHCIState *s, USBDevice *dev)
UHCIAsync *curr, *n;
QTAILQ_FOREACH_SAFE(curr, &s->async_pending, next, n) {
- if (curr->packet.owner != dev) {
+ if (curr->packet.owner != NULL &&
+ curr->packet.owner->dev != dev) {
continue;
}
uhci_async_unlink(s, curr);
diff --git a/hw/usb.c b/hw/usb.c
index 0f163b4..860538a 100644
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -329,7 +329,7 @@ int usb_handle_packet(USBDevice *dev, USBPacket *p)
ret = dev->info->handle_packet(dev, p);
if (ret == USB_RET_ASYNC) {
if (p->owner == NULL) {
- p->owner = dev;
+ p->owner = usb_ep_get(dev, p->pid, p->devep);
} else {
/* We'll end up here when usb_handle_packet is called
* recursively due to a hub being in the chain. Nothing
@@ -357,7 +357,7 @@ void usb_packet_complete(USBDevice *dev, USBPacket *p)
void usb_cancel_packet(USBPacket * p)
{
assert(p->owner != NULL);
- p->owner->info->cancel_packet(p->owner, p);
+ p->owner->dev->info->cancel_packet(p->owner->dev, p);
p->owner = NULL;
}
@@ -419,11 +419,16 @@ void usb_ep_init(USBDevice *dev)
{
int ep;
+ dev->ep_ctl.type = USB_ENDPOINT_XFER_CONTROL;
+ dev->ep_ctl.ifnum = 0;
+ dev->ep_ctl.dev = dev;
for (ep = 0; ep < USB_MAX_ENDPOINTS; ep++) {
dev->ep_in[ep].type = USB_ENDPOINT_XFER_INVALID;
dev->ep_out[ep].type = USB_ENDPOINT_XFER_INVALID;
dev->ep_in[ep].ifnum = 0;
dev->ep_out[ep].ifnum = 0;
+ dev->ep_in[ep].dev = dev;
+ dev->ep_out[ep].dev = dev;
}
}
@@ -472,6 +477,9 @@ void usb_ep_dump(USBDevice *dev)
struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid, int ep)
{
struct USBEndpoint *eps = pid == USB_TOKEN_IN ? dev->ep_in : dev->ep_out;
+ if (ep == 0) {
+ return &dev->ep_ctl;
+ }
assert(pid == USB_TOKEN_IN || pid == USB_TOKEN_OUT);
assert(ep > 0 && ep <= USB_MAX_ENDPOINTS);
return eps + ep - 1;
diff --git a/hw/usb.h b/hw/usb.h
index 5ea984c..0776463 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -177,6 +177,7 @@ struct USBEndpoint {
uint8_t type;
uint8_t ifnum;
int max_packet_size;
+ USBDevice *dev;
};
/* definition of a USB device */
@@ -204,6 +205,7 @@ struct USBDevice {
int32_t setup_len;
int32_t setup_index;
+ USBEndpoint ep_ctl;
USBEndpoint ep_in[USB_MAX_ENDPOINTS];
USBEndpoint ep_out[USB_MAX_ENDPOINTS];
@@ -317,7 +319,7 @@ struct USBPacket {
QEMUIOVector iov;
int result; /* transfer length or USB_RET_* status code */
/* Internal use by the USB layer. */
- USBDevice *owner;
+ USBEndpoint *owner;
};
void usb_packet_init(USBPacket *p);
--
1.7.1
prev parent reply other threads:[~2012-01-06 13:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-06 13:58 [Qemu-devel] [PATCH 00/12] usb patch queue: audio, xhci Gerd Hoffmann
2012-01-06 13:58 ` [Qemu-devel] [PATCH 01/12] usb-host: rip out legacy procfs support Gerd Hoffmann
2012-01-06 13:58 ` [Qemu-devel] [PATCH 02/12] usb: track configuration and interface count in USBDevice Gerd Hoffmann
2012-01-06 13:58 ` [Qemu-devel] [PATCH 03/12] usb: track altsetting " Gerd Hoffmann
2012-01-06 13:58 ` [Qemu-devel] [PATCH 04/12] usb-desc: audio endpoint support Gerd Hoffmann
2012-01-06 13:58 ` [Qemu-devel] [PATCH 05/12] usb: add audio device model Gerd Hoffmann
2012-01-06 17:23 ` Alex Bradbury
2012-01-06 13:59 ` [Qemu-devel] [PATCH 06/12] xhci: Initial xHCI implementation Gerd Hoffmann
2012-01-06 14:54 ` Stefan Weil
2012-01-09 9:30 ` Gerd Hoffmann
2012-01-06 13:59 ` [Qemu-devel] [PATCH 07/12] usb: add USBEndpoint Gerd Hoffmann
2012-01-06 13:59 ` [Qemu-devel] [PATCH 08/12] usb: add ifnum to USBEndpoint Gerd Hoffmann
2012-01-06 13:59 ` [Qemu-devel] [PATCH 09/12] usb-desc: USBEndpoint support Gerd Hoffmann
2012-01-06 13:59 ` [Qemu-devel] [PATCH 10/12] usb/debug: add usb_ep_dump Gerd Hoffmann
2012-01-06 13:59 ` [Qemu-devel] [PATCH 11/12] usb: add max_packet_size to USBEndpoint Gerd Hoffmann
2012-01-06 13:59 ` Gerd Hoffmann [this message]
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=1325858346-1071-13-git-send-email-kraxel@redhat.com \
--to=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).