qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/4] usb patch queue
@ 2013-04-23  8:32 Gerd Hoffmann
  2013-04-23  8:32 ` [Qemu-devel] [PATCH 1/4] xhci: remove XHCIRing->base (unused) Gerd Hoffmann
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2013-04-23  8:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

Nothing major, just some small fixes.

please pull,
  Gerd

The following changes since commit 456736710df19c2275192269fe67a3f0b2583835:

  block: Fix build with tracing enabled (2013-04-22 11:31:41 -0500)

are available in the git repository at:

  git://git.kraxel.org/qemu usb.81

for you to fetch changes up to 3f5cc97e2ba00b34fd20a5553ed9d2fecf32f7e3:

  usb-host: raise libusbx minimum version to 1.0.13 (2013-04-23 08:43:10 +0200)

----------------------------------------------------------------
Gerd Hoffmann (3):
      xhci: remove XHCIRing->base (unused)
      usb: better speed mismatch error reporting
      usb-host: raise libusbx minimum version to 1.0.13

Hans de Goede (1):
      ehci_free_packet: Discard finished packets when the queue is halted

 configure            |    2 +-
 hw/usb/bus.c         |   36 ++++++++++++++++++++++++++++++++----
 hw/usb/desc.c        |    2 --
 hw/usb/hcd-ehci.c    |   16 +++++++++++-----
 hw/usb/hcd-xhci.c    |    4 +---
 hw/usb/host-libusb.c |    5 -----
 trace-events         |    2 +-
 7 files changed, 46 insertions(+), 21 deletions(-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 1/4] xhci: remove XHCIRing->base (unused)
  2013-04-23  8:32 [Qemu-devel] [PULL 0/4] usb patch queue Gerd Hoffmann
@ 2013-04-23  8:32 ` Gerd Hoffmann
  2013-04-23  8:32 ` [Qemu-devel] [PATCH 2/4] ehci_free_packet: Discard finished packets when the queue is halted Gerd Hoffmann
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2013-04-23  8:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/hcd-xhci.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index a26b78e..2c90e56 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -326,7 +326,6 @@ typedef enum EPType {
 } EPType;
 
 typedef struct XHCIRing {
-    dma_addr_t base;
     dma_addr_t dequeue;
     bool ccs;
 } XHCIRing;
@@ -943,7 +942,6 @@ static void xhci_event(XHCIState *xhci, XHCIEvent *event, int v)
 static void xhci_ring_init(XHCIState *xhci, XHCIRing *ring,
                            dma_addr_t base)
 {
-    ring->base = base;
     ring->dequeue = base;
     ring->ccs = 1;
 }
@@ -1948,7 +1946,7 @@ static void xhci_kick_ep(XHCIState *xhci, unsigned int slotid,
         streamid = 0;
         xhci_set_ep_state(xhci, epctx, NULL, EP_RUNNING);
     }
-    assert(ring->base != 0);
+    assert(ring->dequeue != 0);
 
     while (1) {
         XHCITransfer *xfer = &epctx->transfers[epctx->next_xfer];
-- 
1.7.9.7

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 2/4] ehci_free_packet: Discard finished packets when the queue is halted
  2013-04-23  8:32 [Qemu-devel] [PULL 0/4] usb patch queue Gerd Hoffmann
  2013-04-23  8:32 ` [Qemu-devel] [PATCH 1/4] xhci: remove XHCIRing->base (unused) Gerd Hoffmann
