[RFC 6/9] drm/i915: Improve the vm_fault_gtt user PAT index restriction

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Tue Aug 1 13:34:58 UTC 2023


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Now that i915 understands the caching modes behind PAT indices, we can
refine the check in vm_fault_gtt() to not reject the uncached PAT if it
was set by userspace on a snoopable platform.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Cc: Fei Yang <fei.yang at intel.com>
Cc: Matt Roper <matthew.d.roper at intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
index 5373e864afe6..9aa6ecf68432 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
@@ -383,17 +383,8 @@ static vm_fault_t vm_fault_gtt(struct vm_fault *vmf)
 	}
 
 	/* Access to snoopable pages through the GTT is incoherent. */
-	/*
-	 * For objects created by userspace through GEM_CREATE with pat_index
-	 * set by set_pat extension, coherency is managed by userspace, make
-	 * sure we don't fail handling the vm fault by calling
-	 * i915_gem_object_has_cache_level() which always return true for such
-	 * objects. Otherwise this helper function would fall back to checking
-	 * whether the object is un-cached.
-	 */
-	if (!((obj->pat_set_by_user ||
-	       i915_gem_object_has_cache_mode(obj, I915_CACHE_MODE_UC)) ||
-	      HAS_LLC(i915))) {
+	if (!i915_gem_object_has_cache_mode(obj, I915_CACHE_MODE_UC) &&
+	    !HAS_LLC(i915)) {
 		ret = -EFAULT;
 		goto err_unpin;
 	}
-- 
2.39.2



More information about the Intel-gfx-trybot mailing list