17
#include <etnaviv_xml/common.xml.h>
19
#include "etnaviv_cmdbuf.h"
20
#include "etnaviv_drv.h"
21
#include "etnaviv_gem.h"
22
#include "etnaviv_gpu.h"
23
#include "etnaviv_iommu.h"
24
#include "etnaviv_mmu.h"
26
int etnaviv_iommu_init(struct etnaviv_gpu *gpu) {
27
struct etnaviv_iommu *mmu = &gpu->mmu;
29
memset(mmu, 0, sizeof(*mmu));
31
if (!(gpu->identity.minor_features1 & chipMinorFeatures1_MMU_VERSION)) {
32
etnaviv_iommuv1_domain_init(gpu);
33
mmu->version = ETNAVIV_IOMMU_V1;
35
etnaviv_iommuv2_domain_init(gpu);
36
mmu->version = ETNAVIV_IOMMU_V2;
42
void etnaviv_iommu_restore(struct etnaviv_gpu *gpu) {
43
if (gpu->mmu.version == ETNAVIV_IOMMU_V1) {
44
etnaviv_iommuv1_restore(gpu);
46
etnaviv_iommuv2_restore(gpu);
50
extern struct etnaviv_iommu_ops etnaviv_iommu_ops;
51
int etnaviv_iommu_get_suballoc_va(struct etnaviv_gpu *gpu, dma_addr_t paddr,
54
struct etnaviv_iommu *mmu = &gpu->mmu;
56
if (mmu->version == ETNAVIV_IOMMU_V1) {
57
*iova = paddr - gpu->memory_base;
62
ret = etnaviv_iommu_ops.ops.map((void*)mmu->domain, mmu->last_iova, paddr, size, IOMMU_READ);
66
*iova = mmu->last_iova;
67
mmu->last_iova = mmu->last_iova + size;
68
mmu->need_flush = true;