From a313bd7845fea9de898293d40f0ae0ff662b67a0 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 28 Jun 2021 11:38:08 -0700 Subject: [PATCH] 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 Part-of: --- 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,