@ 2013-04-23  8:32 ` Gerd Hoffmann
  2013-04-23  8:32 ` [Qemu-devel] [PATCH 3/4] usb: better speed mismatch error reporting Gerd Hoffmann
  2013-04-23  8:32 ` [Qemu-devel] [PATCH 4/4] usb-host: raise libusbx minimum version to 1.0.13 Gerd Hoffmann
  3 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2013-04-23  8:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Hans de Goede, Gerd Hoffmann

From: Hans de Goede <hdegoede@redhat.com>

With pipelining it is possible to encounter a finished packet when cleaning
the queue due to a halt. This happens when a non stall error happens while
talking to a real device. In this case the queue on the usb-host side will
continue processing packets, and we can have completed packets waiting in
the queue after an error condition packet causing a halt.

There are 2 reasons to discard the completed packets at this point, rather
then trying to writing them back to the guest:

1) The guest expect to be able to cancel and/or change packets after the
packet with the error without doing an unlink, so writing them back may
confuse the guest.

2) Since the queue does not advance when halted, the writing back of these
packets will fail anyways since p->qtdaddr != q->qtdaddr, so the
ehci_verify_qtd call in ehci_writeback_async_complete_packet will fail.

Note that 2) means that then only functional change this patch introduces
is the printing of a warning when this scenario happens.

Note that discarding these packets means that the guest driver and the device
will get out of sync! This is unfortunate, but should not be a problem since
with a non stall error (iow an io-error) the 2 are out of sync already anyways.
Still this patch adds a warning to signal this happening.

Note that sofar this has only been seen with a DVB-T receiver, which gives
of a MPEG-2 stream, which allows for recovering from lost packets, see:
https://bugzilla.redhat.com/show_bug.cgi?id=890320

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/hcd-ehci.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 5176251..0d3799d 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -586,17 +586,23 @@ static EHCIPacket *ehci_alloc_packet(EHCIQueue *q)
 
 static void ehci_free_packet(EHCIPacket *p)
 {
-    if (p->async == EHCI_ASYNC_FINISHED) {
+    if (p->async == EHCI_ASYNC_FINISHED &&
+            !(p->queue->qh.token & QTD_TOKEN_HALT)) {
         ehci_writeback_async_complete_packet(p);
         return;
     }
     trace_usb_ehci_packet_action(p->queue, p, "free");
-    if (p->async == EHCI_ASYNC_INITIALIZED) {
-        usb_packet_unmap(&p->packet, &p->sgl);
-        qemu_sglist_destroy(&p->sgl);
-    }
     if (p->async == EHCI_ASYNC_INFLIGHT) {
         usb_cancel_packet(&p->packet);
+    }
+    if (p->async == EHCI_ASYNC_FINISHED &&
+            p->packet.status == USB_RET_SUCCESS) {
+        fprintf(stderr,
+                "EHCI: Dropping completed packet from halted %s ep %02X\n",
+                (p->pid == USB_TOKEN_IN) ? "in" : "out",
+                get_field(p->queue->qh.epchar, QH_EPCHAR_EP));
+    }
+    if (p->async != EHCI_ASYNC_NONE) {
         usb_packet_unmap(&p->packet, &p->sgl);
         qemu_sglist_destroy(&p->sgl);
     }
-- 
1.7.9.7

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 3/4] usb: better speed mismatch error reporting
  2013-04-23  8:32 [Qemu-devel] [PULL 0/4] usb patch queue Gerd Hoffmann
  2013-04-23  8:32 ` [Qemu-devel] [PATCH 1/4] xhci: remove XHCIRing->base (unused) Gerd Hoffmann
  2013-04-23  8:32 ` [Qemu-devel] [PATCH 2/4] ehci_free_packet: Discard finished packets when the queue is halted Gerd Hoffmann
@ 2013-04-23  8:32 ` Gerd Hoffmann
  2013-04-23  8:32 ` [Qemu-devel] [PATCH 4/4] usb-host: raise libusbx minimum version to 1.0.13 Gerd Hoffmann
  3 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2013-04-23  8:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Report the supported speeds for device and port in the error message.
Also add the speeds to the tracepoint.  And while being at it drop
the redundant error message in usb_desc_attach, usb_device_attach will
report the error anyway.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/bus.c  |   36 ++++++++++++++++++++++++++++++++----
 hw/usb/desc.c |    2 --
 trace-events  |    2 +-
 3 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index b10c290..d1827be 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -417,19 +417,47 @@ void usb_release_port(USBDevice *dev)
     bus->nfree++;
 }
 
+static void usb_mask_to_str(char *dest, size_t size,
+                            unsigned int speedmask)
+{
+    static const struct {
+        unsigned int mask;
+        const char *name;
+    } speeds[] = {
+        { .mask = USB_SPEED_MASK_FULL,  .name = "full"  },
+        { .mask = USB_SPEED_MASK_HIGH,  .name = "high"  },
+        { .mask = USB_SPEED_MASK_SUPER, .name = "super" },
+    };
+    int i, pos = 0;
+
+    for (i = 0; i < ARRAY_SIZE(speeds); i++) {
+        if (speeds[i].mask & speedmask) {
+            pos += snprintf(dest + pos, size - pos, "%s%s",
+                            pos ? "+" : "",
+                            speeds[i].name);
+        }
+    }
+}
+
 int usb_device_attach(USBDevice *dev)
 {
     USBBus *bus = usb_bus_from_device(dev);
     USBPort *port = dev->port;
+    char devspeed[32], portspeed[32];
 
     assert(port != NULL);
     assert(!dev->attached);
-    trace_usb_port_attach(bus->busnr, port->path);
+    usb_mask_to_str(devspeed, sizeof(devspeed), dev->speedmask);
+    usb_mask_to_str(portspeed, sizeof(portspeed), port->speedmask);
+    trace_usb_port_attach(bus->busnr, port->path,
+                          devspeed, portspeed);
 
     if (!(port->speedmask & dev->speedmask)) {
-        error_report("Warning: speed mismatch trying to attach "
-                     "usb device %s to bus %s",
-                     dev->product_desc, bus->qbus.name);
+        error_report("Warning: speed mismatch trying to attach"
+                     " usb device \"%s\" (%s speed)"
+                     " to bus \"%s\", port \"%s\" (%s speed)",
+                     dev->product_desc, devspeed,
+                     bus->qbus.name, port->path, portspeed);
         return -1;
     }
 
diff --git a/hw/usb/desc.c b/hw/usb/desc.c
index b389381..fce303e 100644
--- a/hw/usb/desc.c
+++ b/hw/usb/desc.c
@@ -522,8 +522,6 @@ void usb_desc_attach(USBDevice *dev)
     } else if (desc->full && (dev->port->speedmask & USB_SPEED_MASK_FULL)) {
         dev->speed = USB_SPEED_FULL;
     } else {
-        fprintf(stderr, "usb: port/device speed mismatch for \"%s\"\n",
-                usb_device_get_product_desc(dev));
         return;
     }
     usb_desc_setdefaults(dev);
diff --git a/trace-events b/trace-events
index e587487..ffaa3f4 100644
--- a/trace-events
+++ b/trace-events
@@ -277,7 +277,7 @@ usb_packet_state_fault(int bus, const char *port, int ep, void *p, const char *o
 
 # hw/usb/bus.c
 usb_port_claim(int bus, const char *port) "bus %d, port %s"
-usb_port_attach(int bus, const char *port) "bus %d, port %s"
+usb_port_attach(int bus, const char *port, const char *devspeed, const char *portspeed) "bus %d, port %s, devspeed %s, portspeed %s"
 usb_port_detach(int bus, const char *port) "bus %d, port %s"
 usb_port_release(int bus, const char *port) "bus %d, port %s"
 
-- 
1.7.9.7

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 4/4] usb-host: raise libusbx minimum version to 1.0.13
  2013-04-23  8:32 [Qemu-devel] [PULL 0/4] usb patch queue Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2013-04-23  8:32 ` [Qemu-devel] [PATCH 3/4] usb: better speed mismatch error reporting Gerd Hoffmann
