thermal.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308
  1. /*
  2. * acpi_thermal.c - ACPI Thermal Zone Driver ($Revision: 41 $)
  3. *
  4. * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
  5. * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  6. *
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or (at
  12. * your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  22. *
  23. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. *
  25. * This driver fully implements the ACPI thermal policy as described in the
  26. * ACPI 2.0 Specification.
  27. *
  28. * TBD: 1. Implement passive cooling hysteresis.
  29. * 2. Enhance passive cooling (CPU) states/limit interface to support
  30. * concepts of 'multiple limiters', upper/lower limits, etc.
  31. *
  32. */
  33. #include <linux/kernel.h>
  34. #include <linux/module.h>
  35. #include <linux/init.h>
  36. #include <linux/types.h>
  37. #include <linux/proc_fs.h>
  38. #include <linux/timer.h>
  39. #include <linux/jiffies.h>
  40. #include <linux/kmod.h>
  41. #include <linux/seq_file.h>
  42. #include <linux/reboot.h>
  43. #include <asm/uaccess.h>
  44. #include <acpi/acpi_bus.h>
  45. #include <acpi/acpi_drivers.h>
  46. #define ACPI_THERMAL_COMPONENT 0x04000000
  47. #define ACPI_THERMAL_CLASS "thermal_zone"
  48. #define ACPI_THERMAL_DEVICE_NAME "Thermal Zone"
  49. #define ACPI_THERMAL_FILE_STATE "state"
  50. #define ACPI_THERMAL_FILE_TEMPERATURE "temperature"
  51. #define ACPI_THERMAL_FILE_TRIP_POINTS "trip_points"
  52. #define ACPI_THERMAL_FILE_COOLING_MODE "cooling_mode"
  53. #define ACPI_THERMAL_FILE_POLLING_FREQ "polling_frequency"
  54. #define ACPI_THERMAL_NOTIFY_TEMPERATURE 0x80
  55. #define ACPI_THERMAL_NOTIFY_THRESHOLDS 0x81
  56. #define ACPI_THERMAL_NOTIFY_DEVICES 0x82
  57. #define ACPI_THERMAL_NOTIFY_CRITICAL 0xF0
  58. #define ACPI_THERMAL_NOTIFY_HOT 0xF1
  59. #define ACPI_THERMAL_MODE_ACTIVE 0x00
  60. #define ACPI_THERMAL_MAX_ACTIVE 10
  61. #define ACPI_THERMAL_MAX_LIMIT_STR_LEN 65
  62. #define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732>=0) ? ((long)t-2732+5)/10 : ((long)t-2732-5)/10)
  63. #define CELSIUS_TO_KELVIN(t) ((t+273)*10)
  64. #define _COMPONENT ACPI_THERMAL_COMPONENT
  65. ACPI_MODULE_NAME("thermal");
  66. MODULE_AUTHOR("Paul Diefenbaugh");
  67. MODULE_DESCRIPTION("ACPI Thermal Zone Driver");
  68. MODULE_LICENSE("GPL");
  69. static int tzp;
  70. module_param(tzp, int, 0);
  71. MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds.\n");
  72. static int acpi_thermal_add(struct acpi_device *device);
  73. static int acpi_thermal_remove(struct acpi_device *device, int type);
  74. static int acpi_thermal_resume(struct acpi_device *device);
  75. static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file);
  76. static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file);
  77. static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file);
  78. static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file);
  79. static ssize_t acpi_thermal_write_cooling_mode(struct file *,
  80. const char __user *, size_t,
  81. loff_t *);
  82. static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file);
  83. static ssize_t acpi_thermal_write_polling(struct file *, const char __user *,
  84. size_t, loff_t *);
  85. static struct acpi_driver acpi_thermal_driver = {
  86. .name = "thermal",
  87. .class = ACPI_THERMAL_CLASS,
  88. .ids = ACPI_THERMAL_HID,
  89. .ops = {
  90. .add = acpi_thermal_add,
  91. .remove = acpi_thermal_remove,
  92. .resume = acpi_thermal_resume,
  93. },
  94. };
  95. struct acpi_thermal_state {
  96. u8 critical:1;
  97. u8 hot:1;
  98. u8 passive:1;
  99. u8 active:1;
  100. u8 reserved:4;
  101. int active_index;
  102. };
  103. struct acpi_thermal_state_flags {
  104. u8 valid:1;
  105. u8 enabled:1;
  106. u8 reserved:6;
  107. };
  108. struct acpi_thermal_critical {
  109. struct acpi_thermal_state_flags flags;
  110. unsigned long temperature;
  111. };
  112. struct acpi_thermal_hot {
  113. struct acpi_thermal_state_flags flags;
  114. unsigned long temperature;
  115. };
  116. struct acpi_thermal_passive {
  117. struct acpi_thermal_state_flags flags;
  118. unsigned long temperature;
  119. unsigned long tc1;
  120. unsigned long tc2;
  121. unsigned long tsp;
  122. struct acpi_handle_list devices;
  123. };
  124. struct acpi_thermal_active {
  125. struct acpi_thermal_state_flags flags;
  126. unsigned long temperature;
  127. struct acpi_handle_list devices;
  128. };
  129. struct acpi_thermal_trips {
  130. struct acpi_thermal_critical critical;
  131. struct acpi_thermal_hot hot;
  132. struct acpi_thermal_passive passive;
  133. struct acpi_thermal_active active[ACPI_THERMAL_MAX_ACTIVE];
  134. };
  135. struct acpi_thermal_flags {
  136. u8 cooling_mode:1; /* _SCP */
  137. u8 devices:1; /* _TZD */
  138. u8 reserved:6;
  139. };
  140. struct acpi_thermal {
  141. struct acpi_device * device;
  142. acpi_bus_id name;
  143. unsigned long temperature;
  144. unsigned long last_temperature;
  145. unsigned long polling_frequency;
  146. volatile u8 zombie;
  147. struct acpi_thermal_flags flags;
  148. struct acpi_thermal_state state;
  149. struct acpi_thermal_trips trips;
  150. struct acpi_handle_list devices;
  151. struct timer_list timer;
  152. };
  153. static const struct file_operations acpi_thermal_state_fops = {
  154. .open = acpi_thermal_state_open_fs,
  155. .read = seq_read,
  156. .llseek = seq_lseek,
  157. .release = single_release,
  158. };
  159. static const struct file_operations acpi_thermal_temp_fops = {
  160. .open = acpi_thermal_temp_open_fs,
  161. .read = seq_read,
  162. .llseek = seq_lseek,
  163. .release = single_release,
  164. };
  165. static const struct file_operations acpi_thermal_trip_fops = {
  166. .open = acpi_thermal_trip_open_fs,
  167. .read = seq_read,
  168. .llseek = seq_lseek,
  169. .release = single_release,
  170. };
  171. static const struct file_operations acpi_thermal_cooling_fops = {
  172. .open = acpi_thermal_cooling_open_fs,
  173. .read = seq_read,
  174. .write = acpi_thermal_write_cooling_mode,
  175. .llseek = seq_lseek,
  176. .release = single_release,
  177. };
  178. static const struct file_operations acpi_thermal_polling_fops = {
  179. .open = acpi_thermal_polling_open_fs,
  180. .read = seq_read,
  181. .write = acpi_thermal_write_polling,
  182. .llseek = seq_lseek,
  183. .release = single_release,
  184. };
  185. /* --------------------------------------------------------------------------
  186. Thermal Zone Management
  187. -------------------------------------------------------------------------- */
  188. static int acpi_thermal_get_temperature(struct acpi_thermal *tz)
  189. {
  190. acpi_status status = AE_OK;
  191. if (!tz)
  192. return -EINVAL;
  193. tz->last_temperature = tz->temperature;
  194. status =
  195. acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tz->temperature);
  196. if (ACPI_FAILURE(status))
  197. return -ENODEV;
  198. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n",
  199. tz->temperature));
  200. return 0;
  201. }
  202. static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
  203. {
  204. acpi_status status = AE_OK;
  205. if (!tz)
  206. return -EINVAL;
  207. status =
  208. acpi_evaluate_integer(tz->device->handle, "_TZP", NULL,
  209. &tz->polling_frequency);
  210. if (ACPI_FAILURE(status))
  211. return -ENODEV;
  212. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n",
  213. tz->polling_frequency));
  214. return 0;
  215. }
  216. static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds)
  217. {
  218. if (!tz)
  219. return -EINVAL;
  220. tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */
  221. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  222. "Polling frequency set to %lu seconds\n",
  223. tz->polling_frequency/10));
  224. return 0;
  225. }
  226. static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
  227. {
  228. acpi_status status = AE_OK;
  229. union acpi_object arg0 = { ACPI_TYPE_INTEGER };
  230. struct acpi_object_list arg_list = { 1, &arg0 };
  231. acpi_handle handle = NULL;
  232. if (!tz)
  233. return -EINVAL;
  234. status = acpi_get_handle(tz->device->handle, "_SCP", &handle);
  235. if (ACPI_FAILURE(status)) {
  236. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n"));
  237. return -ENODEV;
  238. }
  239. arg0.integer.value = mode;
  240. status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
  241. if (ACPI_FAILURE(status))
  242. return -ENODEV;
  243. return 0;
  244. }
  245. static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
  246. {
  247. acpi_status status = AE_OK;
  248. int i = 0;
  249. if (!tz)
  250. return -EINVAL;
  251. /* Critical Shutdown (required) */
  252. status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL,
  253. &tz->trips.critical.temperature);
  254. if (ACPI_FAILURE(status)) {
  255. tz->trips.critical.flags.valid = 0;
  256. ACPI_EXCEPTION((AE_INFO, status, "No critical threshold"));
  257. return -ENODEV;
  258. } else {
  259. tz->trips.critical.flags.valid = 1;
  260. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  261. "Found critical threshold [%lu]\n",
  262. tz->trips.critical.temperature));
  263. }
  264. /* Critical Sleep (optional) */
  265. status =
  266. acpi_evaluate_integer(tz->device->handle, "_HOT", NULL,
  267. &tz->trips.hot.temperature);
  268. if (ACPI_FAILURE(status)) {
  269. tz->trips.hot.flags.valid = 0;
  270. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No hot threshold\n"));
  271. } else {
  272. tz->trips.hot.flags.valid = 1;
  273. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found hot threshold [%lu]\n",
  274. tz->trips.hot.temperature));
  275. }
  276. /* Passive: Processors (optional) */
  277. status =
  278. acpi_evaluate_integer(tz->device->handle, "_PSV", NULL,
  279. &tz->trips.passive.temperature);
  280. if (ACPI_FAILURE(status)) {
  281. tz->trips.passive.flags.valid = 0;
  282. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No passive threshold\n"));
  283. } else {
  284. tz->trips.passive.flags.valid = 1;
  285. status =
  286. acpi_evaluate_integer(tz->device->handle, "_TC1", NULL,
  287. &tz->trips.passive.tc1);
  288. if (ACPI_FAILURE(status))
  289. tz->trips.passive.flags.valid = 0;
  290. status =
  291. acpi_evaluate_integer(tz->device->handle, "_TC2", NULL,
  292. &tz->trips.passive.tc2);
  293. if (ACPI_FAILURE(status))
  294. tz->trips.passive.flags.valid = 0;
  295. status =
  296. acpi_evaluate_integer(tz->device->handle, "_TSP", NULL,
  297. &tz->trips.passive.tsp);
  298. if (ACPI_FAILURE(status))
  299. tz->trips.passive.flags.valid = 0;
  300. status =
  301. acpi_evaluate_reference(tz->device->handle, "_PSL", NULL,
  302. &tz->trips.passive.devices);
  303. if (ACPI_FAILURE(status))
  304. tz->trips.passive.flags.valid = 0;
  305. if (!tz->trips.passive.flags.valid)
  306. printk(KERN_WARNING PREFIX "Invalid passive threshold\n");
  307. else
  308. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  309. "Found passive threshold [%lu]\n",
  310. tz->trips.passive.temperature));
  311. }
  312. /* Active: Fans, etc. (optional) */
  313. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  314. char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
  315. status =
  316. acpi_evaluate_integer(tz->device->handle, name, NULL,
  317. &tz->trips.active[i].temperature);
  318. if (ACPI_FAILURE(status))
  319. break;
  320. name[2] = 'L';
  321. status =
  322. acpi_evaluate_reference(tz->device->handle, name, NULL,
  323. &tz->trips.active[i].devices);
  324. if (ACPI_SUCCESS(status)) {
  325. tz->trips.active[i].flags.valid = 1;
  326. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  327. "Found active threshold [%d]:[%lu]\n",
  328. i, tz->trips.active[i].temperature));
  329. } else
  330. ACPI_EXCEPTION((AE_INFO, status,
  331. "Invalid active threshold [%d]", i));
  332. }
  333. return 0;
  334. }
  335. static int acpi_thermal_get_devices(struct acpi_thermal *tz)
  336. {
  337. acpi_status status = AE_OK;
  338. if (!tz)
  339. return -EINVAL;
  340. status =
  341. acpi_evaluate_reference(tz->device->handle, "_TZD", NULL, &tz->devices);
  342. if (ACPI_FAILURE(status))
  343. return -ENODEV;
  344. return 0;
  345. }
  346. static int acpi_thermal_critical(struct acpi_thermal *tz)
  347. {
  348. if (!tz || !tz->trips.critical.flags.valid)
  349. return -EINVAL;
  350. if (tz->temperature >= tz->trips.critical.temperature) {
  351. printk(KERN_WARNING PREFIX "Critical trip point\n");
  352. tz->trips.critical.flags.enabled = 1;
  353. } else if (tz->trips.critical.flags.enabled)
  354. tz->trips.critical.flags.enabled = 0;
  355. printk(KERN_EMERG
  356. "Critical temperature reached (%ld C), shutting down.\n",
  357. KELVIN_TO_CELSIUS(tz->temperature));
  358. acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL,
  359. tz->trips.critical.flags.enabled);
  360. orderly_poweroff(true);
  361. return 0;
  362. }
  363. static int acpi_thermal_hot(struct acpi_thermal *tz)
  364. {
  365. if (!tz || !tz->trips.hot.flags.valid)
  366. return -EINVAL;
  367. if (tz->temperature >= tz->trips.hot.temperature) {
  368. printk(KERN_WARNING PREFIX "Hot trip point\n");
  369. tz->trips.hot.flags.enabled = 1;
  370. } else if (tz->trips.hot.flags.enabled)
  371. tz->trips.hot.flags.enabled = 0;
  372. acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_HOT,
  373. tz->trips.hot.flags.enabled);
  374. /* TBD: Call user-mode "sleep(S4)" function */
  375. return 0;
  376. }
  377. static void acpi_thermal_passive(struct acpi_thermal *tz)
  378. {
  379. int result = 1;
  380. struct acpi_thermal_passive *passive = NULL;
  381. int trend = 0;
  382. int i = 0;
  383. if (!tz || !tz->trips.passive.flags.valid)
  384. return;
  385. passive = &(tz->trips.passive);
  386. /*
  387. * Above Trip?
  388. * -----------
  389. * Calculate the thermal trend (using the passive cooling equation)
  390. * and modify the performance limit for all passive cooling devices
  391. * accordingly. Note that we assume symmetry.
  392. */
  393. if (tz->temperature >= passive->temperature) {
  394. trend =
  395. (passive->tc1 * (tz->temperature - tz->last_temperature)) +
  396. (passive->tc2 * (tz->temperature - passive->temperature));
  397. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  398. "trend[%d]=(tc1[%lu]*(tmp[%lu]-last[%lu]))+(tc2[%lu]*(tmp[%lu]-psv[%lu]))\n",
  399. trend, passive->tc1, tz->temperature,
  400. tz->last_temperature, passive->tc2,
  401. tz->temperature, passive->temperature));
  402. passive->flags.enabled = 1;
  403. /* Heating up? */
  404. if (trend > 0)
  405. for (i = 0; i < passive->devices.count; i++)
  406. acpi_processor_set_thermal_limit(passive->
  407. devices.
  408. handles[i],
  409. ACPI_PROCESSOR_LIMIT_INCREMENT);
  410. /* Cooling off? */
  411. else if (trend < 0) {
  412. for (i = 0; i < passive->devices.count; i++)
  413. /*
  414. * assume that we are on highest
  415. * freq/lowest thrott and can leave
  416. * passive mode, even in error case
  417. */
  418. if (!acpi_processor_set_thermal_limit
  419. (passive->devices.handles[i],
  420. ACPI_PROCESSOR_LIMIT_DECREMENT))
  421. result = 0;
  422. /*
  423. * Leave cooling mode, even if the temp might
  424. * higher than trip point This is because some
  425. * machines might have long thermal polling
  426. * frequencies (tsp) defined. We will fall back
  427. * into passive mode in next cycle (probably quicker)
  428. */
  429. if (result) {
  430. passive->flags.enabled = 0;
  431. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  432. "Disabling passive cooling, still above threshold,"
  433. " but we are cooling down\n"));
  434. }
  435. }
  436. return;
  437. }
  438. /*
  439. * Below Trip?
  440. * -----------
  441. * Implement passive cooling hysteresis to slowly increase performance
  442. * and avoid thrashing around the passive trip point. Note that we
  443. * assume symmetry.
  444. */
  445. if (!passive->flags.enabled)
  446. return;
  447. for (i = 0; i < passive->devices.count; i++)
  448. if (!acpi_processor_set_thermal_limit
  449. (passive->devices.handles[i],
  450. ACPI_PROCESSOR_LIMIT_DECREMENT))
  451. result = 0;
  452. if (result) {
  453. passive->flags.enabled = 0;
  454. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  455. "Disabling passive cooling (zone is cool)\n"));
  456. }
  457. }
  458. static void acpi_thermal_active(struct acpi_thermal *tz)
  459. {
  460. int result = 0;
  461. struct acpi_thermal_active *active = NULL;
  462. int i = 0;
  463. int j = 0;
  464. unsigned long maxtemp = 0;
  465. if (!tz)
  466. return;
  467. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  468. active = &(tz->trips.active[i]);
  469. if (!active || !active->flags.valid)
  470. break;
  471. if (tz->temperature >= active->temperature) {
  472. /*
  473. * Above Threshold?
  474. * ----------------
  475. * If not already enabled, turn ON all cooling devices
  476. * associated with this active threshold.
  477. */
  478. if (active->temperature > maxtemp)
  479. tz->state.active_index = i;
  480. maxtemp = active->temperature;
  481. if (active->flags.enabled)
  482. continue;
  483. for (j = 0; j < active->devices.count; j++) {
  484. result =
  485. acpi_bus_set_power(active->devices.
  486. handles[j],
  487. ACPI_STATE_D0);
  488. if (result) {
  489. printk(KERN_WARNING PREFIX
  490. "Unable to turn cooling device [%p] 'on'\n",
  491. active->devices.
  492. handles[j]);
  493. continue;
  494. }
  495. active->flags.enabled = 1;
  496. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  497. "Cooling device [%p] now 'on'\n",
  498. active->devices.handles[j]));
  499. }
  500. continue;
  501. }
  502. if (!active->flags.enabled)
  503. continue;
  504. /*
  505. * Below Threshold?
  506. * ----------------
  507. * Turn OFF all cooling devices associated with this
  508. * threshold.
  509. */
  510. for (j = 0; j < active->devices.count; j++) {
  511. result = acpi_bus_set_power(active->devices.handles[j],
  512. ACPI_STATE_D3);
  513. if (result) {
  514. printk(KERN_WARNING PREFIX
  515. "Unable to turn cooling device [%p] 'off'\n",
  516. active->devices.handles[j]);
  517. continue;
  518. }
  519. active->flags.enabled = 0;
  520. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  521. "Cooling device [%p] now 'off'\n",
  522. active->devices.handles[j]));
  523. }
  524. }
  525. }
  526. static void acpi_thermal_check(void *context);
  527. static void acpi_thermal_run(unsigned long data)
  528. {
  529. struct acpi_thermal *tz = (struct acpi_thermal *)data;
  530. if (!tz->zombie)
  531. acpi_os_execute(OSL_GPE_HANDLER, acpi_thermal_check, (void *)data);
  532. }
  533. static void acpi_thermal_check(void *data)
  534. {
  535. int result = 0;
  536. struct acpi_thermal *tz = data;
  537. unsigned long sleep_time = 0;
  538. int i = 0;
  539. struct acpi_thermal_state state;
  540. if (!tz) {
  541. printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
  542. return;
  543. }
  544. state = tz->state;
  545. result = acpi_thermal_get_temperature(tz);
  546. if (result)
  547. return;
  548. memset(&tz->state, 0, sizeof(tz->state));
  549. /*
  550. * Check Trip Points
  551. * -----------------
  552. * Compare the current temperature to the trip point values to see
  553. * if we've entered one of the thermal policy states. Note that
  554. * this function determines when a state is entered, but the
  555. * individual policy decides when it is exited (e.g. hysteresis).
  556. */
  557. if (tz->trips.critical.flags.valid)
  558. state.critical |=
  559. (tz->temperature >= tz->trips.critical.temperature);
  560. if (tz->trips.hot.flags.valid)
  561. state.hot |= (tz->temperature >= tz->trips.hot.temperature);
  562. if (tz->trips.passive.flags.valid)
  563. state.passive |=
  564. (tz->temperature >= tz->trips.passive.temperature);
  565. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
  566. if (tz->trips.active[i].flags.valid)
  567. state.active |=
  568. (tz->temperature >=
  569. tz->trips.active[i].temperature);
  570. /*
  571. * Invoke Policy
  572. * -------------
  573. * Separated from the above check to allow individual policy to
  574. * determine when to exit a given state.
  575. */
  576. if (state.critical)
  577. acpi_thermal_critical(tz);
  578. if (state.hot)
  579. acpi_thermal_hot(tz);
  580. if (state.passive)
  581. acpi_thermal_passive(tz);
  582. if (state.active)
  583. acpi_thermal_active(tz);
  584. /*
  585. * Calculate State
  586. * ---------------
  587. * Again, separated from the above two to allow independent policy
  588. * decisions.
  589. */
  590. tz->state.critical = tz->trips.critical.flags.enabled;
  591. tz->state.hot = tz->trips.hot.flags.enabled;
  592. tz->state.passive = tz->trips.passive.flags.enabled;
  593. tz->state.active = 0;
  594. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
  595. tz->state.active |= tz->trips.active[i].flags.enabled;
  596. /*
  597. * Calculate Sleep Time
  598. * --------------------
  599. * If we're in the passive state, use _TSP's value. Otherwise
  600. * use the default polling frequency (e.g. _TZP). If no polling
  601. * frequency is specified then we'll wait forever (at least until
  602. * a thermal event occurs). Note that _TSP and _TZD values are
  603. * given in 1/10th seconds (we must covert to milliseconds).
  604. */
  605. if (tz->state.passive)
  606. sleep_time = tz->trips.passive.tsp * 100;
  607. else if (tz->polling_frequency > 0)
  608. sleep_time = tz->polling_frequency * 100;
  609. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s: temperature[%lu] sleep[%lu]\n",
  610. tz->name, tz->temperature, sleep_time));
  611. /*
  612. * Schedule Next Poll
  613. * ------------------
  614. */
  615. if (!sleep_time) {
  616. if (timer_pending(&(tz->timer)))
  617. del_timer(&(tz->timer));
  618. } else {
  619. if (timer_pending(&(tz->timer)))
  620. mod_timer(&(tz->timer),
  621. jiffies + (HZ * sleep_time) / 1000);
  622. else {
  623. tz->timer.data = (unsigned long)tz;
  624. tz->timer.function = acpi_thermal_run;
  625. tz->timer.expires = jiffies + (HZ * sleep_time) / 1000;
  626. add_timer(&(tz->timer));
  627. }
  628. }
  629. return;
  630. }
  631. /* --------------------------------------------------------------------------
  632. FS Interface (/proc)
  633. -------------------------------------------------------------------------- */
  634. static struct proc_dir_entry *acpi_thermal_dir;
  635. static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
  636. {
  637. struct acpi_thermal *tz = seq->private;
  638. if (!tz)
  639. goto end;
  640. seq_puts(seq, "state: ");
  641. if (!tz->state.critical && !tz->state.hot && !tz->state.passive
  642. && !tz->state.active)
  643. seq_puts(seq, "ok\n");
  644. else {
  645. if (tz->state.critical)
  646. seq_puts(seq, "critical ");
  647. if (tz->state.hot)
  648. seq_puts(seq, "hot ");
  649. if (tz->state.passive)
  650. seq_puts(seq, "passive ");
  651. if (tz->state.active)
  652. seq_printf(seq, "active[%d]", tz->state.active_index);
  653. seq_puts(seq, "\n");
  654. }
  655. end:
  656. return 0;
  657. }
  658. static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file)
  659. {
  660. return single_open(file, acpi_thermal_state_seq_show, PDE(inode)->data);
  661. }
  662. static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
  663. {
  664. int result = 0;
  665. struct acpi_thermal *tz = seq->private;
  666. if (!tz)
  667. goto end;
  668. result = acpi_thermal_get_temperature(tz);
  669. if (result)
  670. goto end;
  671. seq_printf(seq, "temperature: %ld C\n",
  672. KELVIN_TO_CELSIUS(tz->temperature));
  673. end:
  674. return 0;
  675. }
  676. static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file)
  677. {
  678. return single_open(file, acpi_thermal_temp_seq_show, PDE(inode)->data);
  679. }
  680. static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
  681. {
  682. struct acpi_thermal *tz = seq->private;
  683. struct acpi_device *device;
  684. acpi_status status;
  685. int i = 0;
  686. int j = 0;
  687. if (!tz)
  688. goto end;
  689. if (tz->trips.critical.flags.valid)
  690. seq_printf(seq, "critical (S5): %ld C\n",
  691. KELVIN_TO_CELSIUS(tz->trips.critical.temperature));
  692. if (tz->trips.hot.flags.valid)
  693. seq_printf(seq, "hot (S4): %ld C\n",
  694. KELVIN_TO_CELSIUS(tz->trips.hot.temperature));
  695. if (tz->trips.passive.flags.valid) {
  696. seq_printf(seq,
  697. "passive: %ld C: tc1=%lu tc2=%lu tsp=%lu devices=",
  698. KELVIN_TO_CELSIUS(tz->trips.passive.temperature),
  699. tz->trips.passive.tc1, tz->trips.passive.tc2,
  700. tz->trips.passive.tsp);
  701. for (j = 0; j < tz->trips.passive.devices.count; j++) {
  702. status = acpi_bus_get_device(tz->trips.passive.devices.
  703. handles[j], &device);
  704. seq_printf(seq, "%4.4s ", status ? "" :
  705. acpi_device_bid(device));
  706. }
  707. seq_puts(seq, "\n");
  708. }
  709. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  710. if (!(tz->trips.active[i].flags.valid))
  711. break;
  712. seq_printf(seq, "active[%d]: %ld C: devices=",
  713. i,
  714. KELVIN_TO_CELSIUS(tz->trips.active[i].temperature));
  715. for (j = 0; j < tz->trips.active[i].devices.count; j++){
  716. status = acpi_bus_get_device(tz->trips.active[i].
  717. devices.handles[j],
  718. &device);
  719. seq_printf(seq, "%4.4s ", status ? "" :
  720. acpi_device_bid(device));
  721. }
  722. seq_puts(seq, "\n");
  723. }
  724. end:
  725. return 0;
  726. }
  727. static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file)
  728. {
  729. return single_open(file, acpi_thermal_trip_seq_show, PDE(inode)->data);
  730. }
  731. static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
  732. {
  733. struct acpi_thermal *tz = seq->private;
  734. if (!tz)
  735. goto end;
  736. if (!tz->flags.cooling_mode)
  737. seq_puts(seq, "<setting not supported>\n");
  738. else
  739. seq_puts(seq, "0 - Active; 1 - Passive\n");
  740. end:
  741. return 0;
  742. }
  743. static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file)
  744. {
  745. return single_open(file, acpi_thermal_cooling_seq_show,
  746. PDE(inode)->data);
  747. }
  748. static ssize_t
  749. acpi_thermal_write_cooling_mode(struct file *file,
  750. const char __user * buffer,
  751. size_t count, loff_t * ppos)
  752. {
  753. struct seq_file *m = file->private_data;
  754. struct acpi_thermal *tz = m->private;
  755. int result = 0;
  756. char mode_string[12] = { '\0' };
  757. if (!tz || (count > sizeof(mode_string) - 1))
  758. return -EINVAL;
  759. if (!tz->flags.cooling_mode)
  760. return -ENODEV;
  761. if (copy_from_user(mode_string, buffer, count))
  762. return -EFAULT;
  763. mode_string[count] = '\0';
  764. result = acpi_thermal_set_cooling_mode(tz,
  765. simple_strtoul(mode_string, NULL,
  766. 0));
  767. if (result)
  768. return result;
  769. acpi_thermal_check(tz);
  770. return count;
  771. }
  772. static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
  773. {
  774. struct acpi_thermal *tz = seq->private;
  775. if (!tz)
  776. goto end;
  777. if (!tz->polling_frequency) {
  778. seq_puts(seq, "<polling disabled>\n");
  779. goto end;
  780. }
  781. seq_printf(seq, "polling frequency: %lu seconds\n",
  782. (tz->polling_frequency / 10));
  783. end:
  784. return 0;
  785. }
  786. static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file)
  787. {
  788. return single_open(file, acpi_thermal_polling_seq_show,
  789. PDE(inode)->data);
  790. }
  791. static ssize_t
  792. acpi_thermal_write_polling(struct file *file,
  793. const char __user * buffer,
  794. size_t count, loff_t * ppos)
  795. {
  796. struct seq_file *m = file->private_data;
  797. struct acpi_thermal *tz = m->private;
  798. int result = 0;
  799. char polling_string[12] = { '\0' };
  800. int seconds = 0;
  801. if (!tz || (count > sizeof(polling_string) - 1))
  802. return -EINVAL;
  803. if (copy_from_user(polling_string, buffer, count))
  804. return -EFAULT;
  805. polling_string[count] = '\0';
  806. seconds = simple_strtoul(polling_string, NULL, 0);
  807. result = acpi_thermal_set_polling(tz, seconds);
  808. if (result)
  809. return result;
  810. acpi_thermal_check(tz);
  811. return count;
  812. }
  813. static int acpi_thermal_add_fs(struct acpi_device *device)
  814. {
  815. struct proc_dir_entry *entry = NULL;
  816. if (!acpi_device_dir(device)) {
  817. acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
  818. acpi_thermal_dir);
  819. if (!acpi_device_dir(device))
  820. return -ENODEV;
  821. acpi_device_dir(device)->owner = THIS_MODULE;
  822. }
  823. /* 'state' [R] */
  824. entry = create_proc_entry(ACPI_THERMAL_FILE_STATE,
  825. S_IRUGO, acpi_device_dir(device));
  826. if (!entry)
  827. return -ENODEV;
  828. else {
  829. entry->proc_fops = &acpi_thermal_state_fops;
  830. entry->data = acpi_driver_data(device);
  831. entry->owner = THIS_MODULE;
  832. }
  833. /* 'temperature' [R] */
  834. entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE,
  835. S_IRUGO, acpi_device_dir(device));
  836. if (!entry)
  837. return -ENODEV;
  838. else {
  839. entry->proc_fops = &acpi_thermal_temp_fops;
  840. entry->data = acpi_driver_data(device);
  841. entry->owner = THIS_MODULE;
  842. }
  843. /* 'trip_points' [R/W] */
  844. entry = create_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS,
  845. S_IFREG | S_IRUGO | S_IWUSR,
  846. acpi_device_dir(device));
  847. if (!entry)
  848. return -ENODEV;
  849. else {
  850. entry->proc_fops = &acpi_thermal_trip_fops;
  851. entry->data = acpi_driver_data(device);
  852. entry->owner = THIS_MODULE;
  853. }
  854. /* 'cooling_mode' [R/W] */
  855. entry = create_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE,
  856. S_IFREG | S_IRUGO | S_IWUSR,
  857. acpi_device_dir(device));
  858. if (!entry)
  859. return -ENODEV;
  860. else {
  861. entry->proc_fops = &acpi_thermal_cooling_fops;
  862. entry->data = acpi_driver_data(device);
  863. entry->owner = THIS_MODULE;
  864. }
  865. /* 'polling_frequency' [R/W] */
  866. entry = create_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ,
  867. S_IFREG | S_IRUGO | S_IWUSR,
  868. acpi_device_dir(device));
  869. if (!entry)
  870. return -ENODEV;
  871. else {
  872. entry->proc_fops = &acpi_thermal_polling_fops;
  873. entry->data = acpi_driver_data(device);
  874. entry->owner = THIS_MODULE;
  875. }
  876. return 0;
  877. }
  878. static int acpi_thermal_remove_fs(struct acpi_device *device)
  879. {
  880. if (acpi_device_dir(device)) {
  881. remove_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ,
  882. acpi_device_dir(device));
  883. remove_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE,
  884. acpi_device_dir(device));
  885. remove_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS,
  886. acpi_device_dir(device));
  887. remove_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE,
  888. acpi_device_dir(device));
  889. remove_proc_entry(ACPI_THERMAL_FILE_STATE,
  890. acpi_device_dir(device));
  891. remove_proc_entry(acpi_device_bid(device), acpi_thermal_dir);
  892. acpi_device_dir(device) = NULL;
  893. }
  894. return 0;
  895. }
  896. /* --------------------------------------------------------------------------
  897. Driver Interface
  898. -------------------------------------------------------------------------- */
  899. static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
  900. {
  901. struct acpi_thermal *tz = data;
  902. struct acpi_device *device = NULL;
  903. if (!tz)
  904. return;
  905. device = tz->device;
  906. switch (event) {
  907. case ACPI_THERMAL_NOTIFY_TEMPERATURE:
  908. acpi_thermal_check(tz);
  909. break;
  910. case ACPI_THERMAL_NOTIFY_THRESHOLDS:
  911. acpi_thermal_get_trip_points(tz);
  912. acpi_thermal_check(tz);
  913. acpi_bus_generate_event(device, event, 0);
  914. break;
  915. case ACPI_THERMAL_NOTIFY_DEVICES:
  916. if (tz->flags.devices)
  917. acpi_thermal_get_devices(tz);
  918. acpi_bus_generate_event(device, event, 0);
  919. break;
  920. default:
  921. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  922. "Unsupported event [0x%x]\n", event));
  923. break;
  924. }
  925. return;
  926. }
  927. static int acpi_thermal_get_info(struct acpi_thermal *tz)
  928. {
  929. int result = 0;
  930. if (!tz)
  931. return -EINVAL;
  932. /* Get temperature [_TMP] (required) */
  933. result = acpi_thermal_get_temperature(tz);
  934. if (result)
  935. return result;
  936. /* Get trip points [_CRT, _PSV, etc.] (required) */
  937. result = acpi_thermal_get_trip_points(tz);
  938. if (result)
  939. return result;
  940. /* Set the cooling mode [_SCP] to active cooling (default) */
  941. result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE);
  942. if (!result)
  943. tz->flags.cooling_mode = 1;
  944. /* Get default polling frequency [_TZP] (optional) */
  945. if (tzp)
  946. tz->polling_frequency = tzp;
  947. else
  948. acpi_thermal_get_polling_frequency(tz);
  949. /* Get devices in this thermal zone [_TZD] (optional) */
  950. result = acpi_thermal_get_devices(tz);
  951. if (!result)
  952. tz->flags.devices = 1;
  953. return 0;
  954. }
  955. static int acpi_thermal_add(struct acpi_device *device)
  956. {
  957. int result = 0;
  958. acpi_status status = AE_OK;
  959. struct acpi_thermal *tz = NULL;
  960. if (!device)
  961. return -EINVAL;
  962. tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
  963. if (!tz)
  964. return -ENOMEM;
  965. tz->device = device;
  966. strcpy(tz->name, device->pnp.bus_id);
  967. strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME);
  968. strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS);
  969. acpi_driver_data(device) = tz;
  970. result = acpi_thermal_get_info(tz);
  971. if (result)
  972. goto end;
  973. result = acpi_thermal_add_fs(device);
  974. if (result)
  975. goto end;
  976. init_timer(&tz->timer);
  977. acpi_thermal_check(tz);
  978. status = acpi_install_notify_handler(device->handle,
  979. ACPI_DEVICE_NOTIFY,
  980. acpi_thermal_notify, tz);
  981. if (ACPI_FAILURE(status)) {
  982. result = -ENODEV;
  983. goto end;
  984. }
  985. printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n",
  986. acpi_device_name(device), acpi_device_bid(device),
  987. KELVIN_TO_CELSIUS(tz->temperature));
  988. end:
  989. if (result) {
  990. acpi_thermal_remove_fs(device);
  991. kfree(tz);
  992. }
  993. return result;
  994. }
  995. static int acpi_thermal_remove(struct acpi_device *device, int type)
  996. {
  997. acpi_status status = AE_OK;
  998. struct acpi_thermal *tz = NULL;
  999. if (!device || !acpi_driver_data(device))
  1000. return -EINVAL;
  1001. tz = acpi_driver_data(device);
  1002. /* avoid timer adding new defer task */
  1003. tz->zombie = 1;
  1004. /* wait for running timer (on other CPUs) finish */
  1005. del_timer_sync(&(tz->timer));
  1006. /* synchronize deferred task */
  1007. acpi_os_wait_events_complete(NULL);
  1008. /* deferred task may reinsert timer */
  1009. del_timer_sync(&(tz->timer));
  1010. status = acpi_remove_notify_handler(device->handle,
  1011. ACPI_DEVICE_NOTIFY,
  1012. acpi_thermal_notify);
  1013. /* Terminate policy */
  1014. if (tz->trips.passive.flags.valid && tz->trips.passive.flags.enabled) {
  1015. tz->trips.passive.flags.enabled = 0;
  1016. acpi_thermal_passive(tz);
  1017. }
  1018. if (tz->trips.active[0].flags.valid
  1019. && tz->trips.active[0].flags.enabled) {
  1020. tz->trips.active[0].flags.enabled = 0;
  1021. acpi_thermal_active(tz);
  1022. }
  1023. acpi_thermal_remove_fs(device);
  1024. kfree(tz);
  1025. return 0;
  1026. }
  1027. static int acpi_thermal_resume(struct acpi_device *device)
  1028. {
  1029. struct acpi_thermal *tz = NULL;
  1030. int i, j, power_state, result;
  1031. if (!device || !acpi_driver_data(device))
  1032. return -EINVAL;
  1033. tz = acpi_driver_data(device);
  1034. for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
  1035. if (!(&tz->trips.active[i]))
  1036. break;
  1037. if (!tz->trips.active[i].flags.valid)
  1038. break;
  1039. tz->trips.active[i].flags.enabled = 1;
  1040. for (j = 0; j < tz->trips.active[i].devices.count; j++) {
  1041. result = acpi_bus_get_power(tz->trips.active[i].devices.
  1042. handles[j], &power_state);
  1043. if (result || (power_state != ACPI_STATE_D0)) {
  1044. tz->trips.active[i].flags.enabled = 0;
  1045. break;
  1046. }
  1047. }
  1048. tz->state.active |= tz->trips.active[i].flags.enabled;
  1049. }
  1050. acpi_thermal_check(tz);
  1051. return AE_OK;
  1052. }
  1053. static int __init acpi_thermal_init(void)
  1054. {
  1055. int result = 0;
  1056. acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir);
  1057. if (!acpi_thermal_dir)
  1058. return -ENODEV;
  1059. acpi_thermal_dir->owner = THIS_MODULE;
  1060. result = acpi_bus_register_driver(&acpi_thermal_driver);
  1061. if (result < 0) {
  1062. remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
  1063. return -ENODEV;
  1064. }
  1065. return 0;
  1066. }
  1067. static void __exit acpi_thermal_exit(void)
  1068. {
  1069. acpi_bus_unregister_driver(&acpi_thermal_driver);
  1070. remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
  1071. return;
  1072. }
  1073. module_init(acpi_thermal_init);
  1074. module_exit(acpi_thermal_exit);