Ian Dowse 0ce606de7c Attempt to fix a number of race conditions in the handling of
transfer timeouts that typically cause a transfer to be completed
twice, resulting in panics and page faults:

 o A transfer completion interrupt could arrive while an abort_task
   event was set up, so the transfer would be aborted after it had
   completed. This is very easy to reproduce. Fix this by setting
   the transfer status to USBD_TIMEOUT before scheduling the
   abort_task so that the transfer completion code will ignore it.

 o The transfer completion code could execute concurrently with the
   timeout callout, leaving the callout blocked (e.g. waiting for
   Giant) while the transfer completion code runs. In this case,
   callout_stop() does not prevent the callout from running, so
   again the timeout code would run after the transfer was complete.
   Handle this case by checking the return value from callout_stop(),
   and ignoring the transfer if the callout could not be removed.

 o Finally, protect against a timeout callout occurring while a
   transfer is being aborted by another process. Here we arrange
   for the timeout processing to ignore the transfer, and use
   callout_drain() to ensure that the callout has really gone before
   completing the transfer.

This was tested by repeatedly performing USB transfers with a timeout
set to approximately the same as the normal transfer completion
time. In the PR below, apparently this occurred by accident with a
particular printer and the default timeout.

PR:		kern/71491
2004-11-09 20:51:32 +00:00
..
2004-11-09 07:02:33 +00:00
2004-05-30 20:08:47 +00:00
2004-06-27 13:07:02 +00:00
2004-07-10 20:57:43 +00:00
2004-07-22 07:11:15 +00:00
2004-10-17 21:44:11 +00:00
2004-10-22 15:39:39 +00:00
2004-06-16 09:47:26 +00:00
2004-08-02 20:42:28 +00:00
2004-06-16 09:47:26 +00:00
2004-06-16 09:47:26 +00:00
2004-06-16 09:47:26 +00:00
2004-07-10 15:38:27 +00:00
2004-08-04 18:30:31 +00:00
2004-06-16 09:47:26 +00:00
2004-06-16 09:47:26 +00:00
2004-08-25 17:54:19 +00:00
2004-06-16 09:47:26 +00:00
2004-07-10 21:05:14 +00:00
2004-07-10 21:06:08 +00:00
2004-05-30 20:08:47 +00:00
2004-05-30 20:08:47 +00:00
2004-05-30 20:08:47 +00:00
2004-07-10 21:14:20 +00:00
2004-09-10 18:39:02 +00:00
2004-09-01 22:53:13 +00:00
2004-05-30 20:08:47 +00:00
2004-08-18 16:14:44 +00:00
2004-06-16 09:47:26 +00:00
2004-05-30 20:08:47 +00:00
2004-05-30 20:08:47 +00:00