then they are NOT mutually exclusive, and the critical regions can happen
at the same time on two different CPU's. That's fine per se, but the
@@ -168,6 +168,25 @@
on other CPU's, because an interrupt on another CPU doesn't interrupt the
CPU that holds the lock, so the lock-holder can continue and eventually
releases the lock).
+
+If you have a case where both interrupt and non-interrupt (e.g. ioctl()) code
+access the same data structures then you should use spin_lock_irqsave() in the
+non-interrupt code and spin_lock() in the interrupt handler as in:
+
+my_ioctl()
+{
+ spin_lock_irqsave(&lock, flags);
+ ...
+ spin_unlock_irqrestore(&lock, flags);
+}
+
+my_irq_handler()
+{
+ spin_lock(&lock);
+ ...
+ spin_unlock(&lock);
+}
+
Note that you can be clever with read-write locks and interrupts. For
example, if you know that the interrupt only ever gets a read-lock, then