* [PATCH libdrm 1/2] amdgpu: Use uint32_t i in amdgpu_find_bo_by_cpu_mapping
@ 2018-08-14 9:58 Michel Dänzer
[not found] ` <20180814095848.10981-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: Michel Dänzer @ 2018-08-14 9:58 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
From: Michel Dänzer <michel.daenzer@amd.com>
The compiler points out that an int doesn't work as intended if
dev->bo_handles.max_key > INT_MAX:
../../amdgpu/amdgpu_bo.c: In function ‘amdgpu_find_bo_by_cpu_mapping’:
../../amdgpu/amdgpu_bo.c:550:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
for (i = 0; i < dev->bo_handles.max_key; i++) {
^
../../amdgpu/amdgpu_bo.c:558:8: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
if (i < dev->bo_handles.max_key) {
^
Fixes: 4d454424e1f2 ("amdgpu: add a function to find bo by cpu mapping
(v2)")
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
amdgpu/amdgpu_bo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
index b790e9be..86d1c143 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -535,7 +535,7 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
amdgpu_bo_handle *buf_handle,
uint64_t *offset_in_bo)
{
- int i;
+ uint32_t i;
struct amdgpu_bo *bo;
if (cpu == NULL || size == 0)
--
2.18.0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 10+ messages in thread[parent not found: <20180814095848.10981-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>]
* [PATCH libdrm 2/2] amdgpu: Use char* pointers in amdgpu_find_bo_by_cpu_mapping [not found] ` <20180814095848.10981-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org> @ 2018-08-14 9:58 ` Michel Dänzer [not found] ` <20180814095848.10981-2-michel-otUistvHUpPR7s880joybQ@public.gmane.org> 2018-08-15 0:50 ` [PATCH libdrm 1/2] amdgpu: Use uint32_t i " Zhang, Jerry (Junwei) 1 sibling, 1 reply; 10+ messages in thread From: Michel Dänzer @ 2018-08-14 9:58 UTC (permalink / raw) To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW From: Michel Dänzer <michel.daenzer@amd.com> Arithmetic using void* pointers isn't defined by the C standard, only as a GCC extension. Avoids compiler warnings: ../../amdgpu/amdgpu_bo.c: In function ‘amdgpu_find_bo_by_cpu_mapping’: ../../amdgpu/amdgpu_bo.c:554:48: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + bo->alloc_size)) ^ ../../amdgpu/amdgpu_bo.c:561:23: warning: pointer of type ‘void *’ used in subtraction [-Wpointer-arith] *offset_in_bo = cpu - bo->cpu_ptr; ^ Fixes: 4d454424e1f2 ("amdgpu: add a function to find bo by cpu mapping (v2)") Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> --- amdgpu/amdgpu.h | 2 +- amdgpu/amdgpu_bo.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index a8c353c6..f2bdeb95 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -695,7 +695,7 @@ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, * */ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, - void *cpu, + char *cpu, uint64_t size, amdgpu_bo_handle *buf_handle, uint64_t *offset_in_bo); diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index 86d1c143..ef75f1d0 100644 --- a/amdgpu/amdgpu_bo.c +++ b/amdgpu/amdgpu_bo.c @@ -530,7 +530,7 @@ int amdgpu_bo_wait_for_idle(amdgpu_bo_handle bo, } int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, - void *cpu, + char *cpu, uint64_t size, amdgpu_bo_handle *buf_handle, uint64_t *offset_in_bo) @@ -551,14 +551,15 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, bo = handle_table_lookup(&dev->bo_handles, i); if (!bo || !bo->cpu_ptr || size > bo->alloc_size) continue; - if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + bo->alloc_size)) + if (cpu >= (char*)bo->cpu_ptr && + cpu < ((char*)bo->cpu_ptr + bo->alloc_size)) break; } if (i < dev->bo_handles.max_key) { atomic_inc(&bo->refcount); *buf_handle = bo; - *offset_in_bo = cpu - bo->cpu_ptr; + *offset_in_bo = cpu - (char*)bo->cpu_ptr; } else { *buf_handle = NULL; *offset_in_bo = 0; -- 2.18.0 _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply related [flat|nested] 10+ messages in thread
[parent not found: <20180814095848.10981-2-michel-otUistvHUpPR7s880joybQ@public.gmane.org>]
* Re: [PATCH libdrm 2/2] amdgpu: Use char* pointers in amdgpu_find_bo_by_cpu_mapping [not found] ` <20180814095848.10981-2-michel-otUistvHUpPR7s880joybQ@public.gmane.org> @ 2018-08-15 1:07 ` Zhang, Jerry (Junwei) [not found] ` <5B737CB6.5010207-5C7GfCeVMHo@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: Zhang, Jerry (Junwei) @ 2018-08-15 1:07 UTC (permalink / raw) To: Michel Dänzer, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW On 08/14/2018 05:58 PM, Michel Dänzer wrote: > From: Michel Dänzer <michel.daenzer@amd.com> > > Arithmetic using void* pointers isn't defined by the C standard, only as > a GCC extension. Avoids compiler warnings: > > ../../amdgpu/amdgpu_bo.c: In function ‘amdgpu_find_bo_by_cpu_mapping’: > ../../amdgpu/amdgpu_bo.c:554:48: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] > if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + bo->alloc_size)) > ^ > ../../amdgpu/amdgpu_bo.c:561:23: warning: pointer of type ‘void *’ used in subtraction [-Wpointer-arith] > *offset_in_bo = cpu - bo->cpu_ptr; > ^ > > Fixes: 4d454424e1f2 ("amdgpu: add a function to find bo by cpu mapping > (v2)") > Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> > --- > amdgpu/amdgpu.h | 2 +- > amdgpu/amdgpu_bo.c | 7 ++++--- > 2 files changed, 5 insertions(+), 4 deletions(-) > > diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h > index a8c353c6..f2bdeb95 100644 > --- a/amdgpu/amdgpu.h > +++ b/amdgpu/amdgpu.h > @@ -695,7 +695,7 @@ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, > * > */ > int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, > - void *cpu, > + char *cpu, Shall we cast the cpu pointer when do arithmetic and keep the arguments as other cpu ponter? e.g. @@ -565,14 +565,15 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, bo = handle_table_lookup(&dev->bo_handles, i); if (!bo || !bo->cpu_ptr || size > bo->alloc_size) continue; - if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + bo->alloc_size)) + if (cpu >= bo->cpu_ptr && + (uint64_t)cpu < ((uint64_t)bo->cpu_ptr + bo->alloc_size)) break; } if (i < dev->bo_handles.max_key) { atomic_inc(&bo->refcount); *buf_handle = bo; - *offset_in_bo = cpu - bo->cpu_ptr; + *offset_in_bo = (uint64_t)cpu - (uint64_t)bo->cpu_ptr; } else { *buf_handle = NULL; *offset_in_bo = 0; Regards, Jerry > uint64_t size, > amdgpu_bo_handle *buf_handle, > uint64_t *offset_in_bo); > diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c > index 86d1c143..ef75f1d0 100644 > --- a/amdgpu/amdgpu_bo.c > +++ b/amdgpu/amdgpu_bo.c > @@ -530,7 +530,7 @@ int amdgpu_bo_wait_for_idle(amdgpu_bo_handle bo, > } > > int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, > - void *cpu, > + char *cpu, > uint64_t size, > amdgpu_bo_handle *buf_handle, > uint64_t *offset_in_bo) > @@ -551,14 +551,15 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, > bo = handle_table_lookup(&dev->bo_handles, i); > if (!bo || !bo->cpu_ptr || size > bo->alloc_size) > continue; > - if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + bo->alloc_size)) > + if (cpu >= (char*)bo->cpu_ptr && > + cpu < ((char*)bo->cpu_ptr + bo->alloc_size)) > break; > } > > if (i < dev->bo_handles.max_key) { > atomic_inc(&bo->refcount); > *buf_handle = bo; > - *offset_in_bo = cpu - bo->cpu_ptr; > + *offset_in_bo = cpu - (char*)bo->cpu_ptr; > } else { > *buf_handle = NULL; > *offset_in_bo = 0; > _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <5B737CB6.5010207-5C7GfCeVMHo@public.gmane.org>]
* [PATCH v2 libdrm] amdgpu: Eliminate void* arithmetic in amdgpu_find_bo_by_cpu_mapping [not found] ` <5B737CB6.5010207-5C7GfCeVMHo@public.gmane.org> @ 2018-08-16 13:54 ` Michel Dänzer [not found] ` <20180816135429.3945-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org> 2018-08-16 13:55 ` [PATCH libdrm 2/2] amdgpu: Use char* pointers " Michel Dänzer 1 sibling, 1 reply; 10+ messages in thread From: Michel Dänzer @ 2018-08-16 13:54 UTC (permalink / raw) To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW From: Michel Dänzer <michel.daenzer@amd.com> Arithmetic using void* pointers isn't defined by the C standard, only as a GCC extension. Avoids compiler warnings: ../../amdgpu/amdgpu_bo.c: In function ‘amdgpu_find_bo_by_cpu_mapping’: ../../amdgpu/amdgpu_bo.c:554:48: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + bo->alloc_size)) ^ ../../amdgpu/amdgpu_bo.c:561:23: warning: pointer of type ‘void *’ used in subtraction [-Wpointer-arith] *offset_in_bo = cpu - bo->cpu_ptr; ^ v2: Use uintptr_t instead of char*, don't change function signature (Junwei Zhang) Fixes: 4d454424e1f2 ("amdgpu: add a function to find bo by cpu mapping (v2)") Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> --- amdgpu/amdgpu_bo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index 86d1c143..8efd014e 100644 --- a/amdgpu/amdgpu_bo.c +++ b/amdgpu/amdgpu_bo.c @@ -551,14 +551,15 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, bo = handle_table_lookup(&dev->bo_handles, i); if (!bo || !bo->cpu_ptr || size > bo->alloc_size) continue; - if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + bo->alloc_size)) + if (cpu >= bo->cpu_ptr && + cpu < (void*)((uintptr_t)bo->cpu_ptr + bo->alloc_size)) break; } if (i < dev->bo_handles.max_key) { atomic_inc(&bo->refcount); *buf_handle = bo; - *offset_in_bo = cpu - bo->cpu_ptr; + *offset_in_bo = (uintptr_t)cpu - (uintptr_t)bo->cpu_ptr; } else { *buf_handle = NULL; *offset_in_bo = 0; -- 2.18.0 _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply related [flat|nested] 10+ messages in thread
[parent not found: <20180816135429.3945-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>]
* Re: [PATCH v2 libdrm] amdgpu: Eliminate void* arithmetic in amdgpu_find_bo_by_cpu_mapping [not found] ` <20180816135429.3945-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org> @ 2018-08-16 18:22 ` Christian König 2018-08-17 3:57 ` Zhang, Jerry 1 sibling, 0 replies; 10+ messages in thread From: Christian König @ 2018-08-16 18:22 UTC (permalink / raw) To: Michel Dänzer, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW Am 16.08.2018 um 15:54 schrieb Michel Dänzer: > From: Michel Dänzer <michel.daenzer@amd.com> > > Arithmetic using void* pointers isn't defined by the C standard, only as > a GCC extension. Avoids compiler warnings: > > ../../amdgpu/amdgpu_bo.c: In function ‘amdgpu_find_bo_by_cpu_mapping’: > ../../amdgpu/amdgpu_bo.c:554:48: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] > if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + bo->alloc_size)) > ^ > ../../amdgpu/amdgpu_bo.c:561:23: warning: pointer of type ‘void *’ used in subtraction [-Wpointer-arith] > *offset_in_bo = cpu - bo->cpu_ptr; > ^ > > v2: Use uintptr_t instead of char*, don't change function signature > (Junwei Zhang) > > Fixes: 4d454424e1f2 ("amdgpu: add a function to find bo by cpu mapping > (v2)") > Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> > --- > amdgpu/amdgpu_bo.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c > index 86d1c143..8efd014e 100644 > --- a/amdgpu/amdgpu_bo.c > +++ b/amdgpu/amdgpu_bo.c > @@ -551,14 +551,15 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, > bo = handle_table_lookup(&dev->bo_handles, i); > if (!bo || !bo->cpu_ptr || size > bo->alloc_size) > continue; > - if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + bo->alloc_size)) > + if (cpu >= bo->cpu_ptr && > + cpu < (void*)((uintptr_t)bo->cpu_ptr + bo->alloc_size)) > break; > } > > if (i < dev->bo_handles.max_key) { > atomic_inc(&bo->refcount); > *buf_handle = bo; > - *offset_in_bo = cpu - bo->cpu_ptr; > + *offset_in_bo = (uintptr_t)cpu - (uintptr_t)bo->cpu_ptr; > } else { > *buf_handle = NULL; > *offset_in_bo = 0; _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 libdrm] amdgpu: Eliminate void* arithmetic in amdgpu_find_bo_by_cpu_mapping [not found] ` <20180816135429.3945-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org> 2018-08-16 18:22 ` Christian König @ 2018-08-17 3:57 ` Zhang, Jerry 1 sibling, 0 replies; 10+ messages in thread From: Zhang, Jerry @ 2018-08-17 3:57 UTC (permalink / raw) To: Michel Dänzer, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com> Regards, Jerry(Junwei Zhang) ________________________________________ From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Michel Dänzer <michel@daenzer.net> Sent: Thursday, August 16, 2018 9:54:29 PM To: amd-gfx@lists.freedesktop.org Subject: [PATCH v2 libdrm] amdgpu: Eliminate void* arithmetic in amdgpu_find_bo_by_cpu_mapping From: Michel Dänzer <michel.daenzer@amd.com> Arithmetic using void* pointers isn't defined by the C standard, only as a GCC extension. Avoids compiler warnings: ../../amdgpu/amdgpu_bo.c: In function ‘amdgpu_find_bo_by_cpu_mapping’: ../../amdgpu/amdgpu_bo.c:554:48: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + bo->alloc_size)) ^ ../../amdgpu/amdgpu_bo.c:561:23: warning: pointer of type ‘void *’ used in subtraction [-Wpointer-arith] *offset_in_bo = cpu - bo->cpu_ptr; ^ v2: Use uintptr_t instead of char*, don't change function signature (Junwei Zhang) Fixes: 4d454424e1f2 ("amdgpu: add a function to find bo by cpu mapping (v2)") Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> --- amdgpu/amdgpu_bo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index 86d1c143..8efd014e 100644 --- a/amdgpu/amdgpu_bo.c +++ b/amdgpu/amdgpu_bo.c @@ -551,14 +551,15 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, bo = handle_table_lookup(&dev->bo_handles, i); if (!bo || !bo->cpu_ptr || size > bo->alloc_size) continue; - if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + bo->alloc_size)) + if (cpu >= bo->cpu_ptr && + cpu < (void*)((uintptr_t)bo->cpu_ptr + bo->alloc_size)) break; } if (i < dev->bo_handles.max_key) { atomic_inc(&bo->refcount); *buf_handle = bo; - *offset_in_bo = cpu - bo->cpu_ptr; + *offset_in_bo = (uintptr_t)cpu - (uintptr_t)bo->cpu_ptr; } else { *buf_handle = NULL; *offset_in_bo = 0; -- 2.18.0 _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH libdrm 2/2] amdgpu: Use char* pointers in amdgpu_find_bo_by_cpu_mapping [not found] ` <5B737CB6.5010207-5C7GfCeVMHo@public.gmane.org> 2018-08-16 13:54 ` [PATCH v2 libdrm] amdgpu: Eliminate void* arithmetic " Michel Dänzer @ 2018-08-16 13:55 ` Michel Dänzer 1 sibling, 0 replies; 10+ messages in thread From: Michel Dänzer @ 2018-08-16 13:55 UTC (permalink / raw) To: Zhang, Jerry (Junwei); +Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW On 2018-08-15 03:07 AM, Zhang, Jerry (Junwei) wrote: > On 08/14/2018 05:58 PM, Michel Dänzer wrote: >> From: Michel Dänzer <michel.daenzer@amd.com> >> >> Arithmetic using void* pointers isn't defined by the C standard, only as >> a GCC extension. Avoids compiler warnings: >> >> ../../amdgpu/amdgpu_bo.c: In function ‘amdgpu_find_bo_by_cpu_mapping’: >> ../../amdgpu/amdgpu_bo.c:554:48: warning: pointer of type ‘void *’ >> used in arithmetic [-Wpointer-arith] >> if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + bo->alloc_size)) >> ^ >> ../../amdgpu/amdgpu_bo.c:561:23: warning: pointer of type ‘void *’ >> used in subtraction [-Wpointer-arith] >> *offset_in_bo = cpu - bo->cpu_ptr; >> ^ >> >> Fixes: 4d454424e1f2 ("amdgpu: add a function to find bo by cpu mapping >> (v2)") >> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> >> --- >> amdgpu/amdgpu.h | 2 +- >> amdgpu/amdgpu_bo.c | 7 ++++--- >> 2 files changed, 5 insertions(+), 4 deletions(-) >> >> diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h >> index a8c353c6..f2bdeb95 100644 >> --- a/amdgpu/amdgpu.h >> +++ b/amdgpu/amdgpu.h >> @@ -695,7 +695,7 @@ int >> amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, >> * >> */ >> int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, >> - void *cpu, >> + char *cpu, > > Shall we cast the cpu pointer when do arithmetic and keep the arguments > as other cpu ponter? > > e.g. > @@ -565,14 +565,15 @@ int > amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, > bo = handle_table_lookup(&dev->bo_handles, i); > if (!bo || !bo->cpu_ptr || size > bo->alloc_size) > continue; > - if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + > bo->alloc_size)) > + if (cpu >= bo->cpu_ptr && > + (uint64_t)cpu < ((uint64_t)bo->cpu_ptr + > bo->alloc_size)) > break; > } > > if (i < dev->bo_handles.max_key) { > atomic_inc(&bo->refcount); > *buf_handle = bo; > - *offset_in_bo = cpu - bo->cpu_ptr; > + *offset_in_bo = (uint64_t)cpu - (uint64_t)bo->cpu_ptr; > } else { > *buf_handle = NULL; > *offset_in_bo = 0; Thanks for the suggestion, I sent out a v2 patch along those lines (though slightly different). -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH libdrm 1/2] amdgpu: Use uint32_t i in amdgpu_find_bo_by_cpu_mapping [not found] ` <20180814095848.10981-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org> 2018-08-14 9:58 ` [PATCH libdrm 2/2] amdgpu: Use char* pointers " Michel Dänzer @ 2018-08-15 0:50 ` Zhang, Jerry (Junwei) 1 sibling, 0 replies; 10+ messages in thread From: Zhang, Jerry (Junwei) @ 2018-08-15 0:50 UTC (permalink / raw) To: Michel Dänzer, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW On 08/14/2018 05:58 PM, Michel Dänzer wrote: > From: Michel Dänzer <michel.daenzer@amd.com> > > The compiler points out that an int doesn't work as intended if > dev->bo_handles.max_key > INT_MAX: > > ../../amdgpu/amdgpu_bo.c: In function ‘amdgpu_find_bo_by_cpu_mapping’: > ../../amdgpu/amdgpu_bo.c:550:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare] > for (i = 0; i < dev->bo_handles.max_key; i++) { > ^ > ../../amdgpu/amdgpu_bo.c:558:8: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare] > if (i < dev->bo_handles.max_key) { > ^ > > Fixes: 4d454424e1f2 ("amdgpu: add a function to find bo by cpu mapping > (v2)") > Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Thanks. Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com> > --- > amdgpu/amdgpu_bo.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c > index b790e9be..86d1c143 100644 > --- a/amdgpu/amdgpu_bo.c > +++ b/amdgpu/amdgpu_bo.c > @@ -535,7 +535,7 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, > amdgpu_bo_handle *buf_handle, > uint64_t *offset_in_bo) > { > - int i; > + uint32_t i; > struct amdgpu_bo *bo; > > if (cpu == NULL || size == 0) > _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH libdrm 1/2] amdgpu: Use uint32_t i in amdgpu_find_bo_by_cpu_mapping
@ 2018-08-14 9:56 Michel Dänzer
2018-08-14 10:00 ` Christian König
0 siblings, 1 reply; 10+ messages in thread
From: Michel Dänzer @ 2018-08-14 9:56 UTC (permalink / raw)
To: dri-devel
From: Michel Dänzer <michel.daenzer@amd.com>
The compiler points out that an int doesn't work as intended if
dev->bo_handles.max_key > INT_MAX:
../../amdgpu/amdgpu_bo.c: In function ‘amdgpu_find_bo_by_cpu_mapping’:
../../amdgpu/amdgpu_bo.c:550:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
for (i = 0; i < dev->bo_handles.max_key; i++) {
^
../../amdgpu/amdgpu_bo.c:558:8: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
if (i < dev->bo_handles.max_key) {
^
Fixes: 4d454424e1f2 ("amdgpu: add a function to find bo by cpu mapping
(v2)")
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
amdgpu/amdgpu_bo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
index b790e9be..86d1c143 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -535,7 +535,7 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
amdgpu_bo_handle *buf_handle,
uint64_t *offset_in_bo)
{
- int i;
+ uint32_t i;
struct amdgpu_bo *bo;
if (cpu == NULL || size == 0)
--
2.18.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH libdrm 1/2] amdgpu: Use uint32_t i in amdgpu_find_bo_by_cpu_mapping 2018-08-14 9:56 Michel Dänzer @ 2018-08-14 10:00 ` Christian König 0 siblings, 0 replies; 10+ messages in thread From: Christian König @ 2018-08-14 10:00 UTC (permalink / raw) To: Michel Dänzer, dri-devel Am 14.08.2018 um 11:56 schrieb Michel Dänzer: > From: Michel Dänzer <michel.daenzer@amd.com> > > The compiler points out that an int doesn't work as intended if > dev->bo_handles.max_key > INT_MAX: > > ../../amdgpu/amdgpu_bo.c: In function ‘amdgpu_find_bo_by_cpu_mapping’: > ../../amdgpu/amdgpu_bo.c:550:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare] > for (i = 0; i < dev->bo_handles.max_key; i++) { > ^ > ../../amdgpu/amdgpu_bo.c:558:8: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare] > if (i < dev->bo_handles.max_key) { > ^ > > Fixes: 4d454424e1f2 ("amdgpu: add a function to find bo by cpu mapping > (v2)") > Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> for the series. > --- > amdgpu/amdgpu_bo.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c > index b790e9be..86d1c143 100644 > --- a/amdgpu/amdgpu_bo.c > +++ b/amdgpu/amdgpu_bo.c > @@ -535,7 +535,7 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, > amdgpu_bo_handle *buf_handle, > uint64_t *offset_in_bo) > { > - int i; > + uint32_t i; > struct amdgpu_bo *bo; > > if (cpu == NULL || size == 0) _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2018-08-17 3:57 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-14 9:58 [PATCH libdrm 1/2] amdgpu: Use uint32_t i in amdgpu_find_bo_by_cpu_mapping Michel Dänzer
[not found] ` <20180814095848.10981-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-08-14 9:58 ` [PATCH libdrm 2/2] amdgpu: Use char* pointers " Michel Dänzer
[not found] ` <20180814095848.10981-2-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-08-15 1:07 ` Zhang, Jerry (Junwei)
[not found] ` <5B737CB6.5010207-5C7GfCeVMHo@public.gmane.org>
2018-08-16 13:54 ` [PATCH v2 libdrm] amdgpu: Eliminate void* arithmetic " Michel Dänzer
[not found] ` <20180816135429.3945-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-08-16 18:22 ` Christian König
2018-08-17 3:57 ` Zhang, Jerry
2018-08-16 13:55 ` [PATCH libdrm 2/2] amdgpu: Use char* pointers " Michel Dänzer
2018-08-15 0:50 ` [PATCH libdrm 1/2] amdgpu: Use uint32_t i " Zhang, Jerry (Junwei)
-- strict thread matches above, loose matches on Subject: below --
2018-08-14 9:56 Michel Dänzer
2018-08-14 10:00 ` Christian König
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.