diff --git a/sys/dev/drm/amd/amdgpu/amdgpu_psp.c b/sys/dev/drm/amd/amdgpu/amdgpu_psp.c --- a/sys/dev/drm/amd/amdgpu/amdgpu_psp.c +++ b/sys/dev/drm/amd/amdgpu/amdgpu_psp.c @@ -130,8 +130,21 @@ ret = psp_cmd_submit(psp, ucode, psp->cmd_buf_mc_addr, fence_mc_addr, index); - while (*((unsigned int *)psp->fence_buf) != index) { - msleep(1); + if (ret) { + DRM_ERROR("psp_cmd_submit failed (%d), index=%d\n", ret, index); + return ret; + } + /* Bounded wait: previously no timeout, causing indefinite hangs. */ + { + unsigned int timeout; + for (timeout = 0; + *((unsigned int *)psp->fence_buf) != index && timeout < 100000; + timeout++) + msleep(1); + if (*((unsigned int *)psp->fence_buf) != index) { + DRM_ERROR("psp fence timed out waiting for index=%d\n", index); + return -ETIME; + } } /* the status field must be 0 after FW is loaded */