diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2018-01-18 19:34:56 -0500 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2018-01-18 20:35:44 -0500 |
commit | 2ffa64eba94fc8cc23d431cbec7365f3f07ff0ae (patch) | |
tree | 95bf9b17ad19ed3b502c5b3f282441cc0d09cecb | |
parent | e062a01e6daa2555ed13cf3f4e8cd3a05bbe474c (diff) |
drm/nouveau/mmu/mcp77: fix regressions in stolen memory handling
- Fixes addition of stolen memory base address to PTEs.
- Removes support for compression.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Tested-by: Pierre Moreau <pierre.morrow@free.fr>
-rw-r--r-- | drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/engine/device/base.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mcp77.c | 41 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.h | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmmcp77.c | 45 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv50.c | 16 |
7 files changed, 109 insertions, 10 deletions
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h index 975c42f620a0..542b7095b026 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h | |||
@@ -120,6 +120,7 @@ int nv41_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **); | |||
120 | int nv44_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **); | 120 | int nv44_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **); |
121 | int nv50_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **); | 121 | int nv50_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **); |
122 | int g84_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **); | 122 | int g84_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **); |
123 | int mcp77_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **); | ||
123 | int gf100_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **); | 124 | int gf100_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **); |
124 | int gk104_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **); | 125 | int gk104_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **); |
125 | int gk20a_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **); | 126 | int gk20a_mmu_new(struct nvkm_device *, int, struct nvkm_mmu **); |
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c index 00eeaaffeae5..08e77cd55e6e 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c | |||
@@ -1251,7 +1251,7 @@ nvaa_chipset = { | |||
1251 | .i2c = g94_i2c_new, | 1251 | .i2c = g94_i2c_new, |
1252 | .imem = nv50_instmem_new, | 1252 | .imem = nv50_instmem_new, |
1253 | .mc = g98_mc_new, | 1253 | .mc = g98_mc_new, |
1254 | .mmu = g84_mmu_new, | 1254 | .mmu = mcp77_mmu_new, |
1255 | .mxm = nv50_mxm_new, | 1255 | .mxm = nv50_mxm_new, |
1256 | .pci = g94_pci_new, | 1256 | .pci = g94_pci_new, |
1257 | .therm = g84_therm_new, | 1257 | .therm = g84_therm_new, |
@@ -1283,7 +1283,7 @@ nvac_chipset = { | |||
1283 | .i2c = g94_i2c_new, | 1283 | .i2c = g94_i2c_new, |
1284 | .imem = nv50_instmem_new, | 1284 | .imem = nv50_instmem_new, |
1285 | .mc = g98_mc_new, | 1285 | .mc = g98_mc_new, |
1286 | .mmu = g84_mmu_new, | 1286 | .mmu = mcp77_mmu_new, |
1287 | .mxm = nv50_mxm_new, | 1287 | .mxm = nv50_mxm_new, |
1288 | .pci = g94_pci_new, | 1288 | .pci = g94_pci_new, |
1289 | .therm = g84_therm_new, | 1289 | .therm = g84_therm_new, |
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild index 352a65f9371c..67ee983bb026 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/Kbuild | |||
@@ -4,6 +4,7 @@ nvkm-y += nvkm/subdev/mmu/nv41.o | |||
4 | nvkm-y += nvkm/subdev/mmu/nv44.o | 4 | nvkm-y += nvkm/subdev/mmu/nv44.o |
5 | nvkm-y += nvkm/subdev/mmu/nv50.o | 5 | nvkm-y += nvkm/subdev/mmu/nv50.o |
6 | nvkm-y += nvkm/subdev/mmu/g84.o | 6 | nvkm-y += nvkm/subdev/mmu/g84.o |
7 | nvkm-y += nvkm/subdev/mmu/mcp77.o | ||
7 | nvkm-y += nvkm/subdev/mmu/gf100.o | 8 | nvkm-y += nvkm/subdev/mmu/gf100.o |
8 | nvkm-y += nvkm/subdev/mmu/gk104.o | 9 | nvkm-y += nvkm/subdev/mmu/gk104.o |
9 | nvkm-y += nvkm/subdev/mmu/gk20a.o | 10 | nvkm-y += nvkm/subdev/mmu/gk20a.o |
@@ -22,6 +23,7 @@ nvkm-y += nvkm/subdev/mmu/vmmnv04.o | |||
22 | nvkm-y += nvkm/subdev/mmu/vmmnv41.o | 23 | nvkm-y += nvkm/subdev/mmu/vmmnv41.o |
23 | nvkm-y += nvkm/subdev/mmu/vmmnv44.o | 24 | nvkm-y += nvkm/subdev/mmu/vmmnv44.o |
24 | nvkm-y += nvkm/subdev/mmu/vmmnv50.o | 25 | nvkm-y += nvkm/subdev/mmu/vmmnv50.o |
26 | nvkm-y += nvkm/subdev/mmu/vmmmcp77.o | ||
25 | nvkm-y += nvkm/subdev/mmu/vmmgf100.o | 27 | nvkm-y += nvkm/subdev/mmu/vmmgf100.o |
26 | nvkm-y += nvkm/subdev/mmu/vmmgk104.o | 28 | nvkm-y += nvkm/subdev/mmu/vmmgk104.o |
27 | nvkm-y += nvkm/subdev/mmu/vmmgk20a.o | 29 | nvkm-y += nvkm/subdev/mmu/vmmgk20a.o |
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mcp77.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mcp77.c new file mode 100644 index 000000000000..0527b50730d9 --- /dev/null +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mcp77.c | |||
@@ -0,0 +1,41 @@ | |||
1 | /* | ||
2 | * Copyright 2017 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 | #include "mem.h" | ||
23 | #include "vmm.h" | ||
24 | |||
25 | #include <nvif/class.h> | ||
26 | |||
27 | static const struct nvkm_mmu_func | ||
28 | mcp77_mmu = { | ||
29 | .dma_bits = 40, | ||
30 | .mmu = {{ -1, -1, NVIF_CLASS_MMU_NV50}}, | ||
31 | .mem = {{ -1, 0, NVIF_CLASS_MEM_NV50}, nv50_mem_new, nv50_mem_map }, | ||
32 | .vmm = {{ -1, -1, NVIF_CLASS_VMM_NV50}, mcp77_vmm_new, false, 0x0200 }, | ||
33 | .kind = nv50_mmu_kind, | ||
34 | .kind_sys = true, | ||
35 | }; | ||
36 | |||
37 | int | ||
38 | mcp77_mmu_new(struct nvkm_device *device, int index, struct nvkm_mmu **pmmu) | ||
39 | { | ||
40 | return nvkm_mmu_new_(&mcp77_mmu, device, index, pmmu); | ||
41 | } | ||
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.h b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.h index 6d8f61ea467a..da06e64d8a7d 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.h +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.h | |||
@@ -95,6 +95,9 @@ struct nvkm_vmm_desc { | |||
95 | const struct nvkm_vmm_desc_func *func; | 95 | const struct nvkm_vmm_desc_func *func; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | extern const struct nvkm_vmm_desc nv50_vmm_desc_12[]; | ||
99 | extern const struct nvkm_vmm_desc nv50_vmm_desc_16[]; | ||
100 | |||
98 | extern const struct nvkm_vmm_desc gk104_vmm_desc_16_12[]; | 101 | extern const struct nvkm_vmm_desc gk104_vmm_desc_16_12[]; |
99 | extern const struct nvkm_vmm_desc gk104_vmm_desc_16_16[]; | 102 | extern const struct nvkm_vmm_desc gk104_vmm_desc_16_16[]; |
100 | extern const struct nvkm_vmm_desc gk104_vmm_desc_17_12[]; | 103 | extern const struct nvkm_vmm_desc gk104_vmm_desc_17_12[]; |
@@ -169,6 +172,11 @@ int nv04_vmm_new_(const struct nvkm_vmm_func *, struct nvkm_mmu *, u32, | |||
169 | const char *, struct nvkm_vmm **); | 172 | const char *, struct nvkm_vmm **); |
170 | int nv04_vmm_valid(struct nvkm_vmm *, void *, u32, struct nvkm_vmm_map *); | 173 | int nv04_vmm_valid(struct nvkm_vmm *, void *, u32, struct nvkm_vmm_map *); |
171 | 174 | ||
175 | int nv50_vmm_join(struct nvkm_vmm *, struct nvkm_memory *); | ||
176 | void nv50_vmm_part(struct nvkm_vmm *, struct nvkm_memory *); | ||
177 | int nv50_vmm_valid(struct nvkm_vmm *, void *, u32, struct nvkm_vmm_map *); | ||
178 | void nv50_vmm_flush(struct nvkm_vmm *, int); | ||
179 | |||
172 | int gf100_vmm_new_(const struct nvkm_vmm_func *, const struct nvkm_vmm_func *, | 180 | int gf100_vmm_new_(const struct nvkm_vmm_func *, const struct nvkm_vmm_func *, |
173 | struct nvkm_mmu *, u64, u64, void *, u32, | 181 | struct nvkm_mmu *, u64, u64, void *, u32, |
174 | struct lock_class_key *, const char *, struct nvkm_vmm **); | 182 | struct lock_class_key *, const char *, struct nvkm_vmm **); |
@@ -200,6 +208,8 @@ int nv44_vmm_new(struct nvkm_mmu *, u64, u64, void *, u32, | |||
200 | struct lock_class_key *, const char *, struct nvkm_vmm **); | 208 | struct lock_class_key *, const char *, struct nvkm_vmm **); |
201 | int nv50_vmm_new(struct nvkm_mmu *, u64, u64, void *, u32, | 209 | int nv50_vmm_new(struct nvkm_mmu *, u64, u64, void *, u32, |
202 | struct lock_class_key *, const char *, struct nvkm_vmm **); | 210 | struct lock_class_key *, const char *, struct nvkm_vmm **); |
211 | int mcp77_vmm_new(struct nvkm_mmu *, u64, u64, void *, u32, | ||
212 | struct lock_class_key *, const char *, struct nvkm_vmm **); | ||
203 | int g84_vmm_new(struct nvkm_mmu *, u64, u64, void *, u32, | 213 | int g84_vmm_new(struct nvkm_mmu *, u64, u64, void *, u32, |
204 | struct lock_class_key *, const char *, struct nvkm_vmm **); | 214 | struct lock_class_key *, const char *, struct nvkm_vmm **); |
205 | int gf100_vmm_new(struct nvkm_mmu *, u64, u64, void *, u32, | 215 | int gf100_vmm_new(struct nvkm_mmu *, u64, u64, void *, u32, |
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmmcp77.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmmcp77.c new file mode 100644 index 000000000000..e63d984cbfd4 --- /dev/null +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmmcp77.c | |||
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | * Copyright 2017 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 | #include "vmm.h" | ||
23 | |||
24 | static const struct nvkm_vmm_func | ||
25 | mcp77_vmm = { | ||
26 | .join = nv50_vmm_join, | ||
27 | .part = nv50_vmm_part, | ||
28 | .valid = nv50_vmm_valid, | ||
29 | .flush = nv50_vmm_flush, | ||
30 | .page_block = 1 << 29, | ||
31 | .page = { | ||
32 | { 16, &nv50_vmm_desc_16[0], NVKM_VMM_PAGE_xVxx }, | ||
33 | { 12, &nv50_vmm_desc_12[0], NVKM_VMM_PAGE_xVHx }, | ||
34 | {} | ||
35 | } | ||
36 | }; | ||
37 | |||
38 | int | ||
39 | mcp77_vmm_new(struct nvkm_mmu *mmu, u64 addr, u64 size, void *argv, u32 argc, | ||
40 | struct lock_class_key *key, const char *name, | ||
41 | struct nvkm_vmm **pvmm) | ||
42 | { | ||
43 | return nv04_vmm_new_(&mcp77_vmm, mmu, 0, addr, size, | ||
44 | argv, argc, key, name, pvmm); | ||
45 | } | ||
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv50.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv50.c index 863a2edd9861..64f75d906202 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv50.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmmnv50.c | |||
@@ -32,7 +32,7 @@ static inline void | |||
32 | nv50_vmm_pgt_pte(struct nvkm_vmm *vmm, struct nvkm_mmu_pt *pt, | 32 | nv50_vmm_pgt_pte(struct nvkm_vmm *vmm, struct nvkm_mmu_pt *pt, |
33 | u32 ptei, u32 ptes, struct nvkm_vmm_map *map, u64 addr) | 33 | u32 ptei, u32 ptes, struct nvkm_vmm_map *map, u64 addr) |
34 | { | 34 | { |
35 | u64 next = addr | map->type, data; | 35 | u64 next = addr + map->type, data; |
36 | u32 pten; | 36 | u32 pten; |
37 | int log2blk; | 37 | int log2blk; |
38 | 38 | ||
@@ -69,7 +69,7 @@ nv50_vmm_pgt_dma(struct nvkm_vmm *vmm, struct nvkm_mmu_pt *pt, | |||
69 | VMM_SPAM(vmm, "DMAA %08x %08x PTE(s)", ptei, ptes); | 69 | VMM_SPAM(vmm, "DMAA %08x %08x PTE(s)", ptei, ptes); |
70 | nvkm_kmap(pt->memory); | 70 | nvkm_kmap(pt->memory); |
71 | while (ptes--) { | 71 | while (ptes--) { |
72 | const u64 data = *map->dma++ | map->type; | 72 | const u64 data = *map->dma++ + map->type; |
73 | VMM_WO064(pt, vmm, ptei++ * 8, data); | 73 | VMM_WO064(pt, vmm, ptei++ * 8, data); |
74 | map->type += map->ctag; | 74 | map->type += map->ctag; |
75 | } | 75 | } |
@@ -163,21 +163,21 @@ nv50_vmm_pgd = { | |||
163 | .pde = nv50_vmm_pgd_pde, | 163 | .pde = nv50_vmm_pgd_pde, |
164 | }; | 164 | }; |
165 | 165 | ||
166 | static const struct nvkm_vmm_desc | 166 | const struct nvkm_vmm_desc |
167 | nv50_vmm_desc_12[] = { | 167 | nv50_vmm_desc_12[] = { |
168 | { PGT, 17, 8, 0x1000, &nv50_vmm_pgt }, | 168 | { PGT, 17, 8, 0x1000, &nv50_vmm_pgt }, |
169 | { PGD, 11, 0, 0x0000, &nv50_vmm_pgd }, | 169 | { PGD, 11, 0, 0x0000, &nv50_vmm_pgd }, |
170 | {} | 170 | {} |
171 | }; | 171 | }; |
172 | 172 | ||
173 | static const struct nvkm_vmm_desc | 173 | const struct nvkm_vmm_desc |
174 | nv50_vmm_desc_16[] = { | 174 | nv50_vmm_desc_16[] = { |
175 | { PGT, 13, 8, 0x1000, &nv50_vmm_pgt }, | 175 | { PGT, 13, 8, 0x1000, &nv50_vmm_pgt }, |
176 | { PGD, 11, 0, 0x0000, &nv50_vmm_pgd }, | 176 | { PGD, 11, 0, 0x0000, &nv50_vmm_pgd }, |
177 | {} | 177 | {} |
178 | }; | 178 | }; |
179 | 179 | ||
180 | static void | 180 | void |
181 | nv50_vmm_flush(struct nvkm_vmm *vmm, int level) | 181 | nv50_vmm_flush(struct nvkm_vmm *vmm, int level) |
182 | { | 182 | { |
183 | struct nvkm_subdev *subdev = &vmm->mmu->subdev; | 183 | struct nvkm_subdev *subdev = &vmm->mmu->subdev; |
@@ -223,7 +223,7 @@ nv50_vmm_flush(struct nvkm_vmm *vmm, int level) | |||
223 | mutex_unlock(&subdev->mutex); | 223 | mutex_unlock(&subdev->mutex); |
224 | } | 224 | } |
225 | 225 | ||
226 | static int | 226 | int |
227 | nv50_vmm_valid(struct nvkm_vmm *vmm, void *argv, u32 argc, | 227 | nv50_vmm_valid(struct nvkm_vmm *vmm, void *argv, u32 argc, |
228 | struct nvkm_vmm_map *map) | 228 | struct nvkm_vmm_map *map) |
229 | { | 229 | { |
@@ -321,7 +321,7 @@ nv50_vmm_valid(struct nvkm_vmm *vmm, void *argv, u32 argc, | |||
321 | return 0; | 321 | return 0; |
322 | } | 322 | } |
323 | 323 | ||
324 | static void | 324 | void |
325 | nv50_vmm_part(struct nvkm_vmm *vmm, struct nvkm_memory *inst) | 325 | nv50_vmm_part(struct nvkm_vmm *vmm, struct nvkm_memory *inst) |
326 | { | 326 | { |
327 | struct nvkm_vmm_join *join; | 327 | struct nvkm_vmm_join *join; |
@@ -335,7 +335,7 @@ nv50_vmm_part(struct nvkm_vmm *vmm, struct nvkm_memory *inst) | |||
335 | } | 335 | } |
336 | } | 336 | } |
337 | 337 | ||
338 | static int | 338 | int |
339 | nv50_vmm_join(struct nvkm_vmm *vmm, struct nvkm_memory *inst) | 339 | nv50_vmm_join(struct nvkm_vmm *vmm, struct nvkm_memory *inst) |
340 | { | 340 | { |
341 | const u32 pd_offset = vmm->mmu->func->vmm.pd_offset; | 341 | const u32 pd_offset = vmm->mmu->func->vmm.pd_offset; |