On Fri, Oct 11, 2002, Johannes Erdfelt <[EMAIL PROTECTED]> wrote:
> On Fri, Oct 11, 2002, Dan Streetman <[EMAIL PROTECTED]> wrote:
> > On Fri, 11 Oct 2002, Johannes Erdfelt wrote:
> > >On Fri, Oct 11, 2002, Dan Streetman <[EMAIL PROTECTED]> wrote:
> > >> -for places where a td->link was written, added check to make sure HC
> > >> hadn't already wrote that td->link back to the td's qh->element.
> > >
> > >This sounds racy.
> > 
> > I think it actually fixes a race.  There are only 2 places, in in
> > uhci_append_queued_urb and uhci_delete_queued_urb.  My mental picture of
> > the race is this:
> > 
> > QH1 -(element)-> TD -> <whatever...QH or TERM>
> > 
> > So, let's say the HC is currently processing the TD.  It finishes, reads
> > TD->link, and writes it back into QH->element.  Then, TD->link is updated
> > by the HCD.  But, TD is already out of the frame list!  So whatever was
> > put there really should be in QH->element, and whatever's in QH->element
> > shouldn't be there.
> > 
> > You can check the 2 places (which do essentially the same thing) in the
> > patch to see if you agree.  They both have a comment "If the HC..."
> 
> Oh, that's not a problem. We'll be removing that finished URB (QH +
> TD's) very shortly and we'll put the new URB that just lost the race into
> the schedule.
> 
> It'll get serviced. So there is a race, but it's a self fixing one.
> 
> The HC could also retire the last TD in between setting td->link and
> updating qh->element as well. The HC caches the entire TD for the duration
> of the packet being sent to the device. That's a lot of CPU cycles.
> 
> I'm just hesitant of reading/writing shared fields when we know that we
> don't own it exclusively.

I forgot that we can fix this too.

Georg had a clever method in usb-uhci that used a bottom QH, which was
always at the end of the last URB. It would be passed on to the next
queued URB for it's head. This would fix this race.

I don't think the race is common enough to really need to do this.

JE



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to