Am Sonntag, 12. Januar 2003 18:41 schrieb David Brownell:
> > As far as I can tell an URB should have four states, with preliminary
> > names:
> >
> > 1 - URB_FREE
>
> Try "IDLE" or something; if it's freed, it's owned by the
> memory management code, and usb would never see it.

OK.

> > 2 - URB_SUBMITTED
> > 3 - URB_COMPLETING
> > 4 - URB_CANCELED
>
> If there's a CANCELED state it should just be a sub-state
> of SUBMITTED ... one where urb->status isn't -EINPROGRESS,
> but is -ECONNRESET (async unlink), -ENOENT (synchronous
> unlink) or -ESHUTDOWN (cleanup after host controller halt
> or power loss).

No, that makes the cleanup pointless.
We should have absolute separation of error reporting and state.
Usbcore should never look at urb->status.

> That way the initial state is always IDLE, it always goes
> from there to SUBMITTED, and then becomes eligible to go
> through COMPLETING back to IDLE by (a) hardware-initiated
> completion, normal or fault; else (b) software-initiated
> completion, by unlinking.

We want to make sure that unlinking works in state URB_COMPLETING
as well.
That has several advantages. It reliably unlinks URBs that are resubmitted
in the completion handler. And we can make sure that even the completion
handler is not running when usb_unlink_urb() returns. We beat that pesky
little unload race.

> Then we can define invariants:
>
> - when submitting urbs, they may be either IDLE
>    (for first submit) or COMPLETING (resubmit from
>    completion).
Ack.

> - when unlinking urbs, they must be in SUBMITTED
No, we cannot do that, even in principle. The only
way we could make that an invariant is by calling usb_unlink_urb()
with a spinlock held, which is impossible, as it may sleep.

> - when (really) freeing urbs, they must be in IDLE
Ack.

> - usb_alloc_urb() returns IDLE urbs, and those are
>    the only kind the various init_urb calls take.
Nope, fails for resubmission in completion.
We can only state that it must not be in SUBMITTED.

> Only usbcore would be allowed to change urb->state,
> and everyone spinlocks urb->state before accessing it.
Ack.

        Regards
                Oliver



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to