Skip to contentSkip to conversation

drm/amd/display: 64-bit division on 32-bit arch issue

PATCH In review Lang Yu 4 participants 5 messages Jan 22, 2021

Subsystems (3)
lore
Share & tools
lore

Lang Yu

author
#0 lore raw

PATCH 1/1 drm/amd/display: 64-bit division on 32-bit arch issue

Replace "/" with div_u64 for 32-bit arch. On 32-bit arch, the use of "/" for 64-bit division will cause build error, i.e. "__udivdi3/__divdi3 undefined!".

Fixes 27755cdf83f1

drm/amd/display: Update dcn30_apply_idle_power_optimizations() code

---
 drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +6 -6
index dff83c6a142a..9620fb8a27dc 100644
@@ -772,8 +772,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
 							cursor_cache_enable ? &cursor_attr : NULL)) {
 				unsigned int v_total = stream->adjust.v_total_max ?
 						stream->adjust.v_total_max : stream->timing.v_total;
-				unsigned int refresh_hz = (unsigned long long) stream->timing.pix_clk_100hz *
-						100LL /	(v_total * stream->timing.h_total);
+				unsigned int refresh_hz = div_u64((unsigned long long) stream->timing.pix_clk_100hz *
+						100LL, (v_total * stream->timing.h_total));
 
 				/*
 				 * one frame time in microsec:
@@ -800,8 +800,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
 				unsigned int denom = refresh_hz * 6528;
 				unsigned int stutter_period = dc->current_state->perf_params.stutter_period_us;
 
-				tmr_delay = (((1000000LL + 2 * stutter_period * refresh_hz) *
-						(100LL + dc->debug.mall_additional_timer_percent) + denom - 1) /
+				tmr_delay = div_u64(((1000000LL + 2 * stutter_period * refresh_hz) *
+						(100LL + dc->debug.mall_additional_timer_percent) + denom - 1),
 						denom) - 64LL;
 
 				/* scale should be increased until it fits into 6 bits */
@@ -815,8 +815,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
 					}
 
 					denom *= 2;
-					tmr_delay = (((1000000LL + 2 * stutter_period * refresh_hz) *
-							(100LL + dc->debug.mall_additional_timer_percent) + denom - 1) /
+					tmr_delay = div_u64(((1000000LL + 2 * stutter_period * refresh_hz) *
+							(100LL + dc->debug.mall_additional_timer_percent) + denom - 1),
 							denom) - 64LL;
 				}
 
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Lang

Replace "/" with div_u64 for 32-bit arch. On 32-bit arch, the use of "/" for 64-bit division will cause build error, i.e. "__udivdi3/__divdi3 undefined!".

Fixes 27755cdf83f1

drm/amd/display: Update dcn30_apply_idle_power_optimizations() code

Quoted 44 lines
---
 drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +6 -6
index dff83c6a142a..9620fb8a27dc 100644
@@ -772,8 +772,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
 							cursor_cache_enable ? &cursor_attr : NULL)) {
 				unsigned int v_total = stream->adjust.v_total_max ?
 						stream->adjust.v_total_max : stream->timing.v_total;
-				unsigned int refresh_hz = (unsigned long long) stream->timing.pix_clk_100hz *
-						100LL /	(v_total * stream->timing.h_total);
+				unsigned int refresh_hz = div_u64((unsigned long long) stream->timing.pix_clk_100hz *
+						100LL, (v_total * stream->timing.h_total));
 
 				/*
 				 * one frame time in microsec:
@@ -800,8 +800,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
 				unsigned int denom = refresh_hz * 6528;
 				unsigned int stutter_period = dc->current_state->perf_params.stutter_period_us;
 
-				tmr_delay = (((1000000LL + 2 * stutter_period * refresh_hz) *
-						(100LL + dc->debug.mall_additional_timer_percent) + denom - 1) /
+				tmr_delay = div_u64(((1000000LL + 2 * stutter_period * refresh_hz) *
+						(100LL + dc->debug.mall_additional_timer_percent) + denom - 1),
 						denom) - 64LL;
 
 				/* scale should be increased until it fits into 6 bits */
@@ -815,8 +815,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
 					}
 
 					denom *= 2;
-					tmr_delay = (((1000000LL + 2 * stutter_period * refresh_hz) *
-							(100LL + dc->debug.mall_additional_timer_percent) + denom - 1) /
+					tmr_delay = div_u64(((1000000LL + 2 * stutter_period * refresh_hz) *
+							(100LL + dc->debug.mall_additional_timer_percent) + denom - 1),
 							denom) - 64LL;
 				}
 
Signature · 1 line
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Acked-by Huang Rui
#2 lore raw

[AMD Public Use]

Maybe it's good to modify subject to " drm/amd/display: fix 64-bit division issue on 32-bit OS"

And if header <linux/math64.h> should be included?

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Huang Rui
Sent: Friday, January 22, 2021 5:04 PM
To: Yu, Lang <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Lakha, Bhawanpreet <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amd/display: 64-bit division on 32-bit arch issue

