Skip to content

Commit 4126cb3

Browse files
matt-auldrodrigovivi
authored andcommitted
drm/xe/migrate: don't overflow max copy size
With non-page aligned copy, we need to use 4 byte aligned pitch, however the size itself might still be close to our maximum of ~8M, and so the dimensions of the copy can easily exceed the S16_MAX limit of the copy command leading to the following assert: xe 0000:03:00.0: [drm] Assertion `size / pitch <= ((s16)(((u16)~0U) >> 1))` failed! platform: BATTLEMAGE subplatform: 1 graphics: Xe2_HPG 20.01 step A0 media: Xe2_HPM 13.01 step A1 tile: 0 VRAM 10.0 GiB GT: 0 type 1 WARNING: CPU: 23 PID: 10605 at drivers/gpu/drm/xe/xe_migrate.c:673 emit_copy+0x4b5/0x4e0 [xe] To fix this account for the pitch when calculating the number of current bytes to copy. Fixes: 270172f ("drm/xe: Update xe_ttm_access_memory to use GPU for non-visible access") Signed-off-by: Matthew Auld <[email protected]> Cc: Maciej Patelczyk <[email protected]> Cc: Matthew Brost <[email protected]> Reviewed-by: Stuart Summers <[email protected]> Link: https://lore.kernel.org/r/[email protected] (cherry picked from commit 8c2d61e) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 9d7a1cb commit 4126cb3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/gpu/drm/xe/xe_migrate.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,6 +1887,12 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo,
18871887
else
18881888
current_bytes = min_t(int, bytes_left, cursor.size);
18891889

1890+
if (current_bytes & ~PAGE_MASK) {
1891+
int pitch = 4;
1892+
1893+
current_bytes = min_t(int, current_bytes, S16_MAX * pitch);
1894+
}
1895+
18901896
if (fence)
18911897
dma_fence_put(fence);
18921898

0 commit comments

Comments
 (0)