drm/i915: update cursors asynchronously through atomic
Subsystems (5)
PATCH v5 1/5 drm/i915: update cursors asynchronously through atomic
From: Gustavo Padovan <[email protected]>
Add support to async updates of cursors by using the new atomic interface for that. Basically what this commit does is do what intel_legacy_cursor_update() did but through atomic.
v4:
- call drm_atomic_helper_async_check() from the check hook
v3:
- set correct vma to new state for cleanup
- move size checks back to drivers (Ville Syrjälä)
v2:
- move fb setting to core and use new state (Eric Anholt)
--- drivers/gpu/drm/i915/intel_atomic_plane.c | 73 ++++++++++++++ drivers/gpu/drm/i915/intel_display.c | 160 +++++------------------------- 2 files changed, 100 insertions(+), 133 deletions(-)
drivers/gpu/drm/i915/intel_atomic_plane.c +73 -0
@@ -245,11 +245,84 @@ static void intel_plane_atomic_update(struct drm_plane *plane, } } +static int intel_plane_atomic_async_check (struct drm_plane *plane, +struct drm_plane_state *state) +{ +struct drm_crtc *crtc = plane->state->crtc; +struct drm_crtc_state *crtc_state = crtc->state; + +if (plane->type !=DRM_PLANE_TYPE_CURSOR ) +return -EINVAL ; + +/* +* When crtc is inactive or there is a modeset pending, +* wait for it to complete in the slowpath +*/ +if (!crtc_state->active ||to_intel_crtc_state (crtc_state)->update_pipe) +return -EINVAL ; + +/* +* If any parameters change that may affect watermarks, +* take the slowpath. Only changing fb or position should be +* in the fastpath. +*/ +if (plane->state->crtc != state->crtc || + plane->state->src_w != state->src_w || + plane->state->src_h != state->src_h || + plane->state->crtc_w != state->crtc_w || + plane->state->crtc_h != state->crtc_h || + !plane->state->fb != !state->fb) +return -EINVAL ; + +return 0 ; +} + +static void intel_plane_atomic_async_update (struct drm_plane *plane, +struct drm_plane_state *new_state) +{ +struct intel_plane *intel_plane =to_intel_plane (plane); +struct drm_crtc *crtc = plane->state->crtc; +struct drm_framebuffer *old_fb; +struct i915_vma *old_vma; + + old_vma =to_intel_plane_state (plane->state)->vma; + old_fb = plane->state->fb; + +i915_gem_track_fb (intel_fb_obj (old_fb),intel_fb_obj (new_state->fb), + intel_plane->frontbuffer_bit); + + plane->state->src_x = new_state->src_x; + plane->state->src_y = new_state->src_y; + plane->state->crtc_x = new_state->crtc_x; + plane->state->crtc_y = new_state->crtc_y; + plane->state->fb = new_state->fb; + *to_intel_plane_state (plane->state) = *to_intel_plane_state (new_state); + +to_intel_plane_state (new_state)->vma = old_vma; + new_state->fb = old_fb; + +if (plane->state->visible) { +trace_intel_update_plane (plane,to_intel_crtc (crtc)); + intel_plane->update_plane (intel_plane, +to_intel_crtc_state (crtc->state), +to_intel_plane_state (plane->state)); + }else { +trace_intel_disable_plane (plane,to_intel_crtc (crtc)); + intel_plane->disable_plane (intel_plane,to_intel_crtc (crtc)); + } + +mutex_lock (&plane->dev->struct_mutex); +intel_cleanup_plane_fb (plane, new_state); +mutex_unlock (&plane->dev->struct_mutex); +} +const struct drm_plane_helper_funcs intel_plane_helper_funcs = { .prepare_fb = intel_prepare_plane_fb, .cleanup_fb = intel_cleanup_plane_fb, .atomic_check = intel_plane_atomic_check, .atomic_update = intel_plane_atomic_update, + .atomic_async_check = intel_plane_atomic_async_check, + .atomic_async_update = intel_plane_atomic_async_update, };/**
drivers/gpu/drm/i915/intel_display.c +27 -133
185 lines not on this page · raw message
Signature · 6 lines
2.13.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 2/5 drm/i915: remove intel_cursor_plane_funcs
From: Gustavo Padovan <[email protected]>
After converting legacy cursor updates to atomic async commits intel_cursor_plane_funcs just duplicates intel_plane_funcs now.
--- drivers/gpu/drm/i915/intel_display.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -11
@@ -13547,16 +13547,6 @@ const struct drm_plane_funcs intel_plane_funcs = { .atomic_destroy_state = intel_plane_destroy_state, }; -static const struct drm_plane_funcs intel_cursor_plane_funcs = { - .update_plane = drm_atomic_helper_update_plane, - .disable_plane = drm_atomic_helper_disable_plane, - .destroy = intel_plane_destroy, - .atomic_get_property = intel_plane_atomic_get_property, - .atomic_set_property = intel_plane_atomic_set_property, - .atomic_duplicate_state = intel_plane_duplicate_state, - .atomic_destroy_state = intel_plane_destroy_state, -}; -static struct intel_plane *intel_primary_plane_create (struct drm_i915_private *dev_priv,enum pipe pipe) {
@@ -13721,7 +13711,7 @@ intel_cursor_plane_create(struct drm_i915_private *dev_priv, cursor->cursor.size = ~0 ; ret = drm_universal_plane_init(&dev_priv->drm, &cursor->base, - 0, &intel_cursor_plane_funcs, + 0, &intel_plane_funcs, intel_cursor_formats, ARRAY_SIZE(intel_cursor_formats), NULL, DRM_PLANE_TYPE_CURSOR,
Signature · 6 lines
2.13.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 3/5 drm/msm: update cursors asynchronously through atomic
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
Add support to async updates of cursors by using the new atomic interface for that. Basically what this commit does is do what mdp5_update_cursor_plane_legacy() did but through atomic.
v5: call drm_atomic_helper_async_check() from the check hook
v4: add missing atomic async commit call to msm_atomic_commit(Archit Taneja)
v3: move size checks back to drivers (Ville Syrjälä)
v2: move fb setting to core and use new state (Eric Anholt)
--- drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 151 +++++++++++++----------------- drivers/gpu/drm/msm/msm_atomic.c | 9 ++ 2 files changed, 72 insertions(+), 88 deletions(-)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +63 -88
@@ -31,15 +31,6 @@ static int mdp5_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb, struct drm_rect *src, struct drm_rect *dest); -static int mdp5_update_cursor_plane_legacy (struct drm_plane *plane, -struct drm_crtc *crtc, -struct drm_framebuffer *fb, -int crtc_x,int crtc_y, -unsigned int crtc_w,unsigned int crtc_h, -uint32_t src_x,uint32_t src_y, -uint32_t src_w,uint32_t src_h, -struct drm_modeset_acquire_ctx *ctx); -static struct mdp5_kms *get_kms (struct drm_plane *plane) {struct msm_drm_private *priv = plane->dev->dev_private;
@@ -255,7 +246,7 @@ static const struct drm_plane_funcs mdp5_plane_funcs = { };static const struct drm_plane_funcs mdp5_cursor_plane_funcs = { - .update_plane = mdp5_update_cursor_plane_legacy, + .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, .destroy = mdp5_plane_destroy, .atomic_set_property = mdp5_plane_atomic_set_property,
@@ -487,11 +478,73 @@ static void mdp5_plane_atomic_update(struct drm_plane *plane, } } +static int mdp5_plane_atomic_async_check (struct drm_plane *plane, +struct drm_plane_state *state) +{ +struct mdp5_plane_state *mdp5_state =to_mdp5_plane_state (state); +struct drm_crtc_state *crtc_state; + + crtc_state =drm_atomic_get_existing_crtc_state (state->state, + state->crtc); +if (WARN_ON (!crtc_state)) +return -EINVAL ; + +if (!crtc_state->active) +return -EINVAL ; + + mdp5_state =to_mdp5_plane_state (state); + +/* don't use fast path if we don't have a hwpipe allocated yet */ +if (!mdp5_state->hwpipe) +return -EINVAL ; + +/* only allow changing of position(crtc x/y or src x/y) in fast path */ +if (plane->state->crtc != state->crtc || + plane->state->src_w != state->src_w || + plane->state->src_h != state->src_h || + plane->state->crtc_w != state->crtc_w || + plane->state->crtc_h != state->crtc_h || + !plane->state->fb || + plane->state->fb != state->fb) +return -EINVAL ; + +return 0 ; +} + +static void mdp5_plane_atomic_async_update (struct drm_plane *plane, +struct drm_plane_state *new_state) +{ + plane->state->src_x = new_state->src_x; + plane->state->src_y = new_state->src_y; + plane->state->crtc_x = new_state->crtc_x; + plane->state->crtc_y = new_state->crtc_y; + +if (plane_enabled (new_state)) { +struct mdp5_ctl *ctl; +struct mdp5_pipeline *pipeline = +mdp5_crtc_get_pipeline (plane->crtc); +int ret; + + ret =mdp5_plane_mode_set (plane, new_state->crtc, new_state->fb, + &new_state->src, &new_state->dst); +WARN_ON (ret <0 ); + + ctl =mdp5_crtc_get_ctl (new_state->crtc); + +mdp5_ctl_commit (ctl, pipeline,mdp5_plane_get_flush (plane)); + } + + *to_mdp5_plane_state (plane->state) = + *to_mdp5_plane_state (new_state); +} +static const struct drm_plane_helper_funcs mdp5_plane_helper_funcs = { .prepare_fb = mdp5_plane_prepare_fb, .cleanup_fb = mdp5_plane_cleanup_fb, .atomic_check = mdp5_plane_atomic_check, .atomic_update = mdp5_plane_atomic_update, + .atomic_async_check = mdp5_plane_atomic_async_check, + .atomic_async_update = mdp5_plane_atomic_async_update, }; static void set_scanout_locked(struct mdp5_kms *mdp5_kms,
@@ -996,84 +1049,6 @@ static int mdp5_plane_mode_set(struct drm_plane *plane,return ret; } -static int mdp5_update_cursor_plane_legacy (struct drm_plane *plane, -struct drm_crtc *crtc,struct drm_framebuffer *fb, -int crtc_x,int crtc_y, -unsigned int crtc_w,unsigned int crtc_h, -uint32_t src_x,uint32_t src_y, -uint32_t src_w,uint32_t src_h, -struct drm_modeset_acquire_ctx *ctx) -{ -struct drm_plane_state *plane_state, *new_plane_state; -struct mdp5_plane_state *mdp5_pstate; -struct drm_crtc_state *crtc_state = crtc->state; -int ret; - -if (!crtc_state->active ||drm_atomic_crtc_needs_modeset (crtc_state)) - goto slow; - - plane_state = plane->state; - mdp5_pstate =to_mdp5_plane_state (plane_state); - -/* don't use fast path if we don't have a hwpipe allocated yet */ -if (!mdp5_pstate->hwpipe) - goto slow; - -/* only allow changing of position(crtc x/y or src x/y) in fast path */ -if (plane_state->crtc != crtc || - plane_state->src_w != src_w || - plane_state->src_h != src_h || - plane_state->crtc_w != crtc_w || - plane_state->crtc_h != crtc_h || - !plane_state->fb || - plane_state->fb != fb) - goto slow; - - new_plane_state =mdp5_plane_duplicate_state (plane); -if (!new_plane_state) -return -ENOMEM ; - - new_plane_state->src_x = src_x; - new_plane_state->src_y = src_y; - new_plane_state->src_w = src_w; - new_plane_state->src_h = src_h; - new_plane_state->crtc_x = crtc_x; - new_plane_state->crtc_y = crtc_y; - new_plane_state->crtc_w = crtc_w; - new_plane_state->crtc_h = crtc_h; - - ret =mdp5_plane_atomic_check_with_state (crtc_state, new_plane_state); -if (ret) - goto slow_free; - -if (new_plane_state->visible) { -struct mdp5_ctl *ctl; -struct mdp5_pipeline *pipeline =mdp5_crtc_get_pipeline (crtc); - - ret =mdp5_plane_mode_set (plane, crtc, fb, - &new_plane_state->src, - &new_plane_state->dst); -WARN_ON (ret <0 ); - - ctl =mdp5_crtc_get_ctl (crtc); - -mdp5_ctl_commit (ctl, pipeline,mdp5_plane_get_flush (plane)); - } - - *to_mdp5_plane_state (plane_state) = - *to_mdp5_plane_state (new_plane_state); - -mdp5_plane_destroy_state (plane, new_plane_state); - -return 0 ; -slow_free: -mdp5_plane_destroy_state (plane, new_plane_state); -slow: -return drm_atomic_helper_update_plane (plane, crtc, fb, - crtc_x, crtc_y, crtc_w, crtc_h, - src_x, src_y, src_w, src_h, ctx); -} -/* * Use this func and the one below only after the atomic state has been * successfully swapped
drivers/gpu/drm/msm/msm_atomic.c +9 -0
@@ -172,6 +172,9 @@ int msm_atomic_check(struct drm_device *dev,if (ret)return ret; +if (state->legacy_cursor_update) + state->async_update = !drm_atomic_helper_async_check (dev, state); +return ret; }
@@ -202,6 +205,12 @@ int msm_atomic_commit(struct drm_device *dev,if (ret)return ret; +if (state->async_update) { +drm_atomic_helper_async_commit (dev, state); +drm_atomic_helper_cleanup_planes (dev, state); +return 0 ; + } + c =commit_init (state);if (!c) { ret = -ENOMEM ;
Signature · 6 lines
2.13.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 4/5 drm/msm: remove mdp5_cursor_plane_funcs
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
After converting legacy cursor updates to atomic async commits mdp5_cursor_plane_funcs just duplicates mdp5_plane_funcs now.
--- drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +4 -22
@@ -245,18 +245,6 @@ static const struct drm_plane_funcs mdp5_plane_funcs = { .atomic_print_state = mdp5_plane_atomic_print_state, }; -static const struct drm_plane_funcs mdp5_cursor_plane_funcs = { - .update_plane = drm_atomic_helper_update_plane, - .disable_plane = drm_atomic_helper_disable_plane, - .destroy = mdp5_plane_destroy, - .atomic_set_property = mdp5_plane_atomic_set_property, - .atomic_get_property = mdp5_plane_atomic_get_property, - .reset = mdp5_plane_reset, - .atomic_duplicate_state = mdp5_plane_duplicate_state, - .atomic_destroy_state = mdp5_plane_destroy_state, - .atomic_print_state = mdp5_plane_atomic_print_state, -}; -static int mdp5_plane_prepare_fb (struct drm_plane *plane,struct drm_plane_state *new_state) {
@@ -1108,16 +1096,10 @@ struct drm_plane *mdp5_plane_init(struct drm_device *dev, mdp5_plane->nformats =mdp_get_formats (mdp5_plane->formats,ARRAY_SIZE (mdp5_plane->formats), false); -if (type ==DRM_PLANE_TYPE_CURSOR ) - ret =drm_universal_plane_init (dev, plane,0xff , - &mdp5_cursor_plane_funcs, - mdp5_plane->formats, mdp5_plane->nformats, -NULL , type,NULL ); -else - ret =drm_universal_plane_init (dev, plane,0xff , - &mdp5_plane_funcs, - mdp5_plane->formats, mdp5_plane->nformats, -NULL , type,NULL ); + ret =drm_universal_plane_init (dev, plane,0xff , &mdp5_plane_funcs, + mdp5_plane->formats, + mdp5_plane->nformats, +NULL , type,NULL );if (ret) goto fail;
Signature · 6 lines
2.13.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 5/5 drm/vc4: update cursors asynchronously through atomic
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
Add support for async updates of cursors by using the new atomic interface for that. Basically what this commit does is do what vc4_update_plane() did but through atomic.
v5: add missing call to vc4_plane_atomic_check() (Eric Anholt)
v4: add drm_atomic_helper_async() commit (Eric Anholt)
v3: move size checks back to drivers (Ville Syrjälä)
v2: move fb setting to core and use new state (Eric Anholt)
--- drivers/gpu/drm/vc4/vc4_kms.c | 20 +++++++ drivers/gpu/drm/vc4/vc4_plane.c | 128 ++++++++++++++++------------------------ 2 files changed, 71 insertions(+), 77 deletions(-)
drivers/gpu/drm/vc4/vc4_kms.c +20 -0
@@ -96,6 +96,26 @@ static int vc4_atomic_commit(struct drm_device *dev,struct vc4_dev *vc4 =to_vc4_dev (dev);int ret; +if (state->async_update) { + ret =down_interruptible (&vc4->async_modeset); +if (ret) +return ret; + + ret =drm_atomic_helper_prepare_planes (dev, state); +if (ret) { +up (&vc4->async_modeset); +return ret; + } + +drm_atomic_helper_async_commit (dev, state); + +drm_atomic_helper_cleanup_planes (dev, state); + +up (&vc4->async_modeset); + +return 0 ; + } + ret =drm_atomic_helper_setup_commit (state, nonblock);if (ret)return ret;
drivers/gpu/drm/vc4/vc4_plane.c +51 -77
158 lines not on this page · raw message
Signature · 6 lines
2.13.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoting Gustavo Padovan (2017-09-08 20:24:15)
Quoted 6 lines
drivers/gpu/drm/i915/intel_display.c +2
-0@@ -13167,6 +13170,26 @@ static int intel_atomic_commit(struct drm_device *dev,struct drm_i915_private *dev_priv =to_i915 (dev);int ret =0 ; +/* +* The atomic async update fast path takes care
drivers/gpu/drm/i915/intel_display.c static int intel_atomic_commit(struct drm_device *dev, · line 13184
Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10
-0+* of avoiding the vblank waits for simple cursor +* movement and flips. For cursor on/off and size changes, +* we want to perform the vblank waits so that watermark +* updates happen during the correct frames. Gen9+ have +* double buffered watermarks and so shouldn't need this. +*/ +if (state->async_update) { + ret =mutex_lock_interruptible (&dev->struct_mutex); +if (ret) +return ret;
This deadlock should be found by the test suite, or else we are missing tests!
drivers/gpu/drm/i915/intel_display.c static int intel_atomic_commit(struct drm_device *dev, · line 13186
Quoted 2 lines
drivers/gpu/drm/i915/intel_display.c +2
-0+ + ret =drm_atomic_helper_prepare_planes (dev, state);
And that will make adding the missing if (ret) return ret; easier.
drivers/gpu/drm/i915/intel_display.c static int intel_atomic_commit(struct drm_device *dev, · line 13195
Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +6
-0+mutex_unlock (&dev->struct_mutex); + +drm_atomic_helper_async_commit (dev, state); +return 0 ; + } + ret =drm_atomic_helper_setup_commit (state, nonblock);if (ret)return ret;
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
2017-09-08 Chris Wilson <[email protected]>:
Quoted 5 lines
Quoting Gustavo Padovan (2017-09-08 20:24:15)
Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +0
-0@@ -13167,6 +13170,26 @@ static int intel_atomic_commit(struct drm_device *dev,struct drm_i915_private *dev_priv =to_i915 (dev);int ret =0 ;
Quoted 15 lines
drivers/gpu/drm/i915/intel_display.c static int intel_atomic_commit(struct drm_device *dev, · line 13184
Quoted 12 lines
drivers/gpu/drm/i915/intel_display.c +12
-0+/* +* The atomic async update fast path takes care +* of avoiding the vblank waits for simple cursor +* movement and flips. For cursor on/off and size changes, +* we want to perform the vblank waits so that watermark +* updates happen during the correct frames. Gen9+ have +* double buffered watermarks and so shouldn't need this. +*/ +if (state->async_update) { + ret =mutex_lock_interruptible (&dev->struct_mutex); +if (ret) +return ret;This deadlock should be found by the test suite, or else we are missing tests!
It seems that I missed the fact that the driver changed when I rebased and resent. I'll investigate this further and come back with another patch.
Gustavo
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx