Skip to contentSkip to conversation

drm/amdgpu: fix a warning about different types in min() macro

PATCH In review Nicolai Hähnle 3 participants 3 messages Feb 14, 2017 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: fix a warning about different types in min() macro

From: Nicolai Hähnle <[email protected]>

In file included from ./include/linux/list.h:8:0,
from drivers/gpu/drm/amd/amdgpu/amdgpu_object.c:32:
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c: In function ‘amdgpu_bo_create_restricted’:
./include/linux/kernel.h:739:16: warning: comparison of distinct pointer types lacks a cast

  (void) (&min1 == &min2);   \
                ^

./include/linux/kernel.h:742:2: note: in expansion of macro ‘__min’
__min(typeof(x), typeof(y), \
^~~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c:434:21: note: in expansion of macro ‘min’

  bo->tbo.priority = min(bo->tbo.priority, TTM_MAX_BO_PRIORITY - 1);
                     ^~~
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -1
index bea845f..71dfea4 100644
@@ -431,7 +431,8 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
 	bo->tbo.priority = ilog2(bo->tbo.num_pages);
 	if (kernel)
 		bo->tbo.priority *= 2;
-	bo->tbo.priority = min(bo->tbo.priority, TTM_MAX_BO_PRIORITY - 1);
+	bo->tbo.priority = min(bo->tbo.priority,
+			       (unsigned)(TTM_MAX_BO_PRIORITY - 1));
 
 	if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED &&
 	    bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) {
Signature · 6 lines
2.9.3

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

A message that is not in the archive (sent off-list or not yet received): 20170214104015.4328-1-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

Am 14.02.2017 um 11:40 schrieb Nicolai Hähnle:

Quoted 15 lines

From: Nicolai Hähnle <[email protected]>

In file included from ./include/linux/list.h:8:0,
from drivers/gpu/drm/amd/amdgpu/amdgpu_object.c:32:
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c: In function ‘amdgpu_bo_create_restricted’:
./include/linux/kernel.h:739:16: warning: comparison of distinct pointer types lacks a cast

   (void) (&min1 == &min2);   \
                 ^
./include/linux/kernel.h:742:2: note: in expansion of macro ‘__min’
   __min(typeof(x), typeof(y),   \
   ^~~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c:434:21: note: in expansion of macro ‘min’
   bo->tbo.priority = min(bo->tbo.priority, TTM_MAX_BO_PRIORITY - 1);
                      ^~~
Quoted 1 line

Thanks for taking care of this, but I would prefer to fix the root cause and make the define of TTM_MAX_BO_PRIORITY unsigned.

Regards,
Christian.

Quoted 9 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index bea845f..71dfea4 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create_restricted(struct amdgpu_device *adev, · line 438

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -1
@@ -431,7 +431,8 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
  	bo->tbo.priority = ilog2(bo->tbo.num_pages);
  	if (kernel)
  		bo->tbo.priority *= 2;
-	bo->tbo.priority = min(bo->tbo.priority, TTM_MAX_BO_PRIORITY - 1);
+	bo->tbo.priority = min(bo->tbo.priority,
+			       (unsigned)(TTM_MAX_BO_PRIORITY - 1));
 
  	if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED &&
  	    bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) {

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

A message that is not in the archive (sent off-list or not yet received): f0110d5a-930d-ed73-e50f-3e050e54a5de-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#4 lore raw
Quoted 19 lines · Christian König

Am 14.02.2017 um 11:40 schrieb Nicolai Hähnle:

Quoted 18 lines

From: Nicolai Hähnle <[email protected]>

In file included from ./include/linux/list.h:8:0,
from drivers/gpu/drm/amd/amdgpu/amdgpu_object.c:32:
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c: In function ‘amdgpu_bo_create_restricted’:
./include/linux/kernel.h:739:16: warning: comparison of distinct pointer types lacks a cast

   (void) (&min1 == &min2);   \
                 ^
./include/linux/kernel.h:742:2: note: in expansion of macro ‘__min’
   __min(typeof(x), typeof(y),   \
   ^~~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c:434:21: note: in expansion
of macro ‘min’
   bo->tbo.priority = min(bo->tbo.priority, TTM_MAX_BO_PRIORITY - 1);
                      ^~~
Quoted 4 lines
Quoted 1 line

Thanks for taking care of this, but I would prefer to fix the root cause and make the define of TTM_MAX_BO_PRIORITY unsigned.

Makes sense, will do.

Quoted 8 lines

Regards,
Christian.

Quoted 4 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 17 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index bea845f..71dfea4 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create_restricted(struct · line 438

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -1
@@ -431,7 +431,8 @@ int amdgpu_bo_create_restricted(struct
 amdgpu_device *adev,
      bo->tbo.priority = ilog2(bo->tbo.num_pages);
      if (kernel)
          bo->tbo.priority *= 2;
-    bo->tbo.priority = min(bo->tbo.priority, TTM_MAX_BO_PRIORITY - 1);
+    bo->tbo.priority = min(bo->tbo.priority,
+                   (unsigned)(TTM_MAX_BO_PRIORITY - 1));
        if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED &&
          bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) {

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