drm: Eliminate plane->fb/crtc usage for atomic drivers
Subsystems (16)
cover drm: Eliminate plane->fb/crtc usage for atomic drivers
From: Ville Syrjälä <[email protected]>
I really just wanted to fix i915 to re-enable its planes afer load detection (a two line patch). This is what I actually ended up with after I ran into a framebuffer refcount leak with said two line patch.
I've tested this on a few i915 boxes and so far it's looking good. Everything else is just compile tested.
Entire series available here:git://github.com/vsyrjala/linux.git plane_fb_crtc_nuke
Ville Syrjälä (23):
Revert "drm/atomic-helper: Fix leak in disable_all" drm/atomic-helper: Make drm_atomic_helper_disable_all() update the
plane->fb pointers
drm: Clear crtc->primary->crtc when disabling the crtc via setcrtc() drm/atomic-helper: WARN if legacy plane fb pointers are bogus when
committing duplicated state
drm: Add local 'plane' variable for primary/cursor planes
drm: Adjust whitespace for legibility
drm: Make the fb refcount handover less magic
drm: Use plane->state->fb over plane->fb
drm/i915: Stop consulting plane->fb
drm/msm: Stop consulting plane->fb
drm/sti: Stop consulting plane->fb
drm/vmwgfx: Stop consulting plane->fb
drm/zte: Stop consulting plane->fb
drm/atmel-hlcdc: Stop using plane->fb
drm: Stop updating plane->crtc/fb/old_fb on atomic drivers drm/amdgpu/dc: Stop updating plane->fb
drm/i915: Stop updating plane->fb/crtc
drm/exynos: Stop updating plane->crtc
drm/msm: Stop updating plane->fb/crtc
drm/virtio: Stop updating plane->fb
drm/vc4: Stop updating plane->fb/crtc
drm/i915: Restore planes after load detection
drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 - drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 12 +--- drivers/gpu/drm/drm_atomic.c | 55 ++-------------- drivers/gpu/drm/drm_atomic_helper.c | 79 ++++++++++------------- drivers/gpu/drm/drm_crtc.c | 51 ++++++++++----- drivers/gpu/drm/drm_fb_helper.c | 7 -- drivers/gpu/drm/drm_framebuffer.c | 5 -- drivers/gpu/drm/drm_plane.c | 64 +++++++++++------- drivers/gpu/drm/drm_plane_helper.c | 4 +- drivers/gpu/drm/exynos/exynos_drm_plane.c | 2 - drivers/gpu/drm/i915/intel_crt.c | 6 ++ drivers/gpu/drm/i915/intel_display.c | 9 +-- drivers/gpu/drm/i915/intel_fbdev.c | 2 +- drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c | 3 +- drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c | 2 - drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 2 - drivers/gpu/drm/sti/sti_plane.c | 9 +-- drivers/gpu/drm/vc4/vc4_crtc.c | 3 - drivers/gpu/drm/virtio/virtgpu_display.c | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 6 +- drivers/gpu/drm/zte/zx_vou.c | 2 +- include/drm/drm_atomic.h | 3 - 22 files changed, 143 insertions(+), 187 deletions(-)
Signature · 6 lines
2.16.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 1/23 Revert "drm/atomic-helper: Fix leak in disable_all"
From: Ville Syrjälä <[email protected]>
Currently we're leaking fbs on load detect on account of nothing setting up plane->old_fb for the drm_atomic_clean_old_fb() call in drm_atomic_helper_commit_duplicated_state(). Removing the drm_atomic_clean_old_fb() call seems like the right call to me here. This does mean we end up leaking something via drm_atomic_helper_shutdown() though, but we'll fix that up in a different way.
This reverts commit 49d70aeaeca8f62b72b7712ecd1e29619a445866.
--- drivers/gpu/drm/drm_atomic_helper.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +2 -16
@@ -2914,7 +2914,6 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,struct drm_plane *plane;struct drm_crtc_state *crtc_state;struct drm_crtc *crtc; -unsigned plane_mask =0 ;int ret, i; state =drm_atomic_state_alloc (dev);
@@ -2957,14 +2956,10 @@ int drm_atomic_helper_disable_all(struct drm_device *dev, goto free;drm_atomic_set_fb_for_plane (plane_state,NULL ); - plane_mask |=BIT (drm_plane_index (plane)); - plane->old_fb = plane->fb; } ret =drm_atomic_commit (state); free: -if (plane_mask) -drm_atomic_clean_old_fb (dev, plane_mask, ret);drm_atomic_state_put (state);return ret; }
@@ -3095,16 +3090,11 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,struct drm_connector_state *new_conn_state;struct drm_crtc *crtc;struct drm_crtc_state *new_crtc_state; -unsigned plane_mask =0 ; -struct drm_device *dev = state->dev; -int ret; state->acquire_ctx = ctx; -for_each_new_plane_in_state (state, plane, new_plane_state, i) { - plane_mask |=BIT (drm_plane_index (plane)); +for_each_new_plane_in_state (state, plane, new_plane_state, i) state->planes[i].old_state = plane->state; - }for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) state->crtcs[i].old_state = crtc->state;
@@ -3112,11 +3102,7 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,for_each_new_connector_in_state (state, connector, new_conn_state, i) state->connectors[i].old_state = connector->state; - ret =drm_atomic_commit (state); -if (plane_mask) -drm_atomic_clean_old_fb (dev, plane_mask, ret); - -return ret; +return drm_atomic_commit (state); }EXPORT_SYMBOL (drm_atomic_helper_commit_duplicated_state);
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/23 drm/atomic-helper: Make drm_atomic_helper_disable_all() update the plane->fb pointers
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
drm_atomic_helper_shutdown() needs to release the reference held by plane->fb, so we want to use drm_atomic_clean_old_fb() in drm_atomic_helper_disable_all(). However during suspend/resume, gpu reset and load detection we should probably leave that stuff alone, as otherwise we'd have to make sure we put them back again when we restore the duplicated state to the device. Seems simpler to me to not touch any of it anyway.
v2: Don't inflict the clean_old_fbs bool to drivers (Daniel)
--- drivers/gpu/drm/drm_atomic_helper.c | 67 ++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 27 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +40 -27
@@ -2881,31 +2881,9 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set,return 0 ; } -/** -* drm_atomic_helper_disable_all - disable all currently active outputs -* @dev: DRM device -* @ctx: lock acquisition context -* -* Loops through all connectors, finding those that aren't turned off and then -* turns them off by setting their DPMS mode to OFF and deactivating the CRTC -* that they are connected to. -* -* This is used for example in suspend/resume to disable all currently active -* functions when suspending. If you just want to shut down everything at e.g. -* driver unload, look at drm_atomic_helper_shutdown(). -* -* Note that if callers haven't already acquired all modeset locks this might -* return -EDEADLK, which must be handled by calling drm_modeset_backoff(). -* -* Returns: -* 0 on success or a negative error code on failure. -* -* See also: -* drm_atomic_helper_suspend(), drm_atomic_helper_resume() and -* drm_atomic_helper_shutdown(). -*/ -int drm_atomic_helper_disable_all (struct drm_device *dev, -struct drm_modeset_acquire_ctx *ctx) +static int __drm_atomic_helper_disable_all (struct drm_device *dev, +struct drm_modeset_acquire_ctx *ctx, +bool clean_old_fbs) {struct drm_atomic_state *state;struct drm_connector_state *conn_state;
@@ -2914,6 +2892,7 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,struct drm_plane *plane;struct drm_crtc_state *crtc_state;struct drm_crtc *crtc; +unsigned int plane_mask =0 ;int ret, i; state =drm_atomic_state_alloc (dev);
@@ -2956,14 +2935,48 @@ int drm_atomic_helper_disable_all(struct drm_device *dev, goto free;drm_atomic_set_fb_for_plane (plane_state,NULL ); + +if (clean_old_fbs) { + plane->old_fb = plane->fb; + plane_mask |=BIT (drm_plane_index (plane)); + } } ret =drm_atomic_commit (state); free: +drm_atomic_clean_old_fb (dev, plane_mask, ret); +drm_atomic_state_put (state);return ret; } - +/** +* drm_atomic_helper_disable_all - disable all currently active outputs +* @dev: DRM device +* @ctx: lock acquisition context +* +* Loops through all connectors, finding those that aren't turned off and then +* turns them off by setting their DPMS mode to OFF and deactivating the CRTC +* that they are connected to. +* +* This is used for example in suspend/resume to disable all currently active +* functions when suspending. If you just want to shut down everything at e.g. +* driver unload, look at drm_atomic_helper_shutdown(). +* +* Note that if callers haven't already acquired all modeset locks this might +* return -EDEADLK, which must be handled by calling drm_modeset_backoff(). +* +* Returns: +* 0 on success or a negative error code on failure. +* +* See also: +* drm_atomic_helper_suspend(), drm_atomic_helper_resume() and +* drm_atomic_helper_shutdown(). +*/ +int drm_atomic_helper_disable_all (struct drm_device *dev, +struct drm_modeset_acquire_ctx *ctx) +{ +return __drm_atomic_helper_disable_all (dev, ctx, false); +}EXPORT_SYMBOL (drm_atomic_helper_disable_all);/**
@@ -2986,7 +2999,7 @@ void drm_atomic_helper_shutdown(struct drm_device *dev)while (1 ) { ret =drm_modeset_lock_all_ctx (dev, &ctx);if (!ret) - ret =drm_atomic_helper_disable_all (dev, &ctx); + ret =__drm_atomic_helper_disable_all (dev, &ctx, true);if (ret != -EDEADLK )break ;
Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/23 drm: Clear crtc->primary->crtc when disabling the crtc via setcrtc()
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Keep the primary->crtc in sync with the state->crtc (also with primary->fb and state->fb) when disabling the crtc (and thus also the primary) via setcrtc().
--- drivers/gpu/drm/drm_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_crtc.c +1 -1
@@ -471,7 +471,7 @@ static int __drm_mode_set_config_internal(struct drm_mode_set *set, ret = crtc->funcs->set_config (set, ctx);if (ret ==0 ) { - crtc->primary->crtc = crtc; + crtc->primary->crtc = fb ? crtc :NULL ; crtc->primary->fb = fb; }
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/23 drm/atomic-helper: WARN if legacy plane fb pointers are bogus when committing duplicated state
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
drm_atomic_helper_commit_duplicated_state() should only be called resume/reset/load_detect paths where plane->old_fb should always be NULL and plane->fb should be equal to the new_plane_state->fb. Assert that is indeed the case.
--- drivers/gpu/drm/drm_atomic_helper.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic_helper.c +6 -1
@@ -3106,8 +3106,13 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state, state->acquire_ctx = ctx; -for_each_new_plane_in_state (state, plane, new_plane_state, i) +for_each_new_plane_in_state (state, plane, new_plane_state, i) { +WARN_ON (plane->crtc != new_plane_state->crtc); +WARN_ON (plane->fb != new_plane_state->fb); +WARN_ON (plane->old_fb); + state->planes[i].old_state = plane->state; + }for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) state->crtcs[i].old_state = crtc->state;
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/23 drm: Add local 'plane' variable for primary/cursor planes
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Make the code a bit more readable by storing the plane pointer in a local variable rather than having to do crtc->{primary,cursor} all the time.
--- drivers/gpu/drm/drm_crtc.c | 32 +++++++++++++++++++------------- drivers/gpu/drm/drm_plane.c | 32 ++++++++++++++++++-------------- 2 files changed, 37 insertions(+), 27 deletions(-)
drivers/gpu/drm/drm_crtc.c +19 -13
@@ -402,6 +402,7 @@ int drm_mode_getcrtc(struct drm_device *dev, {struct drm_mode_crtc *crtc_resp = data;struct drm_crtc *crtc; +struct drm_plane *plane;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;
@@ -410,21 +411,23 @@ int drm_mode_getcrtc(struct drm_device *dev,if (!crtc)return -ENOENT ; + plane = crtc->primary; + crtc_resp->gamma_size = crtc->gamma_size; -drm_modeset_lock (&crtc->primary->mutex,NULL ); -if (crtc->primary->state && crtc->primary->state->fb) - crtc_resp->fb_id = crtc->primary->state->fb->base.id; -else if (!crtc->primary->state && crtc->primary->fb) - crtc_resp->fb_id = crtc->primary->fb->base.id; +drm_modeset_lock (&plane->mutex,NULL ); +if (plane->state && plane->state->fb) + crtc_resp->fb_id = plane->state->fb->base.id; +else if (!plane->state && plane->fb) + crtc_resp->fb_id = plane->fb->base.id;else crtc_resp->fb_id =0 ; -if (crtc->primary->state) { - crtc_resp->x = crtc->primary->state->src_x >>16 ; - crtc_resp->y = crtc->primary->state->src_y >>16 ; +if (plane->state) { + crtc_resp->x = plane->state->src_x >>16 ; + crtc_resp->y = plane->state->src_y >>16 ; } -drm_modeset_unlock (&crtc->primary->mutex); +drm_modeset_unlock (&plane->mutex);drm_modeset_lock (&crtc->mutex,NULL );if (crtc->state) {
@@ -554,6 +557,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,struct drm_mode_config *config = &dev->mode_config;struct drm_mode_crtc *crtc_req = data;struct drm_crtc *crtc; +struct drm_plane *plane;struct drm_connector **connector_set =NULL , *connector;struct drm_framebuffer *fb =NULL ;struct drm_display_mode *mode =NULL ;
@@ -580,6 +584,8 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, }DRM_DEBUG_KMS ("[CRTC:%d:%s]\n" , crtc->base.id, crtc->name); + plane = crtc->primary; +mutex_lock (&crtc->dev->mode_config.mutex);drm_modeset_acquire_init (&ctx,DRM_MODESET_ACQUIRE_INTERRUPTIBLE ); retry:
@@ -590,12 +596,12 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,/* If we have a mode we need a framebuffer. */ /* If we pass -1, set the mode with the currently bound fb */ if (crtc_req->fb_id ==-1 ) { -if (!crtc->primary->fb) { +if (!plane->fb) {DRM_DEBUG_KMS ("CRTC doesn't have current FB\n" ); ret = -EINVAL ; goto out; } - fb = crtc->primary->fb; + fb = plane->fb;/* Make refcounting symmetric with the lookup path. */ drm_framebuffer_get (fb); }else {
@@ -627,8 +633,8 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,* match real hardware capabilities. Skip the check in that * case. */ -if (!crtc->primary->format_default) { - ret =drm_plane_check_pixel_format (crtc->primary, +if (!plane->format_default) { + ret =drm_plane_check_pixel_format (plane, fb->format->format, fb->modifier);if (ret) {
drivers/gpu/drm/drm_plane.c +18 -14
@@ -756,6 +756,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc, struct drm_modeset_acquire_ctx *ctx) {struct drm_device *dev = crtc->dev; +struct drm_plane *plane = crtc->cursor;struct drm_framebuffer *fb =NULL ;struct drm_mode_fb_cmd2 fbreq = { .width = req->width,
@@ -769,8 +770,8 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,uint32_t src_w =0 , src_h =0 ;int ret =0 ; -BUG_ON (!crtc->cursor); -WARN_ON (crtc->cursor->crtc != crtc && crtc->cursor->crtc !=NULL ); +BUG_ON (!plane); +WARN_ON (plane->crtc != crtc && plane->crtc !=NULL );/* * Obtain fb we'll be using (either new or existing) and take an extra
@@ -790,7 +791,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc, fb =NULL ; } }else { - fb = crtc->cursor->fb; + fb = plane->fb;if (fb)drm_framebuffer_get (fb); }
@@ -810,7 +811,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc, src_h = fb->height <<16 ; } - ret =__setplane_internal (crtc->cursor, crtc, fb, + ret =__setplane_internal (plane, crtc, fb, crtc_x, crtc_y, crtc_w, crtc_h,0 ,0 , src_w, src_h, ctx);
@@ -931,6 +932,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, {struct drm_mode_crtc_page_flip_target *page_flip = data;struct drm_crtc *crtc; +struct drm_plane *plane;struct drm_framebuffer *fb =NULL ;struct drm_pending_vblank_event *e =NULL ;u32 target_vblank = page_flip->sequence;
@@ -959,6 +961,8 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,if (!crtc)return -ENOENT ; + plane = crtc->primary; +if (crtc->funcs->page_flip_target) {u32 current_vblank;int r;
@@ -1003,11 +1007,11 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, ret =drm_modeset_lock (&crtc->mutex, &ctx);if (ret) goto out; - ret =drm_modeset_lock (&crtc->primary->mutex, &ctx); + ret =drm_modeset_lock (&plane->mutex, &ctx);if (ret) goto out; -if (crtc->primary->fb ==NULL ) { +if (plane->fb ==NULL ) {/* The framebuffer is currently unbound, presumably * due to a hotplug event, that userspace has not * yet discovered.
@@ -1023,7 +1027,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, }if (crtc->state) { -const struct drm_plane_state *state = crtc->primary->state; +const struct drm_plane_state *state = plane->state; ret = drm_framebuffer_check_src_coords(state->src_x, state->src_y,
@@ -1036,7 +1040,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,if (ret) goto out; -if (crtc->primary->fb->format != fb->format) { +if (plane->fb->format != fb->format) {DRM_DEBUG_KMS ("Page flip is not allowed to change frame buffer format.\n" ); ret = -EINVAL ; goto out;
@@ -1060,7 +1064,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, } } - crtc->primary->old_fb = crtc->primary->fb; + plane->old_fb = plane->fb;if (crtc->funcs->page_flip_target) ret = crtc->funcs->page_flip_target(crtc, fb, e, page_flip->flags,
@@ -1073,9 +1077,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,if (page_flip->flags &DRM_MODE_PAGE_FLIP_EVENT )drm_event_cancel_free (dev, &e->base);/* Keep the old fb, don't unref it. */ - crtc->primary->old_fb =NULL ; + plane->old_fb =NULL ; }else { - crtc->primary->fb = fb; + plane->fb = fb;/* Unref only the old framebuffer. */ fb =NULL ; }
@@ -1083,9 +1087,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, out:if (fb)drm_framebuffer_put (fb); -if (crtc->primary->old_fb) -drm_framebuffer_put (crtc->primary->old_fb); - crtc->primary->old_fb =NULL ; +if (plane->old_fb) +drm_framebuffer_put (plane->old_fb); + plane->old_fb =NULL ;if (ret == -EDEADLK ) { ret =drm_modeset_backoff (&ctx);
Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/23 drm: Adjust whitespace for legibility
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Add a bit of whitespace here and there to make the code look a bit more structured.
--- drivers/gpu/drm/drm_crtc.c | 4 +++- drivers/gpu/drm/drm_plane.c | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_crtc.c +3 -1
@@ -434,13 +434,13 @@ int drm_mode_getcrtc(struct drm_device *dev,if (crtc->state->enable) {drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->state->mode); crtc_resp->mode_valid =1 ; - }else { crtc_resp->mode_valid =0 ; } }else { crtc_resp->x = crtc->x; crtc_resp->y = crtc->y; +if (crtc->enabled) {drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid =1 ;
@@ -592,6 +592,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, ret =drm_modeset_lock_all_ctx (crtc->dev, &ctx);if (ret) goto out; +if (crtc_req->mode_valid) {/* If we have a mode we need a framebuffer. */ /* If we pass -1, set the mode with the currently bound fb */
@@ -601,6 +602,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, ret = -EINVAL ; goto out; } + fb = plane->fb;/* Make refcounting symmetric with the lookup path. */ drm_framebuffer_get (fb);
drivers/gpu/drm/drm_plane.c +5 -1
@@ -785,6 +785,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,DRM_DEBUG_KMS ("failed to wrap cursor buffer in drm framebuffer\n" );return PTR_ERR (fb); } + fb->hot_x = req->hot_x; fb->hot_y = req->hot_y; }else {
@@ -1035,7 +1036,8 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, state->src_h, fb); }else { - ret =drm_crtc_check_viewport (crtc, crtc->x, crtc->y, &crtc->mode, fb); + ret =drm_crtc_check_viewport (crtc, crtc->x, crtc->y, + &crtc->mode, fb); }if (ret) goto out;
@@ -1052,10 +1054,12 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, ret = -ENOMEM ; goto out; } + e->event.base.type =DRM_EVENT_FLIP_COMPLETE ; e->event.base.length =sizeof (e->event); e->event.vbl.user_data = page_flip->user_data; e->event.vbl.crtc_id = crtc->base.id; + ret =drm_event_reserve_init (dev, file_priv, &e->base, &e->event.base);if (ret) {kfree (e);
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/23 drm: Make the fb refcount handover less magic
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Instead of assigning the plane->fb pointer and clearing the fb pointer to hand over the reference, let's just do it by grabbing another referece for plane->fb and let fb keep its original one.
--- drivers/gpu/drm/drm_plane.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/drm_plane.c +1 -2
@@ -1084,8 +1084,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, plane->old_fb =NULL ; }else { plane->fb = fb; -/* Unref only the old framebuffer. */ - fb =NULL ; +drm_framebuffer_get (fb); } out:
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/23 drm: Use plane->state->fb over plane->fb
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Stop looking at plane->fb on atomic drivers. Use plane->state->fb instead.
--- drivers/gpu/drm/drm_atomic_helper.c | 2 +- drivers/gpu/drm/drm_crtc.c | 11 +++++++++-- drivers/gpu/drm/drm_plane.c | 19 ++++++++++++++----- 3 files changed, 24 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +1 -1
@@ -2659,7 +2659,7 @@ int drm_atomic_helper_disable_plane(struct drm_plane *plane, goto fail; } -if (plane_state->crtc && (plane == plane->crtc->cursor)) +if (plane_state->crtc && plane_state->crtc->cursor == plane) plane_state->state->legacy_cursor_update = true; ret =__drm_atomic_helper_disable_plane (plane, plane_state);
drivers/gpu/drm/drm_crtc.c +9 -2
@@ -597,13 +597,20 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,/* If we have a mode we need a framebuffer. */ /* If we pass -1, set the mode with the currently bound fb */ if (crtc_req->fb_id ==-1 ) { -if (!plane->fb) { +struct drm_framebuffer *old_fb; + +if (plane->state) + old_fb = plane->state->fb; +else + old_fb = plane->fb; + +if (!old_fb) {DRM_DEBUG_KMS ("CRTC doesn't have current FB\n" ); ret = -EINVAL ; goto out; } - fb = plane->fb; + fb = old_fb;/* Make refcounting symmetric with the lookup path. */ drm_framebuffer_get (fb); }else {
drivers/gpu/drm/drm_plane.c +14 -5
@@ -792,7 +792,11 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc, fb =NULL ; } }else { - fb = plane->fb; +if (plane->state) + fb = plane->state->fb; +else + fb = plane->fb; +if (fb)drm_framebuffer_get (fb); }
@@ -934,7 +938,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,struct drm_mode_crtc_page_flip_target *page_flip = data;struct drm_crtc *crtc;struct drm_plane *plane; -struct drm_framebuffer *fb =NULL ; +struct drm_framebuffer *fb =NULL , *old_fb;struct drm_pending_vblank_event *e =NULL ;u32 target_vblank = page_flip->sequence;struct drm_modeset_acquire_ctx ctx;
@@ -1012,7 +1016,12 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,if (ret) goto out; -if (plane->fb ==NULL ) { +if (plane->state) + old_fb = plane->state->fb; +else + old_fb = plane->fb; + +if (old_fb ==NULL ) {/* The framebuffer is currently unbound, presumably * due to a hotplug event, that userspace has not * yet discovered.
@@ -1027,7 +1036,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, goto out; } -if (crtc->state) { +if (plane->state) {const struct drm_plane_state *state = plane->state; ret = drm_framebuffer_check_src_coords(state->src_x,
@@ -1042,7 +1051,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,if (ret) goto out; -if (plane->fb->format != fb->format) { +if (old_fb->format != fb->format) {DRM_DEBUG_KMS ("Page flip is not allowed to change frame buffer format.\n" ); ret = -EINVAL ; goto out;
Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 9/23 drm/i915: Stop consulting plane->fb
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->fb on atomic drivers. Stop looking at it.
--- drivers/gpu/drm/i915/intel_display.c | 2 +- drivers/gpu/drm/i915/intel_fbdev.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
@@ -2824,7 +2824,7 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc,continue ;if (intel_plane_ggtt_offset (state) == plane_config->base) { - fb = c->primary->fb; + fb = state->base.fb;drm_framebuffer_get (fb); goto valid_fb; }
drivers/gpu/drm/i915/intel_fbdev.c +1 -1
@@ -641,7 +641,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,if (!crtc->state->active)continue ; -WARN (!crtc->primary->fb, +WARN (!crtc->primary->state->fb,"re-used BIOS config but lost an fb on crtc %d\n" , crtc->base.id); }
Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 10/23 drm/msm: Stop consulting plane->fb
In reply to a message not in the archiveFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->fb on atomic drivers. Stop looking at it.
--- drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c +1 -1
@@ -201,7 +201,7 @@ static void blend_setup(struct drm_crtc *crtc)int idx = idxs[pipe_id];if (idx >0 ) {const struct mdp_format *format = -to_mdp_format (msm_framebuffer_format (plane->fb)); +to_mdp_format (msm_framebuffer_format (plane->state->fb)); alpha[idx-1 ] = format->alpha_enable; } }
Signature · 6 lines
2.16.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH 11/23 drm/sti: Stop consulting plane->fb
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->fb on atomic drivers. Stop looking at it.
--- drivers/gpu/drm/sti/sti_plane.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/sti/sti_plane.c +5 -4
@@ -40,6 +40,7 @@ void sti_plane_update_fps(struct sti_plane *plane, bool new_frame, bool new_field) { +struct drm_plane_state *state = plane->drm_plane.state;ktime_t now;struct sti_fps_info *fps;int fpks, fipks, ms_since_last, num_frames, num_fields;
@@ -66,14 +67,14 @@ void sti_plane_update_fps(struct sti_plane *plane, fps->last_timestamp = now; fps->last_frame_counter = fps->curr_frame_counter; -if (plane->drm_plane.fb) { +if (state->fb) { fpks = (num_frames *1000000 ) / ms_since_last;snprintf (plane->fps_info.fps_str,FPS_LENGTH ,"%-8s %4dx%-4d %.4s @ %3d.%-3.3d fps (%s)" , plane->drm_plane.name, - plane->drm_plane.fb->width, - plane->drm_plane.fb->height, - (char *)&plane->drm_plane.fb->format->format, + state->fb->width, + state->fb->height, + (char *)&state->fb->format->format, fpks /1000 , fpks %1000 ,sti_plane_to_str (plane)); }
Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 12/23 drm/vmwgfx: Stop consulting plane->fb
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->fb on atomic drivers. Stop looking at it.
--- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +3 -3
@@ -385,9 +385,9 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane, hotspot_x = du->hotspot_x; hotspot_y = du->hotspot_y; -if (plane->fb) { - hotspot_x += plane->fb->hot_x; - hotspot_y += plane->fb->hot_y; +if (plane->state->fb) { + hotspot_x += plane->state->fb->hot_x; + hotspot_y += plane->state->fb->hot_y; } du->cursor_surface = vps->surf;
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 13/23 drm/zte: Stop consulting plane->fb
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->fb on atomic drivers. Stop looking at it.
--- drivers/gpu/drm/zte/zx_vou.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/zte/zx_vou.c +1 -1
@@ -629,7 +629,7 @@ void zx_vou_layer_enable(struct drm_plane *plane)void zx_vou_layer_disable (struct drm_plane *plane) { -struct zx_crtc *zcrtc =to_zx_crtc (plane->crtc); +struct zx_crtc *zcrtc =to_zx_crtc (plane->state->crtc);struct zx_vou_hw *vou = zcrtc->vou;struct zx_plane *zplane =to_zx_plane (plane);const struct vou_layer_bits *bits = zplane->bits;
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 14/23 drm/atmel-hlcdc: Stop using plane->fb
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->fb on atomic drivers. Stop looking at it.
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +1 -11
@@ -819,16 +819,6 @@ static void atmel_hlcdc_plane_atomic_disable(struct drm_plane *p,atmel_hlcdc_layer_read_reg (&plane->layer,ATMEL_HLCDC_LAYER_ISR ); } -static void atmel_hlcdc_plane_destroy (struct drm_plane *p) -{ -struct atmel_hlcdc_plane *plane =drm_plane_to_atmel_hlcdc_plane (p); - -if (plane->base.fb) -drm_framebuffer_put (plane->base.fb); - -drm_plane_cleanup (p); -} - static int atmel_hlcdc_plane_atomic_set_property(struct drm_plane *p, struct drm_plane_state *s, struct drm_property *property,
@@ -1038,7 +1028,7 @@ static void atmel_hlcdc_plane_atomic_destroy_state(struct drm_plane *p,static const struct drm_plane_funcs layer_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = atmel_hlcdc_plane_destroy, + .destroy = drm_plane_cleanup, .reset = atmel_hlcdc_plane_reset, .atomic_duplicate_state = atmel_hlcdc_plane_atomic_duplicate_state, .atomic_destroy_state = atmel_hlcdc_plane_atomic_destroy_state,
Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 15/23 drm: Stop updating plane->crtc/fb/old_fb on atomic drivers
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Stop playing around with plane->crtc/fb/old_fb with atomic drivers. Make life a lot simpler when we don't have to do the magic old_fb vs. fb dance around plane updates. That way we can't risk plane->fb getting out of sync with plane->state->fb and we're less likely to leak any refcounts as well.
--- drivers/gpu/drm/drm_atomic.c | 55 ++++--------------------------------- drivers/gpu/drm/drm_atomic_helper.c | 15 +--------- drivers/gpu/drm/drm_crtc.c | 8 ++++-- drivers/gpu/drm/drm_fb_helper.c | 7 ----- drivers/gpu/drm/drm_framebuffer.c | 5 ---- drivers/gpu/drm/drm_plane.c | 14 ++++++---- drivers/gpu/drm/drm_plane_helper.c | 4 ++- include/drm/drm_atomic.h | 3 -- 8 files changed, 24 insertions(+), 87 deletions(-)
drivers/gpu/drm/drm_atomic.c +5 -50
@@ -692,6 +692,11 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,WARN_ON (!state->acquire_ctx); +/* the legacy pointers should never be set */ +WARN_ON (plane->fb); +WARN_ON (plane->old_fb); +WARN_ON (plane->crtc); + plane_state =drm_atomic_get_existing_plane_state (state, plane);if (plane_state)return plane_state;
@@ -2021,45 +2026,6 @@ int drm_atomic_set_property(struct drm_atomic_state *state,return ret; } -/** -* drm_atomic_clean_old_fb -- Unset old_fb pointers and set plane->fb pointers. -* -* @dev: drm device to check. -* @plane_mask: plane mask for planes that were updated. -* @ret: return value, can be -EDEADLK for a retry. -* -* Before doing an update &drm_plane.old_fb is set to &drm_plane.fb, but before -* dropping the locks old_fb needs to be set to NULL and plane->fb updated. This -* is a common operation for each atomic update, so this call is split off as a -* helper. -*/ -void drm_atomic_clean_old_fb (struct drm_device *dev, -unsigned plane_mask, -int ret) -{ -struct drm_plane *plane; - -/* if succeeded, fixup legacy plane crtc/fb ptrs before dropping -* locks (ie. while it is still safe to deref plane->state). We -* need to do this here because the driver entry points cannot -* distinguish between legacy and atomic ioctls. -*/ -drm_for_each_plane_mask (plane, dev, plane_mask) { -if (ret ==0 ) { -struct drm_framebuffer *new_fb = plane->state->fb; -if (new_fb) -drm_framebuffer_get (new_fb); - plane->fb = new_fb; - plane->crtc = plane->state->crtc; - -if (plane->old_fb) -drm_framebuffer_put (plane->old_fb); - } - plane->old_fb =NULL ; - } -} -EXPORT_SYMBOL (drm_atomic_clean_old_fb); -/** * DOC: explicit fencing properties *
@@ -2280,9 +2246,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,unsigned int copied_objs, copied_props;struct drm_atomic_state *state;struct drm_modeset_acquire_ctx ctx; -struct drm_plane *plane;struct drm_out_fence_state *fence_state; -unsigned plane_mask;int ret =0 ;unsigned int i, j, num_fences;
@@ -2322,7 +2286,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, state->allow_modeset = !!(arg->flags &DRM_MODE_ATOMIC_ALLOW_MODESET ); retry: - plane_mask =0 ; copied_objs =0 ; copied_props =0 ; fence_state =NULL ;
@@ -2393,12 +2356,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, copied_props++; } -if (obj->type ==DRM_MODE_OBJECT_PLANE && count_props && - !(arg->flags &DRM_MODE_ATOMIC_TEST_ONLY )) { - plane =obj_to_plane (obj); - plane_mask |= (1 <<drm_plane_index (plane)); - plane->old_fb = plane->fb; - }drm_mode_object_put (obj); }
@@ -2419,8 +2376,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, } out: -drm_atomic_clean_old_fb (dev, plane_mask, ret); -complete_crtc_signaling (dev, state, fence_state, num_fences, !ret);if (ret == -EDEADLK ) {
drivers/gpu/drm/drm_atomic_helper.c +1 -14
@@ -2892,7 +2892,6 @@ static int __drm_atomic_helper_disable_all(struct drm_device *dev,struct drm_plane *plane;struct drm_crtc_state *crtc_state;struct drm_crtc *crtc; -unsigned int plane_mask =0 ;int ret, i; state =drm_atomic_state_alloc (dev);
@@ -2935,17 +2934,10 @@ static int __drm_atomic_helper_disable_all(struct drm_device *dev, goto free;drm_atomic_set_fb_for_plane (plane_state,NULL ); - -if (clean_old_fbs) { - plane->old_fb = plane->fb; - plane_mask |=BIT (drm_plane_index (plane)); - } } ret =drm_atomic_commit (state); free: -drm_atomic_clean_old_fb (dev, plane_mask, ret); -drm_atomic_state_put (state);return ret; }
@@ -3106,13 +3098,8 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state, state->acquire_ctx = ctx; -for_each_new_plane_in_state (state, plane, new_plane_state, i) { -WARN_ON (plane->crtc != new_plane_state->crtc); -WARN_ON (plane->fb != new_plane_state->fb); -WARN_ON (plane->old_fb); - +for_each_new_plane_in_state (state, plane, new_plane_state, i) state->planes[i].old_state = plane->state; - }for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) state->crtcs[i].old_state = crtc->state;
drivers/gpu/drm/drm_crtc.c +6 -2
@@ -474,8 +474,12 @@ static int __drm_mode_set_config_internal(struct drm_mode_set *set, ret = crtc->funcs->set_config (set, ctx);if (ret ==0 ) { - crtc->primary->crtc = fb ? crtc :NULL ; - crtc->primary->fb = fb; +struct drm_plane *plane = crtc->primary; + +if (!plane->state) { + plane->crtc = fb ? crtc :NULL ; + plane->fb = fb; + } }drm_for_each_crtc (tmp, crtc->dev) {
drivers/gpu/drm/drm_fb_helper.c +0 -7
@@ -368,7 +368,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activstruct drm_plane *plane;struct drm_atomic_state *state;int i, ret; -unsigned int plane_mask;struct drm_modeset_acquire_ctx ctx;drm_modeset_acquire_init (&ctx,0 );
@@ -381,7 +380,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ state->acquire_ctx = &ctx; retry: - plane_mask =0 ;drm_for_each_plane (plane, dev) { plane_state =drm_atomic_get_plane_state (state, plane);if (IS_ERR (plane_state)) {
@@ -391,9 +389,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ plane_state->rotation =DRM_MODE_ROTATE_0 ; - plane->old_fb = plane->fb; - plane_mask |=1 <<drm_plane_index (plane); -/* disable non-primary: */ if (plane->type ==DRM_PLANE_TYPE_PRIMARY )continue ;
@@ -430,8 +425,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ ret =drm_atomic_commit (state); out_state: -drm_atomic_clean_old_fb (dev, plane_mask, ret); -if (ret == -EDEADLK ) goto backoff;
drivers/gpu/drm/drm_framebuffer.c +0 -5
@@ -835,8 +835,6 @@ static int atomic_remove_fb(struct drm_framebuffer *fb) goto unlock; plane_mask |=BIT (drm_plane_index (plane)); - - plane->old_fb = plane->fb; }/* This list is only filled when disable_crtcs is set. */
@@ -851,9 +849,6 @@ static int atomic_remove_fb(struct drm_framebuffer *fb) ret =drm_atomic_commit (state); unlock: -if (plane_mask) -drm_atomic_clean_old_fb (dev, plane_mask, ret); -if (ret == -EDEADLK ) {drm_atomic_state_clear (state);drm_modeset_backoff (&ctx);
drivers/gpu/drm/drm_plane.c +9 -5
@@ -650,9 +650,11 @@ static int __setplane_internal(struct drm_plane *plane, crtc_x, crtc_y, crtc_w, crtc_h, src_x, src_y, src_w, src_h, ctx);if (!ret) { - plane->crtc = crtc; - plane->fb = fb; -drm_framebuffer_get (plane->fb); +if (!plane->state) { + plane->crtc = crtc; + plane->fb = fb; +drm_framebuffer_get (plane->fb); + } }else { plane->old_fb =NULL ; }
@@ -1092,8 +1094,10 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,/* Keep the old fb, don't unref it. */ plane->old_fb =NULL ; }else { - plane->fb = fb; -drm_framebuffer_get (fb); +if (!plane->state) { + plane->fb = fb; +drm_framebuffer_get (fb); + } } out:
drivers/gpu/drm/drm_plane_helper.c +3 -1
@@ -502,6 +502,7 @@ EXPORT_SYMBOL(drm_plane_helper_update);int drm_plane_helper_disable (struct drm_plane *plane) {struct drm_plane_state *plane_state; +struct drm_framebuffer *old_fb;/* crtc helpers love to call disable functions for already disabled hw * functions. So cope with that. */
@@ -521,8 +522,9 @@ int drm_plane_helper_disable(struct drm_plane *plane) plane_state->plane = plane; plane_state->crtc =NULL ; + old_fb = plane_state->fb;drm_atomic_set_fb_for_plane (plane_state,NULL ); -return drm_plane_helper_commit (plane, plane_state, plane->fb); +return drm_plane_helper_commit (plane, plane_state, old_fb); }EXPORT_SYMBOL (drm_plane_helper_disable);
include/drm/drm_atomic.h +0 -3
@@ -601,9 +601,6 @@ int __must_check drm_atomic_add_affected_planes(struct drm_atomic_state *state, struct drm_crtc *crtc); -void -drm_atomic_clean_old_fb (struct drm_device *dev,unsigned plane_mask,int ret); -int __must_check drm_atomic_check_only (struct drm_atomic_state *state);int __must_check drm_atomic_commit (struct drm_atomic_state *state);int __must_check drm_atomic_nonblocking_commit (struct drm_atomic_state *state);
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 16/23 drm/amdgpu/dc: Stop updating plane->fb
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->fb on atomic drivers. Stop setting it.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -2
@@ -3941,8 +3941,6 @@ static void amdgpu_dm_do_flip(struct drm_crtc *crtc,/* Flip */ spin_lock_irqsave (&crtc->dev->event_lock, flags); -/* update crtc fb */ - crtc->primary->fb = fb;WARN_ON (acrtc->pflip_status !=AMDGPU_FLIP_NONE );WARN_ON (!acrtc_state->stream);
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 17/23 drm/i915: Stop updating plane->fb/crtc
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->fb/crtc on atomic drivers. Stop setting them.
--- drivers/gpu/drm/i915/intel_display.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +2 -3
@@ -2877,9 +2877,8 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc,if (i915_gem_object_is_tiled (obj)) dev_priv->preserve_bios_swizzle = true; -drm_framebuffer_get (fb); - primary->fb = primary->state->fb = fb; - primary->crtc = primary->state->crtc = &intel_crtc->base; + plane_state->fb = fb; + plane_state->crtc = &intel_crtc->base; intel_set_plane_visible(to_intel_crtc_state(crtc_state), to_intel_plane_state(plane_state),
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 18/23 drm/exynos: Stop updating plane->crtc
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->crtc on atomic drivers. Stop setting it.
--- drivers/gpu/drm/exynos/exynos_drm_plane.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_plane.c +0 -2
@@ -263,8 +263,6 @@ static void exynos_plane_atomic_update(struct drm_plane *plane,if (!state->crtc)return ; - plane->crtc = state->crtc; -if (exynos_crtc->ops->update_plane) exynos_crtc->ops->update_plane (exynos_crtc, exynos_plane); }
Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 19/23 drm/msm: Stop updating plane->fb/crtc
In reply to a message not in the archiveFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->fb/crtc on atomic drivers. Stop setting them.
--- drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c | 1 - drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c | 2 -- drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 2 -- 3 files changed, 5 deletions(-)
drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c +0 -1
@@ -664,7 +664,6 @@ struct drm_crtc *mdp4_crtc_init(struct drm_device *dev,drm_crtc_init_with_planes (dev, crtc, plane,NULL , &mdp4_crtc_funcs,NULL );drm_crtc_helper_add (crtc, &mdp4_crtc_helper_funcs); - plane->crtc = crtc;return crtc; }
drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c +0 -2
@@ -182,8 +182,6 @@ static void mdp4_plane_set_scanout(struct drm_plane *plane, msm_framebuffer_iova(fb, kms->aspace, 2));mdp4_write (mdp4_kms,REG_MDP4_PIPE_SRCP3_BASE (pipe),msm_framebuffer_iova (fb, kms->aspace,3 )); - - plane->fb = fb; } static void mdp4_write_csc_config(struct mdp4_kms *mdp4_kms,
drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c +0 -2
@@ -1043,8 +1043,6 @@ static int mdp5_plane_mode_set(struct drm_plane *plane, src_img_w, src_img_h, src_x + src_w, src_y, src_w, src_h); - plane->fb = fb; -return ret; }
Signature · 6 lines
2.16.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH 20/23 drm/virtio: Stop updating plane->fb
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->fb on atomic drivers. Stop setting it.
--- drivers/gpu/drm/virtio/virtgpu_display.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/virtio/virtgpu_display.c +0 -2
@@ -302,8 +302,6 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)drm_crtc_init_with_planes (dev, crtc, primary, cursor, &virtio_gpu_crtc_funcs,NULL );drm_crtc_helper_add (crtc, &virtio_gpu_crtc_helper_funcs); - primary->crtc = crtc; - cursor->crtc = crtc;drm_connector_init (dev, connector, &virtio_gpu_connector_funcs,DRM_MODE_CONNECTOR_VIRTUAL );
Signature · 6 lines
2.16.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
PATCH 21/23 drm/vc4: Stop updating plane->fb/crtc
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->fb/crtc on atomic drivers. Stop setting them.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +0 -3
@@ -837,7 +837,6 @@ static int vc4_async_page_flip(struct drm_crtc *crtc,* is released. */ drm_atomic_set_fb_for_plane (plane->state, fb); - plane->fb = fb;vc4_queue_seqno_cb (dev, &flip_state->cb, bo->seqno, vc4_async_page_flip_complete);
@@ -1032,7 +1031,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)drm_crtc_init_with_planes (drm, crtc, primary_plane,NULL , &vc4_crtc_funcs,NULL );drm_crtc_helper_add (crtc, &vc4_crtc_helper_funcs); - primary_plane->crtc = crtc; vc4_crtc->channel = vc4_crtc->data->hvs_channel;drm_mode_crtc_set_gamma_size (crtc,ARRAY_SIZE (vc4_crtc->lut_r));
@@ -1062,7 +1060,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data) cursor_plane =vc4_plane_init (drm,DRM_PLANE_TYPE_CURSOR );if (!IS_ERR (cursor_plane)) { cursor_plane->possible_crtcs =1 <<drm_crtc_index (crtc); - cursor_plane->crtc = crtc; crtc->cursor = cursor_plane; }
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 22/23 drm/i915: Restore planes after load detection
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Actually turn the planes back on after were done with the load detection.
--- drivers/gpu/drm/i915/intel_display.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/intel_display.c +2 -0
@@ -9975,6 +9975,8 @@ int intel_get_load_detect_pipe(struct drm_connector *connector, ret =PTR_ERR_OR_ZERO (drm_atomic_get_connector_state (restore_state, connector));if (!ret) ret =PTR_ERR_OR_ZERO (drm_atomic_get_crtc_state (restore_state, crtc)); +if (!ret) + ret =drm_atomic_add_affected_planes (restore_state, crtc);if (ret) {DRM_DEBUG_KMS ("Failed to create a copy of old state to restore: %i\n" , ret); goto fail;
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 23/23 drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
When doing forced load detection testing we should totally ignore any hotplug status for the connector. This is mostly relevant for machines where we already ignore the hotplug status based on the DMI quirks. On other machines we would currently skip the force load detection tests on account of the connector already being connected.
--- drivers/gpu/drm/i915/intel_crt.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_crt.c +6 -0
@@ -748,6 +748,11 @@ intel_crt_detect(struct drm_connector *connector, connector->base.id, connector->name, force); +if (i915_modparams.load_detect_test) { +intel_display_power_get (dev_priv, intel_encoder->power_domain); + goto load_detect; + } +/* Skip machines without VGA that falsely report hotplug events */ if (dmi_check_system (intel_spurious_crt_detect))return connector_status_disconnected;
@@ -781,6 +786,7 @@ intel_crt_detect(struct drm_connector *connector, goto out; } +load_detect:if (!force) { status = connector->status; goto out;
Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 12/23] drm/vmwgfx: Stop consulting plane->fb
In reply to Ville SyrjalaQuoted 19 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
We want to get rid of
plane->fbon atomic drivers. Stop looking at it.Cc VMware Graphics <[email protected]>Cc Sinclair Yeh <[email protected]>Cc Thomas Hellstrom <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0
-0@@ -385,9 +385,9 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane, hotspot_x = du->hotspot_x; hotspot_y = du->hotspot_y;
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c vmw_du_cursor_plane_atomic_update(struct drm_plane *plane, · line 393
Quoted 10 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +3
-3-if (plane->fb) { - hotspot_x += plane->fb->hot_x; - hotspot_y += plane->fb->hot_y; +if (plane->state->fb) { + hotspot_x += plane->state->fb->hot_x; + hotspot_y += plane->state->fb->hot_y; } du->cursor_surface = vps->surf;
LGTM.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Gerd Hoffmann
maintainerRe: [PATCH 20/23] drm/virtio: Stop updating plane->fb
In reply to Ville Syrjaladrivers/gpu/drm/virtio/virtgpu_display.c static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index) · line 306
Quoted 4 lines
We want to get rid of
plane->fbon atomic drivers. Stop setting it.drivers/gpu/drm/virtio/virtgpu_display.c +0
-2- primary->crtc = crtc; - cursor->crtc = crtc;
commit msg vs. patch content mismatch here ...
cheers,
Gerd
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Gerd Hoffmann
maintainerRe: [PATCH 20/23] drm/virtio: Stop updating plane->fb
In reply to Ville Syrjaladrivers/gpu/drm/virtio/virtgpu_display.c static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index) · line 306
Quoted 4 lines
We want to get rid of
plane->fbon atomic drivers. Stop setting it.drivers/gpu/drm/virtio/virtgpu_display.c +0
-2- primary->crtc = crtc; - cursor->crtc = crtc;
commit msg vs. patch content mismatch here ...
cheers,
Gerd
Maarten Lankhorst
maintainerRe: [PATCH 13/23] drm/zte: Stop consulting plane->fb
In reply to Ville SyrjalaOp 22-03-18 om 16:23 schreef Ville Syrjala:
Quoted 15 lines
From: Ville Syrjälä <[email protected]>
We want to get rid of
plane->fbon atomic drivers. Stop looking at it.Cc Shawn Guo <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/zte/zx_vou.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/zte/zx_vou.c +0
-0
drivers/gpu/drm/zte/zx_vou.c void zx_vou_layer_enable(struct drm_plane *plane) · line 635
Quoted 8 lines
drivers/gpu/drm/zte/zx_vou.c +1
-1@@ -629,7 +629,7 @@ void zx_vou_layer_enable(struct drm_plane *plane)void zx_vou_layer_disable (struct drm_plane *plane) { -struct zx_crtc *zcrtc =to_zx_crtc (plane->crtc); +struct zx_crtc *zcrtc =to_zx_crtc (plane->state->crtc);struct zx_vou_hw *vou = zcrtc->vou;struct zx_plane *zplane =to_zx_plane (plane);const struct vou_layer_bits *bits = zplane->bits;
This function was not called with old_plane_state, which was ok when we still looked at plane->crtc. But with the changes it seems that this will likely cause a null pointer deref because when zx_plane_atomic_disable() is called, new_state->crtc is probably NULL when disabling. I would look at old_state to be sure.
~Maarten
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Maarten Lankhorst
maintainerRe: [PATCH 14/23] drm/atmel-hlcdc: Stop using plane->fb
In reply to Ville SyrjalaOp 22-03-18 om 16:23 schreef Ville Syrjala:
Quoted 32 lines
From: Ville Syrjälä <[email protected]>
We want to get rid of
plane->fbon atomic drivers. Stop looking at it.Cc Boris Brezillon <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +0
-10@@ -819,16 +819,6 @@ static void atmel_hlcdc_plane_atomic_disable(struct drm_plane *p,atmel_hlcdc_layer_read_reg (&plane->layer,ATMEL_HLCDC_LAYER_ISR ); } -static void atmel_hlcdc_plane_destroy (struct drm_plane *p) -{ -struct atmel_hlcdc_plane *plane =drm_plane_to_atmel_hlcdc_plane (p); - -if (plane->base.fb) -drm_framebuffer_put (plane->base.fb); - -drm_plane_cleanup (p); -} - static int atmel_hlcdc_plane_atomic_set_property(struct drm_plane *p, struct drm_plane_state *s, struct drm_property *property,
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c static void atmel_hlcdc_plane_atomic_destroy_state(struct drm_plane *p, · line 1034
Quoted 8 lines
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +1
-1@@ -1038,7 +1028,7 @@ static void atmel_hlcdc_plane_atomic_destroy_state(struct drm_plane *p,static const struct drm_plane_funcs layer_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = atmel_hlcdc_plane_destroy, + .destroy = drm_plane_cleanup, .reset = atmel_hlcdc_plane_reset, .atomic_duplicate_state = atmel_hlcdc_plane_atomic_duplicate_state, .atomic_destroy_state = atmel_hlcdc_plane_atomic_destroy_state,
This patch should probably be after 'drm: Stop updating plane->crtc/fb/old_fb on atomic drivers'?
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 11/23] drm/sti: Stop consulting plane->fb
In reply to Ville Syrjala2018-03-22 16:23 GMT+01:00 Ville Syrjala <[email protected]>:
Quoted 7 lines
From: Ville Syrjälä <[email protected]>
We want to get rid of
plane->fbon atomic drivers. Stop looking at it.Cc Benjamin Gaignard <[email protected]>Cc Vincent Abriou <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>
Ack-ed by: Benjamin Gaignard <[email protected]>
Quoted 36 lines
--- drivers/gpu/drm/sti/sti_plane.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/gpu/drm/sti/sti_plane.c +5
-5@@ -40,6 +40,7 @@ void sti_plane_update_fps(struct sti_plane *plane, bool new_frame, bool new_field) { +struct drm_plane_state *state = plane->drm_plane.state;ktime_t now;struct sti_fps_info *fps;int fpks, fipks, ms_since_last, num_frames, num_fields;@@ -66,14 +67,14 @@ void sti_plane_update_fps(struct sti_plane *plane, fps->last_timestamp = now; fps->last_frame_counter = fps->curr_frame_counter; -if (plane->drm_plane.fb) { +if (state->fb) { fpks = (num_frames *1000000 ) / ms_since_last;snprintf (plane->fps_info.fps_str,FPS_LENGTH ,"%-8s %4dx%-4d %.4s @ %3d.%-3.3d fps (%s)" , plane->drm_plane.name, - plane->drm_plane.fb->width, - plane->drm_plane.fb->height, - (char *)&plane->drm_plane.fb->format->format, + state->fb->width, + state->fb->height, + (char *)&state->fb->format->format, fpks /1000 , fpks %1000 ,sti_plane_to_str (plane)); } --
Quoted 2 lines
2.16.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patchwork
CI✗ Fi.CI.CHECKPATCH: warning for drm: Eliminate plane->fb/crtc usage for atomic drivers
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm: Eliminate plane->fb/crtc usage for atomic drivers
URL : https://patchwork.freedesktop.org/series/40478/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip 8af098617121 Revert "drm/atomic-helper: Fix leak in disable_all" 03876a233cc7 drm/atomic-helper: Make drm_atomic_helper_disable_all() update the plane->fb pointers -:93: CHECK:LINE_SPACING: Please use a blank line after function/struct/union/enum declarations #93: FILE: drivers/gpu/drm/drm_atomic_helper.c:2952: } +/**
total: 0 errors, 0 warnings, 1 checks, 98 lines checked224a3f4b99a5 drm: Clear crtc->primary->crtc when disabling the crtc via setcrtc()c3954d83df2f drm/atomic-helper: WARN if legacy plane fb pointers are bogus when committing duplicated state 6580440ce62b drm: Add local 'plane' variable for primary/cursor planes
-:121: WARNING:AVOID_BUG: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() #121: FILE: drivers/gpu/drm/drm_plane.c:773:
+ BUG_ON(!plane);
-:122: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "plane->crtc" #122: FILE: drivers/gpu/drm/drm_plane.c:774:
+ WARN_ON(plane->crtc != crtc && plane->crtc != NULL);
-:171: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!plane->fb" #171: FILE: drivers/gpu/drm/drm_plane.c:1014:
+ if (plane->fb == NULL) {
total: 0 errors, 1 warnings, 2 checks, 186 lines checked c5f62380d076 drm: Adjust whitespace for legibilitya7e79ff637c5 drm: Make the fb refcount handover less magic b3b47d829071 drm: Use plane->state->fb over plane->fb
-:90: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!old_fb" #90: FILE: drivers/gpu/drm/drm_plane.c:1024:
+ if (old_fb == NULL) {
total: 0 errors, 0 warnings, 1 checks, 79 lines checked8ea5e6add2d4 drm/i915: Stop consulting plane->fbae87bf410783 drm/msm: Stop consulting plane->fb7c4e668f28fa drm/sti: Stop consulting plane->fb610d46292088 drm/vmwgfx: Stop consulting plane->fb9be6d164afc9 drm/zte: Stop consulting plane->fbbfa847ae0a04 drm/atmel-hlcdc: Stop using plane->fb44c1635bfc7d drm: Stop updating plane->crtc/fb/old_fb on atomic drivers 54454e18424d drm/amdgpu/dc: Stop updating plane->fbb2817ab02542 drm/i915: Stop updating plane->fb/crtc12ec4c91178b drm/exynos: Stop updating plane->crtcd79a0cea6333 drm/msm: Stop updating plane->fb/crtc39c3be848eb9 drm/virtio: Stop updating plane->fb6994f330dc05 drm/vc4: Stop updating plane->fb/crtcea19ce070e91 drm/i915: Restore planes after load detection 9ed8bc3b37c4 drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Maarten Lankhorst
maintainerRe: [PATCH 23/23] drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug
In reply to Ville SyrjalaOp 22-03-18 om 16:23 schreef Ville Syrjala:
Quoted 30 lines
From: Ville Syrjälä <[email protected]>
When doing forced load detection testing we should totally ignore any hotplug status for the connector. This is mostly relevant for machines where we already ignore the hotplug status based on the DMI quirks. On other machines we would currently skip the force load detection tests on account of the connector already being connected.
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/i915/intel_crt.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/i915/intel_crt.c +5
-0@@ -748,6 +748,11 @@ intel_crt_detect(struct drm_connector *connector, connector->base.id, connector->name, force); +if (i915_modparams.load_detect_test) { +intel_display_power_get (dev_priv, intel_encoder->power_domain); + goto load_detect; + } +/* Skip machines without VGA that falsely report hotplug events */ if (dmi_check_system (intel_spurious_crt_detect))return connector_status_disconnected;
drivers/gpu/drm/i915/intel_crt.c intel_crt_detect(struct drm_connector *connector, · line 792
Quoted 7 lines
drivers/gpu/drm/i915/intel_crt.c +1
-0@@ -781,6 +786,7 @@ intel_crt_detect(struct drm_connector *connector, goto out; } +load_detect:if (!force) { status = connector->status; goto out;
This makes another reference to load_detect_test obsolete, the other one should be removed since its unreachable now. :)
~Maarten
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 21/23] drm/vc4: Stop updating plane->fb/crtc
In reply to Ville SyrjalaOp 22-03-18 om 16:23 schreef Ville Syrjala:
Quoted 32 lines
From: Ville Syrjälä <[email protected]>
We want to get rid of plane->fb/crtc on atomic drivers. Stop setting them.
Cc Eric Anholt <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/vc4/vc4_crtc.c | 3 --- 1 file changed, 3 deletions(-)drivers/gpu/drm/vc4/vc4_crtc.c +0
-2@@ -837,7 +837,6 @@ static int vc4_async_page_flip(struct drm_crtc *crtc,* is released. */ drm_atomic_set_fb_for_plane (plane->state, fb); - plane->fb = fb;vc4_queue_seqno_cb (dev, &flip_state->cb, bo->seqno, vc4_async_page_flip_complete);@@ -1032,7 +1031,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)drm_crtc_init_with_planes (drm, crtc, primary_plane,NULL , &vc4_crtc_funcs,NULL );drm_crtc_helper_add (crtc, &vc4_crtc_helper_funcs); - primary_plane->crtc = crtc; vc4_crtc->channel = vc4_crtc->data->hvs_channel;drm_mode_crtc_set_gamma_size (crtc,ARRAY_SIZE (vc4_crtc->lut_r));
drivers/gpu/drm/vc4/vc4_crtc.c static int vc4_crtc_bind(struct device *dev, struct device *master, void *data) · line 1065
Quoted 7 lines
drivers/gpu/drm/vc4/vc4_crtc.c +0
-1@@ -1062,7 +1060,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data) cursor_plane =vc4_plane_init (drm,DRM_PLANE_TYPE_CURSOR );if (!IS_ERR (cursor_plane)) { cursor_plane->possible_crtcs =1 <<drm_crtc_index (crtc); - cursor_plane->crtc = crtc; crtc->cursor = cursor_plane; }
With all my comments fixed, for the whole series:
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Den 22.03.2018 16.22, skrev Ville Syrjala:
Quoted 59 lines
From: Ville Syrjälä <[email protected]>
I really just wanted to fix i915 to re-enable its planes afer load detection (a two line patch). This is what I actually ended up with after I ran into a framebuffer refcount leak with said two line patch.
I've tested this on a few i915 boxes and so far it's looking good. Everything else is just compile tested.
Entire series available here:
git://github.com/vsyrjala/linux.gitplane_fb_crtc_nukeCc Alex Deucher <[email protected]>Cc Benjamin Gaignard <[email protected]>Cc Boris Brezillon <[email protected]>Cc "Christian König" <[email protected]>Cc Daniel Vetter <[email protected]>Cc Dave Airlie <[email protected]>Cc David Airlie <[email protected]>Cc "David (ChunMing) Zhou" <[email protected]>Cc Eric Anholt <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Harry Wentland <[email protected]>Cc Inki Dae <[email protected]>Cc Joonyoung Shim <[email protected]>Cc Kyungmin Park <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Rob Clark <[email protected]>Cc Seung-Woo Kim <[email protected]>Cc Shawn Guo <[email protected]>Cc Sinclair Yeh <[email protected]>Cc Thomas Hellstrom <[email protected]>Cc Vincent Abriou <[email protected]>Cc VMware Graphics <[email protected]>Ville Syrjälä (23):
Revert "drm/atomic-helper: Fix leak in disable_all" drm/atomic-helper: Make drm_atomic_helper_disable_all() update the plane->fb pointers drm: Clear crtc->primary->crtc when disabling the crtc via setcrtc() drm/atomic-helper: WARN if legacy plane fb pointers are bogus when committing duplicated state drm: Add local 'plane' variable for primary/cursor planes drm: Adjust whitespace for legibility drm: Make the fb refcount handover less magic drm: Use plane->state->fb over plane->fb drm/i915: Stop consulting plane->fb drm/msm: Stop consulting plane->fb drm/sti: Stop consulting plane->fb drm/vmwgfx: Stop consulting plane->fb drm/zte: Stop consulting plane->fb drm/atmel-hlcdc: Stop using plane->fb drm: Stop updating plane->crtc/fb/old_fb on atomic drivers
Quoted 8 lines
drm/amdgpu/dc: Stop updating plane->fb drm/i915: Stop updating plane->fb/crtc drm/exynos: Stop updating plane->crtc drm/msm: Stop updating plane->fb/crtc drm/virtio: Stop updating plane->fb drm/vc4: Stop updating plane->fb/crtc drm/i915: Restore planes after load detection drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug
tinydrm is also using plane->fb:
$ grep -r "plane\.fb" drivers/gpu/drm/tinydrm/ drivers/gpu/drm/tinydrm/repaper.c: if (tdev->pipe.plane.fb != fb) drivers/gpu/drm/tinydrm/mipi-dbi.c: if (tdev->pipe.plane.fb != fb) drivers/gpu/drm/tinydrm/mipi-dbi.c: struct drm_framebuffer *fb = mipi->tinydrm.pipe.plane.fb; drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c: pipe->plane.fb = fb; drivers/gpu/drm/tinydrm/ili9225.c: if (tdev->pipe.plane.fb != fb) drivers/gpu/drm/tinydrm/st7586.c: if (tdev->pipe.plane.fb != fb)
Noralf.
Quoted 15 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 - drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 12 +--- drivers/gpu/drm/drm_atomic.c | 55 ++-------------- drivers/gpu/drm/drm_atomic_helper.c | 79 ++++++++++------------- drivers/gpu/drm/drm_crtc.c | 51 ++++++++++----- drivers/gpu/drm/drm_fb_helper.c | 7 -- drivers/gpu/drm/drm_framebuffer.c | 5 -- drivers/gpu/drm/drm_plane.c | 64 +++++++++++------- drivers/gpu/drm/drm_plane_helper.c | 4 +- drivers/gpu/drm/exynos/exynos_drm_plane.c | 2 - drivers/gpu/drm/i915/intel_crt.c | 6 ++ drivers/gpu/drm/i915/intel_display.c | 9 +-- drivers/gpu/drm/i915/intel_fbdev.c | 2 +- drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c | 3 +- drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c | 2 -
Quoted 9 lines
drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 2 - drivers/gpu/drm/sti/sti_plane.c | 9 +-- drivers/gpu/drm/vc4/vc4_crtc.c | 3 - drivers/gpu/drm/virtio/virtgpu_display.c | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 6 +- drivers/gpu/drm/zte/zx_vou.c | 2 +- include/drm/drm_atomic.h | 3 - 22 files changed, 143 insertions(+), 187 deletions(-)
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Den 22.03.2018 16.22, skrev Ville Syrjala:
Quoted 59 lines
From: Ville Syrjälä <[email protected]>
I really just wanted to fix i915 to re-enable its planes afer load detection (a two line patch). This is what I actually ended up with after I ran into a framebuffer refcount leak with said two line patch.
I've tested this on a few i915 boxes and so far it's looking good. Everything else is just compile tested.
Entire series available here:
git://github.com/vsyrjala/linux.gitplane_fb_crtc_nukeCc Alex Deucher <[email protected]>Cc Benjamin Gaignard <[email protected]>Cc Boris Brezillon <[email protected]>Cc "Christian König" <[email protected]>Cc Daniel Vetter <[email protected]>Cc Dave Airlie <[email protected]>Cc David Airlie <[email protected]>Cc "David (ChunMing) Zhou" <[email protected]>Cc Eric Anholt <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Harry Wentland <[email protected]>Cc Inki Dae <[email protected]>Cc Joonyoung Shim <[email protected]>Cc Kyungmin Park <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Rob Clark <[email protected]>Cc Seung-Woo Kim <[email protected]>Cc Shawn Guo <[email protected]>Cc Sinclair Yeh <[email protected]>Cc Thomas Hellstrom <[email protected]>Cc Vincent Abriou <[email protected]>Cc VMware Graphics <[email protected]>Ville Syrjälä (23):
Revert "drm/atomic-helper: Fix leak in disable_all" drm/atomic-helper: Make drm_atomic_helper_disable_all() update the plane->fb pointers drm: Clear crtc->primary->crtc when disabling the crtc via setcrtc() drm/atomic-helper: WARN if legacy plane fb pointers are bogus when committing duplicated state drm: Add local 'plane' variable for primary/cursor planes drm: Adjust whitespace for legibility drm: Make the fb refcount handover less magic drm: Use plane->state->fb over plane->fb drm/i915: Stop consulting plane->fb drm/msm: Stop consulting plane->fb drm/sti: Stop consulting plane->fb drm/vmwgfx: Stop consulting plane->fb drm/zte: Stop consulting plane->fb drm/atmel-hlcdc: Stop using plane->fb drm: Stop updating plane->crtc/fb/old_fb on atomic drivers
Quoted 8 lines
drm/amdgpu/dc: Stop updating plane->fb drm/i915: Stop updating plane->fb/crtc drm/exynos: Stop updating plane->crtc drm/msm: Stop updating plane->fb/crtc drm/virtio: Stop updating plane->fb drm/vc4: Stop updating plane->fb/crtc drm/i915: Restore planes after load detection drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug
tinydrm is also using plane->fb:
$ grep -r "plane\.fb" drivers/gpu/drm/tinydrm/ drivers/gpu/drm/tinydrm/repaper.c: if (tdev->pipe.plane.fb != fb) drivers/gpu/drm/tinydrm/mipi-dbi.c: if (tdev->pipe.plane.fb != fb) drivers/gpu/drm/tinydrm/mipi-dbi.c: struct drm_framebuffer *fb = mipi->tinydrm.pipe.plane.fb; drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c: pipe->plane.fb = fb; drivers/gpu/drm/tinydrm/ili9225.c: if (tdev->pipe.plane.fb != fb) drivers/gpu/drm/tinydrm/st7586.c: if (tdev->pipe.plane.fb != fb)
Noralf.
Quoted 15 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 - drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 12 +--- drivers/gpu/drm/drm_atomic.c | 55 ++-------------- drivers/gpu/drm/drm_atomic_helper.c | 79 ++++++++++------------- drivers/gpu/drm/drm_crtc.c | 51 ++++++++++----- drivers/gpu/drm/drm_fb_helper.c | 7 -- drivers/gpu/drm/drm_framebuffer.c | 5 -- drivers/gpu/drm/drm_plane.c | 64 +++++++++++------- drivers/gpu/drm/drm_plane_helper.c | 4 +- drivers/gpu/drm/exynos/exynos_drm_plane.c | 2 - drivers/gpu/drm/i915/intel_crt.c | 6 ++ drivers/gpu/drm/i915/intel_display.c | 9 +-- drivers/gpu/drm/i915/intel_fbdev.c | 2 +- drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c | 3 +- drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c | 2 -
Quoted 9 lines
drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 2 - drivers/gpu/drm/sti/sti_plane.c | 9 +-- drivers/gpu/drm/vc4/vc4_crtc.c | 3 - drivers/gpu/drm/virtio/virtgpu_display.c | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 6 +- drivers/gpu/drm/zte/zx_vou.c | 2 +- include/drm/drm_atomic.h | 3 - 22 files changed, 143 insertions(+), 187 deletions(-)
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Patchwork
CI✗ Fi.CI.BAT: failure for drm: Eliminate plane->fb/crtc usage for atomic drivers
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm: Eliminate plane->fb/crtc usage for atomic drivers
URL : https://patchwork.freedesktop.org/series/40478/
State : failure
== Summary ==
Series 40478v1 drm: Eliminate plane->fb/crtc usage for atomic drivers
https://patchwork.freedesktop.org/api/1.0/series/40478/revisions/1/mbox/
---- Possible new issues:
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-a:
pass -> INCOMPLETE (fi-glk-1)---- Known issues:
Test debugfs_test:
Subgroup read_all_entries:
incomplete -> PASS (fi-snb-2520m) fdo#103713
Test gem_mmap_gtt:
Subgroup basic-small-bo-tiledx:
fail -> PASS (fi-gdg-551) fdo#102575
Test kms_pipe_crc_basic:
Subgroup nonblocking-crc-pipe-b-frame-sequence:
incomplete -> PASS (fi-cnl-y3) fdo#103191fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fi-bdw-5557u total:285 pass:264 dwarn:0 dfail:0 fail:0 skip:21 time:430s fi-bdw-gvtdvm total:285 pass:261 dwarn:0 dfail:0 fail:0 skip:24 time:440s fi-blb-e6850 total:285 pass:220 dwarn:1 dfail:0 fail:0 skip:64 time:385s fi-bsw-n3050 total:285 pass:239 dwarn:0 dfail:0 fail:0 skip:46 time:543s fi-bwr-2160 total:285 pass:180 dwarn:0 dfail:0 fail:0 skip:105 time:297s fi-bxt-dsi total:285 pass:255 dwarn:0 dfail:0 fail:0 skip:30 time:510s fi-bxt-j4205 total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:515s fi-byt-j1900 total:285 pass:250 dwarn:0 dfail:0 fail:0 skip:35 time:517s fi-byt-n2820 total:285 pass:246 dwarn:0 dfail:0 fail:0 skip:39 time:504s fi-cfl-8700k total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:407s fi-cfl-u total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:513s fi-cnl-drrs total:285 pass:254 dwarn:3 dfail:0 fail:0 skip:28 time:525s fi-cnl-y3 total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:580s fi-elk-e7500 total:285 pass:225 dwarn:1 dfail:0 fail:0 skip:59 time:425s fi-gdg-551 total:285 pass:177 dwarn:0 dfail:0 fail:0 skip:108 time:317s fi-glk-1 total:241 pass:214 dwarn:0 dfail:0 fail:0 skip:26 fi-hsw-4770 total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:402s fi-ilk-650 total:285 pass:225 dwarn:0 dfail:0 fail:0 skip:60 time:422s fi-ivb-3520m total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:468s fi-ivb-3770 total:285 pass:252 dwarn:0 dfail:0 fail:0 skip:33 time:431s fi-kbl-7500u total:285 pass:260 dwarn:1 dfail:0 fail:0 skip:24 time:481s fi-kbl-7567u total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:467s fi-kbl-r total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:514s fi-pnv-d510 total:285 pass:219 dwarn:1 dfail:0 fail:0 skip:65 time:653s fi-skl-6260u total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:441s fi-skl-6600u total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:537s fi-skl-6700k2 total:285 pass:261 dwarn:0 dfail:0 fail:0 skip:24 time:501s fi-skl-6770hq total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:511s fi-skl-guc total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:429s fi-skl-gvtdvm total:285 pass:262 dwarn:0 dfail:0 fail:0 skip:23 time:445s fi-snb-2520m total:285 pass:245 dwarn:0 dfail:0 fail:0 skip:40 time:587s fi-snb-2600 total:285 pass:245 dwarn:0 dfail:0 fail:0 skip:40 time:400s
fi-cfl-s3 failed to connect after reboot
40fcdd23bec787a5913496f2b11c5d26bdff985a drm-tip: 2018y-03m-22d-15h-28m-32s UTC integration manifest 9ed8bc3b37c4 drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug ea19ce070e91 drm/i915: Restore planes after load detection6994f330dc05 drm/vc4: Stop updating plane->fb/crtc39c3be848eb9 drm/virtio: Stop updating plane->fbd79a0cea6333 drm/msm: Stop updating plane->fb/crtc12ec4c91178b drm/exynos: Stop updating plane->crtcb2817ab02542 drm/i915: Stop updating plane->fb/crtc54454e18424d drm/amdgpu/dc: Stop updating plane->fb44c1635bfc7d drm: Stop updating plane->crtc/fb/old_fb on atomic driversbfa847ae0a04 drm/atmel-hlcdc: Stop using plane->fb9be6d164afc9 drm/zte: Stop consulting plane->fb610d46292088 drm/vmwgfx: Stop consulting plane->fb7c4e668f28fa drm/sti: Stop consulting plane->fbae87bf410783 drm/msm: Stop consulting plane->fb8ea5e6add2d4 drm/i915: Stop consulting plane->fbb3b47d829071 drm: Use plane->state->fb over plane->fba7e79ff637c5 drm: Make the fb refcount handover less magicc5f62380d076 drm: Adjust whitespace for legibility6580440ce62b drm: Add local 'plane' variable for primary/cursor planesc3954d83df2f drm/atomic-helper: WARN if legacy plane fb pointers are bogus when committing duplicated state 224a3f4b99a5 drm: Clear crtc->primary->crtc when disabling the crtc via setcrtc() 03876a233cc7 drm/atomic-helper: Make drm_atomic_helper_disable_all() update the plane->fb pointers 8af098617121 Revert "drm/atomic-helper: Fix leak in disable_all"
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8452/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 14/23] drm/atmel-hlcdc: Stop using plane->fb
In reply to Maarten LankhorstQuoted 35 lines · Maarten Lankhorst
Op 22-03-18 om 16:23 schreef Ville Syrjala:
Quoted 34 lines
From: Ville Syrjälä <[email protected]>
We want to get rid of
plane->fbon atomic drivers. Stop looking at it.Cc Boris Brezillon <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +0
-10@@ -819,16 +819,6 @@ static void atmel_hlcdc_plane_atomic_disable(struct drm_plane *p,atmel_hlcdc_layer_read_reg (&plane->layer,ATMEL_HLCDC_LAYER_ISR ); } -static void atmel_hlcdc_plane_destroy (struct drm_plane *p) -{ -struct atmel_hlcdc_plane *plane =drm_plane_to_atmel_hlcdc_plane (p); - -if (plane->base.fb) -drm_framebuffer_put (plane->base.fb); - -drm_plane_cleanup (p); -} - static int atmel_hlcdc_plane_atomic_set_property(struct drm_plane *p, struct drm_plane_state *s, struct drm_property *property,@@ -1038,7 +1028,7 @@ static void atmel_hlcdc_plane_atomic_destroy_state(struct drm_plane *p,static const struct drm_plane_funcs layer_plane_funcs = { .update_plane = drm_atomic_helper_update_plane,
Quoted 8 lines
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c static void atmel_hlcdc_plane_atomic_destroy_state(struct drm_plane *p, · line 1034
Quoted 6 lines
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +1
-1.disable_plane = drm_atomic_helper_disable_plane, - .destroy = atmel_hlcdc_plane_destroy, + .destroy = drm_plane_cleanup, .reset = atmel_hlcdc_plane_reset, .atomic_duplicate_state = atmel_hlcdc_plane_atomic_duplicate_state, .atomic_destroy_state = atmel_hlcdc_plane_atomic_destroy_state,This patch should probably be after 'drm: Stop updating plane->crtc/fb/old_fb on atomic drivers'?
Yeah, that does seem like a better order.
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 13/23 drm/zte: Stop consulting plane->fb
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->fb on atomic drivers. Stop looking at it.
v2: Use old_state->crtc (Maarten)
--- drivers/gpu/drm/zte/zx_plane.c | 2 +- drivers/gpu/drm/zte/zx_vou.c | 5 +++-- drivers/gpu/drm/zte/zx_vou.h | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/zte/zx_plane.c +1 -1
@@ -268,7 +268,7 @@ static void zx_plane_atomic_disable(struct drm_plane *plane,struct zx_plane *zplane =to_zx_plane (plane);void __iomem *hbsc = zplane->hbsc; -zx_vou_layer_disable (plane); +zx_vou_layer_disable (plane, old_state);/* Disable HBSC block */ zx_writel_mask (hbsc +HBSC_CTRL0 ,HBSC_CTRL_EN ,0 );
drivers/gpu/drm/zte/zx_vou.c +3 -2
@@ -627,9 +627,10 @@ void zx_vou_layer_enable(struct drm_plane *plane)zx_writel_mask (vou->osd +OSD_CTRL0 , bits->enable, bits->enable); } -void zx_vou_layer_disable (struct drm_plane *plane) +void zx_vou_layer_disable (struct drm_plane *plane, +struct drm_plane_state *old_state) { -struct zx_crtc *zcrtc =to_zx_crtc (plane->crtc); +struct zx_crtc *zcrtc =to_zx_crtc (old_state->crtc);struct zx_vou_hw *vou = zcrtc->vou;struct zx_plane *zplane =to_zx_plane (plane);const struct vou_layer_bits *bits = zplane->bits;
drivers/gpu/drm/zte/zx_vou.h +2 -1
@@ -62,6 +62,7 @@ void zx_vou_config_dividers(struct drm_crtc *crtc, struct vou_div_config *configs, int num);void zx_vou_layer_enable (struct drm_plane *plane); -void zx_vou_layer_disable (struct drm_plane *plane); +void zx_vou_layer_disable (struct drm_plane *plane, +struct drm_plane_state *old_state);#endif /* __ZX_VOU_H__ */
Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 20/23 drm/virtio: Stop updating plane->crtc
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->crtc on atomic drivers. Stop setting it.
v2: s/fb/crtc/ in the commit message (Gerd)
--- drivers/gpu/drm/virtio/virtgpu_display.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/virtio/virtgpu_display.c +0 -2
@@ -302,8 +302,6 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)drm_crtc_init_with_planes (dev, crtc, primary, cursor, &virtio_gpu_crtc_funcs,NULL );drm_crtc_helper_add (crtc, &virtio_gpu_crtc_helper_funcs); - primary->crtc = crtc; - cursor->crtc = crtc;drm_connector_init (dev, connector, &virtio_gpu_connector_funcs,DRM_MODE_CONNECTOR_VIRTUAL );
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 20/23 drm/virtio: Stop updating plane->crtc
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->crtc on atomic drivers. Stop setting it.
v2: s/fb/crtc/ in the commit message (Gerd)
--- drivers/gpu/drm/virtio/virtgpu_display.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/virtio/virtgpu_display.c +0 -2
@@ -302,8 +302,6 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)drm_crtc_init_with_planes (dev, crtc, primary, cursor, &virtio_gpu_crtc_funcs,NULL );drm_crtc_helper_add (crtc, &virtio_gpu_crtc_helper_funcs); - primary->crtc = crtc; - cursor->crtc = crtc;drm_connector_init (dev, connector, &virtio_gpu_connector_funcs,DRM_MODE_CONNECTOR_VIRTUAL );
Signature · 6 lines
2.16.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
PATCH v2 23/23 drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
When doing forced load detection testing we should totally ignore any hotplug status for the connector. This is mostly relevant for machines where we already ignore the hotplug status based on the DMI quirks. On other machines we would currently skip the force load detection tests on account of the connector already being connected.
v2: Drop the other force_load_detect check since it's useless now (Maarten)
--- drivers/gpu/drm/i915/intel_crt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_crt.c +7 -1
@@ -748,6 +748,11 @@ intel_crt_detect(struct drm_connector *connector, connector->base.id, connector->name, force); +if (i915_modparams.load_detect_test) { +intel_display_power_get (dev_priv, intel_encoder->power_domain); + goto load_detect; + } +/* Skip machines without VGA that falsely report hotplug events */ if (dmi_check_system (intel_spurious_crt_detect))return connector_status_disconnected;
@@ -776,11 +781,12 @@ intel_crt_detect(struct drm_connector *connector,* broken monitor (without edid) to work behind a broken kvm (that fails * to have the right resistors for HP detection) needs to fix this up. * For now just bail out. */ -if (I915_HAS_HOTPLUG (dev_priv) && !i915_modparams.load_detect_test) { +if (I915_HAS_HOTPLUG (dev_priv)) { status = connector_status_disconnected; goto out; } +load_detect:if (!force) { status = connector->status; goto out;
Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Ville,
Quoted 9 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
I really just wanted to fix i915 to re-enable its planes afer load detection (a two line patch). This is what I actually ended up with after I ran into a framebuffer refcount leak with said two line patch.
I've tested this on a few i915 boxes and so far it's looking good. Everything else is just compile tested.
Mostly thinking out loud:
Wondering if one cannot somehow (re)move plane->fb/crtc altogether. Otherwise drivers will reintroduce similar code, despite the WARNs and beefy documentation :-\
HTH
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Ville,
Quoted 9 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
I really just wanted to fix i915 to re-enable its planes afer load detection (a two line patch). This is what I actually ended up with after I ran into a framebuffer refcount leak with said two line patch.
I've tested this on a few i915 boxes and so far it's looking good. Everything else is just compile tested.
Mostly thinking out loud:
Wondering if one cannot somehow (re)move plane->fb/crtc altogether. Otherwise drivers will reintroduce similar code, despite the WARNs and beefy documentation :-\
HTH
Emil
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Patchwork
CI✗ Fi.CI.CHECKPATCH: warning for drm: Eliminate plane->fb/crtc usage for atomic drivers (rev4)
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm: Eliminate plane->fb/crtc usage for atomic drivers (rev4)
URL : https://patchwork.freedesktop.org/series/40478/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip c15222c5376f Revert "drm/atomic-helper: Fix leak in disable_all" e1c1c0c2616b drm/atomic-helper: Make drm_atomic_helper_disable_all() update the plane->fb pointers -:93: CHECK:LINE_SPACING: Please use a blank line after function/struct/union/enum declarations #93: FILE: drivers/gpu/drm/drm_atomic_helper.c:2952: } +/**
total: 0 errors, 0 warnings, 1 checks, 98 lines checked83ae766ecf59 drm: Clear crtc->primary->crtc when disabling the crtc via setcrtc()7a9501d57103 drm/atomic-helper: WARN if legacy plane fb pointers are bogus when committing duplicated state 591ea3185c8b drm: Add local 'plane' variable for primary/cursor planes
-:121: WARNING:AVOID_BUG: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() #121: FILE: drivers/gpu/drm/drm_plane.c:773:
+ BUG_ON(!plane);
-:122: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "plane->crtc" #122: FILE: drivers/gpu/drm/drm_plane.c:774:
+ WARN_ON(plane->crtc != crtc && plane->crtc != NULL);
-:171: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!plane->fb" #171: FILE: drivers/gpu/drm/drm_plane.c:1014:
+ if (plane->fb == NULL) {
total: 0 errors, 1 warnings, 2 checks, 186 lines checked 1c416abc1569 drm: Adjust whitespace for legibility5725ad36f927 drm: Make the fb refcount handover less magic 0c86fdf2fc0a drm: Use plane->state->fb over plane->fb
-:90: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!old_fb" #90: FILE: drivers/gpu/drm/drm_plane.c:1024:
+ if (old_fb == NULL) {
total: 0 errors, 0 warnings, 1 checks, 79 lines checked973ef243f6f2 drm/i915: Stop consulting plane->fb8725c9242cc1 drm/msm: Stop consulting plane->fb935907ed7ad6 drm/sti: Stop consulting plane->fb9f0e4d0b9e42 drm/vmwgfx: Stop consulting plane->fba3badb58385a drm/zte: Stop consulting plane->fb588e4c26248d drm/atmel-hlcdc: Stop using plane->fb1163ef51d4d6 drm: Stop updating plane->crtc/fb/old_fb on atomic drivers 8f452e9c6e6d drm/amdgpu/dc: Stop updating plane->fb337b7212bf2c drm/i915: Stop updating plane->fb/crtce20bc30e5a6b drm/exynos: Stop updating plane->crtc38ee91954b33 drm/msm: Stop updating plane->fb/crtc8c80fa662591 drm/virtio: Stop updating plane->crtc32af98aba537 drm/vc4: Stop updating plane->fb/crtcb4e5a00d654e drm/i915: Restore planes after load detection ad0944dbaf79 drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 9 lines · Emil Velikov
Hi Ville,
Quoted 6 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
I really just wanted to fix i915 to re-enable its planes afer load detection (a two line patch). This is what I actually ended up with after I ran into a framebuffer refcount leak with said two line patch.
Quoted 8 lines
Quoted 3 lines
I've tested this on a few i915 boxes and so far it's looking good. Everything else is just compile tested.
Mostly thinking out loud:
Wondering if one cannot somehow (re)move plane->fb/crtc altogether. Otherwise drivers will reintroduce similar code, despite the WARNs and beefy documentation :-\
Wouldn't that require an atomic conversion of all remaining drivers?
Harry
Quoted 8 lines
HTH
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm: Eliminate plane->fb/crtc usage for atomic drivers (rev4)
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm: Eliminate plane->fb/crtc usage for atomic drivers (rev4)
URL : https://patchwork.freedesktop.org/series/40478/
State : success
== Summary ==
Series 40478v4 drm: Eliminate plane->fb/crtc usage for atomic drivers
https://patchwork.freedesktop.org/api/1.0/series/40478/revisions/4/mbox/
---- Known issues:
Test debugfs_test:
Subgroup read_all_entries:
incomplete -> PASS (fi-snb-2520m) fdo#103713
Test kms_pipe_crc_basic:
Subgroup nonblocking-crc-pipe-b-frame-sequence:
incomplete -> PASS (fi-cnl-y3) fdo#103191fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fi-bdw-5557u total:285 pass:264 dwarn:0 dfail:0 fail:0 skip:21 time:432s fi-bdw-gvtdvm total:285 pass:261 dwarn:0 dfail:0 fail:0 skip:24 time:440s fi-blb-e6850 total:285 pass:220 dwarn:1 dfail:0 fail:0 skip:64 time:382s fi-bsw-n3050 total:285 pass:239 dwarn:0 dfail:0 fail:0 skip:46 time:539s fi-bwr-2160 total:285 pass:180 dwarn:0 dfail:0 fail:0 skip:105 time:299s fi-bxt-dsi total:285 pass:255 dwarn:0 dfail:0 fail:0 skip:30 time:514s fi-bxt-j4205 total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:512s fi-byt-j1900 total:285 pass:250 dwarn:0 dfail:0 fail:0 skip:35 time:521s fi-byt-n2820 total:285 pass:246 dwarn:0 dfail:0 fail:0 skip:39 time:505s fi-cfl-8700k total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:410s fi-cfl-u total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:510s fi-cnl-drrs total:285 pass:254 dwarn:3 dfail:0 fail:0 skip:28 time:538s fi-cnl-y3 total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:587s fi-elk-e7500 total:285 pass:225 dwarn:1 dfail:0 fail:0 skip:59 time:424s fi-gdg-551 total:285 pass:176 dwarn:0 dfail:0 fail:1 skip:108 time:319s fi-glk-1 total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:542s fi-hsw-4770 total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:401s fi-ilk-650 total:285 pass:225 dwarn:0 dfail:0 fail:0 skip:60 time:418s fi-ivb-3520m total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:474s fi-ivb-3770 total:285 pass:252 dwarn:0 dfail:0 fail:0 skip:33 time:432s fi-kbl-7500u total:285 pass:260 dwarn:1 dfail:0 fail:0 skip:24 time:475s fi-kbl-7567u total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:469s fi-kbl-r total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:520s fi-pnv-d510 total:285 pass:219 dwarn:1 dfail:0 fail:0 skip:65 time:659s fi-skl-6260u total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:443s fi-skl-6600u total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:539s fi-skl-6700k2 total:285 pass:261 dwarn:0 dfail:0 fail:0 skip:24 time:502s fi-skl-6770hq total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:489s fi-skl-guc total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:428s fi-skl-gvtdvm total:285 pass:262 dwarn:0 dfail:0 fail:0 skip:23 time:443s fi-snb-2520m total:285 pass:245 dwarn:0 dfail:0 fail:0 skip:40 time:589s fi-snb-2600 total:285 pass:245 dwarn:0 dfail:0 fail:0 skip:40 time:414s
fi-cfl-s3 failed to connect after reboot
40fcdd23bec787a5913496f2b11c5d26bdff985a drm-tip: 2018y-03m-22d-15h-28m-32s UTC integration manifest ad0944dbaf79 drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug b4e5a00d654e drm/i915: Restore planes after load detection32af98aba537 drm/vc4: Stop updating plane->fb/crtc8c80fa662591 drm/virtio: Stop updating plane->crtc38ee91954b33 drm/msm: Stop updating plane->fb/crtce20bc30e5a6b drm/exynos: Stop updating plane->crtc337b7212bf2c drm/i915: Stop updating plane->fb/crtc8f452e9c6e6d drm/amdgpu/dc: Stop updating plane->fb1163ef51d4d6 drm: Stop updating plane->crtc/fb/old_fb on atomic drivers588e4c26248d drm/atmel-hlcdc: Stop using plane->fba3badb58385a drm/zte: Stop consulting plane->fb9f0e4d0b9e42 drm/vmwgfx: Stop consulting plane->fb935907ed7ad6 drm/sti: Stop consulting plane->fb8725c9242cc1 drm/msm: Stop consulting plane->fb973ef243f6f2 drm/i915: Stop consulting plane->fb0c86fdf2fc0a drm: Use plane->state->fb over plane->fb5725ad36f927 drm: Make the fb refcount handover less magic1c416abc1569 drm: Adjust whitespace for legibility591ea3185c8b drm: Add local 'plane' variable for primary/cursor planes7a9501d57103 drm/atomic-helper: WARN if legacy plane fb pointers are bogus when committing duplicated state 83ae766ecf59 drm: Clear crtc->primary->crtc when disabling the crtc via setcrtc() e1c1c0c2616b drm/atomic-helper: Make drm_atomic_helper_disable_all() update the plane->fb pointers c15222c5376f Revert "drm/atomic-helper: Fix leak in disable_all"
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8456/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 13 lines · Harry Wentland
Quoted 12 lines · Emil Velikov
Hi Ville,
Quoted 9 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
I really just wanted to fix i915 to re-enable its planes afer load detection (a two line patch). This is what I actually ended up with after I ran into a framebuffer refcount leak with said two line patch.
I've tested this on a few i915 boxes and so far it's looking good. Everything else is just compile tested.
Quoted 8 lines
Quoted 5 lines
Mostly thinking out loud:
Wondering if one cannot somehow (re)move plane->fb/crtc altogether. Otherwise drivers will reintroduce similar code, despite the WARNs and beefy documentation :-\
Wouldn't that require an atomic conversion of all remaining drivers?
That or maybe move into plane->legacy->{fb,crtc}. Feel free to swap 'legacy' with flashier name.
Hmm back in 2015 we had a GSoC that updated BOCHS and CIRRUS drivers, but they never got merged.
Don't recall the details - from memory the conversion seemed fine, but there was either shortage on review/other.
Might be worth reviving that... regardless it's getting a bit off-topic. -Emil
[1] https://www.google-melange.com/archive/gsoc/2015/orgs/xorg/projects/johnhunter.html
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 13 lines · Harry Wentland
Quoted 12 lines · Emil Velikov
Hi Ville,
Quoted 9 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
I really just wanted to fix i915 to re-enable its planes afer load detection (a two line patch). This is what I actually ended up with after I ran into a framebuffer refcount leak with said two line patch.
I've tested this on a few i915 boxes and so far it's looking good. Everything else is just compile tested.
Quoted 8 lines
Quoted 5 lines
Mostly thinking out loud:
Wondering if one cannot somehow (re)move plane->fb/crtc altogether. Otherwise drivers will reintroduce similar code, despite the WARNs and beefy documentation :-\
Wouldn't that require an atomic conversion of all remaining drivers?
That or maybe move into plane->legacy->{fb,crtc}. Feel free to swap 'legacy' with flashier name.
Hmm back in 2015 we had a GSoC that updated BOCHS and CIRRUS drivers, but they never got merged.
Don't recall the details - from memory the conversion seemed fine, but there was either shortage on review/other.
Might be worth reviving that... regardless it's getting a bit off-topic. -Emil
[1] https://www.google-melange.com/archive/gsoc/2015/orgs/xorg/projects/johnhunter.html
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 7 lines · Noralf Trønnes
tinydrm is also using
plane->fb:$ grep -r "plane\.fb" drivers/gpu/drm/tinydrm/ drivers/gpu/drm/tinydrm/repaper.c: if (tdev->pipe.plane.fb != fb) drivers/gpu/drm/tinydrm/mipi-dbi.c: if (tdev->pipe.plane.fb != fb) drivers/gpu/drm/tinydrm/mipi-dbi.c: struct drm_framebuffer *fb = mipi->tinydrm.pipe.plane.fb;
Oh dear, and naturally it's the most annoying one of the bunch. So we want to take the plane lock in the fb.dirty() hook to look at the fb, but mipi-dbi.c calls that directly from the bowels of its .atomic_enable() hook. So that would deadlock pretty neatly if the commit happens while already holding the lock.
So we'd either need to plumb an acquire context into fb.dirty(), or maybe have tinydrm provide a lower level lockless dirty() hook that gets called by both (there are just too many layers in this particular cake to immediately see where such a hook would be best placed). Or maybe there's some other solution I didn't think of.
Looking at this I'm also left wondering how this is supposed handle fb.dirty() getting called concurrently with a modeset. The dirty_mutex only seems to offer any protection for fb.dirty() against another fb.dirty()...
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 7 lines · Noralf Trønnes
tinydrm is also using
plane->fb:$ grep -r "plane\.fb" drivers/gpu/drm/tinydrm/ drivers/gpu/drm/tinydrm/repaper.c: if (tdev->pipe.plane.fb != fb) drivers/gpu/drm/tinydrm/mipi-dbi.c: if (tdev->pipe.plane.fb != fb) drivers/gpu/drm/tinydrm/mipi-dbi.c: struct drm_framebuffer *fb = mipi->tinydrm.pipe.plane.fb;
Oh dear, and naturally it's the most annoying one of the bunch. So we want to take the plane lock in the fb.dirty() hook to look at the fb, but mipi-dbi.c calls that directly from the bowels of its .atomic_enable() hook. So that would deadlock pretty neatly if the commit happens while already holding the lock.
So we'd either need to plumb an acquire context into fb.dirty(), or maybe have tinydrm provide a lower level lockless dirty() hook that gets called by both (there are just too many layers in this particular cake to immediately see where such a hook would be best placed). Or maybe there's some other solution I didn't think of.
Looking at this I'm also left wondering how this is supposed handle fb.dirty() getting called concurrently with a modeset. The dirty_mutex only seems to offer any protection for fb.dirty() against another fb.dirty()...
Signature · 2 lines
Ville Syrjälä Intel OTC
Patchwork
CI✗ Fi.CI.IGT: failure for drm: Eliminate plane->fb/crtc usage for atomic drivers (rev4)
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm: Eliminate plane->fb/crtc usage for atomic drivers (rev4)
URL : https://patchwork.freedesktop.org/series/40478/
State : failure
== Summary ==
---- Possible new issues:
Test kms_cursor_legacy:
Subgroup flip-vs-cursor-legacy:
pass -> FAIL (shard-hsw)---- Known issues:
Test kms_flip:
Subgroup dpms-vs-vblank-race:
fail -> PASS (shard-hsw) fdo#103060 +1
Subgroup plain-flip-fb-recreate:
pass -> FAIL (shard-hsw) fdo#100368 +1fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
shard-apl total:3484 pass:1820 dwarn:1 dfail:0 fail:7 skip:1655 time:13121s shard-hsw total:3484 pass:1771 dwarn:1 dfail:0 fail:4 skip:1707 time:11775s shard-snb total:3484 pass:1363 dwarn:1 dfail:0 fail:3 skip:2117 time:7300s
Blacklisted hosts:
shard-kbl total:3484 pass:1944 dwarn:1 dfail:0 fail:10 skip:1529 time:9956s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8456/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Den 22.03.2018 19.49, skrev Ville Syrjälä:
Quoted 20 lines · Noralf Trønnes
Quoted 7 lines
tinydrm is also using
plane->fb:$ grep -r "plane\.fb" drivers/gpu/drm/tinydrm/ drivers/gpu/drm/tinydrm/repaper.c: if (tdev->pipe.plane.fb != fb) drivers/gpu/drm/tinydrm/mipi-dbi.c: if (tdev->pipe.plane.fb != fb) drivers/gpu/drm/tinydrm/mipi-dbi.c: struct drm_framebuffer *fb = mipi->tinydrm.pipe.plane.fb;Oh dear, and naturally it's the most annoying one of the bunch. So we want to take the plane lock in the
fb.dirty()hook to look at the fb, butmipi-dbi.ccalls that directly from the bowels of its .atomic_enable() hook. So that would deadlock pretty neatly if the commit happens while already holding the lock.So we'd either need to plumb an acquire context into
fb.dirty(), or maybe have tinydrm provide a lower level locklessdirty()hook that gets called by both (there are just too many layers in this particular cake to immediately see where such a hook would be best placed). Or maybe there's some other solution I didn't think of.
Quoted 5 lines
Looking at this I'm also left wondering how this is supposed handle
fb.dirty()getting called concurrently with a modeset. Thedirty_mutexonly seems to offer any protection forfb.dirty()against anotherfb.dirty()...
I have been waiting for the 'page-flip with damage'[1] work to come to fruition so I could handle all flushing during atomic commit. The idea is to use the same damage rect for a generic dirtyfb callback.
Maybe a temporary tinydrm specific solution is possible until that work lands, but I don't know enough about how to implement such a dirtyfb callback.
I imagine it could look something like this:
struct tinydrm_device {
+ struct drm_clip_rect dirtyfb_rect;
};
static int tinydrm_fb_dirty(struct drm_framebuffer *fb, struct drm_file *file_priv, unsigned int flags, unsigned int color, struct drm_clip_rect *clips, unsigned int num_clips)
{
struct tinydrm_device *tdev = fb->dev->dev_private; struct drm_framebuffer *planefb;
/* Grab whatever lock needed to check this */
planefb = tdev->pipe.plane.state->fb;
/* fbdev can flush even when we're not interested */ if (fb != planefb)
return 0;
/* Protect dirtyfb_rect with a lock */ tinydrm_merge_clips(&tdev->dirty_rectfb, clips, num_clips, flags, fb->width, fb->height);
/*
* Somehow do an atomic commit that results in the atomic update
* callback being called
*/
ret = drm_atomic_commit(state);
...
}
static void mipi_dbi_flush(struct drm_framebuffer *fb, struct drm_clip_rect *clip)
{
/* Flush out framebuffer */
}
void mipi_dbi_pipe_update(struct drm_simple_display_pipe *pipe, struct drm_plane_state *old_state)
{
struct tinydrm_device *tdev = pipe_to_tinydrm(pipe); struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev); struct drm_framebuffer *fb = pipe->plane.state->fb; struct drm_crtc *crtc = &tdev->pipe.crtc;
if (!fb || (fb == old_state->fb && !tdev->dirty_rect.x2)) goto out_vblank;
/* Don't flush if the controller isn't initialized yet */ if (!mipi->enabled)
goto out_vblank;
if (fb != old_state->fb) { /* Page flip or new, flush all */ mipi_dbi_flush(fb, NULL);
} else { /* dirtyfb ioctl */
mipi_dbi_flush(fb, &tdev->dirtyfb_rect); memset(&tdev->dirtyfb_rect, 0, sizeof(tdev->dirtyfb_rect)); }
out_vblank:
if (crtc->state->event) { spin_lock_irq(&crtc->dev->event_lock); drm_crtc_send_vblank_event(crtc, crtc->state->event); spin_unlock_irq(&crtc->dev->event_lock); crtc->state->event = NULL;
}
}
This is called from the driver pipe enable callback after the controller has been initialized:
void mipi_dbi_pipe_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state)
{
struct tinydrm_device *tdev = pipe_to_tinydrm(pipe); struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
- struct drm_framebuffer *fb = pipe->plane.fb;
+ struct drm_framebuffer *fb = pipe->plane.state->fb;
DRM_DEBUG_KMS("\n");
mipi->enabled = true;
- if (fb)
- fb->funcs->dirty(fb, NULL, 0, 0, NULL, 0); + mipi_dbi_flush(fb, NULL); tinydrm_enable_backlight(mipi->backlight); }
I can make patches if this makes any sense and you can help me with the dirtyfb implementation.
Noralf.
[1] https://lists.freedesktop.org/archives/dri-devel/2017-December/161003.html
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 16/23] drm/amdgpu/dc: Stop updating plane->fb
In reply to Ville SyrjalaQuoted 10 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
We want to get rid of
plane->fbon atomic drivers. Stop setting it.Cc Alex Deucher <[email protected]>Cc "Christian König" <[email protected]>Cc "David (ChunMing) Zhou" <[email protected]>Cc Harry Wentland <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>
Patches 1-8 & 15 also look reasonable to me, but I'm not an expert on this. Feel free to add my
Harry
Quoted 10 lines
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 -- 1 file changed, 2 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_do_flip(struct drm_crtc *crtc, · line 3946
Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-2@@ -3941,8 +3941,6 @@ static void amdgpu_dm_do_flip(struct drm_crtc *crtc,/* Flip */ spin_lock_irqsave (&crtc->dev->event_lock, flags); -/* update crtc fb */ - crtc->primary->fb = fb;WARN_ON (acrtc->pflip_status !=AMDGPU_FLIP_NONE );WARN_ON (!acrtc_state->stream);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 13/23] drm/zte: Stop consulting plane->fb
In reply to Ville SyrjalaQuoted 3 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
We want to get rid of
plane->fbon atomic drivers. Stop looking at it.
Would it be more precise to use "plane->crtc" in both subject and commit log? Other than that:
Quoted 58 lines
v2: Use
old_state->crtc(Maarten)Cc Shawn Guo <[email protected]>Cc Maarten Lankhorst <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/zte/zx_plane.c | 2 +- drivers/gpu/drm/zte/zx_vou.c | 5 +++-- drivers/gpu/drm/zte/zx_vou.h | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-)drivers/gpu/drm/zte/zx_plane.c +1
-1@@ -268,7 +268,7 @@ static void zx_plane_atomic_disable(struct drm_plane *plane,struct zx_plane *zplane =to_zx_plane (plane);void __iomem *hbsc = zplane->hbsc; -zx_vou_layer_disable (plane); +zx_vou_layer_disable (plane, old_state);/* Disable HBSC block */ zx_writel_mask (hbsc +HBSC_CTRL0 ,HBSC_CTRL_EN ,0 );drivers/gpu/drm/zte/zx_vou.c +3
-2@@ -627,9 +627,10 @@ void zx_vou_layer_enable(struct drm_plane *plane)zx_writel_mask (vou->osd +OSD_CTRL0 , bits->enable, bits->enable); } -void zx_vou_layer_disable (struct drm_plane *plane) +void zx_vou_layer_disable (struct drm_plane *plane, +struct drm_plane_state *old_state) { -struct zx_crtc *zcrtc =to_zx_crtc (plane->crtc); +struct zx_crtc *zcrtc =to_zx_crtc (old_state->crtc);struct zx_vou_hw *vou = zcrtc->vou;struct zx_plane *zplane =to_zx_plane (plane);const struct vou_layer_bits *bits = zplane->bits;drivers/gpu/drm/zte/zx_vou.h +2
-1@@ -62,6 +62,7 @@ void zx_vou_config_dividers(struct drm_crtc *crtc, struct vou_div_config *configs, int num);void zx_vou_layer_enable (struct drm_plane *plane); -void zx_vou_layer_disable (struct drm_plane *plane); +void zx_vou_layer_disable (struct drm_plane *plane, +struct drm_plane_state *old_state);#endif /* __ZX_VOU_H__ */ Signature · 1 line
2.16.1
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 13/23 drm/zte: Stop consulting plane->crtc
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We want to get rid of plane->crtc on atomic drivers. Stop looking at it.
v2: Use old_state->crtc (Maarten)
v3: s/fb/crtc/ in commit message to actually match the patch (Shawn)
--- drivers/gpu/drm/zte/zx_plane.c | 2 +- drivers/gpu/drm/zte/zx_vou.c | 5 +++-- drivers/gpu/drm/zte/zx_vou.h | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/zte/zx_plane.c +1 -1
@@ -268,7 +268,7 @@ static void zx_plane_atomic_disable(struct drm_plane *plane,struct zx_plane *zplane =to_zx_plane (plane);void __iomem *hbsc = zplane->hbsc; -zx_vou_layer_disable (plane); +zx_vou_layer_disable (plane, old_state);/* Disable HBSC block */ zx_writel_mask (hbsc +HBSC_CTRL0 ,HBSC_CTRL_EN ,0 );
drivers/gpu/drm/zte/zx_vou.c +3 -2
@@ -627,9 +627,10 @@ void zx_vou_layer_enable(struct drm_plane *plane)zx_writel_mask (vou->osd +OSD_CTRL0 , bits->enable, bits->enable); } -void zx_vou_layer_disable (struct drm_plane *plane) +void zx_vou_layer_disable (struct drm_plane *plane, +struct drm_plane_state *old_state) { -struct zx_crtc *zcrtc =to_zx_crtc (plane->crtc); +struct zx_crtc *zcrtc =to_zx_crtc (old_state->crtc);struct zx_vou_hw *vou = zcrtc->vou;struct zx_plane *zplane =to_zx_plane (plane);const struct vou_layer_bits *bits = zplane->bits;
drivers/gpu/drm/zte/zx_vou.h +2 -1
@@ -62,6 +62,7 @@ void zx_vou_config_dividers(struct drm_crtc *crtc, struct vou_div_config *configs, int num);void zx_vou_layer_enable (struct drm_plane *plane); -void zx_vou_layer_disable (struct drm_plane *plane); +void zx_vou_layer_disable (struct drm_plane *plane, +struct drm_plane_state *old_state);#endif /* __ZX_VOU_H__ */
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.CHECKPATCH: warning for drm: Eliminate plane->fb/crtc usage for atomic drivers (rev5)
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm: Eliminate plane->fb/crtc usage for atomic drivers (rev5)
URL : https://patchwork.freedesktop.org/series/40478/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip eec2e4920fa9 Revert "drm/atomic-helper: Fix leak in disable_all" 885b9185b11c drm/atomic-helper: Make drm_atomic_helper_disable_all() update the plane->fb pointers -:93: CHECK:LINE_SPACING: Please use a blank line after function/struct/union/enum declarations #93: FILE: drivers/gpu/drm/drm_atomic_helper.c:2952: } +/**
total: 0 errors, 0 warnings, 1 checks, 98 lines checked565952128dd5 drm: Clear crtc->primary->crtc when disabling the crtc via setcrtc()9847962e92bf drm/atomic-helper: WARN if legacy plane fb pointers are bogus when committing duplicated state c82dc4275c43 drm: Add local 'plane' variable for primary/cursor planes
-:121: WARNING:AVOID_BUG: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() #121: FILE: drivers/gpu/drm/drm_plane.c:773:
+ BUG_ON(!plane);
-:122: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "plane->crtc" #122: FILE: drivers/gpu/drm/drm_plane.c:774:
+ WARN_ON(plane->crtc != crtc && plane->crtc != NULL);
-:171: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!plane->fb" #171: FILE: drivers/gpu/drm/drm_plane.c:1014:
+ if (plane->fb == NULL) {
total: 0 errors, 1 warnings, 2 checks, 186 lines checked 755974d48345 drm: Adjust whitespace for legibilityf3e2f2d38a43 drm: Make the fb refcount handover less magic 9fd23bc1fc50 drm: Use plane->state->fb over plane->fb
-:90: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!old_fb" #90: FILE: drivers/gpu/drm/drm_plane.c:1024:
+ if (old_fb == NULL) {
total: 0 errors, 0 warnings, 1 checks, 79 lines checked7fe441e1f443 drm/i915: Stop consulting plane->fbc63ecc6320ad drm/msm: Stop consulting plane->fb9aee2233a34a drm/sti: Stop consulting plane->fb260aa997ef90 drm/vmwgfx: Stop consulting plane->fb213b45d96872 drm/zte: Stop consulting plane->crtcab4d18f860a9 drm/atmel-hlcdc: Stop using plane->fb9295b76b993d drm: Stop updating plane->crtc/fb/old_fb on atomic drivers 98c28044ce49 drm/amdgpu/dc: Stop updating plane->fb9eb46f68d697 drm/i915: Stop updating plane->fb/crtcdd5198a96fab drm/exynos: Stop updating plane->crtc5c81f06359a0 drm/msm: Stop updating plane->fb/crtc7ea33fb4ffda drm/virtio: Stop updating plane->crtcaf0596d92fc4 drm/vc4: Stop updating plane->fb/crtcd8e5f287c232 drm/i915: Restore planes after load detection 5b47761e238f drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm: Eliminate plane->fb/crtc usage for atomic drivers (rev5)
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm: Eliminate plane->fb/crtc usage for atomic drivers (rev5)
URL : https://patchwork.freedesktop.org/series/40478/
State : success
== Summary ==
Series 40478v5 drm: Eliminate plane->fb/crtc usage for atomic drivers
https://patchwork.freedesktop.org/api/1.0/series/40478/revisions/5/mbox/
---- Known issues:
Test gem_mmap_gtt:
Subgroup basic-small-bo-tiledx:
pass -> FAIL (fi-gdg-551) fdo#102575
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-c:
incomplete -> PASS (fi-bxt-dsi) fdo#103927
incomplete -> PASS (fi-hsw-4770) fdo#104944fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
fdo#104944 https://bugs.freedesktop.org/show_bug.cgi?id=104944
fi-bdw-5557u total:285 pass:264 dwarn:0 dfail:0 fail:0 skip:21 time:433s fi-bdw-gvtdvm total:285 pass:261 dwarn:0 dfail:0 fail:0 skip:24 time:449s fi-blb-e6850 total:285 pass:220 dwarn:1 dfail:0 fail:0 skip:64 time:380s fi-bsw-n3050 total:285 pass:239 dwarn:0 dfail:0 fail:0 skip:46 time:537s fi-bwr-2160 total:285 pass:180 dwarn:0 dfail:0 fail:0 skip:105 time:298s fi-bxt-dsi total:285 pass:255 dwarn:0 dfail:0 fail:0 skip:30 time:511s fi-bxt-j4205 total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:514s fi-byt-j1900 total:285 pass:250 dwarn:0 dfail:0 fail:0 skip:35 time:519s fi-byt-n2820 total:285 pass:246 dwarn:0 dfail:0 fail:0 skip:39 time:507s fi-cfl-8700k total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:409s fi-cfl-u total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:512s fi-elk-e7500 total:285 pass:225 dwarn:1 dfail:0 fail:0 skip:59 time:428s fi-gdg-551 total:285 pass:176 dwarn:0 dfail:0 fail:1 skip:108 time:317s fi-glk-1 total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:535s fi-hsw-4770 total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:408s fi-ilk-650 total:285 pass:225 dwarn:0 dfail:0 fail:0 skip:60 time:425s fi-ivb-3520m total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:472s fi-ivb-3770 total:285 pass:252 dwarn:0 dfail:0 fail:0 skip:33 time:428s fi-kbl-7500u total:285 pass:260 dwarn:1 dfail:0 fail:0 skip:24 time:478s fi-kbl-7567u total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:468s fi-kbl-r total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:516s fi-pnv-d510 total:285 pass:219 dwarn:1 dfail:0 fail:0 skip:65 time:651s fi-skl-6260u total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:438s fi-skl-6600u total:285 pass:258 dwarn:0 dfail:0 fail:0 skip:27 time:532s fi-skl-6700k2 total:285 pass:261 dwarn:0 dfail:0 fail:0 skip:24 time:506s fi-skl-6770hq total:285 pass:265 dwarn:0 dfail:0 fail:0 skip:20 time:508s fi-skl-guc total:285 pass:257 dwarn:0 dfail:0 fail:0 skip:28 time:428s fi-skl-gvtdvm total:285 pass:262 dwarn:0 dfail:0 fail:0 skip:23 time:444s fi-snb-2520m total:285 pass:245 dwarn:0 dfail:0 fail:0 skip:40 time:584s fi-snb-2600 total:285 pass:245 dwarn:0 dfail:0 fail:0 skip:40 time:399s Blacklisted hosts: fi-cfl-s3 total:285 pass:259 dwarn:0 dfail:0 fail:0 skip:26 time:566s fi-cnl-psr total:224 pass:198 dwarn:0 dfail:0 fail:1 skip:24 fi-glk-j4005 total:285 pass:256 dwarn:0 dfail:0 fail:0 skip:29 time:484s
94f5d9189e61055e246c31106b3810dc17ddee9c drm-tip: 2018y-03m-23d-23h-41m-40s UTC integration manifest 5b47761e238f drm/i915: Make force_load_detect effective even w/ DMI quirks/hotplug d8e5f287c232 drm/i915: Restore planes after load detectionaf0596d92fc4 drm/vc4: Stop updating plane->fb/crtc7ea33fb4ffda drm/virtio: Stop updating plane->crtc5c81f06359a0 drm/msm: Stop updating plane->fb/crtcdd5198a96fab drm/exynos: Stop updating plane->crtc9eb46f68d697 drm/i915: Stop updating plane->fb/crtc98c28044ce49 drm/amdgpu/dc: Stop updating plane->fb9295b76b993d drm: Stop updating plane->crtc/fb/old_fb on atomic driversab4d18f860a9 drm/atmel-hlcdc: Stop using plane->fb213b45d96872 drm/zte: Stop consulting plane->crtc260aa997ef90 drm/vmwgfx: Stop consulting plane->fb9aee2233a34a drm/sti: Stop consulting plane->fbc63ecc6320ad drm/msm: Stop consulting plane->fb7fe441e1f443 drm/i915: Stop consulting plane->fb9fd23bc1fc50 drm: Use plane->state->fb over plane->fbf3e2f2d38a43 drm: Make the fb refcount handover less magic755974d48345 drm: Adjust whitespace for legibilityc82dc4275c43 drm: Add local 'plane' variable for primary/cursor planes9847962e92bf drm/atomic-helper: WARN if legacy plane fb pointers are bogus when committing duplicated state 565952128dd5 drm: Clear crtc->primary->crtc when disabling the crtc via setcrtc() 885b9185b11c drm/atomic-helper: Make drm_atomic_helper_disable_all() update the plane->fb pointers eec2e4920fa9 Revert "drm/atomic-helper: Fix leak in disable_all"
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8490/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for drm: Eliminate plane->fb/crtc usage for atomic drivers (rev5)
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm: Eliminate plane->fb/crtc usage for atomic drivers (rev5)
URL : https://patchwork.freedesktop.org/series/40478/
State : success
== Summary ==
---- Known issues:
Test kms_flip:
Subgroup 2x-dpms-vs-vblank-race:
fail -> PASS (shard-hsw) fdo#103060 +1
Subgroup 2x-flip-vs-expired-vblank-interruptible:
fail -> PASS (shard-hsw) fdo#102887
Subgroup plain-flip-ts-check:
pass -> FAIL (shard-hsw) fdo#100368 +1
Test kms_rotation_crc:
Subgroup sprite-rotation-180:
fail -> PASS (shard-snb) fdo#103925
Test kms_setmode:
Subgroup basic:
pass -> FAIL (shard-apl) fdo#99912
Test kms_vblank:
Subgroup pipe-a-accuracy-idle:
pass -> FAIL (shard-hsw) fdo#102583fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
fdo#102583 https://bugs.freedesktop.org/show_bug.cgi?id=102583
shard-apl total:3386 pass:1767 dwarn:1 dfail:0 fail:6 skip:1611 time:12568s shard-hsw total:3484 pass:1771 dwarn:1 dfail:0 fail:4 skip:1707 time:11784s shard-snb total:3484 pass:1363 dwarn:1 dfail:0 fail:3 skip:2117 time:7030s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8490/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 02/23] drm/atomic-helper: Make drm_atomic_helper_disable_all() update the plane->fb pointers
In reply to Ville SyrjalaQuoted 10 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
drm_atomic_helper_shutdown()needs to release the reference held byplane->fb, so we want to usedrm_atomic_clean_old_fb()indrm_atomic_helper_disable_all(). However during suspend/resume, gpu reset and load detection we should probably leave that stuff alone, as otherwise we'd have to make sure we put them back again when we restore the duplicated state to the device. Seems simpler to me to not touch any of it anyway.
Quoted 8 lines
v2: Don't inflict the
clean_old_fbsbool to drivers (Daniel)Cc Dave Airlie <[email protected]> (v1)Cc Maarten Lankhorst <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>
I think this would be cleaner diff to read if you squash the first 2 patches together. Also avoids the bisect fail. With that (and I trust you to come up with a suitably merged commit message):
I reviewed this by re-reading the analysis from 49d70aeaeca8f62b72b77 and trusting my former self :-)
Cheers, Daniel
Quoted 113 lines
--- drivers/gpu/drm/drm_atomic_helper.c | 67 ++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 27 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +40
-27@@ -2881,31 +2881,9 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set,return 0 ; } -/** -* drm_atomic_helper_disable_all - disable all currently active outputs -* @dev: DRM device -* @ctx: lock acquisition context -* -* Loops through all connectors, finding those that aren't turned off and then -* turns them off by setting their DPMS mode to OFF and deactivating the CRTC -* that they are connected to. -* -* This is used for example in suspend/resume to disable all currently active -* functions when suspending. If you just want to shut down everything at e.g. -* driver unload, look at drm_atomic_helper_shutdown(). -* -* Note that if callers haven't already acquired all modeset locks this might -* return -EDEADLK, which must be handled by calling drm_modeset_backoff(). -* -* Returns: -* 0 on success or a negative error code on failure. -* -* See also: -* drm_atomic_helper_suspend(), drm_atomic_helper_resume() and -* drm_atomic_helper_shutdown(). -*/ -int drm_atomic_helper_disable_all (struct drm_device *dev, -struct drm_modeset_acquire_ctx *ctx) +static int __drm_atomic_helper_disable_all (struct drm_device *dev, +struct drm_modeset_acquire_ctx *ctx, +bool clean_old_fbs) {struct drm_atomic_state *state;struct drm_connector_state *conn_state;@@ -2914,6 +2892,7 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,struct drm_plane *plane;struct drm_crtc_state *crtc_state;struct drm_crtc *crtc; +unsigned int plane_mask =0 ;int ret, i; state =drm_atomic_state_alloc (dev);@@ -2956,14 +2935,48 @@ int drm_atomic_helper_disable_all(struct drm_device *dev, goto free;drm_atomic_set_fb_for_plane (plane_state,NULL ); + +if (clean_old_fbs) { + plane->old_fb = plane->fb; + plane_mask |=BIT (drm_plane_index (plane)); + } } ret =drm_atomic_commit (state); free: +drm_atomic_clean_old_fb (dev, plane_mask, ret); +drm_atomic_state_put (state);return ret; } - +/** +* drm_atomic_helper_disable_all - disable all currently active outputs +* @dev: DRM device +* @ctx: lock acquisition context +* +* Loops through all connectors, finding those that aren't turned off and then +* turns them off by setting their DPMS mode to OFF and deactivating the CRTC +* that they are connected to. +* +* This is used for example in suspend/resume to disable all currently active +* functions when suspending. If you just want to shut down everything at e.g. +* driver unload, look at drm_atomic_helper_shutdown(). +* +* Note that if callers haven't already acquired all modeset locks this might +* return -EDEADLK, which must be handled by calling drm_modeset_backoff(). +* +* Returns: +* 0 on success or a negative error code on failure. +* +* See also: +* drm_atomic_helper_suspend(), drm_atomic_helper_resume() and +* drm_atomic_helper_shutdown(). +*/ +int drm_atomic_helper_disable_all (struct drm_device *dev, +struct drm_modeset_acquire_ctx *ctx) +{ +return __drm_atomic_helper_disable_all (dev, ctx, false); +}EXPORT_SYMBOL (drm_atomic_helper_disable_all);/** @@ -2986,7 +2999,7 @@ void drm_atomic_helper_shutdown(struct drm_device *dev)while (1 ) { ret =drm_modeset_lock_all_ctx (dev, &ctx);if (!ret) - ret =drm_atomic_helper_disable_all (dev, &ctx); + ret =__drm_atomic_helper_disable_all (dev, &ctx, true);if (ret != -EDEADLK )break ;Signature · 1 line
2.16.1
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: [PATCH 03/23] drm: Clear crtc->primary->crtc when disabling the crtc via setcrtc()
In reply to Ville SyrjalaQuoted 7 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Keep the
primary->crtcin sync with thestate->crtc(also withprimary->fbandstate->fb) when disabling the crtc (and thus also the primary) viasetcrtc().Signed-off-by Ville Syrjälä <[email protected]>
Yeah seems more consistent, and we do the same for atomic already. Only 2 legacy drivers seem to look at this (armada and shmob), and I think both should be fine.
Quoted 24 lines
--- drivers/gpu/drm/drm_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_crtc.c +1
-1@@ -471,7 +471,7 @@ static int __drm_mode_set_config_internal(struct drm_mode_set *set, ret = crtc->funcs->set_config (set, ctx);if (ret ==0 ) { - crtc->primary->crtc = crtc; + crtc->primary->crtc = fb ? crtc :NULL ; crtc->primary->fb = fb; }Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 04/23] drm/atomic-helper: WARN if legacy plane fb pointers are bogus when committing duplicated state
In reply to Ville SyrjalaQuoted 10 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
drm_atomic_helper_commit_duplicated_state()should only be called resume/reset/load_detect paths whereplane->old_fbshould always be NULL andplane->fbshould be equal to thenew_plane_state->fb. Assert that is indeed the case.
The (v1) here looks funny. dim add-missing-cc not working?
Quoted 12 lines
Cc Maarten Lankhorst <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_atomic_helper.c +0
-0
drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state, · line 3112
Quoted 8 lines
drivers/gpu/drm/drm_atomic_helper.c +4
-1@@ -3106,8 +3106,13 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state, state->acquire_ctx = ctx; -for_each_new_plane_in_state (state, plane, new_plane_state, i) +for_each_new_plane_in_state (state, plane, new_plane_state, i) { +WARN_ON (plane->crtc != new_plane_state->crtc); +WARN_ON (plane->fb != new_plane_state->fb); +WARN_ON (plane->old_fb);
Yeah I think with your rework of how this works this holds true now.
Quoted 13 lines
drivers/gpu/drm/drm_atomic_helper.c +2
-0+ state->planes[i].old_state = plane->state; + }for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) state->crtcs[i].old_state = crtc->state;Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
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: [PATCH 02/23] drm/atomic-helper: Make drm_atomic_helper_disable_all() update the plane->fb pointers
In reply to Ville SyrjalaQuoted 10 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
drm_atomic_helper_shutdown()needs to release the reference held byplane->fb, so we want to usedrm_atomic_clean_old_fb()indrm_atomic_helper_disable_all(). However during suspend/resume, gpu reset and load detection we should probably leave that stuff alone, as otherwise we'd have to make sure we put them back again when we restore the duplicated state to the device. Seems simpler to me to not touch any of it anyway.
Quoted 5 lines
v2: Don't inflict the
clean_old_fbsbool to drivers (Daniel)
More funny (v1) I just noticed ...
-Daniel
Quoted 116 lines
Cc Maarten Lankhorst <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 67 ++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 27 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +40
-27@@ -2881,31 +2881,9 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set,return 0 ; } -/** -* drm_atomic_helper_disable_all - disable all currently active outputs -* @dev: DRM device -* @ctx: lock acquisition context -* -* Loops through all connectors, finding those that aren't turned off and then -* turns them off by setting their DPMS mode to OFF and deactivating the CRTC -* that they are connected to. -* -* This is used for example in suspend/resume to disable all currently active -* functions when suspending. If you just want to shut down everything at e.g. -* driver unload, look at drm_atomic_helper_shutdown(). -* -* Note that if callers haven't already acquired all modeset locks this might -* return -EDEADLK, which must be handled by calling drm_modeset_backoff(). -* -* Returns: -* 0 on success or a negative error code on failure. -* -* See also: -* drm_atomic_helper_suspend(), drm_atomic_helper_resume() and -* drm_atomic_helper_shutdown(). -*/ -int drm_atomic_helper_disable_all (struct drm_device *dev, -struct drm_modeset_acquire_ctx *ctx) +static int __drm_atomic_helper_disable_all (struct drm_device *dev, +struct drm_modeset_acquire_ctx *ctx, +bool clean_old_fbs) {struct drm_atomic_state *state;struct drm_connector_state *conn_state;@@ -2914,6 +2892,7 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,struct drm_plane *plane;struct drm_crtc_state *crtc_state;struct drm_crtc *crtc; +unsigned int plane_mask =0 ;int ret, i; state =drm_atomic_state_alloc (dev);@@ -2956,14 +2935,48 @@ int drm_atomic_helper_disable_all(struct drm_device *dev, goto free;drm_atomic_set_fb_for_plane (plane_state,NULL ); + +if (clean_old_fbs) { + plane->old_fb = plane->fb; + plane_mask |=BIT (drm_plane_index (plane)); + } } ret =drm_atomic_commit (state); free: +drm_atomic_clean_old_fb (dev, plane_mask, ret); +drm_atomic_state_put (state);return ret; } - +/** +* drm_atomic_helper_disable_all - disable all currently active outputs +* @dev: DRM device +* @ctx: lock acquisition context +* +* Loops through all connectors, finding those that aren't turned off and then +* turns them off by setting their DPMS mode to OFF and deactivating the CRTC +* that they are connected to. +* +* This is used for example in suspend/resume to disable all currently active +* functions when suspending. If you just want to shut down everything at e.g. +* driver unload, look at drm_atomic_helper_shutdown(). +* +* Note that if callers haven't already acquired all modeset locks this might +* return -EDEADLK, which must be handled by calling drm_modeset_backoff(). +* +* Returns: +* 0 on success or a negative error code on failure. +* +* See also: +* drm_atomic_helper_suspend(), drm_atomic_helper_resume() and +* drm_atomic_helper_shutdown(). +*/ +int drm_atomic_helper_disable_all (struct drm_device *dev, +struct drm_modeset_acquire_ctx *ctx) +{ +return __drm_atomic_helper_disable_all (dev, ctx, false); +}EXPORT_SYMBOL (drm_atomic_helper_disable_all);/** @@ -2986,7 +2999,7 @@ void drm_atomic_helper_shutdown(struct drm_device *dev)while (1 ) { ret =drm_modeset_lock_all_ctx (dev, &ctx);if (!ret) - ret =drm_atomic_helper_disable_all (dev, &ctx); + ret =__drm_atomic_helper_disable_all (dev, &ctx, true);if (ret != -EDEADLK )break ;Signature · 1 line
2.16.1
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 05/23] drm: Add local 'plane' variable for primary/cursor planes
In reply to Ville Syrjaladrivers/gpu/drm/drm_crtc.c int drm_mode_setcrtc(struct drm_device *dev, void *data,
Quoted 66 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Make the code a bit more readable by storing the plane pointer in a local variable rather than having to do crtc->{primary,cursor} all the time.
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 32 +++++++++++++++++++------------- drivers/gpu/drm/drm_plane.c | 32 ++++++++++++++++++-------------- 2 files changed, 37 insertions(+), 27 deletions(-)drivers/gpu/drm/drm_crtc.c +13
-9@@ -402,6 +402,7 @@ int drm_mode_getcrtc(struct drm_device *dev, {struct drm_mode_crtc *crtc_resp = data;struct drm_crtc *crtc; +struct drm_plane *plane;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;@@ -410,21 +411,23 @@ int drm_mode_getcrtc(struct drm_device *dev,if (!crtc)return -ENOENT ; + plane = crtc->primary; + crtc_resp->gamma_size = crtc->gamma_size; -drm_modeset_lock (&crtc->primary->mutex,NULL ); -if (crtc->primary->state && crtc->primary->state->fb) - crtc_resp->fb_id = crtc->primary->state->fb->base.id; -else if (!crtc->primary->state && crtc->primary->fb) - crtc_resp->fb_id = crtc->primary->fb->base.id; +drm_modeset_lock (&plane->mutex,NULL ); +if (plane->state && plane->state->fb) + crtc_resp->fb_id = plane->state->fb->base.id; +else if (!plane->state && plane->fb) + crtc_resp->fb_id = plane->fb->base.id;else crtc_resp->fb_id =0 ; -if (crtc->primary->state) { - crtc_resp->x = crtc->primary->state->src_x >>16 ; - crtc_resp->y = crtc->primary->state->src_y >>16 ; +if (plane->state) { + crtc_resp->x = plane->state->src_x >>16 ; + crtc_resp->y = plane->state->src_y >>16 ; } -drm_modeset_unlock (&crtc->primary->mutex); +drm_modeset_unlock (&plane->mutex);drm_modeset_lock (&crtc->mutex,NULL );if (crtc->state) {@@ -554,6 +557,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,struct drm_mode_config *config = &dev->mode_config;struct drm_mode_crtc *crtc_req = data;struct drm_crtc *crtc; +struct drm_plane *plane;struct drm_connector **connector_set =NULL , *connector;struct drm_framebuffer *fb =NULL ;struct drm_display_mode *mode =NULL ;@@ -580,6 +584,8 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
Could do the same for setconfig_internal's tmp->primary, if you're bored.
Quoted 146 lines
drivers/gpu/drm/drm_crtc.c +6
-4}DRM_DEBUG_KMS ("[CRTC:%d:%s]\n" , crtc->base.id, crtc->name); + plane = crtc->primary; +mutex_lock (&crtc->dev->mode_config.mutex);drm_modeset_acquire_init (&ctx,DRM_MODESET_ACQUIRE_INTERRUPTIBLE ); retry:@@ -590,12 +596,12 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,/* If we have a mode we need a framebuffer. */ /* If we pass -1, set the mode with the currently bound fb */ if (crtc_req->fb_id ==-1 ) { -if (!crtc->primary->fb) { +if (!plane->fb) {DRM_DEBUG_KMS ("CRTC doesn't have current FB\n" ); ret = -EINVAL ; goto out; } - fb = crtc->primary->fb; + fb = plane->fb;/* Make refcounting symmetric with the lookup path. */ drm_framebuffer_get (fb); }else {@@ -627,8 +633,8 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,* match real hardware capabilities. Skip the check in that * case. */ -if (!crtc->primary->format_default) { - ret =drm_plane_check_pixel_format (crtc->primary, +if (!plane->format_default) { + ret =drm_plane_check_pixel_format (plane, fb->format->format, fb->modifier);if (ret) {drivers/gpu/drm/drm_plane.c +15
-11@@ -756,6 +756,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc, struct drm_modeset_acquire_ctx *ctx) {struct drm_device *dev = crtc->dev; +struct drm_plane *plane = crtc->cursor;struct drm_framebuffer *fb =NULL ;struct drm_mode_fb_cmd2 fbreq = { .width = req->width,@@ -769,8 +770,8 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,uint32_t src_w =0 , src_h =0 ;int ret =0 ; -BUG_ON (!crtc->cursor); -WARN_ON (crtc->cursor->crtc != crtc && crtc->cursor->crtc !=NULL ); +BUG_ON (!plane); +WARN_ON (plane->crtc != crtc && plane->crtc !=NULL );/* * Obtain fb we'll be using (either new or existing) and take an extra @@ -790,7 +791,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc, fb =NULL ; } }else { - fb = crtc->cursor->fb; + fb = plane->fb;if (fb)drm_framebuffer_get (fb); }@@ -810,7 +811,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc, src_h = fb->height <<16 ; } - ret =__setplane_internal (crtc->cursor, crtc, fb, + ret =__setplane_internal (plane, crtc, fb, crtc_x, crtc_y, crtc_w, crtc_h,0 ,0 , src_w, src_h, ctx);@@ -931,6 +932,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, {struct drm_mode_crtc_page_flip_target *page_flip = data;struct drm_crtc *crtc; +struct drm_plane *plane;struct drm_framebuffer *fb =NULL ;struct drm_pending_vblank_event *e =NULL ;u32 target_vblank = page_flip->sequence;@@ -959,6 +961,8 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,if (!crtc)return -ENOENT ; + plane = crtc->primary; +if (crtc->funcs->page_flip_target) {u32 current_vblank;int r;@@ -1003,11 +1007,11 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, ret =drm_modeset_lock (&crtc->mutex, &ctx);if (ret) goto out; - ret =drm_modeset_lock (&crtc->primary->mutex, &ctx); + ret =drm_modeset_lock (&plane->mutex, &ctx);if (ret) goto out; -if (crtc->primary->fb ==NULL ) { +if (plane->fb ==NULL ) {/* The framebuffer is currently unbound, presumably * due to a hotplug event, that userspace has not * yet discovered. @@ -1023,7 +1027,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, }if (crtc->state) { -const struct drm_plane_state *state = crtc->primary->state; +const struct drm_plane_state *state = plane->state; ret = drm_framebuffer_check_src_coords(state->src_x, state->src_y,@@ -1036,7 +1040,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,if (ret) goto out; -if (crtc->primary->fb->format != fb->format) { +if (plane->fb->format != fb->format) {DRM_DEBUG_KMS ("Page flip is not allowed to change frame buffer format.\n" ); ret = -EINVAL ; goto out;@@ -1060,7 +1064,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, } } - crtc->primary->old_fb = crtc->primary->fb; + plane->old_fb = plane->fb;if (crtc->funcs->page_flip_target) ret = crtc->funcs->page_flip_target(crtc, fb, e, page_flip->flags,@@ -1073,9 +1077,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,if (page_flip->flags &DRM_MODE_PAGE_FLIP_EVENT )drm_event_cancel_free (dev, &e->base);/* Keep the old fb, don't unref it. */ - crtc->primary->old_fb =NULL ; + plane->old_fb =NULL ; }else { - crtc->primary->fb = fb; + plane->fb = fb;/* Unref only the old framebuffer. */ fb =NULL ; }
drivers/gpu/drm/drm_plane.c int drm_mode_page_flip_ioctl(struct drm_device *dev, · line 1093
Quoted 10 lines
drivers/gpu/drm/drm_plane.c +3
-3@@ -1083,9 +1087,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, out:if (fb)drm_framebuffer_put (fb); -if (crtc->primary->old_fb) -drm_framebuffer_put (crtc->primary->old_fb); - crtc->primary->old_fb =NULL ; +if (plane->old_fb) +drm_framebuffer_put (plane->old_fb); + plane->old_fb =NULL ;
Quoted 9 lines
drivers/gpu/drm/drm_plane.c +0
-0if (ret == -EDEADLK ) { ret =drm_modeset_backoff (&ctx);Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
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: [PATCH 06/23] drm: Adjust whitespace for legibility
In reply to Ville SyrjalaQuoted 6 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Add a bit of whitespace here and there to make the code look a bit more structured.
Signed-off-by Ville Syrjälä <[email protected]>
Too lazy to grow a real opinion on whitespace :-)
Quoted 82 lines
--- drivers/gpu/drm/drm_crtc.c | 4 +++- drivers/gpu/drm/drm_plane.c | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_crtc.c +3
-1@@ -434,13 +434,13 @@ int drm_mode_getcrtc(struct drm_device *dev,if (crtc->state->enable) {drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->state->mode); crtc_resp->mode_valid =1 ; - }else { crtc_resp->mode_valid =0 ; } }else { crtc_resp->x = crtc->x; crtc_resp->y = crtc->y; +if (crtc->enabled) {drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid =1 ;@@ -592,6 +592,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, ret =drm_modeset_lock_all_ctx (crtc->dev, &ctx);if (ret) goto out; +if (crtc_req->mode_valid) {/* If we have a mode we need a framebuffer. */ /* If we pass -1, set the mode with the currently bound fb */ @@ -601,6 +602,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, ret = -EINVAL ; goto out; } + fb = plane->fb;/* Make refcounting symmetric with the lookup path. */ drm_framebuffer_get (fb);drivers/gpu/drm/drm_plane.c +5
-1@@ -785,6 +785,7 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,DRM_DEBUG_KMS ("failed to wrap cursor buffer in drm framebuffer\n" );return PTR_ERR (fb); } + fb->hot_x = req->hot_x; fb->hot_y = req->hot_y; }else {@@ -1035,7 +1036,8 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, state->src_h, fb); }else { - ret =drm_crtc_check_viewport (crtc, crtc->x, crtc->y, &crtc->mode, fb); + ret =drm_crtc_check_viewport (crtc, crtc->x, crtc->y, + &crtc->mode, fb); }if (ret) goto out;@@ -1052,10 +1054,12 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, ret = -ENOMEM ; goto out; } + e->event.base.type =DRM_EVENT_FLIP_COMPLETE ; e->event.base.length =sizeof (e->event); e->event.vbl.user_data = page_flip->user_data; e->event.vbl.crtc_id = crtc->base.id; + ret =drm_event_reserve_init (dev, file_priv, &e->base, &e->event.base);if (ret) {kfree (e);Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 15/23] drm: Stop updating plane->crtc/fb/old_fb on atomic drivers
In reply to Ville SyrjalaQuoted 25 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Stop playing around with plane->crtc/fb/old_fb with atomic drivers. Make life a lot simpler when we don't have to do the magic
old_fbvs. fb dance around plane updates. That way we can't riskplane->fbgetting out of sync withplane->state->fband we're less likely to leak any refcounts as well.Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_atomic.c | 55 ++++--------------------------------- drivers/gpu/drm/drm_atomic_helper.c | 15 +--------- drivers/gpu/drm/drm_crtc.c | 8 ++++-- drivers/gpu/drm/drm_fb_helper.c | 7 ----- drivers/gpu/drm/drm_framebuffer.c | 5 ---- drivers/gpu/drm/drm_plane.c | 14 ++++++---- drivers/gpu/drm/drm_plane_helper.c | 4 ++- include/drm/drm_atomic.h | 3 -- 8 files changed, 24 insertions(+), 87 deletions(-)drivers/gpu/drm/drm_atomic.c +0
-0
drivers/gpu/drm/drm_atomic.c drm_atomic_get_plane_state(struct drm_atomic_state *state, · line 698
Quoted 7 lines
drivers/gpu/drm/drm_atomic.c +4
-0@@ -692,6 +692,11 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,WARN_ON (!state->acquire_ctx); +/* the legacy pointers should never be set */ +WARN_ON (plane->fb); +WARN_ON (plane->old_fb); +WARN_ON (plane->crtc);
I did already review all the users for plane->crtc and found:
armada + shmob: not atomic, should be fine
But there's also exynos, msm/mdp5, sti and vc4 doing various silly things with setting plane->crtc. I think before you can add this WARN_ON we need to clean up that cruft (it looks like 100% cargo culting, so should be quit).
Going to think about the other patches tomorrow.
-Daniel
Quoted 292 lines
drivers/gpu/drm/drm_atomic.c +1
-50+ plane_state =drm_atomic_get_existing_plane_state (state, plane);if (plane_state)return plane_state;@@ -2021,45 +2026,6 @@ int drm_atomic_set_property(struct drm_atomic_state *state,return ret; } -/** -* drm_atomic_clean_old_fb -- Unset old_fb pointers and set plane->fb pointers. -* -* @dev: drm device to check. -* @plane_mask: plane mask for planes that were updated. -* @ret: return value, can be -EDEADLK for a retry. -* -* Before doing an update &drm_plane.old_fb is set to &drm_plane.fb, but before -* dropping the locks old_fb needs to be set to NULL and plane->fb updated. This -* is a common operation for each atomic update, so this call is split off as a -* helper. -*/ -void drm_atomic_clean_old_fb (struct drm_device *dev, -unsigned plane_mask, -int ret) -{ -struct drm_plane *plane; - -/* if succeeded, fixup legacy plane crtc/fb ptrs before dropping -* locks (ie. while it is still safe to deref plane->state). We -* need to do this here because the driver entry points cannot -* distinguish between legacy and atomic ioctls. -*/ -drm_for_each_plane_mask (plane, dev, plane_mask) { -if (ret ==0 ) { -struct drm_framebuffer *new_fb = plane->state->fb; -if (new_fb) -drm_framebuffer_get (new_fb); - plane->fb = new_fb; - plane->crtc = plane->state->crtc; - -if (plane->old_fb) -drm_framebuffer_put (plane->old_fb); - } - plane->old_fb =NULL ; - } -} -EXPORT_SYMBOL (drm_atomic_clean_old_fb); -/** * DOC: explicit fencing properties * @@ -2280,9 +2246,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,unsigned int copied_objs, copied_props;struct drm_atomic_state *state;struct drm_modeset_acquire_ctx ctx; -struct drm_plane *plane;struct drm_out_fence_state *fence_state; -unsigned plane_mask;int ret =0 ;unsigned int i, j, num_fences;@@ -2322,7 +2286,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, state->allow_modeset = !!(arg->flags &DRM_MODE_ATOMIC_ALLOW_MODESET ); retry: - plane_mask =0 ; copied_objs =0 ; copied_props =0 ; fence_state =NULL ;@@ -2393,12 +2356,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, copied_props++; } -if (obj->type ==DRM_MODE_OBJECT_PLANE && count_props && - !(arg->flags &DRM_MODE_ATOMIC_TEST_ONLY )) { - plane =obj_to_plane (obj); - plane_mask |= (1 <<drm_plane_index (plane)); - plane->old_fb = plane->fb; - }drm_mode_object_put (obj); }@@ -2419,8 +2376,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, } out: -drm_atomic_clean_old_fb (dev, plane_mask, ret); -complete_crtc_signaling (dev, state, fence_state, num_fences, !ret);if (ret == -EDEADLK ) {drivers/gpu/drm/drm_atomic_helper.c +1
-14@@ -2892,7 +2892,6 @@ static int __drm_atomic_helper_disable_all(struct drm_device *dev,struct drm_plane *plane;struct drm_crtc_state *crtc_state;struct drm_crtc *crtc; -unsigned int plane_mask =0 ;int ret, i; state =drm_atomic_state_alloc (dev);@@ -2935,17 +2934,10 @@ static int __drm_atomic_helper_disable_all(struct drm_device *dev, goto free;drm_atomic_set_fb_for_plane (plane_state,NULL ); - -if (clean_old_fbs) { - plane->old_fb = plane->fb; - plane_mask |=BIT (drm_plane_index (plane)); - } } ret =drm_atomic_commit (state); free: -drm_atomic_clean_old_fb (dev, plane_mask, ret); -drm_atomic_state_put (state);return ret; }@@ -3106,13 +3098,8 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state, state->acquire_ctx = ctx; -for_each_new_plane_in_state (state, plane, new_plane_state, i) { -WARN_ON (plane->crtc != new_plane_state->crtc); -WARN_ON (plane->fb != new_plane_state->fb); -WARN_ON (plane->old_fb); - +for_each_new_plane_in_state (state, plane, new_plane_state, i) state->planes[i].old_state = plane->state; - }for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) state->crtcs[i].old_state = crtc->state;drivers/gpu/drm/drm_crtc.c +6
-2@@ -474,8 +474,12 @@ static int __drm_mode_set_config_internal(struct drm_mode_set *set, ret = crtc->funcs->set_config (set, ctx);if (ret ==0 ) { - crtc->primary->crtc = fb ? crtc :NULL ; - crtc->primary->fb = fb; +struct drm_plane *plane = crtc->primary; + +if (!plane->state) { + plane->crtc = fb ? crtc :NULL ; + plane->fb = fb; + } }drm_for_each_crtc (tmp, crtc->dev) {drivers/gpu/drm/drm_fb_helper.c +0
-7@@ -368,7 +368,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activstruct drm_plane *plane;struct drm_atomic_state *state;int i, ret; -unsigned int plane_mask;struct drm_modeset_acquire_ctx ctx;drm_modeset_acquire_init (&ctx,0 );@@ -381,7 +380,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ state->acquire_ctx = &ctx; retry: - plane_mask =0 ;drm_for_each_plane (plane, dev) { plane_state =drm_atomic_get_plane_state (state, plane);if (IS_ERR (plane_state)) {@@ -391,9 +389,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ plane_state->rotation =DRM_MODE_ROTATE_0 ; - plane->old_fb = plane->fb; - plane_mask |=1 <<drm_plane_index (plane); -/* disable non-primary: */ if (plane->type ==DRM_PLANE_TYPE_PRIMARY )continue ;@@ -430,8 +425,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ ret =drm_atomic_commit (state); out_state: -drm_atomic_clean_old_fb (dev, plane_mask, ret); -if (ret == -EDEADLK ) goto backoff;drivers/gpu/drm/drm_framebuffer.c +0
-5@@ -835,8 +835,6 @@ static int atomic_remove_fb(struct drm_framebuffer *fb) goto unlock; plane_mask |=BIT (drm_plane_index (plane)); - - plane->old_fb = plane->fb; }/* This list is only filled when disable_crtcs is set. */ @@ -851,9 +849,6 @@ static int atomic_remove_fb(struct drm_framebuffer *fb) ret =drm_atomic_commit (state); unlock: -if (plane_mask) -drm_atomic_clean_old_fb (dev, plane_mask, ret); -if (ret == -EDEADLK ) {drm_atomic_state_clear (state);drm_modeset_backoff (&ctx);drivers/gpu/drm/drm_plane.c +9
-5@@ -650,9 +650,11 @@ static int __setplane_internal(struct drm_plane *plane, crtc_x, crtc_y, crtc_w, crtc_h, src_x, src_y, src_w, src_h, ctx);if (!ret) { - plane->crtc = crtc; - plane->fb = fb; -drm_framebuffer_get (plane->fb); +if (!plane->state) { + plane->crtc = crtc; + plane->fb = fb; +drm_framebuffer_get (plane->fb); + } }else { plane->old_fb =NULL ; }@@ -1092,8 +1094,10 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,/* Keep the old fb, don't unref it. */ plane->old_fb =NULL ; }else { - plane->fb = fb; -drm_framebuffer_get (fb); +if (!plane->state) { + plane->fb = fb; +drm_framebuffer_get (fb); + } } out:drivers/gpu/drm/drm_plane_helper.c +3
-1@@ -502,6 +502,7 @@ EXPORT_SYMBOL(drm_plane_helper_update);int drm_plane_helper_disable (struct drm_plane *plane) {struct drm_plane_state *plane_state; +struct drm_framebuffer *old_fb;/* crtc helpers love to call disable functions for already disabled hw * functions. So cope with that. */ @@ -521,8 +522,9 @@ int drm_plane_helper_disable(struct drm_plane *plane) plane_state->plane = plane; plane_state->crtc =NULL ; + old_fb = plane_state->fb;drm_atomic_set_fb_for_plane (plane_state,NULL ); -return drm_plane_helper_commit (plane, plane_state, plane->fb); +return drm_plane_helper_commit (plane, plane_state, old_fb); }EXPORT_SYMBOL (drm_plane_helper_disable);include/drm/drm_atomic.h +0
-3@@ -601,9 +601,6 @@ int __must_check drm_atomic_add_affected_planes(struct drm_atomic_state *state, struct drm_crtc *crtc); -void -drm_atomic_clean_old_fb (struct drm_device *dev,unsigned plane_mask,int ret); -int __must_check drm_atomic_check_only (struct drm_atomic_state *state);int __must_check drm_atomic_commit (struct drm_atomic_state *state);int __must_check drm_atomic_nonblocking_commit (struct drm_atomic_state *state);Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 15/23] drm: Stop updating plane->crtc/fb/old_fb on atomic drivers
Quoted 36 lines · Daniel Vetter
Quoted 25 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Stop playing around with plane->crtc/fb/old_fb with atomic drivers. Make life a lot simpler when we don't have to do the magic
old_fbvs. fb dance around plane updates. That way we can't riskplane->fbgetting out of sync withplane->state->fband we're less likely to leak any refcounts as well.Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_atomic.c | 55 ++++--------------------------------- drivers/gpu/drm/drm_atomic_helper.c | 15 +--------- drivers/gpu/drm/drm_crtc.c | 8 ++++-- drivers/gpu/drm/drm_fb_helper.c | 7 ----- drivers/gpu/drm/drm_framebuffer.c | 5 ---- drivers/gpu/drm/drm_plane.c | 14 ++++++---- drivers/gpu/drm/drm_plane_helper.c | 4 ++- include/drm/drm_atomic.h | 3 -- 8 files changed, 24 insertions(+), 87 deletions(-)drivers/gpu/drm/drm_atomic.c +0
-0drivers/gpu/drm/drm_atomic.c drm_atomic_get_plane_state(struct drm_atomic_state *state, · line 698
Quoted 7 lines
drivers/gpu/drm/drm_atomic.c +4
-0@@ -692,6 +692,11 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,WARN_ON (!state->acquire_ctx); +/* the legacy pointers should never be set */ +WARN_ON (plane->fb); +WARN_ON (plane->old_fb); +WARN_ON (plane->crtc);I did already review all the users for
plane->crtcand found:
Quoted 6 lines
armada + shmob: not atomic, should be fine
But there's also exynos, msm/mdp5, sti and vc4 doing various silly things with setting
plane->crtc. I think before you can add thisWARN_ONwe need to clean up that cruft (it looks like 100% cargo culting, so should be quit).
Ah, follow-up patches take care of most of this. But note that msm sets plane->crtc in its _init function, so will trip over your WARN_ON here.
And you seem to have missed sti, which looks at plane->crtc instead of plane->state->crtc (and appropriate locking) in its debugfs code. -Daniel
Quoted 301 lines
Going to think about the other patches tomorrow.
-DanielQuoted 292 lines
drivers/gpu/drm/drm_atomic.c +1
-50+ plane_state =drm_atomic_get_existing_plane_state (state, plane);if (plane_state)return plane_state;@@ -2021,45 +2026,6 @@ int drm_atomic_set_property(struct drm_atomic_state *state,return ret; } -/** -* drm_atomic_clean_old_fb -- Unset old_fb pointers and set plane->fb pointers. -* -* @dev: drm device to check. -* @plane_mask: plane mask for planes that were updated. -* @ret: return value, can be -EDEADLK for a retry. -* -* Before doing an update &drm_plane.old_fb is set to &drm_plane.fb, but before -* dropping the locks old_fb needs to be set to NULL and plane->fb updated. This -* is a common operation for each atomic update, so this call is split off as a -* helper. -*/ -void drm_atomic_clean_old_fb (struct drm_device *dev, -unsigned plane_mask, -int ret) -{ -struct drm_plane *plane; - -/* if succeeded, fixup legacy plane crtc/fb ptrs before dropping -* locks (ie. while it is still safe to deref plane->state). We -* need to do this here because the driver entry points cannot -* distinguish between legacy and atomic ioctls. -*/ -drm_for_each_plane_mask (plane, dev, plane_mask) { -if (ret ==0 ) { -struct drm_framebuffer *new_fb = plane->state->fb; -if (new_fb) -drm_framebuffer_get (new_fb); - plane->fb = new_fb; - plane->crtc = plane->state->crtc; - -if (plane->old_fb) -drm_framebuffer_put (plane->old_fb); - } - plane->old_fb =NULL ; - } -} -EXPORT_SYMBOL (drm_atomic_clean_old_fb); -/** * DOC: explicit fencing properties * @@ -2280,9 +2246,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,unsigned int copied_objs, copied_props;struct drm_atomic_state *state;struct drm_modeset_acquire_ctx ctx; -struct drm_plane *plane;struct drm_out_fence_state *fence_state; -unsigned plane_mask;int ret =0 ;unsigned int i, j, num_fences;@@ -2322,7 +2286,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, state->allow_modeset = !!(arg->flags &DRM_MODE_ATOMIC_ALLOW_MODESET ); retry: - plane_mask =0 ; copied_objs =0 ; copied_props =0 ; fence_state =NULL ;@@ -2393,12 +2356,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, copied_props++; } -if (obj->type ==DRM_MODE_OBJECT_PLANE && count_props && - !(arg->flags &DRM_MODE_ATOMIC_TEST_ONLY )) { - plane =obj_to_plane (obj); - plane_mask |= (1 <<drm_plane_index (plane)); - plane->old_fb = plane->fb; - }drm_mode_object_put (obj); }@@ -2419,8 +2376,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, } out: -drm_atomic_clean_old_fb (dev, plane_mask, ret); -complete_crtc_signaling (dev, state, fence_state, num_fences, !ret);if (ret == -EDEADLK ) {drivers/gpu/drm/drm_atomic_helper.c +1
-14@@ -2892,7 +2892,6 @@ static int __drm_atomic_helper_disable_all(struct drm_device *dev,struct drm_plane *plane;struct drm_crtc_state *crtc_state;struct drm_crtc *crtc; -unsigned int plane_mask =0 ;int ret, i; state =drm_atomic_state_alloc (dev);@@ -2935,17 +2934,10 @@ static int __drm_atomic_helper_disable_all(struct drm_device *dev, goto free;drm_atomic_set_fb_for_plane (plane_state,NULL ); - -if (clean_old_fbs) { - plane->old_fb = plane->fb; - plane_mask |=BIT (drm_plane_index (plane)); - } } ret =drm_atomic_commit (state); free: -drm_atomic_clean_old_fb (dev, plane_mask, ret); -drm_atomic_state_put (state);return ret; }@@ -3106,13 +3098,8 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state, state->acquire_ctx = ctx; -for_each_new_plane_in_state (state, plane, new_plane_state, i) { -WARN_ON (plane->crtc != new_plane_state->crtc); -WARN_ON (plane->fb != new_plane_state->fb); -WARN_ON (plane->old_fb); - +for_each_new_plane_in_state (state, plane, new_plane_state, i) state->planes[i].old_state = plane->state; - }for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) state->crtcs[i].old_state = crtc->state;drivers/gpu/drm/drm_crtc.c +6
-2@@ -474,8 +474,12 @@ static int __drm_mode_set_config_internal(struct drm_mode_set *set, ret = crtc->funcs->set_config (set, ctx);if (ret ==0 ) { - crtc->primary->crtc = fb ? crtc :NULL ; - crtc->primary->fb = fb; +struct drm_plane *plane = crtc->primary; + +if (!plane->state) { + plane->crtc = fb ? crtc :NULL ; + plane->fb = fb; + } }drm_for_each_crtc (tmp, crtc->dev) {drivers/gpu/drm/drm_fb_helper.c +0
-7@@ -368,7 +368,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activstruct drm_plane *plane;struct drm_atomic_state *state;int i, ret; -unsigned int plane_mask;struct drm_modeset_acquire_ctx ctx;drm_modeset_acquire_init (&ctx,0 );@@ -381,7 +380,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ state->acquire_ctx = &ctx; retry: - plane_mask =0 ;drm_for_each_plane (plane, dev) { plane_state =drm_atomic_get_plane_state (state, plane);if (IS_ERR (plane_state)) {@@ -391,9 +389,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ plane_state->rotation =DRM_MODE_ROTATE_0 ; - plane->old_fb = plane->fb; - plane_mask |=1 <<drm_plane_index (plane); -/* disable non-primary: */ if (plane->type ==DRM_PLANE_TYPE_PRIMARY )continue ;@@ -430,8 +425,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ ret =drm_atomic_commit (state); out_state: -drm_atomic_clean_old_fb (dev, plane_mask, ret); -if (ret == -EDEADLK ) goto backoff;drivers/gpu/drm/drm_framebuffer.c +0
-5@@ -835,8 +835,6 @@ static int atomic_remove_fb(struct drm_framebuffer *fb) goto unlock; plane_mask |=BIT (drm_plane_index (plane)); - - plane->old_fb = plane->fb; }/* This list is only filled when disable_crtcs is set. */ @@ -851,9 +849,6 @@ static int atomic_remove_fb(struct drm_framebuffer *fb) ret =drm_atomic_commit (state); unlock: -if (plane_mask) -drm_atomic_clean_old_fb (dev, plane_mask, ret); -if (ret == -EDEADLK ) {drm_atomic_state_clear (state);drm_modeset_backoff (&ctx);drivers/gpu/drm/drm_plane.c +9
-5@@ -650,9 +650,11 @@ static int __setplane_internal(struct drm_plane *plane, crtc_x, crtc_y, crtc_w, crtc_h, src_x, src_y, src_w, src_h, ctx);if (!ret) { - plane->crtc = crtc; - plane->fb = fb; -drm_framebuffer_get (plane->fb); +if (!plane->state) { + plane->crtc = crtc; + plane->fb = fb; +drm_framebuffer_get (plane->fb); + } }else { plane->old_fb =NULL ; }@@ -1092,8 +1094,10 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,/* Keep the old fb, don't unref it. */ plane->old_fb =NULL ; }else { - plane->fb = fb; -drm_framebuffer_get (fb); +if (!plane->state) { + plane->fb = fb; +drm_framebuffer_get (fb); + } } out:drivers/gpu/drm/drm_plane_helper.c +3
-1@@ -502,6 +502,7 @@ EXPORT_SYMBOL(drm_plane_helper_update);int drm_plane_helper_disable (struct drm_plane *plane) {struct drm_plane_state *plane_state; +struct drm_framebuffer *old_fb;/* crtc helpers love to call disable functions for already disabled hw * functions. So cope with that. */ @@ -521,8 +522,9 @@ int drm_plane_helper_disable(struct drm_plane *plane) plane_state->plane = plane; plane_state->crtc =NULL ; + old_fb = plane_state->fb;drm_atomic_set_fb_for_plane (plane_state,NULL ); -return drm_plane_helper_commit (plane, plane_state, plane->fb); +return drm_plane_helper_commit (plane, plane_state, old_fb); }EXPORT_SYMBOL (drm_plane_helper_disable);include/drm/drm_atomic.h +0
-3@@ -601,9 +601,6 @@ int __must_check drm_atomic_add_affected_planes(struct drm_atomic_state *state, struct drm_crtc *crtc); -void -drm_atomic_clean_old_fb (struct drm_device *dev,unsigned plane_mask,int ret); -int __must_check drm_atomic_check_only (struct drm_atomic_state *state);int __must_check drm_atomic_commit (struct drm_atomic_state *state);int __must_check drm_atomic_nonblocking_commit (struct drm_atomic_state *state);Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
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: [PATCH 07/23] drm: Make the fb refcount handover less magic
In reply to Ville SyrjalaQuoted 7 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Instead of assigning the
plane->fbpointer and clearing the fb pointer to hand over the reference, let's just do it by grabbing another referece forplane->fband let fb keep its original one.Signed-off-by Ville Syrjälä <[email protected]>
Quoted 25 lines
--- drivers/gpu/drm/drm_plane.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/drm_plane.c +1
-2@@ -1084,8 +1084,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, plane->old_fb =NULL ; }else { plane->fb = fb; -/* Unref only the old framebuffer. */ - fb =NULL ; +drm_framebuffer_get (fb); } out:Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 15/23] drm: Stop updating plane->crtc/fb/old_fb on atomic drivers
In reply to Ville SyrjalaQuoted 9 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Stop playing around with plane->crtc/fb/old_fb with atomic drivers. Make life a lot simpler when we don't have to do the magic
old_fbvs. fb dance around plane updates. That way we can't riskplane->fbgetting out of sync withplane->state->fband we're less likely to leak any refcounts as well.Signed-off-by Ville Syrjälä <[email protected]>
What's the reason for this patch being in the middle of the patch series? I figured it's savest if we put this at the end? If you need parts of this here, we definitely need to split out the WARN_ON hunk, since you haven't fixed up everything yet at this point here.
-Daniel
Quoted 315 lines
--- drivers/gpu/drm/drm_atomic.c | 55 ++++--------------------------------- drivers/gpu/drm/drm_atomic_helper.c | 15 +--------- drivers/gpu/drm/drm_crtc.c | 8 ++++-- drivers/gpu/drm/drm_fb_helper.c | 7 ----- drivers/gpu/drm/drm_framebuffer.c | 5 ---- drivers/gpu/drm/drm_plane.c | 14 ++++++---- drivers/gpu/drm/drm_plane_helper.c | 4 ++- include/drm/drm_atomic.h | 3 -- 8 files changed, 24 insertions(+), 87 deletions(-)drivers/gpu/drm/drm_atomic.c +5
-50@@ -692,6 +692,11 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,WARN_ON (!state->acquire_ctx); +/* the legacy pointers should never be set */ +WARN_ON (plane->fb); +WARN_ON (plane->old_fb); +WARN_ON (plane->crtc); + plane_state =drm_atomic_get_existing_plane_state (state, plane);if (plane_state)return plane_state;@@ -2021,45 +2026,6 @@ int drm_atomic_set_property(struct drm_atomic_state *state,return ret; } -/** -* drm_atomic_clean_old_fb -- Unset old_fb pointers and set plane->fb pointers. -* -* @dev: drm device to check. -* @plane_mask: plane mask for planes that were updated. -* @ret: return value, can be -EDEADLK for a retry. -* -* Before doing an update &drm_plane.old_fb is set to &drm_plane.fb, but before -* dropping the locks old_fb needs to be set to NULL and plane->fb updated. This -* is a common operation for each atomic update, so this call is split off as a -* helper. -*/ -void drm_atomic_clean_old_fb (struct drm_device *dev, -unsigned plane_mask, -int ret) -{ -struct drm_plane *plane; - -/* if succeeded, fixup legacy plane crtc/fb ptrs before dropping -* locks (ie. while it is still safe to deref plane->state). We -* need to do this here because the driver entry points cannot -* distinguish between legacy and atomic ioctls. -*/ -drm_for_each_plane_mask (plane, dev, plane_mask) { -if (ret ==0 ) { -struct drm_framebuffer *new_fb = plane->state->fb; -if (new_fb) -drm_framebuffer_get (new_fb); - plane->fb = new_fb; - plane->crtc = plane->state->crtc; - -if (plane->old_fb) -drm_framebuffer_put (plane->old_fb); - } - plane->old_fb =NULL ; - } -} -EXPORT_SYMBOL (drm_atomic_clean_old_fb); -/** * DOC: explicit fencing properties * @@ -2280,9 +2246,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,unsigned int copied_objs, copied_props;struct drm_atomic_state *state;struct drm_modeset_acquire_ctx ctx; -struct drm_plane *plane;struct drm_out_fence_state *fence_state; -unsigned plane_mask;int ret =0 ;unsigned int i, j, num_fences;@@ -2322,7 +2286,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, state->allow_modeset = !!(arg->flags &DRM_MODE_ATOMIC_ALLOW_MODESET ); retry: - plane_mask =0 ; copied_objs =0 ; copied_props =0 ; fence_state =NULL ;@@ -2393,12 +2356,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, copied_props++; } -if (obj->type ==DRM_MODE_OBJECT_PLANE && count_props && - !(arg->flags &DRM_MODE_ATOMIC_TEST_ONLY )) { - plane =obj_to_plane (obj); - plane_mask |= (1 <<drm_plane_index (plane)); - plane->old_fb = plane->fb; - }drm_mode_object_put (obj); }@@ -2419,8 +2376,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, } out: -drm_atomic_clean_old_fb (dev, plane_mask, ret); -complete_crtc_signaling (dev, state, fence_state, num_fences, !ret);if (ret == -EDEADLK ) {drivers/gpu/drm/drm_atomic_helper.c +1
-14@@ -2892,7 +2892,6 @@ static int __drm_atomic_helper_disable_all(struct drm_device *dev,struct drm_plane *plane;struct drm_crtc_state *crtc_state;struct drm_crtc *crtc; -unsigned int plane_mask =0 ;int ret, i; state =drm_atomic_state_alloc (dev);@@ -2935,17 +2934,10 @@ static int __drm_atomic_helper_disable_all(struct drm_device *dev, goto free;drm_atomic_set_fb_for_plane (plane_state,NULL ); - -if (clean_old_fbs) { - plane->old_fb = plane->fb; - plane_mask |=BIT (drm_plane_index (plane)); - } } ret =drm_atomic_commit (state); free: -drm_atomic_clean_old_fb (dev, plane_mask, ret); -drm_atomic_state_put (state);return ret; }@@ -3106,13 +3098,8 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state, state->acquire_ctx = ctx; -for_each_new_plane_in_state (state, plane, new_plane_state, i) { -WARN_ON (plane->crtc != new_plane_state->crtc); -WARN_ON (plane->fb != new_plane_state->fb); -WARN_ON (plane->old_fb); - +for_each_new_plane_in_state (state, plane, new_plane_state, i) state->planes[i].old_state = plane->state; - }for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) state->crtcs[i].old_state = crtc->state;drivers/gpu/drm/drm_crtc.c +6
-2@@ -474,8 +474,12 @@ static int __drm_mode_set_config_internal(struct drm_mode_set *set, ret = crtc->funcs->set_config (set, ctx);if (ret ==0 ) { - crtc->primary->crtc = fb ? crtc :NULL ; - crtc->primary->fb = fb; +struct drm_plane *plane = crtc->primary; + +if (!plane->state) { + plane->crtc = fb ? crtc :NULL ; + plane->fb = fb; + } }drm_for_each_crtc (tmp, crtc->dev) {drivers/gpu/drm/drm_fb_helper.c +0
-7@@ -368,7 +368,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activstruct drm_plane *plane;struct drm_atomic_state *state;int i, ret; -unsigned int plane_mask;struct drm_modeset_acquire_ctx ctx;drm_modeset_acquire_init (&ctx,0 );@@ -381,7 +380,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ state->acquire_ctx = &ctx; retry: - plane_mask =0 ;drm_for_each_plane (plane, dev) { plane_state =drm_atomic_get_plane_state (state, plane);if (IS_ERR (plane_state)) {@@ -391,9 +389,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ plane_state->rotation =DRM_MODE_ROTATE_0 ; - plane->old_fb = plane->fb; - plane_mask |=1 <<drm_plane_index (plane); -/* disable non-primary: */ if (plane->type ==DRM_PLANE_TYPE_PRIMARY )continue ;@@ -430,8 +425,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ ret =drm_atomic_commit (state); out_state: -drm_atomic_clean_old_fb (dev, plane_mask, ret); -if (ret == -EDEADLK ) goto backoff;drivers/gpu/drm/drm_framebuffer.c +0
-5@@ -835,8 +835,6 @@ static int atomic_remove_fb(struct drm_framebuffer *fb) goto unlock; plane_mask |=BIT (drm_plane_index (plane)); - - plane->old_fb = plane->fb; }/* This list is only filled when disable_crtcs is set. */ @@ -851,9 +849,6 @@ static int atomic_remove_fb(struct drm_framebuffer *fb) ret =drm_atomic_commit (state); unlock: -if (plane_mask) -drm_atomic_clean_old_fb (dev, plane_mask, ret); -if (ret == -EDEADLK ) {drm_atomic_state_clear (state);drm_modeset_backoff (&ctx);drivers/gpu/drm/drm_plane.c +9
-5@@ -650,9 +650,11 @@ static int __setplane_internal(struct drm_plane *plane, crtc_x, crtc_y, crtc_w, crtc_h, src_x, src_y, src_w, src_h, ctx);if (!ret) { - plane->crtc = crtc; - plane->fb = fb; -drm_framebuffer_get (plane->fb); +if (!plane->state) { + plane->crtc = crtc; + plane->fb = fb; +drm_framebuffer_get (plane->fb); + } }else { plane->old_fb =NULL ; }@@ -1092,8 +1094,10 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,/* Keep the old fb, don't unref it. */ plane->old_fb =NULL ; }else { - plane->fb = fb; -drm_framebuffer_get (fb); +if (!plane->state) { + plane->fb = fb; +drm_framebuffer_get (fb); + } } out:drivers/gpu/drm/drm_plane_helper.c +3
-1@@ -502,6 +502,7 @@ EXPORT_SYMBOL(drm_plane_helper_update);int drm_plane_helper_disable (struct drm_plane *plane) {struct drm_plane_state *plane_state; +struct drm_framebuffer *old_fb;/* crtc helpers love to call disable functions for already disabled hw * functions. So cope with that. */ @@ -521,8 +522,9 @@ int drm_plane_helper_disable(struct drm_plane *plane) plane_state->plane = plane; plane_state->crtc =NULL ; + old_fb = plane_state->fb;drm_atomic_set_fb_for_plane (plane_state,NULL ); -return drm_plane_helper_commit (plane, plane_state, plane->fb); +return drm_plane_helper_commit (plane, plane_state, old_fb); }EXPORT_SYMBOL (drm_plane_helper_disable);include/drm/drm_atomic.h +0
-3@@ -601,9 +601,6 @@ int __must_check drm_atomic_add_affected_planes(struct drm_atomic_state *state, struct drm_crtc *crtc); -void -drm_atomic_clean_old_fb (struct drm_device *dev,unsigned plane_mask,int ret); -int __must_check drm_atomic_check_only (struct drm_atomic_state *state);int __must_check drm_atomic_commit (struct drm_atomic_state *state);int __must_check drm_atomic_nonblocking_commit (struct drm_atomic_state *state);Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 08/23] drm: Use plane->state->fb over plane->fb
In reply to Ville SyrjalaQuoted 6 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Stop looking at
plane->fbon atomic drivers. Useplane->state->fbinstead.Signed-off-by Ville Syrjälä <[email protected]>
Quoted 111 lines
--- drivers/gpu/drm/drm_atomic_helper.c | 2 +- drivers/gpu/drm/drm_crtc.c | 11 +++++++++-- drivers/gpu/drm/drm_plane.c | 19 ++++++++++++++----- 3 files changed, 24 insertions(+), 8 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +1
-1@@ -2659,7 +2659,7 @@ int drm_atomic_helper_disable_plane(struct drm_plane *plane, goto fail; } -if (plane_state->crtc && (plane == plane->crtc->cursor)) +if (plane_state->crtc && plane_state->crtc->cursor == plane) plane_state->state->legacy_cursor_update = true; ret =__drm_atomic_helper_disable_plane (plane, plane_state);drivers/gpu/drm/drm_crtc.c +9
-2@@ -597,13 +597,20 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,/* If we have a mode we need a framebuffer. */ /* If we pass -1, set the mode with the currently bound fb */ if (crtc_req->fb_id ==-1 ) { -if (!plane->fb) { +struct drm_framebuffer *old_fb; + +if (plane->state) + old_fb = plane->state->fb; +else + old_fb = plane->fb; + +if (!old_fb) {DRM_DEBUG_KMS ("CRTC doesn't have current FB\n" ); ret = -EINVAL ; goto out; } - fb = plane->fb; + fb = old_fb;/* Make refcounting symmetric with the lookup path. */ drm_framebuffer_get (fb); }else {drivers/gpu/drm/drm_plane.c +14
-5@@ -792,7 +792,11 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc, fb =NULL ; } }else { - fb = plane->fb; +if (plane->state) + fb = plane->state->fb; +else + fb = plane->fb; +if (fb)drm_framebuffer_get (fb); }@@ -934,7 +938,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,struct drm_mode_crtc_page_flip_target *page_flip = data;struct drm_crtc *crtc;struct drm_plane *plane; -struct drm_framebuffer *fb =NULL ; +struct drm_framebuffer *fb =NULL , *old_fb;struct drm_pending_vblank_event *e =NULL ;u32 target_vblank = page_flip->sequence;struct drm_modeset_acquire_ctx ctx;@@ -1012,7 +1016,12 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,if (ret) goto out; -if (plane->fb ==NULL ) { +if (plane->state) + old_fb = plane->state->fb; +else + old_fb = plane->fb; + +if (old_fb ==NULL ) {/* The framebuffer is currently unbound, presumably * due to a hotplug event, that userspace has not * yet discovered. @@ -1027,7 +1036,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, goto out; } -if (crtc->state) { +if (plane->state) {const struct drm_plane_state *state = plane->state; ret = drm_framebuffer_check_src_coords(state->src_x,@@ -1042,7 +1051,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,if (ret) goto out; -if (plane->fb->format != fb->format) { +if (old_fb->format != fb->format) {DRM_DEBUG_KMS ("Page flip is not allowed to change frame buffer format.\n" ); ret = -EINVAL ; goto out;Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 14/23] drm/atmel-hlcdc: Stop using plane->fb
In reply to Ville SyrjalaQuoted 17 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
We want to get rid of
plane->fbon atomic drivers. Stop looking at it.Cc Boris Brezillon <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +0
-0@@ -819,16 +819,6 @@ static void atmel_hlcdc_plane_atomic_disable(struct drm_plane *p,atmel_hlcdc_layer_read_reg (&plane->layer,ATMEL_HLCDC_LAYER_ISR ); }
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c static void atmel_hlcdc_plane_atomic_disable(struct drm_plane *p, · line 830
Quoted 10 lines
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +0
-9-static void atmel_hlcdc_plane_destroy (struct drm_plane *p) -{ -struct atmel_hlcdc_plane *plane =drm_plane_to_atmel_hlcdc_plane (p); - -if (plane->base.fb) -drm_framebuffer_put (plane->base.fb); - -drm_plane_cleanup (p); -}
This looks like refcount leak duct-tape due to lack of drm_atomic_helper_shutdown() in atmel. If you just apply this I think you'll start leaking.
We need a patch here to add the shutdown call instead. -Daniel
Quoted 20 lines
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +1
-2- static int atmel_hlcdc_plane_atomic_set_property(struct drm_plane *p, struct drm_plane_state *s, struct drm_property *property,@@ -1038,7 +1028,7 @@ static void atmel_hlcdc_plane_atomic_destroy_state(struct drm_plane *p,static const struct drm_plane_funcs layer_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = atmel_hlcdc_plane_destroy, + .destroy = drm_plane_cleanup, .reset = atmel_hlcdc_plane_reset, .atomic_duplicate_state = atmel_hlcdc_plane_atomic_duplicate_state, .atomic_destroy_state = atmel_hlcdc_plane_atomic_destroy_state,Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
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
Quoted 59 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
I really just wanted to fix i915 to re-enable its planes afer load detection (a two line patch). This is what I actually ended up with after I ran into a framebuffer refcount leak with said two line patch.
I've tested this on a few i915 boxes and so far it's looking good. Everything else is just compile tested.
Entire series available here:
git://github.com/vsyrjala/linux.gitplane_fb_crtc_nukeCc Alex Deucher <[email protected]>Cc Benjamin Gaignard <[email protected]>Cc Boris Brezillon <[email protected]>Cc "Christian König" <[email protected]>Cc Daniel Vetter <[email protected]>Cc Dave Airlie <[email protected]>Cc David Airlie <[email protected]>Cc "David (ChunMing) Zhou" <[email protected]>Cc Eric Anholt <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Harry Wentland <[email protected]>Cc Inki Dae <[email protected]>Cc Joonyoung Shim <[email protected]>Cc Kyungmin Park <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Rob Clark <[email protected]>Cc Seung-Woo Kim <[email protected]>Cc Shawn Guo <[email protected]>Cc Sinclair Yeh <[email protected]>Cc Thomas Hellstrom <[email protected]>Cc Vincent Abriou <[email protected]>Cc VMware Graphics <[email protected]>Ville Syrjälä (23):
Revert "drm/atomic-helper: Fix leak indisable_all" drm/atomic-helper: Makedrm_atomic_helper_disable_all()update theplane->fb pointersdrm: Clear
crtc->primary->crtcwhen disabling the crtc viasetcrtc()drm/atomic-helper: WARN if legacy plane fb pointers are bogus when
committing duplicated state
drm: Add local 'plane' variable for primary/cursor planes
drm: Adjust whitespace for legibility
drm: Make the fb refcount handover less magic
drm: Useplane->state->fboverplane->fb
drm/i915: Stop consultingplane->fb
drm/msm: Stop consultingplane->fb
drm/sti: Stop consultingplane->fb
drm/vmwgfx: Stop consultingplane->fb
drm/zte: Stop consultingplane->fb
drm/atmel-hlcdc: Stop usingplane->fb
drm: Stop updating plane->crtc/fb/old_fb on atomic drivers
Quoted 8 lines
drm/amdgpu/dc: Stop updating
plane->fb
drm/i915: Stop updating plane->fb/crtc
drm/exynos: Stop updatingplane->crtc
drm/msm: Stop updating plane->fb/crtc
drm/virtio: Stop updatingplane->fb
drm/vc4: Stop updating plane->fb/crtc
drm/i915: Restore planes after load detection
drm/i915: Makeforce_load_detecteffective even w/ DMI quirks/hotplug
Ok, I reviewed the core patches, looks all good.
Also starting auditing all the drivers. I think there's some small oversights in there, and I need to update my grep foo a bit, but by and large looks all reasonable.
Imo we should start merging, that will also make the auditing easier. -Daniel
Quoted 28 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 - drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 12 +--- drivers/gpu/drm/drm_atomic.c | 55 ++-------------- drivers/gpu/drm/drm_atomic_helper.c | 79 ++++++++++------------- drivers/gpu/drm/drm_crtc.c | 51 ++++++++++----- drivers/gpu/drm/drm_fb_helper.c | 7 -- drivers/gpu/drm/drm_framebuffer.c | 5 -- drivers/gpu/drm/drm_plane.c | 64 +++++++++++------- drivers/gpu/drm/drm_plane_helper.c | 4 +- drivers/gpu/drm/exynos/exynos_drm_plane.c | 2 - drivers/gpu/drm/i915/intel_crt.c | 6 ++ drivers/gpu/drm/i915/intel_display.c | 9 +-- drivers/gpu/drm/i915/intel_fbdev.c | 2 +- drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c | 3 +- drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c | 2 - drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 2 - drivers/gpu/drm/sti/sti_plane.c | 9 +-- drivers/gpu/drm/vc4/vc4_crtc.c | 3 - drivers/gpu/drm/virtio/virtgpu_display.c | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 6 +- drivers/gpu/drm/zte/zx_vou.c | 2 +- include/drm/drm_atomic.h | 3 - 22 files changed, 143 insertions(+), 187 deletions(-)Signature · 1 line
2.16.1
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
Quoted 59 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
I really just wanted to fix i915 to re-enable its planes afer load detection (a two line patch). This is what I actually ended up with after I ran into a framebuffer refcount leak with said two line patch.
I've tested this on a few i915 boxes and so far it's looking good. Everything else is just compile tested.
Entire series available here:
git://github.com/vsyrjala/linux.gitplane_fb_crtc_nukeCc Alex Deucher <[email protected]>Cc Benjamin Gaignard <[email protected]>Cc Boris Brezillon <[email protected]>Cc "Christian König" <[email protected]>Cc Daniel Vetter <[email protected]>Cc Dave Airlie <[email protected]>Cc David Airlie <[email protected]>Cc "David (ChunMing) Zhou" <[email protected]>Cc Eric Anholt <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Harry Wentland <[email protected]>Cc Inki Dae <[email protected]>Cc Joonyoung Shim <[email protected]>Cc Kyungmin Park <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Rob Clark <[email protected]>Cc Seung-Woo Kim <[email protected]>Cc Shawn Guo <[email protected]>Cc Sinclair Yeh <[email protected]>Cc Thomas Hellstrom <[email protected]>Cc Vincent Abriou <[email protected]>Cc VMware Graphics <[email protected]>Ville Syrjälä (23):
Revert "drm/atomic-helper: Fix leak indisable_all" drm/atomic-helper: Makedrm_atomic_helper_disable_all()update theplane->fb pointersdrm: Clear
crtc->primary->crtcwhen disabling the crtc viasetcrtc()drm/atomic-helper: WARN if legacy plane fb pointers are bogus when
committing duplicated state
drm: Add local 'plane' variable for primary/cursor planes
drm: Adjust whitespace for legibility
drm: Make the fb refcount handover less magic
drm: Useplane->state->fboverplane->fb
drm/i915: Stop consultingplane->fb
drm/msm: Stop consultingplane->fb
drm/sti: Stop consultingplane->fb
drm/vmwgfx: Stop consultingplane->fb
drm/zte: Stop consultingplane->fb
drm/atmel-hlcdc: Stop usingplane->fb
drm: Stop updating plane->crtc/fb/old_fb on atomic drivers
Quoted 8 lines
drm/amdgpu/dc: Stop updating
plane->fb
drm/i915: Stop updating plane->fb/crtc
drm/exynos: Stop updatingplane->crtc
drm/msm: Stop updating plane->fb/crtc
drm/virtio: Stop updatingplane->fb
drm/vc4: Stop updating plane->fb/crtc
drm/i915: Restore planes after load detection
drm/i915: Makeforce_load_detecteffective even w/ DMI quirks/hotplug
Ok, I reviewed the core patches, looks all good.
Also starting auditing all the drivers. I think there's some small oversights in there, and I need to update my grep foo a bit, but by and large looks all reasonable.
Imo we should start merging, that will also make the auditing easier. -Daniel
Quoted 28 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 - drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 12 +--- drivers/gpu/drm/drm_atomic.c | 55 ++-------------- drivers/gpu/drm/drm_atomic_helper.c | 79 ++++++++++------------- drivers/gpu/drm/drm_crtc.c | 51 ++++++++++----- drivers/gpu/drm/drm_fb_helper.c | 7 -- drivers/gpu/drm/drm_framebuffer.c | 5 -- drivers/gpu/drm/drm_plane.c | 64 +++++++++++------- drivers/gpu/drm/drm_plane_helper.c | 4 +- drivers/gpu/drm/exynos/exynos_drm_plane.c | 2 - drivers/gpu/drm/i915/intel_crt.c | 6 ++ drivers/gpu/drm/i915/intel_display.c | 9 +-- drivers/gpu/drm/i915/intel_fbdev.c | 2 +- drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c | 3 +- drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c | 2 - drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 2 - drivers/gpu/drm/sti/sti_plane.c | 9 +-- drivers/gpu/drm/vc4/vc4_crtc.c | 3 - drivers/gpu/drm/virtio/virtgpu_display.c | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 6 +- drivers/gpu/drm/zte/zx_vou.c | 2 +- include/drm/drm_atomic.h | 3 - 22 files changed, 143 insertions(+), 187 deletions(-)Signature · 1 line
2.16.1
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [Intel-gfx] [PATCH 15/23] drm: Stop updating plane->crtc/fb/old_fb on atomic drivers
In reply to Daniel VetterQuoted 9 lines · Daniel Vetter
Quoted 8 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Stop playing around with plane->crtc/fb/old_fb with atomic drivers. Make life a lot simpler when we don't have to do the magic
old_fbvs. fb dance around plane updates. That way we can't riskplane->fbgetting out of sync withplane->state->fband we're less likely to leak any refcounts as well.
Quoted 6 lines
Quoted 1 line
Signed-off-by Ville Syrjälä <[email protected]>What's the reason for this patch being in the middle of the patch series? I figured it's savest if we put this at the end? If you need parts of this here, we definitely need to split out the
WARN_ONhunk, since you haven't fixed up everything yet at this point here.
Yeah, the ordering is probably not great. I think I had some idea why I had to do "cleanup drivers a bit, do core/helper stuff, cleanup some more drivers, do other core/helper stuff". But I can't even recall that reason now. Most likely I had just managed to confuse myself by that time.
Quoted 322 lines
-Daniel
Quoted 315 lines
--- drivers/gpu/drm/drm_atomic.c | 55 ++++--------------------------------- drivers/gpu/drm/drm_atomic_helper.c | 15 +--------- drivers/gpu/drm/drm_crtc.c | 8 ++++-- drivers/gpu/drm/drm_fb_helper.c | 7 ----- drivers/gpu/drm/drm_framebuffer.c | 5 ---- drivers/gpu/drm/drm_plane.c | 14 ++++++---- drivers/gpu/drm/drm_plane_helper.c | 4 ++- include/drm/drm_atomic.h | 3 -- 8 files changed, 24 insertions(+), 87 deletions(-)drivers/gpu/drm/drm_atomic.c +5
-50@@ -692,6 +692,11 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,WARN_ON (!state->acquire_ctx); +/* the legacy pointers should never be set */ +WARN_ON (plane->fb); +WARN_ON (plane->old_fb); +WARN_ON (plane->crtc); + plane_state =drm_atomic_get_existing_plane_state (state, plane);if (plane_state)return plane_state;@@ -2021,45 +2026,6 @@ int drm_atomic_set_property(struct drm_atomic_state *state,return ret; } -/** -* drm_atomic_clean_old_fb -- Unset old_fb pointers and set plane->fb pointers. -* -* @dev: drm device to check. -* @plane_mask: plane mask for planes that were updated. -* @ret: return value, can be -EDEADLK for a retry. -* -* Before doing an update &drm_plane.old_fb is set to &drm_plane.fb, but before -* dropping the locks old_fb needs to be set to NULL and plane->fb updated. This -* is a common operation for each atomic update, so this call is split off as a -* helper. -*/ -void drm_atomic_clean_old_fb (struct drm_device *dev, -unsigned plane_mask, -int ret) -{ -struct drm_plane *plane; - -/* if succeeded, fixup legacy plane crtc/fb ptrs before dropping -* locks (ie. while it is still safe to deref plane->state). We -* need to do this here because the driver entry points cannot -* distinguish between legacy and atomic ioctls. -*/ -drm_for_each_plane_mask (plane, dev, plane_mask) { -if (ret ==0 ) { -struct drm_framebuffer *new_fb = plane->state->fb; -if (new_fb) -drm_framebuffer_get (new_fb); - plane->fb = new_fb; - plane->crtc = plane->state->crtc; - -if (plane->old_fb) -drm_framebuffer_put (plane->old_fb); - } - plane->old_fb =NULL ; - } -} -EXPORT_SYMBOL (drm_atomic_clean_old_fb); -/** * DOC: explicit fencing properties * @@ -2280,9 +2246,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,unsigned int copied_objs, copied_props;struct drm_atomic_state *state;struct drm_modeset_acquire_ctx ctx; -struct drm_plane *plane;struct drm_out_fence_state *fence_state; -unsigned plane_mask;int ret =0 ;unsigned int i, j, num_fences;@@ -2322,7 +2286,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, state->allow_modeset = !!(arg->flags &DRM_MODE_ATOMIC_ALLOW_MODESET ); retry: - plane_mask =0 ; copied_objs =0 ; copied_props =0 ; fence_state =NULL ;@@ -2393,12 +2356,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, copied_props++; } -if (obj->type ==DRM_MODE_OBJECT_PLANE && count_props && - !(arg->flags &DRM_MODE_ATOMIC_TEST_ONLY )) { - plane =obj_to_plane (obj); - plane_mask |= (1 <<drm_plane_index (plane)); - plane->old_fb = plane->fb; - }drm_mode_object_put (obj); }@@ -2419,8 +2376,6 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, } out: -drm_atomic_clean_old_fb (dev, plane_mask, ret); -complete_crtc_signaling (dev, state, fence_state, num_fences, !ret);if (ret == -EDEADLK ) {drivers/gpu/drm/drm_atomic_helper.c +1
-14@@ -2892,7 +2892,6 @@ static int __drm_atomic_helper_disable_all(struct drm_device *dev,struct drm_plane *plane;struct drm_crtc_state *crtc_state;struct drm_crtc *crtc; -unsigned int plane_mask =0 ;int ret, i; state =drm_atomic_state_alloc (dev);@@ -2935,17 +2934,10 @@ static int __drm_atomic_helper_disable_all(struct drm_device *dev, goto free;drm_atomic_set_fb_for_plane (plane_state,NULL ); - -if (clean_old_fbs) { - plane->old_fb = plane->fb; - plane_mask |=BIT (drm_plane_index (plane)); - } } ret =drm_atomic_commit (state); free: -drm_atomic_clean_old_fb (dev, plane_mask, ret); -drm_atomic_state_put (state);return ret; }@@ -3106,13 +3098,8 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state, state->acquire_ctx = ctx; -for_each_new_plane_in_state (state, plane, new_plane_state, i) { -WARN_ON (plane->crtc != new_plane_state->crtc); -WARN_ON (plane->fb != new_plane_state->fb); -WARN_ON (plane->old_fb); - +for_each_new_plane_in_state (state, plane, new_plane_state, i) state->planes[i].old_state = plane->state; - }for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) state->crtcs[i].old_state = crtc->state;drivers/gpu/drm/drm_crtc.c +6
-2@@ -474,8 +474,12 @@ static int __drm_mode_set_config_internal(struct drm_mode_set *set, ret = crtc->funcs->set_config (set, ctx);if (ret ==0 ) { - crtc->primary->crtc = fb ? crtc :NULL ; - crtc->primary->fb = fb; +struct drm_plane *plane = crtc->primary; + +if (!plane->state) { + plane->crtc = fb ? crtc :NULL ; + plane->fb = fb; + } }drm_for_each_crtc (tmp, crtc->dev) {drivers/gpu/drm/drm_fb_helper.c +0
-7@@ -368,7 +368,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activstruct drm_plane *plane;struct drm_atomic_state *state;int i, ret; -unsigned int plane_mask;struct drm_modeset_acquire_ctx ctx;drm_modeset_acquire_init (&ctx,0 );@@ -381,7 +380,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ state->acquire_ctx = &ctx; retry: - plane_mask =0 ;drm_for_each_plane (plane, dev) { plane_state =drm_atomic_get_plane_state (state, plane);if (IS_ERR (plane_state)) {@@ -391,9 +389,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ plane_state->rotation =DRM_MODE_ROTATE_0 ; - plane->old_fb = plane->fb; - plane_mask |=1 <<drm_plane_index (plane); -/* disable non-primary: */ if (plane->type ==DRM_PLANE_TYPE_PRIMARY )continue ;@@ -430,8 +425,6 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ ret =drm_atomic_commit (state); out_state: -drm_atomic_clean_old_fb (dev, plane_mask, ret); -if (ret == -EDEADLK ) goto backoff;drivers/gpu/drm/drm_framebuffer.c +0
-5@@ -835,8 +835,6 @@ static int atomic_remove_fb(struct drm_framebuffer *fb) goto unlock; plane_mask |=BIT (drm_plane_index (plane)); - - plane->old_fb = plane->fb; }/* This list is only filled when disable_crtcs is set. */ @@ -851,9 +849,6 @@ static int atomic_remove_fb(struct drm_framebuffer *fb) ret =drm_atomic_commit (state); unlock: -if (plane_mask) -drm_atomic_clean_old_fb (dev, plane_mask, ret); -if (ret == -EDEADLK ) {drm_atomic_state_clear (state);drm_modeset_backoff (&ctx);drivers/gpu/drm/drm_plane.c +9
-5@@ -650,9 +650,11 @@ static int __setplane_internal(struct drm_plane *plane, crtc_x, crtc_y, crtc_w, crtc_h, src_x, src_y, src_w, src_h, ctx);if (!ret) { - plane->crtc = crtc; - plane->fb = fb; -drm_framebuffer_get (plane->fb); +if (!plane->state) { + plane->crtc = crtc; + plane->fb = fb; +drm_framebuffer_get (plane->fb); + } }else { plane->old_fb =NULL ; }@@ -1092,8 +1094,10 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,/* Keep the old fb, don't unref it. */ plane->old_fb =NULL ; }else { - plane->fb = fb; -drm_framebuffer_get (fb); +if (!plane->state) { + plane->fb = fb; +drm_framebuffer_get (fb); + } } out:drivers/gpu/drm/drm_plane_helper.c +3
-1@@ -502,6 +502,7 @@ EXPORT_SYMBOL(drm_plane_helper_update);int drm_plane_helper_disable (struct drm_plane *plane) {struct drm_plane_state *plane_state; +struct drm_framebuffer *old_fb;/* crtc helpers love to call disable functions for already disabled hw * functions. So cope with that. */ @@ -521,8 +522,9 @@ int drm_plane_helper_disable(struct drm_plane *plane) plane_state->plane = plane; plane_state->crtc =NULL ; + old_fb = plane_state->fb;drm_atomic_set_fb_for_plane (plane_state,NULL ); -return drm_plane_helper_commit (plane, plane_state, plane->fb); +return drm_plane_helper_commit (plane, plane_state, old_fb); }EXPORT_SYMBOL (drm_plane_helper_disable);include/drm/drm_atomic.h +0
-3@@ -601,9 +601,6 @@ int __must_check drm_atomic_add_affected_planes(struct drm_atomic_state *state, struct drm_crtc *crtc); -void -drm_atomic_clean_old_fb (struct drm_device *dev,unsigned plane_mask,int ret); -int __must_check drm_atomic_check_only (struct drm_atomic_state *state);int __must_check drm_atomic_commit (struct drm_atomic_state *state);int __must_check drm_atomic_nonblocking_commit (struct drm_atomic_state *state);Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 02/23] drm/atomic-helper: Make drm_atomic_helper_disable_all() update the plane->fb pointers
In reply to Daniel VetterQuoted 20 lines · Daniel Vetter
Quoted 10 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
drm_atomic_helper_shutdown()needs to release the reference held byplane->fb, so we want to usedrm_atomic_clean_old_fb()indrm_atomic_helper_disable_all(). However during suspend/resume, gpu reset and load detection we should probably leave that stuff alone, as otherwise we'd have to make sure we put them back again when we restore the duplicated state to the device. Seems simpler to me to not touch any of it anyway.Quoted 8 lines
v2: Don't inflict the
clean_old_fbsbool to drivers (Daniel)Cc Dave Airlie <[email protected]> (v1)Cc Maarten Lankhorst <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>
Quoted 5 lines
I think this would be cleaner diff to read if you squash the first 2 patches together. Also avoids the bisect fail. With that (and I trust you to come up with a suitably merged commit message):
Reviewed-by Daniel Vetter <[email protected]>
Squashed, and commit message rescribbeled. And with sufficient confidence from a local smoke test I proceeded to push the easy ones 1-13 (except msm), and 22-23 (the load detect stuff for i915). I'll have to figure out the correct merge order for the rest next week.
Thanks for the reviews.
Quoted 124 lines
I reviewed this by re-reading the analysis from
49d70aeaeca8f62b72b77and trusting my former self :-)Cheers, Daniel
Quoted 113 lines
--- drivers/gpu/drm/drm_atomic_helper.c | 67 ++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 27 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +40
-27@@ -2881,31 +2881,9 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set,return 0 ; } -/** -* drm_atomic_helper_disable_all - disable all currently active outputs -* @dev: DRM device -* @ctx: lock acquisition context -* -* Loops through all connectors, finding those that aren't turned off and then -* turns them off by setting their DPMS mode to OFF and deactivating the CRTC -* that they are connected to. -* -* This is used for example in suspend/resume to disable all currently active -* functions when suspending. If you just want to shut down everything at e.g. -* driver unload, look at drm_atomic_helper_shutdown(). -* -* Note that if callers haven't already acquired all modeset locks this might -* return -EDEADLK, which must be handled by calling drm_modeset_backoff(). -* -* Returns: -* 0 on success or a negative error code on failure. -* -* See also: -* drm_atomic_helper_suspend(), drm_atomic_helper_resume() and -* drm_atomic_helper_shutdown(). -*/ -int drm_atomic_helper_disable_all (struct drm_device *dev, -struct drm_modeset_acquire_ctx *ctx) +static int __drm_atomic_helper_disable_all (struct drm_device *dev, +struct drm_modeset_acquire_ctx *ctx, +bool clean_old_fbs) {struct drm_atomic_state *state;struct drm_connector_state *conn_state;@@ -2914,6 +2892,7 @@ int drm_atomic_helper_disable_all(struct drm_device *dev,struct drm_plane *plane;struct drm_crtc_state *crtc_state;struct drm_crtc *crtc; +unsigned int plane_mask =0 ;int ret, i; state =drm_atomic_state_alloc (dev);@@ -2956,14 +2935,48 @@ int drm_atomic_helper_disable_all(struct drm_device *dev, goto free;drm_atomic_set_fb_for_plane (plane_state,NULL ); + +if (clean_old_fbs) { + plane->old_fb = plane->fb; + plane_mask |=BIT (drm_plane_index (plane)); + } } ret =drm_atomic_commit (state); free: +drm_atomic_clean_old_fb (dev, plane_mask, ret); +drm_atomic_state_put (state);return ret; } - +/** +* drm_atomic_helper_disable_all - disable all currently active outputs +* @dev: DRM device +* @ctx: lock acquisition context +* +* Loops through all connectors, finding those that aren't turned off and then +* turns them off by setting their DPMS mode to OFF and deactivating the CRTC +* that they are connected to. +* +* This is used for example in suspend/resume to disable all currently active +* functions when suspending. If you just want to shut down everything at e.g. +* driver unload, look at drm_atomic_helper_shutdown(). +* +* Note that if callers haven't already acquired all modeset locks this might +* return -EDEADLK, which must be handled by calling drm_modeset_backoff(). +* +* Returns: +* 0 on success or a negative error code on failure. +* +* See also: +* drm_atomic_helper_suspend(), drm_atomic_helper_resume() and +* drm_atomic_helper_shutdown(). +*/ +int drm_atomic_helper_disable_all (struct drm_device *dev, +struct drm_modeset_acquire_ctx *ctx) +{ +return __drm_atomic_helper_disable_all (dev, ctx, false); +}EXPORT_SYMBOL (drm_atomic_helper_disable_all);/** @@ -2986,7 +2999,7 @@ void drm_atomic_helper_shutdown(struct drm_device *dev)while (1 ) { ret =drm_modeset_lock_all_ctx (dev, &ctx);if (!ret) - ret =drm_atomic_helper_disable_all (dev, &ctx); + ret =__drm_atomic_helper_disable_all (dev, &ctx, true);if (ret != -EDEADLK )break ;Signature · 1 line
2.16.1Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx