drm/i915: Track pinned vma in intel_plane_state
Subsystems (2)
PATCH 1/1 drm/i915: Track pinned vma in intel_plane_state
From: Chris Wilson <[email protected]>
With atomic plane states we are able to track an allocation right from preparation, during use and through to the final free after being swapped out for a new plane. We can couple the VMA we pin for the framebuffer (and its rotation) to this lifetime and avoid all the clumsy lookups in between.
v2: Remove residual vma on plane cleanup (Chris)
v3: Add a description for the vma destruction in
intel_plane_destroy_state (Maarten)
--- drivers/gpu/drm/i915/i915_drv.h | 16 +--- drivers/gpu/drm/i915/intel_atomic_plane.c | 20 +++++ drivers/gpu/drm/i915/intel_display.c | 129 +++++++++++------------------- drivers/gpu/drm/i915/intel_drv.h | 9 ++- drivers/gpu/drm/i915/intel_fbc.c | 52 +++++------- drivers/gpu/drm/i915/intel_fbdev.c | 4 +- drivers/gpu/drm/i915/intel_sprite.c | 8 +- 7 files changed, 103 insertions(+), 135 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -12
@@ -1079,6 +1079,8 @@ struct intel_fbc {struct work_struct underrun_work;struct intel_fbc_state_cache { +struct i915_vma *vma; +struct {unsigned int mode_flags;uint32_t hsw_bdw_pixel_rate;
@@ -1092,15 +1094,14 @@ struct intel_fbc { } plane;struct { -u64 ilk_ggtt_offset;const struct drm_format_info *format;unsigned int stride; -int fence_reg; -unsigned int tiling_mode; } fb; } state_cache;struct intel_fbc_reg_params { +struct i915_vma *vma; +struct {enum pipe pipe;enum plane plane;
@@ -1108,10 +1109,8 @@ struct intel_fbc { } crtc;struct { -u64 ggtt_offset;const struct drm_format_info *format;unsigned int stride; -int fence_reg; } fb;int cfb_size;
@@ -3406,13 +3405,6 @@ i915_gem_object_to_ggtt(struct drm_i915_gem_object *obj,return i915_gem_obj_to_vma (obj, &to_i915 (obj->base.dev)->ggtt.base, view); } -static inline unsigned long -i915_gem_object_ggtt_offset (struct drm_i915_gem_object *o, -const struct i915_ggtt_view *view) -{ -return i915_ggtt_offset (i915_gem_object_to_ggtt (o, view)); -} -/* i915_gem_fence_reg.c */ int __must_check i915_vma_get_fence (struct i915_vma *vma);int __must_check i915_vma_put_fence (struct i915_vma *vma);
drivers/gpu/drm/i915/intel_atomic_plane.c +20 -0
@@ -85,6 +85,8 @@ intel_plane_duplicate_state(struct drm_plane *plane)__drm_atomic_helper_plane_duplicate_state (plane, state); + intel_state->vma =NULL ; +return state; }
@@ -100,6 +102,24 @@ void intel_plane_destroy_state(struct drm_plane *plane, struct drm_plane_state *state) { + struct i915_vma *vma; + + vma =fetch_and_zero (&to_intel_plane_state (state)->vma); + +/* +* FIXME: Normally intel_cleanup_plane_fb handles destruction of vma. +* We currently don't clear all planes during driver unload, so we have +* to be able to unpin vma here for now. +* +* Normally this can only happen during unload when kmscon is disabled +* and userspace doesn't attempt to set a framebuffer at all. +*/ +if (vma) { +mutex_lock (&plane->dev->struct_mutex); +intel_unpin_fb_vma (vma); +mutex_unlock (&plane->dev->struct_mutex); + } +drm_atomic_helper_plane_destroy_state (plane, state); }
drivers/gpu/drm/i915/intel_display.c +46 -83
263 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +7 -2
@@ -376,6 +376,7 @@ struct intel_atomic_state {struct intel_plane_state {struct drm_plane_state base;struct drm_rect clip; +struct i915_vma *vma;struct {u32 offset;
@@ -1067,6 +1068,7 @@ struct intel_flip_work {struct work_struct mmio_work;struct drm_crtc *crtc; +struct i915_vma *old_vma;struct drm_framebuffer *old_fb;struct drm_i915_gem_object *pending_flip_obj;struct drm_pending_vblank_event *event;
@@ -1302,7 +1304,7 @@ void intel_release_load_detect_pipe(struct drm_connector *connector, struct drm_modeset_acquire_ctx *ctx);struct i915_vma *intel_pin_and_fence_fb_obj (struct drm_framebuffer *fb,unsigned int rotation); -void intel_unpin_fb_obj (struct drm_framebuffer *fb,unsigned int rotation); +void intel_unpin_fb_vma (struct i915_vma *vma);struct drm_framebuffer * __intel_framebuffer_create(struct drm_device *dev, struct drm_mode_fb_cmd2 *mode_cmd,
@@ -1391,7 +1393,10 @@ void intel_mode_from_pipe_config(struct drm_display_mode *mode,int skl_update_scaler_crtc (struct intel_crtc_state *crtc_state);int skl_max_scale (struct intel_crtc *crtc,struct intel_crtc_state *crtc_state); -u32 intel_fb_gtt_offset (struct drm_framebuffer *fb,unsigned int rotation); +static inline u32 intel_plane_ggtt_offset (const struct intel_plane_state *state) +{ +return i915_ggtt_offset (state->vma); +}u32 skl_plane_ctl_format (uint32_t pixel_format);u32 skl_plane_ctl_tiling (uint64_t fb_modifier);
drivers/gpu/drm/i915/intel_fbc.c +20 -32
134 lines not on this page · raw message
drivers/gpu/drm/i915/intel_fbdev.c +2 -2
@@ -284,7 +284,7 @@ static int intelfb_create(struct drm_fb_helper *helper, out_destroy_fbi:drm_fb_helper_release_fbi (helper); out_unpin: -intel_unpin_fb_obj (&ifbdev->fb->base,DRM_ROTATE_0 ); +intel_unpin_fb_vma (vma); out_unlock:mutex_unlock (&dev->struct_mutex);return ret;
@@ -549,7 +549,7 @@ static void intel_fbdev_destroy(struct intel_fbdev *ifbdev)if (ifbdev->fb) {mutex_lock (&ifbdev->helper.dev->struct_mutex); -intel_unpin_fb_obj (&ifbdev->fb->base,DRM_ROTATE_0 ); +intel_unpin_fb_vma (ifbdev->vma);mutex_unlock (&ifbdev->helper.dev->struct_mutex);drm_framebuffer_remove (&ifbdev->fb->base);
drivers/gpu/drm/i915/intel_sprite.c +4 -4
@@ -273,7 +273,7 @@ skl_update_plane(struct drm_plane *drm_plane,I915_WRITE (PLANE_CTL (pipe, plane_id), plane_ctl);I915_WRITE (PLANE_SURF (pipe, plane_id), -intel_fb_gtt_offset (fb, rotation) + surf_addr); +intel_plane_ggtt_offset (plane_state) + surf_addr);POSTING_READ (PLANE_SURF (pipe, plane_id)); }
@@ -458,7 +458,7 @@ vlv_update_plane(struct drm_plane *dplane,I915_WRITE (SPSIZE (pipe, plane_id), (crtc_h <<16 ) | crtc_w);I915_WRITE (SPCNTR (pipe, plane_id), sprctl);I915_WRITE (SPSURF (pipe, plane_id), -intel_fb_gtt_offset (fb, rotation) + sprsurf_offset); +intel_plane_ggtt_offset (plane_state) + sprsurf_offset);POSTING_READ (SPSURF (pipe, plane_id)); }
@@ -594,7 +594,7 @@ ivb_update_plane(struct drm_plane *plane,I915_WRITE (SPRSCALE (pipe), sprscale);I915_WRITE (SPRCTL (pipe), sprctl);I915_WRITE (SPRSURF (pipe), -intel_fb_gtt_offset (fb, rotation) + sprsurf_offset); +intel_plane_ggtt_offset (plane_state) + sprsurf_offset);POSTING_READ (SPRSURF (pipe)); }
@@ -721,7 +721,7 @@ ilk_update_plane(struct drm_plane *plane,I915_WRITE (DVSSCALE (pipe), dvsscale);I915_WRITE (DVSCNTR (pipe), dvscntr);I915_WRITE (DVSSURF (pipe), -intel_fb_gtt_offset (fb, rotation) + dvssurf_offset); +intel_plane_ggtt_offset (plane_state) + dvssurf_offset);POSTING_READ (DVSSURF (pipe)); }
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: warning for drm/i915: Track pinned vma in intel_plane_state
== Series Details ==
== Series Details ==
Series: drm/i915: Track pinned vma in intel_plane_state
URL : https://patchwork.freedesktop.org/series/17490/
State : warning
== Summary ==
Series 17490v1 drm/i915: Track pinned vma in intel_plane_state
https://patchwork.freedesktop.org/api/1.0/series/17490/revisions/1/mbox/
Test kms_pipe_crc_basic:
Subgroup read-crc-pipe-b-frame-sequence:
pass -> DMESG-WARN (fi-ivb-3770)fi-bdw-5557u total:246 pass:232 dwarn:0 dfail:0 fail:0 skip:14 fi-bsw-n3050 total:246 pass:207 dwarn:0 dfail:0 fail:0 skip:39 fi-bxt-j4205 total:246 pass:224 dwarn:0 dfail:0 fail:0 skip:22 fi-byt-j1900 total:246 pass:219 dwarn:0 dfail:0 fail:0 skip:27 fi-byt-n2820 total:246 pass:215 dwarn:0 dfail:0 fail:0 skip:31 fi-hsw-4770 total:246 pass:227 dwarn:0 dfail:0 fail:0 skip:19 fi-hsw-4770r total:246 pass:227 dwarn:0 dfail:0 fail:0 skip:19 fi-ivb-3520m total:246 pass:225 dwarn:0 dfail:0 fail:0 skip:21 fi-ivb-3770 total:246 pass:224 dwarn:1 dfail:0 fail:0 skip:21 fi-kbl-7500u total:246 pass:225 dwarn:0 dfail:0 fail:0 skip:21 fi-skl-6260u total:246 pass:233 dwarn:0 dfail:0 fail:0 skip:13 fi-skl-6700hq total:246 pass:226 dwarn:0 dfail:0 fail:0 skip:20 fi-skl-6700k total:246 pass:222 dwarn:3 dfail:0 fail:0 skip:21 fi-skl-6770hq total:246 pass:233 dwarn:0 dfail:0 fail:0 skip:13 fi-snb-2520m total:246 pass:215 dwarn:0 dfail:0 fail:0 skip:31
3ff9912451fd6840732ac0184f0561c9e6c4107f drm-tip: 2017y-01m-04d-11h-22m-41s UTC integration manifest 08b671e drm/i915: Track pinned vma in intel_plane_state
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3429/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 85 lines · Maarten Lankhorst
From: Chris Wilson <[email protected]>
With atomic plane states we are able to track an allocation right from preparation, during use and through to the final free after being swapped out for a new plane. We can couple the VMA we pin for the framebuffer (and its rotation) to this lifetime and avoid all the clumsy lookups in between.
v2: Remove residual vma on plane cleanup (Chris)
v3: Add a description for the vma destruction in
intel_plane_destroy_state(Maarten)Signed-off-by Chris Wilson <[email protected]>Signed-off-by Maarten Lankhorst <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 16 +--- drivers/gpu/drm/i915/intel_atomic_plane.c | 20 +++++ drivers/gpu/drm/i915/intel_display.c | 129 +++++++++++------------------- drivers/gpu/drm/i915/intel_drv.h | 9 ++- drivers/gpu/drm/i915/intel_fbc.c | 52 +++++------- drivers/gpu/drm/i915/intel_fbdev.c | 4 +- drivers/gpu/drm/i915/intel_sprite.c | 8 +- 7 files changed, 103 insertions(+), 135 deletions(-)drivers/gpu/drm/i915/i915_drv.h +4
-12@@ -1079,6 +1079,8 @@ struct intel_fbc {struct work_struct underrun_work;struct intel_fbc_state_cache { +struct i915_vma *vma; +struct {unsigned int mode_flags;uint32_t hsw_bdw_pixel_rate;@@ -1092,15 +1094,14 @@ struct intel_fbc { } plane;struct { -u64 ilk_ggtt_offset;const struct drm_format_info *format;unsigned int stride; -int fence_reg; -unsigned int tiling_mode; } fb; } state_cache;struct intel_fbc_reg_params { +struct i915_vma *vma; +struct {enum pipe pipe;enum plane plane;@@ -1108,10 +1109,8 @@ struct intel_fbc { } crtc;struct { -u64 ggtt_offset;const struct drm_format_info *format;unsigned int stride; -int fence_reg; } fb;int cfb_size;@@ -3406,13 +3405,6 @@ i915_gem_object_to_ggtt(struct drm_i915_gem_object *obj,return i915_gem_obj_to_vma (obj, &to_i915 (obj->base.dev)->ggtt.base, view); } -static inline unsigned long -i915_gem_object_ggtt_offset (struct drm_i915_gem_object *o, -const struct i915_ggtt_view *view) -{ -return i915_ggtt_offset (i915_gem_object_to_ggtt (o, view)); -} -/* i915_gem_fence_reg.c */ int __must_check i915_vma_get_fence (struct i915_vma *vma);int __must_check i915_vma_put_fence (struct i915_vma *vma);drivers/gpu/drm/i915/intel_atomic_plane.c +0
-0
drivers/gpu/drm/i915/intel_atomic_plane.c intel_plane_duplicate_state(struct drm_plane *plane) · line 88
Quoted 4 lines
drivers/gpu/drm/i915/intel_atomic_plane.c +1
-0@@ -85,6 +85,8 @@ intel_plane_duplicate_state(struct drm_plane *plane)__drm_atomic_helper_plane_duplicate_state (plane, state); + intel_state->vma =NULL ;
Shouldn't we be doing vma_get() instead?
Quoted 4 lines
drivers/gpu/drm/i915/intel_atomic_plane.c +1
-0+return state; }
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 87 lines · Ville Syrjälä
Quoted 86 lines · Maarten Lankhorst
From: Chris Wilson <[email protected]>
With atomic plane states we are able to track an allocation right from preparation, during use and through to the final free after being swapped out for a new plane. We can couple the VMA we pin for the framebuffer (and its rotation) to this lifetime and avoid all the clumsy lookups in between.
v2: Remove residual vma on plane cleanup (Chris)
v3: Add a description for the vma destruction in
intel_plane_destroy_state(Maarten)Signed-off-by Chris Wilson <[email protected]>Signed-off-by Maarten Lankhorst <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 16 +--- drivers/gpu/drm/i915/intel_atomic_plane.c | 20 +++++ drivers/gpu/drm/i915/intel_display.c | 129 +++++++++++------------------- drivers/gpu/drm/i915/intel_drv.h | 9 ++- drivers/gpu/drm/i915/intel_fbc.c | 52 +++++------- drivers/gpu/drm/i915/intel_fbdev.c | 4 +- drivers/gpu/drm/i915/intel_sprite.c | 8 +- 7 files changed, 103 insertions(+), 135 deletions(-)drivers/gpu/drm/i915/i915_drv.h +4
-12@@ -1079,6 +1079,8 @@ struct intel_fbc {struct work_struct underrun_work;struct intel_fbc_state_cache { +struct i915_vma *vma; +struct {unsigned int mode_flags;uint32_t hsw_bdw_pixel_rate;@@ -1092,15 +1094,14 @@ struct intel_fbc { } plane;struct { -u64 ilk_ggtt_offset;const struct drm_format_info *format;unsigned int stride; -int fence_reg; -unsigned int tiling_mode; } fb; } state_cache;struct intel_fbc_reg_params { +struct i915_vma *vma; +struct {enum pipe pipe;enum plane plane;@@ -1108,10 +1109,8 @@ struct intel_fbc { } crtc;struct { -u64 ggtt_offset;const struct drm_format_info *format;unsigned int stride; -int fence_reg; } fb;int cfb_size;@@ -3406,13 +3405,6 @@ i915_gem_object_to_ggtt(struct drm_i915_gem_object *obj,return i915_gem_obj_to_vma (obj, &to_i915 (obj->base.dev)->ggtt.base, view); } -static inline unsigned long -i915_gem_object_ggtt_offset (struct drm_i915_gem_object *o, -const struct i915_ggtt_view *view) -{ -return i915_ggtt_offset (i915_gem_object_to_ggtt (o, view)); -} -/* i915_gem_fence_reg.c */ int __must_check i915_vma_get_fence (struct i915_vma *vma);int __must_check i915_vma_put_fence (struct i915_vma *vma);drivers/gpu/drm/i915/intel_atomic_plane.c +0
-0@@ -85,6 +85,8 @@ intel_plane_duplicate_state(struct drm_plane *plane)
Quoted 5 lines
drivers/gpu/drm/i915/intel_atomic_plane.c intel_plane_duplicate_state(struct drm_plane *plane) · line 88
Quoted 3 lines
drivers/gpu/drm/i915/intel_atomic_plane.c +1
-0__drm_atomic_helper_plane_duplicate_state (plane, state); + intel_state->vma =NULL ;Shouldn't we be doing
vma_get()instead?
I went with NULL (dropping the copy) for simplicity. Before the plane can be used it must be prepared, so vma will always be set before commiting, and using NULL avoided having the reference counting dance. It also allowed detection of when we didn't prepare the plane as required.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 94 lines · Chris Wilson
Quoted 87 lines · Ville Syrjälä
Quoted 86 lines · Maarten Lankhorst
From: Chris Wilson <[email protected]>
With atomic plane states we are able to track an allocation right from preparation, during use and through to the final free after being swapped out for a new plane. We can couple the VMA we pin for the framebuffer (and its rotation) to this lifetime and avoid all the clumsy lookups in between.
v2: Remove residual vma on plane cleanup (Chris)
v3: Add a description for the vma destruction in
intel_plane_destroy_state(Maarten)Signed-off-by Chris Wilson <[email protected]>Signed-off-by Maarten Lankhorst <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 16 +--- drivers/gpu/drm/i915/intel_atomic_plane.c | 20 +++++ drivers/gpu/drm/i915/intel_display.c | 129 +++++++++++------------------- drivers/gpu/drm/i915/intel_drv.h | 9 ++- drivers/gpu/drm/i915/intel_fbc.c | 52 +++++------- drivers/gpu/drm/i915/intel_fbdev.c | 4 +- drivers/gpu/drm/i915/intel_sprite.c | 8 +- 7 files changed, 103 insertions(+), 135 deletions(-)drivers/gpu/drm/i915/i915_drv.h +4
-12@@ -1079,6 +1079,8 @@ struct intel_fbc {struct work_struct underrun_work;struct intel_fbc_state_cache { +struct i915_vma *vma; +struct {unsigned int mode_flags;uint32_t hsw_bdw_pixel_rate;@@ -1092,15 +1094,14 @@ struct intel_fbc { } plane;struct { -u64 ilk_ggtt_offset;const struct drm_format_info *format;unsigned int stride; -int fence_reg; -unsigned int tiling_mode; } fb; } state_cache;struct intel_fbc_reg_params { +struct i915_vma *vma; +struct {enum pipe pipe;enum plane plane;@@ -1108,10 +1109,8 @@ struct intel_fbc { } crtc;struct { -u64 ggtt_offset;const struct drm_format_info *format;unsigned int stride; -int fence_reg; } fb;int cfb_size;@@ -3406,13 +3405,6 @@ i915_gem_object_to_ggtt(struct drm_i915_gem_object *obj,return i915_gem_obj_to_vma (obj, &to_i915 (obj->base.dev)->ggtt.base, view); } -static inline unsigned long -i915_gem_object_ggtt_offset (struct drm_i915_gem_object *o, -const struct i915_ggtt_view *view) -{ -return i915_ggtt_offset (i915_gem_object_to_ggtt (o, view)); -} -/* i915_gem_fence_reg.c */ int __must_check i915_vma_get_fence (struct i915_vma *vma);int __must_check i915_vma_put_fence (struct i915_vma *vma);drivers/gpu/drm/i915/intel_atomic_plane.c +0
-0@@ -85,6 +85,8 @@ intel_plane_duplicate_state(struct drm_plane *plane)Quoted 5 lines
drivers/gpu/drm/i915/intel_atomic_plane.c intel_plane_duplicate_state(struct drm_plane *plane) · line 88
Quoted 3 lines
drivers/gpu/drm/i915/intel_atomic_plane.c +1
-0__drm_atomic_helper_plane_duplicate_state (plane, state); + intel_state->vma =NULL ;Shouldn't we be doing
vma_get()instead?
Quoted 5 lines
I went with NULL (dropping the copy) for simplicity. Before the plane can be used it must be prepared, so vma will always be set before commiting, and using NULL avoided having the reference counting dance. It also allowed detection of when we didn't prepare the plane as required.
Hmm. Does that risk some kind of failure at prepare_fb time if the vma got nuked in the meantime? I guess that might ahve to involve suspend/resume or some other case where we duplicate the state and don't hang on to the old state.
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 101 lines · Ville Syrjälä
Quoted 94 lines · Chris Wilson
Quoted 87 lines · Ville Syrjälä
Quoted 86 lines · Maarten Lankhorst
From: Chris Wilson <[email protected]>
With atomic plane states we are able to track an allocation right from preparation, during use and through to the final free after being swapped out for a new plane. We can couple the VMA we pin for the framebuffer (and its rotation) to this lifetime and avoid all the clumsy lookups in between.
v2: Remove residual vma on plane cleanup (Chris)
v3: Add a description for the vma destruction in
intel_plane_destroy_state(Maarten)Signed-off-by Chris Wilson <[email protected]>Signed-off-by Maarten Lankhorst <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 16 +--- drivers/gpu/drm/i915/intel_atomic_plane.c | 20 +++++ drivers/gpu/drm/i915/intel_display.c | 129 +++++++++++------------------- drivers/gpu/drm/i915/intel_drv.h | 9 ++- drivers/gpu/drm/i915/intel_fbc.c | 52 +++++------- drivers/gpu/drm/i915/intel_fbdev.c | 4 +- drivers/gpu/drm/i915/intel_sprite.c | 8 +- 7 files changed, 103 insertions(+), 135 deletions(-)drivers/gpu/drm/i915/i915_drv.h +4
-12@@ -1079,6 +1079,8 @@ struct intel_fbc {struct work_struct underrun_work;struct intel_fbc_state_cache { +struct i915_vma *vma; +struct {unsigned int mode_flags;uint32_t hsw_bdw_pixel_rate;@@ -1092,15 +1094,14 @@ struct intel_fbc { } plane;struct { -u64 ilk_ggtt_offset;const struct drm_format_info *format;unsigned int stride; -int fence_reg; -unsigned int tiling_mode; } fb; } state_cache;struct intel_fbc_reg_params { +struct i915_vma *vma; +struct {enum pipe pipe;enum plane plane;@@ -1108,10 +1109,8 @@ struct intel_fbc { } crtc;struct { -u64 ggtt_offset;const struct drm_format_info *format;unsigned int stride; -int fence_reg; } fb;int cfb_size;@@ -3406,13 +3405,6 @@ i915_gem_object_to_ggtt(struct drm_i915_gem_object *obj,return i915_gem_obj_to_vma (obj, &to_i915 (obj->base.dev)->ggtt.base, view); } -static inline unsigned long -i915_gem_object_ggtt_offset (struct drm_i915_gem_object *o, -const struct i915_ggtt_view *view) -{ -return i915_ggtt_offset (i915_gem_object_to_ggtt (o, view)); -} -/* i915_gem_fence_reg.c */ int __must_check i915_vma_get_fence (struct i915_vma *vma);int __must_check i915_vma_put_fence (struct i915_vma *vma);drivers/gpu/drm/i915/intel_atomic_plane.c +0
-0@@ -85,6 +85,8 @@ intel_plane_duplicate_state(struct drm_plane *plane)Quoted 5 lines
drivers/gpu/drm/i915/intel_atomic_plane.c intel_plane_duplicate_state(struct drm_plane *plane) · line 88
Quoted 3 lines
drivers/gpu/drm/i915/intel_atomic_plane.c +1
-0__drm_atomic_helper_plane_duplicate_state (plane, state); + intel_state->vma =NULL ;Shouldn't we be doing
vma_get()instead?Quoted 5 lines
I went with NULL (dropping the copy) for simplicity. Before the plane can be used it must be prepared, so vma will always be set before commiting, and using NULL avoided having the reference counting dance. It also allowed detection of when we didn't prepare the plane as required.
Quoted 4 lines
Hmm. Does that risk some kind of failure at
prepare_fbtime if the vma got nuked in the meantime? I guess that might ahve to involve suspend/resume or some other case where we duplicate the state and don't hang on to the old state.
If we are restoring the same plane_state, the old_plane_state will not be unpinned until after the swap. So prepare_fb will return the duplicate VMA with incremented pin_count.
So long as prepare_fb is always called, I don't think there is a hole. So long as.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 102 lines · Chris Wilson
Quoted 101 lines · Ville Syrjälä
Quoted 99 lines · Chris Wilson
Quoted 87 lines · Ville Syrjälä
Quoted 86 lines · Maarten Lankhorst
From: Chris Wilson <[email protected]>
With atomic plane states we are able to track an allocation right from preparation, during use and through to the final free after being swapped out for a new plane. We can couple the VMA we pin for the framebuffer (and its rotation) to this lifetime and avoid all the clumsy lookups in between.
v2: Remove residual vma on plane cleanup (Chris)
v3: Add a description for the vma destruction in
intel_plane_destroy_state(Maarten)Signed-off-by Chris Wilson <[email protected]>Signed-off-by Maarten Lankhorst <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 16 +--- drivers/gpu/drm/i915/intel_atomic_plane.c | 20 +++++ drivers/gpu/drm/i915/intel_display.c | 129 +++++++++++------------------- drivers/gpu/drm/i915/intel_drv.h | 9 ++- drivers/gpu/drm/i915/intel_fbc.c | 52 +++++------- drivers/gpu/drm/i915/intel_fbdev.c | 4 +- drivers/gpu/drm/i915/intel_sprite.c | 8 +- 7 files changed, 103 insertions(+), 135 deletions(-)drivers/gpu/drm/i915/i915_drv.h +4
-12@@ -1079,6 +1079,8 @@ struct intel_fbc {struct work_struct underrun_work;struct intel_fbc_state_cache { +struct i915_vma *vma; +struct {unsigned int mode_flags;uint32_t hsw_bdw_pixel_rate;@@ -1092,15 +1094,14 @@ struct intel_fbc { } plane;struct { -u64 ilk_ggtt_offset;const struct drm_format_info *format;unsigned int stride; -int fence_reg; -unsigned int tiling_mode; } fb; } state_cache;struct intel_fbc_reg_params { +struct i915_vma *vma; +struct {enum pipe pipe;enum plane plane;@@ -1108,10 +1109,8 @@ struct intel_fbc { } crtc;struct { -u64 ggtt_offset;const struct drm_format_info *format;unsigned int stride; -int fence_reg; } fb;int cfb_size;@@ -3406,13 +3405,6 @@ i915_gem_object_to_ggtt(struct drm_i915_gem_object *obj,return i915_gem_obj_to_vma (obj, &to_i915 (obj->base.dev)->ggtt.base, view); } -static inline unsigned long -i915_gem_object_ggtt_offset (struct drm_i915_gem_object *o, -const struct i915_ggtt_view *view) -{ -return i915_ggtt_offset (i915_gem_object_to_ggtt (o, view)); -} -/* i915_gem_fence_reg.c */ int __must_check i915_vma_get_fence (struct i915_vma *vma);int __must_check i915_vma_put_fence (struct i915_vma *vma);drivers/gpu/drm/i915/intel_atomic_plane.c +0
-0@@ -85,6 +85,8 @@ intel_plane_duplicate_state(struct drm_plane *plane)Quoted 5 lines
drivers/gpu/drm/i915/intel_atomic_plane.c intel_plane_duplicate_state(struct drm_plane *plane) · line 88
Quoted 3 lines
drivers/gpu/drm/i915/intel_atomic_plane.c +1
-0__drm_atomic_helper_plane_duplicate_state (plane, state); + intel_state->vma =NULL ;Shouldn't we be doing
vma_get()instead?I went with NULL (dropping the copy) for simplicity. Before the plane can be used it must be prepared, so vma will always be set before commiting, and using NULL avoided having the reference counting dance. It also allowed detection of when we didn't prepare the plane as required.
Quoted 8 lines
Quoted 4 lines
Hmm. Does that risk some kind of failure at
prepare_fbtime if the vma got nuked in the meantime? I guess that might ahve to involve suspend/resume or some other case where we duplicate the state and don't hang on to the old state.If we are restoring the same
plane_state, theold_plane_statewill not be unpinned until after the swap. Soprepare_fbwill return the duplicate VMA with incrementedpin_count.
During suspend we throw away the old state, and resume will read in the state from the hardware. So when we do the swap we won't have the original old state in place anymore.
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 8 lines · Ville Syrjälä
Quoted 3 lines · Chris Wilson
If we are restoring the same
plane_state, theold_plane_statewill not be unpinned until after the swap. Soprepare_fbwill return the duplicate VMA with incrementedpin_count.During suspend we throw away the old state, and resume will read in the state from the hardware. So when we do the swap we won't have the original old state in place anymore.
But in this case, we should have a plane_config from HW readout that has a recovered VMA? I presume the same takeover code is run after resume as on init...
On the other hand, if the plane_state was removed from the hardware, its VMA would be unpinned and we would be free to rebind it in a new location. Provided the obj itself wasn't freed, the VMA will be kept. However, we still risk a potential error on remapping (if the vma was unbound during suspend). That's not a huge risk though, and does require the VMA to be actually unbound on suspend.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Op 04-01-17 om 17:19 schreef Chris Wilson:
Quoted 11 lines · Ville Syrjälä
Quoted 7 lines · Chris Wilson
Quoted 3 lines
If we are restoring the same
plane_state, theold_plane_statewill not be unpinned until after the swap. Soprepare_fbwill return the duplicate VMA with incrementedpin_count.During suspend we throw away the old state, and resume will read in the state from the hardware. So when we do the swap we won't have the original old state in place anymore.
But in this case, we should have a
plane_configfrom HW readout that has a recovered VMA? I presume the same takeover code is run after resume as on init...
No, we only recover it during init. On resume we still have the old vma pinned and in plane_state. Which should be fine for our purpose, but even if we didn't resume should probably not fail.
Quoted 6 lines
On the other hand, if the
plane_statewas removed from the hardware, its VMA would be unpinned and we would be free to rebind it in a new location. Provided the obj itself wasn't freed, the VMA will be kept. However, we still risk a potential error on remapping (if the vma was unbound during suspend). That's not a huge risk though, and does require the VMA to be actually unbound on suspend.
Not currently the case, but it's an implementation detail that might be changed. :)
~Maarten
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Op 04-01-17 om 16:47 schreef Ville Syrjälä:
Quoted 98 lines · Chris Wilson
Quoted 90 lines · Ville Syrjälä
Quoted 89 lines · Maarten Lankhorst
Quoted 88 lines
From: Chris Wilson <[email protected]>
With atomic plane states we are able to track an allocation right from preparation, during use and through to the final free after being swapped out for a new plane. We can couple the VMA we pin for the framebuffer (and its rotation) to this lifetime and avoid all the clumsy lookups in between.
v2: Remove residual vma on plane cleanup (Chris)
v3: Add a description for the vma destruction in
intel_plane_destroy_state(Maarten)Signed-off-by Chris Wilson <[email protected]>Signed-off-by Maarten Lankhorst <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 16 +--- drivers/gpu/drm/i915/intel_atomic_plane.c | 20 +++++ drivers/gpu/drm/i915/intel_display.c | 129 +++++++++++------------------- drivers/gpu/drm/i915/intel_drv.h | 9 ++- drivers/gpu/drm/i915/intel_fbc.c | 52 +++++------- drivers/gpu/drm/i915/intel_fbdev.c | 4 +- drivers/gpu/drm/i915/intel_sprite.c | 8 +- 7 files changed, 103 insertions(+), 135 deletions(-)drivers/gpu/drm/i915/i915_drv.h +4
-12@@ -1079,6 +1079,8 @@ struct intel_fbc {struct work_struct underrun_work;struct intel_fbc_state_cache { +struct i915_vma *vma; +struct {unsigned int mode_flags;uint32_t hsw_bdw_pixel_rate;@@ -1092,15 +1094,14 @@ struct intel_fbc { } plane;struct { -u64 ilk_ggtt_offset;const struct drm_format_info *format;unsigned int stride; -int fence_reg; -unsigned int tiling_mode; } fb; } state_cache;struct intel_fbc_reg_params { +struct i915_vma *vma; +struct {enum pipe pipe;enum plane plane;@@ -1108,10 +1109,8 @@ struct intel_fbc { } crtc;struct { -u64 ggtt_offset;const struct drm_format_info *format;unsigned int stride; -int fence_reg; } fb;int cfb_size;@@ -3406,13 +3405,6 @@ i915_gem_object_to_ggtt(struct drm_i915_gem_object *obj,return i915_gem_obj_to_vma (obj, &to_i915 (obj->base.dev)->ggtt.base, view); } -static inline unsigned long -i915_gem_object_ggtt_offset (struct drm_i915_gem_object *o, -const struct i915_ggtt_view *view) -{ -return i915_ggtt_offset (i915_gem_object_to_ggtt (o, view)); -} -/* i915_gem_fence_reg.c */ int __must_check i915_vma_get_fence (struct i915_vma *vma);int __must_check i915_vma_put_fence (struct i915_vma *vma);drivers/gpu/drm/i915/intel_atomic_plane.c +0
-0@@ -85,6 +85,8 @@ intel_plane_duplicate_state(struct drm_plane *plane)__drm_atomic_helper_plane_duplicate_state (plane, state);Quoted 7 lines
Quoted 2 lines
drivers/gpu/drm/i915/intel_atomic_plane.c intel_plane_duplicate_state(struct drm_plane *plane) · line 88
Quoted 1 line
drivers/gpu/drm/i915/intel_atomic_plane.c +1
-0+ intel_state->vma =NULL ;Shouldn't we be doing
vma_get()instead?I went with NULL (dropping the copy) for simplicity. Before the plane can be used it must be prepared, so vma will always be set before commiting, and using NULL avoided having the reference counting dance. It also allowed detection of when we didn't prepare the plane as required.
Quoted 4 lines
Hmm. Does that risk some kind of failure at
prepare_fbtime if the vma got nuked in the meantime? I guess that might ahve to involve suspend/resume or some other case where we duplicate the state and don't hang on to the old state.
I think the way this is done is sane, and a nice safeguard against forgetting to call prepare. The old mapping is still around when prepare_plane_fb is called, and we keep the vma during suspend/resume since we never unset the plane fb. We only set crtc_state->active = false (dpms off).
~Maarten
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx