aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_vm.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_vm.h')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_vm.h107
1 files changed, 107 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_vm.h b/drivers/gpu/drm/nouveau/nouveau_vm.h
new file mode 100644
index 000000000000..b6755cfa7b71
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nouveau_vm.h
@@ -0,0 +1,107 @@
1/*
2 * Copyright 2010 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs
23 */
24
25#ifndef __NOUVEAU_VM_H__
26#define __NOUVEAU_VM_H__
27
28#include "drmP.h"
29
30#include "nouveau_drv.h"
31#include "nouveau_mm.h"
32
33struct nouveau_vm_pgt {
34 struct nouveau_gpuobj *obj;
35 u32 page_shift;
36 u32 refcount;
37};
38
39struct nouveau_vm_pgd {
40 struct list_head head;
41 struct nouveau_gpuobj *obj;
42};
43
44struct nouveau_vma {
45 struct nouveau_vm *vm;
46 struct nouveau_mm_node *node;
47 u64 offset;
48 u32 access;
49};
50
51struct nouveau_vm {
52 struct drm_device *dev;
53 struct nouveau_mm *mm;
54 int refcount;
55
56 struct list_head pgd_list;
57 atomic_t pgraph_refs;
58 atomic_t pcrypt_refs;
59
60 struct nouveau_vm_pgt *pgt;
61 u32 fpde;
62 u32 lpde;
63
64 u32 pgt_bits;
65 u8 spg_shift;
66 u8 lpg_shift;
67
68 void (*map_pgt)(struct nouveau_gpuobj *pgd, u32 type, u32 pde,
69 struct nouveau_gpuobj *pgt);
70 void (*unmap_pgt)(struct nouveau_gpuobj *pgd, u32 pde);
71 void (*map)(struct nouveau_vma *, struct nouveau_gpuobj *,
72 struct nouveau_vram *, u32 pte, u32 cnt, u64 phys);
73 void (*map_sg)(struct nouveau_vma *, struct nouveau_gpuobj *,
74 u32 pte, dma_addr_t *, u32 cnt);
75 void (*unmap)(struct nouveau_gpuobj *pgt, u32 pte, u32 cnt);
76 void (*flush)(struct nouveau_vm *);
77};
78
79/* nouveau_vm.c */
80int nouveau_vm_new(struct drm_device *, u64 offset, u64 length, u64 mm_offset,
81 u8 pgt_bits, u8 spg_shift, u8 lpg_shift,
82 struct nouveau_vm **);
83int nouveau_vm_ref(struct nouveau_vm *, struct nouveau_vm **,
84 struct nouveau_gpuobj *pgd);
85int nouveau_vm_get(struct nouveau_vm *, u64 size, u32 page_shift,
86 u32 access, struct nouveau_vma *);
87void nouveau_vm_put(struct nouveau_vma *);
88void nouveau_vm_map(struct nouveau_vma *, struct nouveau_vram *);
89void nouveau_vm_map_at(struct nouveau_vma *, u64 offset, struct nouveau_vram *);
90void nouveau_vm_unmap(struct nouveau_vma *);
91void nouveau_vm_unmap_at(struct nouveau_vma *, u64 offset, u64 length);
92void nouveau_vm_map_sg(struct nouveau_vma *, u64 offset, u64 length,
93 dma_addr_t *);
94
95/* nv50_vm.c */
96void nv50_vm_map_pgt(struct nouveau_gpuobj *pgd, u32 type, u32 pde,
97 struct nouveau_gpuobj *pgt);
98void nv50_vm_unmap_pgt(struct nouveau_gpuobj *pgd, u32 pde);
99void nv50_vm_map(struct nouveau_vma *, struct nouveau_gpuobj *,
100 struct nouveau_vram *, u32 pte, u32 cnt, u64 phys);
101void nv50_vm_map_sg(struct nouveau_vma *, struct nouveau_gpuobj *,
102 u32 pte, dma_addr_t *, u32 cnt);
103void nv50_vm_unmap(struct nouveau_gpuobj *, u32 pte, u32 cnt);
104void nv50_vm_flush(struct nouveau_vm *);
105void nv50_vm_flush_engine(struct drm_device *, int engine);
106
107#endif