From d10cbd5dafb284e9984e199ce93efa47d65a004c Mon Sep 17 00:00:00 2001 From: sakumisu <1203593632@qq.com> Date: Mon, 13 Nov 2023 19:49:49 +0800 Subject: check if token is active without errors, if token has errors, go to wakeup sem --- port/ehci/usb_hc_ehci.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/port/ehci/usb_hc_ehci.c b/port/ehci/usb_hc_ehci.c index cdabdf01..7e6e9469 100644 --- a/port/ehci/usb_hc_ehci.c +++ b/port/ehci/usb_hc_ehci.c @@ -682,25 +682,24 @@ static void ehci_check_qh(struct ehci_qh_hw *qhead, struct ehci_qh_hw *qh) token = qh->hw.overlay.token; - if (token & QTD_TOKEN_STATUS_ACTIVE) { + /* Check if token is only in active status without errors */ + if ((token & (QTD_TOKEN_STATUS_ERRORS | QTD_TOKEN_STATUS_ACTIVE)) == QTD_TOKEN_STATUS_ACTIVE) { return; } - qtd = EHCI_ADDR2QTD(qh->first_qtd); - - while (qtd) { - if (qtd->hw.token & QTD_TOKEN_STATUS_ACTIVE) { - return; - } - qtd = EHCI_ADDR2QTD(qtd->hw.next_qtd); - } - urb = qh->urb; pipe = urb->pipe; - ehci_qh_scan_qtds(qhead, qh); - if ((token & QTD_TOKEN_STATUS_ERRORS) == 0) { + qtd = EHCI_ADDR2QTD(qh->first_qtd); + + while (qtd) { + if (qtd->hw.token & QTD_TOKEN_STATUS_ACTIVE) { + return; + } + qtd = EHCI_ADDR2QTD(qtd->hw.next_qtd); + } + if (token & QTD_TOKEN_TOGGLE) { pipe->toggle = true; } else { @@ -719,6 +718,8 @@ static void ehci_check_qh(struct ehci_qh_hw *qhead, struct ehci_qh_hw *qh) } } + ehci_qh_scan_qtds(qhead, qh); + if (pipe->ep_type == USB_ENDPOINT_TYPE_INTERRUPT) { qh->remove_in_iaad = 0; ehci_qh_free(qh); -- cgit v1.3.1