2005/10/24, Alan Stern <[EMAIL PROTECTED]>:
> On Fri, 21 Oct 2005, Franck wrote:
>
> > But the HCD can decide to not add the urb into the ep's queue if
> > something is going wrong...In that case it refuses to own the urb.
> > What I was thinking of is: the usbcore initialized the urb then passes
> > it to HCD through hcd->urb_enqueue. the HCD initiailized urb and then
> > if every thing is ok it adds urb into queue through a usbcore
> > function, for instance "usb_make_active"
> >
> > void usb_make_active(struct usb_hos_endpoint *ep, struct *urb)
> > {
> >         spin_lock(&hcd_data_lock);
> >         urb->status = -EINPROGRESS;
> >         usb_get_urb(urb);
> >         atomic_inc(&urb->use_count);
> >         list_add_tail (&urb->urb_list, &ep->urb_list);
> >         spin_unlock(&hcd_data_lock);
> > }
>
> I realized over the weekend that this won't work.  You'll encounter a race
> when trying to disable endpoints.  Right now it works because usbcore
> knows that hcd_data_lock can be used to synchronize threads trying to
> submit URBs with the thread trying to disable the endpoint.  The only way
> it could continue to work would be if your usb_make_active routine could
> return a failure when the endpoint had been disabled.  Then that would
> force the HCDs to clean up whatever action they had already taken.
>

That's true. It would mean move more code from hcd_submit_urb into
usb_make_active.

> I still think it would be simpler all round to have HCDs avoid activating
> an URB if urb->hcpriv is NULL.
>

It's obviously the simplest fix. But I still think that the other fix
make lock and ownership things easier to understand...

I noticed in hcd_submit_urb that we increments the reference count of
the usb device structure through usb_get_dev. This refence count seems
to be handle by usbcore, is that correct ? If so, why does
"sl811h->disable_endpoint" method call usb_put_dev ?

Thanks
--
               Franck


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to