On Wed, 28 Nov 2012, Vivek Bhagat wrote: > Hi Alan, > > In function usb_hcd_giveback_urb() , urb completion handler is called first > followed by decrement of urb->use_count . > usb_hcd_giveback_urb(){ > ... > urb->complete (urb); > atomic_dec (&urb->use_count); > ... > } > > In urb completion handler , urb is re-submitted , urb ref count is > incremented to a value of 2 first and then usb_hcd_giveback_urb reduces > urb->ref_count to 1 . > I think urb ref count should be decremented first followed by urb > completion handler call as below :- > > usb_hcd_giveback_urb(){ > ... > atomic_dec (&urb->use_count); > urb->complete (urb); > ... > } > > Please let me know if i am missing something . > > Thanks, > Vivek On Wed, 28 Nov 2012, amit nagal wrote: > On Thu, Nov 22, 2012 at 6:50 PM, naveen yadav <yad.naveen@xxxxxxxxx> wrote: > > urb_count is incremented at only one place in usb_hcd_submit_urb() and > > decremented in usb_hcd_giveback_urb(). (Also, in error case inside > > usb_hcd_submit_urb()). After taking print of urb->use_count at all > Hi Alan , > > In function usb_hcd_giveback_urb() , urb completion handler is called > first followed by decrement of > urb->use_count as follow : > usb_hcd_giveback_urb(){ > ... > urb->complete (urb); > atomic_dec (&urb->use_count); > ... > } > > In urb completion handler , urb is re-submitted , so urb->use_count is > incremented to a value of 2 first and then usb_hcd_giveback_urb > reduces urb->use_count to 1 . As urb processing is complete by the > time urb->complete() > is called , I think urb->use_count should be decremented first > followed by urb completion handler call as below :- > > usb_hcd_giveback_urb(){ > ... > atomic_dec (&urb->use_count); > urb->complete (urb); > ... > } > > Please let me know if i am missing something . > > Thanks, > Amit Nagal Vivek and Amit, are you two copies of the same person? Anyway, you're both right that urb->use_count is not decremented until after the completion routine returns. But Amit wrote: > As urb processing is complete by the > time urb->complete() > is called , I think urb->use_count should be decremented first > followed by urb completion handler call as below :- This is wrong. Processing continues during urb->complete, which may even resubmit the URB. Now, maybe your problem is that somehow urb->reject is getting set to 0 at the wrong time. You should check its value as well as the value of urb->use_count. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html