]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe/migrate: Fix alignment check
authorLucas De Marchi <lucas.demarchi@intel.com>
Thu, 10 Jul 2025 21:34:41 +0000 (14:34 -0700)
committerLucas De Marchi <lucas.demarchi@intel.com>
Fri, 11 Jul 2025 19:40:58 +0000 (12:40 -0700)
The check would fail if the address is unaligned, but not when
accounting the offset. Instead of `buf | offset` it should have
been `buf + offset`. To make it more readable and also drop the
uintptr_t, just use the IS_ALIGNED() macro.

Fixes: 270172f64b11 ("drm/xe: Update xe_ttm_access_memory to use GPU for non-visible access")
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://lore.kernel.org/r/20250710-migrate-aligned-v1-1-44003ef3c078@intel.com
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
drivers/gpu/drm/xe/xe_migrate.c

index 2adf95d35c3161895b6b3b9a2b335904ec09a9e0..ba1cff2e4cda3f6154707b25e5b8d0e0ff062822 100644 (file)
@@ -1817,8 +1817,8 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo,
        xe_bo_assert_held(bo);
 
        /* Use bounce buffer for small access and unaligned access */
-       if (len & XE_CACHELINE_MASK ||
-           ((uintptr_t)buf | offset) & XE_CACHELINE_MASK) {
+       if (!IS_ALIGNED(len, XE_CACHELINE_BYTES) ||
+           !IS_ALIGNED((unsigned long)buf + offset, XE_CACHELINE_BYTES)) {
                int buf_offset = 0;
 
                /*