Quoted 8 lines · Lang

Replace "/" with div_u64 for 32-bit arch. On 32-bit arch, the use of "/" for 64-bit division will cause build error, i.e. "__udivdi3/__divdi3 undefined!".

Fixes 27755cdf83f1

drm/amd/display: Update dcn30_apply_idle_power_optimizations() code

Quoted 45 lines
---
 drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +4 -4
index dff83c6a142a..9620fb8a27dc 100644
@@ -772,8 +772,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
 							cursor_cache_enable ? &cursor_attr : NULL)) {
 				unsigned int v_total = stream->adjust.v_total_max ?
 						stream->adjust.v_total_max : stream->timing.v_total;
-				unsigned int refresh_hz = (unsigned long long) stream->timing.pix_clk_100hz *
-						100LL /	(v_total * stream->timing.h_total);
+				unsigned int refresh_hz = div_u64((unsigned long long) stream->timing.pix_clk_100hz *
+						100LL, (v_total * stream->timing.h_total));
 
 				/*
 				 * one frame time in microsec:
@@ -800,8 +800,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
 				unsigned int denom = refresh_hz * 6528;
 				unsigned int stutter_period = 
 dc->current_state->perf_params.stutter_period_us;
 
-				tmr_delay = (((1000000LL + 2 * stutter_period * refresh_hz) *
-						(100LL + dc->debug.mall_additional_timer_percent) + denom - 1) /
+				tmr_delay = div_u64(((1000000LL + 2 * stutter_period * refresh_hz) *
+						(100LL + dc->debug.mall_additional_timer_percent) + denom - 1),
 						denom) - 64LL;
 
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +3 -4
 				/* scale should be increased until it fits into 6 bits */ @@ 
-815,8 +815,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
 					}
 
 					denom *= 2;
-					tmr_delay = (((1000000LL + 2 * stutter_period * refresh_hz) *
-							(100LL + dc->debug.mall_additional_timer_percent) + denom - 1) /
+					tmr_delay = div_u64(((1000000LL + 2 * stutter_period * refresh_hz) *
+							(100LL + dc->debug.mall_additional_timer_percent) + denom - 
+1),
 							denom) - 64LL;
 				}
 
--
Quoted 2 lines

2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7Cguchun.chen%40amd.com%7Cd61b9d6686b64c78d73b08d8beb4ac34%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637469030487750031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=zKx39HfCyPJmDR9NH1r0Vtap5HBImUxVBae7h1ORhUA%3D&amp;reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author Acked-by Huang Rui
#3 lore raw

[AMD Public Use]

The header <linux/math64.h> has been included by dm_services.h. The following is the sequence,

dm_services.h -> dm_services_types.h -> os_types.h -> drm/drm_print.h -> linux/device.h -> linux/pm.h -> linux/timer.h -> linux/time.h -> linux/jiffies.h -> linux/math64.h

Regards,
Lang

-----Original Message-----
From: Chen, Guchun <[email protected]>
Sent: Friday, January 22, 2021 5:32 PM
To: Huang, Ray <[email protected]>; Yu, Lang <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Lakha, Bhawanpreet <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/amd/display: 64-bit division on 32-bit arch issue

[AMD Public Use]

Maybe it's good to modify subject to " drm/amd/display: fix 64-bit division issue on 32-bit OS"

And if header <linux/math64.h> should be included?

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Huang Rui
Sent: Friday, January 22, 2021 5:04 PM
To: Yu, Lang <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Lakha, Bhawanpreet <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amd/display: 64-bit division on 32-bit arch issue

Quoted 8 lines · Lang

Replace "/" with div_u64 for 32-bit arch. On 32-bit arch, the use of "/" for 64-bit division will cause build error, i.e. "__udivdi3/__divdi3 undefined!".

Fixes 27755cdf83f1

drm/amd/display: Update dcn30_apply_idle_power_optimizations() code

Quoted 45 lines
---
 drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +4 -4
index dff83c6a142a..9620fb8a27dc 100644
@@ -772,8 +772,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
 							cursor_cache_enable ? &cursor_attr : NULL)) {
 				unsigned int v_total = stream->adjust.v_total_max ?
 						stream->adjust.v_total_max : stream->timing.v_total;
-				unsigned int refresh_hz = (unsigned long long) stream->timing.pix_clk_100hz *
-						100LL /	(v_total * stream->timing.h_total);
+				unsigned int refresh_hz = div_u64((unsigned long long) stream->timing.pix_clk_100hz *
+						100LL, (v_total * stream->timing.h_total));
 
 				/*
 				 * one frame time in microsec:
@@ -800,8 +800,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
 				unsigned int denom = refresh_hz * 6528;
 				unsigned int stutter_period =
 dc->current_state->perf_params.stutter_period_us;
 
-				tmr_delay = (((1000000LL + 2 * stutter_period * refresh_hz) *
-						(100LL + dc->debug.mall_additional_timer_percent) + denom - 1) /
+				tmr_delay = div_u64(((1000000LL + 2 * stutter_period * refresh_hz) *
+						(100LL + dc->debug.mall_additional_timer_percent) + denom - 1),
 						denom) - 64LL;
 
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +3 -4
 				/* scale should be increased until it fits into 6 bits */ @@
-815,8 +815,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
 					}
 
 					denom *= 2;
