From 5843b6b35250139d91220ac3b75d467703e345b3 Mon Sep 17 00:00:00 2001 From: Jason Andryuk Date: Fri, 6 Mar 2020 09:09:17 -0500 Subject: usb-serial: wakeup device on input Currently usb-serial devices are unable to send data into guests with the xhci controller. Data is copied into the usb-serial's buffer, but it is not sent into the guest. Data coming out of the guest works properly. usb-serial devices work properly with ehci. Have usb-serial call usb_wakeup() when receiving data from the chardev. This seems to notify the xhci controller and fix inbound data flow. Also add USB_CFG_ATT_WAKEUP to the device's bmAttributes. This matches a real FTDI serial adapter's bmAttributes. Signed-off-by: Jason Andryuk Message-id: 20200306140917.26726-1-jandryuk@gmail.com Signed-off-by: Gerd Hoffmann --- hw/usb/dev-serial.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index 98465990ef..daac75b7ae 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -98,6 +98,7 @@ do { printf("usb-serial: " fmt , ## __VA_ARGS__); } while (0) typedef struct { USBDevice dev; + USBEndpoint *intr; uint8_t recv_buf[RECV_BUF]; uint16_t recv_ptr; uint16_t recv_used; @@ -153,7 +154,7 @@ static const USBDescDevice desc_device = { { .bNumInterfaces = 1, .bConfigurationValue = 1, - .bmAttributes = USB_CFG_ATT_ONE, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_WAKEUP, .bMaxPower = 50, .nif = 1, .ifs = &desc_iface0, @@ -459,6 +460,8 @@ static void usb_serial_read(void *opaque, const uint8_t *buf, int size) memcpy(s->recv_buf + start, buf, size); } s->recv_used += size; + + usb_wakeup(s->intr, 0); } static void usb_serial_event(void *opaque, QEMUChrEvent event) @@ -513,6 +516,7 @@ static void usb_serial_realize(USBDevice *dev, Error **errp) if (qemu_chr_fe_backend_open(&s->cs) && !dev->attached) { usb_device_attach(dev, &error_abort); } + s->intr = usb_ep_get(dev, USB_TOKEN_IN, 1); } static USBDevice *usb_braille_init(USBBus *bus, const char *unused) -- cgit v1.2.3 From e13a22db0d47012e19ad02c9dafacbe25f94e1b4 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Wed, 26 Feb 2020 16:46:46 +0800 Subject: usb/hcd-ehci: Remove redundant statements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "again" assignment is meaningless before g_assert_not_reached. In addition, the break statements no longer needs to be after g_assert_not_reached. Clang static code analyzer show warning: hw/usb/hcd-ehci.c:2108:13: warning: Value stored to 'again' is never read again = -1; ^ ~~ Reported-by: Euler Robot Signed-off-by: Chen Qun Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20200226084647.20636-13-kuhn.chenqun@huawei.com> Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ehci.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 56ab2f457f..29d49c2d7e 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -1301,7 +1301,6 @@ static void ehci_execute_complete(EHCIQueue *q) /* should not be triggerable */ fprintf(stderr, "USB invalid response %d\n", p->packet.status); g_assert_not_reached(); - break; } /* TODO check 4.12 for splits */ @@ -2105,9 +2104,7 @@ static void ehci_advance_state(EHCIState *ehci, int async) default: fprintf(stderr, "Bad state!\n"); - again = -1; g_assert_not_reached(); - break; } if (again < 0 || itd_count > 16) { -- cgit v1.2.3