Skip to contentSkip to conversation

drm/xe: Enable 2M pages in xe_migrate_vram

PATCH In review Matthew Brost 2 participants 3 messages Aug 28, 2025

Subsystems (2)
lore
Share & tools
lore

Matthew Brost

author maintainer
#0 lore raw

PATCH 1/1 drm/xe: Enable 2M pages in xe_migrate_vram

Using 2M pages in xe_migrate_vram has two benefits: we issue fewer instructions per 2M copy (1 vs. 512), and the cache hit rate should be higher. This results in increased copy engine bandwidth, as shown by benchmark IGTs.

Enable 2M pages by reserving PDEs in the migrate VM and using 2M pages in xe_migrate_vram if the DMA address order matches 2M.

While here, correct build_pt_update_batch_sram to handle PAGE_SIZE > 4K.

v2:
- Reuse build_pt_update_batch_sram (Stuart)
- Fix build_pt_update_batch_sram for PAGE_SIZE > 4K
v3:
- More fixes for PAGE_SIZE > 4K, align chunk, decrement chunk as needed
- Use stack incr var in xe_migrate_vram_use_pde (Stuart)

---
 drivers/gpu/drm/xe/xe_migrate.c | 71 ++++++++++++++++++++++++++++-----
 1 file changed, 61 insertions(+), 10 deletions(-)
