kernel - acpi - fix thermal thread loop
authorMatthew Dillon <dillon@apollo.backplane.com>
Mon, 15 Feb 2010 05:37:01 +0000 (21:37 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 15 Feb 2010 05:37:01 +0000 (21:37 -0800)
* The thermal thread was sleeping in tzpool with the thermal lock held,
  causing anyone trying to use the lock (e.g. apm) to block for very
  long periods of time (sometimes forever).

* Properly drop the lock when sleeping.

sys/dev/acpica5/acpi_thermal.c

index 5bf894b..4fd6893 100644 (file)
@@ -981,15 +981,15 @@ acpi_tz_thread(void *arg)
        }
 
        /*
-        * If we have no more work, sleep for a while, setting PDROP so that
-        * the mutex will not be reacquired.  Otherwise, drop the mutex and
-        * loop to handle more events.
+        * Interlocked sleep until signaled or we timeout.
         */
-       if (i == devcount)
-           tsleep(&acpi_tz_td, 0, "tzpoll",
-               hz * acpi_tz_polling_rate);
-       else
+       if (i == devcount) {
+           tsleep_interlock(&acpi_tz_td, 0);
+           ACPI_UNLOCK(thermal);
+           tsleep(&acpi_tz_td, 0, "tzpoll", hz * acpi_tz_polling_rate);
+       } else {
            ACPI_UNLOCK(thermal);
+       }
     }
 }