Skip to content

Commit 470db8b

Browse files
author
Ben Skeggs
committed
drm/nouveau/gem: tie deferred unmapping of buffers to VMA fence completion
As VMAs are per-client, unlike buffers, this allows us to avoid referencing foreign fences (those that belong to another client/driver) from the client deferred work handler, and prevent some not-fun race conditions that can be triggered when a fence stalls. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
1 parent 0db912a commit 470db8b

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

drivers/gpu/drm/nouveau/nouveau_gem.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,12 @@ nouveau_gem_object_delete_work(struct nouveau_cli_work *w)
115115
static void
116116
nouveau_gem_object_unmap(struct nouveau_bo *nvbo, struct nouveau_vma *vma)
117117
{
118-
const bool mapped = nvbo->bo.mem.mem_type != TTM_PL_SYSTEM;
119-
struct reservation_object *resv = nvbo->bo.resv;
120-
struct reservation_object_list *fobj;
118+
struct dma_fence *fence = vma->fence ? &vma->fence->base : NULL;
121119
struct nouveau_gem_object_unmap *work;
122-
struct dma_fence *fence = NULL;
123-
124-
fobj = reservation_object_get_list(resv);
125120

126121
list_del_init(&vma->head);
127122

128-
if (fobj && fobj->shared_count > 1)
129-
ttm_bo_wait(&nvbo->bo, false, false);
130-
else if (fobj && fobj->shared_count == 1)
131-
fence = rcu_dereference_protected(fobj->shared[0],
132-
reservation_object_held(resv));
133-
else
134-
fence = reservation_object_get_excl(nvbo->bo.resv);
135-
136-
if (!fence || !mapped) {
123+
if (!fence) {
137124
nouveau_gem_object_delete(vma);
138125
return;
139126
}

0 commit comments

Comments
 (0)