All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/4] drm/xe/xe_migrate: Fix memory corruption with unaligned dst in MEM_COPY
@ 2026-10-14 13:46 Jan Maslak
  2026-10-14 13:46 ` [PATCH v4 1/4] drm/xe/xe_migrate: Fix page tracking in access_memory Jan Maslak
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Jan Maslak @ 2026-10-14 13:46 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

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       | 176 +++++++++++++--
 2 files changed, 459 insertions(+), 19 deletions(-)


base-commit: f7f8e453bef8ea29ae3615e5308eb2d4c250545d
-- 
2.43.0


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

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

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-14 13:46 [PATCH v4 0/4] drm/xe/xe_migrate: Fix memory corruption with unaligned dst in MEM_COPY Jan Maslak
2026-10-14 13:46 ` [PATCH v4 1/4] drm/xe/xe_migrate: Fix page tracking in access_memory Jan Maslak
2026-10-14 13:46 ` [PATCH v4 2/4] drm/xe/xe_migrate: Align MEM_COPY pitch with destination address Jan Maslak
2026-10-14 13:58   ` sashiko-bot
2026-10-14 13:46 ` [PATCH v4 3/4] drm/xe/xe_migrate: Optimize unaligned access_memory copies Jan Maslak
2026-10-14 13:57   ` sashiko-bot
2026-10-14 13:46 ` [PATCH v4 4/4] drm/xe/tests: Add xe_migrate_access_memory subtest Jan Maslak
2026-10-14 13:58   ` sashiko-bot

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.