Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Akshata Jahagirdar and committed by
Matt Roper
523f191c 2b808d6b

+11 -8
+11 -8
drivers/gpu/drm/xe/xe_migrate.c
··· 705 705 struct xe_gt *gt = m->tile->primary_gt; 706 706 u32 flush_flags = 0; 707 707 708 - if (xe_device_has_flat_ccs(gt_to_xe(gt)) && !copy_ccs && dst_is_indirect) { 708 + if (!copy_ccs && dst_is_indirect) { 709 709 /* 710 710 * If the src is already in vram, then it should already 711 711 * have been cleared by us, or has been populated by the ··· 781 781 bool copy_ccs = xe_device_has_flat_ccs(xe) && 782 782 xe_bo_needs_ccs_pages(src_bo) && xe_bo_needs_ccs_pages(dst_bo); 783 783 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; 784 785 785 786 /* Copying CCS between two different BOs is not supported yet. */ 786 787 if (XE_WARN_ON(copy_ccs && src_bo != dst_bo)) ··· 808 807 u32 batch_size = 2; /* arb_clear() + MI_BATCH_BUFFER_END */ 809 808 struct xe_sched_job *job; 810 809 struct xe_bb *bb; 811 - u32 flush_flags; 810 + u32 flush_flags = 0; 812 811 u32 update_idx; 813 812 u64 ccs_ofs, ccs_size; 814 813 u32 ccs_pt; ··· 826 825 src_L0 = min(src_L0, dst_L0); 827 826 828 827 pte_flags = src_is_vram ? PTE_UPDATE_FLAG_IS_VRAM : 0; 828 + pte_flags |= use_comp_pat ? PTE_UPDATE_FLAG_IS_COMP_PTE : 0; 829 829 batch_size += pte_update_size(m, pte_flags, src, &src_it, &src_L0, 830 830 &src_L0_ofs, &src_L0_pt, 0, 0, 831 831 avail_pts); ··· 847 845 848 846 /* Add copy commands size here */ 849 847 batch_size += ((copy_only_ccs) ? 0 : EMIT_COPY_DW) + 850 - ((xe_device_has_flat_ccs(xe) ? EMIT_COPY_CCS_DW : 0)); 848 + ((xe_migrate_needs_ccs_emit(xe) ? EMIT_COPY_CCS_DW : 0)); 851 849 852 850 bb = xe_bb_new(gt, batch_size, usm); 853 851 if (IS_ERR(bb)) { ··· 876 874 if (!copy_only_ccs) 877 875 emit_copy(gt, bb, src_L0_ofs, dst_L0_ofs, src_L0, XE_PAGE_SIZE); 878 876 879 - flush_flags = xe_migrate_ccs_copy(m, bb, src_L0_ofs, 880 - IS_DGFX(xe) ? src_is_vram : src_is_pltt, 881 - dst_L0_ofs, 882 - IS_DGFX(xe) ? dst_is_vram : dst_is_pltt, 883 - src_L0, ccs_ofs, copy_ccs); 877 + if (xe_migrate_needs_ccs_emit(xe)) 878 + flush_flags = xe_migrate_ccs_copy(m, bb, src_L0_ofs, 879 + IS_DGFX(xe) ? src_is_vram : src_is_pltt, 880 + dst_L0_ofs, 881 + IS_DGFX(xe) ? dst_is_vram : dst_is_pltt, 882 + src_L0, ccs_ofs, copy_ccs); 884 883 885 884 job = xe_bb_create_migration_job(m->q, bb, 886 885 xe_migrate_batch_base(m, usm),