]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmgf100.c
2 * Copyright 2017 Red Hat Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
24 #include <subdev/fb.h>
26 const struct nvkm_vmm_desc_func
30 const struct nvkm_vmm_desc_func
34 static const struct nvkm_vmm_desc
35 gf100_vmm_desc_17_12
[] = {
36 { SPT
, 15, 8, 0x1000, &gf100_vmm_pgt
},
37 { PGD
, 13, 8, 0x1000, &gf100_vmm_pgd
},
41 static const struct nvkm_vmm_desc
42 gf100_vmm_desc_17_17
[] = {
43 { LPT
, 10, 8, 0x1000, &gf100_vmm_pgt
},
44 { PGD
, 13, 8, 0x1000, &gf100_vmm_pgd
},
48 static const struct nvkm_vmm_desc
49 gf100_vmm_desc_16_12
[] = {
50 { SPT
, 14, 8, 0x1000, &gf100_vmm_pgt
},
51 { PGD
, 14, 8, 0x1000, &gf100_vmm_pgd
},
55 static const struct nvkm_vmm_desc
56 gf100_vmm_desc_16_16
[] = {
57 { LPT
, 10, 8, 0x1000, &gf100_vmm_pgt
},
58 { PGD
, 14, 8, 0x1000, &gf100_vmm_pgd
},
63 gf100_vmm_part(struct nvkm_vmm
*vmm
, struct nvkm_memory
*inst
)
65 nvkm_fo64(inst
, 0x0200, 0x00000000, 2);
69 gf100_vmm_join_(struct nvkm_vmm
*vmm
, struct nvkm_memory
*inst
, u64 base
)
71 struct nvkm_mmu_pt
*pd
= vmm
->pd
->pt
[0];
73 switch (nvkm_memory_target(pd
->memory
)) {
74 case NVKM_MEM_TARGET_VRAM
: base
|= 0ULL << 0; break;
75 case NVKM_MEM_TARGET_HOST
: base
|= 2ULL << 0;
76 base
|= BIT_ULL(2) /* VOL. */;
78 case NVKM_MEM_TARGET_NCOH
: base
|= 3ULL << 0; break;
86 nvkm_wo64(inst
, 0x0200, base
);
87 nvkm_wo64(inst
, 0x0208, vmm
->limit
- 1);
93 gf100_vmm_join(struct nvkm_vmm
*vmm
, struct nvkm_memory
*inst
)
95 return gf100_vmm_join_(vmm
, inst
, 0);
98 static const struct nvkm_vmm_func
100 .join
= gf100_vmm_join
,
101 .part
= gf100_vmm_part
,
103 { 17, &gf100_vmm_desc_17_17
[0], NVKM_VMM_PAGE_xVxC
},
104 { 12, &gf100_vmm_desc_17_12
[0], NVKM_VMM_PAGE_xVHx
},
109 static const struct nvkm_vmm_func
111 .join
= gf100_vmm_join
,
112 .part
= gf100_vmm_part
,
114 { 16, &gf100_vmm_desc_16_16
[0], NVKM_VMM_PAGE_xVxC
},
115 { 12, &gf100_vmm_desc_16_12
[0], NVKM_VMM_PAGE_xVHx
},
121 gf100_vmm_new_(const struct nvkm_vmm_func
*func_16
,
122 const struct nvkm_vmm_func
*func_17
,
123 struct nvkm_mmu
*mmu
, u64 addr
, u64 size
, void *argv
, u32 argc
,
124 struct lock_class_key
*key
, const char *name
,
125 struct nvkm_vmm
**pvmm
)
127 switch (mmu
->subdev
.device
->fb
->page
) {
128 case 16: return nv04_vmm_new_(func_16
, mmu
, 0, addr
, size
,
129 argv
, argc
, key
, name
, pvmm
);
130 case 17: return nv04_vmm_new_(func_17
, mmu
, 0, addr
, size
,
131 argv
, argc
, key
, name
, pvmm
);
139 gf100_vmm_new(struct nvkm_mmu
*mmu
, u64 addr
, u64 size
, void *argv
, u32 argc
,
140 struct lock_class_key
*key
, const char *name
,
141 struct nvkm_vmm
**pvmm
)
143 return gf100_vmm_new_(&gf100_vmm_16
, &gf100_vmm_17
, mmu
, addr
,
144 size
, argv
, argc
, key
, name
, pvmm
);