mmu.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef __NVKM_MMU_H__
  2. #define __NVKM_MMU_H__
  3. #include <core/subdev.h>
  4. #include <core/mm.h>
  5. struct nvkm_device;
  6. struct nvkm_mem;
  7. struct nvkm_vm_pgt {
  8. struct nvkm_memory *mem[2];
  9. u32 refcount[2];
  10. };
  11. struct nvkm_vm_pgd {
  12. struct list_head head;
  13. struct nvkm_gpuobj *obj;
  14. };
  15. struct nvkm_vma {
  16. struct list_head head;
  17. int refcount;
  18. struct nvkm_vm *vm;
  19. struct nvkm_mm_node *node;
  20. u64 offset;
  21. u32 access;
  22. };
  23. struct nvkm_vm {
  24. struct nvkm_mmu *mmu;
  25. struct mutex mutex;
  26. struct nvkm_mm mm;
  27. struct kref refcount;
  28. struct list_head pgd_list;
  29. atomic_t engref[NVKM_SUBDEV_NR];
  30. struct nvkm_vm_pgt *pgt;
  31. u32 fpde;
  32. u32 lpde;
  33. };
  34. int nvkm_vm_new(struct nvkm_device *, u64 offset, u64 length, u64 mm_offset,
  35. struct lock_class_key *, struct nvkm_vm **);
  36. int nvkm_vm_ref(struct nvkm_vm *, struct nvkm_vm **, struct nvkm_gpuobj *pgd);
  37. int nvkm_vm_boot(struct nvkm_vm *, u64 size);
  38. int nvkm_vm_get(struct nvkm_vm *, u64 size, u32 page_shift, u32 access,
  39. struct nvkm_vma *);
  40. void nvkm_vm_put(struct nvkm_vma *);
  41. void nvkm_vm_map(struct nvkm_vma *, struct nvkm_mem *);
  42. void nvkm_vm_map_at(struct nvkm_vma *, u64 offset, struct nvkm_mem *);
  43. void nvkm_vm_unmap(struct nvkm_vma *);
  44. void nvkm_vm_unmap_at(struct nvkm_vma *, u64 offset, u64 length);
  45. struct nvkm_mmu {
  46. const struct nvkm_mmu_func *func;
  47. struct nvkm_subdev subdev;
  48. u64 limit;
  49. u8 dma_bits;
  50. u8 lpg_shift;
  51. };
  52. int nv04_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
  53. int nv41_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
  54. int nv44_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
  55. int nv50_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
  56. int gf100_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **);
  57. #endif