All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/4] drm/xe/xe_migrate: Fix memory corruption with unaligned dst in MEM_COPY
@ 2026-10-14 14:27 Jan Maslak
  2026-10-14 14:27 ` [PATCH v5 1/4] drm/xe/xe_migrate: Fix page tracking in access_memory Jan Maslak
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Jan Maslak @ 2026-10-14 14:27 UTC (permalink / raw)
  To: intel-xe
  Cc: matthew.auld, matthew.brost, thomas.hellstrom, rodrigo.vivi,
	Jan Maslak

MEM_COPY_CMD in MATRIX_COPY mode produces incorrect results when the
destination address is not aligned to the pitch. This manifests as
memory corruption during xe_migrate_access_memory() reads from VRAM.

The probable cause appears to be a hardware requirement that the
destination address must be aligned to the pitch when using MATRIX_COPY
mode.

This was observed on BMG during xe_migrate_access_memory() calls where
the destination offset within a page was not aligned to the computed
pitch value.

Patch 1 fixes an independent page tracking bug in
xe_migrate_access_memory().

Patch 2 adds the minimal workaround by selecting a pitch that is aligned
to both the copy length and the destination address.

Patch 3 adds a follow-up optimization to reduce the number of linear
copy jobs for unaligned destinations.

Patch 4 adds a KUnit live test that exercises xe_migrate_access_memory()
with various unaligned destination offsets to prevent regressions.

Tested on BMG (Battlemage).

v2:
 - Split the original xe_migrate change into a minimal workaround,
   a standalone page tracking fix, and a follow-up optimization
   per Matthew Auld's review feedback
v3:
 - Used a helper function and added an additional comment in patch 3
   per Matthew Auld's review feedback
v4:
 - Rebased onto current drm-xe-next
 - Moved the page tracking fix before the pitch workaround, so the
   series stays correct at every commit
 - Patch 2: free the batch buffer when returning -EOPNOTSUPP instead
   of leaking it
 - Patch 3: use a single max_bytes limit to shorten an over-long line
 - Patch 4: validate the BO into VRAM and wait for it to be idle
   after locking it, before accessing it
v5:
 - Patch 3: drop the pitch variable from xe_migrate_access_memory(),
   which was set but no longer used (fixes an unused-but-set-variable
   build warning/error)

Christoph Manszewski (2):
  drm/xe/xe_migrate: Fix page tracking in access_memory
  drm/xe/xe_migrate: Align MEM_COPY pitch with destination address

Jan Maslak (2):
  drm/xe/xe_migrate: Optimize unaligned access_memory copies
  drm/xe/tests: Add xe_migrate_access_memory subtest

 drivers/gpu/drm/xe/tests/xe_migrate.c | 302 ++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_migrate.c       | 173 +++++++++++++--
 2 files changed, 455 insertions(+), 20 deletions(-)


base-commit: f7f8e453bef8ea29ae3615e5308eb2d4c250545d
-- 
2.43.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-10-14 16:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-14 14:27 [PATCH v5 0/4] drm/xe/xe_migrate: Fix memory corruption with unaligned dst in MEM_COPY Jan Maslak
2026-10-14 14:27 ` [PATCH v5 1/4] drm/xe/xe_migrate: Fix page tracking in access_memory Jan Maslak
2026-10-14 14:47   ` sashiko-bot
2026-10-14 14:27 ` [PATCH v5 2/4] drm/xe/xe_migrate: Align MEM_COPY pitch with destination address Jan Maslak
2026-10-14 14:41   ` sashiko-bot
2026-10-14 14:27 ` [PATCH v5 3/4] drm/xe/xe_migrate: Optimize unaligned access_memory copies Jan Maslak
2026-10-14 14:36   ` sashiko-bot
2026-10-14 14:27 ` [PATCH v5 4/4] drm/xe/tests: Add xe_migrate_access_memory subtest Jan Maslak
2026-10-14 14:45   ` sashiko-bot
2026-10-14 16:11 ` ✗ CI.checkpatch: warning for drm/xe/xe_migrate: Fix memory corruption with unaligned dst in MEM_COPY (rev5) Patchwork
2026-10-14 16:13 ` ✓ CI.KUnit: success " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.