Skip to content

Commit 0db912a

Browse files
author
Ben Skeggs
committed
drm/nouveau/gem: attach fences to VMAs to track GPU usage
An upcoming patch will use these to fix issues related to the deferred unmapping of GEM objects. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
1 parent 19ca10d commit 0db912a

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

drivers/gpu/drm/nouveau/nouveau_gem.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ struct nouveau_gem_object_unmap {
9999
static void
100100
nouveau_gem_object_delete(struct nouveau_vma *vma)
101101
{
102+
nouveau_fence_unref(&vma->fence);
102103
nouveau_vma_del(&vma);
103104
}
104105

@@ -344,9 +345,20 @@ validate_fini_no_ticket(struct validate_op *op, struct nouveau_fence *fence,
344345
nvbo = list_entry(op->list.next, struct nouveau_bo, entry);
345346
b = &pbbo[nvbo->pbbo_index];
346347

347-
if (likely(fence))
348+
if (likely(fence)) {
349+
struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
350+
struct nouveau_vma *vma;
351+
348352
nouveau_bo_fence(nvbo, fence, !!b->write_domains);
349353

354+
if (drm->client.vmm.vmm.object.oclass >= NVIF_CLASS_VMM_NV50) {
355+
vma = (void *)(unsigned long)b->user_priv;
356+
nouveau_fence_unref(&vma->fence);
357+
dma_fence_get(&fence->base);
358+
vma->fence = fence;
359+
}
360+
}
361+
350362
if (unlikely(nvbo->validate_mapped)) {
351363
ttm_bo_kunmap(&nvbo->kmap);
352364
nvbo->validate_mapped = false;

drivers/gpu/drm/nouveau/nouveau_vmm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ nouveau_vma_new(struct nouveau_bo *nvbo, struct nouveau_vmm *vmm,
9292
vma->refs = 1;
9393
vma->addr = ~0ULL;
9494
vma->mem = NULL;
95+
vma->fence = NULL;
9596
list_add_tail(&vma->head, &nvbo->vma_list);
9697

9798
if (nvbo->bo.mem.mem_type != TTM_PL_SYSTEM &&

drivers/gpu/drm/nouveau/nouveau_vmm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ struct nouveau_vma {
1111
u64 addr;
1212

1313
struct nouveau_mem *mem;
14+
15+
struct nouveau_fence *fence;
1416
};
1517

1618
struct nouveau_vma *nouveau_vma_find(struct nouveau_bo *, struct nouveau_vmm *);

0 commit comments

Comments
 (0)