> Inspecting the legousbtower.c code reveals that it behaves the same way.
> 
> The offending line is the down() call in the 
> tower_interrupt_in_callback......... (named adu_interrupt_in_callback in my code)
> 
> The down() function in ./include/asm/semaphore.h calls
> might_sleep in ./kernel/sched.c which generates the warning message.
> 
> QUESTIONS:
> Is this acceptable behaviour?

No, it is not.

> If not, how should the code be modified?

You cannot use down() within a completion handler. You need to use a
spinlock. Unfortunately you race with static ssize_t adu_read. It uses
copy_to_user() which in turn cannot be called with a spinlock held.
You should use a double buffer. Protect the switching of buffers and
the completion handler with a spinlock.
First exhaust the secondary buffer. If it is empty, grab the lock, check
whether there's something in the primary buffer. If so exchange the
pointers, drop the lock and begin anew.

        HTH
                Oliver



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to