Skip to contentSkip to conversation

drm, i915: Fix pointer size cast

PATCH In review Borislav Petkov 3 participants 3 messages Dec 21, 2015 – Dec 22, 2015

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

PATCH 1/1 drm, i915: Fix pointer size cast

From: Borislav Petkov <[email protected]>

gcc complains on 32-bit like this:

drivers/gpu/drm/i915/intel_display.c: In function ‘intel_plane_obj_offset’:
drivers/gpu/drm/i915/intel_display.c:2954:11: warning: cast to pointer from \

	  integer of different size [-Wint-to-pointer-cast]
    offset = (unsigned char *)vma->node.start;
             ^

because vma->node.start is u64 but a pointer on 32-bit is 4 bytes.

Do the calculations with an unsigned long directly and save us the casts.

---
 drivers/gpu/drm/i915/intel_display.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -3
index 62211abe4922..640cb7c9b7f3 100644
@@ -2941,7 +2941,7 @@ unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
 {
 	const struct i915_ggtt_view *view = &i915_ggtt_view_normal;
 	struct i915_vma *vma;
-	unsigned char *offset;
+	unsigned long offset;
 
 	if (intel_rotation_90_or_270(intel_plane->base.state->rotation))
 		view = &i915_ggtt_view_rotated;
@@ -2951,14 +2951,14 @@ unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
 		view->type))
 		return -1;
 
-	offset = (unsigned char *)vma->node.start;
+	offset = vma->node.start;
 
 	if (plane == 1) {
 		offset += vma->ggtt_view.rotation_info.uv_start_page *
 			  PAGE_SIZE;
 	}
 
-	return (unsigned long)offset;
+	return offset;
 }
 
 static void skl_detach_scaler(struct intel_crtc *intel_crtc, int id)
Signature · 1 line
2.3.5
#1 lore raw
Quoted 15 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

gcc complains on 32-bit like this:

drivers/gpu/drm/i915/intel_display.c: In function ‘intel_plane_obj_offset’:
drivers/gpu/drm/i915/intel_display.c:2954:11: warning: cast to pointer from \

	  integer of different size [-Wint-to-pointer-cast]
    offset = (unsigned char *)vma->node.start;
             ^

because vma->node.start is u64 but a pointer on 32-bit is 4 bytes.

Do the calculations with an unsigned long directly and save us the casts.

Quoted 7 lines

This has been fixed already in

commit 44eb0cb9620c6a53ec8e7073262e2af8079b727f

Author: Mika Kuoppala <[email protected]>
Date:   Fri Oct 30 13:26:15 2015 +0200

drm/i915: Avoid pointer arithmetic in calculating plane surface offset

Cheers,
Daniel

Quoted 41 lines
---
 drivers/gpu/drm/i915/intel_display.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -3
index 62211abe4922..640cb7c9b7f3 100644
@@ -2941,7 +2941,7 @@ unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
 {
 	const struct i915_ggtt_view *view = &i915_ggtt_view_normal;
 	struct i915_vma *vma;
-	unsigned char *offset;
+	unsigned long offset;
 
 	if (intel_rotation_90_or_270(intel_plane->base.state->rotation))
 		view = &i915_ggtt_view_rotated;
@@ -2951,14 +2951,14 @@ unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
 		view->type))
 		return -1;
 
-	offset = (unsigned char *)vma->node.start;
+	offset = vma->node.start;
 
 	if (plane == 1) {
 		offset += vma->ggtt_view.rotation_info.uv_start_page *
 			  PAGE_SIZE;
 	}
 
-	return (unsigned long)offset;
+	return offset;
 }
 
 static void skl_detach_scaler(struct intel_crtc *intel_crtc, int id)
Signature · 6 lines
2.3.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

✗ failure: Fi.CI.BAT

In reply to Borislav Petkov
== Summary ==

== Summary ==

HEAD is now at 78deeec drm-intel-nightly: 2015y-12m-21d-16h-03m-57s UTC integration manifest
Applying: drm, i915: Fix pointer size cast
Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/intel_display.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/intel_display.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/intel_display.c Patch failed at 0001 drm, i915: Fix pointer size cast

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx