From 5737d12b622e8f3e2a4c737f2c2aa3179dbcace7 Mon Sep 17 00:00:00 2001 From: Kurt Eckhardt Date: Sat, 11 Nov 2017 13:20:04 -0800 Subject: [PATCH] Fix hang part 2... I am not sure if you can also get the same hang in the periodic update list as well, but to be on the safe side added same checks as the one that was hanging. --- ehci.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/ehci.cpp b/ehci.cpp index 21c97eb..d0d5427 100644 --- a/ehci.cpp +++ b/ehci.cpp @@ -1254,16 +1254,6 @@ void USBHost::delete_Pipe(Pipe_t *pipe) // find & free all the transfers which completed println(" Free transfers"); Transfer_t *t = async_followup_first; -#if 0 - if (t) { - println(" (Look at QH list first)"); - Transfer_t *tr = (Transfer_t *)(pipe->qh.next); - while ((uint32_t)tr & 0xFFFFFFE0) { - println(" $ ", (uint32_t)tr); - tr = (Transfer_t *)(tr->qtd.next); - } - } -#endif while (t) { print(" * ", (uint32_t)t); Transfer_t *next = t->next_followup; @@ -1312,12 +1302,28 @@ void USBHost::delete_Pipe(Pipe_t *pipe) // TODO: subtract bandwidth from uframe_bandwidth array // find & free all the transfers which completed + println(" Free transfers"); Transfer_t *t = periodic_followup_first; while (t) { + print(" * ", (uint32_t)t); Transfer_t *next = t->next_followup; if (t->pipe == pipe) { + print(" * remove"); remove_from_periodic_followup_list(t); - free_Transfer(t); + + // Only free if not in QH list + Transfer_t *tr = (Transfer_t *)(pipe->qh.next); + while (((uint32_t)tr & 0xFFFFFFE0) && (tr != t)){ + tr = (Transfer_t *)(tr->qtd.next); + } + if (tr == t) { + println(" * defer free until QH"); + } else { + println(" * free"); + free_Transfer(t); // The later code should actually free it... + } + } else { + println(""); } t = next; }