[Mesa-dev] [PATCH 06/10] i965: Add virtual memory allocator infrastructure to brw_bufmgr.

Chris Wilson chris at chris-wilson.co.uk
Fri May 4 21:27:27 UTC 2018


Quoting Kenneth Graunke (2018-05-04 02:12:36)
> +   if (brw_using_softpin(bufmgr) && bo->gtt_offset == 0ull) {
> +      bo->gtt_offset = vma_alloc(bufmgr, memzone, bo->size, 1);
> +
> +      if (bo->gtt_offset == 0ull)
> +         goto err_free;
> +   }
> +
>     bo->name = name;
>     p_atomic_set(&bo->refcount, 1);
>     bo->reusable = true;
> @@ -545,6 +792,9 @@ brw_bo_gem_create_from_name(struct brw_bufmgr *bufmgr,
>     bo->external = true;
>     bo->kflags = bufmgr->initial_kflags;
>  
> +   if (brw_using_softpin(bufmgr))
> +      bo->gtt_offset = vma_alloc(bufmgr, BRW_MEMZONE_OTHER, bo->size, 1);

At this point, I think you want bo_using_softpoin() and pull it from the
kflags. Not any different today, but I think more defensive, especially
on the free paths.

On exec I think you want something like

assert(!bo_using_softpin(bo) ||
       bo->gtt_offset == execobj[bo->index].gtt_iffset);

to document and check that the kernel isn't moving the objects and
breaking the vma manager.

Overall impression: very, very neat.
-Chris


More information about the mesa-dev mailing list