embox

Форк
0
/
etnaviv_mmu.c 
72 строки · 1.9 Кб
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

17
#include <etnaviv_xml/common.xml.h>
18

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"
25

26
int etnaviv_iommu_init(struct etnaviv_gpu *gpu) {
27
	struct etnaviv_iommu *mmu = &gpu->mmu;
28

29
	memset(mmu, 0, sizeof(*mmu));
30

31
	if (!(gpu->identity.minor_features1 & chipMinorFeatures1_MMU_VERSION)) {
32
		etnaviv_iommuv1_domain_init(gpu);
33
		mmu->version = ETNAVIV_IOMMU_V1;
34
	} else {
35
		etnaviv_iommuv2_domain_init(gpu);
36
		mmu->version = ETNAVIV_IOMMU_V2;
37
	}
38

39
	return 0;
40
}
41

42
void etnaviv_iommu_restore(struct etnaviv_gpu *gpu) {
43
	if (gpu->mmu.version == ETNAVIV_IOMMU_V1) {
44
		etnaviv_iommuv1_restore(gpu);
45
	} else {
46
		etnaviv_iommuv2_restore(gpu);
47
	}
48
}
49

50
extern struct etnaviv_iommu_ops etnaviv_iommu_ops;
51
int etnaviv_iommu_get_suballoc_va(struct etnaviv_gpu *gpu, dma_addr_t paddr,
52
				size_t size,
53
				  uint32_t *iova) {
54
	struct etnaviv_iommu *mmu = &gpu->mmu;
55

56
	if (mmu->version == ETNAVIV_IOMMU_V1) {
57
		*iova = paddr - gpu->memory_base;
58
		return 0;
59
	} else {
60
		int ret;
61

62
		ret = etnaviv_iommu_ops.ops.map((void*)mmu->domain, mmu->last_iova, paddr, size, IOMMU_READ);
63
		if (ret < 0) {
64
			return ret;
65
		}
66
		*iova = mmu->last_iova;
67
		mmu->last_iova = mmu->last_iova + size;
68
		mmu->need_flush = true;
69

70
		return 0;
71
	}
72
}
73

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.