drm/amd/display: fix __udivdi3 link error
Subsystems (3)
PATCH 1/1 drm/amd/display: fix __udivdi3 link error
From: yanglinlin <[email protected]>
When compiling the AMDGPU display driver for 32-bit architectures, the linker reports undefined reference to __udivdi3 in functions get_dp_dto_frequency_100hz() and dcn401_get_dp_dto_frequency_100hz().
This is because the code uses 64-bit division (/) on 32-bit systems, which GCC cannot handle directly and instead tries to call the missing __udivdi3 helper function.
Replace the raw division with div_u64(), the kernel's standard 64-bit division helper, to avoid the link error.
--- drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +5 -6
@@ -1229,9 +1229,9 @@ static bool get_dp_dto_frequency_100hz(*/ modulo_hz =REG_READ (MODULO [inst]);if (modulo_hz) { - temp =div_u64 ((uint64_t )clock_hz * dp_dto_ref_khz *10 , modulo_hz); -ASSERT (temp /100 <=0xFFFFFFFFUL ); - *pixel_clk_100hz = (unsigned int )(temp /100 ); + temp = clock_hz * dp_dto_ref_khz *10 ; +ASSERT (temp <=INT_MAX * modulo_hz *100 ); + *pixel_clk_100hz =div_u64 (temp, modulo_hz *100 ); }else *pixel_clk_100hz =0 ; }else {
@@ -1285,13 +1285,12 @@ static bool dcn401_get_dp_dto_frequency_100hz(const struct clock_source *clock_s* - target pix_clk_hz = (DPDTO INTEGER * DPDTO MODULO + DPDTO PHASE) */ temp = (unsigned long long )dp_dto_integer * modulo_hz + phase_hz; - -if (temp /100 >0xFFFFFFFFUL ) { +if (temp > (UINT_MAX *100ULL )) {/* pixel rate 100hz should never be this high, if it is, throw an assert and return 0 */ BREAK_TO_DEBUGGER (); *pixel_clk_100hz =0 ; }else { - *pixel_clk_100hz = (unsigned int )(temp /100 ); + *pixel_clk_100hz =div_u64 (temp,100 ); }return true;
Signature · 1 line
2.25.1
Quoted 24 lines · On Fri, Jul 10, 2026 at 3:44 AM <[email protected]> wrote:
From: yanglinlin <[email protected]>
When compiling the AMDGPU display driver for 32-bit architectures, the linker reports undefined reference to
__udivdi3in functionsget_dp_dto_frequency_100hz()anddcn401_get_dp_dto_frequency_100hz().This is because the code uses 64-bit division (/) on 32-bit systems, which GCC cannot handle directly and instead tries to call the missing
__udivdi3helper function.Replace the raw division with
div_u64(), the kernel's standard 64-bit division helper, to avoid the link error.Signed-off-by yanglinlin <[email protected]>--- drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +0
-0
drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c static bool get_dp_dto_frequency_100hz( · line 1233
Quoted 8 lines
drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +2
-3@@ -1229,9 +1229,9 @@ static bool get_dp_dto_frequency_100hz(*/ modulo_hz =REG_READ (MODULO [inst]);if (modulo_hz) { - temp =div_u64 ((uint64_t )clock_hz * dp_dto_ref_khz *10 , modulo_hz); -ASSERT (temp /100 <=0xFFFFFFFFUL ); - *pixel_clk_100hz = (unsigned int )(temp /100 ); + temp = clock_hz * dp_dto_ref_khz *10 ; +ASSERT (temp <=INT_MAX * modulo_hz *100 );
Shouldn't this be UINT_MAX?
Alex
Quoted 23 lines
drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +3
-4+ *pixel_clk_100hz =div_u64 (temp, modulo_hz *100 ); }else *pixel_clk_100hz =0 ; }else {@@ -1285,13 +1285,12 @@ static bool dcn401_get_dp_dto_frequency_100hz(const struct clock_source *clock_s* - target pix_clk_hz = (DPDTO INTEGER * DPDTO MODULO + DPDTO PHASE) */ temp = (unsigned long long )dp_dto_integer * modulo_hz + phase_hz; - -if (temp /100 >0xFFFFFFFFUL ) { +if (temp > (UINT_MAX *100ULL )) {/* pixel rate 100hz should never be this high, if it is, throw an assert and return 0 */ BREAK_TO_DEBUGGER (); *pixel_clk_100hz =0 ; }else { - *pixel_clk_100hz = (unsigned int )(temp /100 ); + *pixel_clk_100hz =div_u64 (temp,100 ); }return true; --2.25.1