drm/xe/display: ensure clear-color surfaces are cpu mappable
authorMatthew Auld <matthew.auld@intel.com>
Fri, 31 Mar 2023 08:46:27 +0000 (09:46 +0100)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 21 Dec 2023 16:44:30 +0000 (11:44 -0500)
The KMD needs to access the clear-color value stored in the buffer via
the CPU. On small-bar systems reject any buffers that are potentially
not CPU accessible.

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: José Roberto de Souza <jose.souza@intel.com>
Cc: Filip Hazubski <filip.hazubski@intel.com>
Cc: Carl Zhang <carl.zhang@intel.com>
Cc: Effie Yu <effie.yu@intel.com>
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
[ Split display-related changes from small-bar support ]
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/display/xe_fb_pin.c

index 67b956a6da8d3c2737a3bea9466e4d1667ff0656..16e04b24daee86749bcac52a0b3be5980ee6d958 100644 (file)
@@ -217,6 +217,23 @@ static struct i915_vma *__xe_pin_fb_vma(struct intel_framebuffer *fb,
                goto err;
        }
 
+       if (IS_DGFX(to_xe_device(bo->ttm.base.dev)) &&
+           intel_fb_rc_ccs_cc_plane(&fb->base) >= 0 &&
+           !(bo->flags & XE_BO_NEEDS_CPU_ACCESS)) {
+               struct xe_tile *tile = xe_device_get_root_tile(xe);
+
+               /*
+                * If we need to able to access the clear-color value stored in
+                * the buffer, then we require that such buffers are also CPU
+                * accessible.  This is important on small-bar systems where
+                * only some subset of VRAM is CPU accessible.
+                */
+               if (tile->mem.vram.io_size < tile->mem.vram.usable_size) {
+                       ret = -EINVAL;
+                       goto err;
+               }
+       }
+
        /*
         * Pin the framebuffer, we can't use xe_bo_(un)pin functions as the
         * assumptions are incorrect for framebuffers