Process going to "D" state because of semaphore
I've a device driver that provides two ioctl calls: one for writing to the device & the other for reading from the device.
Both these ioctl cases use the same semaphore for synchronization.
There is a read process that invokes the read ioctl every 1 sec. There is a write process that invokes write ioctl pretty fast comparatively (3-4 times a second).
My observation is that after sometime, the read process goes to the "D" (uninterrupted sleep state). After inserting debug messages I'm seeing that it goes to this state after invoking the "down" system call at the beginning of read ioctl. And it never recovers.
The write process does not stop, it runs continuously.
If write process is killed, then also read process does not recover.
Same behavior is seen even when down_trylock and down_interruptible function calls are used.