drm/xe/bo: further limit where CCS pages are needed
authorMatthew Auld <matthew.auld@intel.com>
Thu, 25 May 2023 11:45:42 +0000 (12:45 +0100)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 19 Dec 2023 23:34:04 +0000 (18:34 -0500)
No need to allocate extra pages for this if we know flat-ccs AUX state
is not even possible, like for normal system memory objects.

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_bo.c

index 71864ef95328e4cdc497a79850a2a1046875f4d3..394e4bfae6e193ac3337b585e2022ce343758599 100644 (file)
@@ -285,6 +285,7 @@ static struct ttm_tt *xe_ttm_tt_create(struct ttm_buffer_object *ttm_bo,
        struct xe_bo *bo = ttm_to_xe_bo(ttm_bo);
        struct xe_device *xe = xe_bo_device(bo);
        struct xe_ttm_tt *tt;
+       unsigned long extra_pages;
        int err;
 
        tt = kzalloc(sizeof(*tt), GFP_KERNEL);
@@ -293,12 +294,15 @@ static struct ttm_tt *xe_ttm_tt_create(struct ttm_buffer_object *ttm_bo,
 
        tt->dev = xe->drm.dev;
 
+       extra_pages = 0;
+       if (xe_bo_needs_ccs_pages(bo))
+               extra_pages = DIV_ROUND_UP(xe_device_ccs_bytes(xe, bo->size),
+                                          PAGE_SIZE);
+
        /* TODO: Select caching mode */
        err = ttm_tt_init(&tt->ttm, &bo->ttm, page_flags,
                          bo->flags & XE_BO_SCANOUT_BIT ? ttm_write_combined : ttm_cached,
-                         DIV_ROUND_UP(xe_device_ccs_bytes(xe_bo_device(bo),
-                                                          bo->ttm.base.size),
-                                      PAGE_SIZE));
+                         extra_pages);
        if (err) {
                kfree(tt);
                return NULL;