From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> 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. Cc: martin.peres@xxxxxxx Cc: chris@xxxxxxxxxxxxxxxxxx Cc: Dave Airlie <airlied@xxxxxxxxx> (v1) Cc: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx> Cc: Daniel Vetter <daniel.vetter@xxxxxxxxx> Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> --- drivers/gpu/drm/drm_atomic_helper.c | 16 +++++++++++++--- drivers/gpu/drm/i915/intel_display.c | 2 +- include/drm/drm_atomic_helper.h | 3 ++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index c48f187d08de..e9dff9c014df 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -2885,6 +2885,7 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set, * drm_atomic_helper_disable_all - disable all currently active outputs * @dev: DRM device * @ctx: lock acquisition context + * @clean_old_fbs: update the plane->fb/old_fb pointers? * * 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 @@ -2905,7 +2906,8 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set, * drm_atomic_helper_shutdown(). */ int drm_atomic_helper_disable_all(struct drm_device *dev, - struct drm_modeset_acquire_ctx *ctx) + struct drm_modeset_acquire_ctx *ctx, + bool clean_old_fbs) { struct drm_atomic_state *state; struct drm_connector_state *conn_state; @@ -2914,6 +2916,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,10 +2959,17 @@ 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; } @@ -2986,7 +2996,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; @@ -3046,7 +3056,7 @@ struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev) if (IS_ERR(state)) goto unlock; - err = drm_atomic_helper_disable_all(dev, &ctx); + err = drm_atomic_helper_disable_all(dev, &ctx, false); if (err < 0) { drm_atomic_state_put(state); state = ERR_PTR(err); diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 3e7ab75e1b41..c79800ae35c3 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -3716,7 +3716,7 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv) return; } - ret = drm_atomic_helper_disable_all(dev, ctx); + ret = drm_atomic_helper_disable_all(dev, ctx, false); if (ret) { DRM_ERROR("Suspending crtc's failed with %i\n", ret); drm_atomic_state_put(state); diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h index 26aaba58d6ce..10e952951d2f 100644 --- a/include/drm/drm_atomic_helper.h +++ b/include/drm/drm_atomic_helper.h @@ -122,7 +122,8 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set, struct drm_atomic_state *state); int drm_atomic_helper_disable_all(struct drm_device *dev, - struct drm_modeset_acquire_ctx *ctx); + struct drm_modeset_acquire_ctx *ctx, + bool clean_old_fbs); void drm_atomic_helper_shutdown(struct drm_device *dev); struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev); int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state, -- 2.16.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx