i915_irq.c 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158
  1. /* i915_irq.c -- IRQ support for the I915 -*- linux-c -*-
  2. */
  3. /*
  4. * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
  5. * All Rights Reserved.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the
  9. * "Software"), to deal in the Software without restriction, including
  10. * without limitation the rights to use, copy, modify, merge, publish,
  11. * distribute, sub license, and/or sell copies of the Software, and to
  12. * permit persons to whom the Software is furnished to do so, subject to
  13. * the following conditions:
  14. *
  15. * The above copyright notice and this permission notice (including the
  16. * next paragraph) shall be included in all copies or substantial portions
  17. * of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  20. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  22. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  23. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  24. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  25. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. *
  27. */
  28. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  29. #include <linux/sysrq.h>
  30. #include <linux/slab.h>
  31. #include "drmP.h"
  32. #include "drm.h"
  33. #include "i915_drm.h"
  34. #include "i915_drv.h"
  35. #include "i915_trace.h"
  36. #include "intel_drv.h"
  37. #define MAX_NOPID ((u32)~0)
  38. /**
  39. * Interrupts that are always left unmasked.
  40. *
  41. * Since pipe events are edge-triggered from the PIPESTAT register to IIR,
  42. * we leave them always unmasked in IMR and then control enabling them through
  43. * PIPESTAT alone.
  44. */
  45. #define I915_INTERRUPT_ENABLE_FIX \
  46. (I915_ASLE_INTERRUPT | \
  47. I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | \
  48. I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | \
  49. I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT | \
  50. I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT | \
  51. I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT)
  52. /** Interrupts that we mask and unmask at runtime. */
  53. #define I915_INTERRUPT_ENABLE_VAR (I915_USER_INTERRUPT | I915_BSD_USER_INTERRUPT)
  54. #define I915_PIPE_VBLANK_STATUS (PIPE_START_VBLANK_INTERRUPT_STATUS |\
  55. PIPE_VBLANK_INTERRUPT_STATUS)
  56. #define I915_PIPE_VBLANK_ENABLE (PIPE_START_VBLANK_INTERRUPT_ENABLE |\
  57. PIPE_VBLANK_INTERRUPT_ENABLE)
  58. #define DRM_I915_VBLANK_PIPE_ALL (DRM_I915_VBLANK_PIPE_A | \
  59. DRM_I915_VBLANK_PIPE_B)
  60. /* For display hotplug interrupt */
  61. static void
  62. ironlake_enable_display_irq(drm_i915_private_t *dev_priv, u32 mask)
  63. {
  64. if ((dev_priv->irq_mask & mask) != 0) {
  65. dev_priv->irq_mask &= ~mask;
  66. I915_WRITE(DEIMR, dev_priv->irq_mask);
  67. POSTING_READ(DEIMR);
  68. }
  69. }
  70. static inline void
  71. ironlake_disable_display_irq(drm_i915_private_t *dev_priv, u32 mask)
  72. {
  73. if ((dev_priv->irq_mask & mask) != mask) {
  74. dev_priv->irq_mask |= mask;
  75. I915_WRITE(DEIMR, dev_priv->irq_mask);
  76. POSTING_READ(DEIMR);
  77. }
  78. }
  79. void
  80. i915_enable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask)
  81. {
  82. if ((dev_priv->pipestat[pipe] & mask) != mask) {
  83. u32 reg = PIPESTAT(pipe);
  84. dev_priv->pipestat[pipe] |= mask;
  85. /* Enable the interrupt, clear any pending status */
  86. I915_WRITE(reg, dev_priv->pipestat[pipe] | (mask >> 16));
  87. POSTING_READ(reg);
  88. }
  89. }
  90. void
  91. i915_disable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask)
  92. {
  93. if ((dev_priv->pipestat[pipe] & mask) != 0) {
  94. u32 reg = PIPESTAT(pipe);
  95. dev_priv->pipestat[pipe] &= ~mask;
  96. I915_WRITE(reg, dev_priv->pipestat[pipe]);
  97. POSTING_READ(reg);
  98. }
  99. }
  100. /**
  101. * intel_enable_asle - enable ASLE interrupt for OpRegion
  102. */
  103. void intel_enable_asle(struct drm_device *dev)
  104. {
  105. drm_i915_private_t *dev_priv = dev->dev_private;
  106. unsigned long irqflags;
  107. spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
  108. if (HAS_PCH_SPLIT(dev))
  109. ironlake_enable_display_irq(dev_priv, DE_GSE);
  110. else {
  111. i915_enable_pipestat(dev_priv, 1,
  112. PIPE_LEGACY_BLC_EVENT_ENABLE);
  113. if (INTEL_INFO(dev)->gen >= 4)
  114. i915_enable_pipestat(dev_priv, 0,
  115. PIPE_LEGACY_BLC_EVENT_ENABLE);
  116. }
  117. spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
  118. }
  119. /**
  120. * i915_pipe_enabled - check if a pipe is enabled
  121. * @dev: DRM device
  122. * @pipe: pipe to check
  123. *
  124. * Reading certain registers when the pipe is disabled can hang the chip.
  125. * Use this routine to make sure the PLL is running and the pipe is active
  126. * before reading such registers if unsure.
  127. */
  128. static int
  129. i915_pipe_enabled(struct drm_device *dev, int pipe)
  130. {
  131. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  132. return I915_READ(PIPECONF(pipe)) & PIPECONF_ENABLE;
  133. }
  134. /* Called from drm generic code, passed a 'crtc', which
  135. * we use as a pipe index
  136. */
  137. static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
  138. {
  139. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  140. unsigned long high_frame;
  141. unsigned long low_frame;
  142. u32 high1, high2, low;
  143. if (!i915_pipe_enabled(dev, pipe)) {
  144. DRM_DEBUG_DRIVER("trying to get vblank count for disabled "
  145. "pipe %c\n", pipe_name(pipe));
  146. return 0;
  147. }
  148. high_frame = PIPEFRAME(pipe);
  149. low_frame = PIPEFRAMEPIXEL(pipe);
  150. /*
  151. * High & low register fields aren't synchronized, so make sure
  152. * we get a low value that's stable across two reads of the high
  153. * register.
  154. */
  155. do {
  156. high1 = I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK;
  157. low = I915_READ(low_frame) & PIPE_FRAME_LOW_MASK;
  158. high2 = I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK;
  159. } while (high1 != high2);
  160. high1 >>= PIPE_FRAME_HIGH_SHIFT;
  161. low >>= PIPE_FRAME_LOW_SHIFT;
  162. return (high1 << 8) | low;
  163. }
  164. static u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe)
  165. {
  166. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  167. int reg = PIPE_FRMCOUNT_GM45(pipe);
  168. if (!i915_pipe_enabled(dev, pipe)) {
  169. DRM_DEBUG_DRIVER("trying to get vblank count for disabled "
  170. "pipe %c\n", pipe_name(pipe));
  171. return 0;
  172. }
  173. return I915_READ(reg);
  174. }
  175. static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,
  176. int *vpos, int *hpos)
  177. {
  178. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  179. u32 vbl = 0, position = 0;
  180. int vbl_start, vbl_end, htotal, vtotal;
  181. bool in_vbl = true;
  182. int ret = 0;
  183. if (!i915_pipe_enabled(dev, pipe)) {
  184. DRM_DEBUG_DRIVER("trying to get scanoutpos for disabled "
  185. "pipe %c\n", pipe_name(pipe));
  186. return 0;
  187. }
  188. /* Get vtotal. */
  189. vtotal = 1 + ((I915_READ(VTOTAL(pipe)) >> 16) & 0x1fff);
  190. if (INTEL_INFO(dev)->gen >= 4) {
  191. /* No obvious pixelcount register. Only query vertical
  192. * scanout position from Display scan line register.
  193. */
  194. position = I915_READ(PIPEDSL(pipe));
  195. /* Decode into vertical scanout position. Don't have
  196. * horizontal scanout position.
  197. */
  198. *vpos = position & 0x1fff;
  199. *hpos = 0;
  200. } else {
  201. /* Have access to pixelcount since start of frame.
  202. * We can split this into vertical and horizontal
  203. * scanout position.
  204. */
  205. position = (I915_READ(PIPEFRAMEPIXEL(pipe)) & PIPE_PIXEL_MASK) >> PIPE_PIXEL_SHIFT;
  206. htotal = 1 + ((I915_READ(HTOTAL(pipe)) >> 16) & 0x1fff);
  207. *vpos = position / htotal;
  208. *hpos = position - (*vpos * htotal);
  209. }
  210. /* Query vblank area. */
  211. vbl = I915_READ(VBLANK(pipe));
  212. /* Test position against vblank region. */
  213. vbl_start = vbl & 0x1fff;
  214. vbl_end = (vbl >> 16) & 0x1fff;
  215. if ((*vpos < vbl_start) || (*vpos > vbl_end))
  216. in_vbl = false;
  217. /* Inside "upper part" of vblank area? Apply corrective offset: */
  218. if (in_vbl && (*vpos >= vbl_start))
  219. *vpos = *vpos - vtotal;
  220. /* Readouts valid? */
  221. if (vbl > 0)
  222. ret |= DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE;
  223. /* In vblank? */
  224. if (in_vbl)
  225. ret |= DRM_SCANOUTPOS_INVBL;
  226. return ret;
  227. }
  228. static int i915_get_vblank_timestamp(struct drm_device *dev, int pipe,
  229. int *max_error,
  230. struct timeval *vblank_time,
  231. unsigned flags)
  232. {
  233. struct drm_i915_private *dev_priv = dev->dev_private;
  234. struct drm_crtc *crtc;
  235. if (pipe < 0 || pipe >= dev_priv->num_pipe) {
  236. DRM_ERROR("Invalid crtc %d\n", pipe);
  237. return -EINVAL;
  238. }
  239. /* Get drm_crtc to timestamp: */
  240. crtc = intel_get_crtc_for_pipe(dev, pipe);
  241. if (crtc == NULL) {
  242. DRM_ERROR("Invalid crtc %d\n", pipe);
  243. return -EINVAL;
  244. }
  245. if (!crtc->enabled) {
  246. DRM_DEBUG_KMS("crtc %d is disabled\n", pipe);
  247. return -EBUSY;
  248. }
  249. /* Helper routine in DRM core does all the work: */
  250. return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
  251. vblank_time, flags,
  252. crtc);
  253. }
  254. /*
  255. * Handle hotplug events outside the interrupt handler proper.
  256. */
  257. static void i915_hotplug_work_func(struct work_struct *work)
  258. {
  259. drm_i915_private_t *dev_priv = container_of(work, drm_i915_private_t,
  260. hotplug_work);
  261. struct drm_device *dev = dev_priv->dev;
  262. struct drm_mode_config *mode_config = &dev->mode_config;
  263. struct intel_encoder *encoder;
  264. mutex_lock(&mode_config->mutex);
  265. DRM_DEBUG_KMS("running encoder hotplug functions\n");
  266. list_for_each_entry(encoder, &mode_config->encoder_list, base.head)
  267. if (encoder->hot_plug)
  268. encoder->hot_plug(encoder);
  269. mutex_unlock(&mode_config->mutex);
  270. /* Just fire off a uevent and let userspace tell us what to do */
  271. drm_helper_hpd_irq_event(dev);
  272. }
  273. static void i915_handle_rps_change(struct drm_device *dev)
  274. {
  275. drm_i915_private_t *dev_priv = dev->dev_private;
  276. u32 busy_up, busy_down, max_avg, min_avg;
  277. u8 new_delay = dev_priv->cur_delay;
  278. I915_WRITE16(MEMINTRSTS, MEMINT_EVAL_CHG);
  279. busy_up = I915_READ(RCPREVBSYTUPAVG);
  280. busy_down = I915_READ(RCPREVBSYTDNAVG);
  281. max_avg = I915_READ(RCBMAXAVG);
  282. min_avg = I915_READ(RCBMINAVG);
  283. /* Handle RCS change request from hw */
  284. if (busy_up > max_avg) {
  285. if (dev_priv->cur_delay != dev_priv->max_delay)
  286. new_delay = dev_priv->cur_delay - 1;
  287. if (new_delay < dev_priv->max_delay)
  288. new_delay = dev_priv->max_delay;
  289. } else if (busy_down < min_avg) {
  290. if (dev_priv->cur_delay != dev_priv->min_delay)
  291. new_delay = dev_priv->cur_delay + 1;
  292. if (new_delay > dev_priv->min_delay)
  293. new_delay = dev_priv->min_delay;
  294. }
  295. if (ironlake_set_drps(dev, new_delay))
  296. dev_priv->cur_delay = new_delay;
  297. return;
  298. }
  299. static void notify_ring(struct drm_device *dev,
  300. struct intel_ring_buffer *ring)
  301. {
  302. struct drm_i915_private *dev_priv = dev->dev_private;
  303. u32 seqno;
  304. if (ring->obj == NULL)
  305. return;
  306. seqno = ring->get_seqno(ring);
  307. trace_i915_gem_request_complete(ring, seqno);
  308. ring->irq_seqno = seqno;
  309. wake_up_all(&ring->irq_queue);
  310. if (i915_enable_hangcheck) {
  311. dev_priv->hangcheck_count = 0;
  312. mod_timer(&dev_priv->hangcheck_timer,
  313. jiffies +
  314. msecs_to_jiffies(DRM_I915_HANGCHECK_PERIOD));
  315. }
  316. }
  317. static void gen6_pm_rps_work(struct work_struct *work)
  318. {
  319. drm_i915_private_t *dev_priv = container_of(work, drm_i915_private_t,
  320. rps_work);
  321. u8 new_delay = dev_priv->cur_delay;
  322. u32 pm_iir, pm_imr;
  323. spin_lock_irq(&dev_priv->rps_lock);
  324. pm_iir = dev_priv->pm_iir;
  325. dev_priv->pm_iir = 0;
  326. pm_imr = I915_READ(GEN6_PMIMR);
  327. I915_WRITE(GEN6_PMIMR, 0);
  328. spin_unlock_irq(&dev_priv->rps_lock);
  329. if (!pm_iir)
  330. return;
  331. mutex_lock(&dev_priv->dev->struct_mutex);
  332. if (pm_iir & GEN6_PM_RP_UP_THRESHOLD) {
  333. if (dev_priv->cur_delay != dev_priv->max_delay)
  334. new_delay = dev_priv->cur_delay + 1;
  335. if (new_delay > dev_priv->max_delay)
  336. new_delay = dev_priv->max_delay;
  337. } else if (pm_iir & (GEN6_PM_RP_DOWN_THRESHOLD | GEN6_PM_RP_DOWN_TIMEOUT)) {
  338. gen6_gt_force_wake_get(dev_priv);
  339. if (dev_priv->cur_delay != dev_priv->min_delay)
  340. new_delay = dev_priv->cur_delay - 1;
  341. if (new_delay < dev_priv->min_delay) {
  342. new_delay = dev_priv->min_delay;
  343. I915_WRITE(GEN6_RP_INTERRUPT_LIMITS,
  344. I915_READ(GEN6_RP_INTERRUPT_LIMITS) |
  345. ((new_delay << 16) & 0x3f0000));
  346. } else {
  347. /* Make sure we continue to get down interrupts
  348. * until we hit the minimum frequency */
  349. I915_WRITE(GEN6_RP_INTERRUPT_LIMITS,
  350. I915_READ(GEN6_RP_INTERRUPT_LIMITS) & ~0x3f0000);
  351. }
  352. gen6_gt_force_wake_put(dev_priv);
  353. }
  354. gen6_set_rps(dev_priv->dev, new_delay);
  355. dev_priv->cur_delay = new_delay;
  356. /*
  357. * rps_lock not held here because clearing is non-destructive. There is
  358. * an *extremely* unlikely race with gen6_rps_enable() that is prevented
  359. * by holding struct_mutex for the duration of the write.
  360. */
  361. mutex_unlock(&dev_priv->dev->struct_mutex);
  362. }
  363. static void pch_irq_handler(struct drm_device *dev)
  364. {
  365. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  366. u32 pch_iir;
  367. int pipe;
  368. pch_iir = I915_READ(SDEIIR);
  369. if (pch_iir & SDE_AUDIO_POWER_MASK)
  370. DRM_DEBUG_DRIVER("PCH audio power change on port %d\n",
  371. (pch_iir & SDE_AUDIO_POWER_MASK) >>
  372. SDE_AUDIO_POWER_SHIFT);
  373. if (pch_iir & SDE_GMBUS)
  374. DRM_DEBUG_DRIVER("PCH GMBUS interrupt\n");
  375. if (pch_iir & SDE_AUDIO_HDCP_MASK)
  376. DRM_DEBUG_DRIVER("PCH HDCP audio interrupt\n");
  377. if (pch_iir & SDE_AUDIO_TRANS_MASK)
  378. DRM_DEBUG_DRIVER("PCH transcoder audio interrupt\n");
  379. if (pch_iir & SDE_POISON)
  380. DRM_ERROR("PCH poison interrupt\n");
  381. if (pch_iir & SDE_FDI_MASK)
  382. for_each_pipe(pipe)
  383. DRM_DEBUG_DRIVER(" pipe %c FDI IIR: 0x%08x\n",
  384. pipe_name(pipe),
  385. I915_READ(FDI_RX_IIR(pipe)));
  386. if (pch_iir & (SDE_TRANSB_CRC_DONE | SDE_TRANSA_CRC_DONE))
  387. DRM_DEBUG_DRIVER("PCH transcoder CRC done interrupt\n");
  388. if (pch_iir & (SDE_TRANSB_CRC_ERR | SDE_TRANSA_CRC_ERR))
  389. DRM_DEBUG_DRIVER("PCH transcoder CRC error interrupt\n");
  390. if (pch_iir & SDE_TRANSB_FIFO_UNDER)
  391. DRM_DEBUG_DRIVER("PCH transcoder B underrun interrupt\n");
  392. if (pch_iir & SDE_TRANSA_FIFO_UNDER)
  393. DRM_DEBUG_DRIVER("PCH transcoder A underrun interrupt\n");
  394. }
  395. static irqreturn_t ivybridge_irq_handler(DRM_IRQ_ARGS)
  396. {
  397. struct drm_device *dev = (struct drm_device *) arg;
  398. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  399. int ret = IRQ_NONE;
  400. u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
  401. struct drm_i915_master_private *master_priv;
  402. atomic_inc(&dev_priv->irq_received);
  403. /* disable master interrupt before clearing iir */
  404. de_ier = I915_READ(DEIER);
  405. I915_WRITE(DEIER, de_ier & ~DE_MASTER_IRQ_CONTROL);
  406. POSTING_READ(DEIER);
  407. de_iir = I915_READ(DEIIR);
  408. gt_iir = I915_READ(GTIIR);
  409. pch_iir = I915_READ(SDEIIR);
  410. pm_iir = I915_READ(GEN6_PMIIR);
  411. if (de_iir == 0 && gt_iir == 0 && pch_iir == 0 && pm_iir == 0)
  412. goto done;
  413. ret = IRQ_HANDLED;
  414. if (dev->primary->master) {
  415. master_priv = dev->primary->master->driver_priv;
  416. if (master_priv->sarea_priv)
  417. master_priv->sarea_priv->last_dispatch =
  418. READ_BREADCRUMB(dev_priv);
  419. }
  420. if (gt_iir & (GT_USER_INTERRUPT | GT_PIPE_NOTIFY))
  421. notify_ring(dev, &dev_priv->ring[RCS]);
  422. if (gt_iir & GT_GEN6_BSD_USER_INTERRUPT)
  423. notify_ring(dev, &dev_priv->ring[VCS]);
  424. if (gt_iir & GT_BLT_USER_INTERRUPT)
  425. notify_ring(dev, &dev_priv->ring[BCS]);
  426. if (de_iir & DE_GSE_IVB)
  427. intel_opregion_gse_intr(dev);
  428. if (de_iir & DE_PLANEA_FLIP_DONE_IVB) {
  429. intel_prepare_page_flip(dev, 0);
  430. intel_finish_page_flip_plane(dev, 0);
  431. }
  432. if (de_iir & DE_PLANEB_FLIP_DONE_IVB) {
  433. intel_prepare_page_flip(dev, 1);
  434. intel_finish_page_flip_plane(dev, 1);
  435. }
  436. if (de_iir & DE_PIPEA_VBLANK_IVB)
  437. drm_handle_vblank(dev, 0);
  438. if (de_iir & DE_PIPEB_VBLANK_IVB)
  439. drm_handle_vblank(dev, 1);
  440. /* check event from PCH */
  441. if (de_iir & DE_PCH_EVENT_IVB) {
  442. if (pch_iir & SDE_HOTPLUG_MASK_CPT)
  443. queue_work(dev_priv->wq, &dev_priv->hotplug_work);
  444. pch_irq_handler(dev);
  445. }
  446. if (pm_iir & GEN6_PM_DEFERRED_EVENTS) {
  447. unsigned long flags;
  448. spin_lock_irqsave(&dev_priv->rps_lock, flags);
  449. WARN(dev_priv->pm_iir & pm_iir, "Missed a PM interrupt\n");
  450. dev_priv->pm_iir |= pm_iir;
  451. I915_WRITE(GEN6_PMIMR, dev_priv->pm_iir);
  452. POSTING_READ(GEN6_PMIMR);
  453. spin_unlock_irqrestore(&dev_priv->rps_lock, flags);
  454. queue_work(dev_priv->wq, &dev_priv->rps_work);
  455. }
  456. /* should clear PCH hotplug event before clear CPU irq */
  457. I915_WRITE(SDEIIR, pch_iir);
  458. I915_WRITE(GTIIR, gt_iir);
  459. I915_WRITE(DEIIR, de_iir);
  460. I915_WRITE(GEN6_PMIIR, pm_iir);
  461. done:
  462. I915_WRITE(DEIER, de_ier);
  463. POSTING_READ(DEIER);
  464. return ret;
  465. }
  466. static irqreturn_t ironlake_irq_handler(DRM_IRQ_ARGS)
  467. {
  468. struct drm_device *dev = (struct drm_device *) arg;
  469. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  470. int ret = IRQ_NONE;
  471. u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
  472. u32 hotplug_mask;
  473. struct drm_i915_master_private *master_priv;
  474. u32 bsd_usr_interrupt = GT_BSD_USER_INTERRUPT;
  475. atomic_inc(&dev_priv->irq_received);
  476. if (IS_GEN6(dev))
  477. bsd_usr_interrupt = GT_GEN6_BSD_USER_INTERRUPT;
  478. /* disable master interrupt before clearing iir */
  479. de_ier = I915_READ(DEIER);
  480. I915_WRITE(DEIER, de_ier & ~DE_MASTER_IRQ_CONTROL);
  481. POSTING_READ(DEIER);
  482. de_iir = I915_READ(DEIIR);
  483. gt_iir = I915_READ(GTIIR);
  484. pch_iir = I915_READ(SDEIIR);
  485. pm_iir = I915_READ(GEN6_PMIIR);
  486. if (de_iir == 0 && gt_iir == 0 && pch_iir == 0 &&
  487. (!IS_GEN6(dev) || pm_iir == 0))
  488. goto done;
  489. if (HAS_PCH_CPT(dev))
  490. hotplug_mask = SDE_HOTPLUG_MASK_CPT;
  491. else
  492. hotplug_mask = SDE_HOTPLUG_MASK;
  493. ret = IRQ_HANDLED;
  494. if (dev->primary->master) {
  495. master_priv = dev->primary->master->driver_priv;
  496. if (master_priv->sarea_priv)
  497. master_priv->sarea_priv->last_dispatch =
  498. READ_BREADCRUMB(dev_priv);
  499. }
  500. if (gt_iir & (GT_USER_INTERRUPT | GT_PIPE_NOTIFY))
  501. notify_ring(dev, &dev_priv->ring[RCS]);
  502. if (gt_iir & bsd_usr_interrupt)
  503. notify_ring(dev, &dev_priv->ring[VCS]);
  504. if (gt_iir & GT_BLT_USER_INTERRUPT)
  505. notify_ring(dev, &dev_priv->ring[BCS]);
  506. if (de_iir & DE_GSE)
  507. intel_opregion_gse_intr(dev);
  508. if (de_iir & DE_PLANEA_FLIP_DONE) {
  509. intel_prepare_page_flip(dev, 0);
  510. intel_finish_page_flip_plane(dev, 0);
  511. }
  512. if (de_iir & DE_PLANEB_FLIP_DONE) {
  513. intel_prepare_page_flip(dev, 1);
  514. intel_finish_page_flip_plane(dev, 1);
  515. }
  516. if (de_iir & DE_PIPEA_VBLANK)
  517. drm_handle_vblank(dev, 0);
  518. if (de_iir & DE_PIPEB_VBLANK)
  519. drm_handle_vblank(dev, 1);
  520. /* check event from PCH */
  521. if (de_iir & DE_PCH_EVENT) {
  522. if (pch_iir & hotplug_mask)
  523. queue_work(dev_priv->wq, &dev_priv->hotplug_work);
  524. pch_irq_handler(dev);
  525. }
  526. if (de_iir & DE_PCU_EVENT) {
  527. I915_WRITE16(MEMINTRSTS, I915_READ(MEMINTRSTS));
  528. i915_handle_rps_change(dev);
  529. }
  530. if (IS_GEN6(dev) && pm_iir & GEN6_PM_DEFERRED_EVENTS) {
  531. /*
  532. * IIR bits should never already be set because IMR should
  533. * prevent an interrupt from being shown in IIR. The warning
  534. * displays a case where we've unsafely cleared
  535. * dev_priv->pm_iir. Although missing an interrupt of the same
  536. * type is not a problem, it displays a problem in the logic.
  537. *
  538. * The mask bit in IMR is cleared by rps_work.
  539. */
  540. unsigned long flags;
  541. spin_lock_irqsave(&dev_priv->rps_lock, flags);
  542. WARN(dev_priv->pm_iir & pm_iir, "Missed a PM interrupt\n");
  543. dev_priv->pm_iir |= pm_iir;
  544. I915_WRITE(GEN6_PMIMR, dev_priv->pm_iir);
  545. POSTING_READ(GEN6_PMIMR);
  546. spin_unlock_irqrestore(&dev_priv->rps_lock, flags);
  547. queue_work(dev_priv->wq, &dev_priv->rps_work);
  548. }
  549. /* should clear PCH hotplug event before clear CPU irq */
  550. I915_WRITE(SDEIIR, pch_iir);
  551. I915_WRITE(GTIIR, gt_iir);
  552. I915_WRITE(DEIIR, de_iir);
  553. I915_WRITE(GEN6_PMIIR, pm_iir);
  554. done:
  555. I915_WRITE(DEIER, de_ier);
  556. POSTING_READ(DEIER);
  557. return ret;
  558. }
  559. /**
  560. * i915_error_work_func - do process context error handling work
  561. * @work: work struct
  562. *
  563. * Fire an error uevent so userspace can see that a hang or error
  564. * was detected.
  565. */
  566. static void i915_error_work_func(struct work_struct *work)
  567. {
  568. drm_i915_private_t *dev_priv = container_of(work, drm_i915_private_t,
  569. error_work);
  570. struct drm_device *dev = dev_priv->dev;
  571. char *error_event[] = { "ERROR=1", NULL };
  572. char *reset_event[] = { "RESET=1", NULL };
  573. char *reset_done_event[] = { "ERROR=0", NULL };
  574. kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, error_event);
  575. if (atomic_read(&dev_priv->mm.wedged)) {
  576. DRM_DEBUG_DRIVER("resetting chip\n");
  577. kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, reset_event);
  578. if (!i915_reset(dev, GRDOM_RENDER)) {
  579. atomic_set(&dev_priv->mm.wedged, 0);
  580. kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, reset_done_event);
  581. }
  582. complete_all(&dev_priv->error_completion);
  583. }
  584. }
  585. #ifdef CONFIG_DEBUG_FS
  586. static struct drm_i915_error_object *
  587. i915_error_object_create(struct drm_i915_private *dev_priv,
  588. struct drm_i915_gem_object *src)
  589. {
  590. struct drm_i915_error_object *dst;
  591. int page, page_count;
  592. u32 reloc_offset;
  593. if (src == NULL || src->pages == NULL)
  594. return NULL;
  595. page_count = src->base.size / PAGE_SIZE;
  596. dst = kmalloc(sizeof(*dst) + page_count * sizeof(u32 *), GFP_ATOMIC);
  597. if (dst == NULL)
  598. return NULL;
  599. reloc_offset = src->gtt_offset;
  600. for (page = 0; page < page_count; page++) {
  601. unsigned long flags;
  602. void *d;
  603. d = kmalloc(PAGE_SIZE, GFP_ATOMIC);
  604. if (d == NULL)
  605. goto unwind;
  606. local_irq_save(flags);
  607. if (reloc_offset < dev_priv->mm.gtt_mappable_end &&
  608. src->has_global_gtt_mapping) {
  609. void __iomem *s;
  610. /* Simply ignore tiling or any overlapping fence.
  611. * It's part of the error state, and this hopefully
  612. * captures what the GPU read.
  613. */
  614. s = io_mapping_map_atomic_wc(dev_priv->mm.gtt_mapping,
  615. reloc_offset);
  616. memcpy_fromio(d, s, PAGE_SIZE);
  617. io_mapping_unmap_atomic(s);
  618. } else {
  619. void *s;
  620. drm_clflush_pages(&src->pages[page], 1);
  621. s = kmap_atomic(src->pages[page]);
  622. memcpy(d, s, PAGE_SIZE);
  623. kunmap_atomic(s);
  624. drm_clflush_pages(&src->pages[page], 1);
  625. }
  626. local_irq_restore(flags);
  627. dst->pages[page] = d;
  628. reloc_offset += PAGE_SIZE;
  629. }
  630. dst->page_count = page_count;
  631. dst->gtt_offset = src->gtt_offset;
  632. return dst;
  633. unwind:
  634. while (page--)
  635. kfree(dst->pages[page]);
  636. kfree(dst);
  637. return NULL;
  638. }
  639. static void
  640. i915_error_object_free(struct drm_i915_error_object *obj)
  641. {
  642. int page;
  643. if (obj == NULL)
  644. return;
  645. for (page = 0; page < obj->page_count; page++)
  646. kfree(obj->pages[page]);
  647. kfree(obj);
  648. }
  649. static void
  650. i915_error_state_free(struct drm_device *dev,
  651. struct drm_i915_error_state *error)
  652. {
  653. int i;
  654. for (i = 0; i < ARRAY_SIZE(error->ring); i++) {
  655. i915_error_object_free(error->ring[i].batchbuffer);
  656. i915_error_object_free(error->ring[i].ringbuffer);
  657. kfree(error->ring[i].requests);
  658. }
  659. kfree(error->active_bo);
  660. kfree(error->overlay);
  661. kfree(error);
  662. }
  663. static u32 capture_bo_list(struct drm_i915_error_buffer *err,
  664. int count,
  665. struct list_head *head)
  666. {
  667. struct drm_i915_gem_object *obj;
  668. int i = 0;
  669. list_for_each_entry(obj, head, mm_list) {
  670. err->size = obj->base.size;
  671. err->name = obj->base.name;
  672. err->seqno = obj->last_rendering_seqno;
  673. err->gtt_offset = obj->gtt_offset;
  674. err->read_domains = obj->base.read_domains;
  675. err->write_domain = obj->base.write_domain;
  676. err->fence_reg = obj->fence_reg;
  677. err->pinned = 0;
  678. if (obj->pin_count > 0)
  679. err->pinned = 1;
  680. if (obj->user_pin_count > 0)
  681. err->pinned = -1;
  682. err->tiling = obj->tiling_mode;
  683. err->dirty = obj->dirty;
  684. err->purgeable = obj->madv != I915_MADV_WILLNEED;
  685. err->ring = obj->ring ? obj->ring->id : -1;
  686. err->cache_level = obj->cache_level;
  687. if (++i == count)
  688. break;
  689. err++;
  690. }
  691. return i;
  692. }
  693. static void i915_gem_record_fences(struct drm_device *dev,
  694. struct drm_i915_error_state *error)
  695. {
  696. struct drm_i915_private *dev_priv = dev->dev_private;
  697. int i;
  698. /* Fences */
  699. switch (INTEL_INFO(dev)->gen) {
  700. case 7:
  701. case 6:
  702. for (i = 0; i < 16; i++)
  703. error->fence[i] = I915_READ64(FENCE_REG_SANDYBRIDGE_0 + (i * 8));
  704. break;
  705. case 5:
  706. case 4:
  707. for (i = 0; i < 16; i++)
  708. error->fence[i] = I915_READ64(FENCE_REG_965_0 + (i * 8));
  709. break;
  710. case 3:
  711. if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev))
  712. for (i = 0; i < 8; i++)
  713. error->fence[i+8] = I915_READ(FENCE_REG_945_8 + (i * 4));
  714. case 2:
  715. for (i = 0; i < 8; i++)
  716. error->fence[i] = I915_READ(FENCE_REG_830_0 + (i * 4));
  717. break;
  718. }
  719. }
  720. static struct drm_i915_error_object *
  721. i915_error_first_batchbuffer(struct drm_i915_private *dev_priv,
  722. struct intel_ring_buffer *ring)
  723. {
  724. struct drm_i915_gem_object *obj;
  725. u32 seqno;
  726. if (!ring->get_seqno)
  727. return NULL;
  728. seqno = ring->get_seqno(ring);
  729. list_for_each_entry(obj, &dev_priv->mm.active_list, mm_list) {
  730. if (obj->ring != ring)
  731. continue;
  732. if (i915_seqno_passed(seqno, obj->last_rendering_seqno))
  733. continue;
  734. if ((obj->base.read_domains & I915_GEM_DOMAIN_COMMAND) == 0)
  735. continue;
  736. /* We need to copy these to an anonymous buffer as the simplest
  737. * method to avoid being overwritten by userspace.
  738. */
  739. return i915_error_object_create(dev_priv, obj);
  740. }
  741. return NULL;
  742. }
  743. static void i915_record_ring_state(struct drm_device *dev,
  744. struct drm_i915_error_state *error,
  745. struct intel_ring_buffer *ring)
  746. {
  747. struct drm_i915_private *dev_priv = dev->dev_private;
  748. if (INTEL_INFO(dev)->gen >= 6) {
  749. error->faddr[ring->id] = I915_READ(RING_DMA_FADD(ring->mmio_base));
  750. error->fault_reg[ring->id] = I915_READ(RING_FAULT_REG(ring));
  751. error->semaphore_mboxes[ring->id][0]
  752. = I915_READ(RING_SYNC_0(ring->mmio_base));
  753. error->semaphore_mboxes[ring->id][1]
  754. = I915_READ(RING_SYNC_1(ring->mmio_base));
  755. }
  756. if (INTEL_INFO(dev)->gen >= 4) {
  757. error->ipeir[ring->id] = I915_READ(RING_IPEIR(ring->mmio_base));
  758. error->ipehr[ring->id] = I915_READ(RING_IPEHR(ring->mmio_base));
  759. error->instdone[ring->id] = I915_READ(RING_INSTDONE(ring->mmio_base));
  760. error->instps[ring->id] = I915_READ(RING_INSTPS(ring->mmio_base));
  761. if (ring->id == RCS) {
  762. error->instdone1 = I915_READ(INSTDONE1);
  763. error->bbaddr = I915_READ64(BB_ADDR);
  764. }
  765. } else {
  766. error->ipeir[ring->id] = I915_READ(IPEIR);
  767. error->ipehr[ring->id] = I915_READ(IPEHR);
  768. error->instdone[ring->id] = I915_READ(INSTDONE);
  769. }
  770. error->instpm[ring->id] = I915_READ(RING_INSTPM(ring->mmio_base));
  771. error->seqno[ring->id] = ring->get_seqno(ring);
  772. error->acthd[ring->id] = intel_ring_get_active_head(ring);
  773. error->head[ring->id] = I915_READ_HEAD(ring);
  774. error->tail[ring->id] = I915_READ_TAIL(ring);
  775. error->cpu_ring_head[ring->id] = ring->head;
  776. error->cpu_ring_tail[ring->id] = ring->tail;
  777. }
  778. static void i915_gem_record_rings(struct drm_device *dev,
  779. struct drm_i915_error_state *error)
  780. {
  781. struct drm_i915_private *dev_priv = dev->dev_private;
  782. struct drm_i915_gem_request *request;
  783. int i, count;
  784. for (i = 0; i < I915_NUM_RINGS; i++) {
  785. struct intel_ring_buffer *ring = &dev_priv->ring[i];
  786. if (ring->obj == NULL)
  787. continue;
  788. i915_record_ring_state(dev, error, ring);
  789. error->ring[i].batchbuffer =
  790. i915_error_first_batchbuffer(dev_priv, ring);
  791. error->ring[i].ringbuffer =
  792. i915_error_object_create(dev_priv, ring->obj);
  793. count = 0;
  794. list_for_each_entry(request, &ring->request_list, list)
  795. count++;
  796. error->ring[i].num_requests = count;
  797. error->ring[i].requests =
  798. kmalloc(count*sizeof(struct drm_i915_error_request),
  799. GFP_ATOMIC);
  800. if (error->ring[i].requests == NULL) {
  801. error->ring[i].num_requests = 0;
  802. continue;
  803. }
  804. count = 0;
  805. list_for_each_entry(request, &ring->request_list, list) {
  806. struct drm_i915_error_request *erq;
  807. erq = &error->ring[i].requests[count++];
  808. erq->seqno = request->seqno;
  809. erq->jiffies = request->emitted_jiffies;
  810. erq->tail = request->tail;
  811. }
  812. }
  813. }
  814. /**
  815. * i915_capture_error_state - capture an error record for later analysis
  816. * @dev: drm device
  817. *
  818. * Should be called when an error is detected (either a hang or an error
  819. * interrupt) to capture error state from the time of the error. Fills
  820. * out a structure which becomes available in debugfs for user level tools
  821. * to pick up.
  822. */
  823. static void i915_capture_error_state(struct drm_device *dev)
  824. {
  825. struct drm_i915_private *dev_priv = dev->dev_private;
  826. struct drm_i915_gem_object *obj;
  827. struct drm_i915_error_state *error;
  828. unsigned long flags;
  829. int i, pipe;
  830. spin_lock_irqsave(&dev_priv->error_lock, flags);
  831. error = dev_priv->first_error;
  832. spin_unlock_irqrestore(&dev_priv->error_lock, flags);
  833. if (error)
  834. return;
  835. /* Account for pipe specific data like PIPE*STAT */
  836. error = kzalloc(sizeof(*error), GFP_ATOMIC);
  837. if (!error) {
  838. DRM_DEBUG_DRIVER("out of memory, not capturing error state\n");
  839. return;
  840. }
  841. DRM_INFO("capturing error event; look for more information in /debug/dri/%d/i915_error_state\n",
  842. dev->primary->index);
  843. error->eir = I915_READ(EIR);
  844. error->pgtbl_er = I915_READ(PGTBL_ER);
  845. for_each_pipe(pipe)
  846. error->pipestat[pipe] = I915_READ(PIPESTAT(pipe));
  847. if (INTEL_INFO(dev)->gen >= 6) {
  848. error->error = I915_READ(ERROR_GEN6);
  849. error->done_reg = I915_READ(DONE_REG);
  850. }
  851. i915_gem_record_fences(dev, error);
  852. i915_gem_record_rings(dev, error);
  853. /* Record buffers on the active and pinned lists. */
  854. error->active_bo = NULL;
  855. error->pinned_bo = NULL;
  856. i = 0;
  857. list_for_each_entry(obj, &dev_priv->mm.active_list, mm_list)
  858. i++;
  859. error->active_bo_count = i;
  860. list_for_each_entry(obj, &dev_priv->mm.pinned_list, mm_list)
  861. i++;
  862. error->pinned_bo_count = i - error->active_bo_count;
  863. error->active_bo = NULL;
  864. error->pinned_bo = NULL;
  865. if (i) {
  866. error->active_bo = kmalloc(sizeof(*error->active_bo)*i,
  867. GFP_ATOMIC);
  868. if (error->active_bo)
  869. error->pinned_bo =
  870. error->active_bo + error->active_bo_count;
  871. }
  872. if (error->active_bo)
  873. error->active_bo_count =
  874. capture_bo_list(error->active_bo,
  875. error->active_bo_count,
  876. &dev_priv->mm.active_list);
  877. if (error->pinned_bo)
  878. error->pinned_bo_count =
  879. capture_bo_list(error->pinned_bo,
  880. error->pinned_bo_count,
  881. &dev_priv->mm.pinned_list);
  882. do_gettimeofday(&error->time);
  883. error->overlay = intel_overlay_capture_error_state(dev);
  884. error->display = intel_display_capture_error_state(dev);
  885. spin_lock_irqsave(&dev_priv->error_lock, flags);
  886. if (dev_priv->first_error == NULL) {
  887. dev_priv->first_error = error;
  888. error = NULL;
  889. }
  890. spin_unlock_irqrestore(&dev_priv->error_lock, flags);
  891. if (error)
  892. i915_error_state_free(dev, error);
  893. }
  894. void i915_destroy_error_state(struct drm_device *dev)
  895. {
  896. struct drm_i915_private *dev_priv = dev->dev_private;
  897. struct drm_i915_error_state *error;
  898. unsigned long flags;
  899. spin_lock_irqsave(&dev_priv->error_lock, flags);
  900. error = dev_priv->first_error;
  901. dev_priv->first_error = NULL;
  902. spin_unlock_irqrestore(&dev_priv->error_lock, flags);
  903. if (error)
  904. i915_error_state_free(dev, error);
  905. }
  906. #else
  907. #define i915_capture_error_state(x)
  908. #endif
  909. static void i915_report_and_clear_eir(struct drm_device *dev)
  910. {
  911. struct drm_i915_private *dev_priv = dev->dev_private;
  912. u32 eir = I915_READ(EIR);
  913. int pipe;
  914. if (!eir)
  915. return;
  916. pr_err("render error detected, EIR: 0x%08x\n", eir);
  917. if (IS_G4X(dev)) {
  918. if (eir & (GM45_ERROR_MEM_PRIV | GM45_ERROR_CP_PRIV)) {
  919. u32 ipeir = I915_READ(IPEIR_I965);
  920. pr_err(" IPEIR: 0x%08x\n", I915_READ(IPEIR_I965));
  921. pr_err(" IPEHR: 0x%08x\n", I915_READ(IPEHR_I965));
  922. pr_err(" INSTDONE: 0x%08x\n",
  923. I915_READ(INSTDONE_I965));
  924. pr_err(" INSTPS: 0x%08x\n", I915_READ(INSTPS));
  925. pr_err(" INSTDONE1: 0x%08x\n", I915_READ(INSTDONE1));
  926. pr_err(" ACTHD: 0x%08x\n", I915_READ(ACTHD_I965));
  927. I915_WRITE(IPEIR_I965, ipeir);
  928. POSTING_READ(IPEIR_I965);
  929. }
  930. if (eir & GM45_ERROR_PAGE_TABLE) {
  931. u32 pgtbl_err = I915_READ(PGTBL_ER);
  932. pr_err("page table error\n");
  933. pr_err(" PGTBL_ER: 0x%08x\n", pgtbl_err);
  934. I915_WRITE(PGTBL_ER, pgtbl_err);
  935. POSTING_READ(PGTBL_ER);
  936. }
  937. }
  938. if (!IS_GEN2(dev)) {
  939. if (eir & I915_ERROR_PAGE_TABLE) {
  940. u32 pgtbl_err = I915_READ(PGTBL_ER);
  941. pr_err("page table error\n");
  942. pr_err(" PGTBL_ER: 0x%08x\n", pgtbl_err);
  943. I915_WRITE(PGTBL_ER, pgtbl_err);
  944. POSTING_READ(PGTBL_ER);
  945. }
  946. }
  947. if (eir & I915_ERROR_MEMORY_REFRESH) {
  948. pr_err("memory refresh error:\n");
  949. for_each_pipe(pipe)
  950. pr_err("pipe %c stat: 0x%08x\n",
  951. pipe_name(pipe), I915_READ(PIPESTAT(pipe)));
  952. /* pipestat has already been acked */
  953. }
  954. if (eir & I915_ERROR_INSTRUCTION) {
  955. pr_err("instruction error\n");
  956. pr_err(" INSTPM: 0x%08x\n", I915_READ(INSTPM));
  957. if (INTEL_INFO(dev)->gen < 4) {
  958. u32 ipeir = I915_READ(IPEIR);
  959. pr_err(" IPEIR: 0x%08x\n", I915_READ(IPEIR));
  960. pr_err(" IPEHR: 0x%08x\n", I915_READ(IPEHR));
  961. pr_err(" INSTDONE: 0x%08x\n", I915_READ(INSTDONE));
  962. pr_err(" ACTHD: 0x%08x\n", I915_READ(ACTHD));
  963. I915_WRITE(IPEIR, ipeir);
  964. POSTING_READ(IPEIR);
  965. } else {
  966. u32 ipeir = I915_READ(IPEIR_I965);
  967. pr_err(" IPEIR: 0x%08x\n", I915_READ(IPEIR_I965));
  968. pr_err(" IPEHR: 0x%08x\n", I915_READ(IPEHR_I965));
  969. pr_err(" INSTDONE: 0x%08x\n",
  970. I915_READ(INSTDONE_I965));
  971. pr_err(" INSTPS: 0x%08x\n", I915_READ(INSTPS));
  972. pr_err(" INSTDONE1: 0x%08x\n", I915_READ(INSTDONE1));
  973. pr_err(" ACTHD: 0x%08x\n", I915_READ(ACTHD_I965));
  974. I915_WRITE(IPEIR_I965, ipeir);
  975. POSTING_READ(IPEIR_I965);
  976. }
  977. }
  978. I915_WRITE(EIR, eir);
  979. POSTING_READ(EIR);
  980. eir = I915_READ(EIR);
  981. if (eir) {
  982. /*
  983. * some errors might have become stuck,
  984. * mask them.
  985. */
  986. DRM_ERROR("EIR stuck: 0x%08x, masking\n", eir);
  987. I915_WRITE(EMR, I915_READ(EMR) | eir);
  988. I915_WRITE(IIR, I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT);
  989. }
  990. }
  991. /**
  992. * i915_handle_error - handle an error interrupt
  993. * @dev: drm device
  994. *
  995. * Do some basic checking of regsiter state at error interrupt time and
  996. * dump it to the syslog. Also call i915_capture_error_state() to make
  997. * sure we get a record and make it available in debugfs. Fire a uevent
  998. * so userspace knows something bad happened (should trigger collection
  999. * of a ring dump etc.).
  1000. */
  1001. void i915_handle_error(struct drm_device *dev, bool wedged)
  1002. {
  1003. struct drm_i915_private *dev_priv = dev->dev_private;
  1004. i915_capture_error_state(dev);
  1005. i915_report_and_clear_eir(dev);
  1006. if (wedged) {
  1007. INIT_COMPLETION(dev_priv->error_completion);
  1008. atomic_set(&dev_priv->mm.wedged, 1);
  1009. /*
  1010. * Wakeup waiting processes so they don't hang
  1011. */
  1012. wake_up_all(&dev_priv->ring[RCS].irq_queue);
  1013. if (HAS_BSD(dev))
  1014. wake_up_all(&dev_priv->ring[VCS].irq_queue);
  1015. if (HAS_BLT(dev))
  1016. wake_up_all(&dev_priv->ring[BCS].irq_queue);
  1017. }
  1018. queue_work(dev_priv->wq, &dev_priv->error_work);
  1019. }
  1020. static void i915_pageflip_stall_check(struct drm_device *dev, int pipe)
  1021. {
  1022. drm_i915_private_t *dev_priv = dev->dev_private;
  1023. struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
  1024. struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
  1025. struct drm_i915_gem_object *obj;
  1026. struct intel_unpin_work *work;
  1027. unsigned long flags;
  1028. bool stall_detected;
  1029. /* Ignore early vblank irqs */
  1030. if (intel_crtc == NULL)
  1031. return;
  1032. spin_lock_irqsave(&dev->event_lock, flags);
  1033. work = intel_crtc->unpin_work;
  1034. if (work == NULL || work->pending || !work->enable_stall_check) {
  1035. /* Either the pending flip IRQ arrived, or we're too early. Don't check */
  1036. spin_unlock_irqrestore(&dev->event_lock, flags);
  1037. return;
  1038. }
  1039. /* Potential stall - if we see that the flip has happened, assume a missed interrupt */
  1040. obj = work->pending_flip_obj;
  1041. if (INTEL_INFO(dev)->gen >= 4) {
  1042. int dspsurf = DSPSURF(intel_crtc->plane);
  1043. stall_detected = I915_READ(dspsurf) == obj->gtt_offset;
  1044. } else {
  1045. int dspaddr = DSPADDR(intel_crtc->plane);
  1046. stall_detected = I915_READ(dspaddr) == (obj->gtt_offset +
  1047. crtc->y * crtc->fb->pitches[0] +
  1048. crtc->x * crtc->fb->bits_per_pixel/8);
  1049. }
  1050. spin_unlock_irqrestore(&dev->event_lock, flags);
  1051. if (stall_detected) {
  1052. DRM_DEBUG_DRIVER("Pageflip stall detected\n");
  1053. intel_prepare_page_flip(dev, intel_crtc->plane);
  1054. }
  1055. }
  1056. static irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
  1057. {
  1058. struct drm_device *dev = (struct drm_device *) arg;
  1059. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1060. struct drm_i915_master_private *master_priv;
  1061. u32 iir, new_iir;
  1062. u32 pipe_stats[I915_MAX_PIPES];
  1063. u32 vblank_status;
  1064. int vblank = 0;
  1065. unsigned long irqflags;
  1066. int irq_received;
  1067. int ret = IRQ_NONE, pipe;
  1068. bool blc_event = false;
  1069. atomic_inc(&dev_priv->irq_received);
  1070. iir = I915_READ(IIR);
  1071. if (INTEL_INFO(dev)->gen >= 4)
  1072. vblank_status = PIPE_START_VBLANK_INTERRUPT_STATUS;
  1073. else
  1074. vblank_status = PIPE_VBLANK_INTERRUPT_STATUS;
  1075. for (;;) {
  1076. irq_received = iir != 0;
  1077. /* Can't rely on pipestat interrupt bit in iir as it might
  1078. * have been cleared after the pipestat interrupt was received.
  1079. * It doesn't set the bit in iir again, but it still produces
  1080. * interrupts (for non-MSI).
  1081. */
  1082. spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
  1083. if (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT)
  1084. i915_handle_error(dev, false);
  1085. for_each_pipe(pipe) {
  1086. int reg = PIPESTAT(pipe);
  1087. pipe_stats[pipe] = I915_READ(reg);
  1088. /*
  1089. * Clear the PIPE*STAT regs before the IIR
  1090. */
  1091. if (pipe_stats[pipe] & 0x8000ffff) {
  1092. if (pipe_stats[pipe] & PIPE_FIFO_UNDERRUN_STATUS)
  1093. DRM_DEBUG_DRIVER("pipe %c underrun\n",
  1094. pipe_name(pipe));
  1095. I915_WRITE(reg, pipe_stats[pipe]);
  1096. irq_received = 1;
  1097. }
  1098. }
  1099. spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
  1100. if (!irq_received)
  1101. break;
  1102. ret = IRQ_HANDLED;
  1103. /* Consume port. Then clear IIR or we'll miss events */
  1104. if ((I915_HAS_HOTPLUG(dev)) &&
  1105. (iir & I915_DISPLAY_PORT_INTERRUPT)) {
  1106. u32 hotplug_status = I915_READ(PORT_HOTPLUG_STAT);
  1107. DRM_DEBUG_DRIVER("hotplug event received, stat 0x%08x\n",
  1108. hotplug_status);
  1109. if (hotplug_status & dev_priv->hotplug_supported_mask)
  1110. queue_work(dev_priv->wq,
  1111. &dev_priv->hotplug_work);
  1112. I915_WRITE(PORT_HOTPLUG_STAT, hotplug_status);
  1113. I915_READ(PORT_HOTPLUG_STAT);
  1114. }
  1115. I915_WRITE(IIR, iir);
  1116. new_iir = I915_READ(IIR); /* Flush posted writes */
  1117. if (dev->primary->master) {
  1118. master_priv = dev->primary->master->driver_priv;
  1119. if (master_priv->sarea_priv)
  1120. master_priv->sarea_priv->last_dispatch =
  1121. READ_BREADCRUMB(dev_priv);
  1122. }
  1123. if (iir & I915_USER_INTERRUPT)
  1124. notify_ring(dev, &dev_priv->ring[RCS]);
  1125. if (iir & I915_BSD_USER_INTERRUPT)
  1126. notify_ring(dev, &dev_priv->ring[VCS]);
  1127. if (iir & I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT) {
  1128. intel_prepare_page_flip(dev, 0);
  1129. if (dev_priv->flip_pending_is_done)
  1130. intel_finish_page_flip_plane(dev, 0);
  1131. }
  1132. if (iir & I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT) {
  1133. intel_prepare_page_flip(dev, 1);
  1134. if (dev_priv->flip_pending_is_done)
  1135. intel_finish_page_flip_plane(dev, 1);
  1136. }
  1137. for_each_pipe(pipe) {
  1138. if (pipe_stats[pipe] & vblank_status &&
  1139. drm_handle_vblank(dev, pipe)) {
  1140. vblank++;
  1141. if (!dev_priv->flip_pending_is_done) {
  1142. i915_pageflip_stall_check(dev, pipe);
  1143. intel_finish_page_flip(dev, pipe);
  1144. }
  1145. }
  1146. if (pipe_stats[pipe] & PIPE_LEGACY_BLC_EVENT_STATUS)
  1147. blc_event = true;
  1148. }
  1149. if (blc_event || (iir & I915_ASLE_INTERRUPT))
  1150. intel_opregion_asle_intr(dev);
  1151. /* With MSI, interrupts are only generated when iir
  1152. * transitions from zero to nonzero. If another bit got
  1153. * set while we were handling the existing iir bits, then
  1154. * we would never get another interrupt.
  1155. *
  1156. * This is fine on non-MSI as well, as if we hit this path
  1157. * we avoid exiting the interrupt handler only to generate
  1158. * another one.
  1159. *
  1160. * Note that for MSI this could cause a stray interrupt report
  1161. * if an interrupt landed in the time between writing IIR and
  1162. * the posting read. This should be rare enough to never
  1163. * trigger the 99% of 100,000 interrupts test for disabling
  1164. * stray interrupts.
  1165. */
  1166. iir = new_iir;
  1167. }
  1168. return ret;
  1169. }
  1170. static int i915_emit_irq(struct drm_device * dev)
  1171. {
  1172. drm_i915_private_t *dev_priv = dev->dev_private;
  1173. struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
  1174. i915_kernel_lost_context(dev);
  1175. DRM_DEBUG_DRIVER("\n");
  1176. dev_priv->counter++;
  1177. if (dev_priv->counter > 0x7FFFFFFFUL)
  1178. dev_priv->counter = 1;
  1179. if (master_priv->sarea_priv)
  1180. master_priv->sarea_priv->last_enqueue = dev_priv->counter;
  1181. if (BEGIN_LP_RING(4) == 0) {
  1182. OUT_RING(MI_STORE_DWORD_INDEX);
  1183. OUT_RING(I915_BREADCRUMB_INDEX << MI_STORE_DWORD_INDEX_SHIFT);
  1184. OUT_RING(dev_priv->counter);
  1185. OUT_RING(MI_USER_INTERRUPT);
  1186. ADVANCE_LP_RING();
  1187. }
  1188. return dev_priv->counter;
  1189. }
  1190. static int i915_wait_irq(struct drm_device * dev, int irq_nr)
  1191. {
  1192. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1193. struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
  1194. int ret = 0;
  1195. struct intel_ring_buffer *ring = LP_RING(dev_priv);
  1196. DRM_DEBUG_DRIVER("irq_nr=%d breadcrumb=%d\n", irq_nr,
  1197. READ_BREADCRUMB(dev_priv));
  1198. if (READ_BREADCRUMB(dev_priv) >= irq_nr) {
  1199. if (master_priv->sarea_priv)
  1200. master_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
  1201. return 0;
  1202. }
  1203. if (master_priv->sarea_priv)
  1204. master_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
  1205. if (ring->irq_get(ring)) {
  1206. DRM_WAIT_ON(ret, ring->irq_queue, 3 * DRM_HZ,
  1207. READ_BREADCRUMB(dev_priv) >= irq_nr);
  1208. ring->irq_put(ring);
  1209. } else if (wait_for(READ_BREADCRUMB(dev_priv) >= irq_nr, 3000))
  1210. ret = -EBUSY;
  1211. if (ret == -EBUSY) {
  1212. DRM_ERROR("EBUSY -- rec: %d emitted: %d\n",
  1213. READ_BREADCRUMB(dev_priv), (int)dev_priv->counter);
  1214. }
  1215. return ret;
  1216. }
  1217. /* Needs the lock as it touches the ring.
  1218. */
  1219. int i915_irq_emit(struct drm_device *dev, void *data,
  1220. struct drm_file *file_priv)
  1221. {
  1222. drm_i915_private_t *dev_priv = dev->dev_private;
  1223. drm_i915_irq_emit_t *emit = data;
  1224. int result;
  1225. if (!dev_priv || !LP_RING(dev_priv)->virtual_start) {
  1226. DRM_ERROR("called with no initialization\n");
  1227. return -EINVAL;
  1228. }
  1229. RING_LOCK_TEST_WITH_RETURN(dev, file_priv);
  1230. mutex_lock(&dev->struct_mutex);
  1231. result = i915_emit_irq(dev);
  1232. mutex_unlock(&dev->struct_mutex);
  1233. if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) {
  1234. DRM_ERROR("copy_to_user\n");
  1235. return -EFAULT;
  1236. }
  1237. return 0;
  1238. }
  1239. /* Doesn't need the hardware lock.
  1240. */
  1241. int i915_irq_wait(struct drm_device *dev, void *data,
  1242. struct drm_file *file_priv)
  1243. {
  1244. drm_i915_private_t *dev_priv = dev->dev_private;
  1245. drm_i915_irq_wait_t *irqwait = data;
  1246. if (!dev_priv) {
  1247. DRM_ERROR("called with no initialization\n");
  1248. return -EINVAL;
  1249. }
  1250. return i915_wait_irq(dev, irqwait->irq_seq);
  1251. }
  1252. /* Called from drm generic code, passed 'crtc' which
  1253. * we use as a pipe index
  1254. */
  1255. static int i915_enable_vblank(struct drm_device *dev, int pipe)
  1256. {
  1257. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1258. unsigned long irqflags;
  1259. if (!i915_pipe_enabled(dev, pipe))
  1260. return -EINVAL;
  1261. spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
  1262. if (INTEL_INFO(dev)->gen >= 4)
  1263. i915_enable_pipestat(dev_priv, pipe,
  1264. PIPE_START_VBLANK_INTERRUPT_ENABLE);
  1265. else
  1266. i915_enable_pipestat(dev_priv, pipe,
  1267. PIPE_VBLANK_INTERRUPT_ENABLE);
  1268. /* maintain vblank delivery even in deep C-states */
  1269. if (dev_priv->info->gen == 3)
  1270. I915_WRITE(INSTPM, INSTPM_AGPBUSY_DIS << 16);
  1271. spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
  1272. return 0;
  1273. }
  1274. static int ironlake_enable_vblank(struct drm_device *dev, int pipe)
  1275. {
  1276. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1277. unsigned long irqflags;
  1278. if (!i915_pipe_enabled(dev, pipe))
  1279. return -EINVAL;
  1280. spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
  1281. ironlake_enable_display_irq(dev_priv, (pipe == 0) ?
  1282. DE_PIPEA_VBLANK : DE_PIPEB_VBLANK);
  1283. spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
  1284. return 0;
  1285. }
  1286. static int ivybridge_enable_vblank(struct drm_device *dev, int pipe)
  1287. {
  1288. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1289. unsigned long irqflags;
  1290. if (!i915_pipe_enabled(dev, pipe))
  1291. return -EINVAL;
  1292. spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
  1293. ironlake_enable_display_irq(dev_priv, (pipe == 0) ?
  1294. DE_PIPEA_VBLANK_IVB : DE_PIPEB_VBLANK_IVB);
  1295. spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
  1296. return 0;
  1297. }
  1298. /* Called from drm generic code, passed 'crtc' which
  1299. * we use as a pipe index
  1300. */
  1301. static void i915_disable_vblank(struct drm_device *dev, int pipe)
  1302. {
  1303. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1304. unsigned long irqflags;
  1305. spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
  1306. if (dev_priv->info->gen == 3)
  1307. I915_WRITE(INSTPM,
  1308. INSTPM_AGPBUSY_DIS << 16 | INSTPM_AGPBUSY_DIS);
  1309. i915_disable_pipestat(dev_priv, pipe,
  1310. PIPE_VBLANK_INTERRUPT_ENABLE |
  1311. PIPE_START_VBLANK_INTERRUPT_ENABLE);
  1312. spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
  1313. }
  1314. static void ironlake_disable_vblank(struct drm_device *dev, int pipe)
  1315. {
  1316. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1317. unsigned long irqflags;
  1318. spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
  1319. ironlake_disable_display_irq(dev_priv, (pipe == 0) ?
  1320. DE_PIPEA_VBLANK : DE_PIPEB_VBLANK);
  1321. spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
  1322. }
  1323. static void ivybridge_disable_vblank(struct drm_device *dev, int pipe)
  1324. {
  1325. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1326. unsigned long irqflags;
  1327. spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
  1328. ironlake_disable_display_irq(dev_priv, (pipe == 0) ?
  1329. DE_PIPEA_VBLANK_IVB : DE_PIPEB_VBLANK_IVB);
  1330. spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
  1331. }
  1332. /* Set the vblank monitor pipe
  1333. */
  1334. int i915_vblank_pipe_set(struct drm_device *dev, void *data,
  1335. struct drm_file *file_priv)
  1336. {
  1337. drm_i915_private_t *dev_priv = dev->dev_private;
  1338. if (!dev_priv) {
  1339. DRM_ERROR("called with no initialization\n");
  1340. return -EINVAL;
  1341. }
  1342. return 0;
  1343. }
  1344. int i915_vblank_pipe_get(struct drm_device *dev, void *data,
  1345. struct drm_file *file_priv)
  1346. {
  1347. drm_i915_private_t *dev_priv = dev->dev_private;
  1348. drm_i915_vblank_pipe_t *pipe = data;
  1349. if (!dev_priv) {
  1350. DRM_ERROR("called with no initialization\n");
  1351. return -EINVAL;
  1352. }
  1353. pipe->pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B;
  1354. return 0;
  1355. }
  1356. /**
  1357. * Schedule buffer swap at given vertical blank.
  1358. */
  1359. int i915_vblank_swap(struct drm_device *dev, void *data,
  1360. struct drm_file *file_priv)
  1361. {
  1362. /* The delayed swap mechanism was fundamentally racy, and has been
  1363. * removed. The model was that the client requested a delayed flip/swap
  1364. * from the kernel, then waited for vblank before continuing to perform
  1365. * rendering. The problem was that the kernel might wake the client
  1366. * up before it dispatched the vblank swap (since the lock has to be
  1367. * held while touching the ringbuffer), in which case the client would
  1368. * clear and start the next frame before the swap occurred, and
  1369. * flicker would occur in addition to likely missing the vblank.
  1370. *
  1371. * In the absence of this ioctl, userland falls back to a correct path
  1372. * of waiting for a vblank, then dispatching the swap on its own.
  1373. * Context switching to userland and back is plenty fast enough for
  1374. * meeting the requirements of vblank swapping.
  1375. */
  1376. return -EINVAL;
  1377. }
  1378. static u32
  1379. ring_last_seqno(struct intel_ring_buffer *ring)
  1380. {
  1381. return list_entry(ring->request_list.prev,
  1382. struct drm_i915_gem_request, list)->seqno;
  1383. }
  1384. static bool i915_hangcheck_ring_idle(struct intel_ring_buffer *ring, bool *err)
  1385. {
  1386. if (list_empty(&ring->request_list) ||
  1387. i915_seqno_passed(ring->get_seqno(ring), ring_last_seqno(ring))) {
  1388. /* Issue a wake-up to catch stuck h/w. */
  1389. if (ring->waiting_seqno && waitqueue_active(&ring->irq_queue)) {
  1390. DRM_ERROR("Hangcheck timer elapsed... %s idle [waiting on %d, at %d], missed IRQ?\n",
  1391. ring->name,
  1392. ring->waiting_seqno,
  1393. ring->get_seqno(ring));
  1394. wake_up_all(&ring->irq_queue);
  1395. *err = true;
  1396. }
  1397. return true;
  1398. }
  1399. return false;
  1400. }
  1401. static bool kick_ring(struct intel_ring_buffer *ring)
  1402. {
  1403. struct drm_device *dev = ring->dev;
  1404. struct drm_i915_private *dev_priv = dev->dev_private;
  1405. u32 tmp = I915_READ_CTL(ring);
  1406. if (tmp & RING_WAIT) {
  1407. DRM_ERROR("Kicking stuck wait on %s\n",
  1408. ring->name);
  1409. I915_WRITE_CTL(ring, tmp);
  1410. return true;
  1411. }
  1412. return false;
  1413. }
  1414. /**
  1415. * This is called when the chip hasn't reported back with completed
  1416. * batchbuffers in a long time. The first time this is called we simply record
  1417. * ACTHD. If ACTHD hasn't changed by the time the hangcheck timer elapses
  1418. * again, we assume the chip is wedged and try to fix it.
  1419. */
  1420. void i915_hangcheck_elapsed(unsigned long data)
  1421. {
  1422. struct drm_device *dev = (struct drm_device *)data;
  1423. drm_i915_private_t *dev_priv = dev->dev_private;
  1424. uint32_t acthd, instdone, instdone1, acthd_bsd, acthd_blt;
  1425. bool err = false;
  1426. if (!i915_enable_hangcheck)
  1427. return;
  1428. /* If all work is done then ACTHD clearly hasn't advanced. */
  1429. if (i915_hangcheck_ring_idle(&dev_priv->ring[RCS], &err) &&
  1430. i915_hangcheck_ring_idle(&dev_priv->ring[VCS], &err) &&
  1431. i915_hangcheck_ring_idle(&dev_priv->ring[BCS], &err)) {
  1432. dev_priv->hangcheck_count = 0;
  1433. if (err)
  1434. goto repeat;
  1435. return;
  1436. }
  1437. if (INTEL_INFO(dev)->gen < 4) {
  1438. instdone = I915_READ(INSTDONE);
  1439. instdone1 = 0;
  1440. } else {
  1441. instdone = I915_READ(INSTDONE_I965);
  1442. instdone1 = I915_READ(INSTDONE1);
  1443. }
  1444. acthd = intel_ring_get_active_head(&dev_priv->ring[RCS]);
  1445. acthd_bsd = HAS_BSD(dev) ?
  1446. intel_ring_get_active_head(&dev_priv->ring[VCS]) : 0;
  1447. acthd_blt = HAS_BLT(dev) ?
  1448. intel_ring_get_active_head(&dev_priv->ring[BCS]) : 0;
  1449. if (dev_priv->last_acthd == acthd &&
  1450. dev_priv->last_acthd_bsd == acthd_bsd &&
  1451. dev_priv->last_acthd_blt == acthd_blt &&
  1452. dev_priv->last_instdone == instdone &&
  1453. dev_priv->last_instdone1 == instdone1) {
  1454. if (dev_priv->hangcheck_count++ > 1) {
  1455. DRM_ERROR("Hangcheck timer elapsed... GPU hung\n");
  1456. i915_handle_error(dev, true);
  1457. if (!IS_GEN2(dev)) {
  1458. /* Is the chip hanging on a WAIT_FOR_EVENT?
  1459. * If so we can simply poke the RB_WAIT bit
  1460. * and break the hang. This should work on
  1461. * all but the second generation chipsets.
  1462. */
  1463. if (kick_ring(&dev_priv->ring[RCS]))
  1464. goto repeat;
  1465. if (HAS_BSD(dev) &&
  1466. kick_ring(&dev_priv->ring[VCS]))
  1467. goto repeat;
  1468. if (HAS_BLT(dev) &&
  1469. kick_ring(&dev_priv->ring[BCS]))
  1470. goto repeat;
  1471. }
  1472. return;
  1473. }
  1474. } else {
  1475. dev_priv->hangcheck_count = 0;
  1476. dev_priv->last_acthd = acthd;
  1477. dev_priv->last_acthd_bsd = acthd_bsd;
  1478. dev_priv->last_acthd_blt = acthd_blt;
  1479. dev_priv->last_instdone = instdone;
  1480. dev_priv->last_instdone1 = instdone1;
  1481. }
  1482. repeat:
  1483. /* Reset timer case chip hangs without another request being added */
  1484. mod_timer(&dev_priv->hangcheck_timer,
  1485. jiffies + msecs_to_jiffies(DRM_I915_HANGCHECK_PERIOD));
  1486. }
  1487. /* drm_dma.h hooks
  1488. */
  1489. static void ironlake_irq_preinstall(struct drm_device *dev)
  1490. {
  1491. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1492. atomic_set(&dev_priv->irq_received, 0);
  1493. INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func);
  1494. INIT_WORK(&dev_priv->error_work, i915_error_work_func);
  1495. if (IS_GEN6(dev) || IS_IVYBRIDGE(dev))
  1496. INIT_WORK(&dev_priv->rps_work, gen6_pm_rps_work);
  1497. I915_WRITE(HWSTAM, 0xeffe);
  1498. /* XXX hotplug from PCH */
  1499. I915_WRITE(DEIMR, 0xffffffff);
  1500. I915_WRITE(DEIER, 0x0);
  1501. POSTING_READ(DEIER);
  1502. /* and GT */
  1503. I915_WRITE(GTIMR, 0xffffffff);
  1504. I915_WRITE(GTIER, 0x0);
  1505. POSTING_READ(GTIER);
  1506. /* south display irq */
  1507. I915_WRITE(SDEIMR, 0xffffffff);
  1508. I915_WRITE(SDEIER, 0x0);
  1509. POSTING_READ(SDEIER);
  1510. }
  1511. /*
  1512. * Enable digital hotplug on the PCH, and configure the DP short pulse
  1513. * duration to 2ms (which is the minimum in the Display Port spec)
  1514. *
  1515. * This register is the same on all known PCH chips.
  1516. */
  1517. static void ironlake_enable_pch_hotplug(struct drm_device *dev)
  1518. {
  1519. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1520. u32 hotplug;
  1521. hotplug = I915_READ(PCH_PORT_HOTPLUG);
  1522. hotplug &= ~(PORTD_PULSE_DURATION_MASK|PORTC_PULSE_DURATION_MASK|PORTB_PULSE_DURATION_MASK);
  1523. hotplug |= PORTD_HOTPLUG_ENABLE | PORTD_PULSE_DURATION_2ms;
  1524. hotplug |= PORTC_HOTPLUG_ENABLE | PORTC_PULSE_DURATION_2ms;
  1525. hotplug |= PORTB_HOTPLUG_ENABLE | PORTB_PULSE_DURATION_2ms;
  1526. I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
  1527. }
  1528. static int ironlake_irq_postinstall(struct drm_device *dev)
  1529. {
  1530. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1531. /* enable kind of interrupts always enabled */
  1532. u32 display_mask = DE_MASTER_IRQ_CONTROL | DE_GSE | DE_PCH_EVENT |
  1533. DE_PLANEA_FLIP_DONE | DE_PLANEB_FLIP_DONE;
  1534. u32 render_irqs;
  1535. u32 hotplug_mask;
  1536. DRM_INIT_WAITQUEUE(&dev_priv->ring[RCS].irq_queue);
  1537. if (HAS_BSD(dev))
  1538. DRM_INIT_WAITQUEUE(&dev_priv->ring[VCS].irq_queue);
  1539. if (HAS_BLT(dev))
  1540. DRM_INIT_WAITQUEUE(&dev_priv->ring[BCS].irq_queue);
  1541. dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B;
  1542. dev_priv->irq_mask = ~display_mask;
  1543. /* should always can generate irq */
  1544. I915_WRITE(DEIIR, I915_READ(DEIIR));
  1545. I915_WRITE(DEIMR, dev_priv->irq_mask);
  1546. I915_WRITE(DEIER, display_mask | DE_PIPEA_VBLANK | DE_PIPEB_VBLANK);
  1547. POSTING_READ(DEIER);
  1548. dev_priv->gt_irq_mask = ~0;
  1549. I915_WRITE(GTIIR, I915_READ(GTIIR));
  1550. I915_WRITE(GTIMR, dev_priv->gt_irq_mask);
  1551. if (IS_GEN6(dev))
  1552. render_irqs =
  1553. GT_USER_INTERRUPT |
  1554. GT_GEN6_BSD_USER_INTERRUPT |
  1555. GT_BLT_USER_INTERRUPT;
  1556. else
  1557. render_irqs =
  1558. GT_USER_INTERRUPT |
  1559. GT_PIPE_NOTIFY |
  1560. GT_BSD_USER_INTERRUPT;
  1561. I915_WRITE(GTIER, render_irqs);
  1562. POSTING_READ(GTIER);
  1563. if (HAS_PCH_CPT(dev)) {
  1564. hotplug_mask = (SDE_CRT_HOTPLUG_CPT |
  1565. SDE_PORTB_HOTPLUG_CPT |
  1566. SDE_PORTC_HOTPLUG_CPT |
  1567. SDE_PORTD_HOTPLUG_CPT);
  1568. } else {
  1569. hotplug_mask = (SDE_CRT_HOTPLUG |
  1570. SDE_PORTB_HOTPLUG |
  1571. SDE_PORTC_HOTPLUG |
  1572. SDE_PORTD_HOTPLUG |
  1573. SDE_AUX_MASK);
  1574. }
  1575. dev_priv->pch_irq_mask = ~hotplug_mask;
  1576. I915_WRITE(SDEIIR, I915_READ(SDEIIR));
  1577. I915_WRITE(SDEIMR, dev_priv->pch_irq_mask);
  1578. I915_WRITE(SDEIER, hotplug_mask);
  1579. POSTING_READ(SDEIER);
  1580. ironlake_enable_pch_hotplug(dev);
  1581. if (IS_IRONLAKE_M(dev)) {
  1582. /* Clear & enable PCU event interrupts */
  1583. I915_WRITE(DEIIR, DE_PCU_EVENT);
  1584. I915_WRITE(DEIER, I915_READ(DEIER) | DE_PCU_EVENT);
  1585. ironlake_enable_display_irq(dev_priv, DE_PCU_EVENT);
  1586. }
  1587. return 0;
  1588. }
  1589. static int ivybridge_irq_postinstall(struct drm_device *dev)
  1590. {
  1591. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1592. /* enable kind of interrupts always enabled */
  1593. u32 display_mask = DE_MASTER_IRQ_CONTROL | DE_GSE_IVB |
  1594. DE_PCH_EVENT_IVB | DE_PLANEA_FLIP_DONE_IVB |
  1595. DE_PLANEB_FLIP_DONE_IVB;
  1596. u32 render_irqs;
  1597. u32 hotplug_mask;
  1598. DRM_INIT_WAITQUEUE(&dev_priv->ring[RCS].irq_queue);
  1599. if (HAS_BSD(dev))
  1600. DRM_INIT_WAITQUEUE(&dev_priv->ring[VCS].irq_queue);
  1601. if (HAS_BLT(dev))
  1602. DRM_INIT_WAITQUEUE(&dev_priv->ring[BCS].irq_queue);
  1603. dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B;
  1604. dev_priv->irq_mask = ~display_mask;
  1605. /* should always can generate irq */
  1606. I915_WRITE(DEIIR, I915_READ(DEIIR));
  1607. I915_WRITE(DEIMR, dev_priv->irq_mask);
  1608. I915_WRITE(DEIER, display_mask | DE_PIPEA_VBLANK_IVB |
  1609. DE_PIPEB_VBLANK_IVB);
  1610. POSTING_READ(DEIER);
  1611. dev_priv->gt_irq_mask = ~0;
  1612. I915_WRITE(GTIIR, I915_READ(GTIIR));
  1613. I915_WRITE(GTIMR, dev_priv->gt_irq_mask);
  1614. render_irqs = GT_USER_INTERRUPT | GT_GEN6_BSD_USER_INTERRUPT |
  1615. GT_BLT_USER_INTERRUPT;
  1616. I915_WRITE(GTIER, render_irqs);
  1617. POSTING_READ(GTIER);
  1618. hotplug_mask = (SDE_CRT_HOTPLUG_CPT |
  1619. SDE_PORTB_HOTPLUG_CPT |
  1620. SDE_PORTC_HOTPLUG_CPT |
  1621. SDE_PORTD_HOTPLUG_CPT);
  1622. dev_priv->pch_irq_mask = ~hotplug_mask;
  1623. I915_WRITE(SDEIIR, I915_READ(SDEIIR));
  1624. I915_WRITE(SDEIMR, dev_priv->pch_irq_mask);
  1625. I915_WRITE(SDEIER, hotplug_mask);
  1626. POSTING_READ(SDEIER);
  1627. ironlake_enable_pch_hotplug(dev);
  1628. return 0;
  1629. }
  1630. static void i915_driver_irq_preinstall(struct drm_device * dev)
  1631. {
  1632. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1633. int pipe;
  1634. atomic_set(&dev_priv->irq_received, 0);
  1635. INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func);
  1636. INIT_WORK(&dev_priv->error_work, i915_error_work_func);
  1637. if (I915_HAS_HOTPLUG(dev)) {
  1638. I915_WRITE(PORT_HOTPLUG_EN, 0);
  1639. I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
  1640. }
  1641. I915_WRITE(HWSTAM, 0xeffe);
  1642. for_each_pipe(pipe)
  1643. I915_WRITE(PIPESTAT(pipe), 0);
  1644. I915_WRITE(IMR, 0xffffffff);
  1645. I915_WRITE(IER, 0x0);
  1646. POSTING_READ(IER);
  1647. }
  1648. /*
  1649. * Must be called after intel_modeset_init or hotplug interrupts won't be
  1650. * enabled correctly.
  1651. */
  1652. static int i915_driver_irq_postinstall(struct drm_device *dev)
  1653. {
  1654. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1655. u32 enable_mask = I915_INTERRUPT_ENABLE_FIX | I915_INTERRUPT_ENABLE_VAR;
  1656. u32 error_mask;
  1657. dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B;
  1658. /* Unmask the interrupts that we always want on. */
  1659. dev_priv->irq_mask = ~I915_INTERRUPT_ENABLE_FIX;
  1660. dev_priv->pipestat[0] = 0;
  1661. dev_priv->pipestat[1] = 0;
  1662. if (I915_HAS_HOTPLUG(dev)) {
  1663. /* Enable in IER... */
  1664. enable_mask |= I915_DISPLAY_PORT_INTERRUPT;
  1665. /* and unmask in IMR */
  1666. dev_priv->irq_mask &= ~I915_DISPLAY_PORT_INTERRUPT;
  1667. }
  1668. /*
  1669. * Enable some error detection, note the instruction error mask
  1670. * bit is reserved, so we leave it masked.
  1671. */
  1672. if (IS_G4X(dev)) {
  1673. error_mask = ~(GM45_ERROR_PAGE_TABLE |
  1674. GM45_ERROR_MEM_PRIV |
  1675. GM45_ERROR_CP_PRIV |
  1676. I915_ERROR_MEMORY_REFRESH);
  1677. } else {
  1678. error_mask = ~(I915_ERROR_PAGE_TABLE |
  1679. I915_ERROR_MEMORY_REFRESH);
  1680. }
  1681. I915_WRITE(EMR, error_mask);
  1682. I915_WRITE(IMR, dev_priv->irq_mask);
  1683. I915_WRITE(IER, enable_mask);
  1684. POSTING_READ(IER);
  1685. if (I915_HAS_HOTPLUG(dev)) {
  1686. u32 hotplug_en = I915_READ(PORT_HOTPLUG_EN);
  1687. /* Note HDMI and DP share bits */
  1688. if (dev_priv->hotplug_supported_mask & HDMIB_HOTPLUG_INT_STATUS)
  1689. hotplug_en |= HDMIB_HOTPLUG_INT_EN;
  1690. if (dev_priv->hotplug_supported_mask & HDMIC_HOTPLUG_INT_STATUS)
  1691. hotplug_en |= HDMIC_HOTPLUG_INT_EN;
  1692. if (dev_priv->hotplug_supported_mask & HDMID_HOTPLUG_INT_STATUS)
  1693. hotplug_en |= HDMID_HOTPLUG_INT_EN;
  1694. if (dev_priv->hotplug_supported_mask & SDVOC_HOTPLUG_INT_STATUS)
  1695. hotplug_en |= SDVOC_HOTPLUG_INT_EN;
  1696. if (dev_priv->hotplug_supported_mask & SDVOB_HOTPLUG_INT_STATUS)
  1697. hotplug_en |= SDVOB_HOTPLUG_INT_EN;
  1698. if (dev_priv->hotplug_supported_mask & CRT_HOTPLUG_INT_STATUS) {
  1699. hotplug_en |= CRT_HOTPLUG_INT_EN;
  1700. /* Programming the CRT detection parameters tends
  1701. to generate a spurious hotplug event about three
  1702. seconds later. So just do it once.
  1703. */
  1704. if (IS_G4X(dev))
  1705. hotplug_en |= CRT_HOTPLUG_ACTIVATION_PERIOD_64;
  1706. hotplug_en |= CRT_HOTPLUG_VOLTAGE_COMPARE_50;
  1707. }
  1708. /* Ignore TV since it's buggy */
  1709. I915_WRITE(PORT_HOTPLUG_EN, hotplug_en);
  1710. }
  1711. intel_opregion_enable_asle(dev);
  1712. return 0;
  1713. }
  1714. static void ironlake_irq_uninstall(struct drm_device *dev)
  1715. {
  1716. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1717. if (!dev_priv)
  1718. return;
  1719. dev_priv->vblank_pipe = 0;
  1720. I915_WRITE(HWSTAM, 0xffffffff);
  1721. I915_WRITE(DEIMR, 0xffffffff);
  1722. I915_WRITE(DEIER, 0x0);
  1723. I915_WRITE(DEIIR, I915_READ(DEIIR));
  1724. I915_WRITE(GTIMR, 0xffffffff);
  1725. I915_WRITE(GTIER, 0x0);
  1726. I915_WRITE(GTIIR, I915_READ(GTIIR));
  1727. I915_WRITE(SDEIMR, 0xffffffff);
  1728. I915_WRITE(SDEIER, 0x0);
  1729. I915_WRITE(SDEIIR, I915_READ(SDEIIR));
  1730. }
  1731. static void i915_driver_irq_uninstall(struct drm_device * dev)
  1732. {
  1733. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  1734. int pipe;
  1735. if (!dev_priv)
  1736. return;
  1737. dev_priv->vblank_pipe = 0;
  1738. if (I915_HAS_HOTPLUG(dev)) {
  1739. I915_WRITE(PORT_HOTPLUG_EN, 0);
  1740. I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
  1741. }
  1742. I915_WRITE(HWSTAM, 0xffffffff);
  1743. for_each_pipe(pipe)
  1744. I915_WRITE(PIPESTAT(pipe), 0);
  1745. I915_WRITE(IMR, 0xffffffff);
  1746. I915_WRITE(IER, 0x0);
  1747. for_each_pipe(pipe)
  1748. I915_WRITE(PIPESTAT(pipe),
  1749. I915_READ(PIPESTAT(pipe)) & 0x8000ffff);
  1750. I915_WRITE(IIR, I915_READ(IIR));
  1751. }
  1752. void intel_irq_init(struct drm_device *dev)
  1753. {
  1754. dev->driver->get_vblank_counter = i915_get_vblank_counter;
  1755. dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */
  1756. if (IS_G4X(dev) || IS_GEN5(dev) || IS_GEN6(dev) || IS_IVYBRIDGE(dev)) {
  1757. dev->max_vblank_count = 0xffffffff; /* full 32 bit counter */
  1758. dev->driver->get_vblank_counter = gm45_get_vblank_counter;
  1759. }
  1760. if (drm_core_check_feature(dev, DRIVER_MODESET))
  1761. dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp;
  1762. else
  1763. dev->driver->get_vblank_timestamp = NULL;
  1764. dev->driver->get_scanout_position = i915_get_crtc_scanoutpos;
  1765. if (IS_IVYBRIDGE(dev)) {
  1766. /* Share pre & uninstall handlers with ILK/SNB */
  1767. dev->driver->irq_handler = ivybridge_irq_handler;
  1768. dev->driver->irq_preinstall = ironlake_irq_preinstall;
  1769. dev->driver->irq_postinstall = ivybridge_irq_postinstall;
  1770. dev->driver->irq_uninstall = ironlake_irq_uninstall;
  1771. dev->driver->enable_vblank = ivybridge_enable_vblank;
  1772. dev->driver->disable_vblank = ivybridge_disable_vblank;
  1773. } else if (HAS_PCH_SPLIT(dev)) {
  1774. dev->driver->irq_handler = ironlake_irq_handler;
  1775. dev->driver->irq_preinstall = ironlake_irq_preinstall;
  1776. dev->driver->irq_postinstall = ironlake_irq_postinstall;
  1777. dev->driver->irq_uninstall = ironlake_irq_uninstall;
  1778. dev->driver->enable_vblank = ironlake_enable_vblank;
  1779. dev->driver->disable_vblank = ironlake_disable_vblank;
  1780. } else {
  1781. dev->driver->irq_preinstall = i915_driver_irq_preinstall;
  1782. dev->driver->irq_postinstall = i915_driver_irq_postinstall;
  1783. dev->driver->irq_uninstall = i915_driver_irq_uninstall;
  1784. dev->driver->irq_handler = i915_driver_irq_handler;
  1785. dev->driver->enable_vblank = i915_enable_vblank;
  1786. dev->driver->disable_vblank = i915_disable_vblank;
  1787. }
  1788. }