Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: Add more checks to discovery fetch

Add more checks for valid vram size and log error, if any.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Lijo Lazar and committed by
Alex Deucher
719d84f8 4e696906

+13 -3
+13 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
··· 270 270 static int amdgpu_discovery_read_binary_from_mem(struct amdgpu_device *adev, 271 271 uint8_t *binary) 272 272 { 273 + bool sz_valid = true; 273 274 uint64_t vram_size; 274 - u32 msg; 275 275 int i, ret = 0; 276 + u32 msg; 276 277 277 278 if (!amdgpu_sriov_vf(adev)) { 278 279 /* It can take up to a second for IFWI init to complete on some dGPUs, ··· 292 291 } 293 292 } 294 293 295 - vram_size = (uint64_t)RREG32(mmRCC_CONFIG_MEMSIZE) << 20; 294 + vram_size = RREG32(mmRCC_CONFIG_MEMSIZE); 295 + if (!vram_size || vram_size == U32_MAX) 296 + sz_valid = false; 297 + else 298 + vram_size <<= 20; 296 299 297 - if (vram_size) { 300 + if (sz_valid) { 298 301 uint64_t pos = vram_size - DISCOVERY_TMR_OFFSET; 299 302 amdgpu_device_vram_access(adev, pos, (uint32_t *)binary, 300 303 adev->mman.discovery_tmr_size, false); 301 304 } else { 302 305 ret = amdgpu_discovery_read_binary_from_sysmem(adev, binary); 303 306 } 307 + 308 + if (ret) 309 + dev_err(adev->dev, 310 + "failed to read discovery info from memory, vram size read: %llx", 311 + vram_size); 304 312 305 313 return ret; 306 314 }