drivers/gpu/drm/xe/xe_migrate.c +61 -10
index 57e6d5a8ac39..6bfda6441836 100644
@@ -56,6 +56,13 @@ struct xe_migrate {
 	u64 usm_batch_base_ofs;
 	/** @cleared_mem_ofs: VM offset of @cleared_bo. */
 	u64 cleared_mem_ofs;
+	/** @large_page_copy_ofs: VM offset of 2M pages used for large copies */
+	u64 large_page_copy_ofs;
+	/**
+	 * @large_page_copy_pdes: BO offset to writeout 2M pages (PDEs) used for
+	 * large copies
+	 */
+	u64 large_page_copy_pdes;
 	/**
 	 * @fence: dma-fence representing the last migration job batch.
 	 * Protected by @job_mutex.
@@ -287,6 +294,12 @@ static int xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,
 			  (i + 1) * 8, u64, entry);
 	}
 
+	/* Reserve 2M PDEs */
+	level = 1;
+	m->large_page_copy_ofs = NUM_PT_SLOTS << xe_pt_shift(level);
+	m->large_page_copy_pdes = map_ofs + XE_PAGE_SIZE * level +
+		NUM_PT_SLOTS * 8;
+
 	/* Set up a 1GiB NULL mapping at 255GiB offset. */
 	level = 2;
 	xe_map_wr(xe, &bo->vmap, map_ofs + XE_PAGE_SIZE * level + 255 * 8, u64,
@@ -1741,16 +1754,19 @@ static u32 pte_update_cmd_size(u64 size)
 static void build_pt_update_batch_sram(struct xe_migrate *m,
 				       struct xe_bb *bb, u32 pt_offset,
 				       struct drm_pagemap_addr *sram_addr,
-				       u32 size)
+				       u32 size, int level)
 {
 	u16 pat_index = tile_to_xe(m->tile)->pat.idx[XE_CACHE_WB];
+	u64 gpu_page_size = 0x1ull << xe_pt_shift(level);
 	u32 ptes;
 	int i = 0;
 
-	ptes = DIV_ROUND_UP(size, XE_PAGE_SIZE);
+	ptes = DIV_ROUND_UP(size, gpu_page_size);
 	while (ptes) {
 		u32 chunk = min(MAX_PTE_PER_SDI, ptes);
 
+		chunk = ALIGN_DOWN(chunk, PAGE_SIZE / XE_PAGE_SIZE);
+
 		bb->cs[bb->len++] = MI_STORE_DATA_IMM | MI_SDI_NUM_QW(chunk);
 		bb->cs[bb->len++] = pt_offset;
 		bb->cs[bb->len++] = 0;
@@ -1759,22 +1775,46 @@ static void build_pt_update_batch_sram(struct xe_migrate *m,
 		ptes -= chunk;
 
 		while (chunk--) {
-			u64 addr = sram_addr[i].addr & PAGE_MASK;
+			u64 addr = sram_addr[i].addr & ~(gpu_page_size - 1);
 
 			xe_tile_assert(m->tile, sram_addr[i].proto ==
 				       DRM_INTERCONNECT_SYSTEM);
 			xe_tile_assert(m->tile, addr);
+
+again:
 			addr = m->q->vm->pt_ops->pte_encode_addr(m->tile->xe,
 								 addr, pat_index,
-								 0, false, 0);
+								 level, false, 0);
 			bb->cs[bb->len++] = lower_32_bits(addr);
 			bb->cs[bb->len++] = upper_32_bits(addr);
 
-			i++;
+			if (gpu_page_size < PAGE_SIZE) {
+				addr += XE_PAGE_SIZE;
+				if (sram_addr[i].addr + PAGE_SIZE != addr) {
+					chunk--;
+					goto again;
+				}
+				i++;
+			} else {
+				i += gpu_page_size / PAGE_SIZE;
+			}
 		}
 	}
 }
 
+static bool xe_migrate_vram_use_pde(struct drm_pagemap_addr *sram_addr,
+				    unsigned long size)
+{
+	u32 large_size = (0x1 << xe_pt_shift(1));
+	unsigned long i, incr = large_size / PAGE_SIZE;;
+
+	for (i = 0; i < DIV_ROUND_UP(size, PAGE_SIZE); i += incr)
+		if (PAGE_SIZE << sram_addr[i].order != large_size)
+			return false;
+
+	return true;
+}
+
 enum xe_migrate_copy_dir {
 	XE_MIGRATE_COPY_TO_VRAM,
 	XE_MIGRATE_COPY_TO_SRAM,
@@ -1804,6 +1844,7 @@ static struct dma_fence *xe_migrate_vram(struct xe_migrate *m,
 		PAGE_SIZE : 4;
 	int err;
 	unsigned long i, j;
+	bool use_pde = xe_migrate_vram_use_pde(sram_addr, len + sram_offset);
 
 	if (drm_WARN_ON(&xe->drm, (len & XE_CACHELINE_MASK) ||
 			(sram_offset | vram_addr) & XE_CACHELINE_MASK))
@@ -1828,7 +1869,7 @@ static struct dma_fence *xe_migrate_vram(struct xe_migrate *m,
 	 * struct drm_pagemap_addr. Ensure this is the case even with higher
 	 * orders.
 	 */
-	for (i = 0; i < npages;) {
+	for (i = 0; !use_pde && i < npages;) {
 		unsigned int order = sram_addr[i].order;
 
 		for (j = 1; j < NR_PAGES(order) && i + j < npages; j++)
@@ -1838,16 +1879,26 @@ static struct dma_fence *xe_migrate_vram(struct xe_migrate *m,
 		i += NR_PAGES(order);
 	}
 
-	build_pt_update_batch_sram(m, bb, pt_slot * XE_PAGE_SIZE,
-				   sram_addr, len + sram_offset);
+	if (use_pde)
+		build_pt_update_batch_sram(m, bb, m->large_page_copy_pdes,
+					   sram_addr, len + sram_offset, 1);
+	else
+		build_pt_update_batch_sram(m, bb, pt_slot * XE_PAGE_SIZE,
+					   sram_addr, len + sram_offset, 0);
 
 	if (dir == XE_MIGRATE_COPY_TO_VRAM) {
-		src_L0_ofs = xe_migrate_vm_addr(pt_slot, 0) + sram_offset;
+		if (use_pde)
+			src_L0_ofs = m->large_page_copy_ofs + sram_offset;
+		else
+			src_L0_ofs = xe_migrate_vm_addr(pt_slot, 0) + sram_offset;
 		dst_L0_ofs = xe_migrate_vram_ofs(xe, vram_addr, false);
 
 	} else {
 		src_L0_ofs = xe_migrate_vram_ofs(xe, vram_addr, false);
-		dst_L0_ofs = xe_migrate_vm_addr(pt_slot, 0) + sram_offset;
+		if (use_pde)
+			dst_L0_ofs = m->large_page_copy_ofs + sram_offset;
+		else
+			dst_L0_ofs = xe_migrate_vm_addr(pt_slot, 0) + sram_offset;
 	}
 
 	bb->cs[bb->len++] = MI_BATCH_BUFFER_END;
Signature · 1 line
2.34.1
#1 lore raw
Quoted 76 lines · Matthew Brost

Using 2M pages in xe_migrate_vram has two benefits: we issue fewer instructions per 2M copy (1 vs. 512), and the cache hit rate should be
higher. This results in increased copy engine bandwidth, as shown by benchmark IGTs.

Enable 2M pages by reserving PDEs in the migrate VM and using 2M pages
in xe_migrate_vram if the DMA address order matches 2M.

While here, correct build_pt_update_batch_sram to handle PAGE_SIZE > 4K.

v2:
 - Reuse build_pt_update_batch_sram (Stuart)
 - Fix build_pt_update_batch_sram for PAGE_SIZE > 4K v3:
 - More fixes for PAGE_SIZE > 4K, align chunk, decrement chunk as needed
 - Use stack incr var in xe_migrate_vram_use_pde (Stuart)

---
 drivers/gpu/drm/xe/xe_migrate.c | 71 ++++++++++++++++++++++++++++--- --

 1 file changed, 61 insertions(+), 10 deletions(-)
drivers/gpu/drm/xe/xe_migrate.c +1 -0
index 57e6d5a8ac39..6bfda6441836 100644
@@ -56,6 +56,13 @@ struct xe_migrate {
         u64 usm_batch_base_ofs;
         /** @cleared_mem_ofs: VM offset of @cleared_bo. */
         u64 cleared_mem_ofs;
+       /** @large_page_copy_ofs: VM offset of 2M pages used for

large copies */
+       u64 large_page_copy_ofs;
+       /**
+        * @large_page_copy_pdes: BO offset to writeout 2M pages (PDEs) used for
+        * large copies
+        */
+       u64 large_page_copy_pdes;
        /**
         * @fence: dma-fence representing the last migration job batch.
         * Protected by @job_mutex.

drivers/gpu/drm/xe/xe_migrate.c +0 -0
@@ -287,6 +294,12 @@ static int xe_migrate_prepare_vm(struct xe_tile
 *tile, struct xe_migrate *m,
                           (i + 1) * 8, u64, entry);
         }


+       /* Reserve 2M PDEs */
+       level = 1;
+       m->large_page_copy_ofs = NUM_PT_SLOTS << xe_pt_shift(level); +       m->large_page_copy_pdes = map_ofs + XE_PAGE_SIZE * level + +               NUM_PT_SLOTS * 8;
+
        /* Set up a 1GiB NULL mapping at 255GiB offset. */ level = 2;
        xe_map_wr(xe, &bo->vmap, map_ofs + XE_PAGE_SIZE * level + 255
* 8, u64,

drivers/gpu/drm/xe/xe_migrate.c +0 -0
@@ -1741,16 +1754,19 @@ static u32 pte_update_cmd_size(u64 size)
  static void build_pt_update_batch_sram(struct xe_migrate *m,

                                       struct xe_bb *bb, u32 pt_offset,
                                       struct drm_pagemap_addr *sram_addr,
-                                      u32 size)
+                                      u32 size, int level) {
        u16 pat_index = tile_to_xe(m->tile)->pat.idx[XE_CACHE_WB]; +       u64 gpu_page_size = 0x1ull << xe_pt_shift(level); u32 ptes;

Quoted 8 lines

        int i = 0;

-       ptes = DIV_ROUND_UP(size, XE_PAGE_SIZE);
+       ptes = DIV_ROUND_UP(size, gpu_page_size);
        while (ptes) {
                u32 chunk = min(MAX_PTE_PER_SDI, ptes);

+               chunk = ALIGN_DOWN(chunk, PAGE_SIZE / XE_PAGE_SIZE);

Ok I see what you're doing here now (also responding to your comment in the previous revision). I actually think we should split this into two patches then: first patch does the support for arch page size > 4k and second patch adds the 2MB PDE update. This makes it easier to understand the sequence when we look back later to see why we have this change.

Or otherwise I think you should be more clear in the commit message about the two pieces of this patch.

Other than that though the rest of the patch lgtm.

Thanks,
Stuart

Quoted 130 lines

+
                bb->cs[bb->len++] = MI_STORE_DATA_IMM | MI_SDI_NUM_QW(chunk);
                bb->cs[bb->len++] = pt_offset; bb->cs[bb->len++] = 0;

drivers/gpu/drm/xe/xe_migrate.c +0 -0
@@ -1759,22 +1775,46 @@ static void build_pt_update_batch_sram(struct
 xe_migrate *m,
                 ptes -= chunk;


                while (chunk--) {
-                       u64 addr = sram_addr[i].addr & PAGE_MASK; +                       u64 addr = sram_addr[i].addr & ~(gpu_page_size - 1);

                        xe_tile_assert(m->tile, sram_addr[i].proto == DRM_INTERCONNECT_SYSTEM); xe_tile_assert(m->tile, addr);

drivers/gpu/drm/xe/xe_migrate.c +2 -0
+
+again:

                        addr = m->q->vm->pt_ops->pte_encode_addr(m-

Quoted 1 line

tile->xe,


addr, pat_index,
-                                                                0, false, 0);
+
level, false, 0);
                        bb->cs[bb->len++] = lower_32_bits(addr); bb->cs[bb->len++] = upper_32_bits(addr);
-                       i++;
+                       if (gpu_page_size < PAGE_SIZE) { +                               addr += XE_PAGE_SIZE;
+                               if (sram_addr[i].addr + PAGE_SIZE != addr) {
+                                       chunk--;
+                                       goto again;
+                               }
+                               i++;
+                       } else {
+                               i += gpu_page_size / PAGE_SIZE; +                       }
                }
        }
 }

+static bool xe_migrate_vram_use_pde(struct drm_pagemap_addr *sram_addr,
+                                   unsigned long size)

drivers/gpu/drm/xe/xe_migrate.c +11 -0
+{
+       u32 large_size = (0x1 << xe_pt_shift(1));
+       unsigned long i, incr = large_size / PAGE_SIZE;;
+
+       for (i = 0; i < DIV_ROUND_UP(size, PAGE_SIZE); i += incr)
+               if (PAGE_SIZE << sram_addr[i].order != large_size)
+                       return false;
+
+       return true;
+}
+

 enum xe_migrate_copy_dir {
        XE_MIGRATE_COPY_TO_VRAM,
        XE_MIGRATE_COPY_TO_SRAM,

drivers/gpu/drm/xe/xe_migrate.c +1 -0
@@ -1804,6 +1844,7 @@ static struct dma_fence *xe_migrate_vram(struct
 xe_migrate *m,
                 PAGE_SIZE : 4;
         int err;
         unsigned long i, j;
+       bool use_pde = xe_migrate_vram_use_pde(sram_addr, len +
 sram_offset);


        if (drm_WARN_ON(&xe->drm, (len & XE_CACHELINE_MASK) || (sram_offset | vram_addr) & XE_CACHELINE_MASK))

drivers/gpu/drm/xe/xe_migrate.c +0 -0
@@ -1828,7 +1869,7 @@ static struct dma_fence *xe_migrate_vram(struct
 xe_migrate *m,
          * struct drm_pagemap_addr. Ensure this is the case even with

higher
         * orders.
         */
-       for (i = 0; i < npages;) {
+       for (i = 0; !use_pde && i < npages;) {
                unsigned int order = sram_addr[i].order;
                for (j = 1; j < NR_PAGES(order) && i + j < npages; j++)

drivers/gpu/drm/xe/xe_migrate.c +0 -0
@@ -1838,16 +1879,26 @@ static struct dma_fence
 *xe_migrate_vram(struct xe_migrate *m,
                 i += NR_PAGES(order);
         }


-       build_pt_update_batch_sram(m, bb, pt_slot * XE_PAGE_SIZE, -                                  sram_addr, len + sram_offset); +       if (use_pde)
+               build_pt_update_batch_sram(m, bb, m-

Quoted 1 line

large_page_copy_pdes,

+                                          sram_addr, len + sram_offset, 1);
+       else
+               build_pt_update_batch_sram(m, bb, pt_slot * XE_PAGE_SIZE,
+                                          sram_addr, len + sram_offset, 0);

        if (dir == XE_MIGRATE_COPY_TO_VRAM) {
-               src_L0_ofs = xe_migrate_vm_addr(pt_slot, 0) + sram_offset;
+               if (use_pde)
+                       src_L0_ofs = m->large_page_copy_ofs + sram_offset;
+               else
+                       src_L0_ofs = xe_migrate_vm_addr(pt_slot, 0) + sram_offset;
                dst_L0_ofs = xe_migrate_vram_ofs(xe, vram_addr, false);

        } else {
                src_L0_ofs = xe_migrate_vram_ofs(xe, vram_addr, false);
-               dst_L0_ofs = xe_migrate_vm_addr(pt_slot, 0) + sram_offset;
+               if (use_pde)
+                       dst_L0_ofs = m->large_page_copy_ofs + sram_offset;
+               else
+                       dst_L0_ofs = xe_migrate_vm_addr(pt_slot, 0) + sram_offset;
        }

        bb->cs[bb->len++] = MI_BATCH_BUFFER_END;

author maintainer
#2 lore raw
Quoted 93 lines · Stuart
Quoted 76 lines · Matthew Brost

Using 2M pages in xe_migrate_vram has two benefits: we issue fewer instructions per 2M copy (1 vs. 512), and the cache hit rate should be
higher. This results in increased copy engine bandwidth, as shown by benchmark IGTs.

Enable 2M pages by reserving PDEs in the migrate VM and using 2M pages
in xe_migrate_vram if the DMA address order matches 2M.

While here, correct build_pt_update_batch_sram to handle PAGE_SIZE > 4K.

v2:
 - Reuse build_pt_update_batch_sram (Stuart)
 - Fix build_pt_update_batch_sram for PAGE_SIZE > 4K v3:
 - More fixes for PAGE_SIZE > 4K, align chunk, decrement chunk as needed
 - Use stack incr var in xe_migrate_vram_use_pde (Stuart)

---
 drivers/gpu/drm/xe/xe_migrate.c | 71 ++++++++++++++++++++++++++++--- --

 1 file changed, 61 insertions(+), 10 deletions(-)
drivers/gpu/drm/xe/xe_migrate.c +1 -0
index 57e6d5a8ac39..6bfda6441836 100644
@@ -56,6 +56,13 @@ struct xe_migrate {
         u64 usm_batch_base_ofs;
         /** @cleared_mem_ofs: VM offset of @cleared_bo. */
         u64 cleared_mem_ofs;
+       /** @large_page_copy_ofs: VM offset of 2M pages used for

large copies */
+       u64 large_page_copy_ofs;
+       /**
+        * @large_page_copy_pdes: BO offset to writeout 2M pages (PDEs) used for
+        * large copies
+        */
+       u64 large_page_copy_pdes;
        /**
         * @fence: dma-fence representing the last migration job batch.
         * Protected by @job_mutex.

drivers/gpu/drm/xe/xe_migrate.c +0 -0
@@ -287,6 +294,12 @@ static int xe_migrate_prepare_vm(struct xe_tile
 *tile, struct xe_migrate *m,
                           (i + 1) * 8, u64, entry);
         }


+       /* Reserve 2M PDEs */
+       level = 1;
+       m->large_page_copy_ofs = NUM_PT_SLOTS << xe_pt_shift(level); +       m->large_page_copy_pdes = map_ofs + XE_PAGE_SIZE * level + +               NUM_PT_SLOTS * 8;
+
        /* Set up a 1GiB NULL mapping at 255GiB offset. */ level = 2;
        xe_map_wr(xe, &bo->vmap, map_ofs + XE_PAGE_SIZE * level + 255
* 8, u64,

drivers/gpu/drm/xe/xe_migrate.c +0 -0
@@ -1741,16 +1754,19 @@ static u32 pte_update_cmd_size(u64 size)
  static void build_pt_update_batch_sram(struct xe_migrate *m,

                                       struct xe_bb *bb, u32 pt_offset,
                                       struct drm_pagemap_addr *sram_addr,
-                                      u32 size)
+                                      u32 size, int level) {
        u16 pat_index = tile_to_xe(m->tile)->pat.idx[XE_CACHE_WB]; +       u64 gpu_page_size = 0x1ull << xe_pt_shift(level); u32 ptes;

Quoted 8 lines

        int i = 0;

-       ptes = DIV_ROUND_UP(size, XE_PAGE_SIZE);
+       ptes = DIV_ROUND_UP(size, gpu_page_size);
        while (ptes) {
                u32 chunk = min(MAX_PTE_PER_SDI, ptes);

+               chunk = ALIGN_DOWN(chunk, PAGE_SIZE / XE_PAGE_SIZE);

Ok I see what you're doing here now (also responding to your comment in the previous revision). I actually think we should split this into two patches then: first patch does the support for arch page size > 4k and second patch adds the 2MB PDE update. This makes it easier to understand the sequence when we look back later to see why we have this change.

Quoted 4 lines

Or otherwise I think you should be more clear in the commit message about the two pieces of this patch.

Other than that though the rest of the patch lgtm.

Sure, I'll just split this.

Matt

Quoted 135 lines

Thanks,
Stuart

Quoted 130 lines

+
                bb->cs[bb->len++] = MI_STORE_DATA_IMM | MI_SDI_NUM_QW(chunk);
                bb->cs[bb->len++] = pt_offset; bb->cs[bb->len++] = 0;

drivers/gpu/drm/xe/xe_migrate.c +0 -0
@@ -1759,22 +1775,46 @@ static void build_pt_update_batch_sram(struct
 xe_migrate *m,
                 ptes -= chunk;


                while (chunk--) {
-                       u64 addr = sram_addr[i].addr & PAGE_MASK; +                       u64 addr = sram_addr[i].addr & ~(gpu_page_size - 1);

                        xe_tile_assert(m->tile, sram_addr[i].proto == DRM_INTERCONNECT_SYSTEM); xe_tile_assert(m->tile, addr);

drivers/gpu/drm/xe/xe_migrate.c +2 -0
+
+again:

                        addr = m->q->vm->pt_ops->pte_encode_addr(m-

Quoted 1 line

tile->xe,


addr, pat_index,
-                                                                0, false, 0);
+
level, false, 0);
                        bb->cs[bb->len++] = lower_32_bits(addr); bb->cs[bb->len++] = upper_32_bits(addr);
-                       i++;
+                       if (gpu_page_size < PAGE_SIZE) { +                               addr += XE_PAGE_SIZE;
+                               if (sram_addr[i].addr + PAGE_SIZE != addr) {
+                                       chunk--;
+                                       goto again;
+                               }
+                               i++;
+                       } else {
+                               i += gpu_page_size / PAGE_SIZE; +                       }
                }
        }
 }

+static bool xe_migrate_vram_use_pde(struct drm_pagemap_addr *sram_addr,
+                                   unsigned long size)

drivers/gpu/drm/xe/xe_migrate.c +11 -0
+{
+       u32 large_size = (0x1 << xe_pt_shift(1));
+       unsigned long i, incr = large_size / PAGE_SIZE;;
+
+       for (i = 0; i < DIV_ROUND_UP(size, PAGE_SIZE); i += incr)
+               if (PAGE_SIZE << sram_addr[i].order != large_size)
+                       return false;
+
+       return true;
+}
+

 enum xe_migrate_copy_dir {
        XE_MIGRATE_COPY_TO_VRAM,
        XE_MIGRATE_COPY_TO_SRAM,

drivers/gpu/drm/xe/xe_migrate.c +1 -0
@@ -1804,6 +1844,7 @@ static struct dma_fence *xe_migrate_vram(struct
 xe_migrate *m,
                 PAGE_SIZE : 4;
         int err;
         unsigned long i, j;
+       bool use_pde = xe_migrate_vram_use_pde(sram_addr, len +
 sram_offset);


        if (drm_WARN_ON(&xe->drm, (len & XE_CACHELINE_MASK) || (sram_offset | vram_addr) & XE_CACHELINE_MASK))

drivers/gpu/drm/xe/xe_migrate.c +0 -0
@@ -1828,7 +1869,7 @@ static struct dma_fence *xe_migrate_vram(struct
 xe_migrate *m,
          * struct drm_pagemap_addr. Ensure this is the case even with

higher
         * orders.
         */
-       for (i = 0; i < npages;) {
+       for (i = 0; !use_pde && i < npages;) {
                unsigned int order = sram_addr[i].order;
                for (j = 1; j < NR_PAGES(order) && i + j < npages; j++)

drivers/gpu/drm/xe/xe_migrate.c +0 -0
@@ -1838,16 +1879,26 @@ static struct dma_fence
 *xe_migrate_vram(struct xe_migrate *m,
                 i += NR_PAGES(order);
         }


-       build_pt_update_batch_sram(m, bb, pt_slot * XE_PAGE_SIZE, -                                  sram_addr, len + sram_offset); +       if (use_pde)
+               build_pt_update_batch_sram(m, bb, m-

Quoted 1 line

large_page_copy_pdes,

+                                          sram_addr, len + sram_offset, 1);
+       else
+               build_pt_update_batch_sram(m, bb, pt_slot * XE_PAGE_SIZE,
+                                          sram_addr, len + sram_offset, 0);

        if (dir == XE_MIGRATE_COPY_TO_VRAM) {
-               src_L0_ofs = xe_migrate_vm_addr(pt_slot, 0) + sram_offset;
+               if (use_pde)
+                       src_L0_ofs = m->large_page_copy_ofs + sram_offset;
+               else
+                       src_L0_ofs = xe_migrate_vm_addr(pt_slot, 0) + sram_offset;
                dst_L0_ofs = xe_migrate_vram_ofs(xe, vram_addr, false);

        } else {
                src_L0_ofs = xe_migrate_vram_ofs(xe, vram_addr, false);
-               dst_L0_ofs = xe_migrate_vm_addr(pt_slot, 0) + sram_offset;
+               if (use_pde)
+                       dst_L0_ofs = m->large_page_copy_ofs + sram_offset;
+               else
+                       dst_L0_ofs = xe_migrate_vm_addr(pt_slot, 0) + sram_offset;
        }

        bb->cs[bb->len++] = MI_BATCH_BUFFER_END;