drm/xe/xe2: Allocate extra pages for ccs during bo create
authorHimal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Tue, 12 Dec 2023 18:25:26 +0000 (23:55 +0530)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 21 Dec 2023 16:46:09 +0000 (11:46 -0500)
Incase of bo move from PL_TT to PL_SYSTEM these pages will be used to
store ccs metadata from flat ccs. And during bo move to PL_TT from
PL_SYSTEM the metadata will be copied from extra pages to flat ccs. This
copy of ccs metadata ensures ccs remains unaltered between swapping out
of bo to disk and its restore to PL_TT.

Bspec:58796

v2:
 - For dgfx ensure system bit is not set.
 - Modify comments.(Thomas)

v3:
 - Separate out patch to modify main memory to ccs memory ratio.(Matt)

v4:
 - Update description for commit message.
 - Make bo allocation routine more readable.(Matt)

Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_bo.c

index 13ebe33bb7a22d14029ae76b34a744a46c6f05e2..c10aa5a63a701116f75590c0304df79db62ac359 100644 (file)
@@ -2160,19 +2160,24 @@ int xe_bo_evict(struct xe_bo *bo, bool force_alloc)
  * placed in system memory.
  * @bo: The xe_bo
  *
- * If a bo has an allowable placement in XE_PL_TT memory, it can't use
- * flat CCS compression, because the GPU then has no way to access the
- * CCS metadata using relevant commands. For the opposite case, we need to
- * allocate storage for the CCS metadata when the BO is not resident in
- * VRAM memory.
- *
  * Return: true if extra pages need to be allocated, false otherwise.
  */
 bool xe_bo_needs_ccs_pages(struct xe_bo *bo)
 {
-       return bo->ttm.type == ttm_bo_type_device &&
-               !(bo->flags & XE_BO_CREATE_SYSTEM_BIT) &&
-               (bo->flags & XE_BO_CREATE_VRAM_MASK);
+       struct xe_device *xe = xe_bo_device(bo);
+
+       if (!xe_device_has_flat_ccs(xe) || bo->ttm.type != ttm_bo_type_device)
+               return false;
+
+       /* On discrete GPUs, if the GPU can access this buffer from
+        * system memory (i.e., it allows XE_PL_TT placement), FlatCCS
+        * can't be used since there's no CCS storage associated with
+        * non-VRAM addresses.
+        */
+       if (IS_DGFX(xe) && (bo->flags & XE_BO_CREATE_SYSTEM_BIT))
+               return false;
+
+       return true;
 }
 
 /**