Skip to contentSkip to conversation

drm: powerplay: use div64_s64 instead of do_div

PATCH Applied Arnd Bergmann 4 participants 4 messages Jan 1, 2016 – Jan 4, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: powerplay: use div64_s64 instead of do_div

The newly added code for Fiji creates a correct compiler warning about invalid use of the do_div macro:

In file included from powerplay/hwmgr/ppatomctrl.c:31:0:
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/ppevvmath.h: In function 'fDivide':
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/ppevvmath.h:382:89: warning: comparison of distinct pointer types lacks a cast

     do_div(longlongX, longlongY); /*Q(32,32) divided by Q(16,16) = Q(16,16) Back to original format */

do_div() divides an unsigned 64-bit number by an unsigned 32-bit number. The code instead wants to divide two signed 64-bit numbers, which is done using the div64_s64 function.

Fixes 770911a3cfbb ("drm/amd/powerplay: add/update headers for Fiji SMU and DPM")

---
Found on ARM allmodconfig on yesterday's linux-next

drivers/gpu/drm/amd/powerplay/hwmgr/ppevvmath.h +1 -1
index 42f2423cddea..411cb0fcdf98 100644
@@ -379,7 +379,7 @@ fInt fDivide (fInt X, fInt Y)
 
     longlongX = longlongX << 16; /*Q(16,16) -> Q(32,32) */
 
-    do_div(longlongX, longlongY); /*Q(32,32) divided by Q(16,16) = Q(16,16) Back to original format */
+    div64_s64(longlongX, longlongY); /*Q(32,32) divided by Q(16,16) = Q(16,16) Back to original format */
 
     fQuotient.full = (int)longlongX;
     return fQuotient;

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Arnd Bergmann

The newly added code for Fiji creates a correct compiler warning about invalid use of the do_div macro:

In file included from powerplay/hwmgr/ppatomctrl.c:31:0:
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/ppevvmath.h: In function 'fDivide':
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/ppevvmath.h:382:89: warning: comparison of distinct pointer types lacks a cast

     do_div(longlongX, longlongY); /*Q(32,32) divided by Q(16,16) = Q(16,16) Back to original format */
Quoted 8 lines

do_div() divides an unsigned 64-bit number by an unsigned 32-bit number. The code instead wants to divide two signed 64-bit numbers, which is done using the div64_s64 function.

Fixes 770911a3cfbb ("drm/amd/powerplay: add/update headers for Fiji SMU and DPM")

---
Found on ARM allmodconfig on yesterday's linux-next

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann

The newly added code for Fiji creates a correct compiler warning about invalid use of the do_div macro:

In file included from powerplay/hwmgr/ppatomctrl.c:31:0:
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/ppevvmath.h: In function 'fDivide':
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/ppevvmath.h:382:89: warning: comparison of distinct pointer types lacks a cast

Quoted 7 lines
      do_div(longlongX, longlongY); /*Q(32,32) divided by Q(16,16) = Q(16,16) Back to original format */

do_div() divides an unsigned 64-bit number by an unsigned 32-bit number. The code instead wants to divide two signed 64-bit numbers, which is done using the div64_s64 function.

Quoted 10 lines
Fixes 770911a3cfbb ("drm/amd/powerplay: add/update headers for Fiji SMU and DPM")

---
Found on ARM allmodconfig on yesterday's linux-next

drivers/gpu/drm/amd/powerplay/hwmgr/ppevvmath.h +0 -0
index 42f2423cddea..411cb0fcdf98 100644

drivers/gpu/drm/amd/powerplay/hwmgr/ppevvmath.h fInt fDivide (fInt X, fInt Y) · line 385

Quoted 8 lines
drivers/gpu/drm/amd/powerplay/hwmgr/ppevvmath.h +1 -1
@@ -379,7 +379,7 @@ fInt fDivide (fInt X, fInt Y)
 
      longlongX = longlongX << 16; /*Q(16,16) -> Q(32,32) */
 
-    do_div(longlongX, longlongY); /*Q(32,32) divided by Q(16,16) = Q(16,16) Back to original format */
+    div64_s64(longlongX, longlongY); /*Q(32,32) divided by Q(16,16) = Q(16,16) Back to original format */
 
      fQuotient.full = (int)longlongX;
      return fQuotient;

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Applied
#3 lore raw
In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann

The newly added code for Fiji creates a correct compiler warning about invalid use of the do_div macro:

In file included from powerplay/hwmgr/ppatomctrl.c:31:0:
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/ppevvmath.h: In function 'fDivide':
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/ppevvmath.h:382:89: warning: comparison of distinct pointer types lacks a cast

Quoted 8 lines
     do_div(longlongX, longlongY); /*Q(32,32) divided by Q(16,16) = Q(16,16) Back to original format */

do_div() divides an unsigned 64-bit number by an unsigned 32-bit number. The code instead wants to divide two signed 64-bit numbers, which is done using the div64_s64 function.

Fixes 770911a3cfbb ("drm/amd/powerplay: add/update headers for Fiji SMU and DPM")

Applied. thanks!

Alex

Quoted 17 lines

---
Found on ARM allmodconfig on yesterday's linux-next

drivers/gpu/drm/amd/powerplay/hwmgr/ppevvmath.h +1 -1
index 42f2423cddea..411cb0fcdf98 100644
@@ -379,7 +379,7 @@ fInt fDivide (fInt X, fInt Y)
 
     longlongX = longlongX << 16; /*Q(16,16) -> Q(32,32) */
 
-    do_div(longlongX, longlongY); /*Q(32,32) divided by Q(16,16) = Q(16,16) Back to original format */
+    div64_s64(longlongX, longlongY); /*Q(32,32) divided by Q(16,16) = Q(16,16) Back to original format */
 
     fQuotient.full = (int)longlongX;
     return fQuotient;
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel