diff mbox series

drm/i915/gem: Prevent using pgprot_writecombine() if PAT is not supported

Message ID 20200819203153.16000-1-chris@chris-wilson.co.uk
State Accepted
Commit ba2ebf605d5f32a9be0f7b05d3174bbc501b83fe
Headers show
Series drm/i915/gem: Prevent using pgprot_writecombine() if PAT is not supported | expand

Commit Message

Chris Wilson Aug. 19, 2020, 8:31 p.m. UTC
Let's not try and use PAT attributes for I915_MAP_WC is the CPU doesn't
support PAT.

Fixes: 6056e50033d9 ("drm/i915/gem: Support discontiguous lmem object maps")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: <stable@vger.kernel.org> # v5.6+
---
 drivers/gpu/drm/i915/gem/i915_gem_pages.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
index 7050519c87a4..5f1725268988 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
@@ -254,6 +254,9 @@  static void *i915_gem_object_map(struct drm_i915_gem_object *obj,
 	if (!i915_gem_object_has_struct_page(obj) && type != I915_MAP_WC)
 		return NULL;
 
+	if (type == I915_MAP_WC && !boot_cpu_has(X86_FEATURE_PAT))
+		return NULL;
+
 	/* A single page can always be kmapped */
 	if (n_pte == 1 && type == I915_MAP_WB)
 		return kmap(sg_page(sgt->sgl));