Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.1.
 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#ifndef __ETNAVIV_MMU_H__
18#define __ETNAVIV_MMU_H__
19
20#define ETNAVIV_PROT_READ	(1 << 0)
21#define ETNAVIV_PROT_WRITE	(1 << 1)
22
23enum etnaviv_iommu_version {
24	ETNAVIV_IOMMU_V1 = 0,
25	ETNAVIV_IOMMU_V2,
26};
27
28struct etnaviv_gpu;
29struct etnaviv_vram_mapping;
30struct etnaviv_iommu_domain;
31
32struct etnaviv_iommu_domain_ops {
33	void (*free)(struct etnaviv_iommu_domain *);
34	int (*map)(struct etnaviv_iommu_domain *domain, unsigned long iova,
35		   phys_addr_t paddr, size_t size, int prot);
36	size_t (*unmap)(struct etnaviv_iommu_domain *domain, unsigned long iova,
37			size_t size);
38	size_t (*dump_size)(struct etnaviv_iommu_domain *);
39	void (*dump)(struct etnaviv_iommu_domain *, void *);
40};
41
42struct etnaviv_iommu_domain {
43	struct device *dev;
44	void *bad_page_cpu;
45	dma_addr_t bad_page_dma;
46	u64 base;
47	u64 size;
48
49	const struct etnaviv_iommu_domain_ops *ops;
50};
51
52struct etnaviv_iommu {
53	struct etnaviv_gpu *gpu;
54	struct etnaviv_iommu_domain *domain;
55
56	enum etnaviv_iommu_version version;
57
58	/* memory manager for GPU address area */
59	struct mutex lock;
60	struct list_head mappings;
61	struct drm_mm mm;
62	u32 last_iova;
63	bool need_flush;
64};
65
66struct etnaviv_gem_object;
67
68int etnaviv_iommu_map_gem(struct etnaviv_iommu *mmu,
69	struct etnaviv_gem_object *etnaviv_obj, u32 memory_base,
70	struct etnaviv_vram_mapping *mapping);
71void etnaviv_iommu_unmap_gem(struct etnaviv_iommu *mmu,
72	struct etnaviv_vram_mapping *mapping);
73
74int etnaviv_iommu_get_suballoc_va(struct etnaviv_gpu *gpu, dma_addr_t paddr,
75				  struct drm_mm_node *vram_node, size_t size,
76				  u32 *iova);
77void etnaviv_iommu_put_suballoc_va(struct etnaviv_gpu *gpu,
78				   struct drm_mm_node *vram_node, size_t size,
79				   u32 iova);
80
81size_t etnaviv_iommu_dump_size(struct etnaviv_iommu *iommu);
82void etnaviv_iommu_dump(struct etnaviv_iommu *iommu, void *buf);
83
84struct etnaviv_iommu *etnaviv_iommu_new(struct etnaviv_gpu *gpu);
85void etnaviv_iommu_destroy(struct etnaviv_iommu *iommu);
86void etnaviv_iommu_restore(struct etnaviv_gpu *gpu);
87
88#endif /* __ETNAVIV_MMU_H__ */