[bug report] amd\powerplay Implement get dal power level

Dan Carpenter dan.carpenter at oracle.com
Wed Apr 4 14:28:09 UTC 2018


[ This is pretty old, but it showed up as a new warning because of the
  recent renames.  It's a private unpublished Smatch check.  -dan ]

Hello Vitaly Prosyak,

The patch c4dd206be156: "amd\powerplay Implement get dal power level"
from Nov 30, 2015, leads to the following static checker warning:

	drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu8_hwmgr.c:1485 smu8_get_dal_power_level()
	warn: why is zero skipped 'i'

drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu8_hwmgr.c
  1472  static int smu8_get_dal_power_level(struct pp_hwmgr *hwmgr,
  1473                  struct amd_pp_simple_clock_info *info)
  1474  {
  1475          uint32_t i;
                ^^^^^^^^^^
If you change anything you'll probably want to make this an int.

  1476          const struct phm_clock_voltage_dependency_table *table =
  1477                          hwmgr->dyn_state.vddc_dep_on_dal_pwrl;
  1478          const struct phm_clock_and_voltage_limits *limits =
  1479                          &hwmgr->dyn_state.max_clock_voltage_on_ac;
  1480  
  1481          info->engine_max_clock = limits->sclk;
  1482          info->memory_max_clock = limits->mclk;
  1483  
  1484          for (i = table->count - 1; i > 0; i--) {
  1485                  if (limits->vddc >= table->entries[i].v) {
  1486                          info->level = table->entries[i].clk;
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I sort of do think we should be using table->entries[0] here?

  1487                          return 0;
  1488                  }
  1489          }
  1490          return -EINVAL;
  1491  }

regards,
dan carpenter


More information about the amd-gfx mailing list