@ 2013-04-23  8:32 ` Gerd Hoffmann
  3 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2013-04-23  8:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Allows to remove one FIXME.  Makes LIBUSB_LOG_LEVEL_WARNING build errors
go away.  And starting with that version libusb has a LIBUSBX_API_VERSION
define which allows to easily #ifdef version dependencies should that
need arrive in the future.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 configure            |    2 +-
 hw/usb/host-libusb.c |    5 -----
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/configure b/configure
index 51a6c56..33d3354 100755
--- a/configure
+++ b/configure
@@ -3060,7 +3060,7 @@ fi
 
 # check for libusb
 if test "$libusb" != "no" ; then
-    if $pkg_config libusb-1.0 >/dev/null 2>&1 ; then
+    if $pkg_config --atleast-version=1.0.13 libusb-1.0 >/dev/null 2>&1 ; then
         libusb="yes"
 	usb="libusb"
         libusb_cflags=$($pkg_config --cflags libusb-1.0 2>/dev/null)
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 29f35b3..d1186b8 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -236,8 +236,6 @@ static int usb_host_init(void)
 
 static int usb_host_get_port(libusb_device *dev, char *port, size_t len)
 {
-#if defined(LIBUSBX_API_VERSION) && (LIBUSBX_API_VERSION >= 0x010000ff)
-    /* have libusb_get_port_path() */
     uint8_t path[7];
     size_t off;
     int rc, i;
@@ -251,9 +249,6 @@ static int usb_host_get_port(libusb_device *dev, char *port, size_t len)
         off += snprintf(port+off, len-off, ".%d", path[i]);
     }
     return off;
-#else
-    return snprintf(port, len, "FIXME");
-#endif
 }
 
 static void usb_host_libusb_error(const char *func, int rc)
-- 
1.7.9.7

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PULL 0/4] usb patch queue
@ 2013-09-10  9:41 Gerd Hoffmann
  0 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2013-09-10  9:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

Here comes the usb patch queue, bringing little fixes and making usb
bluetooth support a compile time option.

please pull,
  Gerd

The following changes since commit 94c2b6aff43cdfcfdfb552773a6b6b973a72ef0b:

  mips_malta: support up to 2GiB RAM (2013-09-09 18:42:22 +0200)

are available in the git repository at:

  git://git.kraxel.org/qemu usb.89

for you to fetch changes up to adbecc89731cf3e0ae656d50ea9fa58c589c4bdc:

  ehci: save device pointer in EHCIState (2013-09-10 11:14:42 +0200)

----------------------------------------------------------------
Gerd Hoffmann (2):
      usb: sanity check setup_index+setup_len in post_load
      ehci: save device pointer in EHCIState

Miroslav Rezanina (2):
      Preparation for usb-bt-dongle conditional build
      Remove dev-bluetooth.c dependency from vl.c

 hw/bt/core.c           | 23 ++++++++++++++
 hw/bt/hci.c            | 48 +++++++++++++++++++++++++++++
 hw/usb/Makefile.objs   |  3 --
 hw/usb/bus.c           |  4 +++
 hw/usb/dev-bluetooth.c | 10 +++++-
 hw/usb/hcd-ehci.c      |  7 ++---
 hw/usb/hcd-ehci.h      |  1 +
 include/hw/bt.h        |  3 ++
 include/hw/usb.h       |  3 --
 vl.c                   | 82 +++-----------------------------------------------
 10 files changed, 95 insertions(+), 89 deletions(-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PULL 0/4] usb patch queue
@ 2014-07-01 14:07 Gerd Hoffmann
  2014-07-01 16:02 ` Peter Maydell
  0 siblings, 1 reply; 8+ messages in thread
