1
0
mirror of https://github.com/gdsports/USBHost_t36 synced 2024-11-27 19:42:15 -05:00

Free transfers and pipe when deleting from periodic schedule

This commit is contained in:
PaulStoffregen 2017-02-26 13:58:41 -08:00
parent fe5cf3e4cd
commit 430e24ba54

View File

@ -907,7 +907,6 @@ void USBHost::add_qh_to_periodic_schedule(Pipe_t *pipe)
void USBHost::delete_Pipe(Pipe_t *pipe) void USBHost::delete_Pipe(Pipe_t *pipe)
{ {
// TODO: a *LOT* of work here.....
println("delete_Pipe ", (uint32_t)pipe, HEX); println("delete_Pipe ", (uint32_t)pipe, HEX);
// halt pipe, find and free all Transfer_t // halt pipe, find and free all Transfer_t
@ -967,17 +966,6 @@ void USBHost::delete_Pipe(Pipe_t *pipe)
} }
t = next; t = next;
} }
// TODO: do we need to look at pipe->qh.current ??
//
// free all the transfers still attached to the QH
t = (Transfer_t *)(pipe->qh.next);
while ((uint32_t)t & 0xFFFFFFE0) {
Transfer_t *next = (Transfer_t *)(t->qtd.next);
free_Transfer(t);
t = next;
}
// hopefully we found everything...
free_Pipe(pipe);
} else { } else {
// remove from the periodic schedule // remove from the periodic schedule
for (uint32_t i=0; i < PERIODIC_LIST_SIZE; i++) { for (uint32_t i=0; i < PERIODIC_LIST_SIZE; i++) {
@ -1000,17 +988,31 @@ void USBHost::delete_Pipe(Pipe_t *pipe)
prev = node; prev = node;
} }
} }
// TODO: find & free all the transfers which completed // TODO: subtract bandwidth from uframe_bandwidth array
// TODO: do we need to look at pipe->qh.current ??
// TODO: free all the transfers still attached to the QH // find & free all the transfers which completed
// TODO: free_Pipe(pipe); Transfer_t *t = periodic_followup_first;
return; while (t) {
Transfer_t *next = t->next_followup;
if (t->pipe == pipe) {
remove_from_periodic_followup_list(t);
free_Transfer(t);
}
t = next;
}
} }
//
// TODO: do we need to look at pipe->qh.current ??
//
// can't free the pipe until the ECHI and all qTD referencing are done // free all the transfers still attached to the QH
// free_Pipe(pipe); Transfer_t *tr = (Transfer_t *)(pipe->qh.next);
while ((uint32_t)tr & 0xFFFFFFE0) {
Transfer_t *next = (Transfer_t *)(tr->qtd.next);
free_Transfer(tr);
tr = next;
}
// hopefully we found everything...
free_Pipe(pipe);
} }