-					tmr_delay = (((1000000LL + 2 * stutter_period * refresh_hz) *
-							(100LL + dc->debug.mall_additional_timer_percent) + denom - 1) /
+					tmr_delay = div_u64(((1000000LL + 2 * stutter_period * refresh_hz) *
+							(100LL + dc->debug.mall_additional_timer_percent) + denom - 
+1),
 							denom) - 64LL;
 				}
 
--
Quoted 2 lines

2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7Cguchun.chen%40amd.com%7Cd61b9d6686b64c78d73b08d8beb4ac34%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637469030487750031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=zKx39HfCyPJmDR9NH1r0Vtap5HBImUxVBae7h1ORhUA%3D&amp;reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by Acked-by Huang Rui
#4 lore raw

[AMD Public Use]

Thanks for the fix.

Thanks,
Bhawan
________________________________
From: Yu, Lang <[email protected]>
Sent: January 22, 2021 7:35 AM
To: Chen, Guchun <[email protected]>; Huang, Ray <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Lakha, Bhawanpreet <[email protected]>; [email protected] <[email protected]>
Subject: RE: [PATCH] drm/amd/display: 64-bit division on 32-bit arch issue

[AMD Public Use]

The header <linux/math64.h> has been included by dm_services.h. The following is the sequence,

dm_services.h -> dm_services_types.h -> os_types.h -> drm/drm_print.h -> linux/device.h -> linux/pm.h -> linux/timer.h -> linux/time.h -> linux/jiffies.h -> linux/math64.h

Regards,
Lang

-----Original Message-----
From: Chen, Guchun <[email protected]>
Sent: Friday, January 22, 2021 5:32 PM
To: Huang, Ray <[email protected]>; Yu, Lang <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Lakha, Bhawanpreet <[email protected]>; [email protected]
Subject: RE: [PATCH] drm/amd/display: 64-bit division on 32-bit arch issue

[AMD Public Use]

Maybe it’s good to modify subject to " drm/amd/display: fix 64-bit division issue on 32-bit OS"

And if header <linux/math64.h> should be included?

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Huang Rui
Sent: Friday, January 22, 2021 5:04 PM
To: Yu, Lang <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Lakha, Bhawanpreet <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amd/display: 64-bit division on 32-bit arch issue

Quoted 8 lines · Lang

Replace "/" with div_u64 for 32-bit arch. On 32-bit arch, the use of "/" for 64-bit division will cause build error, i.e. "__udivdi3/__divdi3 undefined!".

Fixes 27755cdf83f1

drm/amd/display: Update dcn30_apply_idle_power_optimizations() code

Quoted 45 lines
---
 drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +4 -4
index dff83c6a142a..9620fb8a27dc 100644
@@ -772,8 +772,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
                                                       cursor_cache_enable ? &cursor_attr : NULL)) {
                               unsigned int v_total = stream->adjust.v_total_max ?
                                               stream->adjust.v_total_max : stream->timing.v_total;
-                             unsigned int refresh_hz = (unsigned long long) stream->timing.pix_clk_100hz *
-                                             100LL / (v_total * stream->timing.h_total);
+                             unsigned int refresh_hz = div_u64((unsigned long long) stream->timing.pix_clk_100hz *
+                                             100LL, (v_total * stream->timing.h_total));
 
                               /*
                                * one frame time in microsec:
@@ -800,8 +800,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
                               unsigned int denom = refresh_hz * 6528;
                               unsigned int stutter_period =
 dc->current_state->perf_params.stutter_period_us;
 
-                             tmr_delay = (((1000000LL + 2 * stutter_period * refresh_hz) *
-                                             (100LL + dc->debug.mall_additional_timer_percent) + denom - 1) /
+                             tmr_delay = div_u64(((1000000LL + 2 * stutter_period * refresh_hz) *
+                                             (100LL + dc->debug.mall_additional_timer_percent) + denom - 1),
                                               denom) - 64LL;
 
                               /* scale should be increased until it fits into 6 bits */ @@
-815,8 +815,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
                                       }

                                       denom *= 2;
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +3 -3
-                                     tmr_delay = (((1000000LL + 2 * stutter_period * refresh_hz) *
-                                                     (100LL + dc->debug.mall_additional_timer_percent) + denom - 1) /
+                                     tmr_delay = div_u64(((1000000LL + 2 * stutter_period * refresh_hz) *
+                                                     (100LL + dc->debug.mall_additional_timer_percent) + denom -
+1),
                                                       denom) - 64LL;
                               }
 
--
Quoted 2 lines

2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7Cguchun.chen%40amd.com%7Cd61b9d6686b64c78d73b08d8beb4ac34%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637469030487750031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=zKx39HfCyPJmDR9NH1r0Vtap5HBImUxVBae7h1ORhUA%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx