]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/migrate: don't misalign current bytes
authorMatthew Auld <matthew.auld@intel.com>
Fri, 10 Oct 2025 16:20:21 +0000 (17:20 +0100)
committerMatthew Auld <matthew.auld@intel.com>
Wed, 15 Oct 2025 14:26:51 +0000 (15:26 +0100)
If current bytes exceeds the max copy size, ensure the clamped size
still accounts for the XE_CACHELINE_BYTES alignment, otherwise we
trigger the assert in xe_migrate_vram with the size now being out of
alignment.

Fixes: 8c2d61e0e916 ("drm/xe/migrate: don't overflow max copy size")
Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/6212
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Stuart Summers <stuart.summers@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://lore.kernel.org/r/20251010162020.190962-2-matthew.auld@intel.com
drivers/gpu/drm/xe/xe_migrate.c

index 4ca48dd1cfd8df3f86dae1b037b0a66344cf1d08..3112c966c67d7d1189bf4ba0e1e827e35aec4ca8 100644 (file)
@@ -2176,7 +2176,9 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo,
                if (current_bytes & ~PAGE_MASK) {
                        int pitch = 4;
 
-                       current_bytes = min_t(int, current_bytes, S16_MAX * pitch);
+                       current_bytes = min_t(int, current_bytes,
+                                             round_down(S16_MAX * pitch,
+                                                        XE_CACHELINE_BYTES));
                }
 
                __fence = xe_migrate_vram(m, current_bytes,