netdev
[Top] [All Lists]

[PATCH] spinlock badness in last dongle changes.

To: jt@xxxxxxxxxx, davem@xxxxxxxxxx
Subject: [PATCH] spinlock badness in last dongle changes.
From: Stephen Hemminger <shemminger@xxxxxxxx>
Date: Mon, 6 Oct 2003 22:26:31 -0700
Cc: netdev@xxxxxxxxxxx
Organization: Open Source Development Lab
Sender: netdev-bounce@xxxxxxxxxxx
On 2.6.0-test6 bk latest, rmmod of irda hangs on SMP...

A couple of locking problems happened when converted from using
hashbin lock outside of irqueue.  First, the lock was never initialized;
Second, the lock was being unlocked after the hashbin was free.

Since the hashbin of dongles should be empty (ie all dongle unregistered)
don't really need locking there, so just warn if we find anything...

diff -Nru a/net/irda/irda_device.c b/net/irda/irda_device.c
--- a/net/irda/irda_device.c    Mon Oct  6 22:25:01 2003
+++ b/net/irda/irda_device.c    Mon Oct  6 22:25:01 2003
@@ -90,6 +90,7 @@
                printk(KERN_WARNING "IrDA: Can't allocate dongles hashbin!\n");
                return -ENOMEM;
        }
+       spin_lock_init(&dongles->hb_spinlock);
 
        tasks = hashbin_new(HB_LOCK);
        if (tasks == NULL) {
@@ -104,14 +105,20 @@
        return 0;
 }
 
+static void __exit leftover_dongle(void *arg)
+{
+       struct dongle_reg *reg = arg;
+       printk(KERN_WARNING "IrDA: Dongle type %x not unregistered\n",
+              reg->type);
+}
+
 void __exit irda_device_cleanup(void)
 {
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
 
        hashbin_delete(tasks, (FREE_FUNC) __irda_task_delete);
-       spin_lock(&dongles->hb_spinlock);
-       hashbin_delete(dongles, NULL);
-       spin_unlock(&dongles->hb_spinlock);
+
+       hashbin_delete(dongles, leftover_dongle);
 }
 
 /*

<Prev in Thread] Current Thread [Next in Thread>