From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: drm/amd/pm: Use guard(mutex) instead of manual lock+unlock Date: Sat, 16 May 2026 12:18:26 +1000 Message-ID: In-Reply-To: <20260508024744.6523-1-andrejhirata@usp.br> References: <20260508024744.6523-1-andrejhirata@usp.br> <20260508024744.6523-1-andrejhirata@usp.br> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review **Bug 1 (critical): Logic inversion in `amdgpu_dpm_is_link_reset_supported`** The original code calls `smu_link_reset_is_support()` only when `is_support_sw_smu(adev)` is **true**: ```c if (is_support_sw_smu(adev)) { mutex_lock(&adev->pm.mutex); support_link_reset = smu_link_reset_is_support(smu); mutex_unlock(&adev->pm.mutex); } ``` The v3 patch inverts the condition: ```c if (is_support_sw_smu(adev)) return false; guard(mutex)(&adev->pm.mutex); return smu_link_reset_is_support(smu); ``` This returns `false` when sw_smu IS supported (should query the function), and calls `smu_link_reset_is_support` when it's NOT supported (should return `false`). The condition should be `if (!is_support_sw_smu(adev))`. Compare with the correctly negated `amdgpu_dpm_mode1_reset` and `amdgpu_dpm_link_reset` conversions in the same patch. **Bug 2 (build-breaking): Missing semicolon in `amdgpu_dpm_is_mode1_reset_supported`** ```c guard(mutex)(&adev->pm.mutex); return smu_mode1_reset_is_support(smu) } ``` Missing semicolon after the `return` statement. **Bug 3 (build-breaking): `return =` syntax errors** Four instances of `return =` instead of `return`: 1. `amdgpu_dpm_smu_i2c_bus_access`: ```c return = pp_funcs->smu_i2c_bus_access(pp_handle, acquire); ``` 2. `amdgpu_dpm_get_pp_table`: ```c return = pp_funcs->get_pp_table(adev->powerplay.pp_handle, table); ``` 3. `amdgpu_dpm_set_fine_grain_clk_vol`: ```c return = pp_funcs->set_fine_grain_clk_vol(adev->powerplay.pp_handle, ...); ``` 4. `amdgpu_dpm_get_display_mode_validation_clocks`: ```c return = pp_funcs->get_display_mode_validation_clocks(adev->powerplay.pp_handle, clocks); ``` All four should be just `return` (no `=`). **Nit: Superfluous `return;` at end of `amdgpu_dpm_get_current_power_state`** ```c *state = adev->pm.dpm.user_state; -out: - mutex_unlock(&adev->pm.mutex); + return; } ``` The trailing `return;` at the end of a void function is unnecessary. The old `goto out` -> `return;` conversion is correct, but the one at the very end of the function body should be dropped. **Observation: The RESEND/v1 patch did not have any of these bugs** -- it was a simpler mechanical conversion that kept `ret` variables and only swapped lock/unlock for `guard()`. The bugs were introduced in v2/v3 during the more aggressive refactoring to use direct `return f()` and early-return patterns. It would be worth running a `make` build test before submitting v4. --- Generated by Claude Code Patch Reviewer