i915_debugfs.c 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893
  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 <generated/utsrelease.h>
  33. #include "drmP.h"
  34. #include "drm.h"
  35. #include "intel_drv.h"
  36. #include "intel_ringbuffer.h"
  37. #include "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. FLUSHING_LIST,
  44. INACTIVE_LIST,
  45. PINNED_LIST,
  46. DEFERRED_FREE_LIST,
  47. };
  48. static const char *yesno(int v)
  49. {
  50. return v ? "yes" : "no";
  51. }
  52. static int i915_capabilities(struct seq_file *m, void *data)
  53. {
  54. struct drm_info_node *node = (struct drm_info_node *) m->private;
  55. struct drm_device *dev = node->minor->dev;
  56. const struct intel_device_info *info = INTEL_INFO(dev);
  57. seq_printf(m, "gen: %d\n", info->gen);
  58. seq_printf(m, "pch: %d\n", INTEL_PCH_TYPE(dev));
  59. #define B(x) seq_printf(m, #x ": %s\n", yesno(info->x))
  60. B(is_mobile);
  61. B(is_i85x);
  62. B(is_i915g);
  63. B(is_i945gm);
  64. B(is_g33);
  65. B(need_gfx_hws);
  66. B(is_g4x);
  67. B(is_pineview);
  68. B(is_broadwater);
  69. B(is_crestline);
  70. B(has_fbc);
  71. B(has_pipe_cxsr);
  72. B(has_hotplug);
  73. B(cursor_needs_physical);
  74. B(has_overlay);
  75. B(overlay_needs_physical);
  76. B(supports_tv);
  77. B(has_bsd_ring);
  78. B(has_blt_ring);
  79. B(has_llc);
  80. #undef B
  81. return 0;
  82. }
  83. static const char *get_pin_flag(struct drm_i915_gem_object *obj)
  84. {
  85. if (obj->user_pin_count > 0)
  86. return "P";
  87. else if (obj->pin_count > 0)
  88. return "p";
  89. else
  90. return " ";
  91. }
  92. static const char *get_tiling_flag(struct drm_i915_gem_object *obj)
  93. {
  94. switch (obj->tiling_mode) {
  95. default:
  96. case I915_TILING_NONE: return " ";
  97. case I915_TILING_X: return "X";
  98. case I915_TILING_Y: return "Y";
  99. }
  100. }
  101. static const char *cache_level_str(int type)
  102. {
  103. switch (type) {
  104. case I915_CACHE_NONE: return " uncached";
  105. case I915_CACHE_LLC: return " snooped (LLC)";
  106. case I915_CACHE_LLC_MLC: return " snooped (LLC+MLC)";
  107. default: return "";
  108. }
  109. }
  110. static void
  111. describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
  112. {
  113. seq_printf(m, "%pK: %s%s %8zdKiB %04x %04x %d %d%s%s%s",
  114. &obj->base,
  115. get_pin_flag(obj),
  116. get_tiling_flag(obj),
  117. obj->base.size / 1024,
  118. obj->base.read_domains,
  119. obj->base.write_domain,
  120. obj->last_rendering_seqno,
  121. obj->last_fenced_seqno,
  122. cache_level_str(obj->cache_level),
  123. obj->dirty ? " dirty" : "",
  124. obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");
  125. if (obj->base.name)
  126. seq_printf(m, " (name: %d)", obj->base.name);
  127. if (obj->fence_reg != I915_FENCE_REG_NONE)
  128. seq_printf(m, " (fence: %d)", obj->fence_reg);
  129. if (obj->gtt_space != NULL)
  130. seq_printf(m, " (gtt offset: %08x, size: %08x)",
  131. obj->gtt_offset, (unsigned int)obj->gtt_space->size);
  132. if (obj->pin_mappable || obj->fault_mappable) {
  133. char s[3], *t = s;
  134. if (obj->pin_mappable)
  135. *t++ = 'p';
  136. if (obj->fault_mappable)
  137. *t++ = 'f';
  138. *t = '\0';
  139. seq_printf(m, " (%s mappable)", s);
  140. }
  141. if (obj->ring != NULL)
  142. seq_printf(m, " (%s)", obj->ring->name);
  143. }
  144. static int i915_gem_object_list_info(struct seq_file *m, void *data)
  145. {
  146. struct drm_info_node *node = (struct drm_info_node *) m->private;
  147. uintptr_t list = (uintptr_t) node->info_ent->data;
  148. struct list_head *head;
  149. struct drm_device *dev = node->minor->dev;
  150. drm_i915_private_t *dev_priv = dev->dev_private;
  151. struct drm_i915_gem_object *obj;
  152. size_t total_obj_size, total_gtt_size;
  153. int count, ret;
  154. ret = mutex_lock_interruptible(&dev->struct_mutex);
  155. if (ret)
  156. return ret;
  157. switch (list) {
  158. case ACTIVE_LIST:
  159. seq_printf(m, "Active:\n");
  160. head = &dev_priv->mm.active_list;
  161. break;
  162. case INACTIVE_LIST:
  163. seq_printf(m, "Inactive:\n");
  164. head = &dev_priv->mm.inactive_list;
  165. break;
  166. case PINNED_LIST:
  167. seq_printf(m, "Pinned:\n");
  168. head = &dev_priv->mm.pinned_list;
  169. break;
  170. case FLUSHING_LIST:
  171. seq_printf(m, "Flushing:\n");
  172. head = &dev_priv->mm.flushing_list;
  173. break;
  174. case DEFERRED_FREE_LIST:
  175. seq_printf(m, "Deferred free:\n");
  176. head = &dev_priv->mm.deferred_free_list;
  177. break;
  178. default:
  179. mutex_unlock(&dev->struct_mutex);
  180. return -EINVAL;
  181. }
  182. total_obj_size = total_gtt_size = count = 0;
  183. list_for_each_entry(obj, head, mm_list) {
  184. seq_printf(m, " ");
  185. describe_obj(m, obj);
  186. seq_printf(m, "\n");
  187. total_obj_size += obj->base.size;
  188. total_gtt_size += obj->gtt_space->size;
  189. count++;
  190. }
  191. mutex_unlock(&dev->struct_mutex);
  192. seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n",
  193. count, total_obj_size, total_gtt_size);
  194. return 0;
  195. }
  196. #define count_objects(list, member) do { \
  197. list_for_each_entry(obj, list, member) { \
  198. size += obj->gtt_space->size; \
  199. ++count; \
  200. if (obj->map_and_fenceable) { \
  201. mappable_size += obj->gtt_space->size; \
  202. ++mappable_count; \
  203. } \
  204. } \
  205. } while (0)
  206. static int i915_gem_object_info(struct seq_file *m, void* data)
  207. {
  208. struct drm_info_node *node = (struct drm_info_node *) m->private;
  209. struct drm_device *dev = node->minor->dev;
  210. struct drm_i915_private *dev_priv = dev->dev_private;
  211. u32 count, mappable_count;
  212. size_t size, mappable_size;
  213. struct drm_i915_gem_object *obj;
  214. int ret;
  215. ret = mutex_lock_interruptible(&dev->struct_mutex);
  216. if (ret)
  217. return ret;
  218. seq_printf(m, "%u objects, %zu bytes\n",
  219. dev_priv->mm.object_count,
  220. dev_priv->mm.object_memory);
  221. size = count = mappable_size = mappable_count = 0;
  222. count_objects(&dev_priv->mm.gtt_list, gtt_list);
  223. seq_printf(m, "%u [%u] objects, %zu [%zu] bytes in gtt\n",
  224. count, mappable_count, size, mappable_size);
  225. size = count = mappable_size = mappable_count = 0;
  226. count_objects(&dev_priv->mm.active_list, mm_list);
  227. count_objects(&dev_priv->mm.flushing_list, mm_list);
  228. seq_printf(m, " %u [%u] active objects, %zu [%zu] bytes\n",
  229. count, mappable_count, size, mappable_size);
  230. size = count = mappable_size = mappable_count = 0;
  231. count_objects(&dev_priv->mm.pinned_list, mm_list);
  232. seq_printf(m, " %u [%u] pinned objects, %zu [%zu] bytes\n",
  233. count, mappable_count, size, mappable_size);
  234. size = count = mappable_size = mappable_count = 0;
  235. count_objects(&dev_priv->mm.inactive_list, mm_list);
  236. seq_printf(m, " %u [%u] inactive objects, %zu [%zu] bytes\n",
  237. count, mappable_count, size, mappable_size);
  238. size = count = mappable_size = mappable_count = 0;
  239. count_objects(&dev_priv->mm.deferred_free_list, mm_list);
  240. seq_printf(m, " %u [%u] freed objects, %zu [%zu] bytes\n",
  241. count, mappable_count, size, mappable_size);
  242. size = count = mappable_size = mappable_count = 0;
  243. list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) {
  244. if (obj->fault_mappable) {
  245. size += obj->gtt_space->size;
  246. ++count;
  247. }
  248. if (obj->pin_mappable) {
  249. mappable_size += obj->gtt_space->size;
  250. ++mappable_count;
  251. }
  252. }
  253. seq_printf(m, "%u pinned mappable objects, %zu bytes\n",
  254. mappable_count, mappable_size);
  255. seq_printf(m, "%u fault mappable objects, %zu bytes\n",
  256. count, size);
  257. seq_printf(m, "%zu [%zu] gtt total\n",
  258. dev_priv->mm.gtt_total, dev_priv->mm.mappable_gtt_total);
  259. mutex_unlock(&dev->struct_mutex);
  260. return 0;
  261. }
  262. static int i915_gem_gtt_info(struct seq_file *m, void* data)
  263. {
  264. struct drm_info_node *node = (struct drm_info_node *) m->private;
  265. struct drm_device *dev = node->minor->dev;
  266. struct drm_i915_private *dev_priv = dev->dev_private;
  267. struct drm_i915_gem_object *obj;
  268. size_t total_obj_size, total_gtt_size;
  269. int count, ret;
  270. ret = mutex_lock_interruptible(&dev->struct_mutex);
  271. if (ret)
  272. return ret;
  273. total_obj_size = total_gtt_size = count = 0;
  274. list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) {
  275. seq_printf(m, " ");
  276. describe_obj(m, obj);
  277. seq_printf(m, "\n");
  278. total_obj_size += obj->base.size;
  279. total_gtt_size += obj->gtt_space->size;
  280. count++;
  281. }
  282. mutex_unlock(&dev->struct_mutex);
  283. seq_printf(m, "Total %d objects, %zu bytes, %zu GTT size\n",
  284. count, total_obj_size, total_gtt_size);
  285. return 0;
  286. }
  287. static int i915_gem_pageflip_info(struct seq_file *m, void *data)
  288. {
  289. struct drm_info_node *node = (struct drm_info_node *) m->private;
  290. struct drm_device *dev = node->minor->dev;
  291. unsigned long flags;
  292. struct intel_crtc *crtc;
  293. list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) {
  294. const char pipe = pipe_name(crtc->pipe);
  295. const char plane = plane_name(crtc->plane);
  296. struct intel_unpin_work *work;
  297. spin_lock_irqsave(&dev->event_lock, flags);
  298. work = crtc->unpin_work;
  299. if (work == NULL) {
  300. seq_printf(m, "No flip due on pipe %c (plane %c)\n",
  301. pipe, plane);
  302. } else {
  303. if (atomic_read(&work->pending) < INTEL_FLIP_COMPLETE) {
  304. seq_printf(m, "Flip queued on pipe %c (plane %c)\n",
  305. pipe, plane);
  306. } else {
  307. seq_printf(m, "Flip pending (waiting for vsync) on pipe %c (plane %c)\n",
  308. pipe, plane);
  309. }
  310. if (work->enable_stall_check)
  311. seq_printf(m, "Stall check enabled, ");
  312. else
  313. seq_printf(m, "Stall check waiting for page flip ioctl, ");
  314. seq_printf(m, "%d prepares\n", atomic_read(&work->pending));
  315. if (work->old_fb_obj) {
  316. struct drm_i915_gem_object *obj = work->old_fb_obj;
  317. if (obj)
  318. seq_printf(m, "Old framebuffer gtt_offset 0x%08x\n", obj->gtt_offset);
  319. }
  320. if (work->pending_flip_obj) {
  321. struct drm_i915_gem_object *obj = work->pending_flip_obj;
  322. if (obj)
  323. seq_printf(m, "New framebuffer gtt_offset 0x%08x\n", obj->gtt_offset);
  324. }
  325. }
  326. spin_unlock_irqrestore(&dev->event_lock, flags);
  327. }
  328. return 0;
  329. }
  330. static int i915_gem_request_info(struct seq_file *m, void *data)
  331. {
  332. struct drm_info_node *node = (struct drm_info_node *) m->private;
  333. struct drm_device *dev = node->minor->dev;
  334. drm_i915_private_t *dev_priv = dev->dev_private;
  335. struct drm_i915_gem_request *gem_request;
  336. int ret, count;
  337. ret = mutex_lock_interruptible(&dev->struct_mutex);
  338. if (ret)
  339. return ret;
  340. count = 0;
  341. if (!list_empty(&dev_priv->ring[RCS].request_list)) {
  342. seq_printf(m, "Render requests:\n");
  343. list_for_each_entry(gem_request,
  344. &dev_priv->ring[RCS].request_list,
  345. list) {
  346. seq_printf(m, " %d @ %d\n",
  347. gem_request->seqno,
  348. (int) (jiffies - gem_request->emitted_jiffies));
  349. }
  350. count++;
  351. }
  352. if (!list_empty(&dev_priv->ring[VCS].request_list)) {
  353. seq_printf(m, "BSD requests:\n");
  354. list_for_each_entry(gem_request,
  355. &dev_priv->ring[VCS].request_list,
  356. list) {
  357. seq_printf(m, " %d @ %d\n",
  358. gem_request->seqno,
  359. (int) (jiffies - gem_request->emitted_jiffies));
  360. }
  361. count++;
  362. }
  363. if (!list_empty(&dev_priv->ring[BCS].request_list)) {
  364. seq_printf(m, "BLT requests:\n");
  365. list_for_each_entry(gem_request,
  366. &dev_priv->ring[BCS].request_list,
  367. list) {
  368. seq_printf(m, " %d @ %d\n",
  369. gem_request->seqno,
  370. (int) (jiffies - gem_request->emitted_jiffies));
  371. }
  372. count++;
  373. }
  374. mutex_unlock(&dev->struct_mutex);
  375. if (count == 0)
  376. seq_printf(m, "No requests\n");
  377. return 0;
  378. }
  379. static void i915_ring_seqno_info(struct seq_file *m,
  380. struct intel_ring_buffer *ring)
  381. {
  382. if (ring->get_seqno) {
  383. seq_printf(m, "Current sequence (%s): %d\n",
  384. ring->name, ring->get_seqno(ring));
  385. seq_printf(m, "Waiter sequence (%s): %d\n",
  386. ring->name, ring->waiting_seqno);
  387. seq_printf(m, "IRQ sequence (%s): %d\n",
  388. ring->name, ring->irq_seqno);
  389. }
  390. }
  391. static int i915_gem_seqno_info(struct seq_file *m, void *data)
  392. {
  393. struct drm_info_node *node = (struct drm_info_node *) m->private;
  394. struct drm_device *dev = node->minor->dev;
  395. drm_i915_private_t *dev_priv = dev->dev_private;
  396. int ret, i;
  397. ret = mutex_lock_interruptible(&dev->struct_mutex);
  398. if (ret)
  399. return ret;
  400. for (i = 0; i < I915_NUM_RINGS; i++)
  401. i915_ring_seqno_info(m, &dev_priv->ring[i]);
  402. mutex_unlock(&dev->struct_mutex);
  403. return 0;
  404. }
  405. static int i915_interrupt_info(struct seq_file *m, void *data)
  406. {
  407. struct drm_info_node *node = (struct drm_info_node *) m->private;
  408. struct drm_device *dev = node->minor->dev;
  409. drm_i915_private_t *dev_priv = dev->dev_private;
  410. int ret, i, pipe;
  411. ret = mutex_lock_interruptible(&dev->struct_mutex);
  412. if (ret)
  413. return ret;
  414. if (!HAS_PCH_SPLIT(dev)) {
  415. seq_printf(m, "Interrupt enable: %08x\n",
  416. I915_READ(IER));
  417. seq_printf(m, "Interrupt identity: %08x\n",
  418. I915_READ(IIR));
  419. seq_printf(m, "Interrupt mask: %08x\n",
  420. I915_READ(IMR));
  421. for_each_pipe(pipe)
  422. seq_printf(m, "Pipe %c stat: %08x\n",
  423. pipe_name(pipe),
  424. I915_READ(PIPESTAT(pipe)));
  425. } else {
  426. seq_printf(m, "North Display Interrupt enable: %08x\n",
  427. I915_READ(DEIER));
  428. seq_printf(m, "North Display Interrupt identity: %08x\n",
  429. I915_READ(DEIIR));
  430. seq_printf(m, "North Display Interrupt mask: %08x\n",
  431. I915_READ(DEIMR));
  432. seq_printf(m, "South Display Interrupt enable: %08x\n",
  433. I915_READ(SDEIER));
  434. seq_printf(m, "South Display Interrupt identity: %08x\n",
  435. I915_READ(SDEIIR));
  436. seq_printf(m, "South Display Interrupt mask: %08x\n",
  437. I915_READ(SDEIMR));
  438. seq_printf(m, "Graphics Interrupt enable: %08x\n",
  439. I915_READ(GTIER));
  440. seq_printf(m, "Graphics Interrupt identity: %08x\n",
  441. I915_READ(GTIIR));
  442. seq_printf(m, "Graphics Interrupt mask: %08x\n",
  443. I915_READ(GTIMR));
  444. }
  445. seq_printf(m, "Interrupts received: %d\n",
  446. atomic_read(&dev_priv->irq_received));
  447. for (i = 0; i < I915_NUM_RINGS; i++) {
  448. if (IS_GEN6(dev) || IS_GEN7(dev)) {
  449. seq_printf(m, "Graphics Interrupt mask (%s): %08x\n",
  450. dev_priv->ring[i].name,
  451. I915_READ_IMR(&dev_priv->ring[i]));
  452. }
  453. i915_ring_seqno_info(m, &dev_priv->ring[i]);
  454. }
  455. mutex_unlock(&dev->struct_mutex);
  456. return 0;
  457. }
  458. static int i915_gem_fence_regs_info(struct seq_file *m, void *data)
  459. {
  460. struct drm_info_node *node = (struct drm_info_node *) m->private;
  461. struct drm_device *dev = node->minor->dev;
  462. drm_i915_private_t *dev_priv = dev->dev_private;
  463. int i, ret;
  464. ret = mutex_lock_interruptible(&dev->struct_mutex);
  465. if (ret)
  466. return ret;
  467. seq_printf(m, "Reserved fences = %d\n", dev_priv->fence_reg_start);
  468. seq_printf(m, "Total fences = %d\n", dev_priv->num_fence_regs);
  469. for (i = 0; i < dev_priv->num_fence_regs; i++) {
  470. struct drm_i915_gem_object *obj = dev_priv->fence_regs[i].obj;
  471. seq_printf(m, "Fenced object[%2d] = ", i);
  472. if (obj == NULL)
  473. seq_printf(m, "unused");
  474. else
  475. describe_obj(m, obj);
  476. seq_printf(m, "\n");
  477. }
  478. mutex_unlock(&dev->struct_mutex);
  479. return 0;
  480. }
  481. static int i915_hws_info(struct seq_file *m, void *data)
  482. {
  483. struct drm_info_node *node = (struct drm_info_node *) m->private;
  484. struct drm_device *dev = node->minor->dev;
  485. drm_i915_private_t *dev_priv = dev->dev_private;
  486. struct intel_ring_buffer *ring;
  487. const volatile u32 __iomem *hws;
  488. int i;
  489. ring = &dev_priv->ring[(uintptr_t)node->info_ent->data];
  490. hws = (volatile u32 __iomem *)ring->status_page.page_addr;
  491. if (hws == NULL)
  492. return 0;
  493. for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) {
  494. seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
  495. i * 4,
  496. hws[i], hws[i + 1], hws[i + 2], hws[i + 3]);
  497. }
  498. return 0;
  499. }
  500. static int i915_ringbuffer_data(struct seq_file *m, void *data)
  501. {
  502. struct drm_info_node *node = (struct drm_info_node *) m->private;
  503. struct drm_device *dev = node->minor->dev;
  504. drm_i915_private_t *dev_priv = dev->dev_private;
  505. struct intel_ring_buffer *ring;
  506. int ret;
  507. ret = mutex_lock_interruptible(&dev->struct_mutex);
  508. if (ret)
  509. return ret;
  510. ring = &dev_priv->ring[(uintptr_t)node->info_ent->data];
  511. if (!ring->obj) {
  512. seq_printf(m, "No ringbuffer setup\n");
  513. } else {
  514. const u8 __iomem *virt = ring->virtual_start;
  515. uint32_t off;
  516. for (off = 0; off < ring->size; off += 4) {
  517. uint32_t *ptr = (uint32_t *)(virt + off);
  518. seq_printf(m, "%08x : %08x\n", off, *ptr);
  519. }
  520. }
  521. mutex_unlock(&dev->struct_mutex);
  522. return 0;
  523. }
  524. static int i915_ringbuffer_info(struct seq_file *m, void *data)
  525. {
  526. struct drm_info_node *node = (struct drm_info_node *) m->private;
  527. struct drm_device *dev = node->minor->dev;
  528. drm_i915_private_t *dev_priv = dev->dev_private;
  529. struct intel_ring_buffer *ring;
  530. int ret;
  531. ring = &dev_priv->ring[(uintptr_t)node->info_ent->data];
  532. if (ring->size == 0)
  533. return 0;
  534. ret = mutex_lock_interruptible(&dev->struct_mutex);
  535. if (ret)
  536. return ret;
  537. seq_printf(m, "Ring %s:\n", ring->name);
  538. seq_printf(m, " Head : %08x\n", I915_READ_HEAD(ring) & HEAD_ADDR);
  539. seq_printf(m, " Tail : %08x\n", I915_READ_TAIL(ring) & TAIL_ADDR);
  540. seq_printf(m, " Size : %08x\n", ring->size);
  541. seq_printf(m, " Active : %08x\n", intel_ring_get_active_head(ring));
  542. seq_printf(m, " NOPID : %08x\n", I915_READ_NOPID(ring));
  543. if (IS_GEN6(dev) || IS_GEN7(dev)) {
  544. seq_printf(m, " Sync 0 : %08x\n", I915_READ_SYNC_0(ring));
  545. seq_printf(m, " Sync 1 : %08x\n", I915_READ_SYNC_1(ring));
  546. }
  547. seq_printf(m, " Control : %08x\n", I915_READ_CTL(ring));
  548. seq_printf(m, " Start : %08x\n", I915_READ_START(ring));
  549. mutex_unlock(&dev->struct_mutex);
  550. return 0;
  551. }
  552. static const char *ring_str(int ring)
  553. {
  554. switch (ring) {
  555. case RCS: return "render";
  556. case VCS: return "bsd";
  557. case BCS: return "blt";
  558. default: return "";
  559. }
  560. }
  561. static const char *pin_flag(int pinned)
  562. {
  563. if (pinned > 0)
  564. return " P";
  565. else if (pinned < 0)
  566. return " p";
  567. else
  568. return "";
  569. }
  570. static const char *tiling_flag(int tiling)
  571. {
  572. switch (tiling) {
  573. default:
  574. case I915_TILING_NONE: return "";
  575. case I915_TILING_X: return " X";
  576. case I915_TILING_Y: return " Y";
  577. }
  578. }
  579. static const char *dirty_flag(int dirty)
  580. {
  581. return dirty ? " dirty" : "";
  582. }
  583. static const char *purgeable_flag(int purgeable)
  584. {
  585. return purgeable ? " purgeable" : "";
  586. }
  587. static void print_error_buffers(struct seq_file *m,
  588. const char *name,
  589. struct drm_i915_error_buffer *err,
  590. int count)
  591. {
  592. seq_printf(m, "%s [%d]:\n", name, count);
  593. while (count--) {
  594. seq_printf(m, " %08x %8u %04x %04x %08x%s%s%s%s%s%s%s",
  595. err->gtt_offset,
  596. err->size,
  597. err->read_domains,
  598. err->write_domain,
  599. err->seqno,
  600. pin_flag(err->pinned),
  601. tiling_flag(err->tiling),
  602. dirty_flag(err->dirty),
  603. purgeable_flag(err->purgeable),
  604. err->ring != -1 ? " " : "",
  605. ring_str(err->ring),
  606. cache_level_str(err->cache_level));
  607. if (err->name)
  608. seq_printf(m, " (name: %d)", err->name);
  609. if (err->fence_reg != I915_FENCE_REG_NONE)
  610. seq_printf(m, " (fence: %d)", err->fence_reg);
  611. seq_printf(m, "\n");
  612. err++;
  613. }
  614. }
  615. static void i915_ring_error_state(struct seq_file *m,
  616. struct drm_device *dev,
  617. struct drm_i915_error_state *error,
  618. unsigned ring)
  619. {
  620. seq_printf(m, "%s command stream:\n", ring_str(ring));
  621. seq_printf(m, " HEAD: 0x%08x\n", error->head[ring]);
  622. seq_printf(m, " TAIL: 0x%08x\n", error->tail[ring]);
  623. seq_printf(m, " ACTHD: 0x%08x\n", error->acthd[ring]);
  624. seq_printf(m, " IPEIR: 0x%08x\n", error->ipeir[ring]);
  625. seq_printf(m, " IPEHR: 0x%08x\n", error->ipehr[ring]);
  626. seq_printf(m, " INSTDONE: 0x%08x\n", error->instdone[ring]);
  627. if (ring == RCS && INTEL_INFO(dev)->gen >= 4) {
  628. seq_printf(m, " INSTDONE1: 0x%08x\n", error->instdone1);
  629. seq_printf(m, " BBADDR: 0x%08llx\n", error->bbaddr);
  630. }
  631. if (INTEL_INFO(dev)->gen >= 4)
  632. seq_printf(m, " INSTPS: 0x%08x\n", error->instps[ring]);
  633. seq_printf(m, " INSTPM: 0x%08x\n", error->instpm[ring]);
  634. if (INTEL_INFO(dev)->gen >= 6) {
  635. seq_printf(m, " FADDR: 0x%08x\n", error->faddr[ring]);
  636. seq_printf(m, " FAULT_REG: 0x%08x\n", error->fault_reg[ring]);
  637. seq_printf(m, " SYNC_0: 0x%08x\n",
  638. error->semaphore_mboxes[ring][0]);
  639. seq_printf(m, " SYNC_1: 0x%08x\n",
  640. error->semaphore_mboxes[ring][1]);
  641. }
  642. seq_printf(m, " seqno: 0x%08x\n", error->seqno[ring]);
  643. seq_printf(m, " ring->head: 0x%08x\n", error->cpu_ring_head[ring]);
  644. seq_printf(m, " ring->tail: 0x%08x\n", error->cpu_ring_tail[ring]);
  645. }
  646. static int i915_error_state(struct seq_file *m, void *unused)
  647. {
  648. struct drm_info_node *node = (struct drm_info_node *) m->private;
  649. struct drm_device *dev = node->minor->dev;
  650. drm_i915_private_t *dev_priv = dev->dev_private;
  651. struct drm_i915_error_state *error;
  652. unsigned long flags;
  653. int i, j, page, offset, elt;
  654. spin_lock_irqsave(&dev_priv->error_lock, flags);
  655. if (!dev_priv->first_error) {
  656. seq_printf(m, "no error state collected\n");
  657. goto out;
  658. }
  659. error = dev_priv->first_error;
  660. seq_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec,
  661. error->time.tv_usec);
  662. seq_printf(m, "Kernel: " UTS_RELEASE "\n");
  663. seq_printf(m, "PCI ID: 0x%04x\n", dev->pci_device);
  664. seq_printf(m, "EIR: 0x%08x\n", error->eir);
  665. seq_printf(m, "PGTBL_ER: 0x%08x\n", error->pgtbl_er);
  666. for (i = 0; i < dev_priv->num_fence_regs; i++)
  667. seq_printf(m, " fence[%d] = %08llx\n", i, error->fence[i]);
  668. if (INTEL_INFO(dev)->gen >= 6) {
  669. seq_printf(m, "ERROR: 0x%08x\n", error->error);
  670. seq_printf(m, "DONE_REG: 0x%08x\n", error->done_reg);
  671. }
  672. i915_ring_error_state(m, dev, error, RCS);
  673. if (HAS_BLT(dev))
  674. i915_ring_error_state(m, dev, error, BCS);
  675. if (HAS_BSD(dev))
  676. i915_ring_error_state(m, dev, error, VCS);
  677. if (error->active_bo)
  678. print_error_buffers(m, "Active",
  679. error->active_bo,
  680. error->active_bo_count);
  681. if (error->pinned_bo)
  682. print_error_buffers(m, "Pinned",
  683. error->pinned_bo,
  684. error->pinned_bo_count);
  685. for (i = 0; i < ARRAY_SIZE(error->ring); i++) {
  686. struct drm_i915_error_object *obj;
  687. if ((obj = error->ring[i].batchbuffer)) {
  688. seq_printf(m, "%s --- gtt_offset = 0x%08x\n",
  689. dev_priv->ring[i].name,
  690. obj->gtt_offset);
  691. offset = 0;
  692. for (page = 0; page < obj->page_count; page++) {
  693. for (elt = 0; elt < PAGE_SIZE/4; elt++) {
  694. seq_printf(m, "%08x : %08x\n", offset, obj->pages[page][elt]);
  695. offset += 4;
  696. }
  697. }
  698. }
  699. if (error->ring[i].num_requests) {
  700. seq_printf(m, "%s --- %d requests\n",
  701. dev_priv->ring[i].name,
  702. error->ring[i].num_requests);
  703. for (j = 0; j < error->ring[i].num_requests; j++) {
  704. seq_printf(m, " seqno 0x%08x, emitted %ld, tail 0x%08x\n",
  705. error->ring[i].requests[j].seqno,
  706. error->ring[i].requests[j].jiffies,
  707. error->ring[i].requests[j].tail);
  708. }
  709. }
  710. if ((obj = error->ring[i].ringbuffer)) {
  711. seq_printf(m, "%s --- ringbuffer = 0x%08x\n",
  712. dev_priv->ring[i].name,
  713. obj->gtt_offset);
  714. offset = 0;
  715. for (page = 0; page < obj->page_count; page++) {
  716. for (elt = 0; elt < PAGE_SIZE/4; elt++) {
  717. seq_printf(m, "%08x : %08x\n",
  718. offset,
  719. obj->pages[page][elt]);
  720. offset += 4;
  721. }
  722. }
  723. }
  724. }
  725. if (error->overlay)
  726. intel_overlay_print_error_state(m, error->overlay);
  727. if (error->display)
  728. intel_display_print_error_state(m, dev, error->display);
  729. out:
  730. spin_unlock_irqrestore(&dev_priv->error_lock, flags);
  731. return 0;
  732. }
  733. static int i915_rstdby_delays(struct seq_file *m, void *unused)
  734. {
  735. struct drm_info_node *node = (struct drm_info_node *) m->private;
  736. struct drm_device *dev = node->minor->dev;
  737. drm_i915_private_t *dev_priv = dev->dev_private;
  738. u16 crstanddelay;
  739. int ret;
  740. ret = mutex_lock_interruptible(&dev->struct_mutex);
  741. if (ret)
  742. return ret;
  743. crstanddelay = I915_READ16(CRSTANDVID);
  744. mutex_unlock(&dev->struct_mutex);
  745. seq_printf(m, "w/ctx: %d, w/o ctx: %d\n", (crstanddelay >> 8) & 0x3f, (crstanddelay & 0x3f));
  746. return 0;
  747. }
  748. static int i915_cur_delayinfo(struct seq_file *m, void *unused)
  749. {
  750. struct drm_info_node *node = (struct drm_info_node *) m->private;
  751. struct drm_device *dev = node->minor->dev;
  752. drm_i915_private_t *dev_priv = dev->dev_private;
  753. int ret;
  754. if (IS_GEN5(dev)) {
  755. u16 rgvswctl = I915_READ16(MEMSWCTL);
  756. u16 rgvstat = I915_READ16(MEMSTAT_ILK);
  757. seq_printf(m, "Requested P-state: %d\n", (rgvswctl >> 8) & 0xf);
  758. seq_printf(m, "Requested VID: %d\n", rgvswctl & 0x3f);
  759. seq_printf(m, "Current VID: %d\n", (rgvstat & MEMSTAT_VID_MASK) >>
  760. MEMSTAT_VID_SHIFT);
  761. seq_printf(m, "Current P-state: %d\n",
  762. (rgvstat & MEMSTAT_PSTATE_MASK) >> MEMSTAT_PSTATE_SHIFT);
  763. } else if (IS_GEN6(dev) || IS_GEN7(dev)) {
  764. u32 gt_perf_status = I915_READ(GEN6_GT_PERF_STATUS);
  765. u32 rp_state_limits = I915_READ(GEN6_RP_STATE_LIMITS);
  766. u32 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
  767. u32 rpstat;
  768. u32 rpupei, rpcurup, rpprevup;
  769. u32 rpdownei, rpcurdown, rpprevdown;
  770. int max_freq;
  771. /* RPSTAT1 is in the GT power well */
  772. ret = mutex_lock_interruptible(&dev->struct_mutex);
  773. if (ret)
  774. return ret;
  775. gen6_gt_force_wake_get(dev_priv);
  776. rpstat = I915_READ(GEN6_RPSTAT1);
  777. rpupei = I915_READ(GEN6_RP_CUR_UP_EI);
  778. rpcurup = I915_READ(GEN6_RP_CUR_UP);
  779. rpprevup = I915_READ(GEN6_RP_PREV_UP);
  780. rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI);
  781. rpcurdown = I915_READ(GEN6_RP_CUR_DOWN);
  782. rpprevdown = I915_READ(GEN6_RP_PREV_DOWN);
  783. gen6_gt_force_wake_put(dev_priv);
  784. mutex_unlock(&dev->struct_mutex);
  785. seq_printf(m, "GT_PERF_STATUS: 0x%08x\n", gt_perf_status);
  786. seq_printf(m, "RPSTAT1: 0x%08x\n", rpstat);
  787. seq_printf(m, "Render p-state ratio: %d\n",
  788. (gt_perf_status & 0xff00) >> 8);
  789. seq_printf(m, "Render p-state VID: %d\n",
  790. gt_perf_status & 0xff);
  791. seq_printf(m, "Render p-state limit: %d\n",
  792. rp_state_limits & 0xff);
  793. seq_printf(m, "CAGF: %dMHz\n", ((rpstat & GEN6_CAGF_MASK) >>
  794. GEN6_CAGF_SHIFT) * 50);
  795. seq_printf(m, "RP CUR UP EI: %dus\n", rpupei &
  796. GEN6_CURICONT_MASK);
  797. seq_printf(m, "RP CUR UP: %dus\n", rpcurup &
  798. GEN6_CURBSYTAVG_MASK);
  799. seq_printf(m, "RP PREV UP: %dus\n", rpprevup &
  800. GEN6_CURBSYTAVG_MASK);
  801. seq_printf(m, "RP CUR DOWN EI: %dus\n", rpdownei &
  802. GEN6_CURIAVG_MASK);
  803. seq_printf(m, "RP CUR DOWN: %dus\n", rpcurdown &
  804. GEN6_CURBSYTAVG_MASK);
  805. seq_printf(m, "RP PREV DOWN: %dus\n", rpprevdown &
  806. GEN6_CURBSYTAVG_MASK);
  807. max_freq = (rp_state_cap & 0xff0000) >> 16;
  808. seq_printf(m, "Lowest (RPN) frequency: %dMHz\n",
  809. max_freq * 50);
  810. max_freq = (rp_state_cap & 0xff00) >> 8;
  811. seq_printf(m, "Nominal (RP1) frequency: %dMHz\n",
  812. max_freq * 50);
  813. max_freq = rp_state_cap & 0xff;
  814. seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n",
  815. max_freq * 50);
  816. } else {
  817. seq_printf(m, "no P-state info available\n");
  818. }
  819. return 0;
  820. }
  821. static int i915_delayfreq_table(struct seq_file *m, void *unused)
  822. {
  823. struct drm_info_node *node = (struct drm_info_node *) m->private;
  824. struct drm_device *dev = node->minor->dev;
  825. drm_i915_private_t *dev_priv = dev->dev_private;
  826. u32 delayfreq;
  827. int ret, i;
  828. ret = mutex_lock_interruptible(&dev->struct_mutex);
  829. if (ret)
  830. return ret;
  831. for (i = 0; i < 16; i++) {
  832. delayfreq = I915_READ(PXVFREQ_BASE + i * 4);
  833. seq_printf(m, "P%02dVIDFREQ: 0x%08x (VID: %d)\n", i, delayfreq,
  834. (delayfreq & PXVFREQ_PX_MASK) >> PXVFREQ_PX_SHIFT);
  835. }
  836. mutex_unlock(&dev->struct_mutex);
  837. return 0;
  838. }
  839. static inline int MAP_TO_MV(int map)
  840. {
  841. return 1250 - (map * 25);
  842. }
  843. static int i915_inttoext_table(struct seq_file *m, void *unused)
  844. {
  845. struct drm_info_node *node = (struct drm_info_node *) m->private;
  846. struct drm_device *dev = node->minor->dev;
  847. drm_i915_private_t *dev_priv = dev->dev_private;
  848. u32 inttoext;
  849. int ret, i;
  850. ret = mutex_lock_interruptible(&dev->struct_mutex);
  851. if (ret)
  852. return ret;
  853. for (i = 1; i <= 32; i++) {
  854. inttoext = I915_READ(INTTOEXT_BASE_ILK + i * 4);
  855. seq_printf(m, "INTTOEXT%02d: 0x%08x\n", i, inttoext);
  856. }
  857. mutex_unlock(&dev->struct_mutex);
  858. return 0;
  859. }
  860. static int ironlake_drpc_info(struct seq_file *m)
  861. {
  862. struct drm_info_node *node = (struct drm_info_node *) m->private;
  863. struct drm_device *dev = node->minor->dev;
  864. drm_i915_private_t *dev_priv = dev->dev_private;
  865. u32 rgvmodectl, rstdbyctl;
  866. u16 crstandvid;
  867. int ret;
  868. ret = mutex_lock_interruptible(&dev->struct_mutex);
  869. if (ret)
  870. return ret;
  871. rgvmodectl = I915_READ(MEMMODECTL);
  872. rstdbyctl = I915_READ(RSTDBYCTL);
  873. crstandvid = I915_READ16(CRSTANDVID);
  874. mutex_unlock(&dev->struct_mutex);
  875. seq_printf(m, "HD boost: %s\n", (rgvmodectl & MEMMODE_BOOST_EN) ?
  876. "yes" : "no");
  877. seq_printf(m, "Boost freq: %d\n",
  878. (rgvmodectl & MEMMODE_BOOST_FREQ_MASK) >>
  879. MEMMODE_BOOST_FREQ_SHIFT);
  880. seq_printf(m, "HW control enabled: %s\n",
  881. rgvmodectl & MEMMODE_HWIDLE_EN ? "yes" : "no");
  882. seq_printf(m, "SW control enabled: %s\n",
  883. rgvmodectl & MEMMODE_SWMODE_EN ? "yes" : "no");
  884. seq_printf(m, "Gated voltage change: %s\n",
  885. rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no");
  886. seq_printf(m, "Starting frequency: P%d\n",
  887. (rgvmodectl & MEMMODE_FSTART_MASK) >> MEMMODE_FSTART_SHIFT);
  888. seq_printf(m, "Max P-state: P%d\n",
  889. (rgvmodectl & MEMMODE_FMAX_MASK) >> MEMMODE_FMAX_SHIFT);
  890. seq_printf(m, "Min P-state: P%d\n", (rgvmodectl & MEMMODE_FMIN_MASK));
  891. seq_printf(m, "RS1 VID: %d\n", (crstandvid & 0x3f));
  892. seq_printf(m, "RS2 VID: %d\n", ((crstandvid >> 8) & 0x3f));
  893. seq_printf(m, "Render standby enabled: %s\n",
  894. (rstdbyctl & RCX_SW_EXIT) ? "no" : "yes");
  895. seq_printf(m, "Current RS state: ");
  896. switch (rstdbyctl & RSX_STATUS_MASK) {
  897. case RSX_STATUS_ON:
  898. seq_printf(m, "on\n");
  899. break;
  900. case RSX_STATUS_RC1:
  901. seq_printf(m, "RC1\n");
  902. break;
  903. case RSX_STATUS_RC1E:
  904. seq_printf(m, "RC1E\n");
  905. break;
  906. case RSX_STATUS_RS1:
  907. seq_printf(m, "RS1\n");
  908. break;
  909. case RSX_STATUS_RS2:
  910. seq_printf(m, "RS2 (RC6)\n");
  911. break;
  912. case RSX_STATUS_RS3:
  913. seq_printf(m, "RC3 (RC6+)\n");
  914. break;
  915. default:
  916. seq_printf(m, "unknown\n");
  917. break;
  918. }
  919. return 0;
  920. }
  921. static int gen6_drpc_info(struct seq_file *m)
  922. {
  923. struct drm_info_node *node = (struct drm_info_node *) m->private;
  924. struct drm_device *dev = node->minor->dev;
  925. struct drm_i915_private *dev_priv = dev->dev_private;
  926. u32 rpmodectl1, gt_core_status, rcctl1;
  927. unsigned forcewake_count;
  928. int count=0, ret;
  929. ret = mutex_lock_interruptible(&dev->struct_mutex);
  930. if (ret)
  931. return ret;
  932. spin_lock_irq(&dev_priv->gt_lock);
  933. forcewake_count = dev_priv->forcewake_count;
  934. spin_unlock_irq(&dev_priv->gt_lock);
  935. if (forcewake_count) {
  936. seq_printf(m, "RC information inaccurate because somebody "
  937. "holds a forcewake reference \n");
  938. } else {
  939. /* NB: we cannot use forcewake, else we read the wrong values */
  940. while (count++ < 50 && (I915_READ_NOTRACE(FORCEWAKE_ACK) & 1))
  941. udelay(10);
  942. seq_printf(m, "RC information accurate: %s\n", yesno(count < 51));
  943. }
  944. gt_core_status = readl(dev_priv->regs + GEN6_GT_CORE_STATUS);
  945. trace_i915_reg_rw(false, GEN6_GT_CORE_STATUS, gt_core_status, 4);
  946. rpmodectl1 = I915_READ(GEN6_RP_CONTROL);
  947. rcctl1 = I915_READ(GEN6_RC_CONTROL);
  948. mutex_unlock(&dev->struct_mutex);
  949. seq_printf(m, "Video Turbo Mode: %s\n",
  950. yesno(rpmodectl1 & GEN6_RP_MEDIA_TURBO));
  951. seq_printf(m, "HW control enabled: %s\n",
  952. yesno(rpmodectl1 & GEN6_RP_ENABLE));
  953. seq_printf(m, "SW control enabled: %s\n",
  954. yesno((rpmodectl1 & GEN6_RP_MEDIA_MODE_MASK) ==
  955. GEN6_RP_MEDIA_SW_MODE));
  956. seq_printf(m, "RC1e Enabled: %s\n",
  957. yesno(rcctl1 & GEN6_RC_CTL_RC1e_ENABLE));
  958. seq_printf(m, "RC6 Enabled: %s\n",
  959. yesno(rcctl1 & GEN6_RC_CTL_RC6_ENABLE));
  960. seq_printf(m, "Deep RC6 Enabled: %s\n",
  961. yesno(rcctl1 & GEN6_RC_CTL_RC6p_ENABLE));
  962. seq_printf(m, "Deepest RC6 Enabled: %s\n",
  963. yesno(rcctl1 & GEN6_RC_CTL_RC6pp_ENABLE));
  964. seq_printf(m, "Current RC state: ");
  965. switch (gt_core_status & GEN6_RCn_MASK) {
  966. case GEN6_RC0:
  967. if (gt_core_status & GEN6_CORE_CPD_STATE_MASK)
  968. seq_printf(m, "Core Power Down\n");
  969. else
  970. seq_printf(m, "on\n");
  971. break;
  972. case GEN6_RC3:
  973. seq_printf(m, "RC3\n");
  974. break;
  975. case GEN6_RC6:
  976. seq_printf(m, "RC6\n");
  977. break;
  978. case GEN6_RC7:
  979. seq_printf(m, "RC7\n");
  980. break;
  981. default:
  982. seq_printf(m, "Unknown\n");
  983. break;
  984. }
  985. seq_printf(m, "Core Power Down: %s\n",
  986. yesno(gt_core_status & GEN6_CORE_CPD_STATE_MASK));
  987. return 0;
  988. }
  989. static int i915_drpc_info(struct seq_file *m, void *unused)
  990. {
  991. struct drm_info_node *node = (struct drm_info_node *) m->private;
  992. struct drm_device *dev = node->minor->dev;
  993. if (IS_GEN6(dev) || IS_GEN7(dev))
  994. return gen6_drpc_info(m);
  995. else
  996. return ironlake_drpc_info(m);
  997. }
  998. static int i915_fbc_status(struct seq_file *m, void *unused)
  999. {
  1000. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1001. struct drm_device *dev = node->minor->dev;
  1002. drm_i915_private_t *dev_priv = dev->dev_private;
  1003. if (!I915_HAS_FBC(dev)) {
  1004. seq_printf(m, "FBC unsupported on this chipset\n");
  1005. return 0;
  1006. }
  1007. if (intel_fbc_enabled(dev)) {
  1008. seq_printf(m, "FBC enabled\n");
  1009. } else {
  1010. seq_printf(m, "FBC disabled: ");
  1011. switch (dev_priv->no_fbc_reason) {
  1012. case FBC_NO_OUTPUT:
  1013. seq_printf(m, "no outputs");
  1014. break;
  1015. case FBC_STOLEN_TOO_SMALL:
  1016. seq_printf(m, "not enough stolen memory");
  1017. break;
  1018. case FBC_UNSUPPORTED_MODE:
  1019. seq_printf(m, "mode not supported");
  1020. break;
  1021. case FBC_MODE_TOO_LARGE:
  1022. seq_printf(m, "mode too large");
  1023. break;
  1024. case FBC_BAD_PLANE:
  1025. seq_printf(m, "FBC unsupported on plane");
  1026. break;
  1027. case FBC_NOT_TILED:
  1028. seq_printf(m, "scanout buffer not tiled");
  1029. break;
  1030. case FBC_MULTIPLE_PIPES:
  1031. seq_printf(m, "multiple pipes are enabled");
  1032. break;
  1033. case FBC_MODULE_PARAM:
  1034. seq_printf(m, "disabled per module param (default off)");
  1035. break;
  1036. default:
  1037. seq_printf(m, "unknown reason");
  1038. }
  1039. seq_printf(m, "\n");
  1040. }
  1041. return 0;
  1042. }
  1043. static int i915_sr_status(struct seq_file *m, void *unused)
  1044. {
  1045. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1046. struct drm_device *dev = node->minor->dev;
  1047. drm_i915_private_t *dev_priv = dev->dev_private;
  1048. bool sr_enabled = false;
  1049. if (HAS_PCH_SPLIT(dev))
  1050. sr_enabled = I915_READ(WM1_LP_ILK) & WM1_LP_SR_EN;
  1051. else if (IS_CRESTLINE(dev) || IS_I945G(dev) || IS_I945GM(dev))
  1052. sr_enabled = I915_READ(FW_BLC_SELF) & FW_BLC_SELF_EN;
  1053. else if (IS_I915GM(dev))
  1054. sr_enabled = I915_READ(INSTPM) & INSTPM_SELF_EN;
  1055. else if (IS_PINEVIEW(dev))
  1056. sr_enabled = I915_READ(DSPFW3) & PINEVIEW_SELF_REFRESH_EN;
  1057. seq_printf(m, "self-refresh: %s\n",
  1058. sr_enabled ? "enabled" : "disabled");
  1059. return 0;
  1060. }
  1061. static int i915_emon_status(struct seq_file *m, void *unused)
  1062. {
  1063. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1064. struct drm_device *dev = node->minor->dev;
  1065. drm_i915_private_t *dev_priv = dev->dev_private;
  1066. unsigned long temp, chipset, gfx;
  1067. int ret;
  1068. if (!IS_GEN5(dev))
  1069. return -ENODEV;
  1070. ret = mutex_lock_interruptible(&dev->struct_mutex);
  1071. if (ret)
  1072. return ret;
  1073. temp = i915_mch_val(dev_priv);
  1074. chipset = i915_chipset_val(dev_priv);
  1075. gfx = i915_gfx_val(dev_priv);
  1076. mutex_unlock(&dev->struct_mutex);
  1077. seq_printf(m, "GMCH temp: %ld\n", temp);
  1078. seq_printf(m, "Chipset power: %ld\n", chipset);
  1079. seq_printf(m, "GFX power: %ld\n", gfx);
  1080. seq_printf(m, "Total power: %ld\n", chipset + gfx);
  1081. return 0;
  1082. }
  1083. static int i915_ring_freq_table(struct seq_file *m, void *unused)
  1084. {
  1085. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1086. struct drm_device *dev = node->minor->dev;
  1087. drm_i915_private_t *dev_priv = dev->dev_private;
  1088. int ret;
  1089. int gpu_freq, ia_freq;
  1090. if (!(IS_GEN6(dev) || IS_GEN7(dev))) {
  1091. seq_printf(m, "unsupported on this chipset\n");
  1092. return 0;
  1093. }
  1094. ret = mutex_lock_interruptible(&dev->struct_mutex);
  1095. if (ret)
  1096. return ret;
  1097. seq_printf(m, "GPU freq (MHz)\tEffective CPU freq (MHz)\n");
  1098. for (gpu_freq = dev_priv->min_delay; gpu_freq <= dev_priv->max_delay;
  1099. gpu_freq++) {
  1100. I915_WRITE(GEN6_PCODE_DATA, gpu_freq);
  1101. I915_WRITE(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY |
  1102. GEN6_PCODE_READ_MIN_FREQ_TABLE);
  1103. if (wait_for((I915_READ(GEN6_PCODE_MAILBOX) &
  1104. GEN6_PCODE_READY) == 0, 10)) {
  1105. DRM_ERROR("pcode read of freq table timed out\n");
  1106. continue;
  1107. }
  1108. ia_freq = I915_READ(GEN6_PCODE_DATA);
  1109. seq_printf(m, "%d\t\t%d\n", gpu_freq * 50, ia_freq * 100);
  1110. }
  1111. mutex_unlock(&dev->struct_mutex);
  1112. return 0;
  1113. }
  1114. static int i915_gfxec(struct seq_file *m, void *unused)
  1115. {
  1116. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1117. struct drm_device *dev = node->minor->dev;
  1118. drm_i915_private_t *dev_priv = dev->dev_private;
  1119. int ret;
  1120. ret = mutex_lock_interruptible(&dev->struct_mutex);
  1121. if (ret)
  1122. return ret;
  1123. seq_printf(m, "GFXEC: %ld\n", (unsigned long)I915_READ(0x112f4));
  1124. mutex_unlock(&dev->struct_mutex);
  1125. return 0;
  1126. }
  1127. static int i915_opregion(struct seq_file *m, void *unused)
  1128. {
  1129. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1130. struct drm_device *dev = node->minor->dev;
  1131. drm_i915_private_t *dev_priv = dev->dev_private;
  1132. struct intel_opregion *opregion = &dev_priv->opregion;
  1133. int ret;
  1134. ret = mutex_lock_interruptible(&dev->struct_mutex);
  1135. if (ret)
  1136. return ret;
  1137. if (opregion->header)
  1138. seq_write(m, opregion->header, OPREGION_SIZE);
  1139. mutex_unlock(&dev->struct_mutex);
  1140. return 0;
  1141. }
  1142. static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
  1143. {
  1144. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1145. struct drm_device *dev = node->minor->dev;
  1146. drm_i915_private_t *dev_priv = dev->dev_private;
  1147. struct intel_fbdev *ifbdev;
  1148. struct intel_framebuffer *fb;
  1149. int ret;
  1150. ret = mutex_lock_interruptible(&dev->mode_config.mutex);
  1151. if (ret)
  1152. return ret;
  1153. ifbdev = dev_priv->fbdev;
  1154. fb = to_intel_framebuffer(ifbdev->helper.fb);
  1155. seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, obj ",
  1156. fb->base.width,
  1157. fb->base.height,
  1158. fb->base.depth,
  1159. fb->base.bits_per_pixel);
  1160. describe_obj(m, fb->obj);
  1161. seq_printf(m, "\n");
  1162. list_for_each_entry(fb, &dev->mode_config.fb_list, base.head) {
  1163. if (&fb->base == ifbdev->helper.fb)
  1164. continue;
  1165. seq_printf(m, "user size: %d x %d, depth %d, %d bpp, obj ",
  1166. fb->base.width,
  1167. fb->base.height,
  1168. fb->base.depth,
  1169. fb->base.bits_per_pixel);
  1170. describe_obj(m, fb->obj);
  1171. seq_printf(m, "\n");
  1172. }
  1173. mutex_unlock(&dev->mode_config.mutex);
  1174. return 0;
  1175. }
  1176. static int i915_context_status(struct seq_file *m, void *unused)
  1177. {
  1178. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1179. struct drm_device *dev = node->minor->dev;
  1180. drm_i915_private_t *dev_priv = dev->dev_private;
  1181. int ret;
  1182. ret = mutex_lock_interruptible(&dev->mode_config.mutex);
  1183. if (ret)
  1184. return ret;
  1185. if (dev_priv->pwrctx) {
  1186. seq_printf(m, "power context ");
  1187. describe_obj(m, dev_priv->pwrctx);
  1188. seq_printf(m, "\n");
  1189. }
  1190. if (dev_priv->renderctx) {
  1191. seq_printf(m, "render context ");
  1192. describe_obj(m, dev_priv->renderctx);
  1193. seq_printf(m, "\n");
  1194. }
  1195. mutex_unlock(&dev->mode_config.mutex);
  1196. return 0;
  1197. }
  1198. static int i915_gen6_forcewake_count_info(struct seq_file *m, void *data)
  1199. {
  1200. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1201. struct drm_device *dev = node->minor->dev;
  1202. struct drm_i915_private *dev_priv = dev->dev_private;
  1203. unsigned forcewake_count;
  1204. spin_lock_irq(&dev_priv->gt_lock);
  1205. forcewake_count = dev_priv->forcewake_count;
  1206. spin_unlock_irq(&dev_priv->gt_lock);
  1207. seq_printf(m, "forcewake count = %u\n", forcewake_count);
  1208. return 0;
  1209. }
  1210. static const char *swizzle_string(unsigned swizzle)
  1211. {
  1212. switch(swizzle) {
  1213. case I915_BIT_6_SWIZZLE_NONE:
  1214. return "none";
  1215. case I915_BIT_6_SWIZZLE_9:
  1216. return "bit9";
  1217. case I915_BIT_6_SWIZZLE_9_10:
  1218. return "bit9/bit10";
  1219. case I915_BIT_6_SWIZZLE_9_11:
  1220. return "bit9/bit11";
  1221. case I915_BIT_6_SWIZZLE_9_10_11:
  1222. return "bit9/bit10/bit11";
  1223. case I915_BIT_6_SWIZZLE_9_17:
  1224. return "bit9/bit17";
  1225. case I915_BIT_6_SWIZZLE_9_10_17:
  1226. return "bit9/bit10/bit17";
  1227. case I915_BIT_6_SWIZZLE_UNKNOWN:
  1228. return "unkown";
  1229. }
  1230. return "bug";
  1231. }
  1232. static int i915_swizzle_info(struct seq_file *m, void *data)
  1233. {
  1234. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1235. struct drm_device *dev = node->minor->dev;
  1236. struct drm_i915_private *dev_priv = dev->dev_private;
  1237. mutex_lock(&dev->struct_mutex);
  1238. seq_printf(m, "bit6 swizzle for X-tiling = %s\n",
  1239. swizzle_string(dev_priv->mm.bit_6_swizzle_x));
  1240. seq_printf(m, "bit6 swizzle for Y-tiling = %s\n",
  1241. swizzle_string(dev_priv->mm.bit_6_swizzle_y));
  1242. if (IS_GEN3(dev) || IS_GEN4(dev)) {
  1243. seq_printf(m, "DDC = 0x%08x\n",
  1244. I915_READ(DCC));
  1245. seq_printf(m, "C0DRB3 = 0x%04x\n",
  1246. I915_READ16(C0DRB3));
  1247. seq_printf(m, "C1DRB3 = 0x%04x\n",
  1248. I915_READ16(C1DRB3));
  1249. } else if (IS_GEN6(dev) || IS_GEN7(dev)) {
  1250. seq_printf(m, "MAD_DIMM_C0 = 0x%08x\n",
  1251. I915_READ(MAD_DIMM_C0));
  1252. seq_printf(m, "MAD_DIMM_C1 = 0x%08x\n",
  1253. I915_READ(MAD_DIMM_C1));
  1254. seq_printf(m, "MAD_DIMM_C2 = 0x%08x\n",
  1255. I915_READ(MAD_DIMM_C2));
  1256. seq_printf(m, "TILECTL = 0x%08x\n",
  1257. I915_READ(TILECTL));
  1258. seq_printf(m, "ARB_MODE = 0x%08x\n",
  1259. I915_READ(ARB_MODE));
  1260. seq_printf(m, "DISP_ARB_CTL = 0x%08x\n",
  1261. I915_READ(DISP_ARB_CTL));
  1262. }
  1263. mutex_unlock(&dev->struct_mutex);
  1264. return 0;
  1265. }
  1266. static int i915_ppgtt_info(struct seq_file *m, void *data)
  1267. {
  1268. struct drm_info_node *node = (struct drm_info_node *) m->private;
  1269. struct drm_device *dev = node->minor->dev;
  1270. struct drm_i915_private *dev_priv = dev->dev_private;
  1271. struct intel_ring_buffer *ring;
  1272. int i, ret;
  1273. ret = mutex_lock_interruptible(&dev->struct_mutex);
  1274. if (ret)
  1275. return ret;
  1276. if (INTEL_INFO(dev)->gen == 6)
  1277. seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE));
  1278. for (i = 0; i < I915_NUM_RINGS; i++) {
  1279. ring = &dev_priv->ring[i];
  1280. seq_printf(m, "%s\n", ring->name);
  1281. if (INTEL_INFO(dev)->gen == 7)
  1282. seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring)));
  1283. seq_printf(m, "PP_DIR_BASE: 0x%08x\n", I915_READ(RING_PP_DIR_BASE(ring)));
  1284. seq_printf(m, "PP_DIR_BASE_READ: 0x%08x\n", I915_READ(RING_PP_DIR_BASE_READ(ring)));
  1285. seq_printf(m, "PP_DIR_DCLV: 0x%08x\n", I915_READ(RING_PP_DIR_DCLV(ring)));
  1286. }
  1287. if (dev_priv->mm.aliasing_ppgtt) {
  1288. struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
  1289. seq_printf(m, "aliasing PPGTT:\n");
  1290. seq_printf(m, "pd gtt offset: 0x%08x\n", ppgtt->pd_offset);
  1291. }
  1292. seq_printf(m, "ECOCHK: 0x%08x\n", I915_READ(GAM_ECOCHK));
  1293. mutex_unlock(&dev->struct_mutex);
  1294. return 0;
  1295. }
  1296. static ssize_t
  1297. i915_wedged_read(struct file *filp,
  1298. char __user *ubuf,
  1299. size_t max,
  1300. loff_t *ppos)
  1301. {
  1302. struct drm_device *dev = filp->private_data;
  1303. drm_i915_private_t *dev_priv = dev->dev_private;
  1304. char buf[80];
  1305. int len;
  1306. len = snprintf(buf, sizeof(buf),
  1307. "wedged : %d\n",
  1308. atomic_read(&dev_priv->mm.wedged));
  1309. if (len > sizeof(buf))
  1310. len = sizeof(buf);
  1311. return simple_read_from_buffer(ubuf, max, ppos, buf, len);
  1312. }
  1313. static ssize_t
  1314. i915_wedged_write(struct file *filp,
  1315. const char __user *ubuf,
  1316. size_t cnt,
  1317. loff_t *ppos)
  1318. {
  1319. struct drm_device *dev = filp->private_data;
  1320. char buf[20];
  1321. int val = 1;
  1322. if (cnt > 0) {
  1323. if (cnt > sizeof(buf) - 1)
  1324. return -EINVAL;
  1325. if (copy_from_user(buf, ubuf, cnt))
  1326. return -EFAULT;
  1327. buf[cnt] = 0;
  1328. val = simple_strtoul(buf, NULL, 0);
  1329. }
  1330. DRM_INFO("Manually setting wedged to %d\n", val);
  1331. i915_handle_error(dev, val);
  1332. return cnt;
  1333. }
  1334. static const struct file_operations i915_wedged_fops = {
  1335. .owner = THIS_MODULE,
  1336. .open = simple_open,
  1337. .read = i915_wedged_read,
  1338. .write = i915_wedged_write,
  1339. .llseek = default_llseek,
  1340. };
  1341. static ssize_t
  1342. i915_max_freq_read(struct file *filp,
  1343. char __user *ubuf,
  1344. size_t max,
  1345. loff_t *ppos)
  1346. {
  1347. struct drm_device *dev = filp->private_data;
  1348. drm_i915_private_t *dev_priv = dev->dev_private;
  1349. char buf[80];
  1350. int len;
  1351. len = snprintf(buf, sizeof(buf),
  1352. "max freq: %d\n", dev_priv->max_delay * 50);
  1353. if (len > sizeof(buf))
  1354. len = sizeof(buf);
  1355. return simple_read_from_buffer(ubuf, max, ppos, buf, len);
  1356. }
  1357. static ssize_t
  1358. i915_max_freq_write(struct file *filp,
  1359. const char __user *ubuf,
  1360. size_t cnt,
  1361. loff_t *ppos)
  1362. {
  1363. struct drm_device *dev = filp->private_data;
  1364. struct drm_i915_private *dev_priv = dev->dev_private;
  1365. char buf[20];
  1366. int val = 1;
  1367. if (cnt > 0) {
  1368. if (cnt > sizeof(buf) - 1)
  1369. return -EINVAL;
  1370. if (copy_from_user(buf, ubuf, cnt))
  1371. return -EFAULT;
  1372. buf[cnt] = 0;
  1373. val = simple_strtoul(buf, NULL, 0);
  1374. }
  1375. DRM_DEBUG_DRIVER("Manually setting max freq to %d\n", val);
  1376. /*
  1377. * Turbo will still be enabled, but won't go above the set value.
  1378. */
  1379. dev_priv->max_delay = val / 50;
  1380. gen6_set_rps(dev, val / 50);
  1381. return cnt;
  1382. }
  1383. static const struct file_operations i915_max_freq_fops = {
  1384. .owner = THIS_MODULE,
  1385. .open = simple_open,
  1386. .read = i915_max_freq_read,
  1387. .write = i915_max_freq_write,
  1388. .llseek = default_llseek,
  1389. };
  1390. static ssize_t
  1391. i915_cache_sharing_read(struct file *filp,
  1392. char __user *ubuf,
  1393. size_t max,
  1394. loff_t *ppos)
  1395. {
  1396. struct drm_device *dev = filp->private_data;
  1397. drm_i915_private_t *dev_priv = dev->dev_private;
  1398. char buf[80];
  1399. u32 snpcr;
  1400. int len;
  1401. mutex_lock(&dev_priv->dev->struct_mutex);
  1402. snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
  1403. mutex_unlock(&dev_priv->dev->struct_mutex);
  1404. len = snprintf(buf, sizeof(buf),
  1405. "%d\n", (snpcr & GEN6_MBC_SNPCR_MASK) >>
  1406. GEN6_MBC_SNPCR_SHIFT);
  1407. if (len > sizeof(buf))
  1408. len = sizeof(buf);
  1409. return simple_read_from_buffer(ubuf, max, ppos, buf, len);
  1410. }
  1411. static ssize_t
  1412. i915_cache_sharing_write(struct file *filp,
  1413. const char __user *ubuf,
  1414. size_t cnt,
  1415. loff_t *ppos)
  1416. {
  1417. struct drm_device *dev = filp->private_data;
  1418. struct drm_i915_private *dev_priv = dev->dev_private;
  1419. char buf[20];
  1420. u32 snpcr;
  1421. int val = 1;
  1422. if (cnt > 0) {
  1423. if (cnt > sizeof(buf) - 1)
  1424. return -EINVAL;
  1425. if (copy_from_user(buf, ubuf, cnt))
  1426. return -EFAULT;
  1427. buf[cnt] = 0;
  1428. val = simple_strtoul(buf, NULL, 0);
  1429. }
  1430. if (val < 0 || val > 3)
  1431. return -EINVAL;
  1432. DRM_DEBUG_DRIVER("Manually setting uncore sharing to %d\n", val);
  1433. /* Update the cache sharing policy here as well */
  1434. snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
  1435. snpcr &= ~GEN6_MBC_SNPCR_MASK;
  1436. snpcr |= (val << GEN6_MBC_SNPCR_SHIFT);
  1437. I915_WRITE(GEN6_MBCUNIT_SNPCR, snpcr);
  1438. return cnt;
  1439. }
  1440. static const struct file_operations i915_cache_sharing_fops = {
  1441. .owner = THIS_MODULE,
  1442. .open = simple_open,
  1443. .read = i915_cache_sharing_read,
  1444. .write = i915_cache_sharing_write,
  1445. .llseek = default_llseek,
  1446. };
  1447. /* As the drm_debugfs_init() routines are called before dev->dev_private is
  1448. * allocated we need to hook into the minor for release. */
  1449. static int
  1450. drm_add_fake_info_node(struct drm_minor *minor,
  1451. struct dentry *ent,
  1452. const void *key)
  1453. {
  1454. struct drm_info_node *node;
  1455. node = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL);
  1456. if (node == NULL) {
  1457. debugfs_remove(ent);
  1458. return -ENOMEM;
  1459. }
  1460. node->minor = minor;
  1461. node->dent = ent;
  1462. node->info_ent = (void *) key;
  1463. mutex_lock(&minor->debugfs_lock);
  1464. list_add(&node->list, &minor->debugfs_list);
  1465. mutex_unlock(&minor->debugfs_lock);
  1466. return 0;
  1467. }
  1468. static int i915_forcewake_open(struct inode *inode, struct file *file)
  1469. {
  1470. struct drm_device *dev = inode->i_private;
  1471. struct drm_i915_private *dev_priv = dev->dev_private;
  1472. int ret;
  1473. if (INTEL_INFO(dev)->gen < 6)
  1474. return 0;
  1475. ret = mutex_lock_interruptible(&dev->struct_mutex);
  1476. if (ret)
  1477. return ret;
  1478. gen6_gt_force_wake_get(dev_priv);
  1479. mutex_unlock(&dev->struct_mutex);
  1480. return 0;
  1481. }
  1482. int i915_forcewake_release(struct inode *inode, struct file *file)
  1483. {
  1484. struct drm_device *dev = inode->i_private;
  1485. struct drm_i915_private *dev_priv = dev->dev_private;
  1486. if (INTEL_INFO(dev)->gen < 6)
  1487. return 0;
  1488. /*
  1489. * It's bad that we can potentially hang userspace if struct_mutex gets
  1490. * forever stuck. However, if we cannot acquire this lock it means that
  1491. * almost certainly the driver has hung, is not unload-able. Therefore
  1492. * hanging here is probably a minor inconvenience not to be seen my
  1493. * almost every user.
  1494. */
  1495. mutex_lock(&dev->struct_mutex);
  1496. gen6_gt_force_wake_put(dev_priv);
  1497. mutex_unlock(&dev->struct_mutex);
  1498. return 0;
  1499. }
  1500. static const struct file_operations i915_forcewake_fops = {
  1501. .owner = THIS_MODULE,
  1502. .open = i915_forcewake_open,
  1503. .release = i915_forcewake_release,
  1504. };
  1505. static int i915_forcewake_create(struct dentry *root, struct drm_minor *minor)
  1506. {
  1507. struct drm_device *dev = minor->dev;
  1508. struct dentry *ent;
  1509. ent = debugfs_create_file("i915_forcewake_user",
  1510. S_IRUSR,
  1511. root, dev,
  1512. &i915_forcewake_fops);
  1513. if (IS_ERR(ent))
  1514. return PTR_ERR(ent);
  1515. return drm_add_fake_info_node(minor, ent, &i915_forcewake_fops);
  1516. }
  1517. static int i915_debugfs_create(struct dentry *root,
  1518. struct drm_minor *minor,
  1519. const char *name,
  1520. const struct file_operations *fops)
  1521. {
  1522. struct drm_device *dev = minor->dev;
  1523. struct dentry *ent;
  1524. ent = debugfs_create_file(name,
  1525. S_IRUGO | S_IWUSR,
  1526. root, dev,
  1527. fops);
  1528. if (IS_ERR(ent))
  1529. return PTR_ERR(ent);
  1530. return drm_add_fake_info_node(minor, ent, fops);
  1531. }
  1532. static struct drm_info_list i915_debugfs_list[] = {
  1533. {"i915_capabilities", i915_capabilities, 0},
  1534. {"i915_gem_objects", i915_gem_object_info, 0},
  1535. {"i915_gem_gtt", i915_gem_gtt_info, 0},
  1536. {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST},
  1537. {"i915_gem_flushing", i915_gem_object_list_info, 0, (void *) FLUSHING_LIST},
  1538. {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST},
  1539. {"i915_gem_pinned", i915_gem_object_list_info, 0, (void *) PINNED_LIST},
  1540. {"i915_gem_deferred_free", i915_gem_object_list_info, 0, (void *) DEFERRED_FREE_LIST},
  1541. {"i915_gem_pageflip", i915_gem_pageflip_info, 0},
  1542. {"i915_gem_request", i915_gem_request_info, 0},
  1543. {"i915_gem_seqno", i915_gem_seqno_info, 0},
  1544. {"i915_gem_fence_regs", i915_gem_fence_regs_info, 0},
  1545. {"i915_gem_interrupt", i915_interrupt_info, 0},
  1546. {"i915_gem_hws", i915_hws_info, 0, (void *)RCS},
  1547. {"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS},
  1548. {"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS},
  1549. {"i915_ringbuffer_data", i915_ringbuffer_data, 0, (void *)RCS},
  1550. {"i915_ringbuffer_info", i915_ringbuffer_info, 0, (void *)RCS},
  1551. {"i915_bsd_ringbuffer_data", i915_ringbuffer_data, 0, (void *)VCS},
  1552. {"i915_bsd_ringbuffer_info", i915_ringbuffer_info, 0, (void *)VCS},
  1553. {"i915_blt_ringbuffer_data", i915_ringbuffer_data, 0, (void *)BCS},
  1554. {"i915_blt_ringbuffer_info", i915_ringbuffer_info, 0, (void *)BCS},
  1555. {"i915_error_state", i915_error_state, 0},
  1556. {"i915_rstdby_delays", i915_rstdby_delays, 0},
  1557. {"i915_cur_delayinfo", i915_cur_delayinfo, 0},
  1558. {"i915_delayfreq_table", i915_delayfreq_table, 0},
  1559. {"i915_inttoext_table", i915_inttoext_table, 0},
  1560. {"i915_drpc_info", i915_drpc_info, 0},
  1561. {"i915_emon_status", i915_emon_status, 0},
  1562. {"i915_ring_freq_table", i915_ring_freq_table, 0},
  1563. {"i915_gfxec", i915_gfxec, 0},
  1564. {"i915_fbc_status", i915_fbc_status, 0},
  1565. {"i915_sr_status", i915_sr_status, 0},
  1566. {"i915_opregion", i915_opregion, 0},
  1567. {"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
  1568. {"i915_context_status", i915_context_status, 0},
  1569. {"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0},
  1570. {"i915_swizzle_info", i915_swizzle_info, 0},
  1571. {"i915_ppgtt_info", i915_ppgtt_info, 0},
  1572. };
  1573. #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
  1574. int i915_debugfs_init(struct drm_minor *minor)
  1575. {
  1576. int ret;
  1577. ret = i915_debugfs_create(minor->debugfs_root, minor,
  1578. "i915_wedged",
  1579. &i915_wedged_fops);
  1580. if (ret)
  1581. return ret;
  1582. ret = i915_forcewake_create(minor->debugfs_root, minor);
  1583. if (ret)
  1584. return ret;
  1585. ret = i915_debugfs_create(minor->debugfs_root, minor,
  1586. "i915_max_freq",
  1587. &i915_max_freq_fops);
  1588. if (ret)
  1589. return ret;
  1590. ret = i915_debugfs_create(minor->debugfs_root, minor,
  1591. "i915_cache_sharing",
  1592. &i915_cache_sharing_fops);
  1593. if (ret)
  1594. return ret;
  1595. return drm_debugfs_create_files(i915_debugfs_list,
  1596. I915_DEBUGFS_ENTRIES,
  1597. minor->debugfs_root, minor);
  1598. }
  1599. void i915_debugfs_cleanup(struct drm_minor *minor)
  1600. {
  1601. drm_debugfs_remove_files(i915_debugfs_list,
  1602. I915_DEBUGFS_ENTRIES, minor);
  1603. drm_debugfs_remove_files((struct drm_info_list *) &i915_forcewake_fops,
  1604. 1, minor);
  1605. drm_debugfs_remove_files((struct drm_info_list *) &i915_wedged_fops,
  1606. 1, minor);
  1607. drm_debugfs_remove_files((struct drm_info_list *) &i915_max_freq_fops,
  1608. 1, minor);
  1609. drm_debugfs_remove_files((struct drm_info_list *) &i915_cache_sharing_fops,
  1610. 1, minor);
  1611. }
  1612. #endif /* CONFIG_DEBUG_FS */