nv04_instmem.c 2.9 KB

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