[PATCH v2] drm/amdgpu: Fix realloc of ptr

2022-02-28 Thread trix
From: Tom Rix Clang static analysis reports this error amdgpu_debugfs.c:1690:9: warning: 1st function call argument is an uninitialized value tmp = krealloc_array(tmp, i + 1, ^~~ realloc uses tmp, so tmp can not be garbage. And the return needs to be checked.

[PATCH] drm/amdgpu: Fix realloc of ptr

2022-02-28 Thread trix
From: Tom Rix Clang static analysis reports this error amdgpu_debugfs.c:1690:9: warning: 1st function call argument is an uninitialized value tmp = krealloc_array(tmp, i + 1, ^~~ realloc will free tmp, so tmp can not be garbage. And the return needs to be chec

[PATCH] drm/amdgpu: fix printk format for size_t variable

2022-02-21 Thread trix
From: Tom Rix On mips64 allyesconfig, there is this build break amdgpu_discovery.c:671:35: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'size_t' {aka 'unsigned int'} DRM_DEBUG("match:%d @ ip_offset:%ld", ii, ip_offset); For size_t, use %zu. Fixes: a6c40

[PATCH] drm/amdkfd: rework criu_restore_bos error handling

2022-02-18 Thread trix
From: Tom Rix Clang static analysis reports this problem kfd_chardev.c:2327:2: warning: 1st function call argument is an uninitialized value kvfree(bo_privs); ^~~~ If the copy_from_users(bo_buckets, ...) fails, there is a jump to the generic error handler at exit:. The freeing

[PATCH] drm/amdkfd: fix typo in setting enum value

2022-02-17 Thread trix
From: Tom Rix Clang build fails with kfd_packet_manager_v9.c:267:3: error: implicit conversion from enumeration type 'enum mes_map_queues_extended_engine_sel_enum' to different enumeration type 'enum mes_unmap_queues_extended_engine_sel_enum' extended_engine_sel__mes_map_queues__sdma0_to

[PATCH] drm/amdgpu: fix amdgpu_ras_block_late_init error handler

2022-02-17 Thread trix
From: Tom Rix Clang build fails with amdgpu_ras.c:2416:7: error: variable 'ras_obj' is used uninitialized whenever 'if' condition is true if (adev->in_suspend || amdgpu_in_reset(adev)) { ^ amdgpu_ras.c:2453:6: note: uninitialized use occurs here if

[PATCH] drm/amdgpu: check return status before using stable_pstate

2022-02-14 Thread trix
From: Tom Rix Clang static analysis reports this problem amdgpu_ctx.c:616:26: warning: Assigned value is garbage or undefined args->out.pstate.flags = stable_pstate; ^ ~ amdgpu_ctx_stable_pstate can fail without setting stable_pstate. So check. Fixes: 8c

[PATCH] drm/amdkfd: fix loop error handling

2022-02-10 Thread trix
From: Tom Rix Clang static analysis reports this problem kfd_chardev.c:2594:16: warning: The expression is an uninitialized value. The computed value will also be garbage while (ret && i--) { ^~~ i is a loop variable and this block unwinds a problem in the loop. W

[PATCH] drm/amdkfd: fix freeing an unset pointer

2022-02-09 Thread trix
From: Tom Rix clang static analysis reports this problem kfd_chardev.c:2092:2: warning: 1st function call argument is an uninitialized value kvfree(bo_privs); ^~~~ When bo_buckets alloc fails, it jumps to an error handler that frees the yet to be allocated bo_privs.

[PATCH] drm/amd/pm: fix error handling

2022-02-07 Thread trix
From: Tom Rix clang static analysis reports this error amdgpu_smu.c:2289:9: warning: Called function pointer is null (null dereference) return smu->ppt_funcs->emit_clk_levels( ^~~~ There is a logic error in the earlier check of emit_clk_levels

[PATCH] drm/amdgpu: initialize reg_access_ctrl

2022-01-31 Thread trix
From: Tom Rix clang build fails with amdgpu_virt.c:878:51: error: variable 'reg_access_ctrl' is uninitialized when used here ... + 4 * reg_access_ctrl->scratch_reg0; ^~~ The reg_access_ctrl ptr is never initialized, so initialize once we know it is supported. Fixes:

[PATCH v2] drm/amd/pm: return -ENOTSUPP if there is no get_dpm_ultimate_freq function

2022-01-24 Thread trix
From: Tom Rix clang static analysis reports this represenative problem amdgpu_smu.c:144:18: warning: The left operand of '*' is a garbage value return clk_freq * 100; ^ If there is no get_dpm_ultimate_freq function, smu_get_dpm_freq_range returns success without s

[PATCH] drm/amd/pm: set min, max to 0 if there is no get_dpm_ultimate_freq function

2022-01-24 Thread trix
From: Tom Rix clang static analysis reports this represenative problem amdgpu_smu.c:144:18: warning: The left operand of '*' is a garbage value return clk_freq * 100; ^ If there is no get_dpm_ultimate_freq function, smu_get_dpm_freq_range returns success without s

[PATCH] drm/amdkfd: simplify else if to else check of MIGRATION_COPY_DIR

2022-01-24 Thread trix
From: Tom Rix The enum MIGRATION_COPY_DIR type has 2 values. So the else-if can be converted to an else. Signed-off-by: Tom Rix --- drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/driver

[PATCH] drm/amdkfd: match the signatures of the real and stub kgd2kfd_probe()

2021-09-30 Thread trix
From: Tom Rix When CONFIG_HSA_AMD=n this there is this error amdgpu_amdkfd.c:75:56: error: incompatible type for argument 2 of ‘kgd2kfd_probe’ 75 | adev->kfd.dev = kgd2kfd_probe((struct kgd_dev *)adev, vf); amdgpu_amdkfd.h:349:17: note: declared here 349 | struct kfd_dev *kgd2kfd_probe(s

[PATCH] drm/amdgpu: initialize amdgpu_ras_query_error_count() error count parameters

2021-07-05 Thread trix
From: Tom Rix Static analysis reports this problem amdgpu_ras.c:2324:2: warning: 2nd function call argument is an uninitialized value atomic_set(&con->ras_ce_count, ce_count); ^~~~ ce_count is normally set by the earlier call to amdgpu_ras_qu

[PATCH] drm/amd/pm: initialize variable

2021-04-30 Thread trix
From: Tom Rix Static analysis reports this problem amdgpu_pm.c:478:16: warning: The right operand of '<' is a garbage value for (i = 0; i < data.nums; i++) { ^ ~ In some cases data is not set. Initialize to 0 and flag not setting data as an error with the existing che

[PATCH] drm/radeon: remove h from printk format specifier

2020-12-15 Thread trix
From: Tom Rix See Documentation/core-api/printk-formats.rst. h should no longer be used in the format specifier for printk. Signed-off-by: Tom Rix --- drivers/gpu/drm/radeon/radeon_uvd.c | 2 +- drivers/gpu/drm/radeon/radeon_vce.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff

[PATCH] drm/amdgpu: remove h from printk format specifier

2020-12-15 Thread trix
From: Tom Rix See Documentation/core-api/printk-formats.rst. h should no longer be used in the format specifier for printk. Signed-off-by: Tom Rix --- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 4 +

[PATCH] drm/amdgpu/display: remove trailing semicolon in macro definition

2020-11-30 Thread trix
From: Tom Rix The macro use will already have a semicolon. Signed-off-by: Tom Rix --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index f9c81bc21ba4..301e93c9e

[RFC] MAINTAINERS tag for cleanup robot

2020-11-23 Thread trix
A difficult part of automating commits is composing the subsystem preamble in the commit log. For the ongoing effort of a fixer producing one or two fixes a release the use of 'treewide:' does not seem appropriate. It would be better if the normal prefix was used. Unfortunately normal is not con

[PATCH] drm/amd/display: remove unneeded semicolon

2020-10-27 Thread trix
From: Tom Rix A semicolon is not needed after a switch statement. Signed-off-by: Tom Rix --- drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c | 2 +- drivers/gpu/drm/amd/display/modules/hdcp/hdcp_log.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gp

[PATCH] drm/amdgpu: remove unneeded semicolon

2020-10-27 Thread trix
From: Tom Rix A semicolon is not needed after a switch statement. Signed-off-by: Tom Rix --- drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c b

Subject: [RFC] clang tooling cleanups

2020-10-27 Thread trix
This rfc will describe An upcoming treewide cleanup. How clang tooling was used to programatically do the clean up. Solicit opinions on how to generally use clang tooling. The clang warning -Wextra-semi-stmt produces about 10k warnings. Reviewing these, a subset of semicolon after a switch looks s

[PATCH] drm/amdgpu: remove unneeded break

2020-10-19 Thread trix
From: Tom Rix A break is not needed if it is preceded by a return or break Signed-off-by: Tom Rix --- drivers/gpu/drm/amd/display/dc/dce/dce_transform.c | 1 - drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c | 7 --- drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c | 7

[RFC] treewide: cleanup unreachable breaks

2020-10-19 Thread trix
From: Tom Rix This is a upcoming change to clean up a new warning treewide. I am wondering if the change could be one mega patch (see below) or normal patch per file about 100 patches or somewhere half way by collecting early acks. clang has a number of useful, new warnings see https://clang.llv

[PATCH] drm/amdgpu: add missing newline at eof

2020-10-14 Thread trix
From: Tom Rix Representative checkpatch.pl warning WARNING: adding a line without newline at end of file 30: FILE: drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.h:30: +#endif Signed-off-by: Tom Rix --- drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_4_1_sh_mask.h | 2 +- drivers/gpu/drm/amd/pm

[PATCH] drm/radeon: fix double free

2020-07-06 Thread trix
From: Tom Rix clang static analysis flags this error drivers/gpu/drm/radeon/ci_dpm.c:5652:9: warning: Use of memory after it is freed [unix.Malloc] kfree(rdev->pm.dpm.ps[i].ps_priv); ^~ drivers/gpu/drm/radeon/ci_dpm.c:5654:2: warning