drm/amdgpu/mes_v12_1: add mes self test
Hello Jack Xiao,
Commit 44e5195fa3d4 ("drm/amdgpu/mes_v12_1: add mes self test") from Jun 11, 2025 (linux-next), leads to the following Smatch static checker warning:
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c:2080 mes_v12_1_test_ring() warn: reusing outside iterator: 'i'
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c
2069 atomic64_set((atomic64_t *)wptr_cpu_addr, wptr);
2070 WDOORBELL64(doorbell_idx, wptr);
2071
2072 for (i = 0; i < adev->usec_timeout; i++) {i is counting usec
2073 if (queue_type == AMDGPU_RING_TYPE_SDMA) {
2074 tmp = le32_to_cpu(*cpu_ptr);
2075 } else {
2076 if (!adev->mes.enable_coop_mode) {
2077 tmp = RREG32_SOC15(GC, GET_INST(GC, xcc_id),
2078 regSCRATCH_REG0);
2079 } else {--> 2080 for (i = 0; i < num_xcc; i++) {
and then re-used to count something else
2081 if (xcc_id != adev->mes.master_xcc_ids[i])
2082 continue;
2083
2084 tmp = RREG32_SOC15(GC, GET_INST(GC, i),
2085 regSCRATCH_REG0);
2086 if (tmp != 0xDEADBEEF)
2087 break;
2088 }
2089 }
2090 }
2091
2092 if (tmp == 0xDEADBEEF)
2093 break;
2094
2095 if (amdgpu_emu_mode == 1)
2096 msleep(1);
2097 else
2098 udelay(1);
2099 }
2100
2101 if (i >= adev->usec_timeout) {
2102 dev_err(adev->dev, "xcc%d: mes self test (%s) failed\n", xcc_id,
2103 queue_type == AMDGPU_RING_TYPE_SDMA ? "sdma" : "compute");
2104
2105 while (halt_if_hws_hang)
2106 schedule();
2107
2108 r = -ETIMEDOUT;
2109 } else {
2110 dev_info(adev->dev, "xcc%d: mes self test (%s) pass\n", xcc_id,
2111 queue_type == AMDGPU_RING_TYPE_SDMA ? "sdma" : "compute");
2112 }
2113
2114 return r;
2115 }This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter