diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2021-07-29 18:49:39 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2021-07-29 18:49:39 +0100 |
commit | 7742fe64e5c2c2c9f9787d107b693eaac602eaae (patch) | |
tree | 0ba8811c5399056073f4d9402df8dce6c161c8c1 /hw | |
parent | 768832575d2e37042d00eb693cda809cb30981d4 (diff) | |
parent | 30a20f2c5a9cf8f01ffcc918a7a5751dfe956524 (diff) |
Merge remote-tracking branch 'remotes/kraxel/tags/usb-20210729-pull-request' into staging
usb: fixes for 6.1: usbredir, usb-host for windows, docs.
# gpg: Signature made Thu 29 Jul 2021 13:50:32 BST
# gpg: using RSA key A0328CFFB93A17A79901FE7D4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full]
# gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full]
# gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full]
# Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138
* remotes/kraxel/tags/usb-20210729-pull-request:
docs: Fold usb2.txt passthrough information into usb.rst
docs: Fold usb2.txt physical port addressing info into usb.rst
docs: Fold usb2.txt USB controller information into usb.rst
docs: Incorporate information in usb-storage.txt into rST manual
usbredir: fix free call
ci: add libusb for windows builds
usb-host: wire up timer for windows
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/usb/host-libusb.c | 33 | ||||
-rw-r--r-- | hw/usb/redirect.c | 2 |
2 files changed, 33 insertions, 2 deletions
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index c0f314462a..00f6fbb29b 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -254,6 +254,29 @@ static void usb_host_del_fd(int fd, void *user_data) qemu_set_fd_handler(fd, NULL, NULL, NULL); } +#else + +static QEMUTimer *poll_timer; +static uint32_t request_count; + +static void usb_host_timer_kick(void) +{ + int64_t delay_ns; + + delay_ns = request_count + ? (NANOSECONDS_PER_SECOND / 100) /* 10 ms interval with active req */ + : (NANOSECONDS_PER_SECOND); /* 1 sec interval otherwise */ + timer_mod(poll_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + delay_ns); +} + +static void usb_host_timer(void *opaque) +{ + struct timeval tv = { 0, 0 }; + + libusb_handle_events_timeout(ctx, &tv); + usb_host_timer_kick(); +} + #endif /* !CONFIG_WIN32 */ static int usb_host_init(void) @@ -276,7 +299,8 @@ static int usb_host_init(void) libusb_set_debug(ctx, loglevel); #endif #ifdef CONFIG_WIN32 - /* FIXME: add support for Windows. */ + poll_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, usb_host_timer, NULL); + usb_host_timer_kick(); #else libusb_set_pollfd_notifiers(ctx, usb_host_add_fd, usb_host_del_fd, @@ -364,11 +388,18 @@ static USBHostRequest *usb_host_req_alloc(USBHostDevice *s, USBPacket *p, r->buffer = g_malloc(bufsize); } QTAILQ_INSERT_TAIL(&s->requests, r, next); +#ifdef CONFIG_WIN32 + request_count++; + usb_host_timer_kick(); +#endif return r; } static void usb_host_req_free(USBHostRequest *r) { +#ifdef CONFIG_WIN32 + request_count--; +#endif QTAILQ_REMOVE(&r->host->requests, r, next); libusb_free_transfer(r->xfer); g_free(r->buffer); diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 4ec9326e05..1ec909a63a 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -476,7 +476,7 @@ static int bufp_alloc(USBRedirDevice *dev, uint8_t *data, uint16_t len, if (dev->endpoint[EP2I(ep)].bufpq_dropping_packets) { if (dev->endpoint[EP2I(ep)].bufpq_size > dev->endpoint[EP2I(ep)].bufpq_target_size) { - free(data); + free(free_on_destroy); return -1; } dev->endpoint[EP2I(ep)].bufpq_dropping_packets = 0; |