i915_irq.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157
  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. #include <linux/sysrq.h>
  29. #include "drmP.h"
  30. #include "drm.h"
  31. #include "i915_drm.h"
  32. #include "i915_drv.h"
  33. #include "i915_trace.h"
  34. #include "intel_drv.h"
  35. #define MAX_NOPID ((u32)~0)
  36. /**
  37. * Interrupts that are always left unmasked.
  38. *
  39. * Since pipe events are edge-triggered from the PIPESTAT register to IIR,
  40. * we leave them always unmasked in IMR and then control enabling them through
  41. * PIPESTAT alone.
  42. */
  43. #define I915_INTERRUPT_ENABLE_FIX (I915_ASLE_INTERRUPT | \
  44. I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | \
  45. I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | \
  46. I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT)
  47. /** Interrupts that we mask and unmask at runtime. */
  48. #define I915_INTERRUPT_ENABLE_VAR (I915_USER_INTERRUPT)
  49. #define I915_PIPE_VBLANK_STATUS (PIPE_START_VBLANK_INTERRUPT_STATUS |\
  50. PIPE_VBLANK_INTERRUPT_STATUS)
  51. #define I915_PIPE_VBLANK_ENABLE (PIPE_START_VBLANK_INTERRUPT_ENABLE |\
  52. PIPE_VBLANK_INTERRUPT_ENABLE)
  53. #define DRM_I915_VBLANK_PIPE_ALL (DRM_I915_VBLANK_PIPE_A | \
  54. DRM_I915_VBLANK_PIPE_B)
  55. void
  56. igdng_enable_graphics_irq(drm_i915_private_t *dev_priv, u32 mask)
  57. {
  58. if ((dev_priv->gt_irq_mask_reg & mask) != 0) {
  59. dev_priv->gt_irq_mask_reg &= ~mask;
  60. I915_WRITE(GTIMR, dev_priv->gt_irq_mask_reg);
  61. (void) I915_READ(GTIMR);
  62. }
  63. }
  64. static inline void
  65. igdng_disable_graphics_irq(drm_i915_private_t *dev_priv, u32 mask)
  66. {
  67. if ((dev_priv->gt_irq_mask_reg & mask) != mask) {
  68. dev_priv->gt_irq_mask_reg |= mask;
  69. I915_WRITE(GTIMR, dev_priv->gt_irq_mask_reg);
  70. (void) I915_READ(GTIMR);
  71. }
  72. }
  73. /* For display hotplug interrupt */
  74. void
  75. igdng_enable_display_irq(drm_i915_private_t *dev_priv, u32 mask)
  76. {
  77. if ((dev_priv->irq_mask_reg & mask) != 0) {
  78. dev_priv->irq_mask_reg &= ~mask;
  79. I915_WRITE(DEIMR, dev_priv->irq_mask_reg);
  80. (void) I915_READ(DEIMR);
  81. }
  82. }
  83. static inline void
  84. igdng_disable_display_irq(drm_i915_private_t *dev_priv, u32 mask)
  85. {
  86. if ((dev_priv->irq_mask_reg & mask) != mask) {
  87. dev_priv->irq_mask_reg |= mask;
  88. I915_WRITE(DEIMR, dev_priv->irq_mask_reg);
  89. (void) I915_READ(DEIMR);
  90. }
  91. }
  92. void
  93. i915_enable_irq(drm_i915_private_t *dev_priv, u32 mask)
  94. {
  95. if ((dev_priv->irq_mask_reg & mask) != 0) {
  96. dev_priv->irq_mask_reg &= ~mask;
  97. I915_WRITE(IMR, dev_priv->irq_mask_reg);
  98. (void) I915_READ(IMR);
  99. }
  100. }
  101. static inline void
  102. i915_disable_irq(drm_i915_private_t *dev_priv, u32 mask)
  103. {
  104. if ((dev_priv->irq_mask_reg & mask) != mask) {
  105. dev_priv->irq_mask_reg |= mask;
  106. I915_WRITE(IMR, dev_priv->irq_mask_reg);
  107. (void) I915_READ(IMR);
  108. }
  109. }
  110. static inline u32
  111. i915_pipestat(int pipe)
  112. {
  113. if (pipe == 0)
  114. return PIPEASTAT;
  115. if (pipe == 1)
  116. return PIPEBSTAT;
  117. BUG();
  118. }
  119. void
  120. i915_enable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask)
  121. {
  122. if ((dev_priv->pipestat[pipe] & mask) != mask) {
  123. u32 reg = i915_pipestat(pipe);
  124. dev_priv->pipestat[pipe] |= mask;
  125. /* Enable the interrupt, clear any pending status */
  126. I915_WRITE(reg, dev_priv->pipestat[pipe] | (mask >> 16));
  127. (void) I915_READ(reg);
  128. }
  129. }
  130. void
  131. i915_disable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask)
  132. {
  133. if ((dev_priv->pipestat[pipe] & mask) != 0) {
  134. u32 reg = i915_pipestat(pipe);
  135. dev_priv->pipestat[pipe] &= ~mask;
  136. I915_WRITE(reg, dev_priv->pipestat[pipe]);
  137. (void) I915_READ(reg);
  138. }
  139. }
  140. /**
  141. * i915_pipe_enabled - check if a pipe is enabled
  142. * @dev: DRM device
  143. * @pipe: pipe to check
  144. *
  145. * Reading certain registers when the pipe is disabled can hang the chip.
  146. * Use this routine to make sure the PLL is running and the pipe is active
  147. * before reading such registers if unsure.
  148. */
  149. static int
  150. i915_pipe_enabled(struct drm_device *dev, int pipe)
  151. {
  152. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  153. unsigned long pipeconf = pipe ? PIPEBCONF : PIPEACONF;
  154. if (I915_READ(pipeconf) & PIPEACONF_ENABLE)
  155. return 1;
  156. return 0;
  157. }
  158. /* Called from drm generic code, passed a 'crtc', which
  159. * we use as a pipe index
  160. */
  161. u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
  162. {
  163. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  164. unsigned long high_frame;
  165. unsigned long low_frame;
  166. u32 high1, high2, low, count;
  167. high_frame = pipe ? PIPEBFRAMEHIGH : PIPEAFRAMEHIGH;
  168. low_frame = pipe ? PIPEBFRAMEPIXEL : PIPEAFRAMEPIXEL;
  169. if (!i915_pipe_enabled(dev, pipe)) {
  170. DRM_DEBUG("trying to get vblank count for disabled pipe %d\n", pipe);
  171. return 0;
  172. }
  173. /*
  174. * High & low register fields aren't synchronized, so make sure
  175. * we get a low value that's stable across two reads of the high
  176. * register.
  177. */
  178. do {
  179. high1 = ((I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK) >>
  180. PIPE_FRAME_HIGH_SHIFT);
  181. low = ((I915_READ(low_frame) & PIPE_FRAME_LOW_MASK) >>
  182. PIPE_FRAME_LOW_SHIFT);
  183. high2 = ((I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK) >>
  184. PIPE_FRAME_HIGH_SHIFT);
  185. } while (high1 != high2);
  186. count = (high1 << 8) | low;
  187. return count;
  188. }
  189. u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe)
  190. {
  191. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  192. int reg = pipe ? PIPEB_FRMCOUNT_GM45 : PIPEA_FRMCOUNT_GM45;
  193. if (!i915_pipe_enabled(dev, pipe)) {
  194. DRM_DEBUG("trying to get vblank count for disabled pipe %d\n", pipe);
  195. return 0;
  196. }
  197. return I915_READ(reg);
  198. }
  199. /*
  200. * Handle hotplug events outside the interrupt handler proper.
  201. */
  202. static void i915_hotplug_work_func(struct work_struct *work)
  203. {
  204. drm_i915_private_t *dev_priv = container_of(work, drm_i915_private_t,
  205. hotplug_work);
  206. struct drm_device *dev = dev_priv->dev;
  207. struct drm_mode_config *mode_config = &dev->mode_config;
  208. struct drm_connector *connector;
  209. if (mode_config->num_connector) {
  210. list_for_each_entry(connector, &mode_config->connector_list, head) {
  211. struct intel_output *intel_output = to_intel_output(connector);
  212. if (intel_output->hot_plug)
  213. (*intel_output->hot_plug) (intel_output);
  214. }
  215. }
  216. /* Just fire off a uevent and let userspace tell us what to do */
  217. drm_sysfs_hotplug_event(dev);
  218. }
  219. irqreturn_t igdng_irq_handler(struct drm_device *dev)
  220. {
  221. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  222. int ret = IRQ_NONE;
  223. u32 de_iir, gt_iir;
  224. u32 new_de_iir, new_gt_iir;
  225. struct drm_i915_master_private *master_priv;
  226. de_iir = I915_READ(DEIIR);
  227. gt_iir = I915_READ(GTIIR);
  228. for (;;) {
  229. if (de_iir == 0 && gt_iir == 0)
  230. break;
  231. ret = IRQ_HANDLED;
  232. I915_WRITE(DEIIR, de_iir);
  233. new_de_iir = I915_READ(DEIIR);
  234. I915_WRITE(GTIIR, gt_iir);
  235. new_gt_iir = I915_READ(GTIIR);
  236. if (dev->primary->master) {
  237. master_priv = dev->primary->master->driver_priv;
  238. if (master_priv->sarea_priv)
  239. master_priv->sarea_priv->last_dispatch =
  240. READ_BREADCRUMB(dev_priv);
  241. }
  242. if (gt_iir & GT_USER_INTERRUPT) {
  243. u32 seqno = i915_get_gem_seqno(dev);
  244. dev_priv->mm.irq_gem_seqno = seqno;
  245. trace_i915_gem_request_complete(dev, seqno);
  246. DRM_WAKEUP(&dev_priv->irq_queue);
  247. }
  248. de_iir = new_de_iir;
  249. gt_iir = new_gt_iir;
  250. }
  251. return ret;
  252. }
  253. /**
  254. * i915_error_work_func - do process context error handling work
  255. * @work: work struct
  256. *
  257. * Fire an error uevent so userspace can see that a hang or error
  258. * was detected.
  259. */
  260. static void i915_error_work_func(struct work_struct *work)
  261. {
  262. drm_i915_private_t *dev_priv = container_of(work, drm_i915_private_t,
  263. error_work);
  264. struct drm_device *dev = dev_priv->dev;
  265. char *error_event[] = { "ERROR=1", NULL };
  266. char *reset_event[] = { "RESET=1", NULL };
  267. char *reset_done_event[] = { "ERROR=0", NULL };
  268. DRM_DEBUG("generating error event\n");
  269. kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, error_event);
  270. if (atomic_read(&dev_priv->mm.wedged)) {
  271. if (IS_I965G(dev)) {
  272. DRM_DEBUG("resetting chip\n");
  273. kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, reset_event);
  274. if (!i965_reset(dev, GDRST_RENDER)) {
  275. atomic_set(&dev_priv->mm.wedged, 0);
  276. kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, reset_done_event);
  277. }
  278. } else {
  279. printk("reboot required\n");
  280. }
  281. }
  282. }
  283. /**
  284. * i915_capture_error_state - capture an error record for later analysis
  285. * @dev: drm device
  286. *
  287. * Should be called when an error is detected (either a hang or an error
  288. * interrupt) to capture error state from the time of the error. Fills
  289. * out a structure which becomes available in debugfs for user level tools
  290. * to pick up.
  291. */
  292. static void i915_capture_error_state(struct drm_device *dev)
  293. {
  294. struct drm_i915_private *dev_priv = dev->dev_private;
  295. struct drm_i915_error_state *error;
  296. unsigned long flags;
  297. spin_lock_irqsave(&dev_priv->error_lock, flags);
  298. if (dev_priv->first_error)
  299. goto out;
  300. error = kmalloc(sizeof(*error), GFP_ATOMIC);
  301. if (!error) {
  302. DRM_DEBUG("out ot memory, not capturing error state\n");
  303. goto out;
  304. }
  305. error->eir = I915_READ(EIR);
  306. error->pgtbl_er = I915_READ(PGTBL_ER);
  307. error->pipeastat = I915_READ(PIPEASTAT);
  308. error->pipebstat = I915_READ(PIPEBSTAT);
  309. error->instpm = I915_READ(INSTPM);
  310. if (!IS_I965G(dev)) {
  311. error->ipeir = I915_READ(IPEIR);
  312. error->ipehr = I915_READ(IPEHR);
  313. error->instdone = I915_READ(INSTDONE);
  314. error->acthd = I915_READ(ACTHD);
  315. } else {
  316. error->ipeir = I915_READ(IPEIR_I965);
  317. error->ipehr = I915_READ(IPEHR_I965);
  318. error->instdone = I915_READ(INSTDONE_I965);
  319. error->instps = I915_READ(INSTPS);
  320. error->instdone1 = I915_READ(INSTDONE1);
  321. error->acthd = I915_READ(ACTHD_I965);
  322. }
  323. do_gettimeofday(&error->time);
  324. dev_priv->first_error = error;
  325. out:
  326. spin_unlock_irqrestore(&dev_priv->error_lock, flags);
  327. }
  328. /**
  329. * i915_handle_error - handle an error interrupt
  330. * @dev: drm device
  331. *
  332. * Do some basic checking of regsiter state at error interrupt time and
  333. * dump it to the syslog. Also call i915_capture_error_state() to make
  334. * sure we get a record and make it available in debugfs. Fire a uevent
  335. * so userspace knows something bad happened (should trigger collection
  336. * of a ring dump etc.).
  337. */
  338. static void i915_handle_error(struct drm_device *dev, bool wedged)
  339. {
  340. struct drm_i915_private *dev_priv = dev->dev_private;
  341. u32 eir = I915_READ(EIR);
  342. u32 pipea_stats = I915_READ(PIPEASTAT);
  343. u32 pipeb_stats = I915_READ(PIPEBSTAT);
  344. i915_capture_error_state(dev);
  345. printk(KERN_ERR "render error detected, EIR: 0x%08x\n",
  346. eir);
  347. if (IS_G4X(dev)) {
  348. if (eir & (GM45_ERROR_MEM_PRIV | GM45_ERROR_CP_PRIV)) {
  349. u32 ipeir = I915_READ(IPEIR_I965);
  350. printk(KERN_ERR " IPEIR: 0x%08x\n",
  351. I915_READ(IPEIR_I965));
  352. printk(KERN_ERR " IPEHR: 0x%08x\n",
  353. I915_READ(IPEHR_I965));
  354. printk(KERN_ERR " INSTDONE: 0x%08x\n",
  355. I915_READ(INSTDONE_I965));
  356. printk(KERN_ERR " INSTPS: 0x%08x\n",
  357. I915_READ(INSTPS));
  358. printk(KERN_ERR " INSTDONE1: 0x%08x\n",
  359. I915_READ(INSTDONE1));
  360. printk(KERN_ERR " ACTHD: 0x%08x\n",
  361. I915_READ(ACTHD_I965));
  362. I915_WRITE(IPEIR_I965, ipeir);
  363. (void)I915_READ(IPEIR_I965);
  364. }
  365. if (eir & GM45_ERROR_PAGE_TABLE) {
  366. u32 pgtbl_err = I915_READ(PGTBL_ER);
  367. printk(KERN_ERR "page table error\n");
  368. printk(KERN_ERR " PGTBL_ER: 0x%08x\n",
  369. pgtbl_err);
  370. I915_WRITE(PGTBL_ER, pgtbl_err);
  371. (void)I915_READ(PGTBL_ER);
  372. }
  373. }
  374. if (IS_I9XX(dev)) {
  375. if (eir & I915_ERROR_PAGE_TABLE) {
  376. u32 pgtbl_err = I915_READ(PGTBL_ER);
  377. printk(KERN_ERR "page table error\n");
  378. printk(KERN_ERR " PGTBL_ER: 0x%08x\n",
  379. pgtbl_err);
  380. I915_WRITE(PGTBL_ER, pgtbl_err);
  381. (void)I915_READ(PGTBL_ER);
  382. }
  383. }
  384. if (eir & I915_ERROR_MEMORY_REFRESH) {
  385. printk(KERN_ERR "memory refresh error\n");
  386. printk(KERN_ERR "PIPEASTAT: 0x%08x\n",
  387. pipea_stats);
  388. printk(KERN_ERR "PIPEBSTAT: 0x%08x\n",
  389. pipeb_stats);
  390. /* pipestat has already been acked */
  391. }
  392. if (eir & I915_ERROR_INSTRUCTION) {
  393. printk(KERN_ERR "instruction error\n");
  394. printk(KERN_ERR " INSTPM: 0x%08x\n",
  395. I915_READ(INSTPM));
  396. if (!IS_I965G(dev)) {
  397. u32 ipeir = I915_READ(IPEIR);
  398. printk(KERN_ERR " IPEIR: 0x%08x\n",
  399. I915_READ(IPEIR));
  400. printk(KERN_ERR " IPEHR: 0x%08x\n",
  401. I915_READ(IPEHR));
  402. printk(KERN_ERR " INSTDONE: 0x%08x\n",
  403. I915_READ(INSTDONE));
  404. printk(KERN_ERR " ACTHD: 0x%08x\n",
  405. I915_READ(ACTHD));
  406. I915_WRITE(IPEIR, ipeir);
  407. (void)I915_READ(IPEIR);
  408. } else {
  409. u32 ipeir = I915_READ(IPEIR_I965);
  410. printk(KERN_ERR " IPEIR: 0x%08x\n",
  411. I915_READ(IPEIR_I965));
  412. printk(KERN_ERR " IPEHR: 0x%08x\n",
  413. I915_READ(IPEHR_I965));
  414. printk(KERN_ERR " INSTDONE: 0x%08x\n",
  415. I915_READ(INSTDONE_I965));
  416. printk(KERN_ERR " INSTPS: 0x%08x\n",
  417. I915_READ(INSTPS));
  418. printk(KERN_ERR " INSTDONE1: 0x%08x\n",
  419. I915_READ(INSTDONE1));
  420. printk(KERN_ERR " ACTHD: 0x%08x\n",
  421. I915_READ(ACTHD_I965));
  422. I915_WRITE(IPEIR_I965, ipeir);
  423. (void)I915_READ(IPEIR_I965);
  424. }
  425. }
  426. I915_WRITE(EIR, eir);
  427. (void)I915_READ(EIR);
  428. eir = I915_READ(EIR);
  429. if (eir) {
  430. /*
  431. * some errors might have become stuck,
  432. * mask them.
  433. */
  434. DRM_ERROR("EIR stuck: 0x%08x, masking\n", eir);
  435. I915_WRITE(EMR, I915_READ(EMR) | eir);
  436. I915_WRITE(IIR, I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT);
  437. }
  438. if (wedged) {
  439. atomic_set(&dev_priv->mm.wedged, 1);
  440. /*
  441. * Wakeup waiting processes so they don't hang
  442. */
  443. printk("i915: Waking up sleeping processes\n");
  444. DRM_WAKEUP(&dev_priv->irq_queue);
  445. }
  446. queue_work(dev_priv->wq, &dev_priv->error_work);
  447. }
  448. irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
  449. {
  450. struct drm_device *dev = (struct drm_device *) arg;
  451. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  452. struct drm_i915_master_private *master_priv;
  453. u32 iir, new_iir;
  454. u32 pipea_stats, pipeb_stats;
  455. u32 vblank_status;
  456. u32 vblank_enable;
  457. int vblank = 0;
  458. unsigned long irqflags;
  459. int irq_received;
  460. int ret = IRQ_NONE;
  461. atomic_inc(&dev_priv->irq_received);
  462. if (IS_IGDNG(dev))
  463. return igdng_irq_handler(dev);
  464. iir = I915_READ(IIR);
  465. if (IS_I965G(dev)) {
  466. vblank_status = I915_START_VBLANK_INTERRUPT_STATUS;
  467. vblank_enable = PIPE_START_VBLANK_INTERRUPT_ENABLE;
  468. } else {
  469. vblank_status = I915_VBLANK_INTERRUPT_STATUS;
  470. vblank_enable = I915_VBLANK_INTERRUPT_ENABLE;
  471. }
  472. for (;;) {
  473. irq_received = iir != 0;
  474. /* Can't rely on pipestat interrupt bit in iir as it might
  475. * have been cleared after the pipestat interrupt was received.
  476. * It doesn't set the bit in iir again, but it still produces
  477. * interrupts (for non-MSI).
  478. */
  479. spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
  480. pipea_stats = I915_READ(PIPEASTAT);
  481. pipeb_stats = I915_READ(PIPEBSTAT);
  482. if (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT)
  483. i915_handle_error(dev, false);
  484. /*
  485. * Clear the PIPE(A|B)STAT regs before the IIR
  486. */
  487. if (pipea_stats & 0x8000ffff) {
  488. if (pipea_stats & PIPE_FIFO_UNDERRUN_STATUS)
  489. DRM_DEBUG("pipe a underrun\n");
  490. I915_WRITE(PIPEASTAT, pipea_stats);
  491. irq_received = 1;
  492. }
  493. if (pipeb_stats & 0x8000ffff) {
  494. if (pipeb_stats & PIPE_FIFO_UNDERRUN_STATUS)
  495. DRM_DEBUG("pipe b underrun\n");
  496. I915_WRITE(PIPEBSTAT, pipeb_stats);
  497. irq_received = 1;
  498. }
  499. spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags);
  500. if (!irq_received)
  501. break;
  502. ret = IRQ_HANDLED;
  503. /* Consume port. Then clear IIR or we'll miss events */
  504. if ((I915_HAS_HOTPLUG(dev)) &&
  505. (iir & I915_DISPLAY_PORT_INTERRUPT)) {
  506. u32 hotplug_status = I915_READ(PORT_HOTPLUG_STAT);
  507. DRM_DEBUG("hotplug event received, stat 0x%08x\n",
  508. hotplug_status);
  509. if (hotplug_status & dev_priv->hotplug_supported_mask)
  510. queue_work(dev_priv->wq,
  511. &dev_priv->hotplug_work);
  512. I915_WRITE(PORT_HOTPLUG_STAT, hotplug_status);
  513. I915_READ(PORT_HOTPLUG_STAT);
  514. /* EOS interrupts occurs */
  515. if (IS_IGD(dev) &&
  516. (hotplug_status & CRT_EOS_INT_STATUS)) {
  517. u32 temp;
  518. DRM_DEBUG("EOS interrupt occurs\n");
  519. /* status is already cleared */
  520. temp = I915_READ(ADPA);
  521. temp &= ~ADPA_DAC_ENABLE;
  522. I915_WRITE(ADPA, temp);
  523. temp = I915_READ(PORT_HOTPLUG_EN);
  524. temp &= ~CRT_EOS_INT_EN;
  525. I915_WRITE(PORT_HOTPLUG_EN, temp);
  526. temp = I915_READ(PORT_HOTPLUG_STAT);
  527. if (temp & CRT_EOS_INT_STATUS)
  528. I915_WRITE(PORT_HOTPLUG_STAT,
  529. CRT_EOS_INT_STATUS);
  530. }
  531. }
  532. I915_WRITE(IIR, iir);
  533. new_iir = I915_READ(IIR); /* Flush posted writes */
  534. if (dev->primary->master) {
  535. master_priv = dev->primary->master->driver_priv;
  536. if (master_priv->sarea_priv)
  537. master_priv->sarea_priv->last_dispatch =
  538. READ_BREADCRUMB(dev_priv);
  539. }
  540. if (iir & I915_USER_INTERRUPT) {
  541. u32 seqno = i915_get_gem_seqno(dev);
  542. dev_priv->mm.irq_gem_seqno = seqno;
  543. trace_i915_gem_request_complete(dev, seqno);
  544. DRM_WAKEUP(&dev_priv->irq_queue);
  545. dev_priv->hangcheck_count = 0;
  546. mod_timer(&dev_priv->hangcheck_timer, jiffies + DRM_I915_HANGCHECK_PERIOD);
  547. }
  548. if (pipea_stats & vblank_status) {
  549. vblank++;
  550. drm_handle_vblank(dev, 0);
  551. }
  552. if (pipeb_stats & vblank_status) {
  553. vblank++;
  554. drm_handle_vblank(dev, 1);
  555. }
  556. if ((pipeb_stats & I915_LEGACY_BLC_EVENT_STATUS) ||
  557. (iir & I915_ASLE_INTERRUPT))
  558. opregion_asle_intr(dev);
  559. /* With MSI, interrupts are only generated when iir
  560. * transitions from zero to nonzero. If another bit got
  561. * set while we were handling the existing iir bits, then
  562. * we would never get another interrupt.
  563. *
  564. * This is fine on non-MSI as well, as if we hit this path
  565. * we avoid exiting the interrupt handler only to generate
  566. * another one.
  567. *
  568. * Note that for MSI this could cause a stray interrupt report
  569. * if an interrupt landed in the time between writing IIR and
  570. * the posting read. This should be rare enough to never
  571. * trigger the 99% of 100,000 interrupts test for disabling
  572. * stray interrupts.
  573. */
  574. iir = new_iir;
  575. }
  576. return ret;
  577. }
  578. static int i915_emit_irq(struct drm_device * dev)
  579. {
  580. drm_i915_private_t *dev_priv = dev->dev_private;
  581. struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
  582. RING_LOCALS;
  583. i915_kernel_lost_context(dev);
  584. DRM_DEBUG("\n");
  585. dev_priv->counter++;
  586. if (dev_priv->counter > 0x7FFFFFFFUL)
  587. dev_priv->counter = 1;
  588. if (master_priv->sarea_priv)
  589. master_priv->sarea_priv->last_enqueue = dev_priv->counter;
  590. BEGIN_LP_RING(4);
  591. OUT_RING(MI_STORE_DWORD_INDEX);
  592. OUT_RING(I915_BREADCRUMB_INDEX << MI_STORE_DWORD_INDEX_SHIFT);
  593. OUT_RING(dev_priv->counter);
  594. OUT_RING(MI_USER_INTERRUPT);
  595. ADVANCE_LP_RING();
  596. return dev_priv->counter;
  597. }
  598. void i915_user_irq_get(struct drm_device *dev)
  599. {
  600. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  601. unsigned long irqflags;
  602. spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
  603. if (dev->irq_enabled && (++dev_priv->user_irq_refcount == 1)) {
  604. if (IS_IGDNG(dev))
  605. igdng_enable_graphics_irq(dev_priv, GT_USER_INTERRUPT);
  606. else
  607. i915_enable_irq(dev_priv, I915_USER_INTERRUPT);
  608. }
  609. spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags);
  610. }
  611. void i915_user_irq_put(struct drm_device *dev)
  612. {
  613. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  614. unsigned long irqflags;
  615. spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
  616. BUG_ON(dev->irq_enabled && dev_priv->user_irq_refcount <= 0);
  617. if (dev->irq_enabled && (--dev_priv->user_irq_refcount == 0)) {
  618. if (IS_IGDNG(dev))
  619. igdng_disable_graphics_irq(dev_priv, GT_USER_INTERRUPT);
  620. else
  621. i915_disable_irq(dev_priv, I915_USER_INTERRUPT);
  622. }
  623. spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags);
  624. }
  625. void i915_trace_irq_get(struct drm_device *dev, u32 seqno)
  626. {
  627. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  628. if (dev_priv->trace_irq_seqno == 0)
  629. i915_user_irq_get(dev);
  630. dev_priv->trace_irq_seqno = seqno;
  631. }
  632. static int i915_wait_irq(struct drm_device * dev, int irq_nr)
  633. {
  634. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  635. struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
  636. int ret = 0;
  637. DRM_DEBUG("irq_nr=%d breadcrumb=%d\n", irq_nr,
  638. READ_BREADCRUMB(dev_priv));
  639. if (READ_BREADCRUMB(dev_priv) >= irq_nr) {
  640. if (master_priv->sarea_priv)
  641. master_priv->sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
  642. return 0;
  643. }
  644. if (master_priv->sarea_priv)
  645. master_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
  646. i915_user_irq_get(dev);
  647. DRM_WAIT_ON(ret, dev_priv->irq_queue, 3 * DRM_HZ,
  648. READ_BREADCRUMB(dev_priv) >= irq_nr);
  649. i915_user_irq_put(dev);
  650. if (ret == -EBUSY) {
  651. DRM_ERROR("EBUSY -- rec: %d emitted: %d\n",
  652. READ_BREADCRUMB(dev_priv), (int)dev_priv->counter);
  653. }
  654. return ret;
  655. }
  656. /* Needs the lock as it touches the ring.
  657. */
  658. int i915_irq_emit(struct drm_device *dev, void *data,
  659. struct drm_file *file_priv)
  660. {
  661. drm_i915_private_t *dev_priv = dev->dev_private;
  662. drm_i915_irq_emit_t *emit = data;
  663. int result;
  664. if (!dev_priv || !dev_priv->ring.virtual_start) {
  665. DRM_ERROR("called with no initialization\n");
  666. return -EINVAL;
  667. }
  668. RING_LOCK_TEST_WITH_RETURN(dev, file_priv);
  669. mutex_lock(&dev->struct_mutex);
  670. result = i915_emit_irq(dev);
  671. mutex_unlock(&dev->struct_mutex);
  672. if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) {
  673. DRM_ERROR("copy_to_user\n");
  674. return -EFAULT;
  675. }
  676. return 0;
  677. }
  678. /* Doesn't need the hardware lock.
  679. */
  680. int i915_irq_wait(struct drm_device *dev, void *data,
  681. struct drm_file *file_priv)
  682. {
  683. drm_i915_private_t *dev_priv = dev->dev_private;
  684. drm_i915_irq_wait_t *irqwait = data;
  685. if (!dev_priv) {
  686. DRM_ERROR("called with no initialization\n");
  687. return -EINVAL;
  688. }
  689. return i915_wait_irq(dev, irqwait->irq_seq);
  690. }
  691. /* Called from drm generic code, passed 'crtc' which
  692. * we use as a pipe index
  693. */
  694. int i915_enable_vblank(struct drm_device *dev, int pipe)
  695. {
  696. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  697. unsigned long irqflags;
  698. int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF;
  699. u32 pipeconf;
  700. pipeconf = I915_READ(pipeconf_reg);
  701. if (!(pipeconf & PIPEACONF_ENABLE))
  702. return -EINVAL;
  703. if (IS_IGDNG(dev))
  704. return 0;
  705. spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
  706. if (IS_I965G(dev))
  707. i915_enable_pipestat(dev_priv, pipe,
  708. PIPE_START_VBLANK_INTERRUPT_ENABLE);
  709. else
  710. i915_enable_pipestat(dev_priv, pipe,
  711. PIPE_VBLANK_INTERRUPT_ENABLE);
  712. spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags);
  713. return 0;
  714. }
  715. /* Called from drm generic code, passed 'crtc' which
  716. * we use as a pipe index
  717. */
  718. void i915_disable_vblank(struct drm_device *dev, int pipe)
  719. {
  720. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  721. unsigned long irqflags;
  722. if (IS_IGDNG(dev))
  723. return;
  724. spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
  725. i915_disable_pipestat(dev_priv, pipe,
  726. PIPE_VBLANK_INTERRUPT_ENABLE |
  727. PIPE_START_VBLANK_INTERRUPT_ENABLE);
  728. spin_unlock_irqrestore(&dev_priv->user_irq_lock, irqflags);
  729. }
  730. void i915_enable_interrupt (struct drm_device *dev)
  731. {
  732. struct drm_i915_private *dev_priv = dev->dev_private;
  733. if (!IS_IGDNG(dev))
  734. opregion_enable_asle(dev);
  735. dev_priv->irq_enabled = 1;
  736. }
  737. /* Set the vblank monitor pipe
  738. */
  739. int i915_vblank_pipe_set(struct drm_device *dev, void *data,
  740. struct drm_file *file_priv)
  741. {
  742. drm_i915_private_t *dev_priv = dev->dev_private;
  743. if (!dev_priv) {
  744. DRM_ERROR("called with no initialization\n");
  745. return -EINVAL;
  746. }
  747. return 0;
  748. }
  749. int i915_vblank_pipe_get(struct drm_device *dev, void *data,
  750. struct drm_file *file_priv)
  751. {
  752. drm_i915_private_t *dev_priv = dev->dev_private;
  753. drm_i915_vblank_pipe_t *pipe = data;
  754. if (!dev_priv) {
  755. DRM_ERROR("called with no initialization\n");
  756. return -EINVAL;
  757. }
  758. pipe->pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B;
  759. return 0;
  760. }
  761. /**
  762. * Schedule buffer swap at given vertical blank.
  763. */
  764. int i915_vblank_swap(struct drm_device *dev, void *data,
  765. struct drm_file *file_priv)
  766. {
  767. /* The delayed swap mechanism was fundamentally racy, and has been
  768. * removed. The model was that the client requested a delayed flip/swap
  769. * from the kernel, then waited for vblank before continuing to perform
  770. * rendering. The problem was that the kernel might wake the client
  771. * up before it dispatched the vblank swap (since the lock has to be
  772. * held while touching the ringbuffer), in which case the client would
  773. * clear and start the next frame before the swap occurred, and
  774. * flicker would occur in addition to likely missing the vblank.
  775. *
  776. * In the absence of this ioctl, userland falls back to a correct path
  777. * of waiting for a vblank, then dispatching the swap on its own.
  778. * Context switching to userland and back is plenty fast enough for
  779. * meeting the requirements of vblank swapping.
  780. */
  781. return -EINVAL;
  782. }
  783. struct drm_i915_gem_request *i915_get_tail_request(struct drm_device *dev) {
  784. drm_i915_private_t *dev_priv = dev->dev_private;
  785. return list_entry(dev_priv->mm.request_list.prev, struct drm_i915_gem_request, list);
  786. }
  787. /**
  788. * This is called when the chip hasn't reported back with completed
  789. * batchbuffers in a long time. The first time this is called we simply record
  790. * ACTHD. If ACTHD hasn't changed by the time the hangcheck timer elapses
  791. * again, we assume the chip is wedged and try to fix it.
  792. */
  793. void i915_hangcheck_elapsed(unsigned long data)
  794. {
  795. struct drm_device *dev = (struct drm_device *)data;
  796. drm_i915_private_t *dev_priv = dev->dev_private;
  797. uint32_t acthd;
  798. if (!IS_I965G(dev))
  799. acthd = I915_READ(ACTHD);
  800. else
  801. acthd = I915_READ(ACTHD_I965);
  802. /* If all work is done then ACTHD clearly hasn't advanced. */
  803. if (list_empty(&dev_priv->mm.request_list) ||
  804. i915_seqno_passed(i915_get_gem_seqno(dev), i915_get_tail_request(dev)->seqno)) {
  805. dev_priv->hangcheck_count = 0;
  806. return;
  807. }
  808. if (dev_priv->last_acthd == acthd && dev_priv->hangcheck_count > 0) {
  809. DRM_ERROR("Hangcheck timer elapsed... GPU hung\n");
  810. i915_handle_error(dev, true);
  811. return;
  812. }
  813. /* Reset timer case chip hangs without another request being added */
  814. mod_timer(&dev_priv->hangcheck_timer, jiffies + DRM_I915_HANGCHECK_PERIOD);
  815. if (acthd != dev_priv->last_acthd)
  816. dev_priv->hangcheck_count = 0;
  817. else
  818. dev_priv->hangcheck_count++;
  819. dev_priv->last_acthd = acthd;
  820. }
  821. /* drm_dma.h hooks
  822. */
  823. static void igdng_irq_preinstall(struct drm_device *dev)
  824. {
  825. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  826. I915_WRITE(HWSTAM, 0xeffe);
  827. /* XXX hotplug from PCH */
  828. I915_WRITE(DEIMR, 0xffffffff);
  829. I915_WRITE(DEIER, 0x0);
  830. (void) I915_READ(DEIER);
  831. /* and GT */
  832. I915_WRITE(GTIMR, 0xffffffff);
  833. I915_WRITE(GTIER, 0x0);
  834. (void) I915_READ(GTIER);
  835. }
  836. static int igdng_irq_postinstall(struct drm_device *dev)
  837. {
  838. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  839. /* enable kind of interrupts always enabled */
  840. u32 display_mask = DE_MASTER_IRQ_CONTROL /*| DE_PCH_EVENT */;
  841. u32 render_mask = GT_USER_INTERRUPT;
  842. dev_priv->irq_mask_reg = ~display_mask;
  843. dev_priv->de_irq_enable_reg = display_mask;
  844. /* should always can generate irq */
  845. I915_WRITE(DEIIR, I915_READ(DEIIR));
  846. I915_WRITE(DEIMR, dev_priv->irq_mask_reg);
  847. I915_WRITE(DEIER, dev_priv->de_irq_enable_reg);
  848. (void) I915_READ(DEIER);
  849. /* user interrupt should be enabled, but masked initial */
  850. dev_priv->gt_irq_mask_reg = 0xffffffff;
  851. dev_priv->gt_irq_enable_reg = render_mask;
  852. I915_WRITE(GTIIR, I915_READ(GTIIR));
  853. I915_WRITE(GTIMR, dev_priv->gt_irq_mask_reg);
  854. I915_WRITE(GTIER, dev_priv->gt_irq_enable_reg);
  855. (void) I915_READ(GTIER);
  856. return 0;
  857. }
  858. void i915_driver_irq_preinstall(struct drm_device * dev)
  859. {
  860. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  861. atomic_set(&dev_priv->irq_received, 0);
  862. INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func);
  863. INIT_WORK(&dev_priv->error_work, i915_error_work_func);
  864. if (IS_IGDNG(dev)) {
  865. igdng_irq_preinstall(dev);
  866. return;
  867. }
  868. if (I915_HAS_HOTPLUG(dev)) {
  869. I915_WRITE(PORT_HOTPLUG_EN, 0);
  870. I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
  871. }
  872. I915_WRITE(HWSTAM, 0xeffe);
  873. I915_WRITE(PIPEASTAT, 0);
  874. I915_WRITE(PIPEBSTAT, 0);
  875. I915_WRITE(IMR, 0xffffffff);
  876. I915_WRITE(IER, 0x0);
  877. (void) I915_READ(IER);
  878. }
  879. int i915_driver_irq_postinstall(struct drm_device *dev)
  880. {
  881. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  882. u32 enable_mask = I915_INTERRUPT_ENABLE_FIX | I915_INTERRUPT_ENABLE_VAR;
  883. u32 error_mask;
  884. DRM_INIT_WAITQUEUE(&dev_priv->irq_queue);
  885. dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B;
  886. if (IS_IGDNG(dev))
  887. return igdng_irq_postinstall(dev);
  888. /* Unmask the interrupts that we always want on. */
  889. dev_priv->irq_mask_reg = ~I915_INTERRUPT_ENABLE_FIX;
  890. dev_priv->pipestat[0] = 0;
  891. dev_priv->pipestat[1] = 0;
  892. if (I915_HAS_HOTPLUG(dev)) {
  893. u32 hotplug_en = I915_READ(PORT_HOTPLUG_EN);
  894. /* Leave other bits alone */
  895. hotplug_en |= HOTPLUG_EN_MASK;
  896. I915_WRITE(PORT_HOTPLUG_EN, hotplug_en);
  897. dev_priv->hotplug_supported_mask = CRT_HOTPLUG_INT_STATUS |
  898. TV_HOTPLUG_INT_STATUS | SDVOC_HOTPLUG_INT_STATUS |
  899. SDVOB_HOTPLUG_INT_STATUS;
  900. if (IS_G4X(dev)) {
  901. dev_priv->hotplug_supported_mask |=
  902. HDMIB_HOTPLUG_INT_STATUS |
  903. HDMIC_HOTPLUG_INT_STATUS |
  904. HDMID_HOTPLUG_INT_STATUS;
  905. }
  906. /* Enable in IER... */
  907. enable_mask |= I915_DISPLAY_PORT_INTERRUPT;
  908. /* and unmask in IMR */
  909. i915_enable_irq(dev_priv, I915_DISPLAY_PORT_INTERRUPT);
  910. }
  911. /*
  912. * Enable some error detection, note the instruction error mask
  913. * bit is reserved, so we leave it masked.
  914. */
  915. if (IS_G4X(dev)) {
  916. error_mask = ~(GM45_ERROR_PAGE_TABLE |
  917. GM45_ERROR_MEM_PRIV |
  918. GM45_ERROR_CP_PRIV |
  919. I915_ERROR_MEMORY_REFRESH);
  920. } else {
  921. error_mask = ~(I915_ERROR_PAGE_TABLE |
  922. I915_ERROR_MEMORY_REFRESH);
  923. }
  924. I915_WRITE(EMR, error_mask);
  925. /* Disable pipe interrupt enables, clear pending pipe status */
  926. I915_WRITE(PIPEASTAT, I915_READ(PIPEASTAT) & 0x8000ffff);
  927. I915_WRITE(PIPEBSTAT, I915_READ(PIPEBSTAT) & 0x8000ffff);
  928. /* Clear pending interrupt status */
  929. I915_WRITE(IIR, I915_READ(IIR));
  930. I915_WRITE(IER, enable_mask);
  931. I915_WRITE(IMR, dev_priv->irq_mask_reg);
  932. (void) I915_READ(IER);
  933. opregion_enable_asle(dev);
  934. return 0;
  935. }
  936. static void igdng_irq_uninstall(struct drm_device *dev)
  937. {
  938. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  939. I915_WRITE(HWSTAM, 0xffffffff);
  940. I915_WRITE(DEIMR, 0xffffffff);
  941. I915_WRITE(DEIER, 0x0);
  942. I915_WRITE(DEIIR, I915_READ(DEIIR));
  943. I915_WRITE(GTIMR, 0xffffffff);
  944. I915_WRITE(GTIER, 0x0);
  945. I915_WRITE(GTIIR, I915_READ(GTIIR));
  946. }
  947. void i915_driver_irq_uninstall(struct drm_device * dev)
  948. {
  949. drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
  950. if (!dev_priv)
  951. return;
  952. dev_priv->vblank_pipe = 0;
  953. if (IS_IGDNG(dev)) {
  954. igdng_irq_uninstall(dev);
  955. return;
  956. }
  957. if (I915_HAS_HOTPLUG(dev)) {
  958. I915_WRITE(PORT_HOTPLUG_EN, 0);
  959. I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
  960. }
  961. I915_WRITE(HWSTAM, 0xffffffff);
  962. I915_WRITE(PIPEASTAT, 0);
  963. I915_WRITE(PIPEBSTAT, 0);
  964. I915_WRITE(IMR, 0xffffffff);
  965. I915_WRITE(IER, 0x0);
  966. I915_WRITE(PIPEASTAT, I915_READ(PIPEASTAT) & 0x8000ffff);
  967. I915_WRITE(PIPEBSTAT, I915_READ(PIPEBSTAT) & 0x8000ffff);
  968. I915_WRITE(IIR, I915_READ(IIR));
  969. }