Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/kraxel/tags/pull-usb-20170614-1…
Browse files Browse the repository at this point in the history
…' into staging

usb: bugfixes for ehci and xhci

# gpg: Signature made Wed 14 Jun 2017 08:44:01 BST
# gpg:                using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/pull-usb-20170614-1:
  ehci: stop recursive calls to ehci_work_bh
  xhci: only update dequeue ptr on completed transfers

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Jun 19, 2017
2 parents a1fbe75 + ad3c541 commit cef8fd6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions hw/usb/hcd-ehci.c
Expand Up @@ -2241,6 +2241,11 @@ static void ehci_work_bh(void *opaque)
uint64_t uframes, skipped_uframes;
int i;

if (ehci->working) {
return;
}
ehci->working = true;

t_now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
ns_elapsed = t_now - ehci->last_run_ns;
uframes = ns_elapsed / UFRAME_TIMER_NS;
Expand Down Expand Up @@ -2322,6 +2327,8 @@ static void ehci_work_bh(void *opaque)
}
timer_mod(ehci->frame_timer, expire_time);
}

ehci->working = false;
}

static void ehci_work_timer(void *opaque)
Expand Down
1 change: 1 addition & 0 deletions hw/usb/hcd-ehci.h
Expand Up @@ -297,6 +297,7 @@ struct EHCIState {
*/
QEMUTimer *frame_timer;
QEMUBH *async_bh;
bool working;
uint32_t astate; /* Current state in asynchronous schedule */
uint32_t pstate; /* Current state in periodic schedule */
USBPort ports[NB_PORTS];
Expand Down
6 changes: 4 additions & 2 deletions hw/usb/hcd-xhci.c
Expand Up @@ -1912,6 +1912,8 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid)
}
assert(!xfer->running_retry);
if (xfer->complete) {
/* update ring dequeue ptr */
xhci_set_ep_state(xhci, epctx, stctx, epctx->state);
xhci_ep_free_xfer(epctx->retry);
}
epctx->retry = NULL;
Expand Down Expand Up @@ -1962,6 +1964,8 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid)
xhci_fire_transfer(xhci, xfer, epctx);
}
if (xfer->complete) {
/* update ring dequeue ptr */
xhci_set_ep_state(xhci, epctx, stctx, epctx->state);
xhci_ep_free_xfer(xfer);
xfer = NULL;
}
Expand All @@ -1979,8 +1983,6 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid)
break;
}
}
/* update ring dequeue ptr */
xhci_set_ep_state(xhci, epctx, stctx, epctx->state);
epctx->kick_active--;

ep = xhci_epid_to_usbep(epctx);
Expand Down

0 comments on commit cef8fd6

Please sign in to comment.