Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/xe/migrate: Keep access_memory chunks within the transfer limit
@ 2026-10-27 14:52 Mika Kuoppala
  2026-10-27 14:52 ` [PATCH 2/2] drm/xe/tests: Cover a large write to an unaligned bo offset Mika Kuoppala
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Mika Kuoppala @ 2026-10-27 14:52 UTC (permalink / raw)
  To: intel-xe
  Cc: Mika Kuoppala, Matthew Auld, Thomas Hellström, Matthew Brost,
	Jan Maslak

xe_migrate_access_memory() caps each chunk at MAX_PREEMPTDISABLE_TRANSFER,
but xe_migrate_vram() maps the system memory side from the start of the
page the chunk begins in, DIV_ROUND_UP(len + sram_offset, PAGE_SIZE)
pages.

So when buf is mid page, the 'wasted' space at the start of the first
page needs to be taken into account when considering the amount that
can be copied. Otherwise a full chunk needs one page more than the limit
allows, which trips the warning in pte_update_cmd_size() and, on debug
builds, the assert in xe_migrate_vram().

window:  |slot 0|slot 1| ...  |slot 2047|
         0                              8M
data:      [=================================]   starts at sram_offset
           ^ sram_offset                ^ must end here or earlier

This happens for example when the access starts at an unaligned vram
offset.

Fix this by capping the chunk at the limit minus sram_offset.

Seen on BMG with igt@xe_eudebug@vm-access-alignment, which rewrites 24M
and 48M objects from offset 4 through eudebug vm access:

  xe 0000:03:00.0: [drm] Assertion `npages * ((1UL) << 12) <= 0x00800000` failed!
  WARNING: drivers/gpu/drm/xe/xe_migrate.c:2255 at xe_migrate_vram+0xf40/0x15e0 [xe]
  Call Trace:
  xe_migrate_access_memory
  xe_ttm_access_memory
  ttm_bo_access

  WARNING: drivers/gpu/drm/xe/xe_migrate.c:2118 at xe_migrate_vram+0xbb7/0x15e0 [xe]
  Call Trace:
  xe_migrate_access_memory
  xe_ttm_access_memory
  ttm_bo_access

Fixes: 270172f64b11 ("drm/xe: Update xe_ttm_access_memory to use GPU for non-visible access")
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Jan Maslak <jan.maslak@intel.com>
Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 drivers/gpu/drm/xe/xe_migrate.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
index 70408fa0a606..19c37eb31589 100644
--- a/drivers/gpu/drm/xe/xe_migrate.c
+++ b/drivers/gpu/drm/xe/xe_migrate.c
@@ -2611,6 +2611,7 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo,
 		struct dma_fence *__fence;
 		u64 vram_addr = vram_region_gpu_offset(bo->ttm.resource) +
 			cursor.start;
+		unsigned long sram_offset = (unsigned long)buf & ~PAGE_MASK;
 		int current_bytes;
 
 		if (cursor.size > MAX_PREEMPTDISABLE_TRANSFER)
@@ -2619,6 +2620,9 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo,
 		else
 			current_bytes = min_t(int, bytes_left, cursor.size);
 
+		current_bytes = min_t(int, current_bytes,
+				      MAX_PREEMPTDISABLE_TRANSFER - sram_offset);
+
 		{
 			/*
 			 * Optimized copy strategy to minimize number of jobs:
@@ -2676,8 +2680,7 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo,
 			}
 		}
 
-		__fence = xe_migrate_vram(m, current_bytes,
-					  (unsigned long)buf & ~PAGE_MASK,
+		__fence = xe_migrate_vram(m, current_bytes, sram_offset,
 					  &pagemap_addr[current_page],
 					  vram_addr, NULL, write ?
 					  XE_MIGRATE_COPY_TO_VRAM :
-- 
2.53.0


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

end of thread, other threads:[~2026-10-28 10:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-27 14:52 [PATCH 1/2] drm/xe/migrate: Keep access_memory chunks within the transfer limit Mika Kuoppala
2026-10-27 14:52 ` [PATCH 2/2] drm/xe/tests: Cover a large write to an unaligned bo offset Mika Kuoppala
2026-10-27 15:03   ` sashiko-bot
2026-10-27 15:57   ` Matthew Auld
2026-10-27 18:04     ` Mika Kuoppala
2026-10-28 10:07       ` Matthew Auld
2026-10-27 15:26 ` [PATCH 1/2] drm/xe/migrate: Keep access_memory chunks within the transfer limit Matthew Auld
2026-10-27 15:37 ` Jan Maslak
2026-10-27 15:37 ` ✗ CI.checkpatch: warning for series starting with [1/2] " Patchwork
2026-10-27 15:40 ` ✓ CI.KUnit: success " Patchwork
2026-10-27 16:18 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-27 19:52 ` ✓ Xe.CI.FULL: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox