All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/powerplay: fix integer overflow warning
@ 2016-07-04 13:18 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2016-07-04 13:18 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Arnd Bergmann, Christian König, David Airlie, Rex Zhu,
	Eric Huang, dri-devel, linux-kernel

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 <arnd@arndb.de>
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(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c
index ec2a7ada346a..5b26bbbc3e79 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c
@@ -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));
 		}
 
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] drm/amd/powerplay: fix integer overflow warning
@ 2016-07-04 13:18 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2016-07-04 13:18 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Arnd Bergmann, linux-kernel, dri-devel, Eric Huang, Rex Zhu,
	Christian König

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 <arnd@arndb.de>
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(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c
index ec2a7ada346a..5b26bbbc3e79 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c
@@ -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));
 		}
 
-- 
2.9.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-04 13:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-04 13:18 [PATCH] drm/amd/powerplay: fix integer overflow warning Arnd Bergmann
2016-07-04 13:18 ` Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.