i915_irq.c 30 KB

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