[PATCH] uml: lock the irqs_to_free list
authorJeff Dike <jdike@addtoit.com>
Sat, 10 Feb 2007 09:43:55 +0000 (01:43 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Sun, 11 Feb 2007 18:51:21 +0000 (10:51 -0800)
Fix (i.e. add some) the locking around the irqs_to_free list.

Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/um/drivers/chan_kern.c

index 4e7e3cfa21f96f14845968540984cbd6aa74fa01..bce9b3427b0916fda3fd4f585bc8b3b5e3741688 100644 (file)
@@ -222,15 +222,28 @@ void enable_chan(struct line *line)
        }
 }
 
+/* Items are added in IRQ context, when free_irq can't be called, and
+ * removed in process context, when it can.
+ * This handles interrupt sources which disappear, and which need to
+ * be permanently disabled.  This is discovered in IRQ context, but
+ * the freeing of the IRQ must be done later.
+ */
+static DEFINE_SPINLOCK(irqs_to_free_lock);
 static LIST_HEAD(irqs_to_free);
 
 void free_irqs(void)
 {
        struct chan *chan;
+       LIST_HEAD(list);
+       struct list_head *ele;
+
+       spin_lock_irq(&irqs_to_free_lock);
+       list_splice_init(&irqs_to_free, &list);
+       INIT_LIST_HEAD(&irqs_to_free);
+       spin_unlock_irq(&irqs_to_free_lock);
 
-       while(!list_empty(&irqs_to_free)){
-               chan = list_entry(irqs_to_free.next, struct chan, free_list);
-               list_del(&chan->free_list);
+       list_for_each(ele, &list){
+               chan = list_entry(ele, struct chan, free_list);
 
                if(chan->input)
                        free_irq(chan->line->driver->read_irq, chan);
@@ -246,7 +259,9 @@ static void close_one_chan(struct chan *chan, int delay_free_irq)
                return;
 
        if(delay_free_irq){
+               spin_lock_irq(&irqs_to_free_lock);
                list_add(&chan->free_list, &irqs_to_free);
+               spin_unlock_irq(&irqs_to_free_lock);
        }
        else {
                if(chan->input)