Skip to content

Commit 44eb0cb

Browse files
mikuintvsyrjala
authored andcommitted
drm/i915: Avoid pointer arithmetic in calculating plane surface offset
VMA offsets are 64 bits. Plane surface offsets are in ggtt and the hardware register to set this is thus 32 bits. Be explicit about these and convert carefully to from vma to final size. This will make sparse happy by not creating 32bit pointers out of 64bit vma offsets. Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1446204375-29831-1-git-send-email-mika.kuoppala@intel.com Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
1 parent 0ac7655 commit 44eb0cb

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

drivers/gpu/drm/i915/intel_display.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2915,13 +2915,13 @@ u32 intel_fb_stride_alignment(struct drm_device *dev, uint64_t fb_modifier,
29152915
}
29162916
}
29172917

2918-
unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
2919-
struct drm_i915_gem_object *obj,
2920-
unsigned int plane)
2918+
u32 intel_plane_obj_offset(struct intel_plane *intel_plane,
2919+
struct drm_i915_gem_object *obj,
2920+
unsigned int plane)
29212921
{
29222922
const struct i915_ggtt_view *view = &i915_ggtt_view_normal;
29232923
struct i915_vma *vma;
2924-
unsigned char *offset;
2924+
u64 offset;
29252925

29262926
if (intel_rotation_90_or_270(intel_plane->base.state->rotation))
29272927
view = &i915_ggtt_view_rotated;
@@ -2931,14 +2931,16 @@ unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
29312931
view->type))
29322932
return -1;
29332933

2934-
offset = (unsigned char *)vma->node.start;
2934+
offset = vma->node.start;
29352935

29362936
if (plane == 1) {
29372937
offset += vma->ggtt_view.rotation_info.uv_start_page *
29382938
PAGE_SIZE;
29392939
}
29402940

2941-
return (unsigned long)offset;
2941+
WARN_ON(upper_32_bits(offset));
2942+
2943+
return lower_32_bits(offset);
29422944
}
29432945

29442946
static void skl_detach_scaler(struct intel_crtc *intel_crtc, int id)
@@ -3064,7 +3066,7 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,
30643066
u32 tile_height, plane_offset, plane_size;
30653067
unsigned int rotation;
30663068
int x_offset, y_offset;
3067-
unsigned long surf_addr;
3069+
u32 surf_addr;
30683070
struct intel_crtc_state *crtc_state = intel_crtc->config;
30693071
struct intel_plane_state *plane_state;
30703072
int src_x = 0, src_y = 0, src_w = 0, src_h = 0;

drivers/gpu/drm/i915/intel_drv.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,9 +1199,9 @@ void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file);
11991199
int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state);
12001200
int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
12011201

1202-
unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
1203-
struct drm_i915_gem_object *obj,
1204-
unsigned int plane);
1202+
u32 intel_plane_obj_offset(struct intel_plane *intel_plane,
1203+
struct drm_i915_gem_object *obj,
1204+
unsigned int plane);
12051205

12061206
u32 skl_plane_ctl_format(uint32_t pixel_format);
12071207
u32 skl_plane_ctl_tiling(uint64_t fb_modifier);

drivers/gpu/drm/i915/intel_sprite.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
194194
u32 plane_ctl, stride_div, stride;
195195
const struct drm_intel_sprite_colorkey *key =
196196
&to_intel_plane_state(drm_plane->state)->ckey;
197-
unsigned long surf_addr;
197+
u32 surf_addr;
198198
u32 tile_height, plane_offset, plane_size;
199199
unsigned int rotation;
200200
int x_offset, y_offset;

0 commit comments

Comments
 (0)