etnaviv_mmu.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2015 Etnaviv Project
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License version 2 as published by
  6. * the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef __ETNAVIV_MMU_H__
  17. #define __ETNAVIV_MMU_H__
  18. #include <linux/iommu.h>
  19. enum etnaviv_iommu_version {
  20. ETNAVIV_IOMMU_V1 = 0,
  21. ETNAVIV_IOMMU_V2,
  22. };
  23. struct etnaviv_gpu;
  24. struct etnaviv_vram_mapping;
  25. struct etnaviv_iommu_ops {
  26. struct iommu_ops ops;
  27. size_t (*dump_size)(struct iommu_domain *);
  28. void (*dump)(struct iommu_domain *, void *);
  29. };
  30. struct etnaviv_iommu {
  31. struct etnaviv_gpu *gpu;
  32. struct iommu_domain *domain;
  33. enum etnaviv_iommu_version version;
  34. /* memory manager for GPU address area */
  35. struct mutex lock;
  36. struct list_head mappings;
  37. struct drm_mm mm;
  38. u32 last_iova;
  39. bool need_flush;
  40. };
  41. struct etnaviv_gem_object;
  42. int etnaviv_iommu_attach(struct etnaviv_iommu *iommu, const char **names,
  43. int cnt);
  44. int etnaviv_iommu_map(struct etnaviv_iommu *iommu, u32 iova,
  45. struct sg_table *sgt, unsigned len, int prot);
  46. int etnaviv_iommu_unmap(struct etnaviv_iommu *iommu, u32 iova,
  47. struct sg_table *sgt, unsigned len);
  48. int etnaviv_iommu_map_gem(struct etnaviv_iommu *mmu,
  49. struct etnaviv_gem_object *etnaviv_obj, u32 memory_base,
  50. struct etnaviv_vram_mapping *mapping);
  51. void etnaviv_iommu_unmap_gem(struct etnaviv_iommu *mmu,
  52. struct etnaviv_vram_mapping *mapping);
  53. void etnaviv_iommu_destroy(struct etnaviv_iommu *iommu);
  54. u32 etnaviv_iommu_get_cmdbuf_va(struct etnaviv_gpu *gpu,
  55. struct etnaviv_cmdbuf *buf);
  56. void etnaviv_iommu_put_cmdbuf_va(struct etnaviv_gpu *gpu,
  57. struct etnaviv_cmdbuf *buf);
  58. size_t etnaviv_iommu_dump_size(struct etnaviv_iommu *iommu);
  59. void etnaviv_iommu_dump(struct etnaviv_iommu *iommu, void *buf);
  60. struct etnaviv_iommu *etnaviv_iommu_new(struct etnaviv_gpu *gpu);
  61. void etnaviv_iommu_restore(struct etnaviv_gpu *gpu);
  62. #endif /* __ETNAVIV_MMU_H__ */