nv04_fifo.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. /*
  2. * Copyright (C) 2007 Ben Skeggs.
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining
  6. * a copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sublicense, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the
  14. * next paragraph) shall be included in all copies or substantial
  15. * portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  20. * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
  21. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  22. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  23. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. *
  25. */
  26. #include "drmP.h"
  27. #include "drm.h"
  28. #include "nouveau_drv.h"
  29. #include "nouveau_ramht.h"
  30. #include "nouveau_util.h"
  31. #define NV04_RAMFC(c) (dev_priv->ramfc->pinst + ((c) * NV04_RAMFC__SIZE))
  32. #define NV04_RAMFC__SIZE 32
  33. #define NV04_RAMFC_DMA_PUT 0x00
  34. #define NV04_RAMFC_DMA_GET 0x04
  35. #define NV04_RAMFC_DMA_INSTANCE 0x08
  36. #define NV04_RAMFC_DMA_STATE 0x0C
  37. #define NV04_RAMFC_DMA_FETCH 0x10
  38. #define NV04_RAMFC_ENGINE 0x14
  39. #define NV04_RAMFC_PULL1_ENGINE 0x18
  40. #define RAMFC_WR(offset, val) nv_wo32(chan->ramfc, NV04_RAMFC_##offset, (val))
  41. #define RAMFC_RD(offset) nv_ro32(chan->ramfc, NV04_RAMFC_##offset)
  42. void
  43. nv04_fifo_disable(struct drm_device *dev)
  44. {
  45. uint32_t tmp;
  46. tmp = nv_rd32(dev, NV04_PFIFO_CACHE1_DMA_PUSH);
  47. nv_wr32(dev, NV04_PFIFO_CACHE1_DMA_PUSH, tmp & ~1);
  48. nv_wr32(dev, NV03_PFIFO_CACHE1_PUSH0, 0);
  49. tmp = nv_rd32(dev, NV03_PFIFO_CACHE1_PULL1);
  50. nv_wr32(dev, NV04_PFIFO_CACHE1_PULL0, tmp & ~1);
  51. }
  52. void
  53. nv04_fifo_enable(struct drm_device *dev)
  54. {
  55. nv_wr32(dev, NV03_PFIFO_CACHE1_PUSH0, 1);
  56. nv_wr32(dev, NV04_PFIFO_CACHE1_PULL0, 1);
  57. }
  58. bool
  59. nv04_fifo_reassign(struct drm_device *dev, bool enable)
  60. {
  61. uint32_t reassign = nv_rd32(dev, NV03_PFIFO_CACHES);
  62. nv_wr32(dev, NV03_PFIFO_CACHES, enable ? 1 : 0);
  63. return (reassign == 1);
  64. }
  65. bool
  66. nv04_fifo_cache_pull(struct drm_device *dev, bool enable)
  67. {
  68. int pull = nv_mask(dev, NV04_PFIFO_CACHE1_PULL0, 1, enable);
  69. if (!enable) {
  70. /* In some cases the PFIFO puller may be left in an
  71. * inconsistent state if you try to stop it when it's
  72. * busy translating handles. Sometimes you get a
  73. * PFIFO_CACHE_ERROR, sometimes it just fails silently
  74. * sending incorrect instance offsets to PGRAPH after
  75. * it's started up again. To avoid the latter we
  76. * invalidate the most recently calculated instance.
  77. */
  78. if (!nv_wait(dev, NV04_PFIFO_CACHE1_PULL0,
  79. NV04_PFIFO_CACHE1_PULL0_HASH_BUSY, 0))
  80. NV_ERROR(dev, "Timeout idling the PFIFO puller.\n");
  81. if (nv_rd32(dev, NV04_PFIFO_CACHE1_PULL0) &
  82. NV04_PFIFO_CACHE1_PULL0_HASH_FAILED)
  83. nv_wr32(dev, NV03_PFIFO_INTR_0,
  84. NV_PFIFO_INTR_CACHE_ERROR);
  85. nv_wr32(dev, NV04_PFIFO_CACHE1_HASH, 0);
  86. }
  87. return pull & 1;
  88. }
  89. int
  90. nv04_fifo_channel_id(struct drm_device *dev)
  91. {
  92. return nv_rd32(dev, NV03_PFIFO_CACHE1_PUSH1) &
  93. NV03_PFIFO_CACHE1_PUSH1_CHID_MASK;
  94. }
  95. #ifdef __BIG_ENDIAN
  96. #define DMA_FETCH_ENDIANNESS NV_PFIFO_CACHE1_BIG_ENDIAN
  97. #else
  98. #define DMA_FETCH_ENDIANNESS 0
  99. #endif
  100. int
  101. nv04_fifo_create_context(struct nouveau_channel *chan)
  102. {
  103. struct drm_device *dev = chan->dev;
  104. struct drm_nouveau_private *dev_priv = dev->dev_private;
  105. unsigned long flags;
  106. int ret;
  107. ret = nouveau_gpuobj_new_fake(dev, NV04_RAMFC(chan->id), ~0,
  108. NV04_RAMFC__SIZE,
  109. NVOBJ_FLAG_ZERO_ALLOC |
  110. NVOBJ_FLAG_ZERO_FREE,
  111. &chan->ramfc);
  112. if (ret)
  113. return ret;
  114. chan->user = ioremap(pci_resource_start(dev->pdev, 0) +
  115. NV03_USER(chan->id), PAGE_SIZE);
  116. if (!chan->user)
  117. return -ENOMEM;
  118. spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
  119. /* Setup initial state */
  120. RAMFC_WR(DMA_PUT, chan->pushbuf_base);
  121. RAMFC_WR(DMA_GET, chan->pushbuf_base);
  122. RAMFC_WR(DMA_INSTANCE, chan->pushbuf->pinst >> 4);
  123. RAMFC_WR(DMA_FETCH, (NV_PFIFO_CACHE1_DMA_FETCH_TRIG_128_BYTES |
  124. NV_PFIFO_CACHE1_DMA_FETCH_SIZE_128_BYTES |
  125. NV_PFIFO_CACHE1_DMA_FETCH_MAX_REQS_8 |
  126. DMA_FETCH_ENDIANNESS));
  127. /* enable the fifo dma operation */
  128. nv_wr32(dev, NV04_PFIFO_MODE,
  129. nv_rd32(dev, NV04_PFIFO_MODE) | (1 << chan->id));
  130. spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
  131. return 0;
  132. }
  133. void
  134. nv04_fifo_destroy_context(struct nouveau_channel *chan)
  135. {
  136. struct drm_device *dev = chan->dev;
  137. struct drm_nouveau_private *dev_priv = dev->dev_private;
  138. struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
  139. unsigned long flags;
  140. spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
  141. pfifo->reassign(dev, false);
  142. /* Unload the context if it's the currently active one */
  143. if (pfifo->channel_id(dev) == chan->id) {
  144. pfifo->disable(dev);
  145. pfifo->unload_context(dev);
  146. pfifo->enable(dev);
  147. }
  148. /* Keep it from being rescheduled */
  149. nv_mask(dev, NV04_PFIFO_MODE, 1 << chan->id, 0);
  150. pfifo->reassign(dev, true);
  151. spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
  152. /* Free the channel resources */
  153. if (chan->user) {
  154. iounmap(chan->user);
  155. chan->user = NULL;
  156. }
  157. nouveau_gpuobj_ref(NULL, &chan->ramfc);
  158. }
  159. static void
  160. nv04_fifo_do_load_context(struct drm_device *dev, int chid)
  161. {
  162. struct drm_nouveau_private *dev_priv = dev->dev_private;
  163. uint32_t fc = NV04_RAMFC(chid), tmp;
  164. nv_wr32(dev, NV04_PFIFO_CACHE1_DMA_PUT, nv_ri32(dev, fc + 0));
  165. nv_wr32(dev, NV04_PFIFO_CACHE1_DMA_GET, nv_ri32(dev, fc + 4));
  166. tmp = nv_ri32(dev, fc + 8);
  167. nv_wr32(dev, NV04_PFIFO_CACHE1_DMA_INSTANCE, tmp & 0xFFFF);
  168. nv_wr32(dev, NV04_PFIFO_CACHE1_DMA_DCOUNT, tmp >> 16);
  169. nv_wr32(dev, NV04_PFIFO_CACHE1_DMA_STATE, nv_ri32(dev, fc + 12));
  170. nv_wr32(dev, NV04_PFIFO_CACHE1_DMA_FETCH, nv_ri32(dev, fc + 16));
  171. nv_wr32(dev, NV04_PFIFO_CACHE1_ENGINE, nv_ri32(dev, fc + 20));
  172. nv_wr32(dev, NV04_PFIFO_CACHE1_PULL1, nv_ri32(dev, fc + 24));
  173. nv_wr32(dev, NV03_PFIFO_CACHE1_GET, 0);
  174. nv_wr32(dev, NV03_PFIFO_CACHE1_PUT, 0);
  175. }
  176. int
  177. nv04_fifo_load_context(struct nouveau_channel *chan)
  178. {
  179. uint32_t tmp;
  180. nv_wr32(chan->dev, NV03_PFIFO_CACHE1_PUSH1,
  181. NV03_PFIFO_CACHE1_PUSH1_DMA | chan->id);
  182. nv04_fifo_do_load_context(chan->dev, chan->id);
  183. nv_wr32(chan->dev, NV04_PFIFO_CACHE1_DMA_PUSH, 1);
  184. /* Reset NV04_PFIFO_CACHE1_DMA_CTL_AT_INFO to INVALID */
  185. tmp = nv_rd32(chan->dev, NV04_PFIFO_CACHE1_DMA_CTL) & ~(1 << 31);
  186. nv_wr32(chan->dev, NV04_PFIFO_CACHE1_DMA_CTL, tmp);
  187. return 0;
  188. }
  189. int
  190. nv04_fifo_unload_context(struct drm_device *dev)
  191. {
  192. struct drm_nouveau_private *dev_priv = dev->dev_private;
  193. struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
  194. struct nouveau_channel *chan = NULL;
  195. uint32_t tmp;
  196. int chid;
  197. chid = pfifo->channel_id(dev);
  198. if (chid < 0 || chid >= dev_priv->engine.fifo.channels)
  199. return 0;
  200. chan = dev_priv->channels.ptr[chid];
  201. if (!chan) {
  202. NV_ERROR(dev, "Inactive channel on PFIFO: %d\n", chid);
  203. return -EINVAL;
  204. }
  205. RAMFC_WR(DMA_PUT, nv_rd32(dev, NV04_PFIFO_CACHE1_DMA_PUT));
  206. RAMFC_WR(DMA_GET, nv_rd32(dev, NV04_PFIFO_CACHE1_DMA_GET));
  207. tmp = nv_rd32(dev, NV04_PFIFO_CACHE1_DMA_DCOUNT) << 16;
  208. tmp |= nv_rd32(dev, NV04_PFIFO_CACHE1_DMA_INSTANCE);
  209. RAMFC_WR(DMA_INSTANCE, tmp);
  210. RAMFC_WR(DMA_STATE, nv_rd32(dev, NV04_PFIFO_CACHE1_DMA_STATE));
  211. RAMFC_WR(DMA_FETCH, nv_rd32(dev, NV04_PFIFO_CACHE1_DMA_FETCH));
  212. RAMFC_WR(ENGINE, nv_rd32(dev, NV04_PFIFO_CACHE1_ENGINE));
  213. RAMFC_WR(PULL1_ENGINE, nv_rd32(dev, NV04_PFIFO_CACHE1_PULL1));
  214. nv04_fifo_do_load_context(dev, pfifo->channels - 1);
  215. nv_wr32(dev, NV03_PFIFO_CACHE1_PUSH1, pfifo->channels - 1);
  216. return 0;
  217. }
  218. static void
  219. nv04_fifo_init_reset(struct drm_device *dev)
  220. {
  221. nv_wr32(dev, NV03_PMC_ENABLE,
  222. nv_rd32(dev, NV03_PMC_ENABLE) & ~NV_PMC_ENABLE_PFIFO);
  223. nv_wr32(dev, NV03_PMC_ENABLE,
  224. nv_rd32(dev, NV03_PMC_ENABLE) | NV_PMC_ENABLE_PFIFO);
  225. nv_wr32(dev, 0x003224, 0x000f0078);
  226. nv_wr32(dev, 0x002044, 0x0101ffff);
  227. nv_wr32(dev, 0x002040, 0x000000ff);
  228. nv_wr32(dev, 0x002500, 0x00000000);
  229. nv_wr32(dev, 0x003000, 0x00000000);
  230. nv_wr32(dev, 0x003050, 0x00000000);
  231. nv_wr32(dev, 0x003200, 0x00000000);
  232. nv_wr32(dev, 0x003250, 0x00000000);
  233. nv_wr32(dev, 0x003220, 0x00000000);
  234. nv_wr32(dev, 0x003250, 0x00000000);
  235. nv_wr32(dev, 0x003270, 0x00000000);
  236. nv_wr32(dev, 0x003210, 0x00000000);
  237. }
  238. static void
  239. nv04_fifo_init_ramxx(struct drm_device *dev)
  240. {
  241. struct drm_nouveau_private *dev_priv = dev->dev_private;
  242. nv_wr32(dev, NV03_PFIFO_RAMHT, (0x03 << 24) /* search 128 */ |
  243. ((dev_priv->ramht->bits - 9) << 16) |
  244. (dev_priv->ramht->gpuobj->pinst >> 8));
  245. nv_wr32(dev, NV03_PFIFO_RAMRO, dev_priv->ramro->pinst >> 8);
  246. nv_wr32(dev, NV03_PFIFO_RAMFC, dev_priv->ramfc->pinst >> 8);
  247. }
  248. static void
  249. nv04_fifo_init_intr(struct drm_device *dev)
  250. {
  251. nouveau_irq_register(dev, 8, nv04_fifo_isr);
  252. nv_wr32(dev, 0x002100, 0xffffffff);
  253. nv_wr32(dev, 0x002140, 0xffffffff);
  254. }
  255. int
  256. nv04_fifo_init(struct drm_device *dev)
  257. {
  258. struct drm_nouveau_private *dev_priv = dev->dev_private;
  259. struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
  260. int i;
  261. nv04_fifo_init_reset(dev);
  262. nv04_fifo_init_ramxx(dev);
  263. nv04_fifo_do_load_context(dev, pfifo->channels - 1);
  264. nv_wr32(dev, NV03_PFIFO_CACHE1_PUSH1, pfifo->channels - 1);
  265. nv04_fifo_init_intr(dev);
  266. pfifo->enable(dev);
  267. pfifo->reassign(dev, true);
  268. for (i = 0; i < dev_priv->engine.fifo.channels; i++) {
  269. if (dev_priv->channels.ptr[i]) {
  270. uint32_t mode = nv_rd32(dev, NV04_PFIFO_MODE);
  271. nv_wr32(dev, NV04_PFIFO_MODE, mode | (1 << i));
  272. }
  273. }
  274. return 0;
  275. }
  276. void
  277. nv04_fifo_fini(struct drm_device *dev)
  278. {
  279. nv_wr32(dev, 0x2140, 0x00000000);
  280. nouveau_irq_unregister(dev, 8);
  281. }
  282. static bool
  283. nouveau_fifo_swmthd(struct drm_device *dev, u32 chid, u32 addr, u32 data)
  284. {
  285. struct drm_nouveau_private *dev_priv = dev->dev_private;
  286. struct nouveau_channel *chan = NULL;
  287. struct nouveau_gpuobj *obj;
  288. unsigned long flags;
  289. const int subc = (addr >> 13) & 0x7;
  290. const int mthd = addr & 0x1ffc;
  291. bool handled = false;
  292. u32 engine;
  293. spin_lock_irqsave(&dev_priv->channels.lock, flags);
  294. if (likely(chid >= 0 && chid < dev_priv->engine.fifo.channels))
  295. chan = dev_priv->channels.ptr[chid];
  296. if (unlikely(!chan))
  297. goto out;
  298. switch (mthd) {
  299. case 0x0000: /* bind object to subchannel */
  300. obj = nouveau_ramht_find(chan, data);
  301. if (unlikely(!obj || obj->engine != NVOBJ_ENGINE_SW))
  302. break;
  303. chan->sw_subchannel[subc] = obj->class;
  304. engine = 0x0000000f << (subc * 4);
  305. nv_mask(dev, NV04_PFIFO_CACHE1_ENGINE, engine, 0x00000000);
  306. handled = true;
  307. break;
  308. default:
  309. engine = nv_rd32(dev, NV04_PFIFO_CACHE1_ENGINE);
  310. if (unlikely(((engine >> (subc * 4)) & 0xf) != 0))
  311. break;
  312. if (!nouveau_gpuobj_mthd_call(chan, chan->sw_subchannel[subc],
  313. mthd, data))
  314. handled = true;
  315. break;
  316. }
  317. out:
  318. spin_unlock_irqrestore(&dev_priv->channels.lock, flags);
  319. return handled;
  320. }
  321. static const char *nv_dma_state_err(u32 state)
  322. {
  323. static const char * const desc[] = {
  324. "NONE", "CALL_SUBR_ACTIVE", "INVALID_MTHD", "RET_SUBR_INACTIVE",
  325. "INVALID_CMD", "IB_EMPTY"/* NV50+ */, "MEM_FAULT", "UNK"
  326. };
  327. return desc[(state >> 29) & 0x7];
  328. }
  329. void
  330. nv04_fifo_isr(struct drm_device *dev)
  331. {
  332. struct drm_nouveau_private *dev_priv = dev->dev_private;
  333. struct nouveau_engine *engine = &dev_priv->engine;
  334. uint32_t status, reassign;
  335. int cnt = 0;
  336. reassign = nv_rd32(dev, NV03_PFIFO_CACHES) & 1;
  337. while ((status = nv_rd32(dev, NV03_PFIFO_INTR_0)) && (cnt++ < 100)) {
  338. uint32_t chid, get;
  339. nv_wr32(dev, NV03_PFIFO_CACHES, 0);
  340. chid = engine->fifo.channel_id(dev);
  341. get = nv_rd32(dev, NV03_PFIFO_CACHE1_GET);
  342. if (status & NV_PFIFO_INTR_CACHE_ERROR) {
  343. uint32_t mthd, data;
  344. int ptr;
  345. /* NV_PFIFO_CACHE1_GET actually goes to 0xffc before
  346. * wrapping on my G80 chips, but CACHE1 isn't big
  347. * enough for this much data.. Tests show that it
  348. * wraps around to the start at GET=0x800.. No clue
  349. * as to why..
  350. */
  351. ptr = (get & 0x7ff) >> 2;
  352. if (dev_priv->card_type < NV_40) {
  353. mthd = nv_rd32(dev,
  354. NV04_PFIFO_CACHE1_METHOD(ptr));
  355. data = nv_rd32(dev,
  356. NV04_PFIFO_CACHE1_DATA(ptr));
  357. } else {
  358. mthd = nv_rd32(dev,
  359. NV40_PFIFO_CACHE1_METHOD(ptr));
  360. data = nv_rd32(dev,
  361. NV40_PFIFO_CACHE1_DATA(ptr));
  362. }
  363. if (!nouveau_fifo_swmthd(dev, chid, mthd, data)) {
  364. NV_INFO(dev, "PFIFO_CACHE_ERROR - Ch %d/%d "
  365. "Mthd 0x%04x Data 0x%08x\n",
  366. chid, (mthd >> 13) & 7, mthd & 0x1ffc,
  367. data);
  368. }
  369. nv_wr32(dev, NV04_PFIFO_CACHE1_DMA_PUSH, 0);
  370. nv_wr32(dev, NV03_PFIFO_INTR_0,
  371. NV_PFIFO_INTR_CACHE_ERROR);
  372. nv_wr32(dev, NV03_PFIFO_CACHE1_PUSH0,
  373. nv_rd32(dev, NV03_PFIFO_CACHE1_PUSH0) & ~1);
  374. nv_wr32(dev, NV03_PFIFO_CACHE1_GET, get + 4);
  375. nv_wr32(dev, NV03_PFIFO_CACHE1_PUSH0,
  376. nv_rd32(dev, NV03_PFIFO_CACHE1_PUSH0) | 1);
  377. nv_wr32(dev, NV04_PFIFO_CACHE1_HASH, 0);
  378. nv_wr32(dev, NV04_PFIFO_CACHE1_DMA_PUSH,
  379. nv_rd32(dev, NV04_PFIFO_CACHE1_DMA_PUSH) | 1);
  380. nv_wr32(dev, NV04_PFIFO_CACHE1_PULL0, 1);
  381. status &= ~NV_PFIFO_INTR_CACHE_ERROR;
  382. }
  383. if (status & NV_PFIFO_INTR_DMA_PUSHER) {
  384. u32 dma_get = nv_rd32(dev, 0x003244);
  385. u32 dma_put = nv_rd32(dev, 0x003240);
  386. u32 push = nv_rd32(dev, 0x003220);
  387. u32 state = nv_rd32(dev, 0x003228);
  388. if (dev_priv->card_type == NV_50) {
  389. u32 ho_get = nv_rd32(dev, 0x003328);
  390. u32 ho_put = nv_rd32(dev, 0x003320);
  391. u32 ib_get = nv_rd32(dev, 0x003334);
  392. u32 ib_put = nv_rd32(dev, 0x003330);
  393. if (nouveau_ratelimit())
  394. NV_INFO(dev, "PFIFO_DMA_PUSHER - Ch %d Get 0x%02x%08x "
  395. "Put 0x%02x%08x IbGet 0x%08x IbPut 0x%08x "
  396. "State 0x%08x (err: %s) Push 0x%08x\n",
  397. chid, ho_get, dma_get, ho_put,
  398. dma_put, ib_get, ib_put, state,
  399. nv_dma_state_err(state),
  400. push);
  401. /* METHOD_COUNT, in DMA_STATE on earlier chipsets */
  402. nv_wr32(dev, 0x003364, 0x00000000);
  403. if (dma_get != dma_put || ho_get != ho_put) {
  404. nv_wr32(dev, 0x003244, dma_put);
  405. nv_wr32(dev, 0x003328, ho_put);
  406. } else
  407. if (ib_get != ib_put) {
  408. nv_wr32(dev, 0x003334, ib_put);
  409. }
  410. } else {
  411. NV_INFO(dev, "PFIFO_DMA_PUSHER - Ch %d Get 0x%08x "
  412. "Put 0x%08x State 0x%08x (err: %s) Push 0x%08x\n",
  413. chid, dma_get, dma_put, state,
  414. nv_dma_state_err(state), push);
  415. if (dma_get != dma_put)
  416. nv_wr32(dev, 0x003244, dma_put);
  417. }
  418. nv_wr32(dev, 0x003228, 0x00000000);
  419. nv_wr32(dev, 0x003220, 0x00000001);
  420. nv_wr32(dev, 0x002100, NV_PFIFO_INTR_DMA_PUSHER);
  421. status &= ~NV_PFIFO_INTR_DMA_PUSHER;
  422. }
  423. if (status & NV_PFIFO_INTR_SEMAPHORE) {
  424. uint32_t sem;
  425. status &= ~NV_PFIFO_INTR_SEMAPHORE;
  426. nv_wr32(dev, NV03_PFIFO_INTR_0,
  427. NV_PFIFO_INTR_SEMAPHORE);
  428. sem = nv_rd32(dev, NV10_PFIFO_CACHE1_SEMAPHORE);
  429. nv_wr32(dev, NV10_PFIFO_CACHE1_SEMAPHORE, sem | 0x1);
  430. nv_wr32(dev, NV03_PFIFO_CACHE1_GET, get + 4);
  431. nv_wr32(dev, NV04_PFIFO_CACHE1_PULL0, 1);
  432. }
  433. if (dev_priv->card_type == NV_50) {
  434. if (status & 0x00000010) {
  435. nv50_fb_vm_trap(dev, nouveau_ratelimit());
  436. status &= ~0x00000010;
  437. nv_wr32(dev, 0x002100, 0x00000010);
  438. }
  439. }
  440. if (status) {
  441. if (nouveau_ratelimit())
  442. NV_INFO(dev, "PFIFO_INTR 0x%08x - Ch %d\n",
  443. status, chid);
  444. nv_wr32(dev, NV03_PFIFO_INTR_0, status);
  445. status = 0;
  446. }
  447. nv_wr32(dev, NV03_PFIFO_CACHES, reassign);
  448. }
  449. if (status) {
  450. NV_INFO(dev, "PFIFO still angry after %d spins, halt\n", cnt);
  451. nv_wr32(dev, 0x2140, 0);
  452. nv_wr32(dev, 0x140, 0);
  453. }
  454. nv_wr32(dev, NV03_PMC_INTR_0, NV_PMC_INTR_0_PFIFO_PENDING);
  455. }