nouveau_pm.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156
  1. /*
  2. * Copyright 2010 Red Hat Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: Ben Skeggs
  23. */
  24. #ifdef CONFIG_ACPI
  25. #include <linux/acpi.h>
  26. #endif
  27. #include <linux/power_supply.h>
  28. #include <linux/hwmon.h>
  29. #include <linux/hwmon-sysfs.h>
  30. #include <drm/drmP.h>
  31. #include "nouveau_drm.h"
  32. #include "nouveau_pm.h"
  33. #include <subdev/gpio.h>
  34. #include <subdev/timer.h>
  35. #include <subdev/therm.h>
  36. MODULE_PARM_DESC(perflvl, "Performance level (default: boot)");
  37. static char *nouveau_perflvl;
  38. module_param_named(perflvl, nouveau_perflvl, charp, 0400);
  39. MODULE_PARM_DESC(perflvl_wr, "Allow perflvl changes (warning: dangerous!)");
  40. static int nouveau_perflvl_wr;
  41. module_param_named(perflvl_wr, nouveau_perflvl_wr, int, 0400);
  42. static int
  43. nouveau_pm_perflvl_aux(struct drm_device *dev, struct nouveau_pm_level *perflvl,
  44. struct nouveau_pm_level *a, struct nouveau_pm_level *b)
  45. {
  46. struct nouveau_drm *drm = nouveau_drm(dev);
  47. struct nouveau_pm *pm = nouveau_pm(dev);
  48. struct nouveau_therm *therm = nouveau_therm(drm->device);
  49. int ret;
  50. /*XXX: not on all boards, we should control based on temperature
  51. * on recent boards.. or maybe on some other factor we don't
  52. * know about?
  53. */
  54. if (therm && therm->fan_set &&
  55. a->fanspeed && b->fanspeed && b->fanspeed > a->fanspeed) {
  56. ret = therm->fan_set(therm, perflvl->fanspeed);
  57. if (ret && ret != -ENODEV) {
  58. NV_ERROR(drm, "fanspeed set failed: %d\n", ret);
  59. }
  60. }
  61. if (pm->voltage.supported && pm->voltage_set) {
  62. if (perflvl->volt_min && b->volt_min > a->volt_min) {
  63. ret = pm->voltage_set(dev, perflvl->volt_min);
  64. if (ret) {
  65. NV_ERROR(drm, "voltage set failed: %d\n", ret);
  66. return ret;
  67. }
  68. }
  69. }
  70. return 0;
  71. }
  72. static int
  73. nouveau_pm_perflvl_set(struct drm_device *dev, struct nouveau_pm_level *perflvl)
  74. {
  75. struct nouveau_pm *pm = nouveau_pm(dev);
  76. void *state;
  77. int ret;
  78. if (perflvl == pm->cur)
  79. return 0;
  80. ret = nouveau_pm_perflvl_aux(dev, perflvl, pm->cur, perflvl);
  81. if (ret)
  82. return ret;
  83. state = pm->clocks_pre(dev, perflvl);
  84. if (IS_ERR(state)) {
  85. ret = PTR_ERR(state);
  86. goto error;
  87. }
  88. ret = pm->clocks_set(dev, state);
  89. if (ret)
  90. goto error;
  91. ret = nouveau_pm_perflvl_aux(dev, perflvl, perflvl, pm->cur);
  92. if (ret)
  93. return ret;
  94. pm->cur = perflvl;
  95. return 0;
  96. error:
  97. /* restore the fan speed and voltage before leaving */
  98. nouveau_pm_perflvl_aux(dev, perflvl, perflvl, pm->cur);
  99. return ret;
  100. }
  101. void
  102. nouveau_pm_trigger(struct drm_device *dev)
  103. {
  104. struct nouveau_drm *drm = nouveau_drm(dev);
  105. struct nouveau_timer *ptimer = nouveau_timer(drm->device);
  106. struct nouveau_pm *pm = nouveau_pm(dev);
  107. struct nouveau_pm_profile *profile = NULL;
  108. struct nouveau_pm_level *perflvl = NULL;
  109. int ret;
  110. /* select power profile based on current power source */
  111. if (power_supply_is_system_supplied())
  112. profile = pm->profile_ac;
  113. else
  114. profile = pm->profile_dc;
  115. if (profile != pm->profile) {
  116. pm->profile->func->fini(pm->profile);
  117. pm->profile = profile;
  118. pm->profile->func->init(pm->profile);
  119. }
  120. /* select performance level based on profile */
  121. perflvl = profile->func->select(profile);
  122. /* change perflvl, if necessary */
  123. if (perflvl != pm->cur) {
  124. u64 time0 = ptimer->read(ptimer);
  125. NV_INFO(drm, "setting performance level: %d", perflvl->id);
  126. ret = nouveau_pm_perflvl_set(dev, perflvl);
  127. if (ret)
  128. NV_INFO(drm, "> reclocking failed: %d\n\n", ret);
  129. NV_INFO(drm, "> reclocking took %lluns\n\n",
  130. ptimer->read(ptimer) - time0);
  131. }
  132. }
  133. static struct nouveau_pm_profile *
  134. profile_find(struct drm_device *dev, const char *string)
  135. {
  136. struct nouveau_pm *pm = nouveau_pm(dev);
  137. struct nouveau_pm_profile *profile;
  138. list_for_each_entry(profile, &pm->profiles, head) {
  139. if (!strncmp(profile->name, string, sizeof(profile->name)))
  140. return profile;
  141. }
  142. return NULL;
  143. }
  144. static int
  145. nouveau_pm_profile_set(struct drm_device *dev, const char *profile)
  146. {
  147. struct nouveau_pm *pm = nouveau_pm(dev);
  148. struct nouveau_pm_profile *ac = NULL, *dc = NULL;
  149. char string[16], *cur = string, *ptr;
  150. /* safety precaution, for now */
  151. if (nouveau_perflvl_wr != 7777)
  152. return -EPERM;
  153. strncpy(string, profile, sizeof(string));
  154. string[sizeof(string) - 1] = 0;
  155. if ((ptr = strchr(string, '\n')))
  156. *ptr = '\0';
  157. ptr = strsep(&cur, ",");
  158. if (ptr)
  159. ac = profile_find(dev, ptr);
  160. ptr = strsep(&cur, ",");
  161. if (ptr)
  162. dc = profile_find(dev, ptr);
  163. else
  164. dc = ac;
  165. if (ac == NULL || dc == NULL)
  166. return -EINVAL;
  167. pm->profile_ac = ac;
  168. pm->profile_dc = dc;
  169. nouveau_pm_trigger(dev);
  170. return 0;
  171. }
  172. static void
  173. nouveau_pm_static_dummy(struct nouveau_pm_profile *profile)
  174. {
  175. }
  176. static struct nouveau_pm_level *
  177. nouveau_pm_static_select(struct nouveau_pm_profile *profile)
  178. {
  179. return container_of(profile, struct nouveau_pm_level, profile);
  180. }
  181. const struct nouveau_pm_profile_func nouveau_pm_static_profile_func = {
  182. .destroy = nouveau_pm_static_dummy,
  183. .init = nouveau_pm_static_dummy,
  184. .fini = nouveau_pm_static_dummy,
  185. .select = nouveau_pm_static_select,
  186. };
  187. static int
  188. nouveau_pm_perflvl_get(struct drm_device *dev, struct nouveau_pm_level *perflvl)
  189. {
  190. struct nouveau_drm *drm = nouveau_drm(dev);
  191. struct nouveau_pm *pm = nouveau_pm(dev);
  192. struct nouveau_therm *therm = nouveau_therm(drm->device);
  193. int ret;
  194. memset(perflvl, 0, sizeof(*perflvl));
  195. if (pm->clocks_get) {
  196. ret = pm->clocks_get(dev, perflvl);
  197. if (ret)
  198. return ret;
  199. }
  200. if (pm->voltage.supported && pm->voltage_get) {
  201. ret = pm->voltage_get(dev);
  202. if (ret > 0) {
  203. perflvl->volt_min = ret;
  204. perflvl->volt_max = ret;
  205. }
  206. }
  207. if (therm && therm->fan_get) {
  208. ret = therm->fan_get(therm);
  209. if (ret >= 0)
  210. perflvl->fanspeed = ret;
  211. }
  212. nouveau_mem_timing_read(dev, &perflvl->timing);
  213. return 0;
  214. }
  215. static void
  216. nouveau_pm_perflvl_info(struct nouveau_pm_level *perflvl, char *ptr, int len)
  217. {
  218. char c[16], s[16], v[32], f[16], m[16];
  219. c[0] = '\0';
  220. if (perflvl->core)
  221. snprintf(c, sizeof(c), " core %dMHz", perflvl->core / 1000);
  222. s[0] = '\0';
  223. if (perflvl->shader)
  224. snprintf(s, sizeof(s), " shader %dMHz", perflvl->shader / 1000);
  225. m[0] = '\0';
  226. if (perflvl->memory)
  227. snprintf(m, sizeof(m), " memory %dMHz", perflvl->memory / 1000);
  228. v[0] = '\0';
  229. if (perflvl->volt_min && perflvl->volt_min != perflvl->volt_max) {
  230. snprintf(v, sizeof(v), " voltage %dmV-%dmV",
  231. perflvl->volt_min / 1000, perflvl->volt_max / 1000);
  232. } else
  233. if (perflvl->volt_min) {
  234. snprintf(v, sizeof(v), " voltage %dmV",
  235. perflvl->volt_min / 1000);
  236. }
  237. f[0] = '\0';
  238. if (perflvl->fanspeed)
  239. snprintf(f, sizeof(f), " fanspeed %d%%", perflvl->fanspeed);
  240. snprintf(ptr, len, "%s%s%s%s%s\n", c, s, m, v, f);
  241. }
  242. static ssize_t
  243. nouveau_pm_get_perflvl_info(struct device *d,
  244. struct device_attribute *a, char *buf)
  245. {
  246. struct nouveau_pm_level *perflvl =
  247. container_of(a, struct nouveau_pm_level, dev_attr);
  248. char *ptr = buf;
  249. int len = PAGE_SIZE;
  250. snprintf(ptr, len, "%d:", perflvl->id);
  251. ptr += strlen(buf);
  252. len -= strlen(buf);
  253. nouveau_pm_perflvl_info(perflvl, ptr, len);
  254. return strlen(buf);
  255. }
  256. static ssize_t
  257. nouveau_pm_get_perflvl(struct device *d, struct device_attribute *a, char *buf)
  258. {
  259. struct drm_device *dev = pci_get_drvdata(to_pci_dev(d));
  260. struct nouveau_pm *pm = nouveau_pm(dev);
  261. struct nouveau_pm_level cur;
  262. int len = PAGE_SIZE, ret;
  263. char *ptr = buf;
  264. snprintf(ptr, len, "profile: %s, %s\nc:",
  265. pm->profile_ac->name, pm->profile_dc->name);
  266. ptr += strlen(buf);
  267. len -= strlen(buf);
  268. ret = nouveau_pm_perflvl_get(dev, &cur);
  269. if (ret == 0)
  270. nouveau_pm_perflvl_info(&cur, ptr, len);
  271. return strlen(buf);
  272. }
  273. static ssize_t
  274. nouveau_pm_set_perflvl(struct device *d, struct device_attribute *a,
  275. const char *buf, size_t count)
  276. {
  277. struct drm_device *dev = pci_get_drvdata(to_pci_dev(d));
  278. int ret;
  279. ret = nouveau_pm_profile_set(dev, buf);
  280. if (ret)
  281. return ret;
  282. return strlen(buf);
  283. }
  284. static DEVICE_ATTR(performance_level, S_IRUGO | S_IWUSR,
  285. nouveau_pm_get_perflvl, nouveau_pm_set_perflvl);
  286. static int
  287. nouveau_sysfs_init(struct drm_device *dev)
  288. {
  289. struct nouveau_drm *drm = nouveau_drm(dev);
  290. struct nouveau_pm *pm = nouveau_pm(dev);
  291. struct device *d = &dev->pdev->dev;
  292. int ret, i;
  293. ret = device_create_file(d, &dev_attr_performance_level);
  294. if (ret)
  295. return ret;
  296. for (i = 0; i < pm->nr_perflvl; i++) {
  297. struct nouveau_pm_level *perflvl = &pm->perflvl[i];
  298. perflvl->dev_attr.attr.name = perflvl->name;
  299. perflvl->dev_attr.attr.mode = S_IRUGO;
  300. perflvl->dev_attr.show = nouveau_pm_get_perflvl_info;
  301. perflvl->dev_attr.store = NULL;
  302. sysfs_attr_init(&perflvl->dev_attr.attr);
  303. ret = device_create_file(d, &perflvl->dev_attr);
  304. if (ret) {
  305. NV_ERROR(drm, "failed pervlvl %d sysfs: %d\n",
  306. perflvl->id, i);
  307. perflvl->dev_attr.attr.name = NULL;
  308. nouveau_pm_fini(dev);
  309. return ret;
  310. }
  311. }
  312. return 0;
  313. }
  314. static void
  315. nouveau_sysfs_fini(struct drm_device *dev)
  316. {
  317. struct nouveau_pm *pm = nouveau_pm(dev);
  318. struct device *d = &dev->pdev->dev;
  319. int i;
  320. device_remove_file(d, &dev_attr_performance_level);
  321. for (i = 0; i < pm->nr_perflvl; i++) {
  322. struct nouveau_pm_level *pl = &pm->perflvl[i];
  323. if (!pl->dev_attr.attr.name)
  324. break;
  325. device_remove_file(d, &pl->dev_attr);
  326. }
  327. }
  328. #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
  329. static ssize_t
  330. nouveau_hwmon_show_temp(struct device *d, struct device_attribute *a, char *buf)
  331. {
  332. struct drm_device *dev = dev_get_drvdata(d);
  333. struct nouveau_drm *drm = nouveau_drm(dev);
  334. struct nouveau_therm *therm = nouveau_therm(drm->device);
  335. return snprintf(buf, PAGE_SIZE, "%d\n", therm->temp_get(therm) * 1000);
  336. }
  337. static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, nouveau_hwmon_show_temp,
  338. NULL, 0);
  339. static ssize_t
  340. nouveau_hwmon_show_temp1_auto_point1_pwm(struct device *d,
  341. struct device_attribute *a, char *buf)
  342. {
  343. return snprintf(buf, PAGE_SIZE, "%d\n", 100);
  344. }
  345. static SENSOR_DEVICE_ATTR(temp1_auto_point1_pwm, S_IRUGO,
  346. nouveau_hwmon_show_temp1_auto_point1_pwm, NULL, 0);
  347. static ssize_t
  348. nouveau_hwmon_temp1_auto_point1_temp(struct device *d,
  349. struct device_attribute *a, char *buf)
  350. {
  351. struct drm_device *dev = dev_get_drvdata(d);
  352. struct nouveau_drm *drm = nouveau_drm(dev);
  353. struct nouveau_therm *therm = nouveau_therm(drm->device);
  354. return snprintf(buf, PAGE_SIZE, "%d\n",
  355. therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_FAN_BOOST) * 1000);
  356. }
  357. static ssize_t
  358. nouveau_hwmon_set_temp1_auto_point1_temp(struct device *d,
  359. struct device_attribute *a,
  360. const char *buf, size_t count)
  361. {
  362. struct drm_device *dev = dev_get_drvdata(d);
  363. struct nouveau_drm *drm = nouveau_drm(dev);
  364. struct nouveau_therm *therm = nouveau_therm(drm->device);
  365. long value;
  366. if (kstrtol(buf, 10, &value) == -EINVAL)
  367. return count;
  368. therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_FAN_BOOST,
  369. value / 1000);
  370. return count;
  371. }
  372. static SENSOR_DEVICE_ATTR(temp1_auto_point1_temp, S_IRUGO | S_IWUSR,
  373. nouveau_hwmon_temp1_auto_point1_temp,
  374. nouveau_hwmon_set_temp1_auto_point1_temp, 0);
  375. static ssize_t
  376. nouveau_hwmon_temp1_auto_point1_temp_hyst(struct device *d,
  377. struct device_attribute *a, char *buf)
  378. {
  379. struct drm_device *dev = dev_get_drvdata(d);
  380. struct nouveau_drm *drm = nouveau_drm(dev);
  381. struct nouveau_therm *therm = nouveau_therm(drm->device);
  382. return snprintf(buf, PAGE_SIZE, "%d\n",
  383. therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_FAN_BOOST_HYST) * 1000);
  384. }
  385. static ssize_t
  386. nouveau_hwmon_set_temp1_auto_point1_temp_hyst(struct device *d,
  387. struct device_attribute *a,
  388. const char *buf, size_t count)
  389. {
  390. struct drm_device *dev = dev_get_drvdata(d);
  391. struct nouveau_drm *drm = nouveau_drm(dev);
  392. struct nouveau_therm *therm = nouveau_therm(drm->device);
  393. long value;
  394. if (kstrtol(buf, 10, &value) == -EINVAL)
  395. return count;
  396. therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_FAN_BOOST_HYST,
  397. value / 1000);
  398. return count;
  399. }
  400. static SENSOR_DEVICE_ATTR(temp1_auto_point1_temp_hyst, S_IRUGO | S_IWUSR,
  401. nouveau_hwmon_temp1_auto_point1_temp_hyst,
  402. nouveau_hwmon_set_temp1_auto_point1_temp_hyst, 0);
  403. static ssize_t
  404. nouveau_hwmon_max_temp(struct device *d, struct device_attribute *a, char *buf)
  405. {
  406. struct drm_device *dev = dev_get_drvdata(d);
  407. struct nouveau_drm *drm = nouveau_drm(dev);
  408. struct nouveau_therm *therm = nouveau_therm(drm->device);
  409. return snprintf(buf, PAGE_SIZE, "%d\n",
  410. therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_DOWN_CLK) * 1000);
  411. }
  412. static ssize_t
  413. nouveau_hwmon_set_max_temp(struct device *d, struct device_attribute *a,
  414. const char *buf, size_t count)
  415. {
  416. struct drm_device *dev = dev_get_drvdata(d);
  417. struct nouveau_drm *drm = nouveau_drm(dev);
  418. struct nouveau_therm *therm = nouveau_therm(drm->device);
  419. long value;
  420. if (kstrtol(buf, 10, &value) == -EINVAL)
  421. return count;
  422. therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_DOWN_CLK, value / 1000);
  423. return count;
  424. }
  425. static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, nouveau_hwmon_max_temp,
  426. nouveau_hwmon_set_max_temp,
  427. 0);
  428. static ssize_t
  429. nouveau_hwmon_max_temp_hyst(struct device *d, struct device_attribute *a,
  430. char *buf)
  431. {
  432. struct drm_device *dev = dev_get_drvdata(d);
  433. struct nouveau_drm *drm = nouveau_drm(dev);
  434. struct nouveau_therm *therm = nouveau_therm(drm->device);
  435. return snprintf(buf, PAGE_SIZE, "%d\n",
  436. therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_DOWN_CLK_HYST) * 1000);
  437. }
  438. static ssize_t
  439. nouveau_hwmon_set_max_temp_hyst(struct device *d, struct device_attribute *a,
  440. const char *buf, size_t count)
  441. {
  442. struct drm_device *dev = dev_get_drvdata(d);
  443. struct nouveau_drm *drm = nouveau_drm(dev);
  444. struct nouveau_therm *therm = nouveau_therm(drm->device);
  445. long value;
  446. if (kstrtol(buf, 10, &value) == -EINVAL)
  447. return count;
  448. therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_DOWN_CLK_HYST,
  449. value / 1000);
  450. return count;
  451. }
  452. static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR,
  453. nouveau_hwmon_max_temp_hyst,
  454. nouveau_hwmon_set_max_temp_hyst, 0);
  455. static ssize_t
  456. nouveau_hwmon_critical_temp(struct device *d, struct device_attribute *a,
  457. char *buf)
  458. {
  459. struct drm_device *dev = dev_get_drvdata(d);
  460. struct nouveau_drm *drm = nouveau_drm(dev);
  461. struct nouveau_therm *therm = nouveau_therm(drm->device);
  462. return snprintf(buf, PAGE_SIZE, "%d\n",
  463. therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_CRITICAL) * 1000);
  464. }
  465. static ssize_t
  466. nouveau_hwmon_set_critical_temp(struct device *d, struct device_attribute *a,
  467. const char *buf,
  468. size_t count)
  469. {
  470. struct drm_device *dev = dev_get_drvdata(d);
  471. struct nouveau_drm *drm = nouveau_drm(dev);
  472. struct nouveau_therm *therm = nouveau_therm(drm->device);
  473. long value;
  474. if (kstrtol(buf, 10, &value) == -EINVAL)
  475. return count;
  476. therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_CRITICAL, value / 1000);
  477. return count;
  478. }
  479. static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO | S_IWUSR,
  480. nouveau_hwmon_critical_temp,
  481. nouveau_hwmon_set_critical_temp,
  482. 0);
  483. static ssize_t
  484. nouveau_hwmon_critical_temp_hyst(struct device *d, struct device_attribute *a,
  485. char *buf)
  486. {
  487. struct drm_device *dev = dev_get_drvdata(d);
  488. struct nouveau_drm *drm = nouveau_drm(dev);
  489. struct nouveau_therm *therm = nouveau_therm(drm->device);
  490. return snprintf(buf, PAGE_SIZE, "%d\n",
  491. therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_CRITICAL_HYST) * 1000);
  492. }
  493. static ssize_t
  494. nouveau_hwmon_set_critical_temp_hyst(struct device *d,
  495. struct device_attribute *a,
  496. const char *buf,
  497. size_t count)
  498. {
  499. struct drm_device *dev = dev_get_drvdata(d);
  500. struct nouveau_drm *drm = nouveau_drm(dev);
  501. struct nouveau_therm *therm = nouveau_therm(drm->device);
  502. long value;
  503. if (kstrtol(buf, 10, &value) == -EINVAL)
  504. return count;
  505. therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_CRITICAL_HYST,
  506. value / 1000);
  507. return count;
  508. }
  509. static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO | S_IWUSR,
  510. nouveau_hwmon_critical_temp_hyst,
  511. nouveau_hwmon_set_critical_temp_hyst, 0);
  512. static ssize_t
  513. nouveau_hwmon_emergency_temp(struct device *d, struct device_attribute *a,
  514. char *buf)
  515. {
  516. struct drm_device *dev = dev_get_drvdata(d);
  517. struct nouveau_drm *drm = nouveau_drm(dev);
  518. struct nouveau_therm *therm = nouveau_therm(drm->device);
  519. return snprintf(buf, PAGE_SIZE, "%d\n",
  520. therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_SHUTDOWN) * 1000);
  521. }
  522. static ssize_t
  523. nouveau_hwmon_set_emergency_temp(struct device *d, struct device_attribute *a,
  524. const char *buf,
  525. size_t count)
  526. {
  527. struct drm_device *dev = dev_get_drvdata(d);
  528. struct nouveau_drm *drm = nouveau_drm(dev);
  529. struct nouveau_therm *therm = nouveau_therm(drm->device);
  530. long value;
  531. if (kstrtol(buf, 10, &value) == -EINVAL)
  532. return count;
  533. therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_SHUTDOWN, value / 1000);
  534. return count;
  535. }
  536. static SENSOR_DEVICE_ATTR(temp1_emergency, S_IRUGO | S_IWUSR,
  537. nouveau_hwmon_emergency_temp,
  538. nouveau_hwmon_set_emergency_temp,
  539. 0);
  540. static ssize_t
  541. nouveau_hwmon_emergency_temp_hyst(struct device *d, struct device_attribute *a,
  542. char *buf)
  543. {
  544. struct drm_device *dev = dev_get_drvdata(d);
  545. struct nouveau_drm *drm = nouveau_drm(dev);
  546. struct nouveau_therm *therm = nouveau_therm(drm->device);
  547. return snprintf(buf, PAGE_SIZE, "%d\n",
  548. therm->attr_get(therm, NOUVEAU_THERM_ATTR_THRS_SHUTDOWN_HYST) * 1000);
  549. }
  550. static ssize_t
  551. nouveau_hwmon_set_emergency_temp_hyst(struct device *d,
  552. struct device_attribute *a,
  553. const char *buf,
  554. size_t count)
  555. {
  556. struct drm_device *dev = dev_get_drvdata(d);
  557. struct nouveau_drm *drm = nouveau_drm(dev);
  558. struct nouveau_therm *therm = nouveau_therm(drm->device);
  559. long value;
  560. if (kstrtol(buf, 10, &value) == -EINVAL)
  561. return count;
  562. therm->attr_set(therm, NOUVEAU_THERM_ATTR_THRS_SHUTDOWN_HYST,
  563. value / 1000);
  564. return count;
  565. }
  566. static SENSOR_DEVICE_ATTR(temp1_emergency_hyst, S_IRUGO | S_IWUSR,
  567. nouveau_hwmon_emergency_temp_hyst,
  568. nouveau_hwmon_set_emergency_temp_hyst,
  569. 0);
  570. static ssize_t nouveau_hwmon_show_name(struct device *dev,
  571. struct device_attribute *attr,
  572. char *buf)
  573. {
  574. return sprintf(buf, "nouveau\n");
  575. }
  576. static SENSOR_DEVICE_ATTR(name, S_IRUGO, nouveau_hwmon_show_name, NULL, 0);
  577. static ssize_t nouveau_hwmon_show_update_rate(struct device *dev,
  578. struct device_attribute *attr,
  579. char *buf)
  580. {
  581. return sprintf(buf, "1000\n");
  582. }
  583. static SENSOR_DEVICE_ATTR(update_rate, S_IRUGO,
  584. nouveau_hwmon_show_update_rate,
  585. NULL, 0);
  586. static ssize_t
  587. nouveau_hwmon_show_fan1_input(struct device *d, struct device_attribute *attr,
  588. char *buf)
  589. {
  590. struct drm_device *dev = dev_get_drvdata(d);
  591. struct nouveau_drm *drm = nouveau_drm(dev);
  592. struct nouveau_therm *therm = nouveau_therm(drm->device);
  593. return snprintf(buf, PAGE_SIZE, "%d\n", therm->fan_sense(therm));
  594. }
  595. static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, nouveau_hwmon_show_fan1_input,
  596. NULL, 0);
  597. static ssize_t
  598. nouveau_hwmon_get_pwm1_enable(struct device *d,
  599. struct device_attribute *a, char *buf)
  600. {
  601. struct drm_device *dev = dev_get_drvdata(d);
  602. struct nouveau_drm *drm = nouveau_drm(dev);
  603. struct nouveau_therm *therm = nouveau_therm(drm->device);
  604. int ret;
  605. ret = therm->attr_get(therm, NOUVEAU_THERM_ATTR_FAN_MODE);
  606. if (ret < 0)
  607. return ret;
  608. return sprintf(buf, "%i\n", ret);
  609. }
  610. static ssize_t
  611. nouveau_hwmon_set_pwm1_enable(struct device *d, struct device_attribute *a,
  612. const char *buf, size_t count)
  613. {
  614. struct drm_device *dev = dev_get_drvdata(d);
  615. struct nouveau_drm *drm = nouveau_drm(dev);
  616. struct nouveau_therm *therm = nouveau_therm(drm->device);
  617. long value;
  618. int ret;
  619. if (strict_strtol(buf, 10, &value) == -EINVAL)
  620. return -EINVAL;
  621. ret = therm->attr_set(therm, NOUVEAU_THERM_ATTR_FAN_MODE, value);
  622. if (ret)
  623. return ret;
  624. else
  625. return count;
  626. }
  627. static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,
  628. nouveau_hwmon_get_pwm1_enable,
  629. nouveau_hwmon_set_pwm1_enable, 0);
  630. static ssize_t
  631. nouveau_hwmon_get_pwm1(struct device *d, struct device_attribute *a, char *buf)
  632. {
  633. struct drm_device *dev = dev_get_drvdata(d);
  634. struct nouveau_drm *drm = nouveau_drm(dev);
  635. struct nouveau_therm *therm = nouveau_therm(drm->device);
  636. int ret;
  637. ret = therm->fan_get(therm);
  638. if (ret < 0)
  639. return ret;
  640. return sprintf(buf, "%i\n", ret);
  641. }
  642. static ssize_t
  643. nouveau_hwmon_set_pwm1(struct device *d, struct device_attribute *a,
  644. const char *buf, size_t count)
  645. {
  646. struct drm_device *dev = dev_get_drvdata(d);
  647. struct nouveau_drm *drm = nouveau_drm(dev);
  648. struct nouveau_therm *therm = nouveau_therm(drm->device);
  649. int ret = -ENODEV;
  650. long value;
  651. if (nouveau_perflvl_wr != 7777)
  652. return -EPERM;
  653. if (kstrtol(buf, 10, &value) == -EINVAL)
  654. return -EINVAL;
  655. ret = therm->fan_set(therm, value);
  656. if (ret)
  657. return ret;
  658. return count;
  659. }
  660. static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR,
  661. nouveau_hwmon_get_pwm1,
  662. nouveau_hwmon_set_pwm1, 0);
  663. static ssize_t
  664. nouveau_hwmon_get_pwm1_min(struct device *d,
  665. struct device_attribute *a, char *buf)
  666. {
  667. struct drm_device *dev = dev_get_drvdata(d);
  668. struct nouveau_drm *drm = nouveau_drm(dev);
  669. struct nouveau_therm *therm = nouveau_therm(drm->device);
  670. int ret;
  671. ret = therm->attr_get(therm, NOUVEAU_THERM_ATTR_FAN_MIN_DUTY);
  672. if (ret < 0)
  673. return ret;
  674. return sprintf(buf, "%i\n", ret);
  675. }
  676. static ssize_t
  677. nouveau_hwmon_set_pwm1_min(struct device *d, struct device_attribute *a,
  678. const char *buf, size_t count)
  679. {
  680. struct drm_device *dev = dev_get_drvdata(d);
  681. struct nouveau_drm *drm = nouveau_drm(dev);
  682. struct nouveau_therm *therm = nouveau_therm(drm->device);
  683. long value;
  684. int ret;
  685. if (kstrtol(buf, 10, &value) == -EINVAL)
  686. return -EINVAL;
  687. ret = therm->attr_set(therm, NOUVEAU_THERM_ATTR_FAN_MIN_DUTY, value);
  688. if (ret < 0)
  689. return ret;
  690. return count;
  691. }
  692. static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO | S_IWUSR,
  693. nouveau_hwmon_get_pwm1_min,
  694. nouveau_hwmon_set_pwm1_min, 0);
  695. static ssize_t
  696. nouveau_hwmon_get_pwm1_max(struct device *d,
  697. struct device_attribute *a, char *buf)
  698. {
  699. struct drm_device *dev = dev_get_drvdata(d);
  700. struct nouveau_drm *drm = nouveau_drm(dev);
  701. struct nouveau_therm *therm = nouveau_therm(drm->device);
  702. int ret;
  703. ret = therm->attr_get(therm, NOUVEAU_THERM_ATTR_FAN_MAX_DUTY);
  704. if (ret < 0)
  705. return ret;
  706. return sprintf(buf, "%i\n", ret);
  707. }
  708. static ssize_t
  709. nouveau_hwmon_set_pwm1_max(struct device *d, struct device_attribute *a,
  710. const char *buf, size_t count)
  711. {
  712. struct drm_device *dev = dev_get_drvdata(d);
  713. struct nouveau_drm *drm = nouveau_drm(dev);
  714. struct nouveau_therm *therm = nouveau_therm(drm->device);
  715. long value;
  716. int ret;
  717. if (kstrtol(buf, 10, &value) == -EINVAL)
  718. return -EINVAL;
  719. ret = therm->attr_set(therm, NOUVEAU_THERM_ATTR_FAN_MAX_DUTY, value);
  720. if (ret < 0)
  721. return ret;
  722. return count;
  723. }
  724. static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO | S_IWUSR,
  725. nouveau_hwmon_get_pwm1_max,
  726. nouveau_hwmon_set_pwm1_max, 0);
  727. static struct attribute *hwmon_attributes[] = {
  728. &sensor_dev_attr_temp1_input.dev_attr.attr,
  729. &sensor_dev_attr_temp1_auto_point1_pwm.dev_attr.attr,
  730. &sensor_dev_attr_temp1_auto_point1_temp.dev_attr.attr,
  731. &sensor_dev_attr_temp1_auto_point1_temp_hyst.dev_attr.attr,
  732. &sensor_dev_attr_temp1_max.dev_attr.attr,
  733. &sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
  734. &sensor_dev_attr_temp1_crit.dev_attr.attr,
  735. &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr,
  736. &sensor_dev_attr_temp1_emergency.dev_attr.attr,
  737. &sensor_dev_attr_temp1_emergency_hyst.dev_attr.attr,
  738. &sensor_dev_attr_name.dev_attr.attr,
  739. &sensor_dev_attr_update_rate.dev_attr.attr,
  740. NULL
  741. };
  742. static struct attribute *hwmon_fan_rpm_attributes[] = {
  743. &sensor_dev_attr_fan1_input.dev_attr.attr,
  744. NULL
  745. };
  746. static struct attribute *hwmon_pwm_fan_attributes[] = {
  747. &sensor_dev_attr_pwm1_enable.dev_attr.attr,
  748. &sensor_dev_attr_pwm1.dev_attr.attr,
  749. &sensor_dev_attr_pwm1_min.dev_attr.attr,
  750. &sensor_dev_attr_pwm1_max.dev_attr.attr,
  751. NULL
  752. };
  753. static const struct attribute_group hwmon_attrgroup = {
  754. .attrs = hwmon_attributes,
  755. };
  756. static const struct attribute_group hwmon_fan_rpm_attrgroup = {
  757. .attrs = hwmon_fan_rpm_attributes,
  758. };
  759. static const struct attribute_group hwmon_pwm_fan_attrgroup = {
  760. .attrs = hwmon_pwm_fan_attributes,
  761. };
  762. #endif
  763. static int
  764. nouveau_hwmon_init(struct drm_device *dev)
  765. {
  766. struct nouveau_pm *pm = nouveau_pm(dev);
  767. #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
  768. struct nouveau_drm *drm = nouveau_drm(dev);
  769. struct nouveau_therm *therm = nouveau_therm(drm->device);
  770. struct device *hwmon_dev;
  771. int ret = 0;
  772. if (!therm || !therm->temp_get || !therm->attr_get || !therm->attr_set)
  773. return -ENODEV;
  774. hwmon_dev = hwmon_device_register(&dev->pdev->dev);
  775. if (IS_ERR(hwmon_dev)) {
  776. ret = PTR_ERR(hwmon_dev);
  777. NV_ERROR(drm, "Unable to register hwmon device: %d\n", ret);
  778. return ret;
  779. }
  780. dev_set_drvdata(hwmon_dev, dev);
  781. /* default sysfs entries */
  782. ret = sysfs_create_group(&hwmon_dev->kobj, &hwmon_attrgroup);
  783. if (ret) {
  784. if (ret)
  785. goto error;
  786. }
  787. /* if the card has a pwm fan */
  788. /*XXX: incorrect, need better detection for this, some boards have
  789. * the gpio entries for pwm fan control even when there's no
  790. * actual fan connected to it... therm table? */
  791. if (therm->fan_get && therm->fan_get(therm) >= 0) {
  792. ret = sysfs_create_group(&hwmon_dev->kobj,
  793. &hwmon_pwm_fan_attrgroup);
  794. if (ret)
  795. goto error;
  796. }
  797. /* if the card can read the fan rpm */
  798. if (therm->fan_sense(therm) >= 0) {
  799. ret = sysfs_create_group(&hwmon_dev->kobj,
  800. &hwmon_fan_rpm_attrgroup);
  801. if (ret)
  802. goto error;
  803. }
  804. pm->hwmon = hwmon_dev;
  805. return 0;
  806. error:
  807. NV_ERROR(drm, "Unable to create some hwmon sysfs files: %d\n", ret);
  808. hwmon_device_unregister(hwmon_dev);
  809. pm->hwmon = NULL;
  810. return ret;
  811. #else
  812. pm->hwmon = NULL;
  813. return 0;
  814. #endif
  815. }
  816. static void
  817. nouveau_hwmon_fini(struct drm_device *dev)
  818. {
  819. #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
  820. struct nouveau_pm *pm = nouveau_pm(dev);
  821. if (pm->hwmon) {
  822. sysfs_remove_group(&pm->hwmon->kobj, &hwmon_attrgroup);
  823. sysfs_remove_group(&pm->hwmon->kobj,
  824. &hwmon_pwm_fan_attrgroup);
  825. sysfs_remove_group(&pm->hwmon->kobj,
  826. &hwmon_fan_rpm_attrgroup);
  827. hwmon_device_unregister(pm->hwmon);
  828. }
  829. #endif
  830. }
  831. #if defined(CONFIG_ACPI) && defined(CONFIG_POWER_SUPPLY)
  832. static int
  833. nouveau_pm_acpi_event(struct notifier_block *nb, unsigned long val, void *data)
  834. {
  835. struct nouveau_pm *pm = container_of(nb, struct nouveau_pm, acpi_nb);
  836. struct nouveau_drm *drm = nouveau_drm(pm->dev);
  837. struct acpi_bus_event *entry = (struct acpi_bus_event *)data;
  838. if (strcmp(entry->device_class, "ac_adapter") == 0) {
  839. bool ac = power_supply_is_system_supplied();
  840. NV_DEBUG(drm, "power supply changed: %s\n", ac ? "AC" : "DC");
  841. nouveau_pm_trigger(pm->dev);
  842. }
  843. return NOTIFY_OK;
  844. }
  845. #endif
  846. int
  847. nouveau_pm_init(struct drm_device *dev)
  848. {
  849. struct nouveau_device *device = nouveau_dev(dev);
  850. struct nouveau_drm *drm = nouveau_drm(dev);
  851. struct nouveau_pm *pm;
  852. char info[256];
  853. int ret, i;
  854. pm = drm->pm = kzalloc(sizeof(*pm), GFP_KERNEL);
  855. if (!pm)
  856. return -ENOMEM;
  857. pm->dev = dev;
  858. if (device->card_type < NV_40) {
  859. pm->clocks_get = nv04_pm_clocks_get;
  860. pm->clocks_pre = nv04_pm_clocks_pre;
  861. pm->clocks_set = nv04_pm_clocks_set;
  862. if (nouveau_gpio(drm->device)) {
  863. pm->voltage_get = nouveau_voltage_gpio_get;
  864. pm->voltage_set = nouveau_voltage_gpio_set;
  865. }
  866. } else
  867. if (device->card_type < NV_50) {
  868. pm->clocks_get = nv40_pm_clocks_get;
  869. pm->clocks_pre = nv40_pm_clocks_pre;
  870. pm->clocks_set = nv40_pm_clocks_set;
  871. pm->voltage_get = nouveau_voltage_gpio_get;
  872. pm->voltage_set = nouveau_voltage_gpio_set;
  873. } else
  874. if (device->card_type < NV_C0) {
  875. if (device->chipset < 0xa3 ||
  876. device->chipset == 0xaa ||
  877. device->chipset == 0xac) {
  878. pm->clocks_get = nv50_pm_clocks_get;
  879. pm->clocks_pre = nv50_pm_clocks_pre;
  880. pm->clocks_set = nv50_pm_clocks_set;
  881. } else {
  882. pm->clocks_get = nva3_pm_clocks_get;
  883. pm->clocks_pre = nva3_pm_clocks_pre;
  884. pm->clocks_set = nva3_pm_clocks_set;
  885. }
  886. pm->voltage_get = nouveau_voltage_gpio_get;
  887. pm->voltage_set = nouveau_voltage_gpio_set;
  888. } else
  889. if (device->card_type < NV_E0) {
  890. pm->clocks_get = nvc0_pm_clocks_get;
  891. pm->clocks_pre = nvc0_pm_clocks_pre;
  892. pm->clocks_set = nvc0_pm_clocks_set;
  893. pm->voltage_get = nouveau_voltage_gpio_get;
  894. pm->voltage_set = nouveau_voltage_gpio_set;
  895. }
  896. /* parse aux tables from vbios */
  897. nouveau_volt_init(dev);
  898. INIT_LIST_HEAD(&pm->profiles);
  899. /* determine current ("boot") performance level */
  900. ret = nouveau_pm_perflvl_get(dev, &pm->boot);
  901. if (ret) {
  902. NV_ERROR(drm, "failed to determine boot perflvl\n");
  903. return ret;
  904. }
  905. strncpy(pm->boot.name, "boot", 4);
  906. strncpy(pm->boot.profile.name, "boot", 4);
  907. pm->boot.profile.func = &nouveau_pm_static_profile_func;
  908. list_add(&pm->boot.profile.head, &pm->profiles);
  909. pm->profile_ac = &pm->boot.profile;
  910. pm->profile_dc = &pm->boot.profile;
  911. pm->profile = &pm->boot.profile;
  912. pm->cur = &pm->boot;
  913. /* add performance levels from vbios */
  914. nouveau_perf_init(dev);
  915. /* display available performance levels */
  916. NV_INFO(drm, "%d available performance level(s)\n", pm->nr_perflvl);
  917. for (i = 0; i < pm->nr_perflvl; i++) {
  918. nouveau_pm_perflvl_info(&pm->perflvl[i], info, sizeof(info));
  919. NV_INFO(drm, "%d:%s", pm->perflvl[i].id, info);
  920. }
  921. nouveau_pm_perflvl_info(&pm->boot, info, sizeof(info));
  922. NV_INFO(drm, "c:%s", info);
  923. /* switch performance levels now if requested */
  924. if (nouveau_perflvl != NULL)
  925. nouveau_pm_profile_set(dev, nouveau_perflvl);
  926. nouveau_sysfs_init(dev);
  927. nouveau_hwmon_init(dev);
  928. #if defined(CONFIG_ACPI) && defined(CONFIG_POWER_SUPPLY)
  929. pm->acpi_nb.notifier_call = nouveau_pm_acpi_event;
  930. register_acpi_notifier(&pm->acpi_nb);
  931. #endif
  932. return 0;
  933. }
  934. void
  935. nouveau_pm_fini(struct drm_device *dev)
  936. {
  937. struct nouveau_pm *pm = nouveau_pm(dev);
  938. struct nouveau_pm_profile *profile, *tmp;
  939. list_for_each_entry_safe(profile, tmp, &pm->profiles, head) {
  940. list_del(&profile->head);
  941. profile->func->destroy(profile);
  942. }
  943. if (pm->cur != &pm->boot)
  944. nouveau_pm_perflvl_set(dev, &pm->boot);
  945. nouveau_perf_fini(dev);
  946. nouveau_volt_fini(dev);
  947. #if defined(CONFIG_ACPI) && defined(CONFIG_POWER_SUPPLY)
  948. unregister_acpi_notifier(&pm->acpi_nb);
  949. #endif
  950. nouveau_hwmon_fini(dev);
  951. nouveau_sysfs_fini(dev);
  952. nouveau_drm(dev)->pm = NULL;
  953. kfree(pm);
  954. }
  955. void
  956. nouveau_pm_resume(struct drm_device *dev)
  957. {
  958. struct nouveau_pm *pm = nouveau_pm(dev);
  959. struct nouveau_pm_level *perflvl;
  960. if (!pm->cur || pm->cur == &pm->boot)
  961. return;
  962. perflvl = pm->cur;
  963. pm->cur = &pm->boot;
  964. nouveau_pm_perflvl_set(dev, perflvl);
  965. }