On Wed, 8 May 2013, victor yeo wrote: > >> Is the kagen2_ep_queue function gotten interrupted here? So the > >> kagen2_ep_queue and interrupt routine need spinlock for > >> synchronisation? > > > > That's right. Interrupts can occur at almost any time (on > > multiprocessor systems they can occur even when interrupts are disabled > > on some of the CPUs). > > I am confused. I add the spinlock functions to kagen2_ep_queue function. > > spin_lock_irqsave(&dev->lock, flags); > ...... > spin_unlock_irqrestore(&dev->lock, flags); > > When kagen2_ep_queue function is called, the error "BUG: scheduling > while atomic: swapper/0/0x00000002" occurs. I test the same spinlock > functions in other device module. It is ok in other device module. While the function holds a spinlock, it is not allowed to sleep. The BUG occurs because kagen2_ep_queue must call some function that can sleep. But since you did not provide the rest of the BUG message (including the stack trace), I can't tell what function it calls. Alan Stern -- 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