drm/amd/powerplay: fix integer overflow warning
Subsystems (2)
PATCH 1/1 drm/amd/powerplay: fix integer overflow warning
A late bugfix for v4.7 introduced a build-time regression, producing a (probably harmless) warning:
powerplay/hwmgr/polaris10_hwmgr.c: In function 'polaris10_populate_clock_stretcher_data_table':powerplay/hwmgr/polaris10_hwmgr.c:1817:4: error: this decimal constant is unsigned only in ISO C90 [-Werror]
volt_without_cks = (uint32_t)((2753594000 + (sclk_table->entries[i].clk/100) * 136418 -(ro - 70) * 1000000) / \
^~~~~~~~~~~~~~~~
powerplay/hwmgr/polaris10_hwmgr.c:1822:4: error: this decimal constant is unsigned only in ISO C90 [-Werror]
volt_without_cks = (uint32_t)((2416794800 + (sclk_table->entries[i].clk/100) * 1476925/10 -(ro - 50) * 1000000) / \
^~~~~~~~~~~~~~~~
powerplay/hwmgr/polaris10_hwmgr.c:1824:4: error: this decimal constant is unsigned only in ISO C90 [-Werror]
volt_with_cks = (uint32_t)((2999656000 + sclk_table->entries[i].clk * 392803/100 - (ro - 44) * 1000000) / \This marks the new integer literals unsigned, which makes the calculation more sensible and avoids the warning.
Signed-off-by Arnd Bergmann <[email protected]>
Fixes 0812a945fbb8 ("drm/amd/powerplay: Update CKS on/ CKS off voltage offset calculation")
--- drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c +4 -4
@@ -1814,14 +1814,14 @@ static int polaris10_populate_clock_stretcher_data_table(struct pp_hwmgr *hwmgr) data->smc_state_table.Sclk_CKS_masterEn0_7 |= sclk_table->entries[i].cks_enable << i;if (hwmgr->chip_id ==CHIP_POLARIS10 ) { - volt_without_cks = (uint32_t )((2753594000 + (sclk_table->entries[i].clk/100 ) *136418 -(ro -70 ) *1000000 ) / \ + volt_without_cks = (uint32_t )((2753594000u + (sclk_table->entries[i].clk/100 ) *136418 -(ro -70 ) *1000000 ) / \ (2424180 - (sclk_table->entries[i].clk/100 ) *1132925 /1000 )); - volt_with_cks = (uint32_t )((279720200 + sclk_table->entries[i].clk *3232 - (ro -65 ) *100000000 ) / \ + volt_with_cks = (uint32_t )((279720200u + sclk_table->entries[i].clk *3232 - (ro -65 ) *100000000 ) / \ (252248000 - sclk_table->entries[i].clk/100 *115764 )); }else { - volt_without_cks = (uint32_t )((2416794800 + (sclk_table->entries[i].clk/100 ) *1476925 /10 -(ro -50 ) *1000000 ) / \ + volt_without_cks = (uint32_t )((2416794800u + (sclk_table->entries[i].clk/100 ) *1476925 /10 -(ro -50 ) *1000000 ) / \ (2625416 - (sclk_table->entries[i].clk/100 ) *12586807 /10000 )); - volt_with_cks = (uint32_t )((2999656000 + sclk_table->entries[i].clk *392803 /100 - (ro -44 ) *1000000 ) / \ + volt_with_cks = (uint32_t )((2999656000u + sclk_table->entries[i].clk *392803 /100 - (ro -44 ) *1000000 ) / \ (3422454 - sclk_table->entries[i].clk/100 *18886376 /10000 )); }
Signature · 6 lines
2.9.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel