summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2016-05-06 15:33:12 +1000
committerJérôme Glisse <jglisse@redhat.com>2017-08-09 18:13:31 -0400
commit53db2fd5d053637b0f965d216e33b6f4b1210280 (patch)
treedce2dc29d0b4c0ca938598112e1ee5c4629b26f2
parentd604a791039558aebaa6106d932a491db7c59895 (diff)
mmu: automatically handle "un-bootstrapping" of vmm
Removes the need to expose internals outside of MMU. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h2
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/bar/nv50.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c3
4 files changed, 7 insertions, 8 deletions
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
index dcd3deff27a4..cdae55400d80 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/mmu.h
@@ -37,6 +37,8 @@ struct nvkm_vm {
struct nvkm_vm_pgt *pgt;
u32 fpde;
u32 lpde;
+
+ bool bootstrapped;
};
int nvkm_vm_new(struct nvkm_device *, u64 offset, u64 length, u64 mm_offset,
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c
index 6d8f21290aa2..c8bb73b5370b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c
@@ -144,10 +144,7 @@ gf100_bar_dtor(struct nvkm_bar *base)
nvkm_gpuobj_del(&bar->bar[1].pgd);
nvkm_memory_del(&bar->bar[1].mem);
- if (bar->bar[0].vm) {
- nvkm_memory_del(&bar->bar[0].vm->pgt[0].mem[0]);
- nvkm_vm_ref(NULL, &bar->bar[0].vm, bar->bar[0].pgd);
- }
+ nvkm_vm_ref(NULL, &bar->bar[0].vm, bar->bar[0].pgd);
nvkm_gpuobj_del(&bar->bar[0].pgd);
nvkm_memory_del(&bar->bar[0].mem);
return bar;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bar/nv50.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bar/nv50.c
index 6eff637ac301..acdbcf6bcb12 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bar/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bar/nv50.c
@@ -176,10 +176,7 @@ nv50_bar_dtor(struct nvkm_bar *base)
nvkm_gpuobj_del(&bar->bar1);
nvkm_vm_ref(NULL, &bar->bar1_vm, bar->pgd);
nvkm_gpuobj_del(&bar->bar3);
- if (bar->bar3_vm) {
- nvkm_memory_del(&bar->bar3_vm->pgt[0].mem[0]);
- nvkm_vm_ref(NULL, &bar->bar3_vm, bar->pgd);
- }
+ nvkm_vm_ref(NULL, &bar->bar3_vm, bar->pgd);
nvkm_gpuobj_del(&bar->pgd);
nvkm_gpuobj_del(&bar->pad);
nvkm_gpuobj_del(&bar->mem);
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
index d06ad2c372bf..37f45ade7ef1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
@@ -355,6 +355,7 @@ nvkm_vm_boot(struct nvkm_vm *vm, u64 size)
vm->pgt[0].refcount[0] = 1;
vm->pgt[0].mem[0] = pgt;
nvkm_memory_boot(pgt, vm);
+ vm->bootstrapped = true;
}
return ret;
@@ -479,6 +480,8 @@ nvkm_vm_ref(struct nvkm_vm *ref, struct nvkm_vm **ptr, struct nvkm_gpuobj *pgd)
}
if (*ptr) {
+ if ((*ptr)->bootstrapped && pgd)
+ nvkm_memory_del(&(*ptr)->pgt[0].mem[0]);
nvkm_vm_unlink(*ptr, pgd);
kref_put(&(*ptr)->refcount, nvkm_vm_del);
}