Question about using spinlock to synchronize between kernel driver and an interrupt handler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I read this article http://www.linuxjournal.com/article/5833 to learn
about spinlock. I try this to use it in my kernel driver.

Here is what my driver code needs to do:
In f1(), it will get the spin lock, and caller can call f2() will wait
for the lock since the spin lock is not being unlock. The spin lock
will be unlock in my interrupt handler (triggered by the HW).

void f1() {
spin_lock(&mylock);
// write hardware
REG_ADDR += FLAG_A;

}

void f2() {
spin_lock(&mylock);
//...
}

The hardware will send the application an interrupt and my interrupt
handler will call spin_unlock(&mylock);

My question is if I call
f1()
f2() // i want this to block until the interrupt return saying setting
REG_ADDR is done.

when I run this, I get an exception in kernel saying a deadlock "
INFO: possible recursive locking detected"

How  can I re-write my code so that kernel does not think I have a deadlock?

I want my driver code to wait until HW sends me an interrupt saying
setting REG_ADDR is done.

Thank you.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux