Skip to content

Commit 523f191

Browse files
ajahagirmattrope
authored andcommitted
drm/xe/xe_migrate: Handle migration logic for xe2+ dgfx
During eviction (vram->sysmem), we use compressed -> uncompressed mapping. During restore (sysmem->vram), we need to use mapping from uncompressed -> uncompressed. Handle logic for selecting the compressed identity map for eviction, and selecting uncompressed map for restore operations. v2: Move check of xe_migrate_ccs_emit() before calling xe_migrate_ccs_copy(). (Nirmoy) Signed-off-by: Akshata Jahagirdar <akshata.jahagirdar@intel.com> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Reviewed-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com> Signed-off-by: Matt Roper <matthew.d.roper@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/79b3a016e686a662ae68c32b5fc7f0f2ac8043e9.1721250309.git.akshata.jahagirdar@intel.com
1 parent 2b808d6 commit 523f191

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

drivers/gpu/drm/xe/xe_migrate.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ static u32 xe_migrate_ccs_copy(struct xe_migrate *m,
705705
struct xe_gt *gt = m->tile->primary_gt;
706706
u32 flush_flags = 0;
707707

708-
if (xe_device_has_flat_ccs(gt_to_xe(gt)) && !copy_ccs && dst_is_indirect) {
708+
if (!copy_ccs && dst_is_indirect) {
709709
/*
710710
* If the src is already in vram, then it should already
711711
* have been cleared by us, or has been populated by the
@@ -781,6 +781,7 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m,
781781
bool copy_ccs = xe_device_has_flat_ccs(xe) &&
782782
xe_bo_needs_ccs_pages(src_bo) && xe_bo_needs_ccs_pages(dst_bo);
783783
bool copy_system_ccs = copy_ccs && (!src_is_vram || !dst_is_vram);
784+
bool use_comp_pat = GRAPHICS_VER(xe) >= 20 && IS_DGFX(xe) && src_is_vram && !dst_is_vram;
784785

785786
/* Copying CCS between two different BOs is not supported yet. */
786787
if (XE_WARN_ON(copy_ccs && src_bo != dst_bo))
@@ -807,7 +808,7 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m,
807808
u32 batch_size = 2; /* arb_clear() + MI_BATCH_BUFFER_END */
808809
struct xe_sched_job *job;
809810
struct xe_bb *bb;
810-
u32 flush_flags;
811+
u32 flush_flags = 0;
811812
u32 update_idx;
812813
u64 ccs_ofs, ccs_size;
813814
u32 ccs_pt;
@@ -825,6 +826,7 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m,
825826
src_L0 = min(src_L0, dst_L0);
826827

827828
pte_flags = src_is_vram ? PTE_UPDATE_FLAG_IS_VRAM : 0;
829+
pte_flags |= use_comp_pat ? PTE_UPDATE_FLAG_IS_COMP_PTE : 0;
828830
batch_size += pte_update_size(m, pte_flags, src, &src_it, &src_L0,
829831
&src_L0_ofs, &src_L0_pt, 0, 0,
830832
avail_pts);
@@ -845,7 +847,7 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m,
845847

846848
/* Add copy commands size here */
847849
batch_size += ((copy_only_ccs) ? 0 : EMIT_COPY_DW) +
848-
((xe_device_has_flat_ccs(xe) ? EMIT_COPY_CCS_DW : 0));
850+
((xe_migrate_needs_ccs_emit(xe) ? EMIT_COPY_CCS_DW : 0));
849851

850852
bb = xe_bb_new(gt, batch_size, usm);
851853
if (IS_ERR(bb)) {
@@ -874,11 +876,12 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m,
874876
if (!copy_only_ccs)
875877
emit_copy(gt, bb, src_L0_ofs, dst_L0_ofs, src_L0, XE_PAGE_SIZE);
876878

877-
flush_flags = xe_migrate_ccs_copy(m, bb, src_L0_ofs,
878-
IS_DGFX(xe) ? src_is_vram : src_is_pltt,
879-
dst_L0_ofs,
880-
IS_DGFX(xe) ? dst_is_vram : dst_is_pltt,
881-
src_L0, ccs_ofs, copy_ccs);
879+
if (xe_migrate_needs_ccs_emit(xe))
880+
flush_flags = xe_migrate_ccs_copy(m, bb, src_L0_ofs,
881+
IS_DGFX(xe) ? src_is_vram : src_is_pltt,
882+
dst_L0_ofs,
883+
IS_DGFX(xe) ? dst_is_vram : dst_is_pltt,
884+
src_L0, ccs_ofs, copy_ccs);
882885

883886
job = xe_bb_create_migration_job(m->q, bb,
884887
xe_migrate_batch_base(m, usm),

0 commit comments

Comments
 (0)