Skip to contentSkip to conversation

xhci iso: fix time calculation

PATCH In review Gerd Hoffmann 2 participants 3 messages Feb 6, 2014 – Feb 7, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 xhci iso: fix time calculation

Frameid specifies frames not microframes, so we
need to shift it to get the microframe index.

---
 hw/usb/hcd-xhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/usb/hcd-xhci.c +2 -2
index 44964f4..2c54b86 100644
@@ -1974,8 +1974,8 @@ static void xhci_calc_iso_kick(XHCIState *xhci, XHCITransfer *xfer,
             xfer->mfindex_kick = asap;
         }
     } else {
-        xfer->mfindex_kick = (xfer->trbs[0].control >> TRB_TR_FRAMEID_SHIFT)
-            & TRB_TR_FRAMEID_MASK;
+        xfer->mfindex_kick = ((xfer->trbs[0].control >> TRB_TR_FRAMEID_SHIFT)
+                              & TRB_TR_FRAMEID_MASK) << 3;
         xfer->mfindex_kick |= mfindex & ~0x3fff;
         if (xfer->mfindex_kick < mfindex) {
             xfer->mfindex_kick += 0x4000;
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 2/2 xhci iso: allow for some latency

Allow the scheduled transfer time be a bit behind, to compensate for latencies. Without this xhci will wait way to often for the mfindex wraparound, assuming the scheduled time is in the future just because qemu is a bit behind in processing the iso transfer requests.

---
 hw/usb/hcd-xhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/hcd-xhci.c +1 -1
index 2c54b86..6188e77 100644
@@ -1977,7 +1977,7 @@ static void xhci_calc_iso_kick(XHCIState *xhci, XHCITransfer *xfer,
         xfer->mfindex_kick = ((xfer->trbs[0].control >> TRB_TR_FRAMEID_SHIFT)
                               & TRB_TR_FRAMEID_MASK) << 3;
         xfer->mfindex_kick |= mfindex & ~0x3fff;
-        if (xfer->mfindex_kick < mfindex) {
+        if (xfer->mfindex_kick + 0x100 < mfindex) {
             xfer->mfindex_kick += 0x4000;
         }
     }
Signature · 1 line
1.8.3.1
#2 lore raw
In reply to Gerd Hoffmann

Hi,

Looks good, ack series.

Regards,

Hans

Quoted 24 lines · Gerd Hoffmann

Frameid specifies frames not microframes, so we
need to shift it to get the microframe index.

---
  hw/usb/hcd-xhci.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
hw/usb/hcd-xhci.c +2 -2
index 44964f4..2c54b86 100644
@@ -1974,8 +1974,8 @@ static void xhci_calc_iso_kick(XHCIState *xhci, XHCITransfer *xfer,
              xfer->mfindex_kick = asap;
          }
      } else {
-        xfer->mfindex_kick = (xfer->trbs[0].control >> TRB_TR_FRAMEID_SHIFT)
-            & TRB_TR_FRAMEID_MASK;
+        xfer->mfindex_kick = ((xfer->trbs[0].control >> TRB_TR_FRAMEID_SHIFT)
+                              & TRB_TR_FRAMEID_MASK) << 3;
          xfer->mfindex_kick |= mfindex & ~0x3fff;
          if (xfer->mfindex_kick < mfindex) {
              xfer->mfindex_kick += 0x4000;