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,
nvkm_gpuobj_del(&bar->bar[1].pgd);
nvkm_memory_unref(&bar->bar[1].mem);
- if (bar->bar[0].vm) {
- nvkm_memory_unref(&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_unref(&bar->bar[0].mem);
return bar;
nvkm_gpuobj_del(&bar->bar1);
nvkm_vm_ref(NULL, &bar->bar1_vm, bar->pgd);
nvkm_gpuobj_del(&bar->bar2);
- if (bar->bar2_vm) {
- nvkm_memory_unref(&bar->bar2_vm->pgt[0].mem[0]);
- nvkm_vm_ref(NULL, &bar->bar2_vm, bar->pgd);
- }
+ nvkm_vm_ref(NULL, &bar->bar2_vm, bar->pgd);
nvkm_gpuobj_del(&bar->pgd);
nvkm_gpuobj_del(&bar->pad);
nvkm_gpuobj_del(&bar->mem);
vm->pgt[0].refcount[0] = 1;
vm->pgt[0].mem[0] = pgt;
nvkm_memory_boot(pgt, vm);
+ vm->bootstrapped = true;
}
return ret;
}
if (*ptr) {
+ if ((*ptr)->bootstrapped && pgd)
+ nvkm_memory_unref(&(*ptr)->pgt[0].mem[0]);
nvkm_vm_unlink(*ptr, pgd);
kref_put(&(*ptr)->refcount, nvkm_vm_del);
}