drm/atomic: add async plane update
Subsystems (6)
v3 cover drm/atomic: add async plane update
From: Gustavo Padovan <[email protected]>
Hi,
One more take of Asynchronous Plane Updates over Atomic. Here I looked to msm, vc4 and i915 to identify a common pattern to create atomic helpers for async updates. So in patch 1 drm_atomic_async_check() and drm_atomic_helper_async_commit() are introduced along with driver's plane hooks:
->atomic_async_check() and ->atomic_async_commit().
For now we only support async update for one plane at a time. Also the async update can't modify the CRTC so no modesets are allowed.
Then the other patches add support for it in the drivers. I did virtio mostly for testing. msm and vc4 are only compile-tested.
I started IGT changes to test the Atomic IOCTL with the new flag:
https://git.collabora.com/cgit/user/padovan/intel-gpu-tools.git/
Support for async page flips and drm core workers to delay plane/fb clean up are not plane for this patchset.
TODO
* improve i-g-t tests where needed
Gustavo Padovan (8):
drm/atomic: initial support for asynchronous plane update drm/virtio: support async cursor updates drm/i915: update cursors asynchronously through atomic drm/i915: remove intel_cursor_plane_funcs drm/msm: update cursors asynchronously through atomic drm/msm: remove mdp5_cursor_plane_funcs
drm/vc4: update cursors asynchronously through atomic drm/atomic: add ASYNC_UPDATE flag to the Atomic IOCTL
drivers/gpu/drm/drm_atomic.c | 71 +++++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 48 +++++++++ drivers/gpu/drm/i915/intel_atomic_plane.c | 67 ++++++++++++ drivers/gpu/drm/i915/intel_display.c | 160 +++++----------------------- drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 170 +++++++++++------------------- drivers/gpu/drm/vc4/vc4_plane.c | 96 ++++++----------- drivers/gpu/drm/virtio/virtgpu_plane.c | 48 +++++++++ include/drm/drm_atomic.h | 2 + include/drm/drm_atomic_helper.h | 2 + include/drm/drm_modeset_helper_vtables.h | 48 +++++++++ include/uapi/drm/drm_mode.h | 4 +- 11 files changed, 404 insertions(+), 312 deletions(-)
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC v3 1/8 drm/atomic: initial support for asynchronous plane update
From: Gustavo Padovan <[email protected]>
In some cases, like cursor updates, it is interesting to update the plane in an asynchronous fashion to avoid big delays. The current queued update could be still waiting for a fence to signal and thus block any subsequent update until its scan out. In cases like this if we update the cursor synchronously through the atomic API it will cause significant delays that would even be noticed by the final user.
This patch creates a fast path to jump ahead the current queued state and do single planes updates without going through all atomic steps in drm_atomic_helper_commit(). We take this path for legacy cursor updates.
For now only single plane updates are supported, but we plan to support multiple planes updates and async PageFlips through this interface as well in the near future.
v3:
- fix iteration on the wrong crtc state
- put back code to forbid updates if there is a queued update for the same plane (Ville Syrjälä)
- move size checks back to drivers (Ville Syrjälä)
- move ASYNC_UPDATE flag addition to its own patch (Ville Syrjälä)
v2:
- allow updates even if there is a queued update for the same plane.
- fixes on the documentation (Emil Velikov)
- unconditionally call ->atomic_async_update (Emil Velikov)
- check for ->atomic_async_update earlier (Daniel Vetter)
- make ->atomic_async_check() the last step (Daniel Vetter)
- add ASYNC_UPDATE flag (Eric Anholt)
- update state in core after ->atomic_async_update (Eric Anholt)
- update docs (Eric Anholt)
--- drivers/gpu/drm/drm_atomic.c | 65 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 35 +++++++++++++++++ include/drm/drm_atomic.h | 2 + include/drm/drm_atomic_helper.h | 2 + include/drm/drm_modeset_helper_vtables.h | 48 +++++++++++++++++++++++ 5 files changed, 152 insertions(+)
drivers/gpu/drm/drm_atomic.c +65 -0
@@ -631,6 +631,68 @@ static int drm_atomic_crtc_check(struct drm_crtc *crtc,return 0 ; } +static bool drm_atomic_async_check (struct drm_atomic_state *state) +{ +struct drm_crtc *crtc; +struct drm_crtc_state *crtc_state; +struct drm_crtc_commit *commit; +struct drm_plane *__plane, *plane =NULL ; +struct drm_plane_state *__plane_state, *plane_state =NULL ; +const struct drm_plane_helper_funcs *funcs; +int i, j, n_planes =0 ; + +for_each_new_crtc_in_state (state, crtc, crtc_state, i) { +if (drm_atomic_crtc_needs_modeset (crtc_state)) +return false; + } + +for_each_new_plane_in_state (state, __plane, __plane_state, i) { + n_planes++; + plane = __plane; + plane_state = __plane_state; + } + +/* FIXME: we support only single plane updates for now */ +if (!plane || n_planes !=1 ) +return false; + +if (!plane->state->crtc) +return false; + + funcs = plane->helper_private; +if (!funcs->atomic_async_update) +return false; + +if (plane_state->fence) +return false; + +for_each_new_crtc_in_state (state, crtc, crtc_state, i) { +if (plane->crtc != crtc) +continue ; + +spin_lock (&crtc->commit_lock); + commit =list_first_entry_or_null (&crtc->commit_list, + struct drm_crtc_commit, + commit_entry); +if (!commit) { +spin_unlock (&crtc->commit_lock); +continue ; + } +spin_unlock (&crtc->commit_lock); + +if (!crtc->state->state) +continue ; + +for_each_plane_in_state (crtc->state->state, __plane, + __plane_state, j) { +if (__plane == plane) +return false; + } + } + +return !funcs->atomic_async_check (plane, plane_state); +} +static void drm_atomic_crtc_print_state (struct drm_printer *p,const struct drm_crtc_state *state) {
@@ -1591,6 +1653,9 @@ int drm_atomic_check_only(struct drm_atomic_state *state) } } +if (state->legacy_cursor_update) + state->async_update =drm_atomic_async_check (state); +return ret; }EXPORT_SYMBOL (drm_atomic_check_only);
drivers/gpu/drm/drm_atomic_helper.c +35 -0
@@ -1235,6 +1235,30 @@ static void commit_work(struct work_struct *work) }/** +* drm_atomic_helper_async_commit - commit state asynchronously +* +* This function commits a state asynchronously, i.e., not vblank +* synchronized. It should be used on a state only when +* drm_atomic_async_check() succeeds. Async commits are not supposed to swap +* the states like normal sync commits, but just do in-place changes on the +* current state. +*/ +void drm_atomic_helper_async_commit (struct drm_device *dev, +struct drm_atomic_state *state) +{ +struct drm_plane *plane; +struct drm_plane_state *plane_state; +const struct drm_plane_helper_funcs *funcs; +int i; + +for_each_new_plane_in_state (state, plane, plane_state, i) { + funcs = plane->helper_private; + funcs->atomic_async_update (plane, plane_state); + } +} +EXPORT_SYMBOL (drm_atomic_helper_async_commit); + +/** * drm_atomic_helper_commit - commit validated state object * @dev: DRM device * @state: the driver state object
@@ -1258,6 +1282,17 @@ int drm_atomic_helper_commit(struct drm_device *dev, {int ret; +if (state->async_update) { + ret =drm_atomic_helper_prepare_planes (dev, state); +if (ret) +return ret; + +drm_atomic_helper_async_commit (dev, state); +drm_atomic_helper_cleanup_planes (dev, state); + +return 0 ; + } + ret =drm_atomic_helper_setup_commit (state, nonblock);if (ret)return ret;
include/drm/drm_atomic.h +2 -0
@@ -160,6 +160,7 @@ struct __drm_connnectors_state {* @dev: parent DRM device * @allow_modeset: allow full modeset * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics +* @async_update: hint for asynchronous plane update * @planes: pointer to array of structures with per-plane data * @crtcs: pointer to array of CRTC pointers * @num_connector: size of the @connectors and @connector_states arrays
@@ -172,6 +173,7 @@ struct drm_atomic_state {struct drm_device *dev; bool allow_modeset : 1; bool legacy_cursor_update : 1; + bool async_update : 1;struct __drm_planes_state *planes;struct __drm_crtcs_state *crtcs;int num_connector;
include/drm/drm_atomic_helper.h +2 -0
@@ -44,6 +44,8 @@ void drm_atomic_helper_commit_tail(struct drm_atomic_state *state);int drm_atomic_helper_commit (struct drm_device *dev,struct drm_atomic_state *state,bool nonblock); +void drm_atomic_helper_async_commit (struct drm_device *dev, +struct drm_atomic_state *state); int drm_atomic_helper_wait_for_fences(struct drm_device *dev, struct drm_atomic_state *state,
include/drm/drm_modeset_helper_vtables.h +48 -0
54 lines not on this page · raw message
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC v3 2/8 drm/virtio: support async cursor updates
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
Short circuit the update path for cursors and use the drm async update infrastructure.
v2: move fb setting to core and use new state (Eric Anholt)
---
I wrote this mostly for testing purposes, not sure if its something that we actually need for virtio.
--- drivers/gpu/drm/virtio/virtgpu_plane.c | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
drivers/gpu/drm/virtio/virtgpu_plane.c +53 -0
@@ -260,6 +260,57 @@ static void virtio_gpu_cursor_plane_update(struct drm_plane *plane,virtio_gpu_cursor_ping (vgdev, output); } +static int virtio_gpu_cursor_plane_async_check (struct drm_plane *plane, +struct drm_plane_state *new_state) +{ +struct virtio_gpu_output *output; + +if (!plane->state->crtc) +return -EINVAL ; + + output =drm_crtc_to_virtio_gpu_output (plane->state->crtc); +if (!output) +return -EINVAL ; + +if (plane->state->crtc != new_state->crtc || + plane->state->src_w != new_state->src_w || + plane->state->src_h != new_state->src_h || + plane->state->crtc_w != new_state->crtc_w || + plane->state->crtc_h != new_state->crtc_h || + !plane->state->fb || + plane->state->fb != new_state->fb) +return -EINVAL ; + +return 0 ; +} + +static void virtio_gpu_cursor_plane_async_update (struct drm_plane *plane, +struct drm_plane_state *new_state) +{ +struct drm_device *dev = plane->dev; +struct virtio_gpu_device *vgdev = dev->dev_private; +struct virtio_gpu_output *output =NULL ; + + output =drm_crtc_to_virtio_gpu_output (plane->state->crtc); +if (WARN_ON (!output)) +return ; + +if (plane->state->fb != new_state->fb) +return ; + + 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; + +DRM_DEBUG ("move +%d+%d\n" , plane->state->crtc_x, plane->state->crtc_y); + + output->cursor.hdr.type =cpu_to_le32 (VIRTIO_GPU_CMD_MOVE_CURSOR ); + output->cursor.pos.x =cpu_to_le32 (plane->state->crtc_x); + output->cursor.pos.y =cpu_to_le32 (plane->state->crtc_y); +virtio_gpu_cursor_ping (vgdev, output); +} +static const struct drm_plane_helper_funcs virtio_gpu_primary_helper_funcs = { .atomic_check = virtio_gpu_plane_atomic_check, .atomic_update = virtio_gpu_primary_plane_update,
@@ -268,6 +319,8 @@ static const struct drm_plane_helper_funcs virtio_gpu_primary_helper_funcs = {static const struct drm_plane_helper_funcs virtio_gpu_cursor_helper_funcs = { .atomic_check = virtio_gpu_plane_atomic_check, .atomic_update = virtio_gpu_cursor_plane_update, + .atomic_async_check = virtio_gpu_cursor_plane_async_check, + .atomic_async_update = virtio_gpu_cursor_plane_async_update, }; struct drm_plane *virtio_gpu_plane_init(struct virtio_gpu_device *vgdev,
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC v3 3/8 drm/i915: 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 intel_legacy_cursor_update() did but through atomic.
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 | 149 +++++------------------------- 2 files changed, 97 insertions(+), 125 deletions(-)
drivers/gpu/drm/i915/intel_atomic_plane.c +73 -0
@@ -246,11 +246,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 (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 (plane, 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 +24 -125
168 lines not on this page · raw message
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC v3 4/8 drm/i915: remove intel_cursor_plane_funcs
In reply to Gustavo PadovanFrom: 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 | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -12
@@ -13418,17 +13418,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, - .set_property = drm_atomic_helper_plane_set_property, - .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) {
@@ -13675,7 +13664,7 @@ intel_cursor_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe) cursor->disable_plane = intel_disable_cursor_plane; 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), DRM_PLANE_TYPE_CURSOR,
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC v3 5/8 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.
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 +++++++++++++----------------- 1 file changed, 63 insertions(+), 88 deletions(-)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +63 -88
@@ -33,15 +33,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;
@@ -257,7 +248,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, .set_property = drm_atomic_helper_plane_set_property,
@@ -484,11 +475,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,
@@ -997,84 +1050,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
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC v3 5/8] drm/msm: update cursors asynchronously through atomic
Quoted 5 lines · Gustavo Padovan
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
mdp5_update_cursor_plane_legacy()did but through atomic.
Works well on DB820c (which has a APQ8096 SoC).
Quoted 200 lines
v3: move size checks back to drivers (Ville Syrjälä)
v2: move fb setting to core and use new state (Eric Anholt)
Cc Rob Clark <[email protected]>Signed-off-by Gustavo Padovan <[email protected]>--- drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 151 +++++++++++++----------------- 1 file changed, 63 insertions(+), 88 deletions(-)drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +63
-88@@ -33,15 +33,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;@@ -257,7 +248,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, .set_property = drm_atomic_helper_plane_set_property,@@ -484,11 +475,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,@@ -997,84 +1050,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
Signature · 6 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC v3 5/8] drm/msm: update cursors asynchronously through atomic
Hi,
Quoted 5 lines · Archit Taneja
Quoted 2 lines · Gustavo Padovan
From: Gustavo Padovan <[email protected]>
Quoted 7 lines
Quoted 3 lines
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.Works well on DB820c (which has a APQ8096 SoC).
Tested-by Archit Taneja <[email protected]>
Actually, after some more thorough testing, I found one issue, mentioned below.
Quoted 42 lines
Quoted 42 lines
v3: move size checks back to drivers (Ville Syrjälä)
v2: move fb setting to core and use new state (Eric Anholt)
Cc Rob Clark <[email protected]>Signed-off-by Gustavo Padovan <[email protected]>--- drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 151 +++++++++++++----------------- 1 file changed, 63 insertions(+), 88 deletions(-)drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +1
-9@@ -33,15 +33,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;@@ -257,7 +248,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, .set_property = drm_atomic_helper_plane_set_property,@@ -484,11 +475,73 @@ static void mdp5_plane_atomic_update(struct drm_plane *plane, } }
Quoted 8 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c static void mdp5_plane_atomic_update(struct drm_plane *plane, · line 484
Quoted 8 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +7
-0+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);
I see a kernel splat here (a NULL pointer dereference). The async_check function assumes that there is always going to be a plane_state->crtc available. This doesn't seem to be the case at least in the drm_atomic_helper_disable_plane() path. Moving the check to set legacy_cursor_update after calling __drm_atomic_helper_disable_plane() seems to fix the issue. Do you think it's a legit fix?
One more point w.r.t msm driver is that we don't use the default drm_atomic_helper_commit() for our atomic_commit op. So I had to call drm_atomic_helper_async_commit() from our atomic_commit implementation
(i.e, in msm_atomic_commit in drivers/gpu/drm/msm/msm_atomic.c)
Thanks,
Archit
Quoted 138 lines
Quoted 138 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +54
-73+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,@@ -997,84 +1050,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,
Quoted 9 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c static int mdp5_plane_mode_set(struct drm_plane *plane, · line 1055
Quoted 8 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +0
-4- 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/drm_atomic_helper.c +4 -3
@@ -2230,13 +2230,14 @@ int drm_atomic_helper_disable_plane(struct drm_plane *plane, goto fail; } -if (plane_state->crtc && (plane == plane->crtc->cursor)) - plane_state->state->legacy_cursor_update = true; - ret =__drm_atomic_helper_disable_plane (plane, plane_state);if (ret !=0 ) goto fail; +if (plane_state->crtc && (plane == plane->crtc->cursor)) + plane_state->state->legacy_cursor_update = true; + + ret =drm_atomic_commit (state); fail:drm_atomic_state_put (state);
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC v3 5/8] drm/msm: update cursors asynchronously through atomic
Quoted 67 lines · Archit Taneja
Hi,
Quoted 5 lines · Archit Taneja
Quoted 2 lines · Gustavo Padovan
From: Gustavo Padovan <[email protected]>
Quoted 7 lines
Quoted 3 lines
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.Works well on DB820c (which has a APQ8096 SoC).
Tested-by Archit Taneja <[email protected]>Actually, after some more thorough testing, I found one issue, mentioned below.
Quoted 49 lines
Quoted 49 lines
v3: move size checks back to drivers (Ville Syrjälä)
v2: move fb setting to core and use new state (Eric Anholt)
Cc Rob Clark <[email protected]>Signed-off-by Gustavo Padovan <[email protected]>--- drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 151 +++++++++++++----------------- 1 file changed, 63 insertions(+), 88 deletions(-)drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +7
-9@@ -33,15 +33,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;@@ -257,7 +248,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, .set_property = drm_atomic_helper_plane_set_property,@@ -484,11 +475,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,
Quoted 8 lines
Quoted 1 line
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c static void mdp5_plane_atomic_update(struct drm_plane *plane, · line 484
Quoted 1 line
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +1
-0+ state->crtc);I see a kernel splat here (a NULL pointer dereference). The
async_checkfunction assumes that there is always going to be aplane_state->crtcavailable. This doesn't seem to be the case at least in thedrm_atomic_helper_disable_plane()path. Moving the check to setlegacy_cursor_updateafter calling__drm_atomic_helper_disable_plane()seems to fix the issue. Do you think it's a legit fix?
Yes, plane_state->crtc == NULL is what happens when disabling a plane. I guess simplest would be to just not handle this for the async cursor helpers.
I thought we've had tons of igts to test this ...
Quoted 5 lines
One more point w.r.t msm driver is that we don't use the default
drm_atomic_helper_commit()for ouratomic_commitop. So I had to calldrm_atomic_helper_async_commit()from ouratomic_commitimplementation
(i.e, inmsm_atomic_commitindrivers/gpu/drm/msm/msm_atomic.c)
Would be great to fix that - msm predates the nonblocking support in the commit helper, but since this is fixed there's no reason anymore for driver-private commit functions. Or at least there shouldn't be, for almost all drivers. You can stuff all your hw commit logic into atomic_commit_tail.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC v3 5/8] drm/msm: update cursors asynchronously through atomic
Quoted 77 lines · Daniel Vetter
Quoted 67 lines · Archit Taneja
Hi,
Quoted 5 lines · Archit Taneja
Quoted 2 lines · Gustavo Padovan
From: Gustavo Padovan <[email protected]>
Quoted 7 lines
Quoted 3 lines
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.Works well on DB820c (which has a APQ8096 SoC).
Tested-by Archit Taneja <[email protected]>Actually, after some more thorough testing, I found one issue, mentioned below.
Quoted 49 lines
Quoted 49 lines
v3: move size checks back to drivers (Ville Syrjälä)
v2: move fb setting to core and use new state (Eric Anholt)
Cc Rob Clark <[email protected]>Signed-off-by Gustavo Padovan <[email protected]>--- drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 151 +++++++++++++----------------- 1 file changed, 63 insertions(+), 88 deletions(-)drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +7
-9@@ -33,15 +33,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;@@ -257,7 +248,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, .set_property = drm_atomic_helper_plane_set_property,@@ -484,11 +475,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,Quoted 8 lines
Quoted 1 line
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c static void mdp5_plane_atomic_update(struct drm_plane *plane, · line 484
Quoted 1 line
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +1
-0+ state->crtc);I see a kernel splat here (a NULL pointer dereference). The
async_checkfunction assumes that there is always going to be aplane_state->crtcavailable. This doesn't seem to be the case at least in thedrm_atomic_helper_disable_plane()path. Moving the check to setlegacy_cursor_updateafter calling__drm_atomic_helper_disable_plane()seems to fix the issue. Do you think it's a legit fix?
Quoted 3 lines
Yes,
plane_state->crtc== NULL is what happens when disabling a plane. I guess simplest would be to just not handle this for the async cursor helpers.
Okay. There is actually a check for (crtc != NULL) in drm_atomic_async_check(). The problem with it is that it is referring to the old plane state (i.e plane->state->crtc) instead of the new plane state (i.e, plane_state->crtc). Changing this fixes the issue without the need to touch drm_atomic_helper_disable_plane().
Quoted 9 lines
I thought we've had tons of igts to test this ...
Quoted 5 lines
One more point w.r.t msm driver is that we don't use the default
drm_atomic_helper_commit()for ouratomic_commitop. So I had to calldrm_atomic_helper_async_commit()from ouratomic_commitimplementation
(i.e, inmsm_atomic_commitindrivers/gpu/drm/msm/msm_atomic.c)
Quoted 5 lines
Would be great to fix that - msm predates the nonblocking support in the commit helper, but since this is fixed there's no reason anymore for driver-private commit functions. Or at least there shouldn't be, for almost all drivers. You can stuff all your hw commit logic into
atomic_commit_tail.
Cool. I'll try to to convert to the commit helper funcs.
Thanks,
Archit
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC v3 6/8 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, 3 insertions(+), 23 deletions(-)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +3 -23
@@ -247,19 +247,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, - .set_property = drm_atomic_helper_plane_set_property, - .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) {
@@ -1111,16 +1098,9 @@ struct drm_plane *mdp5_plane_init(struct drm_device *dev,spin_lock_init (&mdp5_plane->pipe_lock); -if (type ==DRM_PLANE_TYPE_CURSOR ) - ret =drm_universal_plane_init (dev, plane,0xff , - &mdp5_cursor_plane_funcs, - mdp5_plane->formats, mdp5_plane->nformats, - type,NULL ); -else - ret =drm_universal_plane_init (dev, plane,0xff , - &mdp5_plane_funcs, - mdp5_plane->formats, mdp5_plane->nformats, - type,NULL ); + ret =drm_universal_plane_init (dev, plane,0xff , &mdp5_plane_funcs, + mdp5_plane->formats, + mdp5_plane->nformats, type,NULL );if (ret) goto fail;
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC v3 6/8] drm/msm: remove mdp5_cursor_plane_funcs
Quoted 4 lines · Gustavo Padovan
From: Gustavo Padovan <[email protected]>
After converting legacy cursor updates to atomic async commits
mdp5_cursor_plane_funcsjust duplicatesmdp5_plane_funcsnow.
Thanks,
Archit
Quoted 52 lines
Cc Rob Clark <[email protected]>Signed-off-by Gustavo Padovan <[email protected]>--- drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-)drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +3
-23@@ -247,19 +247,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, - .set_property = drm_atomic_helper_plane_set_property, - .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) {@@ -1111,16 +1098,9 @@ struct drm_plane *mdp5_plane_init(struct drm_device *dev,spin_lock_init (&mdp5_plane->pipe_lock); -if (type ==DRM_PLANE_TYPE_CURSOR ) - ret =drm_universal_plane_init (dev, plane,0xff , - &mdp5_cursor_plane_funcs, - mdp5_plane->formats, mdp5_plane->nformats, - type,NULL ); -else - ret =drm_universal_plane_init (dev, plane,0xff , - &mdp5_plane_funcs, - mdp5_plane->formats, mdp5_plane->nformats, - type,NULL ); + ret =drm_universal_plane_init (dev, plane,0xff , &mdp5_plane_funcs, + mdp5_plane->formats, + mdp5_plane->nformats, type,NULL );if (ret) goto fail;
Signature · 6 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC v3 7/8 drm/vc4: 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 vc4_update_plane() did but through atomic.
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_plane.c | 99 +++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 64 deletions(-)
drivers/gpu/drm/vc4/vc4_plane.c +35 -64
@@ -735,70 +735,38 @@ void vc4_plane_async_set_fb(struct drm_plane *plane, struct drm_framebuffer *fb) vc4_state->dlist[vc4_state->ptr0_offset] = addr; } -static const struct drm_plane_helper_funcs vc4_plane_helper_funcs = { - .atomic_check = vc4_plane_atomic_check, - .atomic_update = vc4_plane_atomic_update, -}; - -static void vc4_plane_destroy (struct drm_plane *plane) -{ -drm_plane_helper_disable (plane); -drm_plane_cleanup (plane); -} - -/* Implements immediate (non-vblank-synced) updates of the cursor -* position, or falls back to the atomic helper otherwise. -*/ -static int -vc4_update_plane (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 int vc4_plane_atomic_async_check (struct drm_plane *plane, +struct drm_plane_state *state) { -struct drm_plane_state *plane_state; -struct vc4_plane_state *vc4_state; - -if (plane != crtc->cursor) - goto out; - - plane_state = plane->state; - vc4_state =to_vc4_plane_state (plane_state); +if (plane != state->crtc->cursor) +return -EINVAL ; -if (!plane_state) - goto out; +if (!plane->state) +return -EINVAL ;/* No configuring new scaling in the fast path. */ -if (crtc_w != plane_state->crtc_w || - crtc_h != plane_state->crtc_h || - src_w != plane_state->src_w || - src_h != plane_state->src_h) { - goto out; +if (state->crtc_w != plane->state->crtc_w || + state->crtc_h != plane->state->crtc_h || + state->src_w != plane->state->src_w || + state->src_h != plane->state->src_h) { +return -EINVAL ; } -if (fb != plane_state->fb) { -drm_atomic_set_fb_for_plane (plane->state, fb); -vc4_plane_async_set_fb (plane, fb); - } +return 0 ; +} -/* Set the cursor's position on the screen. This is the -* expected change from the drm_mode_cursor_universal() -* helper. -*/ - plane_state->crtc_x = crtc_x; - plane_state->crtc_y = crtc_y; +static void vc4_plane_atomic_async_update (struct drm_plane *plane, +struct drm_plane_state *new_state) +{ +struct vc4_plane_state *vc4_state =to_vc4_plane_state (plane->state); -/* Allow changing the start position within the cursor BO, if -* that matters. -*/ - plane_state->src_x = src_x; - plane_state->src_y = src_y; + 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; -/* Update the display list based on the new crtc_x/y. */ -vc4_plane_atomic_check (plane, plane_state); +if (plane->state->fb != new_state->fb) +vc4_plane_async_set_fb (plane, new_state->fb);/* Note that we can't just call vc4_plane_write_dlist() * because that would smash the context data that the HVS is
@@ -810,20 +778,23 @@ vc4_update_plane(struct drm_plane *plane, &vc4_state->hw_dlist[vc4_state->pos2_offset]);writel (vc4_state->dlist[vc4_state->ptr0_offset], &vc4_state->hw_dlist[vc4_state->ptr0_offset]); +} -return 0 ; +static const struct drm_plane_helper_funcs vc4_plane_helper_funcs = { + .atomic_check = vc4_plane_atomic_check, + .atomic_update = vc4_plane_atomic_update, + .atomic_async_check = vc4_plane_atomic_async_check, + .atomic_async_update = vc4_plane_atomic_async_update, +}; -out: -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); +static void vc4_plane_destroy (struct drm_plane *plane) +{ +drm_plane_helper_disable (plane); +drm_plane_cleanup (plane); }static const struct drm_plane_funcs vc4_plane_funcs = { - .update_plane = vc4_update_plane, + .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, .destroy = vc4_plane_destroy, .set_property =NULL ,
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC v3 7/8] drm/vc4: update cursors asynchronously through atomic
Hey,
I just tested this patch on a RPi2, and the cursor behaves correctly with no unexpected errors.
Quoted 138 lines · Gustavo Padovan
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
vc4_update_plane()did but through atomic.v3: move size checks back to drivers (Ville Syrjälä)
v2: move fb setting to core and use new state (Eric Anholt)
Cc Eric Anholt <[email protected]>Signed-off-by Gustavo Padovan <[email protected]>--- drivers/gpu/drm/vc4/vc4_plane.c | 99 +++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 64 deletions(-)drivers/gpu/drm/vc4/vc4_plane.c +32
-63@@ -735,70 +735,38 @@ void vc4_plane_async_set_fb(struct drm_plane *plane, struct drm_framebuffer *fb) vc4_state->dlist[vc4_state->ptr0_offset] = addr; } -static const struct drm_plane_helper_funcs vc4_plane_helper_funcs = { - .atomic_check = vc4_plane_atomic_check, - .atomic_update = vc4_plane_atomic_update, -}; - -static void vc4_plane_destroy (struct drm_plane *plane) -{ -drm_plane_helper_disable (plane); -drm_plane_cleanup (plane); -} - -/* Implements immediate (non-vblank-synced) updates of the cursor -* position, or falls back to the atomic helper otherwise. -*/ -static int -vc4_update_plane (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 int vc4_plane_atomic_async_check (struct drm_plane *plane, +struct drm_plane_state *state) { -struct drm_plane_state *plane_state; -struct vc4_plane_state *vc4_state; - -if (plane != crtc->cursor) - goto out; - - plane_state = plane->state; - vc4_state =to_vc4_plane_state (plane_state); +if (plane != state->crtc->cursor) +return -EINVAL ; -if (!plane_state) - goto out; +if (!plane->state) +return -EINVAL ;/* No configuring new scaling in the fast path. */ -if (crtc_w != plane_state->crtc_w || - crtc_h != plane_state->crtc_h || - src_w != plane_state->src_w || - src_h != plane_state->src_h) { - goto out; +if (state->crtc_w != plane->state->crtc_w || + state->crtc_h != plane->state->crtc_h || + state->src_w != plane->state->src_w || + state->src_h != plane->state->src_h) { +return -EINVAL ; } -if (fb != plane_state->fb) { -drm_atomic_set_fb_for_plane (plane->state, fb); -vc4_plane_async_set_fb (plane, fb); - } +return 0 ; +} -/* Set the cursor's position on the screen. This is the -* expected change from the drm_mode_cursor_universal() -* helper. -*/ - plane_state->crtc_x = crtc_x; - plane_state->crtc_y = crtc_y; +static void vc4_plane_atomic_async_update (struct drm_plane *plane, +struct drm_plane_state *new_state) +{ +struct vc4_plane_state *vc4_state =to_vc4_plane_state (plane->state); -/* Allow changing the start position within the cursor BO, if -* that matters. -*/ - plane_state->src_x = src_x; - plane_state->src_y = src_y; + 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; -/* Update the display list based on the new crtc_x/y. */ -vc4_plane_atomic_check (plane, plane_state); +if (plane->state->fb != new_state->fb) +vc4_plane_async_set_fb (plane, new_state->fb);/* Note that we can't just call vc4_plane_write_dlist() * because that would smash the context data that the HVS is @@ -810,20 +778,23 @@ vc4_update_plane(struct drm_plane *plane, &vc4_state->hw_dlist[vc4_state->pos2_offset]);writel (vc4_state->dlist[vc4_state->ptr0_offset], &vc4_state->hw_dlist[vc4_state->ptr0_offset]); +} -return 0 ; +static const struct drm_plane_helper_funcs vc4_plane_helper_funcs = { + .atomic_check = vc4_plane_atomic_check, + .atomic_update = vc4_plane_atomic_update, + .atomic_async_check = vc4_plane_atomic_async_check, + .atomic_async_update = vc4_plane_atomic_async_update, +}; -out: -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); +static void vc4_plane_destroy (struct drm_plane *plane) +{
drivers/gpu/drm/vc4/vc4_plane.c vc4_update_plane(struct drm_plane *plane, · line 800
Quoted 10 lines
drivers/gpu/drm/vc4/vc4_plane.c +3
-1+drm_plane_helper_disable (plane); +drm_plane_cleanup (plane); }static const struct drm_plane_funcs vc4_plane_funcs = { - .update_plane = vc4_update_plane, + .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, .destroy = vc4_plane_destroy, .set_property =NULL ,
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC v3 8/8 drm/atomic: add ASYNC_UPDATE flag to the Atomic IOCTL
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
This flag tells core to jump ahead the queued update if the conditions in drm_atomic_async_check() are met. That means we are only able to do an async update if no modeset is pending and update for the same plane is not queued.
It uses the already in place infrastructure for async updates.
It is useful for cursor updates and async PageFlips over the atomic ioctl, otherwise in some cases updates may be delayed to the point the user will notice it.
DRM_MODE_ATOMIC_ASYNC_UPDATE should be passed to the Atomic IOCTL to use this feature.
--- drivers/gpu/drm/drm_atomic.c | 8 +++++++- include/uapi/drm/drm_mode.h | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic.c +7 -1
@@ -77,6 +77,7 @@ drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state)* setting this appropriately? */ state->allow_modeset = true; + state->async_update = true; state->crtcs =kcalloc (dev->mode_config.num_crtc,sizeof (*state->crtcs),GFP_KERNEL );
@@ -1653,7 +1654,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state) } } -if (state->legacy_cursor_update) +if (state->async_update || state->legacy_cursor_update) state->async_update =drm_atomic_async_check (state);return ret;
@@ -2189,6 +2190,10 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))return -EINVAL ; +if ((arg->flags &DRM_MODE_ATOMIC_ALLOW_MODESET ) && + (arg->flags &DRM_MODE_ATOMIC_ASYNC_UPDATE )) +return -EINVAL ; +drm_modeset_acquire_init (&ctx,0 ); state =drm_atomic_state_alloc (dev);
@@ -2197,6 +2202,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, state->acquire_ctx = &ctx; state->allow_modeset = !!(arg->flags &DRM_MODE_ATOMIC_ALLOW_MODESET ); + state->async_update = !!(arg->flags &DRM_MODE_ATOMIC_ASYNC_UPDATE ); retry: plane_mask =0 ;
include/uapi/drm/drm_mode.h +3 -1
@@ -646,13 +646,15 @@ struct drm_mode_destroy_dumb {#define DRM_MODE_ATOMIC_TEST_ONLY 0x0100#define DRM_MODE_ATOMIC_NONBLOCK 0x0200#define DRM_MODE_ATOMIC_ALLOW_MODESET 0x0400 +#define DRM_MODE_ATOMIC_ASYNC_UPDATE 0x0800#define DRM_MODE_ATOMIC_FLAGS (\ DRM_MODE_PAGE_FLIP_EVENT |\ DRM_MODE_PAGE_FLIP_ASYNC |\ DRM_MODE_ATOMIC_TEST_ONLY |\ DRM_MODE_ATOMIC_NONBLOCK |\ - DRM_MODE_ATOMIC_ALLOW_MODESET) + DRM_MODE_ATOMIC_ALLOW_MODESET |\ + DRM_MODE_ATOMIC_ASYNC_UPDATE)struct drm_mode_atomic {__u32 flags;
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel