linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] drm/amdgpu: Use DIV_ROUND_UP_ULL instead of DIV_ROUND_UP
@ 2021-06-10  8:20 He Ying
  2021-06-10  8:20 ` Christian König
  0 siblings, 1 reply; 3+ messages in thread
From: He Ying @ 2021-06-10  8:20 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig, Xinhui.Pan, airlied, daniel,
	airlied, bskeggs, matthew.auld, Ramesh.Errabolu, mchehab+huawei,
	Dennis.Li, funfunctor
  Cc: amd-gfx, dri-devel, linux-kernel, heying24

When compiling the kernel for MIPS with CONFIG_DRM_AMDGPU = y, errors are
encountered as follows:

drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.o: In function `amdgpu_vram_mgr_new':
amdgpu_vram_mgr.c:(.text+0x740): undefined reference to `__udivdi3'

Making a 64 bit division by a/b (a is uint64_t) is not supported by default
in linux kernel space. Instead, using do_div is OK for this situation. For
this problem, using DIV_ROUND_UP_ULL instead of DIV_ROUND_UP is better.

Fixes: 6a7f76e70fac ("drm/amdgpu: add VRAM manager v2")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: He Ying <heying24@huawei.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index 9a6df02477ce..436ec246a7da 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -407,7 +407,7 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
 #endif
 		pages_per_node = max_t(uint32_t, pages_per_node,
 				       tbo->page_alignment);
-		num_nodes = DIV_ROUND_UP(PFN_UP(mem_bytes), pages_per_node);
+		num_nodes = DIV_ROUND_UP_ULL(PFN_UP(mem_bytes), pages_per_node);
 	}
 
 	node = kvmalloc(struct_size(node, mm_nodes, num_nodes),
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] drm/amdgpu: Use DIV_ROUND_UP_ULL instead of DIV_ROUND_UP
  2021-06-10  8:20 [PATCH -next] drm/amdgpu: Use DIV_ROUND_UP_ULL instead of DIV_ROUND_UP He Ying
@ 2021-06-10  8:20 ` Christian König
  2021-06-10  8:41   ` He Ying
  0 siblings, 1 reply; 3+ messages in thread
From: Christian König @ 2021-06-10  8:20 UTC (permalink / raw)
  To: He Ying, alexander.deucher, Xinhui.Pan, airlied, daniel, airlied,
	bskeggs, matthew.auld, Ramesh.Errabolu, mchehab+huawei,
	Dennis.Li, funfunctor
  Cc: amd-gfx, dri-devel, linux-kernel



Am 10.06.21 um 10:20 schrieb He Ying:
> When compiling the kernel for MIPS with CONFIG_DRM_AMDGPU = y, errors are
> encountered as follows:
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.o: In function `amdgpu_vram_mgr_new':
> amdgpu_vram_mgr.c:(.text+0x740): undefined reference to `__udivdi3'
>
> Making a 64 bit division by a/b (a is uint64_t) is not supported by default
> in linux kernel space. Instead, using do_div is OK for this situation. For
> this problem, using DIV_ROUND_UP_ULL instead of DIV_ROUND_UP is better.

Already fixed by this patch in drm-next:

commit 691cf8cd7a531dbfcc29d09a23c509a86fd9b24f
Author: Dave Airlie <airlied@redhat.com>
Date:   Thu Jun 10 12:59:00 2021 +1000

     drm/amdgpu: use correct rounding macro for 64-bit

     This fixes 32-bit arm build due to lack of 64-bit divides.

Regards,
Christian.

>
> Fixes: 6a7f76e70fac ("drm/amdgpu: add VRAM manager v2")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: He Ying <heying24@huawei.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index 9a6df02477ce..436ec246a7da 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -407,7 +407,7 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
>   #endif
>   		pages_per_node = max_t(uint32_t, pages_per_node,
>   				       tbo->page_alignment);
> -		num_nodes = DIV_ROUND_UP(PFN_UP(mem_bytes), pages_per_node);
> +		num_nodes = DIV_ROUND_UP_ULL(PFN_UP(mem_bytes), pages_per_node);
>   	}
>   
>   	node = kvmalloc(struct_size(node, mm_nodes, num_nodes),


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] drm/amdgpu: Use DIV_ROUND_UP_ULL instead of DIV_ROUND_UP
  2021-06-10  8:20 ` Christian König
@ 2021-06-10  8:41   ` He Ying
  0 siblings, 0 replies; 3+ messages in thread
From: He Ying @ 2021-06-10  8:41 UTC (permalink / raw)
  To: Christian König, alexander.deucher, Xinhui.Pan, airlied,
	daniel, airlied, bskeggs, matthew.auld, Ramesh.Errabolu,
	mchehab+huawei, Dennis.Li, funfunctor
  Cc: amd-gfx, dri-devel, linux-kernel

Hello,


在 2021/6/10 16:20, Christian König 写道:
>
>
> Am 10.06.21 um 10:20 schrieb He Ying:
>> When compiling the kernel for MIPS with CONFIG_DRM_AMDGPU = y, errors 
>> are
>> encountered as follows:
>>
>> drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.o: In function 
>> `amdgpu_vram_mgr_new':
>> amdgpu_vram_mgr.c:(.text+0x740): undefined reference to `__udivdi3'
>>
>> Making a 64 bit division by a/b (a is uint64_t) is not supported by 
>> default
>> in linux kernel space. Instead, using do_div is OK for this 
>> situation. For
>> this problem, using DIV_ROUND_UP_ULL instead of DIV_ROUND_UP is better.
>
> Already fixed by this patch in drm-next:
>
> commit 691cf8cd7a531dbfcc29d09a23c509a86fd9b24f
> Author: Dave Airlie <airlied@redhat.com>
> Date:   Thu Jun 10 12:59:00 2021 +1000
>
>     drm/amdgpu: use correct rounding macro for 64-bit
>
>     This fixes 32-bit arm build due to lack of 64-bit divides.

OK. Sigh.

Before sending my patch, I searched patches in https://lore.kernel.org/lkml/

but I didn't find this patch. How can I find whether my patch is duplicated

before sending it? Any suggestions?


Thanks.

>
> Regards,
> Christian.
>
>>
>> Fixes: 6a7f76e70fac ("drm/amdgpu: add VRAM manager v2")
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: He Ying <heying24@huawei.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> index 9a6df02477ce..436ec246a7da 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> @@ -407,7 +407,7 @@ static int amdgpu_vram_mgr_new(struct 
>> ttm_resource_manager *man,
>>   #endif
>>           pages_per_node = max_t(uint32_t, pages_per_node,
>>                          tbo->page_alignment);
>> -        num_nodes = DIV_ROUND_UP(PFN_UP(mem_bytes), pages_per_node);
>> +        num_nodes = DIV_ROUND_UP_ULL(PFN_UP(mem_bytes), 
>> pages_per_node);
>>       }
>>         node = kvmalloc(struct_size(node, mm_nodes, num_nodes),
>
> .

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-10  8:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10  8:20 [PATCH -next] drm/amdgpu: Use DIV_ROUND_UP_ULL instead of DIV_ROUND_UP He Ying
2021-06-10  8:20 ` Christian König
2021-06-10  8:41   ` He Ying

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).