Skip to content

Commit 057a7d6

Browse files
committed
drm/xe/migrate: Fix alignment check
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: 270172f ("drm/xe: Update xe_ttm_access_memory to use GPU for non-visible access") Reviewed-by: Matthew Brost <[email protected]> Reviewed-by: Matthew Auld <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lucas De Marchi <[email protected]> (cherry picked from commit 81e139d) Signed-off-by: Lucas De Marchi <[email protected]>
1 parent 3155ac8 commit 057a7d6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpu/drm/xe/xe_migrate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,8 +1817,8 @@ int xe_migrate_access_memory(struct xe_migrate *m, struct xe_bo *bo,
18171817
xe_bo_assert_held(bo);
18181818

18191819
/* Use bounce buffer for small access and unaligned access */
1820-
if (len & XE_CACHELINE_MASK ||
1821-
((uintptr_t)buf | offset) & XE_CACHELINE_MASK) {
1820+
if (!IS_ALIGNED(len, XE_CACHELINE_BYTES) ||
1821+
!IS_ALIGNED((unsigned long)buf + offset, XE_CACHELINE_BYTES)) {
18221822
int buf_offset = 0;
18231823

18241824
/*

0 commit comments

Comments
 (0)