[PATCH] drm/amdgpu: return reserve errors from amdgpu_gfx_kiq_init()

Runyu Xiao <[email protected]>
Newsgroups org.freedesktop.lists.amd-gfx,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <[email protected]>
amdgpu_gfx_kiq_init() reserves kiq->eop_obj after mapping the buffer.
If amdgpu_bo_reserve() fails, the code still unmaps and unreserves the
BO and then returns success.

Return the reserve error, but keep the kunmap cleanup. Only call
amdgpu_bo_unreserve() on the successful-reservation path.

Fixes: 71c37505e7ea ("drm/amdgpu/gfx: move more common KIQ code to amdgpu_gfx.c")
Cc: [email protected]
Assisted-by: Codex:gpt-5
Signed-off-by: Runyu Xiao <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index c5aa465231c4..630d0fd9ac13 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -241,8 +241,11 @@ int amdgpu_gfx_kiq_init(struct amdgpu_device *adev,
 	memset(hpd, 0, hpd_size);
 
 	r = amdgpu_bo_reserve(kiq->eop_obj, true);
-	if (unlikely(r != 0))
+	if (unlikely(r != 0)) {
 		dev_warn(adev->dev, "(%d) reserve kiq eop bo failed\n", r);
+		amdgpu_bo_kunmap(kiq->eop_obj);
+		return r;
+	}
 	amdgpu_bo_kunmap(kiq->eop_obj);
 	amdgpu_bo_unreserve(kiq->eop_obj);
 
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.