i915_debugfs.c 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335
  1. /*
  2. * Copyright © 2008 Intel Corporation
  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 (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. * IN THE SOFTWARE.
  22. *
  23. * Authors:
  24. * Eric Anholt <eric@anholt.net>
  25. * Keith Packard <keithp@keithp.com>
  26. *
  27. */
  28. #include <linux/seq_file.h>
  29. #include <linux/debugfs.h>
  30. #include <linux/slab.h>
  31. #include <linux/export.h>
  32. #include <linux/list_sort.h>
  33. #include <asm/msr-index.h>
  34. #include <drm/drmP.h>
  35. #include "intel_drv.h"
  36. #include "intel_ringbuffer.h"
  37. #include <drm/i915_drm.h>
  38. #include "i915_drv.h"
  39. #define DRM_I915_RING_DEBUG 1
  40. #if defined(CONFIG_DEBUG_FS)
  41. enum {
  42. ACTIVE_LIST,
  43. INACTIVE_LIST,
  44. PINNED_LIST,
  45. };
  46. static const char *yesno(int v)
  47. {
  48. return v ? "yes" : "no";
  49. }
  50. static int i915_capabilities(struct seq_file *m, void *data)
  51. {
  52. struct drm_info_node *node = (struct drm_info_node *) m->private;
  53. struct drm_device *dev = node->minor->dev;
  54. const struct intel_device_info *info = INTEL_INFO(dev);
  55. seq_printf(m, "gen: %d\n", info->gen);
  56. seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev));
  57. #define PRINT_FLAG(x) seq_printf(m, #x ": %s\n", yesno(info->x))
  58. #define SEP_SEMICOLON ;
  59. DEV_INFO_FOR_EACH_FLAG(PRINT_FLAG, SEP_SEMICOLON);
  60. #undef PRINT_FLAG
  61. #undef SEP_SEMICOLON
  62. return 0;
  63. }
  64. static const char *get_pin_flag(struct drm_i915_gem_object *obj)
  65. {
  66. if (obj->user_pin_count > 0)
  67. return "P";
  68. else if (obj->pin_count > 0)
  69. return "p";
  70. else
  71. return " ";
  72. }
  73. static const char *get_tiling_flag(struct drm_i915_gem_object *obj)
  74. {
  75. switch (obj->tiling_mode) {
  76. default:
  77. case I915_TILING_NONE: return " ";
  78. case I915_TILING_X: return "X";
  79. case I915_TILING_Y: return "Y";
  80. }
  81. }
  82. static inline const char *get_global_flag(struct drm_i915_gem_object *obj)
  83. {
  84. return obj->has_global_gtt_mapping ? "g" : " ";
  85. }
  86. static void
  87. describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
  88. {
  89. struct i915_vma *vma;
  90. seq_printf(m, "%pK: %s%s%s %8zdKiB %02x %02x %u %u %u%s%s%s",
  91. &obj->base,
  92. get_pin_flag(obj),
  93. get_tiling_flag(obj),
  94. get_global_flag(obj),
  95. obj->base.size / 1024,
  96. obj->base.read_domains,
  97. obj->base.write_domain,
  98. obj->last_read_seqno,
  99. obj->last_write_seqno,
  100. obj->last_fenced_seqno,
  101. i915_cache_level_str(obj->cache_level),
  102. obj->dirty ? " dirty" : "",
  103. obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");
  104. if (obj->base.name)
  105. seq_printf(m, " (name: %d)", obj->base.name);
  106. if (obj->pin_count)
  107. seq_printf(m, " (pinned x %d)", obj->pin_count);
  108. if (obj->pin_display)
  109. seq_printf(m, " (display)");
  110. if (obj->fence_reg != I915_FENCE_REG_NONE)
  111. seq_printf(m, " (fence: %d)", obj->fence_reg);
  112. list_for_each_entry(vma, &obj->vma_list, vma_link) {
  113. if (!i915_is_ggtt(vma->vm))
  114. seq_puts(m, " (pp");
  115. else
  116. seq_puts(m, " (g");
  117. seq_printf(m, "gtt offset: %08lx, size: %08lx)",
  118. vma->node.start, vma->node.size);
  119. }
  120. if (obj->stolen)
  121. seq_printf(m, " (stolen: %08lx)", obj->stolen->start);
  122. if (obj->pin_mappable || obj->fault_mappable) {
  123. char s[3], *t = s;
  124. if (obj->pin_mappable)
  125. *t++ = 'p';
  126. if (obj->fault_mappable)
  127. *t++ = 'f';
  128. *t = '\0';
  129. seq_printf(m, " (%s mappable)", s);
  130. }
  131. if (obj->ring != NULL)
  132. seq_printf(m, " (%s)", obj->ring->name);
  133. }
  134. static void describe_ctx(struct seq_file *m, struct i915_hw_context *ctx)
  135. {
  136. seq_putc(m, ctx->is_initialized ? 'I' : 'i');
  137. seq_putc(m, ctx->remap_slice ? 'R' : 'r');
  138. seq_putc(m, ' ');
  139. }
  140. static int i915_gem_object_list_info(struct seq_file *m, void *data)
  141. {
  142. struct drm_info_node *node = (struct drm_info_node *) m->private;
  143. uintptr_t list = (uintptr_t) node->info_ent->data;
  144. struct list_head *head;
  145. struct drm_device *dev = node->minor->dev;
  146. struct drm_i915_private *dev_priv = dev->dev_private;
  147. struct i915_address_space *vm = &dev_priv->gtt.base;
  148. struct i915_vma *vma;
  149. size_t total_obj_size, total_gtt_size;
  150. int count, ret;
  151. ret = mutex_lock_interruptible(&dev->struct_mutex);
  152. if (ret)
  153. return ret;
  154. /* FIXME: the user of this interface might want more than just GGTT */
  155. switch (list) {
  156. case ACTIVE_LIST:
  157. seq_puts(m, "Active:\n");
  158. head = &vm->active_list;
  159. break;
  160. case INACTIVE_LIST:
  161. seq_puts(m, "Inactive:\n");
  162. head = &vm->inactive_list;
  163. break;
  164. default:
  165. mutex_unlock(&dev->struct_mutex);
  166. return -EINVAL;
  167. }
  168. total_obj_size = total_gtt_size = count = 0;
  169. list_for_each_entry(vma, head, mm_list) {
  170. seq_printf(m, " ");
  171. describe_obj(m, vma->obj);
  172. seq_printf(m, "\n");
  173. total_obj_size += vma->obj->base.size;
  174. total_gtt_size += vma->node.size;
  175. count++;
  176. }
  177. mutex_unlock(&dev->struct_mutex);
  178. seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n",
  179. count, total_obj_size, total_gtt_size);
  180. return 0;
  181. }
  182. static int obj_rank_by_stolen(void *priv,
  183. struct list_head *A, struct list_head *B)
  184. {
  185. struct drm_i915_gem_object *a =
  186. container_of(A, struct drm_i915_gem_object, obj_exec_link);
  187. struct drm_i915_gem_object *b =
  188. container_of(B, struct drm_i915_gem_object, obj_exec_link);
  189. return a->stolen->start - b->stolen->start;
  190. }
  191. static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
  192. {
  193. struct drm_info_node *node = (struct drm_info_node *) m->private;
  194. struct drm_device *dev = node->minor->dev;
  195. struct drm_i915_private *dev_priv = dev->dev_private;
  196. struct drm_i915_gem_object *obj;
  197. size_t total_obj_size, total_gtt_size;
  198. LIST_HEAD(stolen);
  199. int count, ret;
  200. ret = mutex_lock_interruptible(&dev->struct_mutex);
  201. if (ret)
  202. return ret;
  203. total_obj_size = total_gtt_size = count = 0;
  204. list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
  205. if (obj->stolen == NULL)
  206. continue;
  207. list_add(&obj->obj_exec_link, &stolen);
  208. total_obj_size += obj->base.size;
  209. total_gtt_size += i915_gem_obj_ggtt_size(obj);
  210. count++;
  211. }
  212. list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) {
  213. if (obj->stolen == NULL)
  214. continue;
  215. list_add(&obj->obj_exec_link, &stolen);
  216. total_obj_size += obj->base.size;
  217. count++;
  218. }
  219. list_sort(NULL, &stolen, obj_rank_by_stolen);
  220. seq_puts(m, "Stolen:\n");
  221. while (!list_empty(&stolen)) {
  222. obj = list_first_entry(&stolen, typeof(*obj), obj_exec_link);
  223. seq_puts(m, " ");
  224. describe_obj(m, obj);
  225. seq_putc(m, '\n');
  226. list_del_init(&obj->obj_exec_link);
  227. }
  228. mutex_unlock(&dev->struct_mutex);
  229. seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n",
  230. count, total_obj_size, total_gtt_size);
  231. return 0;
  232. }
  233. #define count_objects(list, member) do { \
  234. list_for_each_entry(obj, list, member) { \
  235. size += i915_gem_obj_ggtt_size(obj); \
  236. ++count; \
  237. if (obj->map_and_fenceable) { \
  238. mappable_size += i915_gem_obj_ggtt_size(obj); \
  239. ++mappable_count; \
  240. } \
  241. } \
  242. } while (0)
  243. struct file_stats {
  244. int count;
  245. size_t total, active, inactive, unbound;
  246. };
  247. static int per_file_stats(int id, void *ptr, void *data)
  248. {
  249. struct drm_i915_gem_object *obj = ptr;
  250. struct file_stats *stats = data;
  251. stats->count++;
  252. stats->total += obj->base.size;
  253. if (i915_gem_obj_ggtt_bound(obj)) {
  254. if (!list_empty(&obj->ring_list))
  255. stats->active += obj->base.size;
  256. else
  257. stats->inactive += obj->base.size;
  258. } else {
  259. if (!list_empty(&obj->global_list))
  260. stats->unbound += obj->base.size;
  261. }
  262. return 0;
  263. }
  264. #define count_vmas(list, member) do { \
  265. list_for_each_entry(vma, list, member) { \
  266. size += i915_gem_obj_ggtt_size(vma->obj); \
  267. ++count; \
  268. if (vma->obj->map_and_fenceable) { \
  269. mappable_size += i915_gem_obj_ggtt_size(vma->obj); \
  270. ++mappable_count; \
  271. } \
  272. } \
  273. } while (0)
  274. static int i915_gem_object_info(struct seq_file *m, void* data)
  275. {
  276. struct drm_info_node *node = (struct drm_info_node *) m->private;
  277. struct drm_device *dev = node->minor->dev;
  278. struct drm_i915_private *dev_priv = dev->dev_private;
  279. u32 count, mappable_count, purgeable_count;
  280. size_t size, mappable_size, purgeable_size;
  281. struct drm_i915_gem_object *obj;
  282. struct i915_address_space *vm = &dev_priv->gtt.base;
  283. struct drm_file *file;
  284. struct i915_vma *vma;
  285. int ret;
  286. ret = mutex_lock_interruptible(&dev->struct_mutex);
  287. if (ret)
  288. return ret;
  289. seq_printf(m, "%u objects, %zu bytes\n",
  290. dev_priv->mm.object_count,
  291. dev_priv->mm.object_memory);
  292. size = count = mappable_size = mappable_count = 0;
  293. count_objects(&dev_priv->mm.bound_list, global_list);
  294. seq_printf(m, "%u [%u] objects, %zu [%zu] bytes in gtt\n",
  295. count, mappable_count, size, mappable_size);
  296. size = count = mappable_size = mappable_count = 0;
  297. count_vmas(&vm->active_list, mm_list);
  298. seq_printf(m, " %u [%u] active objects, %zu [%zu] bytes\n",
  299. count, mappable_count, size, mappable_size);
  300. size = count = mappable_size = mappable_count = 0;
  301. count_vmas(&vm->inactive_list, mm_list);
  302. seq_printf(m, " %u [%u] inactive objects, %zu [%zu] bytes\n",
  303. count, mappable_count, size, mappable_size);
  304. size = count = purgeable_size = purgeable_count = 0;
  305. list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) {
  306. size += obj->base.size, ++count;
  307. if (obj->madv == I915_MADV_DONTNEED)
  308. purgeable_size += obj->base.size, ++purgeable_count;
  309. }
  310. seq_printf(m, "%u unbound objects, %zu bytes\n", count, size);
  311. size = count = mappable_size = mappable_count = 0;
  312. list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
  313. if (obj->fault_mappable) {
  314. size += i915_gem_obj_ggtt_size(obj);
  315. ++count;
  316. }
  317. if (obj->pin_mappable) {
  318. mappable_size += i915_gem_obj_ggtt_size(obj);
  319. ++mappable_count;
  320. }
  321. if (obj->madv == I915_MADV_DONTNEED) {
  322. purgeable_size += obj->base.size;
  323. ++purgeable_count;
  324. }
  325. }
  326. seq_printf(m, "%u purgeable objects, %zu bytes\n",
  327. purgeable_count, purgeable_size);
  328. seq_printf(m, "%u pinned mappable objects, %zu bytes\n",
  329. mappable_count, mappable_size);
  330. seq_printf(m, "%u fault mappable objects, %zu bytes\n",
  331. count, size);
  332. seq_printf(m, "%zu [%lu] gtt total\n",
  333. dev_priv->gtt.base.total,
  334. dev_priv->gtt.mappable_end - dev_priv->gtt.base.start);
  335. seq_putc(m, '\n');
  336. list_for_each_entry_reverse(file, &dev->filelist, lhead) {
  337. struct file_stats stats;
  338. memset(&stats, 0, sizeof(stats));
  339. idr_for_each(&file->object_idr, per_file_stats, &stats);
  340. seq_printf(m, "%s: %u objects, %zu bytes (%zu active, %zu inactive, %zu unbound)\n",
  341. get_pid_task(file->pid, PIDTYPE_PID)->comm,
  342. stats.count,
  343. stats.total,
  344. stats.active,
  345. stats.inactive,
  346. stats.unbound);
  347. }
  348. mutex_unlock(&dev->struct_mutex);
  349. return 0;
  350. }
  351. static int i915_gem_gtt_info(struct seq_file *m, void *data)
  352. {
  353. struct drm_info_node *node = (struct drm_info_node *) m->private;
  354. struct drm_device *dev = node->minor->dev;
  355. uintptr_t list = (uintptr_t) node->info_ent->data;
  356. struct drm_i915_private *dev_priv = dev->dev_private;
  357. struct drm_i915_gem_object *obj;
  358. size_t total_obj_size, total_gtt_size;
  359. int count, ret;
  360. ret = mutex_lock_interruptible(&dev->struct_mutex);
  361. if (ret)
  362. return ret;
  363. total_obj_size = total_gtt_size = count = 0;
  364. list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
  365. if (list == PINNED_LIST && obj->pin_count == 0)
  366. continue;
  367. seq_puts(m, " ");
  368. describe_obj(m, obj);
  369. seq_putc(m, '\n');
  370. total_obj_size += obj->base.size;
  371. total_gtt_size += i915_gem_obj_ggtt_size(obj);
  372. count++;
  373. }
  374. mutex_unlock(&dev->struct_mutex);
  375. seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n",
  376. count, total_obj_size, total_gtt_size);
  377. return 0;
  378. }
  379. static int i915_gem_pageflip_info(struct seq_file *m, void *data)
  380. {
  381. struct drm_info_node *node = (struct drm_info_node *) m->private;
  382. struct drm_device *dev = node->minor->dev;
  383. unsigned long flags;
  384. struct intel_crtc *crtc;
  385. list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
  386. const char pipe = pipe_name(crtc->pipe);
  387. const char plane = plane_name(crtc->plane);
  388. struct intel_unpin_work *work;
  389. spin_lock_irqsave(&dev->event_lock, flags);
  390. work = crtc->unpin_work;
  391. if (work == NULL) {
  392. seq_printf(m, "No flip due on pipe %c (plane %c)\n",
  393. pipe, plane);
  394. } else {
  395. if (atomic_read(&work->pending) < INTEL_FLIP_COMPLETE) {
  396. seq_printf(m, "Flip queued on pipe %c (plane %c)\n",
  397. pipe, plane);
  398. } else {
  399. seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
  400. pipe, plane);
  401. }
  402. if (work->enable_stall_check)
  403. seq_puts(m, "Stall check enabled, ");
  404. else
  405. seq_puts(m, "Stall check waiting for page flip ioctl, ");
  406. seq_printf(m, "%d prepares\n", atomic_read(&work->pending));
  407. if (work->old_fb_obj) {
  408. struct drm_i915_gem_object *obj = work->old_fb_obj;
  409. if (obj)
  410. seq_printf(m, "Old framebuffer gtt_offset 0x%08lx\n",
  411. i915_gem_obj_ggtt_offset(obj));
  412. }
  413. if (work->pending_flip_obj) {
  414. struct drm_i915_gem_object *obj = work->pending_flip_obj;
  415. if (obj)
  416. seq_printf(m, "New framebuffer gtt_offset 0x%08lx\n",
  417. i915_gem_obj_ggtt_offset(obj));
  418. }
  419. }
  420. spin_unlock_irqrestore(&dev->event_lock, flags);
  421. }
  422. return 0;
  423. }
  424. static int i915_gem_request_info(struct seq_file *m, void *data)
  425. {
  426. struct drm_info_node *node = (struct drm_info_node *) m->private;
  427. struct drm_device *dev = node->minor->dev;
  428. drm_i915_private_t *dev_priv = dev->dev_private;
  429. struct intel_ring_buffer *ring;
  430. struct drm_i915_gem_request *gem_request;
  431. int ret, count, i;
  432. ret = mutex_lock_interruptible(&dev->struct_mutex);
  433. if (ret)
  434. return ret;
  435. count = 0;
  436. for_each_ring(ring, dev_priv, i) {
  437. if (list_empty(&ring->request_list))
  438. continue;
  439. seq_printf(m, "%s requests:\n", ring->name);
  440. list_for_each_entry(gem_request,
  441. &ring->request_list,
  442. list) {
  443. seq_printf(m, " %d @ %d\n",
  444. gem_request->seqno,
  445. (int) (jiffies - gem_request->emitted_jiffies));
  446. }
  447. count++;
  448. }
  449. mutex_unlock(&dev->struct_mutex);
  450. if (count == 0)
  451. seq_puts(m, "No requests\n");
  452. return 0;
  453. }
  454. static void i915_ring_seqno_info(struct seq_file *m,
  455. struct intel_ring_buffer *ring)
  456. {
  457. if (ring->get_seqno) {
  458. seq_printf(m, "Current sequence (%s): %u\n",
  459. ring->name, ring->get_seqno(ring, false));
  460. }
  461. }
  462. static int i915_gem_seqno_info(struct seq_file *m, void *data)
  463. {
  464. struct drm_info_node *node = (struct drm_info_node *) m->private;
  465. struct drm_device *dev = node->minor->dev;
  466. drm_i915_private_t *dev_priv = dev->dev_private;
  467. struct intel_ring_buffer *ring;
  468. int ret, i;
  469. ret = mutex_lock_interruptible(&dev->struct_mutex);
  470. if (ret)
  471. return ret;
  472. for_each_ring(ring, dev_priv, i)
  473. i915_ring_seqno_info(m, ring);
  474. mutex_unlock(&dev->struct_mutex);
  475. return 0;
  476. }
  477. static int i915_interrupt_info(struct seq_file *m, void *data)
  478. {
  479. struct drm_info_node *node = (struct drm_info_node *) m->private;
  480. struct drm_device *dev = node->minor->dev;
  481. drm_i915_private_t *dev_priv = dev->dev_private;
  482. struct intel_ring_buffer *ring;
  483. int ret, i, pipe;
  484. ret = mutex_lock_interruptible(&dev->struct_mutex);
  485. if (ret)
  486. return ret;
  487. if (IS_VALLEYVIEW(dev)) {
  488. seq_printf(m, "Display IER:\t%08x\n",
  489. I915_READ(VLV_IER));
  490. seq_printf(m, "Display IIR:\t%08x\n",
  491. I915_READ(VLV_IIR));
  492. seq_printf(m, "Display IIR_RW:\t%08x\n",
  493. I915_READ(VLV_IIR_RW));
  494. seq_printf(m, "Display IMR:\t%08x\n",
  495. I915_READ(VLV_IMR));
  496. for_each_pipe(pipe)
  497. seq_printf(m, "Pipe %c stat:\t%08x\n",
  498. pipe_name(pipe),
  499. I915_READ(PIPESTAT(pipe)));
  500. seq_printf(m, "Master IER:\t%08x\n",
  501. I915_READ(VLV_MASTER_IER));
  502. seq_printf(m, "Render IER:\t%08x\n",
  503. I915_READ(GTIER));
  504. seq_printf(m, "Render IIR:\t%08x\n",
  505. I915_READ(GTIIR));
  506. seq_printf(m, "Render IMR:\t%08x\n",
  507. I915_READ(GTIMR));
  508. seq_printf(m, "PM IER:\t\t%08x\n",
  509. I915_READ(GEN6_PMIER));
  510. seq_printf(m, "PM IIR:\t\t%08x\n",
  511. I915_READ(GEN6_PMIIR));
  512. seq_printf(m, "PM IMR:\t\t%08x\n",
  513. I915_READ(GEN6_PMIMR));
  514. seq_printf(m, "Port hotplug:\t%08x\n",
  515. I915_READ(PORT_HOTPLUG_EN));
  516. seq_printf(m, "DPFLIPSTAT:\t%08x\n",
  517. I915_READ(VLV_DPFLIPSTAT));
  518. seq_printf(m, "DPINVGTT:\t%08x\n",
  519. I915_READ(DPINVGTT));
  520. } else if (!HAS_PCH_SPLIT(dev)) {
  521. seq_printf(m, "Interrupt enable: %08x\n",
  522. I915_READ(IER));
  523. seq_printf(m, "Interrupt identity: %08x\n",
  524. I915_READ(IIR));
  525. seq_printf(m, "Interrupt mask: %08x\n",
  526. I915_READ(IMR));
  527. for_each_pipe(pipe)
  528. seq_printf(m, "Pipe %c stat: %08x\n",
  529. pipe_name(pipe),
  530. I915_READ(PIPESTAT(pipe)));
  531. } else {
  532. seq_printf(m, "North Display Interrupt enable: %08x\n",
  533. I915_READ(DEIER));
  534. seq_printf(m, "North Display Interrupt identity: %08x\n",
  535. I915_READ(DEIIR));
  536. seq_printf(m, "North Display Interrupt mask: %08x\n",
  537. I915_READ(DEIMR));
  538. seq_printf(m, "South Display Interrupt enable: %08x\n",
  539. I915_READ(SDEIER));
  540. seq_printf(m, "South Display Interrupt identity: %08x\n",
  541. I915_READ(SDEIIR));
  542. seq_printf(m, "South Display Interrupt mask: %08x\n",
  543. I915_READ(SDEIMR));
  544. seq_printf(m, "Graphics Interrupt enable: %08x\n",
  545. I915_READ(GTIER));
  546. seq_printf(m, "Graphics Interrupt identity: %08x\n",
  547. I915_READ(GTIIR));
  548. seq_printf(m, "Graphics Interrupt mask: %08x\n",
  549. I915_READ(GTIMR));
  550. }
  551. seq_printf(m, "Interrupts received: %d\n",
  552. atomic_read(&dev_priv->irq_received));
  553. for_each_ring(ring, dev_priv, i) {
  554. if (IS_GEN6(dev) || IS_GEN7(dev)) {
  555. seq_printf(m,
  556. "Graphics Interrupt mask (%s): %08x\n",
  557. ring->name, I915_READ_IMR(ring));
  558. }
  559. i915_ring_seqno_info(m, ring);
  560. }
  561. mutex_unlock(&dev->struct_mutex);
  562. return 0;
  563. }
  564. static int i915_gem_fence_regs_info(struct seq_file *m, void *data)
  565. {
  566. struct drm_info_node *node = (struct drm_info_node *) m->private;
  567. struct drm_device *dev = node->minor->dev;
  568. drm_i915_private_t *dev_priv = dev->dev_private;
  569. int i, ret;
  570. ret = mutex_lock_interruptible(&dev->struct_mutex);
  571. if (ret)
  572. return ret;
  573. seq_printf(m, "Reserved fences = %d\n", dev_priv->fence_reg_start);
  574. seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs);
  575. for (i = 0; i < dev_priv->num_fence_regs; i++) {
  576. struct drm_i915_gem_object *obj = dev_priv->fence_regs[i].obj;
  577. seq_printf(m, "Fence %d, pin count = %d, object = ",
  578. i, dev_priv->fence_regs[i].pin_count);
  579. if (obj == NULL)
  580. seq_puts(m, "unused");
  581. else
  582. describe_obj(m, obj);
  583. seq_putc(m, '\n');
  584. }
  585. mutex_unlock(&dev->struct_mutex);
  586. return 0;
  587. }
  588. static int i915_hws_info(struct seq_file *m, void *data)
  589. {
  590. struct drm_info_node *node = (struct drm_info_node *) m->private;
  591. struct drm_device *dev = node->minor->dev;
  592. drm_i915_private_t *dev_priv = dev->dev_private;
  593. struct intel_ring_buffer *ring;
  594. const u32 *hws;
  595. int i;
  596. ring = &dev_priv->ring[(uintptr_t)node->info_ent->data];
  597. hws = ring->status_page.page_addr;
  598. if (hws == NULL)
  599. return 0;
  600. for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) {
  601. seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
  602. i * 4,
  603. hws[i], hws[i + 1], hws[i + 2], hws[i + 3]);
  604. }
  605. return 0;
  606. }
  607. static ssize_t
  608. i915_error_state_write(struct file *filp,
  609. const char __user *ubuf,
  610. size_t cnt,
  611. loff_t *ppos)
  612. {
  613. struct i915_error_state_file_priv *error_priv = filp->private_data;
  614. struct drm_device *dev = error_priv->dev;
  615. int ret;
  616. DRM_DEBUG_DRIVER("Resetting error state\n");
  617. ret = mutex_lock_interruptible(&dev->struct_mutex);
  618. if (ret)
  619. return ret;
  620. i915_destroy_error_state(dev);
  621. mutex_unlock(&dev->struct_mutex);
  622. return cnt;
  623. }
  624. static int i915_error_state_open(struct inode *inode, struct file *file)
  625. {
  626. struct drm_device *dev = inode->i_private;
  627. struct i915_error_state_file_priv *error_priv;
  628. error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL);
  629. if (!error_priv)
  630. return -ENOMEM;
  631. error_priv->dev = dev;
  632. i915_error_state_get(dev, error_priv);
  633. file->private_data = error_priv;
  634. return 0;
  635. }
  636. static int i915_error_state_release(struct inode *inode, struct file *file)
  637. {
  638. struct i915_error_state_file_priv *error_priv = file->private_data;
  639. i915_error_state_put(error_priv);
  640. kfree(error_priv);
  641. return 0;
  642. }
  643. static ssize_t i915_error_state_read(struct file *file, char __user *userbuf,
  644. size_t count, loff_t *pos)
  645. {
  646. struct i915_error_state_file_priv *error_priv = file->private_data;
  647. struct drm_i915_error_state_buf error_str;
  648. loff_t tmp_pos = 0;
  649. ssize_t ret_count = 0;
  650. int ret;
  651. ret = i915_error_state_buf_init(&error_str, count, *pos);
  652. if (ret)
  653. return ret;
  654. ret = i915_error_state_to_str(&error_str, error_priv);
  655. if (ret)
  656. goto out;
  657. ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos,
  658. error_str.buf,
  659. error_str.bytes);
  660. if (ret_count < 0)
  661. ret = ret_count;
  662. else
  663. *pos = error_str.start + ret_count;
  664. out:
  665. i915_error_state_buf_release(&error_str);
  666. return ret ?: ret_count;
  667. }
  668. static const struct file_operations i915_error_state_fops = {
  669. .owner = THIS_MODULE,
  670. .open = i915_error_state_open,
  671. .read = i915_error_state_read,
  672. .write = i915_error_state_write,
  673. .llseek = default_llseek,
  674. .release = i915_error_state_release,
  675. };
  676. static int
  677. i915_next_seqno_get(void *data, u64 *val)
  678. {
  679. struct drm_device *dev = data;
  680. drm_i915_private_t *dev_priv = dev->dev_private;
  681. int ret;
  682. ret = mutex_lock_interruptible(&dev->struct_mutex);
  683. if (ret)
  684. return ret;
  685. *val = dev_priv->next_seqno;
  686. mutex_unlock(&dev->struct_mutex);
  687. return 0;
  688. }
  689. static int
  690. i915_next_seqno_set(void *data, u64 val)
  691. {
  692. struct drm_device *dev = data;
  693. int ret;
  694. ret = mutex_lock_interruptible(&dev->struct_mutex);
  695. if (ret)
  696. return ret;
  697. ret = i915_gem_set_seqno(dev, val);
  698. mutex_unlock(&dev->struct_mutex);
  699. return ret;
  700. }
  701. DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops,
  702. i915_next_seqno_get, i915_next_seqno_set,
  703. "0x%llx\n");
  704. static int i915_rstdby_delays(struct seq_file *m, void *unused)
  705. {
  706. struct drm_info_node *node = (struct drm_info_node *) m->private;
  707. struct drm_device *dev = node->minor->dev;
  708. drm_i915_private_t *dev_priv = dev->dev_private;
  709. u16 crstanddelay;
  710. int ret;
  711. ret = mutex_lock_interruptible(&dev->struct_mutex);
  712. if (ret)
  713. return ret;
  714. crstanddelay = I915_READ16(CRSTANDVID);
  715. mutex_unlock(&dev->struct_mutex);
  716. seq_printf(m, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay >> 8) & 0x3f, (crstanddelay & 0x3f));
  717. return 0;
  718. }
  719. static int i915_cur_delayinfo(struct seq_file *m, void *unused)
  720. {
  721. struct drm_info_node *node = (struct drm_info_node *) m->private;
  722. struct drm_device *dev = node->minor->dev;
  723. drm_i915_private_t *dev_priv = dev->dev_private;
  724. int ret;
  725. if (IS_GEN5(dev)) {
  726. u16 rgvswctl = I915_READ16(MEMSWCTL);
  727. u16 rgvstat = I915_READ16(MEMSTAT_ILK);
  728. seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf);
  729. seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f);
  730. seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >>
  731. MEMSTAT_VID_SHIFT);
  732. seq_printf(m, "Current P-state: %d\n",
  733. (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT);
  734. } else if ((IS_GEN6(dev) || IS_GEN7(dev)) && !IS_VALLEYVIEW(dev)) {
  735. u32 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS);
  736. u32 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS);
  737. u32 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
  738. u32 rpstat, cagf, reqf;
  739. u32 rpupei, rpcurup, rpprevup;
  740. u32 rpdownei, rpcurdown, rpprevdown;
  741. int max_freq;
  742. /* RPSTAT1 is in the GT power well */
  743. ret = mutex_lock_interruptible(&dev->struct_mutex);
  744. if (ret)
  745. return ret;
  746. gen6_gt_force_wake_get(dev_priv);
  747. reqf = I915_READ(GEN6_RPNSWREQ);
  748. reqf &= ~GEN6_TURBO_DISABLE;
  749. if (IS_HASWELL(dev))
  750. reqf >>= 24;
  751. else
  752. reqf >>= 25;
  753. reqf *= GT_FREQUENCY_MULTIPLIER;
  754. rpstat = I915_READ(GEN6_RPSTAT1);
  755. rpupei = I915_READ(GEN6_RP_CUR_UP_EI);
  756. rpcurup = I915_READ(GEN6_RP_CUR_UP);
  757. rpprevup = I915_READ(GEN6_RP_PREV_UP);
  758. rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI);
  759. rpcurdown = I915_READ(GEN6_RP_CUR_DOWN);
  760. rpprevdown = I915_READ(GEN6_RP_PREV_DOWN);
  761. if (IS_HASWELL(dev))
  762. cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT;
  763. else
  764. cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT;
  765. cagf *= GT_FREQUENCY_MULTIPLIER;
  766. gen6_gt_force_wake_put(dev_priv);
  767. mutex_unlock(&dev->struct_mutex);
  768. seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status);
  769. seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat);
  770. seq_printf(m, "Render p-state ratio: %d\n",
  771. (gt_perf_status & 0xff00) >> 8);
  772. seq_printf(m, "Render p-state VID: %d\n",
  773. gt_perf_status & 0xff);
  774. seq_printf(m, "Render p-state limit: %d\n",
  775. rp_state_limits & 0xff);
  776. seq_printf(m, "RPNSWREQ: %dMHz\n", reqf);
  777. seq_printf(m, "CAGF: %dMHz\n", cagf);
  778. seq_printf(m, "RP CUR UP EI: %dus\n", rpupei &
  779. GEN6_CURICONT_MASK);
  780. seq_printf(m, "RP CUR UP: %dus\n", rpcurup &
  781. GEN6_CURBSYTAVG_MASK);
  782. seq_printf(m, "RP PREV UP: %dus\n", rpprevup &
  783. GEN6_CURBSYTAVG_MASK);
  784. seq_printf(m, "RP CUR DOWN EI: %dus\n", rpdownei &
  785. GEN6_CURIAVG_MASK);
  786. seq_printf(m, "RP CUR DOWN: %dus\n", rpcurdown &
  787. GEN6_CURBSYTAVG_MASK);
  788. seq_printf(m, "RP PREV DOWN: %dus\n", rpprevdown &
  789. GEN6_CURBSYTAVG_MASK);
  790. max_freq = (rp_state_cap & 0xff0000) >> 16;
  791. seq_printf(m, "Lowest (RPN) frequency: %dMHz\n",
  792. max_freq * GT_FREQUENCY_MULTIPLIER);
  793. max_freq = (rp_state_cap & 0xff00) >> 8;
  794. seq_printf(m, "Nominal (RP1) frequency: %dMHz\n",
  795. max_freq * GT_FREQUENCY_MULTIPLIER);
  796. max_freq = rp_state_cap & 0xff;
  797. seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n",
  798. max_freq * GT_FREQUENCY_MULTIPLIER);
  799. seq_printf(m, "Max overclocked frequency: %dMHz\n",
  800. dev_priv->rps.hw_max * GT_FREQUENCY_MULTIPLIER);
  801. } else if (IS_VALLEYVIEW(dev)) {
  802. u32 freq_sts, val;
  803. mutex_lock(&dev_priv->rps.hw_lock);
  804. freq_sts = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
  805. seq_printf(m, "PUNIT_REG_GPU_FREQ_STS: 0x%08x\n", freq_sts);
  806. seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq);
  807. val = vlv_punit_read(dev_priv, PUNIT_FUSE_BUS1);
  808. seq_printf(m, "max GPU freq: %d MHz\n",
  809. vlv_gpu_freq(dev_priv->mem_freq, val));
  810. val = vlv_punit_read(dev_priv, PUNIT_REG_GPU_LFM);
  811. seq_printf(m, "min GPU freq: %d MHz\n",
  812. vlv_gpu_freq(dev_priv->mem_freq, val));
  813. seq_printf(m, "current GPU freq: %d MHz\n",
  814. vlv_gpu_freq(dev_priv->mem_freq,
  815. (freq_sts >> 8) & 0xff));
  816. mutex_unlock(&dev_priv->rps.hw_lock);
  817. } else {
  818. seq_puts(m, "no P-state info available\n");
  819. }
  820. return 0;
  821. }
  822. static int i915_delayfreq_table(struct seq_file *m, void *unused)
  823. {
  824. struct drm_info_node *node = (struct drm_info_node *) m->private;
  825. struct drm_device *dev = node->minor->dev;
  826. drm_i915_private_t *dev_priv = dev->dev_private;
  827. u32 delayfreq;
  828. int ret, i;
  829. ret = mutex_lock_interruptible(&dev->struct_mutex);
  830. if (ret)
  831. return ret;
  832. for (i = 0; i < 16; i++) {
  833. delayfreq = I915_READ(PXVFREQ_BASE + i * 4);
  834. seq_printf(m, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i, delayfreq,
  835. (delayfreq & PXVFREQ_PX_MASK) >> PXVFREQ_PX_SHIFT);
  836. }
  837. mutex_unlock(&dev->struct_mutex);
  838. return 0;
  839. }
  840. static inline int MAP_TO_MV(int map)
  841. {
  842. return 1250 - (map * 25);
  843. }
  844. static int i915_inttoext_table(struct seq_file *m, void *unused)
  845. {
  846. struct drm_info_node *node = (struct drm_info_node *) m->private;
  847. struct drm_device *dev = node->minor->dev;
  848. drm_i915_private_t *dev_priv = dev->dev_private;
  849. u32 inttoext;
  850. int ret, i;
  851. ret = mutex_lock_interruptible(&dev->struct_mutex);
  852. if (ret)
  853. return ret;
  854. for (i = 1; i <= 32; i++) {
  855. inttoext = I915_READ(INTTOEXT_BASE_ILK + i * 4);
  856. seq_printf(m, "INTTOEXT%02d: 0x%08x\n", i, inttoext);
  857. }
  858. mutex_unlock(&dev->struct_mutex);
  859. return 0;
  860. }
  861. static int ironlake_drpc_info(struct seq_file *m)
  862. {
  863. struct drm_info_node *node = (struct drm_info_node *) m->private;
  864. struct drm_device *dev = node->minor->dev;
  865. drm_i915_private_t *dev_priv = dev->dev_private;
  866. u32 rgvmodectl, rstdbyctl;
  867. u16 crstandvid;
  868. int ret;
  869. ret = mutex_lock_interruptible(&dev->struct_mutex);
  870. if (ret)
  871. return ret;
  872. rgvmodectl = I915_READ(MEMMODECTL);
  873. rstdbyctl = I915_READ(RSTDBYCTL);
  874. crstandvid = I915_READ16(CRSTANDVID);
  875. mutex_unlock(&dev->struct_mutex);
  876. seq_printf(m, "HD boost: %s\n", (rgvmodectl & MEMMODE_BOOST_EN) ?
  877. "yes" : "no");
  878. seq_printf(m, "Boost freq: %d\n",
  879. (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >>
  880. MEMMODE_BOOST_FREQ_SHIFT);
  881. seq_printf(m, "HW control enabled: %s\n",
  882. rgvmodectl & MEMMODE_HWIDLE_EN ? "yes" : "no");
  883. seq_printf(m, "SW control enabled: %s\n",
  884. rgvmodectl & MEMMODE_SWMODE_EN ? "yes" : "no");
  885. seq_printf(m, "Gated voltage change: %s\n",
  886. rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no");
  887. seq_printf(m, "Starting frequency: P%d\n",
  888. (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT);
  889. seq_printf(m, "Max P-state: P%d\n",
  890. (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT);
  891. seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK));
  892. seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f));
  893. seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f));
  894. seq_printf(m, "Render standby enabled: %s\n",
  895. (rstdbyctl & RCX_SW_EXIT) ? "no" : "yes");
  896. seq_puts(m, "Current RS state: ");
  897. switch (rstdbyctl & RSX_STATUS_MASK) {
  898. case RSX_STATUS_ON:
  899. seq_puts(m, "on\n");
  900. break;
  901. case RSX_STATUS_RC1:
  902. seq_puts(m, "RC1\n");
  903. break;
  904. case RSX_STATUS_RC1E:
  905. seq_puts(m, "RC1E\n");
  906. break;
  907. case RSX_STATUS_RS1:
  908. seq_puts(m, "RS1\n");
  909. break;
  910. case RSX_STATUS_RS2:
  911. seq_puts(m, "RS2 (RC6)\n");
  912. break;
  913. case RSX_STATUS_RS3:
  914. seq_puts(m, "RC3 (RC6+)\n");
  915. break;
  916. default:
  917. seq_puts(m, "unknown\n");
  918. break;
  919. }
  920. return 0;
  921. }
  922. static int gen6_drpc_info(struct seq_file *m)
  923. {
  924. struct drm_info_node *node = (struct drm_info_node *) m->private;
  925. struct drm_device *dev = node->minor->dev;
  926. struct drm_i915_private *dev_priv = dev->dev_private;
  927. u32 rpmodectl1, gt_core_status, rcctl1, rc6vids = 0;
  928. unsigned forcewake_count;
  929. int count = 0, ret;
  930. ret = mutex_lock_interruptible(&dev->struct_mutex);
  931. if (ret)
  932. return ret;
  933. spin_lock_irq(&dev_priv->uncore.lock);
  934. forcewake_count = dev_priv->uncore.forcewake_count;
  935. spin_unlock_irq(&dev_priv->uncore.lock);
  936. if (forcewake_count) {
  937. seq_puts(m, "RC information inaccurate because somebody "
  938. "holds a forcewake reference \n");
  939. } else {
  940. /* NB: we cannot use forcewake, else we read the wrong values */
  941. while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1))
  942. udelay(10);
  943. seq_printf(m, "RC information accurate: %s\n", yesno(count < 51));
  944. }
  945. gt_core_status = readl(dev_priv->regs + GEN6_GT_CORE_STATUS);
  946. trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS, gt_core_status, 4, true);
  947. rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
  948. rcctl1 = I915_READ(GEN6_RC_CONTROL);
  949. mutex_unlock(&dev->struct_mutex);
  950. mutex_lock(&dev_priv->rps.hw_lock);
  951. sandybridge_pcode_read(dev_priv, GEN6_PCODE_READ_RC6VIDS, &rc6vids);
  952. mutex_unlock(&dev_priv->rps.hw_lock);
  953. seq_printf(m, "Video Turbo Mode: %s\n",
  954. yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
  955. seq_printf(m, "HW control enabled: %s\n",
  956. yesno(rpmodectl1 & GEN6_RP_ENABLE));
  957. seq_printf(m, "SW control enabled: %s\n",
  958. yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
  959. GEN6_RP_MEDIA_SW_MODE));
  960. seq_printf(m, "RC1e Enabled: %s\n",
  961. yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE));
  962. seq_printf(m, "RC6 Enabled: %s\n",
  963. yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE));
  964. seq_printf(m, "Deep RC6 Enabled: %s\n",
  965. yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE));
  966. seq_printf(m, "Deepest RC6 Enabled: %s\n",
  967. yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE));
  968. seq_puts(m, "Current RC state: ");
  969. switch (gt_core_status & GEN6_RCn_MASK) {
  970. case GEN6_RC0:
  971. if (gt_core_status & GEN6_CORE_CPD_STATE_MASK)
  972. seq_puts(m, "Core Power Down\n");
  973. else
  974. seq_puts(m, "on\n");
  975. break;
  976. case GEN6_RC3:
  977. seq_puts(m, "RC3\n");
  978. break;
  979. case GEN6_RC6:
  980. seq_puts(m, "RC6\n");
  981. break;
  982. case GEN6_RC7:
  983. seq_puts(m, "RC7\n");
  984. break;
  985. default:
  986. seq_puts(m, "Unknown\n");
  987. break;
  988. }
  989. seq_printf(m, "Core Power Down: %s\n",
  990. yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK));
  991. /* Not exactly sure what this is */
  992. seq_printf(m, "RC6 \"Locked to RPn\" residency since boot: %u\n",
  993. I915_READ(GEN6_GT_GFX_RC6_LOCKED));
  994. seq_printf(m, "RC6 residency since boot: %u\n",
  995. I915_READ(GEN6_GT_GFX_RC6));
  996. seq_printf(m, "RC6+ residency since boot: %u\n",
  997. I915_READ(GEN6_GT_GFX_RC6p));
  998. seq_printf(m, "RC6++ residency since boot: %u\n",
  999. I915_READ(GEN6_GT_GFX_RC6pp));
  1000. seq_printf(m, "RC6 voltage: %dmV\n",
  1001. GEN6_DECODE_RC6_VID(((rc6vids >> 0) & 0xff)));
  1002. seq_printf(m, "RC6+ voltage: %dmV\n",
  1003. GEN6_DECODE_RC6_VID(((rc6vids >> 8) & 0xff)));
  1004. seq_printf(m, "RC6++ voltage: %dmV\n",
  1005. GEN6_DECODE_RC6_VID(((rc6vids >> 16) & 0xff)));
  1006. return 0;
  1007. }
  1008. static int i915_drpc_info(struct seq_file *m, void *unused)
  1009. {
  1010. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1011. struct drm_device *dev = node->minor->dev;
  1012. if (IS_GEN6(dev) || IS_GEN7(dev))
  1013. return gen6_drpc_info(m);
  1014. else
  1015. return ironlake_drpc_info(m);
  1016. }
  1017. static int i915_fbc_status(struct seq_file *m, void *unused)
  1018. {
  1019. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1020. struct drm_device *dev = node->minor->dev;
  1021. drm_i915_private_t *dev_priv = dev->dev_private;
  1022. if (!I915_HAS_FBC(dev)) {
  1023. seq_puts(m, "FBC unsupported on this chipset\n");
  1024. return 0;
  1025. }
  1026. if (intel_fbc_enabled(dev)) {
  1027. seq_puts(m, "FBC enabled\n");
  1028. } else {
  1029. seq_puts(m, "FBC disabled: ");
  1030. switch (dev_priv->fbc.no_fbc_reason) {
  1031. case FBC_OK:
  1032. seq_puts(m, "FBC actived, but currently disabled in hardware");
  1033. break;
  1034. case FBC_UNSUPPORTED:
  1035. seq_puts(m, "unsupported by this chipset");
  1036. break;
  1037. case FBC_NO_OUTPUT:
  1038. seq_puts(m, "no outputs");
  1039. break;
  1040. case FBC_STOLEN_TOO_SMALL:
  1041. seq_puts(m, "not enough stolen memory");
  1042. break;
  1043. case FBC_UNSUPPORTED_MODE:
  1044. seq_puts(m, "mode not supported");
  1045. break;
  1046. case FBC_MODE_TOO_LARGE:
  1047. seq_puts(m, "mode too large");
  1048. break;
  1049. case FBC_BAD_PLANE:
  1050. seq_puts(m, "FBC unsupported on plane");
  1051. break;
  1052. case FBC_NOT_TILED:
  1053. seq_puts(m, "scanout buffer not tiled");
  1054. break;
  1055. case FBC_MULTIPLE_PIPES:
  1056. seq_puts(m, "multiple pipes are enabled");
  1057. break;
  1058. case FBC_MODULE_PARAM:
  1059. seq_puts(m, "disabled per module param (default off)");
  1060. break;
  1061. case FBC_CHIP_DEFAULT:
  1062. seq_puts(m, "disabled per chip default");
  1063. break;
  1064. default:
  1065. seq_puts(m, "unknown reason");
  1066. }
  1067. seq_putc(m, '\n');
  1068. }
  1069. return 0;
  1070. }
  1071. static int i915_ips_status(struct seq_file *m, void *unused)
  1072. {
  1073. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1074. struct drm_device *dev = node->minor->dev;
  1075. struct drm_i915_private *dev_priv = dev->dev_private;
  1076. if (!HAS_IPS(dev)) {
  1077. seq_puts(m, "not supported\n");
  1078. return 0;
  1079. }
  1080. if (I915_READ(IPS_CTL) & IPS_ENABLE)
  1081. seq_puts(m, "enabled\n");
  1082. else
  1083. seq_puts(m, "disabled\n");
  1084. return 0;
  1085. }
  1086. static int i915_sr_status(struct seq_file *m, void *unused)
  1087. {
  1088. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1089. struct drm_device *dev = node->minor->dev;
  1090. drm_i915_private_t *dev_priv = dev->dev_private;
  1091. bool sr_enabled = false;
  1092. if (HAS_PCH_SPLIT(dev))
  1093. sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN;
  1094. else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev))
  1095. sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
  1096. else if (IS_I915GM(dev))
  1097. sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
  1098. else if (IS_PINEVIEW(dev))
  1099. sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN;
  1100. seq_printf(m, "self-refresh: %s\n",
  1101. sr_enabled ? "enabled" : "disabled");
  1102. return 0;
  1103. }
  1104. static int i915_emon_status(struct seq_file *m, void *unused)
  1105. {
  1106. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1107. struct drm_device *dev = node->minor->dev;
  1108. drm_i915_private_t *dev_priv = dev->dev_private;
  1109. unsigned long temp, chipset, gfx;
  1110. int ret;
  1111. if (!IS_GEN5(dev))
  1112. return -ENODEV;
  1113. ret = mutex_lock_interruptible(&dev->struct_mutex);
  1114. if (ret)
  1115. return ret;
  1116. temp = i915_mch_val(dev_priv);
  1117. chipset = i915_chipset_val(dev_priv);
  1118. gfx = i915_gfx_val(dev_priv);
  1119. mutex_unlock(&dev->struct_mutex);
  1120. seq_printf(m, "GMCH temp: %ld\n", temp);
  1121. seq_printf(m, "Chipset power: %ld\n", chipset);
  1122. seq_printf(m, "GFX power: %ld\n", gfx);
  1123. seq_printf(m, "Total power: %ld\n", chipset + gfx);
  1124. return 0;
  1125. }
  1126. static int i915_ring_freq_table(struct seq_file *m, void *unused)
  1127. {
  1128. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1129. struct drm_device *dev = node->minor->dev;
  1130. drm_i915_private_t *dev_priv = dev->dev_private;
  1131. int ret;
  1132. int gpu_freq, ia_freq;
  1133. if (!(IS_GEN6(dev) || IS_GEN7(dev))) {
  1134. seq_puts(m, "unsupported on this chipset\n");
  1135. return 0;
  1136. }
  1137. ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
  1138. if (ret)
  1139. return ret;
  1140. seq_puts(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\tEffective Ring freq (MHz)\n");
  1141. for (gpu_freq = dev_priv->rps.min_delay;
  1142. gpu_freq <= dev_priv->rps.max_delay;
  1143. gpu_freq++) {
  1144. ia_freq = gpu_freq;
  1145. sandybridge_pcode_read(dev_priv,
  1146. GEN6_PCODE_READ_MIN_FREQ_TABLE,
  1147. &ia_freq);
  1148. seq_printf(m, "%d\t\t%d\t\t\t\t%d\n",
  1149. gpu_freq * GT_FREQUENCY_MULTIPLIER,
  1150. ((ia_freq >> 0) & 0xff) * 100,
  1151. ((ia_freq >> 8) & 0xff) * 100);
  1152. }
  1153. mutex_unlock(&dev_priv->rps.hw_lock);
  1154. return 0;
  1155. }
  1156. static int i915_gfxec(struct seq_file *m, void *unused)
  1157. {
  1158. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1159. struct drm_device *dev = node->minor->dev;
  1160. drm_i915_private_t *dev_priv = dev->dev_private;
  1161. int ret;
  1162. ret = mutex_lock_interruptible(&dev->struct_mutex);
  1163. if (ret)
  1164. return ret;
  1165. seq_printf(m, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4));
  1166. mutex_unlock(&dev->struct_mutex);
  1167. return 0;
  1168. }
  1169. static int i915_opregion(struct seq_file *m, void *unused)
  1170. {
  1171. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1172. struct drm_device *dev = node->minor->dev;
  1173. drm_i915_private_t *dev_priv = dev->dev_private;
  1174. struct intel_opregion *opregion = &dev_priv->opregion;
  1175. void *data = kmalloc(OPREGION_SIZE, GFP_KERNEL);
  1176. int ret;
  1177. if (data == NULL)
  1178. return -ENOMEM;
  1179. ret = mutex_lock_interruptible(&dev->struct_mutex);
  1180. if (ret)
  1181. goto out;
  1182. if (opregion->header) {
  1183. memcpy_fromio(data, opregion->header, OPREGION_SIZE);
  1184. seq_write(m, data, OPREGION_SIZE);
  1185. }
  1186. mutex_unlock(&dev->struct_mutex);
  1187. out:
  1188. kfree(data);
  1189. return 0;
  1190. }
  1191. static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
  1192. {
  1193. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1194. struct drm_device *dev = node->minor->dev;
  1195. drm_i915_private_t *dev_priv = dev->dev_private;
  1196. struct intel_fbdev *ifbdev;
  1197. struct intel_framebuffer *fb;
  1198. int ret;
  1199. ret = mutex_lock_interruptible(&dev->mode_config.mutex);
  1200. if (ret)
  1201. return ret;
  1202. ifbdev = dev_priv->fbdev;
  1203. fb = to_intel_framebuffer(ifbdev->helper.fb);
  1204. seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, refcount %d, obj ",
  1205. fb->base.width,
  1206. fb->base.height,
  1207. fb->base.depth,
  1208. fb->base.bits_per_pixel,
  1209. atomic_read(&fb->base.refcount.refcount));
  1210. describe_obj(m, fb->obj);
  1211. seq_putc(m, '\n');
  1212. mutex_unlock(&dev->mode_config.mutex);
  1213. mutex_lock(&dev->mode_config.fb_lock);
  1214. list_for_each_entry(fb, &dev->mode_config.fb_list, base.head) {
  1215. if (&fb->base == ifbdev->helper.fb)
  1216. continue;
  1217. seq_printf(m, "user size: %d x %d, depth %d, %d bpp, refcount %d, obj ",
  1218. fb->base.width,
  1219. fb->base.height,
  1220. fb->base.depth,
  1221. fb->base.bits_per_pixel,
  1222. atomic_read(&fb->base.refcount.refcount));
  1223. describe_obj(m, fb->obj);
  1224. seq_putc(m, '\n');
  1225. }
  1226. mutex_unlock(&dev->mode_config.fb_lock);
  1227. return 0;
  1228. }
  1229. static int i915_context_status(struct seq_file *m, void *unused)
  1230. {
  1231. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1232. struct drm_device *dev = node->minor->dev;
  1233. drm_i915_private_t *dev_priv = dev->dev_private;
  1234. struct intel_ring_buffer *ring;
  1235. struct i915_hw_context *ctx;
  1236. int ret, i;
  1237. ret = mutex_lock_interruptible(&dev->mode_config.mutex);
  1238. if (ret)
  1239. return ret;
  1240. if (dev_priv->ips.pwrctx) {
  1241. seq_puts(m, "power context ");
  1242. describe_obj(m, dev_priv->ips.pwrctx);
  1243. seq_putc(m, '\n');
  1244. }
  1245. if (dev_priv->ips.renderctx) {
  1246. seq_puts(m, "render context ");
  1247. describe_obj(m, dev_priv->ips.renderctx);
  1248. seq_putc(m, '\n');
  1249. }
  1250. list_for_each_entry(ctx, &dev_priv->context_list, link) {
  1251. seq_puts(m, "HW context ");
  1252. describe_ctx(m, ctx);
  1253. for_each_ring(ring, dev_priv, i)
  1254. if (ring->default_context == ctx)
  1255. seq_printf(m, "(default context %s) ", ring->name);
  1256. describe_obj(m, ctx->obj);
  1257. seq_putc(m, '\n');
  1258. }
  1259. mutex_unlock(&dev->mode_config.mutex);
  1260. return 0;
  1261. }
  1262. static int i915_gen6_forcewake_count_info(struct seq_file *m, void *data)
  1263. {
  1264. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1265. struct drm_device *dev = node->minor->dev;
  1266. struct drm_i915_private *dev_priv = dev->dev_private;
  1267. unsigned forcewake_count;
  1268. spin_lock_irq(&dev_priv->uncore.lock);
  1269. forcewake_count = dev_priv->uncore.forcewake_count;
  1270. spin_unlock_irq(&dev_priv->uncore.lock);
  1271. seq_printf(m, "forcewake count = %u\n", forcewake_count);
  1272. return 0;
  1273. }
  1274. static const char *swizzle_string(unsigned swizzle)
  1275. {
  1276. switch (swizzle) {
  1277. case I915_BIT_6_SWIZZLE_NONE:
  1278. return "none";
  1279. case I915_BIT_6_SWIZZLE_9:
  1280. return "bit9";
  1281. case I915_BIT_6_SWIZZLE_9_10:
  1282. return "bit9/bit10";
  1283. case I915_BIT_6_SWIZZLE_9_11:
  1284. return "bit9/bit11";
  1285. case I915_BIT_6_SWIZZLE_9_10_11:
  1286. return "bit9/bit10/bit11";
  1287. case I915_BIT_6_SWIZZLE_9_17:
  1288. return "bit9/bit17";
  1289. case I915_BIT_6_SWIZZLE_9_10_17:
  1290. return "bit9/bit10/bit17";
  1291. case I915_BIT_6_SWIZZLE_UNKNOWN:
  1292. return "unknown";
  1293. }
  1294. return "bug";
  1295. }
  1296. static int i915_swizzle_info(struct seq_file *m, void *data)
  1297. {
  1298. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1299. struct drm_device *dev = node->minor->dev;
  1300. struct drm_i915_private *dev_priv = dev->dev_private;
  1301. int ret;
  1302. ret = mutex_lock_interruptible(&dev->struct_mutex);
  1303. if (ret)
  1304. return ret;
  1305. seq_printf(m, "bit6 swizzle for X-tiling = %s\n",
  1306. swizzle_string(dev_priv->mm.bit_6_swizzle_x));
  1307. seq_printf(m, "bit6 swizzle for Y-tiling = %s\n",
  1308. swizzle_string(dev_priv->mm.bit_6_swizzle_y));
  1309. if (IS_GEN3(dev) || IS_GEN4(dev)) {
  1310. seq_printf(m, "DDC = 0x%08x\n",
  1311. I915_READ(DCC));
  1312. seq_printf(m, "C0DRB3 = 0x%04x\n",
  1313. I915_READ16(C0DRB3));
  1314. seq_printf(m, "C1DRB3 = 0x%04x\n",
  1315. I915_READ16(C1DRB3));
  1316. } else if (IS_GEN6(dev) || IS_GEN7(dev)) {
  1317. seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n",
  1318. I915_READ(MAD_DIMM_C0));
  1319. seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n",
  1320. I915_READ(MAD_DIMM_C1));
  1321. seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n",
  1322. I915_READ(MAD_DIMM_C2));
  1323. seq_printf(m, "TILECTL = 0x%08x\n",
  1324. I915_READ(TILECTL));
  1325. seq_printf(m, "ARB_MODE = 0x%08x\n",
  1326. I915_READ(ARB_MODE));
  1327. seq_printf(m, "DISP_ARB_CTL = 0x%08x\n",
  1328. I915_READ(DISP_ARB_CTL));
  1329. }
  1330. mutex_unlock(&dev->struct_mutex);
  1331. return 0;
  1332. }
  1333. static int i915_ppgtt_info(struct seq_file *m, void *data)
  1334. {
  1335. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1336. struct drm_device *dev = node->minor->dev;
  1337. struct drm_i915_private *dev_priv = dev->dev_private;
  1338. struct intel_ring_buffer *ring;
  1339. int i, ret;
  1340. ret = mutex_lock_interruptible(&dev->struct_mutex);
  1341. if (ret)
  1342. return ret;
  1343. if (INTEL_INFO(dev)->gen == 6)
  1344. seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE));
  1345. for_each_ring(ring, dev_priv, i) {
  1346. seq_printf(m, "%s\n", ring->name);
  1347. if (INTEL_INFO(dev)->gen == 7)
  1348. seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring)));
  1349. seq_printf(m, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring)));
  1350. seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring)));
  1351. seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring)));
  1352. }
  1353. if (dev_priv->mm.aliasing_ppgtt) {
  1354. struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
  1355. seq_puts(m, "aliasing PPGTT:\n");
  1356. seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd_offset);
  1357. }
  1358. seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK));
  1359. mutex_unlock(&dev->struct_mutex);
  1360. return 0;
  1361. }
  1362. static int i915_dpio_info(struct seq_file *m, void *data)
  1363. {
  1364. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1365. struct drm_device *dev = node->minor->dev;
  1366. struct drm_i915_private *dev_priv = dev->dev_private;
  1367. int ret;
  1368. if (!IS_VALLEYVIEW(dev)) {
  1369. seq_puts(m, "unsupported\n");
  1370. return 0;
  1371. }
  1372. ret = mutex_lock_interruptible(&dev_priv->dpio_lock);
  1373. if (ret)
  1374. return ret;
  1375. seq_printf(m, "DPIO_CTL: 0x%08x\n", I915_READ(DPIO_CTL));
  1376. seq_printf(m, "DPIO_DIV_A: 0x%08x\n",
  1377. vlv_dpio_read(dev_priv, PIPE_A, _DPIO_DIV_A));
  1378. seq_printf(m, "DPIO_DIV_B: 0x%08x\n",
  1379. vlv_dpio_read(dev_priv, PIPE_A, _DPIO_DIV_B));
  1380. seq_printf(m, "DPIO_REFSFR_A: 0x%08x\n",
  1381. vlv_dpio_read(dev_priv, PIPE_A, _DPIO_REFSFR_A));
  1382. seq_printf(m, "DPIO_REFSFR_B: 0x%08x\n",
  1383. vlv_dpio_read(dev_priv, PIPE_A, _DPIO_REFSFR_B));
  1384. seq_printf(m, "DPIO_CORE_CLK_A: 0x%08x\n",
  1385. vlv_dpio_read(dev_priv, PIPE_A, _DPIO_CORE_CLK_A));
  1386. seq_printf(m, "DPIO_CORE_CLK_B: 0x%08x\n",
  1387. vlv_dpio_read(dev_priv, PIPE_A, _DPIO_CORE_CLK_B));
  1388. seq_printf(m, "DPIO_LPF_COEFF_A: 0x%08x\n",
  1389. vlv_dpio_read(dev_priv, PIPE_A, _DPIO_LPF_COEFF_A));
  1390. seq_printf(m, "DPIO_LPF_COEFF_B: 0x%08x\n",
  1391. vlv_dpio_read(dev_priv, PIPE_A, _DPIO_LPF_COEFF_B));
  1392. seq_printf(m, "DPIO_FASTCLK_DISABLE: 0x%08x\n",
  1393. vlv_dpio_read(dev_priv, PIPE_A, DPIO_FASTCLK_DISABLE));
  1394. mutex_unlock(&dev_priv->dpio_lock);
  1395. return 0;
  1396. }
  1397. static int i915_llc(struct seq_file *m, void *data)
  1398. {
  1399. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1400. struct drm_device *dev = node->minor->dev;
  1401. struct drm_i915_private *dev_priv = dev->dev_private;
  1402. /* Size calculation for LLC is a bit of a pain. Ignore for now. */
  1403. seq_printf(m, "LLC: %s\n", yesno(HAS_LLC(dev)));
  1404. seq_printf(m, "eLLC: %zuMB\n", dev_priv->ellc_size);
  1405. return 0;
  1406. }
  1407. static int i915_edp_psr_status(struct seq_file *m, void *data)
  1408. {
  1409. struct drm_info_node *node = m->private;
  1410. struct drm_device *dev = node->minor->dev;
  1411. struct drm_i915_private *dev_priv = dev->dev_private;
  1412. u32 psrstat, psrperf;
  1413. if (!HAS_PSR(dev)) {
  1414. seq_puts(m, "PSR not supported on this platform\n");
  1415. } else if (HAS_PSR(dev) &&
  1416. I915_READ(EDP_PSR_CTL(dev)) & EDP_PSR_ENABLE) {
  1417. seq_puts(m, "PSR enabled\n");
  1418. } else {
  1419. seq_puts(m, "PSR disabled: ");
  1420. switch (dev_priv->no_psr_reason) {
  1421. case PSR_NO_SOURCE:
  1422. seq_puts(m, "not supported on this platform");
  1423. break;
  1424. case PSR_NO_SINK:
  1425. seq_puts(m, "not supported by panel");
  1426. break;
  1427. case PSR_MODULE_PARAM:
  1428. seq_puts(m, "disabled by flag");
  1429. break;
  1430. case PSR_CRTC_NOT_ACTIVE:
  1431. seq_puts(m, "crtc not active");
  1432. break;
  1433. case PSR_PWR_WELL_ENABLED:
  1434. seq_puts(m, "power well enabled");
  1435. break;
  1436. case PSR_NOT_TILED:
  1437. seq_puts(m, "not tiled");
  1438. break;
  1439. case PSR_SPRITE_ENABLED:
  1440. seq_puts(m, "sprite enabled");
  1441. break;
  1442. case PSR_S3D_ENABLED:
  1443. seq_puts(m, "stereo 3d enabled");
  1444. break;
  1445. case PSR_INTERLACED_ENABLED:
  1446. seq_puts(m, "interlaced enabled");
  1447. break;
  1448. case PSR_HSW_NOT_DDIA:
  1449. seq_puts(m, "HSW ties PSR to DDI A (eDP)");
  1450. break;
  1451. default:
  1452. seq_puts(m, "unknown reason");
  1453. }
  1454. seq_puts(m, "\n");
  1455. return 0;
  1456. }
  1457. psrstat = I915_READ(EDP_PSR_STATUS_CTL(dev));
  1458. seq_puts(m, "PSR Current State: ");
  1459. switch (psrstat & EDP_PSR_STATUS_STATE_MASK) {
  1460. case EDP_PSR_STATUS_STATE_IDLE:
  1461. seq_puts(m, "Reset state\n");
  1462. break;
  1463. case EDP_PSR_STATUS_STATE_SRDONACK:
  1464. seq_puts(m, "Wait for TG/Stream to send on frame of data after SRD conditions are met\n");
  1465. break;
  1466. case EDP_PSR_STATUS_STATE_SRDENT:
  1467. seq_puts(m, "SRD entry\n");
  1468. break;
  1469. case EDP_PSR_STATUS_STATE_BUFOFF:
  1470. seq_puts(m, "Wait for buffer turn off\n");
  1471. break;
  1472. case EDP_PSR_STATUS_STATE_BUFON:
  1473. seq_puts(m, "Wait for buffer turn on\n");
  1474. break;
  1475. case EDP_PSR_STATUS_STATE_AUXACK:
  1476. seq_puts(m, "Wait for AUX to acknowledge on SRD exit\n");
  1477. break;
  1478. case EDP_PSR_STATUS_STATE_SRDOFFACK:
  1479. seq_puts(m, "Wait for TG/Stream to acknowledge the SRD VDM exit\n");
  1480. break;
  1481. default:
  1482. seq_puts(m, "Unknown\n");
  1483. break;
  1484. }
  1485. seq_puts(m, "Link Status: ");
  1486. switch (psrstat & EDP_PSR_STATUS_LINK_MASK) {
  1487. case EDP_PSR_STATUS_LINK_FULL_OFF:
  1488. seq_puts(m, "Link is fully off\n");
  1489. break;
  1490. case EDP_PSR_STATUS_LINK_FULL_ON:
  1491. seq_puts(m, "Link is fully on\n");
  1492. break;
  1493. case EDP_PSR_STATUS_LINK_STANDBY:
  1494. seq_puts(m, "Link is in standby\n");
  1495. break;
  1496. default:
  1497. seq_puts(m, "Unknown\n");
  1498. break;
  1499. }
  1500. seq_printf(m, "PSR Entry Count: %u\n",
  1501. psrstat >> EDP_PSR_STATUS_COUNT_SHIFT &
  1502. EDP_PSR_STATUS_COUNT_MASK);
  1503. seq_printf(m, "Max Sleep Timer Counter: %u\n",
  1504. psrstat >> EDP_PSR_STATUS_MAX_SLEEP_TIMER_SHIFT &
  1505. EDP_PSR_STATUS_MAX_SLEEP_TIMER_MASK);
  1506. seq_printf(m, "Had AUX error: %s\n",
  1507. yesno(psrstat & EDP_PSR_STATUS_AUX_ERROR));
  1508. seq_printf(m, "Sending AUX: %s\n",
  1509. yesno(psrstat & EDP_PSR_STATUS_AUX_SENDING));
  1510. seq_printf(m, "Sending Idle: %s\n",
  1511. yesno(psrstat & EDP_PSR_STATUS_SENDING_IDLE));
  1512. seq_printf(m, "Sending TP2 TP3: %s\n",
  1513. yesno(psrstat & EDP_PSR_STATUS_SENDING_TP2_TP3));
  1514. seq_printf(m, "Sending TP1: %s\n",
  1515. yesno(psrstat & EDP_PSR_STATUS_SENDING_TP1));
  1516. seq_printf(m, "Idle Count: %u\n",
  1517. psrstat & EDP_PSR_STATUS_IDLE_MASK);
  1518. psrperf = (I915_READ(EDP_PSR_PERF_CNT(dev))) & EDP_PSR_PERF_CNT_MASK;
  1519. seq_printf(m, "Performance Counter: %u\n", psrperf);
  1520. return 0;
  1521. }
  1522. static int i915_energy_uJ(struct seq_file *m, void *data)
  1523. {
  1524. struct drm_info_node *node = m->private;
  1525. struct drm_device *dev = node->minor->dev;
  1526. struct drm_i915_private *dev_priv = dev->dev_private;
  1527. u64 power;
  1528. u32 units;
  1529. if (INTEL_INFO(dev)->gen < 6)
  1530. return -ENODEV;
  1531. rdmsrl(MSR_RAPL_POWER_UNIT, power);
  1532. power = (power & 0x1f00) >> 8;
  1533. units = 1000000 / (1 << power); /* convert to uJ */
  1534. power = I915_READ(MCH_SECP_NRG_STTS);
  1535. power *= units;
  1536. seq_printf(m, "%llu", (long long unsigned)power);
  1537. return 0;
  1538. }
  1539. static int i915_pc8_status(struct seq_file *m, void *unused)
  1540. {
  1541. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1542. struct drm_device *dev = node->minor->dev;
  1543. struct drm_i915_private *dev_priv = dev->dev_private;
  1544. if (!IS_HASWELL(dev)) {
  1545. seq_puts(m, "not supported\n");
  1546. return 0;
  1547. }
  1548. mutex_lock(&dev_priv->pc8.lock);
  1549. seq_printf(m, "Requirements met: %s\n",
  1550. yesno(dev_priv->pc8.requirements_met));
  1551. seq_printf(m, "GPU idle: %s\n", yesno(dev_priv->pc8.gpu_idle));
  1552. seq_printf(m, "Disable count: %d\n", dev_priv->pc8.disable_count);
  1553. seq_printf(m, "IRQs disabled: %s\n",
  1554. yesno(dev_priv->pc8.irqs_disabled));
  1555. seq_printf(m, "Enabled: %s\n", yesno(dev_priv->pc8.enabled));
  1556. mutex_unlock(&dev_priv->pc8.lock);
  1557. return 0;
  1558. }
  1559. static int
  1560. i915_wedged_get(void *data, u64 *val)
  1561. {
  1562. struct drm_device *dev = data;
  1563. drm_i915_private_t *dev_priv = dev->dev_private;
  1564. *val = atomic_read(&dev_priv->gpu_error.reset_counter);
  1565. return 0;
  1566. }
  1567. static int
  1568. i915_wedged_set(void *data, u64 val)
  1569. {
  1570. struct drm_device *dev = data;
  1571. DRM_INFO("Manually setting wedged to %llu\n", val);
  1572. i915_handle_error(dev, val);
  1573. return 0;
  1574. }
  1575. DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops,
  1576. i915_wedged_get, i915_wedged_set,
  1577. "%llu\n");
  1578. static int
  1579. i915_ring_stop_get(void *data, u64 *val)
  1580. {
  1581. struct drm_device *dev = data;
  1582. drm_i915_private_t *dev_priv = dev->dev_private;
  1583. *val = dev_priv->gpu_error.stop_rings;
  1584. return 0;
  1585. }
  1586. static int
  1587. i915_ring_stop_set(void *data, u64 val)
  1588. {
  1589. struct drm_device *dev = data;
  1590. struct drm_i915_private *dev_priv = dev->dev_private;
  1591. int ret;
  1592. DRM_DEBUG_DRIVER("Stopping rings 0x%08llx\n", val);
  1593. ret = mutex_lock_interruptible(&dev->struct_mutex);
  1594. if (ret)
  1595. return ret;
  1596. dev_priv->gpu_error.stop_rings = val;
  1597. mutex_unlock(&dev->struct_mutex);
  1598. return 0;
  1599. }
  1600. DEFINE_SIMPLE_ATTRIBUTE(i915_ring_stop_fops,
  1601. i915_ring_stop_get, i915_ring_stop_set,
  1602. "0x%08llx\n");
  1603. #define DROP_UNBOUND 0x1
  1604. #define DROP_BOUND 0x2
  1605. #define DROP_RETIRE 0x4
  1606. #define DROP_ACTIVE 0x8
  1607. #define DROP_ALL (DROP_UNBOUND | \
  1608. DROP_BOUND | \
  1609. DROP_RETIRE | \
  1610. DROP_ACTIVE)
  1611. static int
  1612. i915_drop_caches_get(void *data, u64 *val)
  1613. {
  1614. *val = DROP_ALL;
  1615. return 0;
  1616. }
  1617. static int
  1618. i915_drop_caches_set(void *data, u64 val)
  1619. {
  1620. struct drm_device *dev = data;
  1621. struct drm_i915_private *dev_priv = dev->dev_private;
  1622. struct drm_i915_gem_object *obj, *next;
  1623. struct i915_address_space *vm;
  1624. struct i915_vma *vma, *x;
  1625. int ret;
  1626. DRM_DEBUG_DRIVER("Dropping caches: 0x%08llx\n", val);
  1627. /* No need to check and wait for gpu resets, only libdrm auto-restarts
  1628. * on ioctls on -EAGAIN. */
  1629. ret = mutex_lock_interruptible(&dev->struct_mutex);
  1630. if (ret)
  1631. return ret;
  1632. if (val & DROP_ACTIVE) {
  1633. ret = i915_gpu_idle(dev);
  1634. if (ret)
  1635. goto unlock;
  1636. }
  1637. if (val & (DROP_RETIRE | DROP_ACTIVE))
  1638. i915_gem_retire_requests(dev);
  1639. if (val & DROP_BOUND) {
  1640. list_for_each_entry(vm, &dev_priv->vm_list, global_link) {
  1641. list_for_each_entry_safe(vma, x, &vm->inactive_list,
  1642. mm_list) {
  1643. if (vma->obj->pin_count)
  1644. continue;
  1645. ret = i915_vma_unbind(vma);
  1646. if (ret)
  1647. goto unlock;
  1648. }
  1649. }
  1650. }
  1651. if (val & DROP_UNBOUND) {
  1652. list_for_each_entry_safe(obj, next, &dev_priv->mm.unbound_list,
  1653. global_list)
  1654. if (obj->pages_pin_count == 0) {
  1655. ret = i915_gem_object_put_pages(obj);
  1656. if (ret)
  1657. goto unlock;
  1658. }
  1659. }
  1660. unlock:
  1661. mutex_unlock(&dev->struct_mutex);
  1662. return ret;
  1663. }
  1664. DEFINE_SIMPLE_ATTRIBUTE(i915_drop_caches_fops,
  1665. i915_drop_caches_get, i915_drop_caches_set,
  1666. "0x%08llx\n");
  1667. static int
  1668. i915_max_freq_get(void *data, u64 *val)
  1669. {
  1670. struct drm_device *dev = data;
  1671. drm_i915_private_t *dev_priv = dev->dev_private;
  1672. int ret;
  1673. if (!(IS_GEN6(dev) || IS_GEN7(dev)))
  1674. return -ENODEV;
  1675. ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
  1676. if (ret)
  1677. return ret;
  1678. if (IS_VALLEYVIEW(dev))
  1679. *val = vlv_gpu_freq(dev_priv->mem_freq,
  1680. dev_priv->rps.max_delay);
  1681. else
  1682. *val = dev_priv->rps.max_delay * GT_FREQUENCY_MULTIPLIER;
  1683. mutex_unlock(&dev_priv->rps.hw_lock);
  1684. return 0;
  1685. }
  1686. static int
  1687. i915_max_freq_set(void *data, u64 val)
  1688. {
  1689. struct drm_device *dev = data;
  1690. struct drm_i915_private *dev_priv = dev->dev_private;
  1691. int ret;
  1692. if (!(IS_GEN6(dev) || IS_GEN7(dev)))
  1693. return -ENODEV;
  1694. DRM_DEBUG_DRIVER("Manually setting max freq to %llu\n", val);
  1695. ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
  1696. if (ret)
  1697. return ret;
  1698. /*
  1699. * Turbo will still be enabled, but won't go above the set value.
  1700. */
  1701. if (IS_VALLEYVIEW(dev)) {
  1702. val = vlv_freq_opcode(dev_priv->mem_freq, val);
  1703. dev_priv->rps.max_delay = val;
  1704. gen6_set_rps(dev, val);
  1705. } else {
  1706. do_div(val, GT_FREQUENCY_MULTIPLIER);
  1707. dev_priv->rps.max_delay = val;
  1708. gen6_set_rps(dev, val);
  1709. }
  1710. mutex_unlock(&dev_priv->rps.hw_lock);
  1711. return 0;
  1712. }
  1713. DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops,
  1714. i915_max_freq_get, i915_max_freq_set,
  1715. "%llu\n");
  1716. static int
  1717. i915_min_freq_get(void *data, u64 *val)
  1718. {
  1719. struct drm_device *dev = data;
  1720. drm_i915_private_t *dev_priv = dev->dev_private;
  1721. int ret;
  1722. if (!(IS_GEN6(dev) || IS_GEN7(dev)))
  1723. return -ENODEV;
  1724. ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
  1725. if (ret)
  1726. return ret;
  1727. if (IS_VALLEYVIEW(dev))
  1728. *val = vlv_gpu_freq(dev_priv->mem_freq,
  1729. dev_priv->rps.min_delay);
  1730. else
  1731. *val = dev_priv->rps.min_delay * GT_FREQUENCY_MULTIPLIER;
  1732. mutex_unlock(&dev_priv->rps.hw_lock);
  1733. return 0;
  1734. }
  1735. static int
  1736. i915_min_freq_set(void *data, u64 val)
  1737. {
  1738. struct drm_device *dev = data;
  1739. struct drm_i915_private *dev_priv = dev->dev_private;
  1740. int ret;
  1741. if (!(IS_GEN6(dev) || IS_GEN7(dev)))
  1742. return -ENODEV;
  1743. DRM_DEBUG_DRIVER("Manually setting min freq to %llu\n", val);
  1744. ret = mutex_lock_interruptible(&dev_priv->rps.hw_lock);
  1745. if (ret)
  1746. return ret;
  1747. /*
  1748. * Turbo will still be enabled, but won't go below the set value.
  1749. */
  1750. if (IS_VALLEYVIEW(dev)) {
  1751. val = vlv_freq_opcode(dev_priv->mem_freq, val);
  1752. dev_priv->rps.min_delay = val;
  1753. valleyview_set_rps(dev, val);
  1754. } else {
  1755. do_div(val, GT_FREQUENCY_MULTIPLIER);
  1756. dev_priv->rps.min_delay = val;
  1757. gen6_set_rps(dev, val);
  1758. }
  1759. mutex_unlock(&dev_priv->rps.hw_lock);
  1760. return 0;
  1761. }
  1762. DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops,
  1763. i915_min_freq_get, i915_min_freq_set,
  1764. "%llu\n");
  1765. static int
  1766. i915_cache_sharing_get(void *data, u64 *val)
  1767. {
  1768. struct drm_device *dev = data;
  1769. drm_i915_private_t *dev_priv = dev->dev_private;
  1770. u32 snpcr;
  1771. int ret;
  1772. if (!(IS_GEN6(dev) || IS_GEN7(dev)))
  1773. return -ENODEV;
  1774. ret = mutex_lock_interruptible(&dev->struct_mutex);
  1775. if (ret)
  1776. return ret;
  1777. snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
  1778. mutex_unlock(&dev_priv->dev->struct_mutex);
  1779. *val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT;
  1780. return 0;
  1781. }
  1782. static int
  1783. i915_cache_sharing_set(void *data, u64 val)
  1784. {
  1785. struct drm_device *dev = data;
  1786. struct drm_i915_private *dev_priv = dev->dev_private;
  1787. u32 snpcr;
  1788. if (!(IS_GEN6(dev) || IS_GEN7(dev)))
  1789. return -ENODEV;
  1790. if (val > 3)
  1791. return -EINVAL;
  1792. DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val);
  1793. /* Update the cache sharing policy here as well */
  1794. snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
  1795. snpcr &= ~GEN6_MBC_SNPCR_MASK;
  1796. snpcr |= (val << GEN6_MBC_SNPCR_SHIFT);
  1797. I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr);
  1798. return 0;
  1799. }
  1800. DEFINE_SIMPLE_ATTRIBUTE(i915_cache_sharing_fops,
  1801. i915_cache_sharing_get, i915_cache_sharing_set,
  1802. "%llu\n");
  1803. /* As the drm_debugfs_init() routines are called before dev->dev_private is
  1804. * allocated we need to hook into the minor for release. */
  1805. static int
  1806. drm_add_fake_info_node(struct drm_minor *minor,
  1807. struct dentry *ent,
  1808. const void *key)
  1809. {
  1810. struct drm_info_node *node;
  1811. node = kmalloc(sizeof(*node), GFP_KERNEL);
  1812. if (node == NULL) {
  1813. debugfs_remove(ent);
  1814. return -ENOMEM;
  1815. }
  1816. node->minor = minor;
  1817. node->dent = ent;
  1818. node->info_ent = (void *) key;
  1819. mutex_lock(&minor->debugfs_lock);
  1820. list_add(&node->list, &minor->debugfs_list);
  1821. mutex_unlock(&minor->debugfs_lock);
  1822. return 0;
  1823. }
  1824. static int i915_forcewake_open(struct inode *inode, struct file *file)
  1825. {
  1826. struct drm_device *dev = inode->i_private;
  1827. struct drm_i915_private *dev_priv = dev->dev_private;
  1828. if (INTEL_INFO(dev)->gen < 6)
  1829. return 0;
  1830. gen6_gt_force_wake_get(dev_priv);
  1831. return 0;
  1832. }
  1833. static int i915_forcewake_release(struct inode *inode, struct file *file)
  1834. {
  1835. struct drm_device *dev = inode->i_private;
  1836. struct drm_i915_private *dev_priv = dev->dev_private;
  1837. if (INTEL_INFO(dev)->gen < 6)
  1838. return 0;
  1839. gen6_gt_force_wake_put(dev_priv);
  1840. return 0;
  1841. }
  1842. static const struct file_operations i915_forcewake_fops = {
  1843. .owner = THIS_MODULE,
  1844. .open = i915_forcewake_open,
  1845. .release = i915_forcewake_release,
  1846. };
  1847. static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor)
  1848. {
  1849. struct drm_device *dev = minor->dev;
  1850. struct dentry *ent;
  1851. ent = debugfs_create_file("i915_forcewake_user",
  1852. S_IRUSR,
  1853. root, dev,
  1854. &i915_forcewake_fops);
  1855. if (IS_ERR(ent))
  1856. return PTR_ERR(ent);
  1857. return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops);
  1858. }
  1859. static int i915_debugfs_create(struct dentry *root,
  1860. struct drm_minor *minor,
  1861. const char *name,
  1862. const struct file_operations *fops)
  1863. {
  1864. struct drm_device *dev = minor->dev;
  1865. struct dentry *ent;
  1866. ent = debugfs_create_file(name,
  1867. S_IRUGO | S_IWUSR,
  1868. root, dev,
  1869. fops);
  1870. if (IS_ERR(ent))
  1871. return PTR_ERR(ent);
  1872. return drm_add_fake_info_node(minor, ent, fops);
  1873. }
  1874. static struct drm_info_list i915_debugfs_list[] = {
  1875. {"i915_capabilities", i915_capabilities, 0},
  1876. {"i915_gem_objects", i915_gem_object_info, 0},
  1877. {"i915_gem_gtt", i915_gem_gtt_info, 0},
  1878. {"i915_gem_pinned", i915_gem_gtt_info, 0, (void *) PINNED_LIST},
  1879. {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST},
  1880. {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST},
  1881. {"i915_gem_stolen", i915_gem_stolen_list_info },
  1882. {"i915_gem_pageflip", i915_gem_pageflip_info, 0},
  1883. {"i915_gem_request", i915_gem_request_info, 0},
  1884. {"i915_gem_seqno", i915_gem_seqno_info, 0},
  1885. {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0},
  1886. {"i915_gem_interrupt", i915_interrupt_info, 0},
  1887. {"i915_gem_hws", i915_hws_info, 0, (void *)RCS},
  1888. {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS},
  1889. {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS},
  1890. {"i915_gem_hws_vebox", i915_hws_info, 0, (void *)VECS},
  1891. {"i915_rstdby_delays", i915_rstdby_delays, 0},
  1892. {"i915_cur_delayinfo", i915_cur_delayinfo, 0},
  1893. {"i915_delayfreq_table", i915_delayfreq_table, 0},
  1894. {"i915_inttoext_table", i915_inttoext_table, 0},
  1895. {"i915_drpc_info", i915_drpc_info, 0},
  1896. {"i915_emon_status", i915_emon_status, 0},
  1897. {"i915_ring_freq_table", i915_ring_freq_table, 0},
  1898. {"i915_gfxec", i915_gfxec, 0},
  1899. {"i915_fbc_status", i915_fbc_status, 0},
  1900. {"i915_ips_status", i915_ips_status, 0},
  1901. {"i915_sr_status", i915_sr_status, 0},
  1902. {"i915_opregion", i915_opregion, 0},
  1903. {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
  1904. {"i915_context_status", i915_context_status, 0},
  1905. {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0},
  1906. {"i915_swizzle_info", i915_swizzle_info, 0},
  1907. {"i915_ppgtt_info", i915_ppgtt_info, 0},
  1908. {"i915_dpio", i915_dpio_info, 0},
  1909. {"i915_llc", i915_llc, 0},
  1910. {"i915_edp_psr_status", i915_edp_psr_status, 0},
  1911. {"i915_energy_uJ", i915_energy_uJ, 0},
  1912. {"i915_pc8_status", i915_pc8_status, 0},
  1913. };
  1914. #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
  1915. static struct i915_debugfs_files {
  1916. const char *name;
  1917. const struct file_operations *fops;
  1918. } i915_debugfs_files[] = {
  1919. {"i915_wedged", &i915_wedged_fops},
  1920. {"i915_max_freq", &i915_max_freq_fops},
  1921. {"i915_min_freq", &i915_min_freq_fops},
  1922. {"i915_cache_sharing", &i915_cache_sharing_fops},
  1923. {"i915_ring_stop", &i915_ring_stop_fops},
  1924. {"i915_gem_drop_caches", &i915_drop_caches_fops},
  1925. {"i915_error_state", &i915_error_state_fops},
  1926. {"i915_next_seqno", &i915_next_seqno_fops},
  1927. };
  1928. int i915_debugfs_init(struct drm_minor *minor)
  1929. {
  1930. int ret, i;
  1931. ret = i915_forcewake_create(minor->debugfs_root, minor);
  1932. if (ret)
  1933. return ret;
  1934. for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
  1935. ret = i915_debugfs_create(minor->debugfs_root, minor,
  1936. i915_debugfs_files[i].name,
  1937. i915_debugfs_files[i].fops);
  1938. if (ret)
  1939. return ret;
  1940. }
  1941. return drm_debugfs_create_files(i915_debugfs_list,
  1942. I915_DEBUGFS_ENTRIES,
  1943. minor->debugfs_root, minor);
  1944. }
  1945. void i915_debugfs_cleanup(struct drm_minor *minor)
  1946. {
  1947. int i;
  1948. drm_debugfs_remove_files(i915_debugfs_list,
  1949. I915_DEBUGFS_ENTRIES, minor);
  1950. drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops,
  1951. 1, minor);
  1952. for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) {
  1953. struct drm_info_list *info_list =
  1954. (struct drm_info_list *) i915_debugfs_files[i].fops;
  1955. drm_debugfs_remove_files(info_list, 1, minor);
  1956. }
  1957. }
  1958. #endif /* CONFIG_DEBUG_FS */