AMD General

Reviewed-by: Hawking Zhang <[email protected]>

Regards,
Hawking
-----Original Message-----
From: Kamal, Asad <[email protected]>
Sent: Thursday, June 18, 2026 1:12 PM
To: [email protected]
Cc: Lazar, Lijo <[email protected]>; Zhang, Hawking <[email protected]>; 
Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Deucher, Alexander 
<[email protected]>; Wang, Yang(Kevin) <[email protected]>; Kamal, 
Asad <[email protected]>
Subject: [PATCH v2] drm/amdgpu: validate XCP topology counts before division

In aqua_vanjaram_get_xcp_res_info(), max_res[i] can be zero.
When res_lt_xcp is true the code divides num_xcp by max_res[i], causing a 
divide fault.

Skip the loop body for absent resources.

v2: Remove redundant checks (Lijo)

Signed-off-by: Asad Kamal <[email protected]>
Reviewed-by: Lijo Lazar <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c 
b/drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c
index 72ea37dbfea8..1c11cc280599 100644
--- a/drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c
+++ b/drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c
@@ -273,8 +273,10 @@ static int aqua_vanjaram_get_xcp_res_info(struct 
amdgpu_xcp_mgr *xcp_mgr,
        xcp_cfg->num_res = ARRAY_SIZE(max_res);

        for (i = 0; i < xcp_cfg->num_res; i++) {
-               res_lt_xcp = max_res[i] < num_xcp;
                xcp_cfg->xcp_res[i].id = i;
+               if (!max_res[i])
+                       continue;
+               res_lt_xcp = max_res[i] < num_xcp;
                xcp_cfg->xcp_res[i].num_inst =
                        res_lt_xcp ? 1 : max_res[i] / num_xcp;
                xcp_cfg->xcp_res[i].num_inst =
--
2.46.0

Reply via email to