On Wed, Mar 19, 2014 at 11:05 PM, vichy <vichy.kuo@xxxxxxxxx> wrote: > hi Ming: >>>> One approach I like to use is trace event. >>> Would you please let us how to to use trace event for calculate >>> max/average usb irq time? >> >> You can enable irq_handler_entry and irq_handler_exit event, then >> write a script easily to figure out the time consumed in ehci irq handler, >> see Documentation/trace/events.txt of linux kernel for detailed steps. > I find it ^^ > >>>> But actually the local interrupt is still disabled during completion >>>> because we need to convert spin_lock in all current usb drivers >>>> to spin_lock_irqsave() first. >>> Would you please let me know the function or source you mentioned? >> >> The local interrupt is disabled during completion handler in >> __usb_hcd_giveback_urb(). >> >>> >>> BTW, why I cannot see xhci add HCD_BH? >> >> There might be some reasons: >> >> - in previous following up discussion, Alan thought it should >> be easier to just split the hcd interrupt handler into two parts >> >> - as I said, spin_lock() isn't converted to spin_lock_irqsave() >> in drivers' completion handler yet > Do you mean , > take uvc/uac for example, > if we put completion what they register previously in BH, > the spin_lock() in their completions should be changed to spin_lock_irqsave()? > > Is it due to original completion is called in irq context? Some drivers may assume that the completion handler is called from hardirq handler, so call spin_lock(), and they should have called spin_lock_irqsave() if there are shared resources between its completion handler and other irq handler. So the simplest approach for the conversion is to replace all spin_lock() inside urb completion path into spin_lock_irqsave(). > >> >> - maybe no one really care the time in which local interrupt is >> disabled by USB completion handler.(That might be true >> because USB devices are commonly used in personal >> computer, not in big server product) >> >>> is there some reason xhci cannot put completion in BH? >> >> IMO, the completion handler should be put into tasklet, and >> can be done. If you like, you can take time to do that. > Below is so far kernel implementation. > Isn't it put completion handler into tasklet? Yes, it is run in tasklet context with local irq disabled. As you know we need to enable irq during URB completion. > ....................... > ...................... > spin_lock(&bh->lock); > list_add_tail(&urb->urb_list, &bh->head); > running = bh->running; > spin_unlock(&bh->lock); > > if (running) > ; > else if (high_prio_bh) > tasklet_hi_schedule(&bh->bh); > else > tasklet_schedule(&bh->bh); > > > Thanks for your help, -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html