summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2021-10-12 18:22:05 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2021-10-12 18:22:05 +0000
commit406aa5410c6cd6073f7fd56d96e23e321a782d84 (patch)
treec6da58ecd20b7d66af6498e85c7d318427d91459 /sys
parentb506776769d4df7495472132b6069e7327cc7886 (diff)
Remove misleading uvm reference counting that isn't actually used.
Make sure uvm_obj_init() is only called once. Call uvm_obj_destroy() when we release the GEM object that wraps an uvm object for which we called uvm_obj_init(). ok mpi@, jsg@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/drm/drm_gem.c3
-rw-r--r--sys/dev/pci/drm/ttm/ttm_bo_vm.c5
2 files changed, 5 insertions, 3 deletions
diff --git a/sys/dev/pci/drm/drm_gem.c b/sys/dev/pci/drm/drm_gem.c
index 460bab4e807..79598398bf7 100644
--- a/sys/dev/pci/drm/drm_gem.c
+++ b/sys/dev/pci/drm/drm_gem.c
@@ -343,6 +343,7 @@ void drm_gem_private_object_init(struct drm_device *dev,
obj->filp = NULL;
#else
obj->uao = NULL;
+ obj->uobj.pgops = NULL;
#endif
kref_init(&obj->refcount);
@@ -1166,6 +1167,8 @@ drm_gem_object_release(struct drm_gem_object *obj)
#else
if (obj->uao)
uao_detach(obj->uao);
+ if (obj->uobj.pgops)
+ uvm_obj_destroy(&obj->uobj);
#endif
dma_resv_fini(&obj->_resv);
diff --git a/sys/dev/pci/drm/ttm/ttm_bo_vm.c b/sys/dev/pci/drm/ttm/ttm_bo_vm.c
index a2d27de6e3d..b78a807e27c 100644
--- a/sys/dev/pci/drm/ttm/ttm_bo_vm.c
+++ b/sys/dev/pci/drm/ttm/ttm_bo_vm.c
@@ -852,7 +852,6 @@ ttm_bo_vm_reference(struct uvm_object *uobj)
(struct ttm_buffer_object *)uobj;
ttm_bo_get(bo);
- uobj->uo_refs++;
}
void
@@ -860,7 +859,6 @@ ttm_bo_vm_detach(struct uvm_object *uobj)
{
struct ttm_buffer_object *bo = (struct ttm_buffer_object *)uobj;
- uobj->uo_refs--;
ttm_bo_put(bo);
}
@@ -971,7 +969,8 @@ ttm_bo_mmap(struct file *filp, voff_t off, vsize_t size,
if (unlikely(ret != 0))
goto out_unref;
- uvm_obj_init(&bo->base.uobj, &ttm_bo_vm_ops, 1);
+ if (bo->base.uobj.pgops == NULL)
+ uvm_obj_init(&bo->base.uobj, &ttm_bo_vm_ops, 1);
return &bo->base.uobj;
out_unref:
ttm_bo_put(bo);