Search code examples
clinuxlinux-kerneldriverlinux-device-driver

Waiting in Linux Kernel Module(Driver) Critical Section for user-space input


I'm new to kernel programming and I was making changes in a Linux Driver. I want to block/wait in a Critical Section for user input(The communication between the Driver and the user-space Application work). The Problem is that when I used wait_event_timeout() the System is being crashed and I am getting BUG: scheduling while atomic: swapper. Is anybody have any idea how to solve this problem and can give me some advice where to start?


Solution

  • As explained in other questions, you are calling wait_event_timeout in a context when you already have some lock acquired (inside a critical section). In this point your process can potentially deadlock with other processes and the scheduler complains about it. Please, review the point where you are calling wait_event_timeout and check if the I/O is performed in the correct place and if you have unlocked all synchronization primitives before sending your process to sleep.