nv04_instmem.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #include "drmP.h"
  2. #include "drm.h"
  3. #include "nouveau_drv.h"
  4. #include "nouveau_ramht.h"
  5. /* returns the size of fifo context */
  6. static int
  7. nouveau_fifo_ctx_size(struct drm_device *dev)
  8. {
  9. struct drm_nouveau_private *dev_priv = dev->dev_private;
  10. if (dev_priv->chipset >= 0x40)
  11. return 128;
  12. else
  13. if (dev_priv->chipset >= 0x17)
  14. return 64;
  15. return 32;
  16. }
  17. int nv04_instmem_init(struct drm_device *dev)
  18. {
  19. struct drm_nouveau_private *dev_priv = dev->dev_private;
  20. struct nouveau_gpuobj *ramht = NULL;
  21. u32 offset, length;
  22. int ret;
  23. /* Setup shared RAMHT */
  24. ret = nouveau_gpuobj_new_fake(dev, 0x10000, ~0, 4096,
  25. NVOBJ_FLAG_ZERO_ALLOC, &ramht);
  26. if (ret)
  27. return ret;
  28. ret = nouveau_ramht_new(dev, ramht, &dev_priv->ramht);
  29. nouveau_gpuobj_ref(NULL, &ramht);
  30. if (ret)
  31. return ret;
  32. /* And RAMRO */
  33. ret = nouveau_gpuobj_new_fake(dev, 0x11200, ~0, 512,
  34. NVOBJ_FLAG_ZERO_ALLOC, &dev_priv->ramro);
  35. if (ret)
  36. return ret;
  37. /* And RAMFC */
  38. length = dev_priv->engine.fifo.channels * nouveau_fifo_ctx_size(dev);
  39. switch (dev_priv->card_type) {
  40. case NV_40:
  41. offset = 0x20000;
  42. break;
  43. default:
  44. offset = 0x11400;
  45. break;
  46. }
  47. ret = nouveau_gpuobj_new_fake(dev, offset, ~0, length,
  48. NVOBJ_FLAG_ZERO_ALLOC, &dev_priv->ramfc);
  49. if (ret)
  50. return ret;
  51. /* Only allow space after RAMFC to be used for object allocation */
  52. offset += length;
  53. /* It appears RAMRO (or something?) is controlled by 0x2220/0x2230
  54. * on certain NV4x chipsets as well as RAMFC. When 0x2230 == 0
  55. * ("new style" control) the upper 16-bits of 0x2220 points at this
  56. * other mysterious table that's clobbering important things.
  57. *
  58. * We're now pointing this at RAMIN+0x30000 to avoid RAMFC getting
  59. * smashed to pieces on us, so reserve 0x30000-0x40000 too..
  60. */
  61. if (dev_priv->card_type >= NV_40) {
  62. if (offset < 0x40000)
  63. offset = 0x40000;
  64. }
  65. ret = drm_mm_init(&dev_priv->ramin_heap, offset,
  66. dev_priv->ramin_rsvd_vram - offset);
  67. if (ret) {
  68. NV_ERROR(dev, "Failed to init RAMIN heap: %d\n", ret);
  69. return ret;
  70. }
  71. dev_priv->ramin_available = true;
  72. return 0;
  73. }
  74. void
  75. nv04_instmem_takedown(struct drm_device *dev)
  76. {
  77. struct drm_nouveau_private *dev_priv = dev->dev_private;
  78. nouveau_ramht_ref(NULL, &dev_priv->ramht, NULL);
  79. nouveau_gpuobj_ref(NULL, &dev_priv->ramro);
  80. nouveau_gpuobj_ref(NULL, &dev_priv->ramfc);
  81. }
  82. int
  83. nv04_instmem_populate(struct drm_device *dev, struct nouveau_gpuobj *gpuobj,
  84. uint32_t *sz)
  85. {
  86. return 0;
  87. }
  88. void
  89. nv04_instmem_clear(struct drm_device *dev, struct nouveau_gpuobj *gpuobj)
  90. {
  91. }
  92. int
  93. nv04_instmem_bind(struct drm_device *dev, struct nouveau_gpuobj *gpuobj)
  94. {
  95. return 0;
  96. }
  97. int
  98. nv04_instmem_unbind(struct drm_device *dev, struct nouveau_gpuobj *gpuobj)
  99. {
  100. return 0;
  101. }
  102. void
  103. nv04_instmem_flush(struct drm_device *dev)
  104. {
  105. }
  106. int
  107. nv04_instmem_suspend(struct drm_device *dev)
  108. {
  109. return 0;
  110. }
  111. void
  112. nv04_instmem_resume(struct drm_device *dev)
  113. {
  114. }