qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] usb-host: insert usb device into hostdevs to be scaned
@ 2018-08-16  9:43 linzhecheng
  2018-08-16 10:45 ` Gerd Hoffmann
  0 siblings, 1 reply; 8+ messages in thread
From: linzhecheng @ 2018-08-16  9:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: kraxel, wangxinxin.wang, linzhecheng

According to the comment of usb_host_post_load_bh, after removing the
usb device passed through, we will kick host to scan it again, but the emulated
usb device is not added to global list hostdevs, so it can never be discovered then.
So just do it before usb_host_auto_check. What's more, it's futile to walk devs in
usb_host_auto_check periodically if hostdevs is empty, so let's delete the usb_auto_timer.

Signed-off-by: linzhecheng <linzhecheng@huawei.com>

diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index f31e9cbbb8..632abaa390 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -1534,6 +1534,10 @@ static void usb_host_post_load_bh(void *opaque)
         usb_device_detach(udev);
     }
     dev->bh_postld_pending = false;
+    if (!dev->needs_autoscan) {
+        dev->needs_autoscan = true;
+        QTAILQ_INSERT_TAIL(&hostdevs, dev, next);
+    }
     usb_host_auto_check(NULL);
 }
 
@@ -1631,6 +1635,14 @@ static void usb_host_auto_check(void *unused)
     int unconnected = 0;
     int i, n;
 
+    if (QTAILQ_EMPTY(&hostdevs)) {
+        if (usb_auto_timer) {
+            timer_del(usb_auto_timer);
+            usb_auto_timer = NULL;
+        }
+        return;
+    }
+
     if (usb_host_init() != 0) {
         return;
     }
@@ -1682,6 +1694,8 @@ static void usb_host_auto_check(void *unused)
                     s->errcount++;
                     continue;
                 }
+                s->needs_autoscan = false;
+                QTAILQ_REMOVE(&hostdevs, s, next);
                 break;
             }
         }
-- 
2.12.2.windows.2

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

end of thread, other threads:[~2018-08-20  5:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-16  9:43 [Qemu-devel] [PATCH] usb-host: insert usb device into hostdevs to be scaned linzhecheng
2018-08-16 10:45 ` Gerd Hoffmann
2018-08-16 10:52   ` linzhecheng
2018-08-16 13:01     ` Gerd Hoffmann
2018-08-16 15:17       ` CheneyLin
2018-08-17  6:07         ` gerd hoffmann
2018-08-20  2:08           ` linzhecheng
2018-08-20  5:11             ` gerd hoffmann

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