2022-10-29 17:24:37

by KaiLong Wang

[permalink] [raw]
Subject: [PATCH] drm/amd/pm: replace ternary operator with max()

Fix the following coccicheck warning:
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c:348:85-86:
WARNING opportunity for max()
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c:351:52-53:
WARNING opportunity for max()

Signed-off-by: KaiLong Wang <[email protected]>
---
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c
index c8c9fb827bda..35677c13ddf9 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c
@@ -345,12 +345,8 @@ static int vega10_odn_initial_default_setting(struct pp_hwmgr *hwmgr)
odn_table->min_vddc = dep_table[0]->entries[0].vddc;

i = od_table[2]->count - 1;
- od_table[2]->entries[i].clk = hwmgr->platform_descriptor.overdriveLimit.memoryClock > od_table[2]->entries[i].clk ?
- hwmgr->platform_descriptor.overdriveLimit.memoryClock :
- od_table[2]->entries[i].clk;
- od_table[2]->entries[i].vddc = odn_table->max_vddc > od_table[2]->entries[i].vddc ?
- odn_table->max_vddc :
- od_table[2]->entries[i].vddc;
+ od_table[2]->entries[i].clk = max(hwmgr->platform_descriptor.overdriveLimit.memoryClock, od_table[2]->entries[i].clk);
+ od_table[2]->entries[i].vddc = max(odn_table->max_vddc, od_table[2]->entries[i].vddc);

return 0;
}
--
2.25.1


2022-10-30 04:24:32

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] drm/amd/pm: replace ternary operator with max()

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on linus/master v6.1-rc2 next-20221028]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/wangkailong-jari-cn/drm-amd-pm-replace-ternary-operator-with-max/20221029-233830
base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link: https://lore.kernel.org/r/3b1eb0d7.3f.184245eccc6.Coremail.wangkailong%40jari.cn
patch subject: [PATCH] drm/amd/pm: replace ternary operator with max()
config: parisc-randconfig-s031-20221030
compiler: hppa-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/3c108bd6207a75833150ef3ad12b224364f95c88
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review wangkailong-jari-cn/drm-amd-pm-replace-ternary-operator-with-max/20221029-233830
git checkout 3c108bd6207a75833150ef3ad12b224364f95c88
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=parisc SHELL=/bin/bash drivers/gpu/drm/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

sparse warnings: (new ones prefixed by >>)
drivers/gpu/drm/amd/amdgpu/../pm/powerplay/hwmgr/vega10_hwmgr.c: note: in included file (through drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgpu_virt.h, drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgpu.h, ...):
drivers/gpu/drm/amd/amdgpu/../amdgpu/amdgv_sriovmsg.h:314:49: sparse: sparse: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"
>> drivers/gpu/drm/amd/amdgpu/../pm/powerplay/hwmgr/vega10_hwmgr.c:349:40: sparse: sparse: incompatible types in comparison expression (different type sizes):
>> drivers/gpu/drm/amd/amdgpu/../pm/powerplay/hwmgr/vega10_hwmgr.c:349:40: sparse: unsigned int *
>> drivers/gpu/drm/amd/amdgpu/../pm/powerplay/hwmgr/vega10_hwmgr.c:349:40: sparse: unsigned short *

vim +349 drivers/gpu/drm/amd/amdgpu/../pm/powerplay/hwmgr/vega10_hwmgr.c

303
304 static int vega10_odn_initial_default_setting(struct pp_hwmgr *hwmgr)
305 {
306 struct vega10_hwmgr *data = hwmgr->backend;
307 struct phm_ppt_v2_information *table_info =
308 (struct phm_ppt_v2_information *)(hwmgr->pptable);
309 struct vega10_odn_dpm_table *odn_table = &(data->odn_dpm_table);
310 struct vega10_odn_vddc_lookup_table *od_lookup_table;
311 struct phm_ppt_v1_voltage_lookup_table *vddc_lookup_table;
312 struct phm_ppt_v1_clock_voltage_dependency_table *dep_table[3];
313 struct phm_ppt_v1_clock_voltage_dependency_table *od_table[3];
314 struct pp_atomfwctrl_avfs_parameters avfs_params = {0};
315 uint32_t i;
316 int result;
317
318 result = pp_atomfwctrl_get_avfs_information(hwmgr, &avfs_params);
319 if (!result) {
320 data->odn_dpm_table.max_vddc = avfs_params.ulMaxVddc;
321 data->odn_dpm_table.min_vddc = avfs_params.ulMinVddc;
322 }
323
324 od_lookup_table = &odn_table->vddc_lookup_table;
325 vddc_lookup_table = table_info->vddc_lookup_table;
326
327 for (i = 0; i < vddc_lookup_table->count; i++)
328 od_lookup_table->entries[i].us_vdd = vddc_lookup_table->entries[i].us_vdd;
329
330 od_lookup_table->count = vddc_lookup_table->count;
331
332 dep_table[0] = table_info->vdd_dep_on_sclk;
333 dep_table[1] = table_info->vdd_dep_on_mclk;
334 dep_table[2] = table_info->vdd_dep_on_socclk;
335 od_table[0] = (struct phm_ppt_v1_clock_voltage_dependency_table *)&odn_table->vdd_dep_on_sclk;
336 od_table[1] = (struct phm_ppt_v1_clock_voltage_dependency_table *)&odn_table->vdd_dep_on_mclk;
337 od_table[2] = (struct phm_ppt_v1_clock_voltage_dependency_table *)&odn_table->vdd_dep_on_socclk;
338
339 for (i = 0; i < 3; i++)
340 smu_get_voltage_dependency_table_ppt_v1(dep_table[i], od_table[i]);
341
342 if (odn_table->max_vddc == 0 || odn_table->max_vddc > 2000)
343 odn_table->max_vddc = dep_table[0]->entries[dep_table[0]->count - 1].vddc;
344 if (odn_table->min_vddc == 0 || odn_table->min_vddc > 2000)
345 odn_table->min_vddc = dep_table[0]->entries[0].vddc;
346
347 i = od_table[2]->count - 1;
348 od_table[2]->entries[i].clk = max(hwmgr->platform_descriptor.overdriveLimit.memoryClock, od_table[2]->entries[i].clk);
> 349 od_table[2]->entries[i].vddc = max(odn_table->max_vddc, od_table[2]->entries[i].vddc);
350
351 return 0;
352 }
353

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (5.14 kB)
config (176.11 kB)
Download all attachments