diff options
author | Chris Wilson <[email protected]> | 2019-02-22 21:24:46 +0000 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2019-03-13 10:54:16 -0700 |
commit | 797fb6c6ac96cb7d1d5f9a04dc4f22f350093a16 (patch) | |
tree | fc91b1b21e8dca937bf644f52f398498e9fdc21e /src/gallium/drivers/iris/iris_bufmgr.c | |
parent | 01b224047b0013380a5e8b709eaf2e3cd9976b39 (diff) |
iris: Use coherent allocation for PIPE_RESOURCE_STAGING
On !llc machines (Atoms), reading from a linear buffers is slow and so
copying from one resource into the linear staging buffer is still slow.
However, we can tell the GPU to snoop the CPU cache when reading from and
writing to the staging buffer eliminating the slow uncached reads.
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/gallium/drivers/iris/iris_bufmgr.c')
-rw-r--r-- | src/gallium/drivers/iris/iris_bufmgr.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index 92ede934056..b20297fd94a 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -521,6 +521,12 @@ bo_alloc_internal(struct iris_bufmgr *bufmgr, if (flags & BO_ALLOC_ZEROED) zeroed = true; + if ((flags & BO_ALLOC_COHERENT) && !bufmgr->has_llc) { + bo_size = MAX2(ALIGN(size, page_size), page_size); + bucket = NULL; + goto skip_cache; + } + /* Round the allocated size up to a power of two number of pages. */ bucket = bucket_for_size(bufmgr, size); @@ -579,6 +585,7 @@ retry: bo->gtt_offset = 0ull; } } else { +skip_cache: bo = bo_calloc(); if (!bo) goto err; @@ -644,6 +651,17 @@ retry: mtx_unlock(&bufmgr->lock); + if ((flags & BO_ALLOC_COHERENT) && !bo->cache_coherent) { + struct drm_i915_gem_caching arg = { + .handle = bo->gem_handle, + .caching = 1, + }; + if (drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_SET_CACHING, &arg) == 0) { + bo->cache_coherent = true; + bo->reusable = false; + } + } + DBG("bo_create: buf %d (%s) %llub\n", bo->gem_handle, bo->name, (unsigned long long) size); |