Commit a204bd75 authored by Kenneth Graunke's avatar Kenneth Graunke
Browse files

iris: Allow slab-allocation of explicitly-coherent buffers

When I implemented the suballocator, I skipped it when the caller
explicitly requested coherent buffers.  However, PIPE_USAGE_STAGING
ends up implying BO_ALLOC_COHERENT, and staging buffers for transfer
maps that use copies to avoid stalls are extremely common.

The point of this restriction was to avoid allocating buffers with
different coherency requirements out of the same slab.  We wouldn't
want to have some require snooping, and others not want it.

However, this is trivial on most systems.  On discrete, local memory
is always non-coherent.  System memory is always coherent.  But it's
always consistent.  Similarly, integrated GPUs with LLC always have
coherent allocations, so they're fine too.  The only case that is
troublesome is non-LLC integrated, where we have to manually enable
snooping, and so there are two possible modes.

So, we can enable the suballocator in all cases on discrete and LLC
systems.  For non-LLC systems, this patch suballocates for buffers
where coherency is the default (non-coherent), but falls back to using
real BOs for the less common snooped case.  Someday, we could use two
heaps for non-LLC, if we want to start suballocating snooped buffers.

This moves 95% of the buffer allocations in a trace of Dota 2 from
being allocated in real BOs to being suballocated.  This should not
only be more memory efficient, but should also save on mmap calls.
parent e28aff8c
Pipeline #721259 waiting for manual action with stages
......@@ -1066,7 +1066,14 @@ iris_bo_alloc(struct iris_bufmgr *bufmgr,
bool local = heap != IRIS_HEAP_SYSTEM_MEMORY;
struct bo_cache_bucket *bucket = bucket_for_size(bufmgr, size, heap);
if (memzone != IRIS_MEMZONE_OTHER || (flags & BO_ALLOC_COHERENT))
bool non_llc_snooped = (flags & BO_ALLOC_COHERENT) &&
!bufmgr->has_llc && bufmgr->vram.size == 0;
/* Skip the suballocator when manually requesting non-default coherency.
* We could use a separate heap to support slab-allocating snooped buffers
* someday, but for now we just resort to using actual BOs.
if (memzone != IRIS_MEMZONE_OTHER || non_llc_snooped)
bo = alloc_bo_from_slabs(bufmgr, name, size, alignment, flags);
......@@ -1142,8 +1149,7 @@ iris_bo_alloc(struct iris_bufmgr *bufmgr,
/* On integrated GPUs, enable snooping to ensure coherency if needed.
* For discrete, we instead use SMEM and avoid WB maps for coherency.
if ((flags & BO_ALLOC_COHERENT) &&
!bufmgr->has_llc && bufmgr->vram.size == 0) {
if (non_llc_snooped) {
struct drm_i915_gem_caching arg = {
.handle = bo->gem_handle,
.caching = 1,
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment