nv50_fb.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include "drmP.h"
  2. #include "drm.h"
  3. #include "nouveau_drv.h"
  4. #include "nouveau_drm.h"
  5. int
  6. nv50_fb_init(struct drm_device *dev)
  7. {
  8. struct drm_nouveau_private *dev_priv = dev->dev_private;
  9. /* Not a clue what this is exactly. Without pointing it at a
  10. * scratch page, VRAM->GART blits with M2MF (as in DDX DFS)
  11. * cause IOMMU "read from address 0" errors (rh#561267)
  12. */
  13. nv_wr32(dev, 0x100c08, dev_priv->gart_info.sg_dummy_bus >> 8);
  14. /* This is needed to get meaningful information from 100c90
  15. * on traps. No idea what these values mean exactly. */
  16. switch (dev_priv->chipset) {
  17. case 0x50:
  18. nv_wr32(dev, 0x100c90, 0x0707ff);
  19. break;
  20. case 0xa5:
  21. case 0xa8:
  22. nv_wr32(dev, 0x100c90, 0x0d0fff);
  23. break;
  24. default:
  25. nv_wr32(dev, 0x100c90, 0x1d07ff);
  26. break;
  27. }
  28. return 0;
  29. }
  30. void
  31. nv50_fb_takedown(struct drm_device *dev)
  32. {
  33. }
  34. void
  35. nv50_fb_vm_trap(struct drm_device *dev, int display, const char *name)
  36. {
  37. struct drm_nouveau_private *dev_priv = dev->dev_private;
  38. u32 trap[6], idx, chinst;
  39. int i, ch;
  40. idx = nv_rd32(dev, 0x100c90);
  41. if (!(idx & 0x80000000))
  42. return;
  43. idx &= 0x00ffffff;
  44. for (i = 0; i < 6; i++) {
  45. nv_wr32(dev, 0x100c90, idx | i << 24);
  46. trap[i] = nv_rd32(dev, 0x100c94);
  47. }
  48. nv_wr32(dev, 0x100c90, idx | 0x80000000);
  49. if (!display)
  50. return;
  51. chinst = (trap[2] << 16) | trap[1];
  52. for (ch = 0; ch < dev_priv->engine.fifo.channels; ch++) {
  53. struct nouveau_channel *chan = dev_priv->fifos[ch];
  54. if (!chan || !chan->ramin)
  55. continue;
  56. if (chinst == chan->ramin->vinst >> 12)
  57. break;
  58. }
  59. NV_INFO(dev, "%s - VM: Trapped %s at %02x%04x%04x status %08x "
  60. "channel %d (0x%08x)\n",
  61. name, (trap[5] & 0x100 ? "read" : "write"),
  62. trap[5] & 0xff, trap[4] & 0xffff, trap[3] & 0xffff,
  63. trap[0], ch, chinst);
  64. }