Commit 6a53b313 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Alex Deucher

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.
Reviewed-by: default avatarThierry Reding <treding@nvidia.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Fixes: 770911a3 ("drm/amd/powerplay: add/update headers for Fiji SMU and DPM")
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent c11b8989
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment