qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: "erik.rull@rdsoftware.de" <erik.rull@rdsoftware.de>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] usb: selective endpoint initialization
Date: Tue, 03 Jul 2012 10:21:04 +0200	[thread overview]
Message-ID: <4FF2AB70.5080307@redhat.com> (raw)
In-Reply-To: <4FF2A379.7040403@siemens.com>

[-- Attachment #1: Type: text/plain, Size: 781 bytes --]

On 07/03/12 09:47, Jan Kiszka wrote:
> On 2012-07-02 18:16, Gerd Hoffmann wrote:
>> Add support for (re-)initializing endpoints which belong to a specific
>> interface only.  Use this in usb-host when changing altsetting for an
>> interface, so other interfaces are not disturbed.
>>
> 
> qemu-system-x86_64: /data/qemu/hw/usb/host-linux.c:1220:
> usb_linux_update_endp_table: Assertion `usb_ep_get_type(&s->dev, pid,
> ep) == 255' failed.
> 
> Do you need a trace again?

Don't think so.  Alternative fix attached.

>     Interface Descriptor:
>       bInterfaceNumber        3
>       bInterfaceClass         3 Human Interface Device

This interface is the one the packet comes from, guess the headset has
some button(s) which this HID interface is intended for.

cheers,
  Gerd

[-- Attachment #2: 0001-usb-split-endpoint-init-and-reset.patch --]
[-- Type: text/plain, Size: 2911 bytes --]

>From 7d00f8996f7981bb118b6986813ce407b31f2b70 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Tue, 3 Jul 2012 10:11:21 +0200
Subject: [PATCH] usb: split endpoint init and reset

Create a new usb_ep_reset() function to reset endpoint state, without
re-initialiting the queues, so we don't unlink in-flight packets just
because usb-host has to re-parse the descriptor tables.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb.h            |    1 +
 hw/usb/core.c       |   13 +++++++++++--
 hw/usb/host-linux.c |    5 +++--
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/hw/usb.h b/hw/usb.h
index a5623d3..9cd2f89 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -363,6 +363,7 @@ void usb_packet_complete(USBDevice *dev, USBPacket *p);
 void usb_cancel_packet(USBPacket * p);
 
 void usb_ep_init(USBDevice *dev);
+void usb_ep_reset(USBDevice *dev);
 void usb_ep_dump(USBDevice *dev);
 struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid, int ep);
 uint8_t usb_ep_get_type(USBDevice *dev, int pid, int ep);
diff --git a/hw/usb/core.c b/hw/usb/core.c
index 0e02da7..fe15be0 100644
--- a/hw/usb/core.c
+++ b/hw/usb/core.c
@@ -550,7 +550,7 @@ void usb_packet_cleanup(USBPacket *p)
     qemu_iovec_destroy(&p->iov);
 }
 
-void usb_ep_init(USBDevice *dev)
+void usb_ep_reset(USBDevice *dev)
 {
     int ep;
 
@@ -559,7 +559,6 @@ void usb_ep_init(USBDevice *dev)
     dev->ep_ctl.ifnum = 0;
     dev->ep_ctl.dev = dev;
     dev->ep_ctl.pipeline = false;
-    QTAILQ_INIT(&dev->ep_ctl.queue);
     for (ep = 0; ep < USB_MAX_ENDPOINTS; ep++) {
         dev->ep_in[ep].nr = ep + 1;
         dev->ep_out[ep].nr = ep + 1;
@@ -573,6 +572,16 @@ void usb_ep_init(USBDevice *dev)
         dev->ep_out[ep].dev = dev;
         dev->ep_in[ep].pipeline = false;
         dev->ep_out[ep].pipeline = false;
+    }
+}
+
+void usb_ep_init(USBDevice *dev)
+{
+    int ep;
+
+    usb_ep_reset(dev);
+    QTAILQ_INIT(&dev->ep_ctl.queue);
+    for (ep = 0; ep < USB_MAX_ENDPOINTS; ep++) {
         QTAILQ_INIT(&dev->ep_in[ep].queue);
         QTAILQ_INIT(&dev->ep_out[ep].queue);
     }
diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c
index 5479fb5..9ba8925 100644
--- a/hw/usb/host-linux.c
+++ b/hw/usb/host-linux.c
@@ -1136,7 +1136,7 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
     USBDescriptor *d;
     bool active = false;
 
-    usb_ep_init(&s->dev);
+    usb_ep_reset(&s->dev);
 
     for (i = 0;; i += d->bLength) {
         if (i+2 >= s->descr_len) {
@@ -1239,7 +1239,7 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
     return 0;
 
 error:
-    usb_ep_init(&s->dev);
+    usb_ep_reset(&s->dev);
     return 1;
 }
 
@@ -1326,6 +1326,7 @@ static int usb_host_open(USBHostDevice *dev, int bus_num,
         goto fail;
     }
 
+    usb_ep_init(&dev->dev);
     ret = usb_linux_update_endp_table(dev);
     if (ret) {
         goto fail;
-- 
1.7.1


  reply	other threads:[~2012-07-03  8:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-02 16:16 [Qemu-devel] [PATCH] usb: selective endpoint initialization Gerd Hoffmann
2012-07-03  7:47 ` Jan Kiszka
2012-07-03  8:21   ` Gerd Hoffmann [this message]
2012-07-03  8:43     ` Jan Kiszka
2012-07-03  8:51       ` Jan Kiszka
2012-07-03  9:17         ` Gerd Hoffmann
2012-07-03 11:39           ` Jan Kiszka
2012-07-03 11:55             ` Gerd Hoffmann
2012-07-04  8:09 ` Erik Rull
2012-07-10 18:57   ` Erik Rull
2012-08-09  8:59     ` Gerd Hoffmann
2012-08-13 13:36       ` Erik Rull
2012-08-24 10:11       ` Erik Rull

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=4FF2AB70.5080307@redhat.com \
    --to=kraxel@redhat.com \
    --cc=erik.rull@rdsoftware.de \
    --cc=jan.kiszka@siemens.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).