* [PATCH 0/2] usb-host: windows support
@ 2021-06-23 8:52 Gerd Hoffmann
2021-06-23 8:52 ` [PATCH 1/2] usb-host: wire up timer for windows Gerd Hoffmann
2021-06-23 8:52 ` [PATCH 2/2] ci: add libusb for windows builds Gerd Hoffmann
0 siblings, 2 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2021-06-23 8:52 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Huth, Philippe Mathieu-Daudé,
Wainer dos Santos Moschetta, Willian Rampazzo, Gerd Hoffmann,
Alex Bennée
Gerd Hoffmann (2):
usb-host: wire up timer for windows
ci: add libusb for windows builds
hw/usb/host-libusb.c | 33 ++++++++++++++++++-
.../dockerfiles/fedora-win32-cross.docker | 1 +
.../dockerfiles/fedora-win64-cross.docker | 1 +
3 files changed, 34 insertions(+), 1 deletion(-)
--
2.31.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] usb-host: wire up timer for windows
2021-06-23 8:52 [PATCH 0/2] usb-host: windows support Gerd Hoffmann
@ 2021-06-23 8:52 ` Gerd Hoffmann
2021-06-23 8:52 ` [PATCH 2/2] ci: add libusb for windows builds Gerd Hoffmann
1 sibling, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2021-06-23 8:52 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Huth, Philippe Mathieu-Daudé,
Wainer dos Santos Moschetta, Willian Rampazzo, Gerd Hoffmann,
Alex Bennée
On windows we can't wait on file descriptors.
Poll libusb using a timer instead.
Fixes long-standing FIXME.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/431
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/usb/host-libusb.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 2518306f527f..60cbaf6fdea1 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);
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ci: add libusb for windows builds
2021-06-23 8:52 [PATCH 0/2] usb-host: windows support Gerd Hoffmann
2021-06-23 8:52 ` [PATCH 1/2] usb-host: wire up timer for windows Gerd Hoffmann
@ 2021-06-23 8:52 ` Gerd Hoffmann
2021-07-05 14:50 ` Willian Rampazzo
1 sibling, 1 reply; 4+ messages in thread
From: Gerd Hoffmann @ 2021-06-23 8:52 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Huth, Philippe Mathieu-Daudé,
Wainer dos Santos Moschetta, Willian Rampazzo, Gerd Hoffmann,
Alex Bennée
Add CI coverage for usb passthrough on windows.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
tests/docker/dockerfiles/fedora-win32-cross.docker | 1 +
tests/docker/dockerfiles/fedora-win64-cross.docker | 1 +
2 files changed, 2 insertions(+)
diff --git a/tests/docker/dockerfiles/fedora-win32-cross.docker b/tests/docker/dockerfiles/fedora-win32-cross.docker
index a638afb525ce..2c87d70e4f57 100644
--- a/tests/docker/dockerfiles/fedora-win32-cross.docker
+++ b/tests/docker/dockerfiles/fedora-win32-cross.docker
@@ -23,6 +23,7 @@ ENV PACKAGES \
mingw32-libjpeg-turbo \
mingw32-libpng \
mingw32-libtasn1 \
+ mingw32-libusbx \
mingw32-nettle \
mingw32-nsis \
mingw32-pixman \
diff --git a/tests/docker/dockerfiles/fedora-win64-cross.docker b/tests/docker/dockerfiles/fedora-win64-cross.docker
index f53007ac865e..f0f9057c1baa 100644
--- a/tests/docker/dockerfiles/fedora-win64-cross.docker
+++ b/tests/docker/dockerfiles/fedora-win64-cross.docker
@@ -22,6 +22,7 @@ ENV PACKAGES \
mingw64-libjpeg-turbo \
mingw64-libpng \
mingw64-libtasn1 \
+ mingw64-libusbx \
mingw64-pixman \
mingw64-pkg-config \
perl \
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] ci: add libusb for windows builds
2021-06-23 8:52 ` [PATCH 2/2] ci: add libusb for windows builds Gerd Hoffmann
@ 2021-07-05 14:50 ` Willian Rampazzo
0 siblings, 0 replies; 4+ messages in thread
From: Willian Rampazzo @ 2021-07-05 14:50 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: Thomas Huth, Alex Bennée, qemu-devel,
Wainer dos Santos Moschetta, Philippe Mathieu-Daudé
On Wed, Jun 23, 2021 at 5:53 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> Add CI coverage for usb passthrough on windows.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> tests/docker/dockerfiles/fedora-win32-cross.docker | 1 +
> tests/docker/dockerfiles/fedora-win64-cross.docker | 1 +
> 2 files changed, 2 insertions(+)
>
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-07-05 14:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23 8:52 [PATCH 0/2] usb-host: windows support Gerd Hoffmann
2021-06-23 8:52 ` [PATCH 1/2] usb-host: wire up timer for windows Gerd Hoffmann
2021-06-23 8:52 ` [PATCH 2/2] ci: add libusb for windows builds Gerd Hoffmann
2021-07-05 14:50 ` Willian Rampazzo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.