From: Ivan Lipski <[email protected]> [Why&How] Building the UALink code on x86-32 (ARCH=i386) triggers -Werror failures due to pointer/integer width mismatches:
- In amdgpu_ualink_get_wb_addr(), casting the void * CPU addresses (rb_cpu_addr/rptr_cpu_addr) to u64 causes a pointer-to-int-cast and int-to-pointer-cast warning where pointers are 32-bit. Use uintptr_t for the writeback address so it matches pointer width on both 32- and 64-bit targets. - In amdgpu_ualink_peer_remote_init(), the doorbell NPA constant '0xFFFUL << 40' overflows on 32-bit where unsigned long is 32-bit, triggering a shift-count-overflow warning. Use a ULL literal so the constant is 64-bit on all architectures. No functional change on 64-bit. Assisted-by: Copilot:Claude-Opus-4.8 Signed-off-by: Ivan Lipski <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c index f82bc9a9d083..ad8cc95e6cfa 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c @@ -5674,15 +5674,16 @@ static void amdgpu_ualink_get_wb_addr(struct amdgpu_device *adev, struct amdgpu_ualink_remote *remote = to_remote(adev); u32 accel_id = ualink_accel_id(adev); u32 rb_size = AMDGPU_GPU_PAGE_ALIGN(2 * AMDGPU_UALINK_RB_SIZE); - u64 wb, npa; + uintptr_t wb; + u64 npa; u32 offset = 0; if (ualink_addr_mode(adev) == AMDGPU_UALINK_ADDR_MODE_SOURCE_IDENT) { - wb = (u64)remote->rb_cpu_addr + rb_size * remote->num_accel; + wb = (uintptr_t)remote->rb_cpu_addr + rb_size * remote->num_accel; npa = amdgpu_ualink_npa_addr(adev, RB_TYPE_TAILPTR, remote_accel_id, accel_id); } else { - wb = (u64)remote->rptr_cpu_addr; + wb = (uintptr_t)remote->rptr_cpu_addr; npa = remote->rptr_npa; npa |= (u64)accel_id << AMDGPU_UALINK_GART_NPA_ADDR_GPUID_SHIFT; } @@ -5914,7 +5915,7 @@ static int amdgpu_ualink_peer_remote_init(struct amdgpu_device *adev) * 1 - PMI1 Remote TLB Shootdown * ReqAddr[5:0] = 6'h0 */ - npa = 0xFFFUL << 40 | (u64)dst_accel_id << 30; + npa = 0xFFFULL << 40 | (u64)dst_accel_id << 30; r = amdgpu_ualink_gart_map(adev, 1, npa, &interrupt->mm_node_doorbell, flags); if (r) break; -- 2.43.0
