nouveau_vm.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright 2010 Red Hat Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: Ben Skeggs
  23. */
  24. #ifndef __NOUVEAU_VM_H__
  25. #define __NOUVEAU_VM_H__
  26. #include "drmP.h"
  27. #include "nouveau_drv.h"
  28. #include "nouveau_mm.h"
  29. struct nouveau_vm_pgt {
  30. struct nouveau_gpuobj *obj[2];
  31. u32 refcount[2];
  32. };
  33. struct nouveau_vm_pgd {
  34. struct list_head head;
  35. struct nouveau_gpuobj *obj;
  36. };
  37. struct nouveau_vma {
  38. struct nouveau_vm *vm;
  39. struct nouveau_mm_node *node;
  40. u64 offset;
  41. u32 access;
  42. };
  43. struct nouveau_vm {
  44. struct drm_device *dev;
  45. struct nouveau_mm *mm;
  46. int refcount;
  47. struct list_head pgd_list;
  48. atomic_t pgraph_refs;
  49. atomic_t pcrypt_refs;
  50. struct nouveau_vm_pgt *pgt;
  51. u32 fpde;
  52. u32 lpde;
  53. u32 pgt_bits;
  54. u8 spg_shift;
  55. u8 lpg_shift;
  56. void (*map_pgt)(struct nouveau_gpuobj *pgd, u32 pde,
  57. struct nouveau_gpuobj *pgt[2]);
  58. void (*map)(struct nouveau_vma *, struct nouveau_gpuobj *,
  59. struct nouveau_vram *, u32 pte, u32 cnt, u64 phys);
  60. void (*map_sg)(struct nouveau_vma *, struct nouveau_gpuobj *,
  61. u32 pte, dma_addr_t *, u32 cnt);
  62. void (*unmap)(struct nouveau_gpuobj *pgt, u32 pte, u32 cnt);
  63. void (*flush)(struct nouveau_vm *);
  64. };
  65. /* nouveau_vm.c */
  66. int nouveau_vm_new(struct drm_device *, u64 offset, u64 length, u64 mm_offset,
  67. struct nouveau_vm **);
  68. int nouveau_vm_ref(struct nouveau_vm *, struct nouveau_vm **,
  69. struct nouveau_gpuobj *pgd);
  70. int nouveau_vm_get(struct nouveau_vm *, u64 size, u32 page_shift,
  71. u32 access, struct nouveau_vma *);
  72. void nouveau_vm_put(struct nouveau_vma *);
  73. void nouveau_vm_map(struct nouveau_vma *, struct nouveau_vram *);
  74. void nouveau_vm_map_at(struct nouveau_vma *, u64 offset, struct nouveau_vram *);
  75. void nouveau_vm_unmap(struct nouveau_vma *);
  76. void nouveau_vm_unmap_at(struct nouveau_vma *, u64 offset, u64 length);
  77. void nouveau_vm_map_sg(struct nouveau_vma *, u64 offset, u64 length,
  78. dma_addr_t *);
  79. /* nv50_vm.c */
  80. void nv50_vm_map_pgt(struct nouveau_gpuobj *pgd, u32 pde,
  81. struct nouveau_gpuobj *pgt[2]);
  82. void nv50_vm_map(struct nouveau_vma *, struct nouveau_gpuobj *,
  83. struct nouveau_vram *, u32 pte, u32 cnt, u64 phys);
  84. void nv50_vm_map_sg(struct nouveau_vma *, struct nouveau_gpuobj *,
  85. u32 pte, dma_addr_t *, u32 cnt);
  86. void nv50_vm_unmap(struct nouveau_gpuobj *, u32 pte, u32 cnt);
  87. void nv50_vm_flush(struct nouveau_vm *);
  88. void nv50_vm_flush_engine(struct drm_device *, int engine);
  89. /* nvc0_vm.c */
  90. void nvc0_vm_map_pgt(struct nouveau_gpuobj *pgd, u32 pde,
  91. struct nouveau_gpuobj *pgt[2]);
  92. void nvc0_vm_map(struct nouveau_vma *, struct nouveau_gpuobj *,
  93. struct nouveau_vram *, u32 pte, u32 cnt, u64 phys);
  94. void nvc0_vm_map_sg(struct nouveau_vma *, struct nouveau_gpuobj *,
  95. u32 pte, dma_addr_t *, u32 cnt);
  96. void nvc0_vm_unmap(struct nouveau_gpuobj *, u32 pte, u32 cnt);
  97. void nvc0_vm_flush(struct nouveau_vm *);
  98. #endif