Mesa (main): iris: Fail BO allocation if we can't enable snooping properly.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jul 2 19:17:49 UTC 2021


Module: Mesa
Branch: main
Commit: a313bd7845fea9de898293d40f0ae0ff662b67a0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a313bd7845fea9de898293d40f0ae0ff662b67a0

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Mon Jun 28 11:38:08 2021 -0700

iris: Fail BO allocation if we can't enable snooping properly.

If the caller has asked for a coherent BO with snooping, and the kernel
fails to set it for whatever reason, we were happily returning them a
non-coherent buffer.  This isn't what they wanted and could lead to
surprising results.

Better to simply fail the allocation.  Probably.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11644>

---

 src/gallium/drivers/iris/iris_bufmgr.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
index 5841fa4a7cf..554e7a81d6b 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.c
+++ b/src/gallium/drivers/iris/iris_bufmgr.c
@@ -673,10 +673,11 @@ iris_bo_alloc(struct iris_bufmgr *bufmgr,
          .handle = bo->gem_handle,
          .caching = 1,
       };
-      if (intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_SET_CACHING, &arg) == 0) {
-         bo->cache_coherent = true;
-         bo->reusable = false;
-      }
+      if (intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_SET_CACHING, &arg) != 0)
+         goto err_free;
+
+      bo->cache_coherent = true;
+      bo->reusable = false;
    }
 
    DBG("bo_create: buf %d (%s) (%s memzone) (%s) %llub\n", bo->gem_handle,



More information about the mesa-commit mailing list