qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/1] Usb 20170621 patches
@ 2017-06-21 15:43 Gerd Hoffmann
  2017-06-21 15:43 ` [Qemu-devel] [PULL 1/1] usb-host: support devices with sparse/non-sequential USB interfaces Gerd Hoffmann
  2017-06-22 18:01 ` [Qemu-devel] [PULL 0/1] Usb 20170621 patches Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2017-06-21 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

The following changes since commit 8dfaf23ae1f2273a9730a9b309cc8471269bb524:

  tcg/tci: fix tcg-interpreter build (2017-06-20 18:39:15 +0100)

are available in the git repository at:

  git://git.kraxel.org/qemu tags/usb-20170621-pull-request

for you to fetch changes up to 896b6757f9c4d176ce4439238efea223a2952411:

  usb-host: support devices with sparse/non-sequential USB interfaces (2017-06-21 15:30:08 +0200)

----------------------------------------------------------------

----------------------------------------------------------------

Samuel Brian (1):
  usb-host: support devices with sparse/non-sequential USB interfaces

 hw/usb/host-libusb.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

-- 
2.9.3

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

* [Qemu-devel] [PULL 1/1] usb-host: support devices with sparse/non-sequential USB interfaces
  2017-06-21 15:43 [Qemu-devel] [PULL 0/1] Usb 20170621 patches Gerd Hoffmann
@ 2017-06-21 15:43 ` Gerd Hoffmann
  2017-06-22 18:01 ` [Qemu-devel] [PULL 0/1] Usb 20170621 patches Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2017-06-21 15:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Samuel Brian, Gerd Hoffmann

From: Samuel Brian <sam.brian@accelerated.com>

Some USB devices have sparse interface numbering which is not able to be
passthroughed.
For example, the Sierra Wireless MC7455/MC7430:

  # lsusb  -D /dev/bus/usb/003/003 | egrep '1199|9071|bNumInterfaces|bInterfaceNumber'
  Device: ID 1199:9071 Sierra Wireless, Inc.
    idVendor           0x1199 Sierra Wireless, Inc.
    idProduct          0x9071
      bNumInterfaces          5
        bInterfaceNumber        0
        bInterfaceNumber        2
        bInterfaceNumber        3
        bInterfaceNumber        8
        bInterfaceNumber       10

In this case, the interface numbers are 0, 2, 3, 8, 10 and not the
0, 1, 2, 3, 4 that QEMU tries to claim.

This change allows sparse USB interface numbering.
Instead of only claiming the interfaces in the range reported by the USB
device through bNumInterfaces, QEMU attempts to claim all possible
interfaces.

v2 to fix broken v1 patch formatting.
v3 to fix indentation.

Signed-off-by: Samuel Brian <sam.brian@accelerated.com>
Message-id: 20170613234039.27201-1-sam.brian@accelerated.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/host-libusb.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index f9c8eafe06..1b0be071cc 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -1107,7 +1107,7 @@ static void usb_host_detach_kernel(USBHostDevice *s)
     if (rc != 0) {
         return;
     }
-    for (i = 0; i < conf->bNumInterfaces; i++) {
+    for (i = 0; i < USB_MAX_INTERFACES; i++) {
         rc = libusb_kernel_driver_active(s->dh, i);
         usb_host_libusb_error("libusb_kernel_driver_active", rc);
         if (rc != 1) {
@@ -1130,7 +1130,7 @@ static void usb_host_attach_kernel(USBHostDevice *s)
     if (rc != 0) {
         return;
     }
-    for (i = 0; i < conf->bNumInterfaces; i++) {
+    for (i = 0; i < USB_MAX_INTERFACES; i++) {
         if (!s->ifs[i].detached) {
             continue;
         }
@@ -1145,7 +1145,7 @@ static int usb_host_claim_interfaces(USBHostDevice *s, int configuration)
 {
     USBDevice *udev = USB_DEVICE(s);
     struct libusb_config_descriptor *conf;
-    int rc, i;
+    int rc, i, claimed;
 
     for (i = 0; i < USB_MAX_INTERFACES; i++) {
         udev->altsetting[i] = 0;
@@ -1164,14 +1164,19 @@ static int usb_host_claim_interfaces(USBHostDevice *s, int configuration)
         return USB_RET_STALL;
     }
 
-    for (i = 0; i < conf->bNumInterfaces; i++) {
+    claimed = 0;
+    for (i = 0; i < USB_MAX_INTERFACES; i++) {
         trace_usb_host_claim_interface(s->bus_num, s->addr, configuration, i);
         rc = libusb_claim_interface(s->dh, i);
-        usb_host_libusb_error("libusb_claim_interface", rc);
-        if (rc != 0) {
-            return USB_RET_STALL;
+        if (rc == 0) {
+            s->ifs[i].claimed = true;
+            if (++claimed == conf->bNumInterfaces) {
+                break;
+            }
         }
-        s->ifs[i].claimed = true;
+    }
+    if (claimed != conf->bNumInterfaces) {
+        return USB_RET_STALL;
     }
 
     udev->ninterfaces   = conf->bNumInterfaces;
@@ -1183,10 +1188,9 @@ static int usb_host_claim_interfaces(USBHostDevice *s, int configuration)
 
 static void usb_host_release_interfaces(USBHostDevice *s)
 {
-    USBDevice *udev = USB_DEVICE(s);
     int i, rc;
 
-    for (i = 0; i < udev->ninterfaces; i++) {
+    for (i = 0; i < USB_MAX_INTERFACES; i++) {
         if (!s->ifs[i].claimed) {
             continue;
         }
-- 
2.9.3

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

* Re: [Qemu-devel] [PULL 0/1] Usb 20170621 patches
  2017-06-21 15:43 [Qemu-devel] [PULL 0/1] Usb 20170621 patches Gerd Hoffmann
  2017-06-21 15:43 ` [Qemu-devel] [PULL 1/1] usb-host: support devices with sparse/non-sequential USB interfaces Gerd Hoffmann
@ 2017-06-22 18:01 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2017-06-22 18:01 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On 21 June 2017 at 16:43, Gerd Hoffmann <kraxel@redhat.com> wrote:
> The following changes since commit 8dfaf23ae1f2273a9730a9b309cc8471269bb524:
>
>   tcg/tci: fix tcg-interpreter build (2017-06-20 18:39:15 +0100)
>
> are available in the git repository at:
>
>   git://git.kraxel.org/qemu tags/usb-20170621-pull-request
>
> for you to fetch changes up to 896b6757f9c4d176ce4439238efea223a2952411:
>
>   usb-host: support devices with sparse/non-sequential USB interfaces (2017-06-21 15:30:08 +0200)
>
> ----------------------------------------------------------------
>
> ----------------------------------------------------------------
>
> Samuel Brian (1):
>   usb-host: support devices with sparse/non-sequential USB interfaces
>
>  hw/usb/host-libusb.c | 24 ++++++++++++++----------
>  1 file changed, 14 insertions(+), 10 deletions(-)

Applied, thanks.

-- PMM

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

end of thread, other threads:[~2017-06-22 18:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-21 15:43 [Qemu-devel] [PULL 0/1] Usb 20170621 patches Gerd Hoffmann
2017-06-21 15:43 ` [Qemu-devel] [PULL 1/1] usb-host: support devices with sparse/non-sequential USB interfaces Gerd Hoffmann
2017-06-22 18:01 ` [Qemu-devel] [PULL 0/1] Usb 20170621 patches 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).