Skip to content

Commit e89b384

Browse files
mbrost05rodrigovivi
authored andcommitted
drm/xe/migrate: Update emit_pte to cope with a size level than 4k
emit_pte assumes the size argument is 4k aligned, this may not be true for the PTEs emitted for CSS as seen by below call stack: [ 56.734228] xe_migrate_copy:585: size=327680, ccs_start=327680, css_size=1280,4096 [ 56.734250] xe_migrate_copy:643: size=262144 [ 56.734252] emit_pte:404: ptes=64 [ 56.734255] emit_pte:418: chunk=64 [ 56.734257] xe_migrate_copy:650: size=1024 @ CCS emit PTE [ 56.734259] emit_pte:404: ptes=1 [ 56.734261] emit_pte:418: chunk=1 [ 56.734339] xe_migrate_copy:643: size=65536 [ 56.734342] emit_pte:404: ptes=16 [ 56.734344] emit_pte:418: chunk=16 [ 56.734346] xe_migrate_copy:650: size=256 # CCS emit PTE [ 56.734348] emit_pte:404: ptes=1 [ 56.734350] emit_pte:418: chunk=1 [ 56.734352] xe_res_next:174: size=4096, remaining=0 Update emit_pte to handle sizes less than 4k. Signed-off-by: Matthew Brost <[email protected]> Reviewed-by: Thomas Hellström <[email protected]> Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent c5151fa commit e89b384

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

drivers/gpu/drm/xe/xe_migrate.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,8 @@ static void emit_pte(struct xe_migrate *m,
453453
while (chunk--) {
454454
u64 addr;
455455

456-
XE_BUG_ON(cur->start & (PAGE_SIZE - 1));
457-
456+
addr = xe_res_dma(cur) & PAGE_MASK;
458457
if (is_vram) {
459-
addr = cur->start;
460-
461458
/* Is this a 64K PTE entry? */
462459
if ((m->eng->vm->flags & XE_VM_FLAGS_64K) &&
463460
!(cur_ofs & (16 * 8 - 1))) {
@@ -466,14 +463,12 @@ static void emit_pte(struct xe_migrate *m,
466463
}
467464

468465
addr |= GEN12_PPGTT_PTE_LM;
469-
} else {
470-
addr = xe_res_dma(cur);
471466
}
472467
addr |= PPAT_CACHED | GEN8_PAGE_PRESENT | GEN8_PAGE_RW;
473468
bb->cs[bb->len++] = lower_32_bits(addr);
474469
bb->cs[bb->len++] = upper_32_bits(addr);
475470

476-
xe_res_next(cur, PAGE_SIZE);
471+
xe_res_next(cur, min(size, (u32)PAGE_SIZE));
477472
cur_ofs += 8;
478473
}
479474
}
@@ -615,13 +610,13 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m,
615610
bool copy_system_ccs = copy_ccs && (!src_is_vram || !dst_is_vram);
616611

617612
if (!src_is_vram)
618-
xe_res_first_sg(xe_bo_get_sg(bo), 0, bo->size, &src_it);
613+
xe_res_first_sg(xe_bo_get_sg(bo), 0, size, &src_it);
619614
else
620-
xe_res_first(src, 0, bo->size, &src_it);
615+
xe_res_first(src, 0, size, &src_it);
621616
if (!dst_is_vram)
622-
xe_res_first_sg(xe_bo_get_sg(bo), 0, bo->size, &dst_it);
617+
xe_res_first_sg(xe_bo_get_sg(bo), 0, size, &dst_it);
623618
else
624-
xe_res_first(dst, 0, bo->size, &dst_it);
619+
xe_res_first(dst, 0, size, &dst_it);
625620

626621
if (copy_system_ccs)
627622
xe_res_first_sg(xe_bo_get_sg(bo), xe_bo_ccs_pages_start(bo),

0 commit comments

Comments
 (0)