|
http://lkml.indiana.edu/hypermail/linux/kernel/0009.3/0906.html Heh.. I needed to figure this out about 6 months ago. Here's the
"right
Before sending the command to the board, call
Then, send the command to the board. Then call schedule() or
See linux/drivers/usb/storage/transport.c usb_stor_bulk_msg() for
the code
Matt
> > Hello, > > In order to get the configuration of a board, I have to send, from > userspace, an ioctl to the driver and wait for the board to complete its > action. The way this is implemented is as follows: > - In the ioctl, the driver sends a command to the board and then goes to > sleep (interruptible_sleep_on(&info->config_wait)); > - The board receives the command, handles it and answers back with an > interrupt; > - The driver's interrupt handler schedules a bottom-half action. > - The bottom-half calls wake_up_interuptible(&info->config_wait). > - The ioctl returns and the userspace application has the board > configuration. > > Now, the problem: the board is so fast that it interrupts back _before_ > the driver goes to sleep, i.e.: > - Driver sends command to board; > - Driver goes to sl... interrupt back from board!! > - Interrupt handler schedules bottom-half. > - Bottom-half calls wake_up. > - Ioctl continues, and _then_ goes to sleep. System locked. > > I can't disable interrupts before going to sleep, because the event that > wakes me up is an interrupt. However, if I don't protect it from the > interrupts, the system locks ... > > Is there any other way in Linux to implement this?!?!?! > > Thanks in advance for any help. > > Later, > Ivan |
