[PATCH v2 6/6] drm/xe/svm: Migrate folios when possible

Francois Dugast francois.dugast at intel.com
Fri Jul 25 15:39:30 UTC 2025


The DMA mapping can now correspond to a folio (order > 0), so move the
iterator by the number of pages in the folio in order to migrate all
pages at once. This will improve efficiency compared to migrating pages
one by one.

For this to work, the BOs must be contiguous in memory.

Signed-off-by: Francois Dugast <francois.dugast at intel.com>
---
 drivers/gpu/drm/xe/xe_bo.c  | 2 ++
 drivers/gpu/drm/xe/xe_svm.c | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index ffca1cea5585..59994a978a8c 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -200,6 +200,8 @@ static bool force_contiguous(u32 bo_flags)
 	else if (bo_flags & XE_BO_FLAG_PINNED &&
 		 !(bo_flags & XE_BO_FLAG_PINNED_LATE_RESTORE))
 		return true; /* needs vmap */
+	else if (bo_flags & XE_BO_FLAG_CPU_ADDR_MIRROR)
+		return true;
 
 	/*
 	 * For eviction / restore on suspend / resume objects pinned in VRAM
diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c
index 1d097e76aabc..2759db5f7407 100644
--- a/drivers/gpu/drm/xe/xe_svm.c
+++ b/drivers/gpu/drm/xe/xe_svm.c
@@ -382,6 +382,11 @@ static int xe_svm_copy(struct page **pages,
 				pos = i;
 			}
 
+			if (pagemap_addr[i].order) {
+				i += NR_PAGES(pagemap_addr[i].order);
+				last = (i + 1) == npages;
+			}
+
 			match = vram_addr + PAGE_SIZE * (i - pos) == __vram_addr;
 		}
 
-- 
2.43.0



More information about the Intel-xe mailing list