diff mbox series

drm/amd/display: Fix compilation warnings on i386

Message ID 20200110194123.3718-1-mikita.lipski@amd.com (mailing list archive)
State New, archived
Headers show
Series drm/amd/display: Fix compilation warnings on i386 | expand

Commit Message

Lipski, Mikita Jan. 10, 2020, 7:41 p.m. UTC
From: Mikita Lipski <mikita.lipski@amd.com>

[why]
Compilation error "undefined reference to `__udivdi3'" was
thrown on i386 architecture.

[how]
Use div_u64 for unsigned long division instead of a divide operator.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Mikita Lipski <mikita.lipski@amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alex Deucher Jan. 10, 2020, 8:12 p.m. UTC | #1
On Fri, Jan 10, 2020 at 2:41 PM <mikita.lipski@amd.com> wrote:
>
> From: Mikita Lipski <mikita.lipski@amd.com>
>
> [why]
> Compilation error "undefined reference to `__udivdi3'" was
> thrown on i386 architecture.
>
> [how]
> Use div_u64 for unsigned long division instead of a divide operator.
>
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Signed-off-by: Mikita Lipski <mikita.lipski@amd.com>

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
> index 5a476028ee37..52fb207393ef 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
> @@ -533,7 +533,7 @@ static int kbps_to_peak_pbn(int kbps)
>         u64 peak_kbps = kbps;
>
>         peak_kbps *= 1006;
> -       peak_kbps /= 1000;
> +       peak_kbps = div_u64(peak_kbps, 1000);
>         return (int) DIV_ROUND_UP(peak_kbps * 64, (54 * 8 * 1000));
>  }
>
> @@ -565,7 +565,7 @@ static int bpp_x16_from_pbn(struct dsc_mst_fairness_params param, int pbn)
>         struct dc_dsc_config dsc_config;
>         u64 kbps;
>
> -       kbps = (u64)pbn * 994 * 8 * 54 / 64;
> +       kbps = div_u64((u64)pbn * 994 * 8 * 54, 64);
>         dc_dsc_compute_config(
>                         param.sink->ctx->dc->res_pool->dscs[0],
>                         &param.sink->sink_dsc_caps.dsc_dec_caps,
> --
> 2.17.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Randy Dunlap Jan. 10, 2020, 10:52 p.m. UTC | #2
On 1/10/20 11:41 AM, mikita.lipski@amd.com wrote:
> From: Mikita Lipski <mikita.lipski@amd.com>
> 
> [why]
> Compilation error "undefined reference to `__udivdi3'" was
> thrown on i386 architecture.
> 
> [how]
> Use div_u64 for unsigned long division instead of a divide operator.
> 
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Signed-off-by: Mikita Lipski <mikita.lipski@amd.com>
> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
> index 5a476028ee37..52fb207393ef 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
> @@ -533,7 +533,7 @@ static int kbps_to_peak_pbn(int kbps)
>  	u64 peak_kbps = kbps;
>  
>  	peak_kbps *= 1006;
> -	peak_kbps /= 1000;
> +	peak_kbps = div_u64(peak_kbps, 1000);
>  	return (int) DIV_ROUND_UP(peak_kbps * 64, (54 * 8 * 1000));
>  }
>  
> @@ -565,7 +565,7 @@ static int bpp_x16_from_pbn(struct dsc_mst_fairness_params param, int pbn)
>  	struct dc_dsc_config dsc_config;
>  	u64 kbps;
>  
> -	kbps = (u64)pbn * 994 * 8 * 54 / 64;
> +	kbps = div_u64((u64)pbn * 994 * 8 * 54, 64);
>  	dc_dsc_compute_config(
>  			param.sink->ctx->dc->res_pool->dscs[0],
>  			&param.sink->sink_dsc_caps.dsc_dec_caps,
> 

Still getting this in a different function:

ld: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.o: in function `compute_mst_dsc_configs_for_link':
amdgpu_dm_mst_types.c:(.text+0x7b8): undefined reference to `__udivdi3'
ld: amdgpu_dm_mst_types.c:(.text+0x956): undefined reference to `__udivdi3'
ld: amdgpu_dm_mst_types.c:(.text+0xa24): undefined reference to `__udivdi3'
ld: amdgpu_dm_mst_types.c:(.text+0xb33): undefined reference to `__udivdi3'
ld: amdgpu_dm_mst_types.c:(.text+0x1028): undefined reference to `__udivdi3'
ld: drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.o:amdgpu_dm_mst_types.c:(.text+0x1142): more undefined references to `__udivdi3' follow
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
index 5a476028ee37..52fb207393ef 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
@@ -533,7 +533,7 @@  static int kbps_to_peak_pbn(int kbps)
 	u64 peak_kbps = kbps;
 
 	peak_kbps *= 1006;
-	peak_kbps /= 1000;
+	peak_kbps = div_u64(peak_kbps, 1000);
 	return (int) DIV_ROUND_UP(peak_kbps * 64, (54 * 8 * 1000));
 }
 
@@ -565,7 +565,7 @@  static int bpp_x16_from_pbn(struct dsc_mst_fairness_params param, int pbn)
 	struct dc_dsc_config dsc_config;
 	u64 kbps;
 
-	kbps = (u64)pbn * 994 * 8 * 54 / 64;
+	kbps = div_u64((u64)pbn * 994 * 8 * 54, 64);
 	dc_dsc_compute_config(
 			param.sink->ctx->dc->res_pool->dscs[0],
 			&param.sink->sink_dsc_caps.dsc_dec_caps,