All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 1/4] usb/ohci: Move cancelling async packet to ohci_stop_endpoints()
  2021-10-01 21:11 [RFC PATCH 0/4] Misc OHCI patches BALATON Zoltan
  2021-10-01 21:11 ` [RFC PATCH 2/4] usb/ohci: Move USBPortOps related functions together BALATON Zoltan
@ 2021-10-01 21:11 ` BALATON Zoltan
  2021-10-01 21:11 ` [RFC PATCH 3/4] usb/ohci: Merge ohci_async_cancel_device() into ohci_child_detach() BALATON Zoltan
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: BALATON Zoltan @ 2021-10-01 21:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland, Gerd Hoffmann, Howard Spoelstra

This is always done before calling this function so remove duplicated
code and do it within the function at one place.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 hw/usb/hcd-ohci.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 1cf2816772..405abbb62d 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -369,6 +369,10 @@ void ohci_stop_endpoints(OHCIState *ohci)
     USBDevice *dev;
     int i, j;
 
+    if (ohci->async_td) {
+        usb_cancel_packet(&ohci->usb_packet);
+        ohci->async_td = 0;
+    }
     for (i = 0; i < ohci->num_ports; i++) {
         dev = ohci->rhport[i].port.dev;
         if (dev && dev->attached) {
@@ -398,10 +402,6 @@ static void ohci_roothub_reset(OHCIState *ohci)
             usb_port_reset(&port->port);
         }
     }
-    if (ohci->async_td) {
-        usb_cancel_packet(&ohci->usb_packet);
-        ohci->async_td = 0;
-    }
     ohci_stop_endpoints(ohci);
 }
 
@@ -1271,10 +1271,6 @@ static void ohci_frame_boundary(void *opaque)
 
     /* Cancel all pending packets if either of the lists has been disabled.  */
     if (ohci->old_ctl & (~ohci->ctl) & (OHCI_CTL_BLE | OHCI_CTL_CLE)) {
-        if (ohci->async_td) {
-            usb_cancel_packet(&ohci->usb_packet);
-            ohci->async_td = 0;
-        }
         ohci_stop_endpoints(ohci);
     }
     ohci->old_ctl = ohci->ctl;
-- 
2.21.4



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

* [RFC PATCH 2/4] usb/ohci: Move USBPortOps related functions together
  2021-10-01 21:11 [RFC PATCH 0/4] Misc OHCI patches BALATON Zoltan
@ 2021-10-01 21:11 ` BALATON Zoltan
  2021-10-01 21:11 ` [RFC PATCH 1/4] usb/ohci: Move cancelling async packet to ohci_stop_endpoints() BALATON Zoltan
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: BALATON Zoltan @ 2021-10-01 21:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland, Gerd Hoffmann, Howard Spoelstra

This also allows removing two forward declarations

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 hw/usb/hcd-ohci.c | 204 +++++++++++++++++++++++-----------------------
 1 file changed, 100 insertions(+), 104 deletions(-)

diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 405abbb62d..f8761370e3 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -58,8 +58,6 @@ struct ohci_hcca {
 #define ED_WBACK_OFFSET offsetof(struct ohci_ed, head)
 #define ED_WBACK_SIZE   4
 
-static void ohci_async_cancel_device(OHCIState *ohci, USBDevice *dev);
-
 /* Bitfields for the first word of an Endpoint Desciptor.  */
 #define OHCI_ED_FA_SHIFT  0
 #define OHCI_ED_FA_MASK   (0x7f<<OHCI_ED_FA_SHIFT)
@@ -261,92 +259,6 @@ static inline void ohci_set_interrupt(OHCIState *ohci, uint32_t intr)
     ohci_intr_update(ohci);
 }
 
-/* Attach or detach a device on a root hub port.  */
-static void ohci_attach(USBPort *port1)
-{
-    OHCIState *s = port1->opaque;
-    OHCIPort *port = &s->rhport[port1->index];
-    uint32_t old_state = port->ctrl;
-
-    /* set connect status */
-    port->ctrl |= OHCI_PORT_CCS | OHCI_PORT_CSC;
-
-    /* update speed */
-    if (port->port.dev->speed == USB_SPEED_LOW) {
-        port->ctrl |= OHCI_PORT_LSDA;
-    } else {
-        port->ctrl &= ~OHCI_PORT_LSDA;
-    }
-
-    /* notify of remote-wakeup */
-    if ((s->ctl & OHCI_CTL_HCFS) == OHCI_USB_SUSPEND) {
-        ohci_set_interrupt(s, OHCI_INTR_RD);
-    }
-
-    trace_usb_ohci_port_attach(port1->index);
-
-    if (old_state != port->ctrl) {
-        ohci_set_interrupt(s, OHCI_INTR_RHSC);
-    }
-}
-
-static void ohci_detach(USBPort *port1)
-{
-    OHCIState *s = port1->opaque;
-    OHCIPort *port = &s->rhport[port1->index];
-    uint32_t old_state = port->ctrl;
-
-    ohci_async_cancel_device(s, port1->dev);
-
-    /* set connect status */
-    if (port->ctrl & OHCI_PORT_CCS) {
-        port->ctrl &= ~OHCI_PORT_CCS;
-        port->ctrl |= OHCI_PORT_CSC;
-    }
-    /* disable port */
-    if (port->ctrl & OHCI_PORT_PES) {
-        port->ctrl &= ~OHCI_PORT_PES;
-        port->ctrl |= OHCI_PORT_PESC;
-    }
-    trace_usb_ohci_port_detach(port1->index);
-
-    if (old_state != port->ctrl) {
-        ohci_set_interrupt(s, OHCI_INTR_RHSC);
-    }
-}
-
-static void ohci_wakeup(USBPort *port1)
-{
-    OHCIState *s = port1->opaque;
-    OHCIPort *port = &s->rhport[port1->index];
-    uint32_t intr = 0;
-    if (port->ctrl & OHCI_PORT_PSS) {
-        trace_usb_ohci_port_wakeup(port1->index);
-        port->ctrl |= OHCI_PORT_PSSC;
-        port->ctrl &= ~OHCI_PORT_PSS;
-        intr = OHCI_INTR_RHSC;
-    }
-    /* Note that the controller can be suspended even if this port is not */
-    if ((s->ctl & OHCI_CTL_HCFS) == OHCI_USB_SUSPEND) {
-        trace_usb_ohci_remote_wakeup(s->name);
-        /* This is the one state transition the controller can do by itself */
-        s->ctl &= ~OHCI_CTL_HCFS;
-        s->ctl |= OHCI_USB_RESUME;
-        /* In suspend mode only ResumeDetected is possible, not RHSC:
-         * see the OHCI spec 5.1.2.3.
-         */
-        intr = OHCI_INTR_RD;
-    }
-    ohci_set_interrupt(s, intr);
-}
-
-static void ohci_child_detach(USBPort *port1, USBDevice *child)
-{
-    OHCIState *s = port1->opaque;
-
-    ohci_async_cancel_device(s, child);
-}
-
 static USBDevice *ohci_find_device(OHCIState *ohci, uint8_t addr)
 {
     USBDevice *dev;
@@ -628,17 +540,6 @@ static int ohci_copy_iso_td(OHCIState *ohci,
     return 0;
 }
 
-static void ohci_process_lists(OHCIState *ohci, int completion);
-
-static void ohci_async_complete_packet(USBPort *port, USBPacket *packet)
-{
-    OHCIState *ohci = container_of(packet, OHCIState, usb_packet);
-
-    trace_usb_ohci_async_complete();
-    ohci->async_complete = true;
-    ohci_process_lists(ohci, 1);
-}
-
 #define USUB(a, b) ((int16_t)((uint16_t)(a) - (uint16_t)(b)))
 
 static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed,
@@ -1783,6 +1684,41 @@ static void ohci_mem_write(void *opaque,
     }
 }
 
+static const MemoryRegionOps ohci_mem_ops = {
+    .read = ohci_mem_read,
+    .write = ohci_mem_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+};
+
+/* USBPortOps */
+static void ohci_attach(USBPort *port1)
+{
+    OHCIState *s = port1->opaque;
+    OHCIPort *port = &s->rhport[port1->index];
+    uint32_t old_state = port->ctrl;
+
+    /* set connect status */
+    port->ctrl |= OHCI_PORT_CCS | OHCI_PORT_CSC;
+
+    /* update speed */
+    if (port->port.dev->speed == USB_SPEED_LOW) {
+        port->ctrl |= OHCI_PORT_LSDA;
+    } else {
+        port->ctrl &= ~OHCI_PORT_LSDA;
+    }
+
+    /* notify of remote-wakeup */
+    if ((s->ctl & OHCI_CTL_HCFS) == OHCI_USB_SUSPEND) {
+        ohci_set_interrupt(s, OHCI_INTR_RD);
+    }
+
+    trace_usb_ohci_port_attach(port1->index);
+
+    if (old_state != port->ctrl) {
+        ohci_set_interrupt(s, OHCI_INTR_RHSC);
+    }
+}
+
 static void ohci_async_cancel_device(OHCIState *ohci, USBDevice *dev)
 {
     if (ohci->async_td &&
@@ -1793,11 +1729,71 @@ static void ohci_async_cancel_device(OHCIState *ohci, USBDevice *dev)
     }
 }
 
-static const MemoryRegionOps ohci_mem_ops = {
-    .read = ohci_mem_read,
-    .write = ohci_mem_write,
-    .endianness = DEVICE_LITTLE_ENDIAN,
-};
+static void ohci_child_detach(USBPort *port1, USBDevice *child)
+{
+    OHCIState *s = port1->opaque;
+
+    ohci_async_cancel_device(s, child);
+}
+
+static void ohci_detach(USBPort *port1)
+{
+    OHCIState *s = port1->opaque;
+    OHCIPort *port = &s->rhport[port1->index];
+    uint32_t old_state = port->ctrl;
+
+    ohci_async_cancel_device(s, port1->dev);
+
+    /* set connect status */
+    if (port->ctrl & OHCI_PORT_CCS) {
+        port->ctrl &= ~OHCI_PORT_CCS;
+        port->ctrl |= OHCI_PORT_CSC;
+    }
+    /* disable port */
+    if (port->ctrl & OHCI_PORT_PES) {
+        port->ctrl &= ~OHCI_PORT_PES;
+        port->ctrl |= OHCI_PORT_PESC;
+    }
+    trace_usb_ohci_port_detach(port1->index);
+
+    if (old_state != port->ctrl) {
+        ohci_set_interrupt(s, OHCI_INTR_RHSC);
+    }
+}
+
+static void ohci_wakeup(USBPort *port1)
+{
+    OHCIState *s = port1->opaque;
+    OHCIPort *port = &s->rhport[port1->index];
+    uint32_t intr = 0;
+    if (port->ctrl & OHCI_PORT_PSS) {
+        trace_usb_ohci_port_wakeup(port1->index);
+        port->ctrl |= OHCI_PORT_PSSC;
+        port->ctrl &= ~OHCI_PORT_PSS;
+        intr = OHCI_INTR_RHSC;
+    }
+    /* Note that the controller can be suspended even if this port is not */
+    if ((s->ctl & OHCI_CTL_HCFS) == OHCI_USB_SUSPEND) {
+        trace_usb_ohci_remote_wakeup(s->name);
+        /* This is the one state transition the controller can do by itself */
+        s->ctl &= ~OHCI_CTL_HCFS;
+        s->ctl |= OHCI_USB_RESUME;
+        /* In suspend mode only ResumeDetected is possible, not RHSC:
+         * see the OHCI spec 5.1.2.3.
+         */
+        intr = OHCI_INTR_RD;
+    }
+    ohci_set_interrupt(s, intr);
+}
+
+static void ohci_async_complete_packet(USBPort *port, USBPacket *packet)
+{
+    OHCIState *ohci = container_of(packet, OHCIState, usb_packet);
+
+    trace_usb_ohci_async_complete();
+    ohci->async_complete = true;
+    ohci_process_lists(ohci, 1);
+}
 
 static USBPortOps ohci_port_ops = {
     .attach = ohci_attach,
-- 
2.21.4



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

* [RFC PATCH 3/4] usb/ohci: Merge ohci_async_cancel_device() into ohci_child_detach()
  2021-10-01 21:11 [RFC PATCH 0/4] Misc OHCI patches BALATON Zoltan
  2021-10-01 21:11 ` [RFC PATCH 2/4] usb/ohci: Move USBPortOps related functions together BALATON Zoltan
  2021-10-01 21:11 ` [RFC PATCH 1/4] usb/ohci: Move cancelling async packet to ohci_stop_endpoints() BALATON Zoltan
@ 2021-10-01 21:11 ` BALATON Zoltan
  2021-10-01 21:11 ` [RFC PATCH 4/4] usb/ohci: Don't use packet from OHCIState for isochronous transfers BALATON Zoltan
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: BALATON Zoltan @ 2021-10-01 21:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland, Gerd Hoffmann, Howard Spoelstra

These two do the same and only used once so no need to have two
functions, simplify by merging them.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 hw/usb/hcd-ohci.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index f8761370e3..212d0aabbe 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1719,8 +1719,10 @@ static void ohci_attach(USBPort *port1)
     }
 }
 
-static void ohci_async_cancel_device(OHCIState *ohci, USBDevice *dev)
+static void ohci_child_detach(USBPort *port1, USBDevice *dev)
 {
+    OHCIState *ohci = port1->opaque;
+
     if (ohci->async_td &&
         usb_packet_is_inflight(&ohci->usb_packet) &&
         ohci->usb_packet.ep->dev == dev) {
@@ -1729,20 +1731,13 @@ static void ohci_async_cancel_device(OHCIState *ohci, USBDevice *dev)
     }
 }
 
-static void ohci_child_detach(USBPort *port1, USBDevice *child)
-{
-    OHCIState *s = port1->opaque;
-
-    ohci_async_cancel_device(s, child);
-}
-
 static void ohci_detach(USBPort *port1)
 {
     OHCIState *s = port1->opaque;
     OHCIPort *port = &s->rhport[port1->index];
     uint32_t old_state = port->ctrl;
 
-    ohci_async_cancel_device(s, port1->dev);
+    ohci_child_detach(port1, port1->dev);
 
     /* set connect status */
     if (port->ctrl & OHCI_PORT_CCS) {
-- 
2.21.4



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

* [RFC PATCH 4/4] usb/ohci: Don't use packet from OHCIState for isochronous transfers
  2021-10-01 21:11 [RFC PATCH 0/4] Misc OHCI patches BALATON Zoltan
                   ` (2 preceding siblings ...)
  2021-10-01 21:11 ` [RFC PATCH 3/4] usb/ohci: Merge ohci_async_cancel_device() into ohci_child_detach() BALATON Zoltan
@ 2021-10-01 21:11 ` BALATON Zoltan
  2021-10-02 13:50 ` [RFC PATCH 0/4] Misc OHCI patches Howard Spoelstra
  2021-10-02 14:37 ` BALATON Zoltan
  5 siblings, 0 replies; 15+ messages in thread
From: BALATON Zoltan @ 2021-10-01 21:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland, Gerd Hoffmann, Howard Spoelstra

Since isochronous transfers cannot be handled async (the function
returns error in that case) we don't need to remember the packet.
Avoid using the usb_pkt in OHCIState (as that can be a waiting async
packet on another endpoint) and allocate and use a local USBPacket for
the iso transfer instead. After this we don't have to care if we're
called from a completion callback or not so we can drop that parameter
as well.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 hw/usb/hcd-ohci.c | 70 +++++++++++++++++++++++++----------------------
 1 file changed, 37 insertions(+), 33 deletions(-)

diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 212d0aabbe..18170e7256 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -542,8 +542,7 @@ static int ohci_copy_iso_td(OHCIState *ohci,
 
 #define USUB(a, b) ((int16_t)((uint16_t)(a) - (uint16_t)(b)))
 
-static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed,
-                               int completion)
+static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed)
 {
     int dir;
     size_t len = 0;
@@ -553,6 +552,9 @@ static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed,
     int i;
     USBDevice *dev;
     USBEndpoint *ep;
+    USBPacket *pkt;
+    uint8_t buf[8192];
+    bool int_req;
     struct ohci_iso_td iso_td;
     uint32_t addr;
     uint16_t starting_frame;
@@ -687,40 +689,42 @@ static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed,
     } else {
         len = end_addr - start_addr + 1;
     }
