Public paste
Undefined
By: Guest | Date: Dec 24 2009 22:29 | Format: None | Expires: never | Size: 5.92 KB | Hits: 873

  1. - Use the "direct" objects that previously only the kernel fifo had.
  2. - This avoids corruption on some buffer moves.
  3.  
  4. Signed-off-by: Maarten Maathuis <madman2003@gmail.com>
  5. ---
  6.  drivers/gpu/drm/nouveau/nouveau_bo.c     |   23 ++---------------
  7.  drivers/gpu/drm/nouveau/nouveau_object.c |   36 ++++++++++++++++++++++++++++
  8.  drivers/gpu/drm/nouveau/nouveau_state.c  |   38 +-----------------------------
  9.  3 files changed, 40 insertions(+), 57 deletions(-)
  10.  
  11. diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
  12. index e18d7fc..8ee5583 100644
  13. --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
  14. +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
  15. @@ -471,15 +471,9 @@ static inline uint32_t
  16.  nouveau_bo_mem_ctxdma(struct nouveau_bo *nvbo, struct nouveau_channel *chan,
  17.                      struct ttm_mem_reg *mem)
  18.  {
  19. -       if (chan == nouveau_bdev(nvbo->bo.bdev)->channel) {
  20. -               if (mem->mem_type == TTM_PL_TT)
  21. -                       return NvDmaGART;
  22. -               return NvDmaVRAM;
  23. -       }
  24. -
  25.        if (mem->mem_type == TTM_PL_TT)
  26. -               return chan->gart_handle;
  27. -       return chan->vram_handle;
  28. +               return NvDmaGART;
  29. +       return NvDmaVRAM;
  30.  }
  31.  
  32.  static int
  33. @@ -495,22 +489,11 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
  34.        int ret;
  35.  
  36.        chan = nvbo->channel;
  37. -       if (!chan || nvbo->tile_flags || nvbo->no_vm)
  38. +       if (!chan)
  39.                chan = dev_priv->channel;
  40.  
  41.        src_offset = old_mem->mm_node->start << PAGE_SHIFT;
  42.        dst_offset = new_mem->mm_node->start << PAGE_SHIFT;
  43. -       if (chan != dev_priv->channel) {
  44. -               if (old_mem->mem_type == TTM_PL_TT)
  45. -                       src_offset += dev_priv->vm_gart_base;
  46. -               else
  47. -                       src_offset += dev_priv->vm_vram_base;
  48. -
  49. -               if (new_mem->mem_type == TTM_PL_TT)
  50. -                       dst_offset += dev_priv->vm_gart_base;
  51. -               else
  52. -                       dst_offset += dev_priv->vm_vram_base;
  53. -       }
  54.  
  55.        ret = RING_SPACE(chan, 3);
  56.        if (ret)
  57. diff --git a/drivers/gpu/drm/nouveau/nouveau_object.c b/drivers/gpu/drm/nouveau/nouveau_object.c
  58. index 93379bb..35271c0 100644
  59. --- a/drivers/gpu/drm/nouveau/nouveau_object.c
  60. +++ b/drivers/gpu/drm/nouveau/nouveau_object.c
  61. @@ -33,6 +33,7 @@
  62.  #include "drmP.h"
  63.  #include "drm.h"
  64.  #include "nouveau_drv.h"
  65. +#include "nouveau_dma.h"
  66.  #include "nouveau_drm.h"
  67.  
  68.  /* NVidia uses context objects to drive drawing operations.
  69. @@ -1099,6 +1100,41 @@ nouveau_gpuobj_channel_init(struct nouveau_channel *chan,
  70.                return ret;
  71.        }
  72.  
  73. +       /* Two objects for kernel consumption, on nv50 they allow direct access
  74. +        * to vram. This is needed because we don't know the tiling layout.
  75. +        */
  76. +       vram = NULL;
  77. +       ret = nouveau_gpuobj_dma_new(chan, NV_CLASS_DMA_IN_MEMORY,
  78. +                               0, nouveau_mem_fb_amount(dev),
  79. +                               NV_DMA_ACCESS_RW, NV_DMA_TARGET_VIDMEM,
  80. +                               &vram);
  81. +       if (ret) {
  82. +               NV_ERROR(dev, "Error creating direct VRAM ctxdma: %dn", ret);
  83. +               return ret;
  84. +       }
  85. +
  86. +       ret = nouveau_gpuobj_ref_add(dev, chan, NvDmaVRAM, vram, NULL);
  87. +       if (ret) {
  88. +               NV_ERROR(dev, "Error referencing direct VRAM ctxdma:"
  89. +                       " %dn", ret);
  90. +               return ret;
  91. +       }
  92. +
  93. +       tt = NULL;
  94. +       ret = nouveau_gpuobj_gart_dma_new(chan, 0,
  95. +                                                 dev_priv->gart_info.aper_size,
  96. +                                                 NV_DMA_ACCESS_RW, &tt, NULL);
  97. +       if (ret) {
  98. +               NV_ERROR(dev, "Error creating GART ctxdma: %dn", ret);
  99. +               return ret;
  100. +       }
  101. +
  102. +       ret = nouveau_gpuobj_ref_add(dev, chan, NvDmaGART, tt, NULL);
  103. +       if (ret) {
  104. +               NV_ERROR(dev, "Error referencing GART ctxdma: %dn", ret);
  105. +               return ret;
  106. +       }
  107. +
  108.        return 0;
  109.  }
  110.  
  111. diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
  112. index 6a45913..c9757f2 100644
  113. --- a/drivers/gpu/drm/nouveau/nouveau_state.c
  114. +++ b/drivers/gpu/drm/nouveau/nouveau_state.c
  115. @@ -321,46 +321,10 @@ static int
  116.  nouveau_card_init_channel(struct drm_device *dev)
  117.  {
  118.        struct drm_nouveau_private *dev_priv = dev->dev_private;
  119. -       struct nouveau_gpuobj *gpuobj;
  120. -       int ret;
  121.  
  122. -       ret = nouveau_channel_alloc(dev, &dev_priv->channel,
  123. +       return nouveau_channel_alloc(dev, &dev_priv->channel,
  124.                                    (struct drm_file *)-2,
  125.                                    NvDmaFB, NvDmaTT);
  126. -       if (ret)
  127. -               return ret;
  128. -
  129. -       gpuobj = NULL;
  130. -       ret = nouveau_gpuobj_dma_new(dev_priv->channel, NV_CLASS_DMA_IN_MEMORY,
  131. -                                    0, nouveau_mem_fb_amount(dev),
  132. -                                    NV_DMA_ACCESS_RW, NV_DMA_TARGET_VIDMEM,
  133. -                                    &gpuobj);
  134. -       if (ret)
  135. -               goto out_err;
  136. -
  137. -       ret = nouveau_gpuobj_ref_add(dev, dev_priv->channel, NvDmaVRAM,
  138. -                                    gpuobj, NULL);
  139. -       if (ret)
  140. -               goto out_err;
  141. -
  142. -       gpuobj = NULL;
  143. -       ret = nouveau_gpuobj_gart_dma_new(dev_priv->channel, 0,
  144. -                                         dev_priv->gart_info.aper_size,
  145. -                                         NV_DMA_ACCESS_RW, &gpuobj, NULL);
  146. -       if (ret)
  147. -               goto out_err;
  148. -
  149. -       ret = nouveau_gpuobj_ref_add(dev, dev_priv->channel, NvDmaGART,
  150. -                                    gpuobj, NULL);
  151. -       if (ret)
  152. -               goto out_err;
  153. -
  154. -       return 0;
  155. -out_err:
  156. -       nouveau_gpuobj_del(dev, &gpuobj);
  157. -       nouveau_channel_free(dev_priv->channel);
  158. -       dev_priv->channel = NULL;
  159. -       return ret;
  160.  }
  161.  
  162.  int
  163. --
  164. 1.6.5.4