From: Gerd Hoffmann @ 2014-07-01 14:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

Coming with a collection of usb bugfixes.

please pull,
  Gerd

The following changes since commit b3959efdbb2dc3d5959e3b0a8e188126930beca8:

  Merge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-2.1' into staging (2014-07-01 11:00:53 +0100)

are available in the git repository at:


  git://git.kraxel.org/qemu tags/pull-usb-20140701-1

for you to fetch changes up to c1129f6bffb6fc756f53c06bc554a7997b1f4be4:

  ccid-card-emulated: use EventNotifier (2014-07-01 15:49:51 +0200)

----------------------------------------------------------------
usb bugfixes.

----------------------------------------------------------------
Christian Burger (1):
      input: fix jumpy mouse cursor with USB mouse emulation

Hani Benhabiles (1):
      usb: Fix usb-bt-dongle initialization.

Jincheng Miao (1):
      usb: initialize libusb_device to avoid crash

Paolo Bonzini (1):
      ccid-card-emulated: use EventNotifier

 hw/input/hid.c              |  4 ++--
 hw/usb/ccid-card-emulated.c | 29 ++++++++++-------------------
 hw/usb/dev-bluetooth.c      | 24 ++++++++++++++++--------
 hw/usb/host-libusb.c        |  4 ++--
 4 files changed, 30 insertions(+), 31 deletions(-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PULL 0/4] usb patch queue
  2014-07-01 14:07 Gerd Hoffmann
@ 2014-07-01 16:02 ` Peter Maydell
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Maydell @ 2014-07-01 16:02 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On 1 July 2014 15:07, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
> Coming with a collection of usb bugfixes.
>
> please pull,
>   Gerd
>
> The following changes since commit b3959efdbb2dc3d5959e3b0a8e188126930beca8:
>
>   Merge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-2.1' into staging (2014-07-01 11:00:53 +0100)
>
> are available in the git repository at:
>
>
>   git://git.kraxel.org/qemu tags/pull-usb-20140701-1
>
> for you to fetch changes up to c1129f6bffb6fc756f53c06bc554a7997b1f4be4:
>
>   ccid-card-emulated: use EventNotifier (2014-07-01 15:49:51 +0200)
>
> ----------------------------------------------------------------
> usb bugfixes.

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-07-01 16:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-23  8:32 [Qemu-devel] [PULL 0/4] usb patch queue Gerd Hoffmann
2013-04-23  8:32 ` [Qemu-devel] [PATCH 1/4] xhci: remove XHCIRing->base (unused) Gerd Hoffmann
2013-04-23  8:32 ` [Qemu-devel] [PATCH 2/4] ehci_free_packet: Discard finished packets when the queue is halted Gerd Hoffmann
2013-04-23  8:32 ` [Qemu-devel] [PATCH 3/4] usb: better speed mismatch error reporting Gerd Hoffmann
2013-04-23  8:32 ` [Qemu-devel] [PATCH 4/4] usb-host: raise libusbx minimum version to 1.0.13 Gerd Hoffmann
  -- strict thread matches above, loose matches on Subject: below --
2013-09-10  9:41 [Qemu-devel] [PULL 0/4] usb patch queue Gerd Hoffmann
2014-07-01 14:07 Gerd Hoffmann
2014-07-01 16:02 ` Peter Maydell

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).