-    if (len > sizeof(ohci->usb_buf)) {
-        len = sizeof(ohci->usb_buf);
+    if (len > sizeof(buf)) {
+        len = sizeof(buf);
     }
 
     if (len && dir != OHCI_TD_DIR_IN) {
-        if (ohci_copy_iso_td(ohci, start_addr, end_addr, ohci->usb_buf, len,
+        if (ohci_copy_iso_td(ohci, start_addr, end_addr, buf, len,
                              DMA_DIRECTION_TO_DEVICE)) {
             ohci_die(ohci);
             return 1;
         }
     }
 
-    if (!completion) {
-        bool int_req = relative_frame_number == frame_count &&
-                       OHCI_BM(iso_td.flags, TD_DI) == 0;
-        dev = ohci_find_device(ohci, OHCI_BM(ed->flags, ED_FA));
-        if (dev == NULL) {
-            trace_usb_ohci_td_dev_error();
-            return 1;
-        }
-        ep = usb_ep_get(dev, pid, OHCI_BM(ed->flags, ED_EN));
-        usb_packet_setup(&ohci->usb_packet, pid, ep, 0, addr, false, int_req);
-        usb_packet_addbuf(&ohci->usb_packet, ohci->usb_buf, len);
-        usb_handle_packet(dev, &ohci->usb_packet);
-        if (ohci->usb_packet.status == USB_RET_ASYNC) {
-            usb_device_flush_ep_queue(dev, ep);
-            return 1;
-        }
+    dev = ohci_find_device(ohci, OHCI_BM(ed->flags, ED_FA));
+    if (dev == NULL) {
+        trace_usb_ohci_td_dev_error();
+        return 1;
     }
-    if (ohci->usb_packet.status == USB_RET_SUCCESS) {
-        ret = ohci->usb_packet.actual_length;
+    ep = usb_ep_get(dev, pid, OHCI_BM(ed->flags, ED_EN));
+    pkt = g_new0(USBPacket, 1);
+    usb_packet_init(pkt);
+    int_req = relative_frame_number == frame_count &&
+              OHCI_BM(iso_td.flags, TD_DI) == 0;
+    usb_packet_setup(pkt, pid, ep, 0, addr, false, int_req);
+    usb_packet_addbuf(pkt, buf, len);
+    usb_handle_packet(dev, pkt);
+    if (pkt->status == USB_RET_ASYNC) {
+        usb_device_flush_ep_queue(dev, ep);
+        g_free(pkt);
+        return 1;
+    }
+    if (pkt->status == USB_RET_SUCCESS) {
+        ret = pkt->actual_length;
     } else {
-        ret = ohci->usb_packet.status;
+        ret = pkt->status;
     }
+    g_free(pkt);
 
     trace_usb_ohci_iso_td_so(start_offset, end_offset, start_addr, end_addr,
                              str, len, ret);
@@ -728,7 +732,7 @@ static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed,
     /* Writeback */
     if (dir == OHCI_TD_DIR_IN && ret >= 0 && ret <= len) {
         /* IN transfer succeeded */
-        if (ohci_copy_iso_td(ohci, start_addr, end_addr, ohci->usb_buf, ret,
+        if (ohci_copy_iso_td(ohci, start_addr, end_addr, buf, ret,
                              DMA_DIRECTION_FROM_DEVICE)) {
             ohci_die(ohci);
             return 1;
@@ -1051,7 +1055,7 @@ exit_no_retire:
 }
 
 /* Service an endpoint list.  Returns nonzero if active TD were found.  */
-static int ohci_service_ed_list(OHCIState *ohci, uint32_t head, int completion)
+static int ohci_service_ed_list(OHCIState *ohci, uint32_t head)
 {
     struct ohci_ed ed;
     uint32_t next_ed;
@@ -1102,7 +1106,7 @@ static int ohci_service_ed_list(OHCIState *ohci, uint32_t head, int completion)
                     break;
             } else {
                 /* Handle isochronous endpoints */
-                if (ohci_service_iso_td(ohci, &ed, completion))
+                if (ohci_service_iso_td(ohci, &ed))
                     break;
             }
         }
@@ -1130,20 +1134,20 @@ static void ohci_sof(OHCIState *ohci)
 }
 
 /* Process Control and Bulk lists.  */
-static void ohci_process_lists(OHCIState *ohci, int completion)
+static void ohci_process_lists(OHCIState *ohci)
 {
     if ((ohci->ctl & OHCI_CTL_CLE) && (ohci->status & OHCI_STATUS_CLF)) {
         if (ohci->ctrl_cur && ohci->ctrl_cur != ohci->ctrl_head) {
             trace_usb_ohci_process_lists(ohci->ctrl_head, ohci->ctrl_cur);
         }
-        if (!ohci_service_ed_list(ohci, ohci->ctrl_head, completion)) {
+        if (!ohci_service_ed_list(ohci, ohci->ctrl_head)) {
             ohci->ctrl_cur = 0;
             ohci->status &= ~OHCI_STATUS_CLF;
         }
     }
 
     if ((ohci->ctl & OHCI_CTL_BLE) && (ohci->status & OHCI_STATUS_BLF)) {
-        if (!ohci_service_ed_list(ohci, ohci->bulk_head, completion)) {
+        if (!ohci_service_ed_list(ohci, ohci->bulk_head)) {
             ohci->bulk_cur = 0;
             ohci->status &= ~OHCI_STATUS_BLF;
         }
@@ -1167,7 +1171,7 @@ static void ohci_frame_boundary(void *opaque)
         int n;
 
         n = ohci->frame_number & 0x1f;
-        ohci_service_ed_list(ohci, le32_to_cpu(hcca.intr[n]), 0);
+        ohci_service_ed_list(ohci, le32_to_cpu(hcca.intr[n]));
     }
 
     /* Cancel all pending packets if either of the lists has been disabled.  */
@@ -1175,7 +1179,7 @@ static void ohci_frame_boundary(void *opaque)
         ohci_stop_endpoints(ohci);
     }
     ohci->old_ctl = ohci->ctl;
-    ohci_process_lists(ohci, 0);
+    ohci_process_lists(ohci);
 
     /* Stop if UnrecoverableError happened or ohci_sof will crash */
     if (ohci->intr_status & OHCI_INTR_UE) {
@@ -1787,7 +1791,7 @@ static void ohci_async_complete_packet(USBPort *port, USBPacket *packet)
 
     trace_usb_ohci_async_complete();
     ohci->async_complete = true;
-    ohci_process_lists(ohci, 1);
+    ohci_process_lists(ohci);
 }
 
 static USBPortOps ohci_port_ops = {
-- 
2.21.4



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

* [RFC PATCH 0/4] Misc OHCI patches
@ 2021-10-01 21:11 BALATON Zoltan
  2021-10-01 21:11 ` [RFC PATCH 2/4] usb/ohci: Move USBPortOps related functions together BALATON Zoltan
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: BALATON Zoltan @ 2021-10-01 21:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland, Gerd Hoffmann, Howard Spoelstra

Hello,

This is a first attempt to make some progress with the problems found
with OHCI especially when trying to pass through a usb sound card on
mac99. This does not go all the way to allow multiple async packets on
different endpoints yet but as a first step just try to fix the
interaction and potential breakage of pending async packet by
isochronous transfers. Plus some small clean ups I've found while
trying to make sense of this device model.

Posted as RFC because it's unfinfished and untested as there seems to
be some regression with mac99 so it does not boot for me for some
reason I haven't debugged yet. Hope Howard can test it and see if it
changes any of the traces seen before.

BALATON Zoltan (4):
  usb/ohci: Move cancelling async packet to ohci_stop_endpoints()
  usb/ohci: Move USBPortOps related functions together
  usb/ohci: Merge ohci_async_cancel_device() into ohci_child_detach()
  usb/ohci: Don't use packet from OHCIState for isochronous transfers

 hw/usb/hcd-ohci.c | 281 ++++++++++++++++++++++------------------------
 1 file changed, 136 insertions(+), 145 deletions(-)

-- 
2.21.4



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

* Re: [RFC PATCH 0/4] Misc OHCI patches
  2021-10-01 21:11 [RFC PATCH 0/4] Misc OHCI patches BALATON Zoltan
                   ` (3 preceding siblings ...)
  2021-10-01 21:11 ` [RFC PATCH 4/4] usb/ohci: Don't use packet from OHCIState for isochronous transfers BALATON Zoltan
@ 2021-10-02 13:50 ` Howard Spoelstra
  2021-10-02 14:10   ` BALATON Zoltan
  2021-10-02 15:42   ` BALATON Zoltan
  2021-10-02 14:37 ` BALATON Zoltan
  5 siblings, 2 replies; 15+ messages in thread
From: Howard Spoelstra @ 2021-10-02 13:50 UTC (permalink / raw)
  To: BALATON Zoltan; +Cc: Mark Cave-Ayland, qemu-devel qemu-devel, Gerd Hoffmann


[-- Attachment #1.1: Type: text/plain, Size: 7915 bytes --]

On Fri, Oct 1, 2021 at 11:16 PM BALATON Zoltan <balaton@eik.bme.hu> wrote:

> Hello,
>
> This is a first attempt to make some progress with the problems found
> with OHCI especially when trying to pass through a usb sound card on
> mac99. This does not go all the way to allow multiple async packets on
> different endpoints yet but as a first step just try to fix the
> interaction and potential breakage of pending async packet by
> isochronous transfers. Plus some small clean ups I've found while
> trying to make sense of this device model.
>
> Posted as RFC because it's unfinfished and untested as there seems to
> be some regression with mac99 so it does not boot for me for some
> reason I haven't debugged yet. Hope Howard can test it and see if it
> changes any of the traces seen before.
>
> BALATON Zoltan (4):
>   usb/ohci: Move cancelling async packet to ohci_stop_endpoints()
>   usb/ohci: Move USBPortOps related functions together
>   usb/ohci: Merge ohci_async_cancel_device() into ohci_child_detach()
>   usb/ohci: Don't use packet from OHCIState for isochronous transfers
>
>  hw/usb/hcd-ohci.c | 281 ++++++++++++++++++++++------------------------
>  1 file changed, 136 insertions(+), 145 deletions(-)
>
>
>
Hi all,

I've booted Fedora12 and MacOS 9.2/OSX10.4 ppc with these patches applied.
All boot OK.
(Fedora12 requires -mac99,via=pmu. Here there seems to be some interference
with the kbd, due to via=pmu presenting usb mouse and kdb to the guest. So
I could not test this further.).
All tests done in Fedora 34 host with current master and patched build.

./qemu-system-ppc-ohcipatch02102021 \
-M mac99 \
-L pc-bios \
-display gtk \
-m 512 \
-boot c \
-hda /home/hsp/Mac-disks/10.4.qcow2 \
-device
usb-host,loglevel=4,vendorid=0x046d,productid=0x0a37,pcap=ohci-usb1headset-usb1port-ohcipatchV1-macos104.pcap
\
-trace "usb_*" -D ohci-usb1headset-usb1port-ohcipatchV1-macos104.txt

Endpoint 4 is the interrupt-based hid device, endpoint 1 would be the
isochronous audio stream if it showed up.
Each test consisted of booting to the desktop, opening the system
profiler/system report to check of the presence of the usb device, push the
various buttons on the headset, attempt to play a sound, unplug-replug and
attempt to play a sound again. Then shut down.

Both succesfully open the usb device:
usb_ohci_init_time usb_bit_time=1000000 usb_frame_time=83
usb_port_claim bus 0, port 1
usb_host_auto_scan_enabled
usb_ohci_reset pci-ohci
usb_ohci_stop pci-ohci: USB Suspended
usb_ohci_stop pci-ohci: USB Suspended
usb_host_open_started dev 3:29
usb_host_detach_kernel dev 3:29, if 0
usb_host_detach_kernel dev 3:29, if 1
usb_host_detach_kernel dev 3:29, if 2
usb_host_detach_kernel dev 3:29, if 3
usb_host_parse_config dev 3:29, value 1, active 1
usb_host_parse_interface dev 3:29, num 0, alt 0, active 1
usb_host_parse_interface dev 3:29, num 1, alt 0, active 1
usb_host_parse_interface dev 3:29, num 2, alt 0, active 1
usb_host_parse_interface dev 3:29, num 3, alt 0, active 1
usb_host_parse_endpoint dev 3:29, ep 4, in, int, active 1
usb_port_attach bus 0, port 1, devspeed full, portspeed full
usb_ohci_port_attach port #0
usb_host_open_success dev 3:29

Master with Mac OS 9.2:
usb_ohci_ed_pkt ED @ 0x00152920 h=0 c=0
  head=0x00164000 tailp=0x00164030 next=0x00152020
usb_ohci_ed_pkt_flags fa=37 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_skip_async
usb_ohci_ed_pkt ED @ 0x00152900 h=0 c=0
  head=0x001645a0 tailp=0x00164660 next=0x001528a0
usb_ohci_ed_pkt_flags fa=37 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_pkt_hdr  TD @ 0x001645a0 8 of 8 bytes setup r=1 cbp=0x01661b90
be=0x01661b97
usb_ohci_td_pkt_full OUT data:  01 0b 00 00 01 00 00 00
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt ED @ 0x00152920 h=0 c=0
  head=0x00164000 tailp=0x00164030 next=0x00152020
usb_ohci_ed_pkt_flags fa=37 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_skip_async
usb_ohci_ed_pkt ED @ 0x00152900 h=0 c=0
  head=0x001645a0 tailp=0x00164660 next=0x001528a0
usb_ohci_ed_pkt_flags fa=37 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_pkt_hdr  TD @ 0x001645a0 8 of 8 bytes setup r=1 cbp=0x01661b90
be=0x01661b97
usb_ohci_td_pkt_full OUT data:  01 0b 00 00 01 00 00 00
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt ED @ 0x00152920 h=0 c=0
  head=0x00164000 tailp=0x00164030 next=0x00152020
usb_ohci_ed_pkt_flags fa=37 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_skip_async
usb_ohci_ed_pkt ED @ 0x00152900 h=0 c=0
  head=0x001645a0 tailp=0x00164660 next=0x001528a0
usb_ohci_ed_pkt_flags fa=37 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_pkt_hdr  TD @ 0x001645a0 8 of 8 bytes setup r=1 cbp=0x01661b90
be=0x01661b97
usb_ohci_td_pkt_full OUT data:  01 0b 00 00 01 00 00 00
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt ED @ 0x00152920 h=0 c=0
  head=0x00164000 tailp=0x00164030 next=0x00152020
usb_ohci_ed_pkt_flags fa=37 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_skip_async
usb_ohci_ed_pkt ED @ 0x00152900 h=0 c=0
  head=0x001645a0 tailp=0x00164660 next=0x001528a0
usb_ohci_ed_pkt_flags fa=37 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_pkt_hdr  TD @ 0x001645a0 8 of 8 bytes setup r=1 cbp=0x01661b90
be=0x01661b97
usb_ohci_td_pkt_full OUT data:  01 0b 00 00 01 00 00 00
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt ED @ 0x00152920 h=0 c=0
  head=0x00164000 tailp=0x00164030 next=0x00152020
usb_ohci_ed_pkt_flags fa=37 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_skip_async

OHCI patch with MacOS 9.2:
usb_ohci_ed_pkt ED @ 0x001528e0 h=0 c=0
  head=0x001609c0 tailp=0x001609f0 next=0x00152020
usb_ohci_ed_pkt_flags fa=41 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_skip_async
usb_ohci_ed_pkt ED @ 0x001528c0 h=0 c=0
  head=0x00161030 tailp=0x001610c0 next=0x001528a0
usb_ohci_ed_pkt_flags fa=41 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_pkt_hdr  TD @ 0x00161030 8 of 8 bytes setup r=1 cbp=0x01587b08
be=0x01587b0f
usb_ohci_td_pkt_full OUT data:  80 06 00 02 00 00 0a 00
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt ED @ 0x001528e0 h=0 c=0
  head=0x001609c0 tailp=0x001609f0 next=0x00152020
usb_ohci_ed_pkt_flags fa=41 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_skip_async
usb_ohci_ed_pkt ED @ 0x001528c0 h=0 c=0
  head=0x00161030 tailp=0x001610c0 next=0x001528a0
usb_ohci_ed_pkt_flags fa=41 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_pkt_hdr  TD @ 0x00161030 8 of 8 bytes setup r=1 cbp=0x01587b08
be=0x01587b0f
usb_ohci_td_pkt_full OUT data:  80 06 00 02 00 00 0a 00
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt ED @ 0x001528e0 h=0 c=0
  head=0x001609c0 tailp=0x001609f0 next=0x00152020
usb_ohci_ed_pkt_flags fa=41 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_skip_async
usb_ohci_ed_pkt ED @ 0x001528c0 h=0 c=0
  head=0x00161030 tailp=0x001610c0 next=0x001528a0
usb_ohci_ed_pkt_flags fa=41 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_pkt_hdr  TD @ 0x00161030 8 of 8 bytes setup r=1 cbp=0x01587b08
be=0x01587b0f
usb_ohci_td_pkt_full OUT data:  80 06 00 02 00 00 0a 00
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt ED @ 0x001528e0 h=0 c=0
  head=0x001609c0 tailp=0x001609f0 next=0x00152020
usb_ohci_ed_pkt_flags fa=41 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_skip_async
usb_ohci_ed_pkt ED @ 0x001528c0 h=0 c=0
  head=0x00161030 tailp=0x001610c0 next=0x001528a0
usb_ohci_ed_pkt_flags fa=41 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_pkt_hdr  TD @ 0x00161030 8 of 8 bytes setup r=1 cbp=0x01587b08
be=0x01587b0f
usb_ohci_td_pkt_full OUT data:  80 06 00 02 00 00 0a 00
usb_ohci_td_too_many_pending

Both have issues communicating with endpoint 4 (the hid controls volume
up/down and mute).
Endpoint 1 should receive the isochronous audio stream, but never does.

After some experimentation with unplugging/plugging the headset and probing
the usb stack (using the usb prober from the mac usb ddk for Mac OS 9.2) at
some point endpoint 4 communication works for both guests tested. Only once
was I able to get sound out and in working in Mac OS 9.2. For OSX I could
only once get audio in working.

Pcap and text logs for both MacOS 9.2 and OSX 10.4 tests included...

Best,
Howard

[-- Attachment #1.2: Type: text/html, Size: 9416 bytes --]

[-- Attachment #2: logs.zip --]
[-- Type: application/zip, Size: 763232 bytes --]

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

* Re: [RFC PATCH 0/4] Misc OHCI patches
  2021-10-02 13:50 ` [RFC PATCH 0/4] Misc OHCI patches Howard Spoelstra
@ 2021-10-02 14:10   ` BALATON Zoltan
  2021-10-02 15:42   ` BALATON Zoltan
  1 sibling, 0 replies; 15+ messages in thread
From: BALATON Zoltan @ 2021-10-02 14:10 UTC (permalink / raw)
  To: Howard Spoelstra; +Cc: Mark Cave-Ayland, qemu-devel qemu-devel, Gerd Hoffmann

On Sat, 2 Oct 2021, Howard Spoelstra wrote:
> Hi all,
>
> I've booted Fedora12 and MacOS 9.2/OSX10.4 ppc with these patches applied.
> All boot OK.
> (Fedora12 requires -mac99,via=pmu. Here there seems to be some interference
> with the kbd, due to via=pmu presenting usb mouse and kdb to the guest. So
> I could not test this further.).
> All tests done in Fedora 34 host with current master and patched build.
>
> ./qemu-system-ppc-ohcipatch02102021 \
> -M mac99 \
> -L pc-bios \
> -display gtk \
> -m 512 \
> -boot c \
> -hda /home/hsp/Mac-disks/10.4.qcow2 \
> -device
> usb-host,loglevel=4,vendorid=0x046d,productid=0x0a37,pcap=ohci-usb1headset-usb1port-ohcipatchV1-macos104.pcap
> \
> -trace "usb_*" -D ohci-usb1headset-usb1port-ohcipatchV1-macos104.txt
>
> Endpoint 4 is the interrupt-based hid device, endpoint 1 would be the
> isochronous audio stream if it showed up.
> Each test consisted of booting to the desktop, opening the system
> profiler/system report to check of the presence of the usb device, push the
> various buttons on the headset, attempt to play a sound, unplug-replug and
> attempt to play a sound again. Then shut down.
>
> Both succesfully open the usb device:
> usb_ohci_init_time usb_bit_time=1000000 usb_frame_time=83
> usb_port_claim bus 0, port 1
> usb_host_auto_scan_enabled
> usb_ohci_reset pci-ohci
> usb_ohci_stop pci-ohci: USB Suspended
> usb_ohci_stop pci-ohci: USB Suspended
> usb_host_open_started dev 3:29
> usb_host_detach_kernel dev 3:29, if 0
> usb_host_detach_kernel dev 3:29, if 1
> usb_host_detach_kernel dev 3:29, if 2
> usb_host_detach_kernel dev 3:29, if 3
> usb_host_parse_config dev 3:29, value 1, active 1
> usb_host_parse_interface dev 3:29, num 0, alt 0, active 1
> usb_host_parse_interface dev 3:29, num 1, alt 0, active 1
> usb_host_parse_interface dev 3:29, num 2, alt 0, active 1
> usb_host_parse_interface dev 3:29, num 3, alt 0, active 1
> usb_host_parse_endpoint dev 3:29, ep 4, in, int, active 1
> usb_port_attach bus 0, port 1, devspeed full, portspeed full
> usb_ohci_port_attach port #0
> usb_host_open_success dev 3:29
>
> Master with Mac OS 9.2:
> usb_ohci_ed_pkt ED @ 0x00152920 h=0 c=0
>  head=0x00164000 tailp=0x00164030 next=0x00152020
> usb_ohci_ed_pkt_flags fa=37 en=4 d=2 s=0 k=0 f=0 mps=37
> usb_ohci_td_skip_async

Maybe we need to look a bit before this when the async packet still 
waiting here is submitted and see what is that and why it's not 
completing. At this point we only have everything waiting for that.

> usb_ohci_ed_pkt ED @ 0x00152900 h=0 c=0
>  head=0x001645a0 tailp=0x00164660 next=0x001528a0
> usb_ohci_ed_pkt_flags fa=37 en=0 d=0 s=0 k=0 f=0 mps=64
> usb_ohci_td_pkt_hdr  TD @ 0x001645a0 8 of 8 bytes setup r=1 cbp=0x01661b90
> be=0x01661b97
> usb_ohci_td_pkt_full OUT data:  01 0b 00 00 01 00 00 00
> usb_ohci_td_too_many_pending
> usb_ohci_ed_pkt ED @ 0x00152920 h=0 c=0
>  head=0x00164000 tailp=0x00164030 next=0x00152020
> usb_ohci_ed_pkt_flags fa=37 en=4 d=2 s=0 k=0 f=0 mps=37
> usb_ohci_td_skip_async
> usb_ohci_ed_pkt ED @ 0x00152900 h=0 c=0
>  head=0x001645a0 tailp=0x00164660 next=0x001528a0
> usb_ohci_ed_pkt_flags fa=37 en=0 d=0 s=0 k=0 f=0 mps=64
> usb_ohci_td_pkt_hdr  TD @ 0x001645a0 8 of 8 bytes setup r=1 cbp=0x01661b90
> be=0x01661b97
> usb_ohci_td_pkt_full OUT data:  01 0b 00 00 01 00 00 00
> usb_ohci_td_too_many_pending
> usb_ohci_ed_pkt ED @ 0x00152920 h=0 c=0
>  head=0x00164000 tailp=0x00164030 next=0x00152020
> usb_ohci_ed_pkt_flags fa=37 en=4 d=2 s=0 k=0 f=0 mps=37
> usb_ohci_td_skip_async
> usb_ohci_ed_pkt ED @ 0x00152900 h=0 c=0
>  head=0x001645a0 tailp=0x00164660 next=0x001528a0
> usb_ohci_ed_pkt_flags fa=37 en=0 d=0 s=0 k=0 f=0 mps=64
> usb_ohci_td_pkt_hdr  TD @ 0x001645a0 8 of 8 bytes setup r=1 cbp=0x01661b90
> be=0x01661b97
> usb_ohci_td_pkt_full OUT data:  01 0b 00 00 01 00 00 00
> usb_ohci_td_too_many_pending
> usb_ohci_ed_pkt ED @ 0x00152920 h=0 c=0
>  head=0x00164000 tailp=0x00164030 next=0x00152020
> usb_ohci_ed_pkt_flags fa=37 en=4 d=2 s=0 k=0 f=0 mps=37
> usb_ohci_td_skip_async
> usb_ohci_ed_pkt ED @ 0x00152900 h=0 c=0
>  head=0x001645a0 tailp=0x00164660 next=0x001528a0
> usb_ohci_ed_pkt_flags fa=37 en=0 d=0 s=0 k=0 f=0 mps=64
> usb_ohci_td_pkt_hdr  TD @ 0x001645a0 8 of 8 bytes setup r=1 cbp=0x01661b90
> be=0x01661b97
> usb_ohci_td_pkt_full OUT data:  01 0b 00 00 01 00 00 00
> usb_ohci_td_too_many_pending
> usb_ohci_ed_pkt ED @ 0x00152920 h=0 c=0
>  head=0x00164000 tailp=0x00164030 next=0x00152020
> usb_ohci_ed_pkt_flags fa=37 en=4 d=2 s=0 k=0 f=0 mps=37
> usb_ohci_td_skip_async
>
> OHCI patch with MacOS 9.2:
> usb_ohci_ed_pkt ED @ 0x001528e0 h=0 c=0
>  head=0x001609c0 tailp=0x001609f0 next=0x00152020
> usb_ohci_ed_pkt_flags fa=41 en=4 d=2 s=0 k=0 f=0 mps=37
> usb_ohci_td_skip_async
> usb_ohci_ed_pkt ED @ 0x001528c0 h=0 c=0
>  head=0x00161030 tailp=0x001610c0 next=0x001528a0
> usb_ohci_ed_pkt_flags fa=41 en=0 d=0 s=0 k=0 f=0 mps=64
> usb_ohci_td_pkt_hdr  TD @ 0x00161030 8 of 8 bytes setup r=1 cbp=0x01587b08
> be=0x01587b0f
> usb_ohci_td_pkt_full OUT data:  80 06 00 02 00 00 0a 00
> usb_ohci_td_too_many_pending

This does not seem to have changed with the patch so maybe the iso 
transfer is not the cause as what the patch does is making the iso 
transfers independent of other traffic so a waiting async packet will not 
cause those iso packets rejected but this does not seem to change this so 
the question is still what's the waiting async packet and why it's not 
completing. I don't know how to read these traces so can't really tell 
which endpoint these are for and what these packets could be related to.

Regards,
BALATON Zoltan

> usb_ohci_ed_pkt ED @ 0x001528e0 h=0 c=0
>  head=0x001609c0 tailp=0x001609f0 next=0x00152020
> usb_ohci_ed_pkt_flags fa=41 en=4 d=2 s=0 k=0 f=0 mps=37
> usb_ohci_td_skip_async
> usb_ohci_ed_pkt ED @ 0x001528c0 h=0 c=0
>  head=0x00161030 tailp=0x001610c0 next=0x001528a0
> usb_ohci_ed_pkt_flags fa=41 en=0 d=0 s=0 k=0 f=0 mps=64
> usb_ohci_td_pkt_hdr  TD @ 0x00161030 8 of 8 bytes setup r=1 cbp=0x01587b08
> be=0x01587b0f
> usb_ohci_td_pkt_full OUT data:  80 06 00 02 00 00 0a 00
> usb_ohci_td_too_many_pending
> usb_ohci_ed_pkt ED @ 0x001528e0 h=0 c=0
>  head=0x001609c0 tailp=0x001609f0 next=0x00152020
> usb_ohci_ed_pkt_flags fa=41 en=4 d=2 s=0 k=0 f=0 mps=37
> usb_ohci_td_skip_async
> usb_ohci_ed_pkt ED @ 0x001528c0 h=0 c=0
>  head=0x00161030 tailp=0x001610c0 next=0x001528a0
> usb_ohci_ed_pkt_flags fa=41 en=0 d=0 s=0 k=0 f=0 mps=64
> usb_ohci_td_pkt_hdr  TD @ 0x00161030 8 of 8 bytes setup r=1 cbp=0x01587b08
> be=0x01587b0f
> usb_ohci_td_pkt_full OUT data:  80 06 00 02 00 00 0a 00
> usb_ohci_td_too_many_pending
> usb_ohci_ed_pkt ED @ 0x001528e0 h=0 c=0
>  head=0x001609c0 tailp=0x001609f0 next=0x00152020
> usb_ohci_ed_pkt_flags fa=41 en=4 d=2 s=0 k=0 f=0 mps=37
> usb_ohci_td_skip_async
> usb_ohci_ed_pkt ED @ 0x001528c0 h=0 c=0
>  head=0x00161030 tailp=0x001610c0 next=0x001528a0
> usb_ohci_ed_pkt_flags fa=41 en=0 d=0 s=0 k=0 f=0 mps=64
> usb_ohci_td_pkt_hdr  TD @ 0x00161030 8 of 8 bytes setup r=1 cbp=0x01587b08
> be=0x01587b0f
> usb_ohci_td_pkt_full OUT data:  80 06 00 02 00 00 0a 00
> usb_ohci_td_too_many_pending
>
> Both have issues communicating with endpoint 4 (the hid controls volume
> up/down and mute).
> Endpoint 1 should receive the isochronous audio stream, but never does.
>
> After some experimentation with unplugging/plugging the headset and probing
> the usb stack (using the usb prober from the mac usb ddk for Mac OS 9.2) at
> some point endpoint 4 communication works for both guests tested. Only once
> was I able to get sound out and in working in Mac OS 9.2. For OSX I could
> only once get audio in working.
>
> Pcap and text logs for both MacOS 9.2 and OSX 10.4 tests included...
>
> Best,
> Howard
>


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

* Re: [RFC PATCH 0/4] Misc OHCI patches
  2021-10-01 21:11 [RFC PATCH 0/4] Misc OHCI patches BALATON Zoltan
                   ` (4 preceding siblings ...)
  2021-10-02 13:50 ` [RFC PATCH 0/4] Misc OHCI patches Howard Spoelstra
@ 2021-10-02 14:37 ` BALATON Zoltan
  2021-10-02 20:52   ` BALATON Zoltan
  5 siblings, 1 reply; 15+ messages in thread
From: BALATON Zoltan @ 2021-10-02 14:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland, Gerd Hoffmann, Howard Spoelstra

On Fri, 1 Oct 2021, BALATON Zoltan wrote:
> Posted as RFC because it's unfinfished and untested as there seems to
> be some regression with mac99 so it does not boot for me for some
> reason I haven't debugged yet. Hope Howard can test it and see if it
> changes any of the traces seen before.

I've now tried it with MorphOS on mac99 (needs a new patched OpenBIOS as 
the previous one stopped working with recent escc reset changes, see 
https://mail.coreboot.org/hyperkitty/list/openbios@openbios.org/thread/PE6B3HSQB6XIIELYJP6GJMR3L4RIUANR/ 
) but I don't have a usb audio device to pass through so tried with the 
emulated -device usb-audio instead. It's recognised both before and after 
this patch but does not make any sound. While info about the device shows 
up it seems to get packet NAKs when it's accessed and packet data is all 
zeros so maybe there's some problem decoding OHCI structures from the 
guest? It also has two audio endpoints and the first one is disabled, 
MorphOS seems to try to use the second one, Not sure where these are 
connected or is the first one an input for recording?

Interestingly on pegasos2 which has UHCI instead of OHCI MorphOS does not 
even correctly detect the emulated usb-audio device and trying to get info 
makes it freeze so looks like the UHCI model may also have some problems 
of its own.

On sam460ex that has EHCI it does the same as on mac99, detects usb-audio, 
does not freeze but does not make sound either. I think this would need 
someone with more understanding of the wotkings of usb-audio to debug 
this.

Regards,
BALATON Zoltan


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

* Re: [RFC PATCH 0/4] Misc OHCI patches
  2021-10-02 13:50 ` [RFC PATCH 0/4] Misc OHCI patches Howard Spoelstra
  2021-10-02 14:10   ` BALATON Zoltan
@ 2021-10-02 15:42   ` BALATON Zoltan
  2021-10-03  7:26     ` Howard Spoelstra
  1 sibling, 1 reply; 15+ messages in thread
From: BALATON Zoltan @ 2021-10-02 15:42 UTC (permalink / raw)
  To: Howard Spoelstra; +Cc: Mark Cave-Ayland, qemu-devel qemu-devel, Gerd Hoffmann

On Sat, 2 Oct 2021, Howard Spoelstra wrote:
> Both have issues communicating with endpoint 4 (the hid controls volume
> up/down and mute).
> Endpoint 1 should receive the isochronous audio stream, but never does.
>
> After some experimentation with unplugging/plugging the headset and probing
> the usb stack (using the usb prober from the mac usb ddk for Mac OS 9.2) at
> some point endpoint 4 communication works for both guests tested. Only once
> was I able to get sound out and in working in Mac OS 9.2. For OSX I could
> only once get audio in working.

The async packets are on endpoint 0. I'm not sure the HID endpoint 4 is 
normally involved at all unless you push some buttons but it should work 
without that so maybe look at the 0 and the audio endpoints instead of 
HID that should have no traffic unless you press buttons.

> Pcap and text logs for both MacOS 9.2 and OSX 10.4 tests included...

These are way too big to be possible to find anything in them. Maybe you 
should do something simpler like boot the guest without the device 
attached and discard all logs up to that point. Then start collecting logs 
and attach device and play a short sound. Stop collecting log and try to 
make sense of where that fails. That's still a lot of traces but should 
only contain the relevant info of detecing the device and playing a sound 
not a lot of others that makes it difficult to find what's relevant.

I'm also not sure where's the problem (maybe we have multiple problems). 
It also does not work with an emulated usb-audio device but that also 
doesn't work with EHCI so it may have a problem by itself (UHCI also seems 
to be broken on its own so it does not even work as much as OHCI and 
EHCI). You've also said it worked with pass through with a different 
device so maybe this only happens with some devices or some sequence of 
things these devices are doing. Only allowing one async packet in OHCI 
instead of allowing one per endpoint is just a guess that could cause 
delays in processing other packets but eventually it should go through 
unless one async packet never completes and blocks all later ones or the 
delays introduced by this limitaion causes things to go in a way that 
guests don't expect and thus fail.

Regards,
BALATON Zoltan


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

* Re: [RFC PATCH 0/4] Misc OHCI patches
  2021-10-02 14:37 ` BALATON Zoltan
@ 2021-10-02 20:52   ` BALATON Zoltan
  0 siblings, 0 replies; 15+ messages in thread
From: BALATON Zoltan @ 2021-10-02 20:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland, Gerd Hoffmann, Philippe Mathieu-Daudé

On Sat, 2 Oct 2021, BALATON Zoltan wrote:
> Interestingly on pegasos2 which has UHCI instead of OHCI MorphOS does not 
> even correctly detect the emulated usb-audio device and trying to get info 
> makes it freeze so looks like the UHCI model may also have some problems of 
> its own.

So it's not the UHCI model but a problem with IRQ routing with vt8231. 
I've noticed that it sends USB requests to the usb-audio device but the 
replies come back very slowly. This lead me to think the interrupts may 
not be handled correctly. What happens is that vt82c686-uhci-pci that 
models the USB function of the VT82xx super-southbridge chips is 
implemented as a PCIDevice (it's a subclass of TYPE_UHCI) and hcd-uhci is 
using pci_set_irq() to comminicate interrupts which will generate PCI 
interrupts. But the docs of both VT82c686b and vt8231 say that the 
interrupt line PCI config register (0x3c) of most sub functions of this 
chip selects which ISA IRQ that function is routed to. (This is also 
mentioned at https://wiki.osdev.org/PCI so probably this is generally true 
for such multifunction bridge chips while other PCI cards plugged in the 
PCI bus provided by these bridge chips use normal PCI interrupts.) On the 
other hand some of these functions may also exist as separate PCI cards 
where using the PCI interrupt is correct. If for testing I change 
uhci_update_irq() to set the appropriate ISA IRQ instead of pci_set_irq() 
then it works on pegasos2 and gets the same result as with mac99 and 
sam460ex but I wonder what would be a good way to model this? (Especially 
because in case of usb-uhci we can't cahnge it easily as that's also used 
by other devices.)

This is similar problem we've seen with the via-ide device (although 
that's a bit more complex due to that also disregards the PCI config 
register despite what the docs say and always uses ISA IRQ 14+15). We have 
that call qemu_set_irq(isa_get_irq()) now as it's only used as part of the 
VT82xx chips. We'll have the same problem when implementing via-audio so 
eventually we should come up with a solution for this.

What I can think of is maybe have these devices somehow detect if they are 
a standalone PCI device or a sub function of a bridge chip and use either 
pci_set_irq or isa_get_irq() accordingly which could work but if anybody 
has a better idea (that does not involve rewriting and QOM'ifying the 
whole ISA mess because I won't have time for that) please share.

Regards,
BALATON Zoltan


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

* Re: [RFC PATCH 0/4] Misc OHCI patches
  2021-10-02 15:42   ` BALATON Zoltan
@ 2021-10-03  7:26     ` Howard Spoelstra
  2021-10-03 10:00       ` BALATON Zoltan
  0 siblings, 1 reply; 15+ messages in thread
From: Howard Spoelstra @ 2021-10-03  7:26 UTC (permalink / raw)
  To: BALATON Zoltan; +Cc: Mark Cave-Ayland, qemu-devel qemu-devel, Gerd Hoffmann

[-- Attachment #1: Type: text/plain, Size: 12169 bytes --]

On Sat, Oct 2, 2021 at 5:42 PM BALATON Zoltan <balaton@eik.bme.hu> wrote:

> On Sat, 2 Oct 2021, Howard Spoelstra wrote:
> > Both have issues communicating with endpoint 4 (the hid controls volume
> > up/down and mute).
> > Endpoint 1 should receive the isochronous audio stream, but never does.
> >
> > After some experimentation with unplugging/plugging the headset and
> probing
> > the usb stack (using the usb prober from the mac usb ddk for Mac OS 9.2)
> at
> > some point endpoint 4 communication works for both guests tested. Only
> once
> > was I able to get sound out and in working in Mac OS 9.2. For OSX I could
> > only once get audio in working.
>
> The async packets are on endpoint 0. I'm not sure the HID endpoint 4 is
> normally involved at all unless you push some buttons but it should work
> without that so maybe look at the 0 and the audio endpoints instead of
> HID that should have no traffic unless you press buttons.
>
> > Pcap and text logs for both MacOS 9.2 and OSX 10.4 tests included...
>
> These are way too big to be possible to find anything in them. Maybe you
> should do something simpler like boot the guest without the device
> attached and discard all logs up to that point. Then start collecting logs
> and attach device and play a short sound. Stop collecting log and try to
> make sense of where that fails. That's still a lot of traces but should
> only contain the relevant info of detecing the device and playing a sound
> not a lot of others that makes it difficult to find what's relevant.
>
> I'm also not sure where's the problem (maybe we have multiple problems).
> It also does not work with an emulated usb-audio device but that also
> doesn't work with EHCI so it may have a problem by itself (UHCI also seems
> to be broken on its own so it does not even work as much as OHCI and
> EHCI). You've also said it worked with pass through with a different
> device so maybe this only happens with some devices or some sequence of
> things these devices are doing. Only allowing one async packet in OHCI
> instead of allowing one per endpoint is just a guess that could cause
> delays in processing other packets but eventually it should go through
> unless one async packet never completes and blocks all later ones or the
> delays introduced by this limitaion causes things to go in a way that
> guests don't expect and thus fail.
>
> Regards,
> BALATON Zoltan
>

After some sifting through the logs, I my interpretation of our issue is
this:
Too many pending is referring to endpoint 0 when something is not
completed. Qemu permantly checks endpoint 4 for hid activity, skips when no
interrupt occurs. You can see both intermittently in the 1st log below.
Too many pending refers to qemu not being able to fully read/get the device
descriptors from boot. The too many pending is "solved", with a click on a
hid button. That leads to async complete, after which the only activity is
to check for interrupts from the hid devices.
However, as the descriptors from endpoint 0 are not fully read from boot,
endpoint 1 (the actual audio stream) is not available.
Unplugging/plugging the usb device in combination with some hid interrupts
(me pushing the volume button) can sometimes reload the configuration
correctly, so endpoint 1 becomes available and sound can be played through
it.

usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_async_complete ----------------------------------> me clicking a
hid button.
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=95 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=95 en=4 d=2 s=0 k=0 f=0 mps=37

After unplugging/plugging the device and some ep 4 traffic generated by
button clicks, ep 1 also becomes active:
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=96 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=96 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=96 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending

[-- Attachment #2: Type: text/html, Size: 13435 bytes --]

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

* Re: [RFC PATCH 0/4] Misc OHCI patches
  2021-10-03  7:26     ` Howard Spoelstra
@ 2021-10-03 10:00       ` BALATON Zoltan
  2021-10-03 13:57         ` Howard Spoelstra
  0 siblings, 1 reply; 15+ messages in thread
From: BALATON Zoltan @ 2021-10-03 10:00 UTC (permalink / raw)
  To: Howard Spoelstra; +Cc: Mark Cave-Ayland, qemu-devel qemu-devel, Gerd Hoffmann

On Sun, 3 Oct 2021, Howard Spoelstra wrote:
> On Sat, Oct 2, 2021 at 5:42 PM BALATON Zoltan <balaton@eik.bme.hu> wrote:
>> I'm also not sure where's the problem (maybe we have multiple problems).
>> It also does not work with an emulated usb-audio device but that also
>> doesn't work with EHCI so it may have a problem by itself (UHCI also seems
>> to be broken on its own so it does not even work as much as OHCI and
>> EHCI). You've also said it worked with pass through with a different
>> device so maybe this only happens with some devices or some sequence of
>> things these devices are doing. Only allowing one async packet in OHCI
>> instead of allowing one per endpoint is just a guess that could cause
>> delays in processing other packets but eventually it should go through
>> unless one async packet never completes and blocks all later ones or the
>> delays introduced by this limitaion causes things to go in a way that
>> guests don't expect and thus fail.
>>
> After some sifting through the logs, I my interpretation of our issue is
> this:
> Too many pending is referring to endpoint 0 when something is not
> completed. Qemu permantly checks endpoint 4 for hid activity, skips when no
> interrupt occurs. You can see both intermittently in the 1st log below.
> Too many pending refers to qemu not being able to fully read/get the device
> descriptors from boot. The too many pending is "solved", with a click on a
> hid button. That leads to async complete, after which the only activity is
> to check for interrupts from the hid devices.

That sounds like an async packet waiting on ep 4 blocks communication on 
ep 0 because we don't allow one active packet per ep in hcd-ohci as the 
comment says so this may be fixed by implementing that. But I'm not sure 
because this log did not include packet status. Maybe also enable 
usb_packet_state traces to confirm this. I may try to fix this, I have an 
idea how do it: I can pass the USBPacket back from the completion callback 
via OHCIState to ohci_service_td() but have to find a way to replace the 
various cancel calls that use the usb_packet from OHCIState now to stop 
relying on that and do it by ep or whatever they have. This needs some 
more thinking and understand the code and OHCI better.

I assume no more than one callback can be running at once so I can't get 
completion for two packets at the same time, therefore one pointer to pass 
back a packet is enough. I'll put an assert there and see what happens but 
if somebody knows please advise.

> However, as the descriptors from endpoint 0 are not fully read from boot,
> endpoint 1 (the actual audio stream) is not available.
> Unplugging/plugging the usb device in combination with some hid interrupts
> (me pushing the volume button) can sometimes reload the configuration
> correctly, so endpoint 1 becomes available and sound can be played through
> it.

Could be if guest driver starts polling ep 4 while still trying to talk to 
ep 0 which then fails due to packet waiting in async on ep 4. The emulated 
usb-audio may be different, that does not have HID endpoint only ep 0 for 
control and two audio ones and it seems to be detected but playing sound 
does not work. Does -device usb-audio instead of passed through device 
makes sound with your guest OSes or that has a separate problem?

Regards,
BALATON Zoltan


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

* Re: [RFC PATCH 0/4] Misc OHCI patches
  2021-10-03 10:00       ` BALATON Zoltan
@ 2021-10-03 13:57         ` Howard Spoelstra
  2021-10-04  6:38           ` Howard Spoelstra
  0 siblings, 1 reply; 15+ messages in thread
From: Howard Spoelstra @ 2021-10-03 13:57 UTC (permalink / raw)
  To: BALATON Zoltan; +Cc: Mark Cave-Ayland, qemu-devel qemu-devel, Gerd Hoffmann

[-- Attachment #1: Type: text/plain, Size: 12165 bytes --]

On Sun, Oct 3, 2021 at 12:00 PM BALATON Zoltan <balaton@eik.bme.hu> wrote:

> On Sun, 3 Oct 2021, Howard Spoelstra wrote:
> > On Sat, Oct 2, 2021 at 5:42 PM BALATON Zoltan <balaton@eik.bme.hu>
> wrote:
> >> I'm also not sure where's the problem (maybe we have multiple problems).
> >> It also does not work with an emulated usb-audio device but that also
> >> doesn't work with EHCI so it may have a problem by itself (UHCI also
> seems
> >> to be broken on its own so it does not even work as much as OHCI and
> >> EHCI). You've also said it worked with pass through with a different
> >> device so maybe this only happens with some devices or some sequence of
> >> things these devices are doing. Only allowing one async packet in OHCI
> >> instead of allowing one per endpoint is just a guess that could cause
> >> delays in processing other packets but eventually it should go through
> >> unless one async packet never completes and blocks all later ones or the
> >> delays introduced by this limitaion causes things to go in a way that
> >> guests don't expect and thus fail.
> >>
> > After some sifting through the logs, I my interpretation of our issue is
> > this:
> > Too many pending is referring to endpoint 0 when something is not
> > completed. Qemu permantly checks endpoint 4 for hid activity, skips when
> no
> > interrupt occurs. You can see both intermittently in the 1st log below.
> > Too many pending refers to qemu not being able to fully read/get the
> device
> > descriptors from boot. The too many pending is "solved", with a click on
> a
> > hid button. That leads to async complete, after which the only activity
> is
> > to check for interrupts from the hid devices.
>
> That sounds like an async packet waiting on ep 4 blocks communication on
> ep 0 because we don't allow one active packet per ep in hcd-ohci as the
> comment says so this may be fixed by implementing that. But I'm not sure
> because this log did not include packet status. Maybe also enable
> usb_packet_state traces to confirm this. I may try to fix this, I have an
> idea how do it: I can pass the USBPacket back from the completion callback
> via OHCIState to ohci_service_td() but have to find a way to replace the
> various cancel calls that use the usb_packet from OHCIState now to stop
> relying on that and do it by ep or whatever they have. This needs some
> more thinking and understand the code and OHCI better.
>
> I assume no more than one callback can be running at once so I can't get
> completion for two packets at the same time, therefore one pointer to pass
> back a packet is enough. I'll put an assert there and see what happens but
> if somebody knows please advise.
>
> > However, as the descriptors from endpoint 0 are not fully read from boot,
> > endpoint 1 (the actual audio stream) is not available.
> > Unplugging/plugging the usb device in combination with some hid
> interrupts
> > (me pushing the volume button) can sometimes reload the configuration
> > correctly, so endpoint 1 becomes available and sound can be played
> through
> > it.
>
> Could be if guest driver starts polling ep 4 while still trying to talk to
> ep 0 which then fails due to packet waiting in async on ep 4. The emulated
> usb-audio may be different, that does not have HID endpoint only ep 0 for
> control and two audio ones and it seems to be detected but playing sound
> does not work. Does -device usb-audio instead of passed through device
> makes sound with your guest OSes or that has a separate problem?
>

Usb-audio works in MacOS 9.2 guest, but only for some seconds. After that
the desktop becomes unresponsive. Icons disappear, mouse still moves but
cannot activate anything. With via=pmu, log shows usb mouse/kbd still
communicating.
I've seen something very similar happen when I attempt to stop and start
usb support in Mac OS 9.2 with the headset passed through.
System sounds in Fedora 12 guest can be played.

New logging with package status shows:
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=0
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=-6
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=0
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=0
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_packet_status status=-6  --------------------------> note this
is line 1282 in my log

The following then continues to line 17671
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37

And is followed by:
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending

The first async complete is then at 57456
usb_ohci_td_too_many_pending
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=-6
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=0
usb_ohci_ed_pkt_flags fa=107 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=0  ------------------------> last status=0
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_packet_status status=-6
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_packet_status status=-6

It then takes some 4000 lines before a
usb_ohci_td_packet_status status=-6
usb_ohci_async_complete
happens (me clicking hid button)

Next I get:
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_packet_status status=-6
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37  ----> Line 107770
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37
-----
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37 ---> Line 187472

usb_ohci_async_complete (me clicking hid button)
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=107 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_packet_status status=-6

En1 is then active from line 190303 (after unplug/replug)
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending

Which is again solve by a hid button click:
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=0
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=0
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=-6
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=0
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=0
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=-6
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=0
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=0
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_packet_status status=-6
usb_ohci_async_complete
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_packet_status status=-6
usb_ohci_ed_pkt_flags fa=108 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_async_complete

From here on there is intermittent en1 and en 4 traffic:
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=1 d=1 s=0 k=0 f=1 mps=192
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_td_packet_status status=-6

and for good measure some:
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=0 d=0 s=0 k=0 f=0 mps=64
usb_ohci_td_too_many_pending

and finally completing with ep 4 polling:
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37
usb_ohci_ed_pkt_flags fa=108 en=4 d=2 s=0 k=0 f=0 mps=37

The last async complete is when I shut down the host ;-)

Best,
Howard

[-- Attachment #2: Type: text/html, Size: 13993 bytes --]

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

* Re: [RFC PATCH 0/4] Misc OHCI patches
  2021-10-03 13:57         ` Howard Spoelstra
@ 2021-10-04  6:38           ` Howard Spoelstra
  2021-10-04 10:08             ` BALATON Zoltan
  0 siblings, 1 reply; 15+ messages in thread
From: Howard Spoelstra @ 2021-10-04  6:38 UTC (permalink / raw)
  To: BALATON Zoltan; +Cc: Mark Cave-Ayland, qemu-devel qemu-devel, Gerd Hoffmann

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

Hi all,

One more observation: When running Mac OS  guests with -mac99,via=pmu, the
guest is presented with a usb-mouse and usb-kbd, while -mac99 provides cuda
mouse/kbd.

If I run with via=pmu, the mouse/kbd will not work when passing through the
usb headset.
Only when I keep interrupting by pressing a volume button on the headset,
the mouse moves. So it seems Qemu does not iterate getting interrupts over
multiple devices.

Best,
Howard

>

[-- Attachment #2: Type: text/html, Size: 722 bytes --]

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

* Re: [RFC PATCH 0/4] Misc OHCI patches
  2021-10-04  6:38           ` Howard Spoelstra
@ 2021-10-04 10:08             ` BALATON Zoltan
  0 siblings, 0 replies; 15+ messages in thread
From: BALATON Zoltan @ 2021-10-04 10:08 UTC (permalink / raw)
  To: Howard Spoelstra; +Cc: Mark Cave-Ayland, qemu-devel qemu-devel, Gerd Hoffmann

On Mon, 4 Oct 2021, Howard Spoelstra wrote:
> Hi all,
>
> One more observation: When running Mac OS  guests with -mac99,via=pmu, the
> guest is presented with a usb-mouse and usb-kbd, while -mac99 provides cuda
> mouse/kbd.
>
> If I run with via=pmu, the mouse/kbd will not work when passing through the
> usb headset.
> Only when I keep interrupting by pressing a volume button on the headset,
> the mouse moves. So it seems Qemu does not iterate getting interrupts over
> multiple devices.

It the MacOS HID driver works by always keeping a request pending to 
receive any events that become an async packet waiting on your usb headset 
ep 4, this currently blocks all of OHCI and no other packets go through 
until this async packet completes (when you press a button on the HID 
device). So the comment in code not only means that different endpoints 
block each other but one endpoint blocks the whole controller which is 
clearly wrong. I think this confirms the theory that we'd need to fix 
this.

I've tried removing the async_id from OHCIState but I'm lost between all 
these callbacks. Maybe somebody who knows more about QEMU USB and OHCI 
could take a look or are there some docs about what callbacks are called 
when in QEMU when something happens? I'm interested in the child detach, 
detach and async complete callbacks (which handle pending packets in 
hcd-ohci) and if they can be called while ohci_service_td is running 
(which submits packets and also called for handling completed async 
packets). Maybe ohci_service_td should be split into two parts: submitting 
and handling returns, so only the completion part is called from 
ohci_async_complete_packet callback but that needs to find the OHCI struct 
for the packet to put results in so now it just triggers a complete 
processing of all requests and handles completion if it finds the packet. 
I'm lost in the possible interactions between these callbacks so some info 
on that might help.

Regards,
BALATON Zoltan


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

end of thread, other threads:[~2021-10-04 10:28 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01 21:11 [RFC PATCH 0/4] Misc OHCI patches BALATON Zoltan
2021-10-01 21:11 ` [RFC PATCH 2/4] usb/ohci: Move USBPortOps related functions together BALATON Zoltan
2021-10-01 21:11 ` [RFC PATCH 1/4] usb/ohci: Move cancelling async packet to ohci_stop_endpoints() BALATON Zoltan
2021-10-01 21:11 ` [RFC PATCH 3/4] usb/ohci: Merge ohci_async_cancel_device() into ohci_child_detach() BALATON Zoltan
2021-10-01 21:11 ` [RFC PATCH 4/4] usb/ohci: Don't use packet from OHCIState for isochronous transfers BALATON Zoltan
2021-10-02 13:50 ` [RFC PATCH 0/4] Misc OHCI patches Howard Spoelstra
2021-10-02 14:10   ` BALATON Zoltan
2021-10-02 15:42   ` BALATON Zoltan
2021-10-03  7:26     ` Howard Spoelstra
2021-10-03 10:00       ` BALATON Zoltan
2021-10-03 13:57         ` Howard Spoelstra
2021-10-04  6:38           ` Howard Spoelstra
2021-10-04 10:08             ` BALATON Zoltan
2021-10-02 14:37 ` BALATON Zoltan
2021-10-02 20:52   ` BALATON Zoltan

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.