coretemp, sensors - Adjust spinlocks
authorAlex Hornung <ahornung@gmail.com>
Mon, 30 Aug 2010 06:47:34 +0000 (07:47 +0100)
committerAlex Hornung <ahornung@gmail.com>
Mon, 30 Aug 2010 10:33:28 +0000 (11:33 +0100)
* In kern_sensors, adjust the spinlocks to not be held across the sysctl
  interface management.

* In coretemp, adjust illegal spinlock across calls to kern_sensors.

Reported-by: Matt Dillon (dillon@)
sys/dev/powermng/coretemp/coretemp.c
sys/kern/kern_sensors.c

index 58564bd..7e02dc4 100644 (file)
@@ -39,8 +39,6 @@
 #include <sys/conf.h>
 #include <sys/kernel.h>
 #include <sys/sensors.h>
-#include <sys/spinlock.h>
-#include <sys/spinlock2.h>
 #include <sys/proc.h>  /* for curthread */
 #include <sys/sched.h>
 
@@ -48,8 +46,6 @@
 #include <machine/cpufunc.h>
 #include <machine/md_var.h>
 
-static struct spinlock         coretemp_lock;
-
 struct coretemp_softc {
        struct ksensordev       sc_sensordev;
        struct ksensor          sc_sensor;
@@ -186,7 +182,6 @@ coretemp_attach(device_t dev)
                return (ENXIO);
        }
        sensordev_install(&sc->sc_sensordev);
-       spin_init(&coretemp_lock);
 
        return (0);
 }
@@ -196,11 +191,8 @@ coretemp_detach(device_t dev)
 {
        struct coretemp_softc *sc = device_get_softc(dev);
 
-       spin_lock_wr(&coretemp_lock);
        sensordev_deinstall(&sc->sc_sensordev);
        sensor_task_unregister(sc);
-       spin_unlock_wr(&coretemp_lock);
-       spin_uninit(&coretemp_lock);
 
        return (0);
 }
@@ -225,9 +217,7 @@ coretemp_get_temp(device_t dev)
                origcpu = mycpuid;
                lwkt_migratecpu(cpu);
 
-               spin_lock_wr(&coretemp_lock);
                msr = rdmsr(MSR_THERM_STATUS);
-               spin_unlock_wr(&coretemp_lock);
 
                lwkt_migratecpu(origcpu);
        } else if (cpu != 0)
index 7070ece..d266ebe 100644 (file)
@@ -86,11 +86,11 @@ sensordev_install(struct ksensordev *sensdev)
        }
        sensordev_count++;
        /* mtx_unlock(&Giant); */
+       spin_unlock_wr(&sensor_dev_lock);
 
 #ifndef NOSYSCTL8HACK
        sensor_sysctl8magic_install(sensdev);
 #endif
-       spin_unlock_wr(&sensor_dev_lock);
 }
 
 void
@@ -139,11 +139,11 @@ sensordev_deinstall(struct ksensordev *sensdev)
        sensordev_count--;
        SLIST_REMOVE(&sensordev_list, sensdev, ksensordev, list);
        /* mtx_unlock(&Giant); */
+       spin_unlock_wr(&sensor_dev_lock);
 
 #ifndef NOSYSCTL8HACK
        sensor_sysctl8magic_deinstall(sensdev);
 #endif
-       spin_unlock_wr(&sensor_dev_lock);
 }
 
 void