drm/atomic: Make prepare_fb/cleanup_fb only take state, v3.
Subsystems (9)
Maarten Lankhorst
maintainerPATCH 1/2 drm/atomic: Make prepare_fb/cleanup_fb only take state, v3.
This removes the need to separately track fb changes i915. That will be done as a separate commit, however.
Changes since v1:
- Add dri-devel to cc.
- Fix a check in intel's prepare and cleanup fb to take rotation into account.
Changes since v2:
- Split out i915 changes to a separate commit.
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 4 +++- drivers/gpu/drm/drm_atomic_helper.c | 21 ++++++--------------- drivers/gpu/drm/drm_plane_helper.c | 6 +++--- drivers/gpu/drm/i915/intel_display.c | 9 ++++----- drivers/gpu/drm/i915/intel_drv.h | 2 -- drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c | 10 ++++++++-- drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 9 ++++++++- drivers/gpu/drm/omapdrm/omap_plane.c | 10 ++++++---- drivers/gpu/drm/tegra/dc.c | 2 -- include/drm/drm_plane_helper.h | 2 -- 10 files changed, 38 insertions(+), 37 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +3 -1
@@ -712,11 +712,13 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p, }static int atmel_hlcdc_plane_prepare_fb (struct drm_plane *p, -struct drm_framebuffer *fb,const struct drm_plane_state *new_state) {struct atmel_hlcdc_plane *plane =drm_plane_to_atmel_hlcdc_plane (p); +if (!new_state->fb) +return 0 ; +return atmel_hlcdc_layer_update_start (&plane->layer); }
drivers/gpu/drm/drm_atomic_helper.c +6 -15
@@ -1111,17 +1111,14 @@ int drm_atomic_helper_prepare_planes(struct drm_device *dev,const struct drm_plane_helper_funcs *funcs;struct drm_plane *plane = state->planes[i];struct drm_plane_state *plane_state = state->plane_states[i]; -struct drm_framebuffer *fb;if (!plane)continue ; funcs = plane->helper_private; - fb = plane_state->fb; - -if (fb && funcs->prepare_fb) { - ret = funcs->prepare_fb (plane, fb, plane_state); +if (funcs->prepare_fb) { + ret = funcs->prepare_fb (plane, plane_state);if (ret) goto fail; }
@@ -1134,17 +1131,14 @@ fail:const struct drm_plane_helper_funcs *funcs;struct drm_plane *plane = state->planes[i];struct drm_plane_state *plane_state = state->plane_states[i]; -struct drm_framebuffer *fb;if (!plane)continue ; funcs = plane->helper_private; - fb = state->plane_states[i]->fb; - -if (fb && funcs->cleanup_fb) - funcs->cleanup_fb (plane, fb, plane_state); +if (funcs->cleanup_fb) + funcs->cleanup_fb (plane, plane_state); }
@@ -1300,14 +1294,11 @@ void drm_atomic_helper_cleanup_planes(struct drm_device *dev,for_each_plane_in_state (old_state, plane, plane_state, i) {const struct drm_plane_helper_funcs *funcs; -struct drm_framebuffer *old_fb; funcs = plane->helper_private; - old_fb = plane_state->fb; - -if (old_fb && funcs->cleanup_fb) - funcs->cleanup_fb (plane, old_fb, plane_state); +if (funcs->cleanup_fb) + funcs->cleanup_fb (plane, plane_state); } }EXPORT_SYMBOL (drm_atomic_helper_cleanup_planes);
drivers/gpu/drm/drm_plane_helper.c +3 -3
@@ -426,7 +426,7 @@ int drm_plane_helper_commit(struct drm_plane *plane,if (plane_funcs->prepare_fb && plane_state->fb && plane_state->fb != old_fb) { - ret = plane_funcs->prepare_fb (plane, plane_state->fb, + ret = plane_funcs->prepare_fb (plane, plane_state);if (ret) goto out;
@@ -479,8 +479,8 @@ int drm_plane_helper_commit(struct drm_plane *plane, ret =0 ; } -if (plane_funcs->cleanup_fb && old_fb) - plane_funcs->cleanup_fb (plane, old_fb, plane_state); +if (plane_funcs->cleanup_fb) + plane_funcs->cleanup_fb (plane, plane_state); out:if (plane_state) {if (plane->funcs->atomic_destroy_state)
drivers/gpu/drm/i915/intel_display.c +4 -5
@@ -13266,10 +13266,10 @@ static void intel_shared_dpll_init(struct drm_device *dev)*/ int intel_prepare_plane_fb (struct drm_plane *plane, -struct drm_framebuffer *fb,const struct drm_plane_state *new_state) {struct drm_device *dev = plane->dev; +struct drm_framebuffer *fb = new_state->fb;struct intel_plane *intel_plane =to_intel_plane (plane);struct drm_i915_gem_object *obj =intel_fb_obj (fb);struct drm_i915_gem_object *old_obj =intel_fb_obj (plane->fb);
@@ -13307,19 +13307,18 @@ intel_prepare_plane_fb(struct drm_plane *plane,*/ void intel_cleanup_plane_fb (struct drm_plane *plane, -struct drm_framebuffer *fb,const struct drm_plane_state *old_state) {struct drm_device *dev = plane->dev; -struct drm_i915_gem_object *obj =intel_fb_obj (fb); +struct drm_i915_gem_object *obj =intel_fb_obj (old_state->fb); -if (WARN_ON (!obj)) +if (!obj)return ;if (plane->type !=DRM_PLANE_TYPE_CURSOR || !INTEL_INFO (dev)->cursor_needs_physical) {mutex_lock (&dev->struct_mutex); -intel_unpin_fb_obj (fb, old_state); +intel_unpin_fb_obj (old_state->fb, old_state);mutex_unlock (&dev->struct_mutex); } }
drivers/gpu/drm/i915/intel_drv.h +0 -2
@@ -1062,10 +1062,8 @@ void intel_finish_page_flip(struct drm_device *dev, int pipe);void intel_finish_page_flip_plane (struct drm_device *dev,int plane);void intel_check_page_flip (struct drm_device *dev,int pipe);int intel_prepare_plane_fb (struct drm_plane *plane, -struct drm_framebuffer *fb,const struct drm_plane_state *new_state);void intel_cleanup_plane_fb (struct drm_plane *plane, -struct drm_framebuffer *fb,const struct drm_plane_state *old_state); int intel_plane_atomic_get_property(struct drm_plane *plane, const struct drm_plane_state *state,
drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c +8 -2
@@ -99,22 +99,28 @@ static const struct drm_plane_funcs mdp4_plane_funcs = { };static int mdp4_plane_prepare_fb (struct drm_plane *plane, -struct drm_framebuffer *fb,const struct drm_plane_state *new_state) {struct mdp4_plane *mdp4_plane =to_mdp4_plane (plane);struct mdp4_kms *mdp4_kms =get_kms (plane); +struct drm_framebuffer *fb = new_state->fb; + +if (!fb) +return 0 ;DBG ("%s: prepare: FB[%u]" , mdp4_plane->name, fb->base.id);return msm_framebuffer_prepare (fb, mdp4_kms->id); }static void mdp4_plane_cleanup_fb (struct drm_plane *plane, -struct drm_framebuffer *fb,const struct drm_plane_state *old_state) {struct mdp4_plane *mdp4_plane =to_mdp4_plane (plane);struct mdp4_kms *mdp4_kms =get_kms (plane); +struct drm_framebuffer *fb = old_state->fb; + +if (!fb) +return ;DBG ("%s: cleanup: FB[%u]" , mdp4_plane->name, fb->base.id);msm_framebuffer_cleanup (fb, mdp4_kms->id);
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c +8 -1
@@ -250,11 +250,14 @@ static const struct drm_plane_funcs mdp5_plane_funcs = { };static int mdp5_plane_prepare_fb (struct drm_plane *plane, -struct drm_framebuffer *fb,const struct drm_plane_state *new_state) {struct mdp5_plane *mdp5_plane =to_mdp5_plane (plane);struct mdp5_kms *mdp5_kms =get_kms (plane); +struct drm_framebuffer *fb = new_state->fb; + +if (!new_state->fb) +return 0 ;DBG ("%s: prepare: FB[%u]" , mdp5_plane->name, fb->base.id);return msm_framebuffer_prepare (fb, mdp5_kms->id);
@@ -266,6 +269,10 @@ static void mdp5_plane_cleanup_fb(struct drm_plane *plane, {struct mdp5_plane *mdp5_plane =to_mdp5_plane (plane);struct mdp5_kms *mdp5_kms =get_kms (plane); +struct drm_framebuffer *fb = old_state->fb; + +if (!fb) +return ;DBG ("%s: cleanup: FB[%u]" , mdp5_plane->name, fb->base.id);msm_framebuffer_cleanup (fb, mdp5_kms->id);
drivers/gpu/drm/omapdrm/omap_plane.c +6 -4
@@ -60,17 +60,19 @@ to_omap_plane_state(struct drm_plane_state *state) }static int omap_plane_prepare_fb (struct drm_plane *plane, -struct drm_framebuffer *fb,const struct drm_plane_state *new_state) { -return omap_framebuffer_pin (fb); +if (!new_state->fb) +return 0 ; + +return omap_framebuffer_pin (new_state->fb); }static void omap_plane_cleanup_fb (struct drm_plane *plane, -struct drm_framebuffer *fb,const struct drm_plane_state *old_state) { -omap_framebuffer_unpin (fb); +if (old_state->fb) +omap_framebuffer_unpin (old_state->fb); } static void omap_plane_atomic_update(struct drm_plane *plane,
drivers/gpu/drm/tegra/dc.c +0 -2
@@ -480,14 +480,12 @@ static const struct drm_plane_funcs tegra_primary_plane_funcs = { };static int tegra_plane_prepare_fb (struct drm_plane *plane, -struct drm_framebuffer *fb,const struct drm_plane_state *new_state) {return 0 ; }static void tegra_plane_cleanup_fb (struct drm_plane *plane, -struct drm_framebuffer *fb,const struct drm_plane_state *old_fb) { }
include/drm/drm_plane_helper.h +0 -2
@@ -58,10 +58,8 @@ int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,*/ struct drm_plane_helper_funcs {int (*prepare_fb)(struct drm_plane *plane, -struct drm_framebuffer *fb,const struct drm_plane_state *new_state);void (*cleanup_fb)(struct drm_plane *plane, -struct drm_framebuffer *fb,const struct drm_plane_state *old_state); int (*atomic_check)(struct drm_plane *plane,
Signature · 6 lines
2.1.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Maarten Lankhorst
maintainerPATCH 2/2 drm/i915: Make plane fb tracking work correctly.
atomic->disabled_planes is a hack that had to exist because prepare_fb was only called when a new fb was set. This messed up fb tracking in some circumstances like aborts from interruptible waits. As a result interruptible waiting in prepare_plane_fb was forbidden, but other errors could still cause frontbuffer tracking to be messed up.
Now that prepare_fb is always called, this hack is no longer required and prepare_fb may fail without consequences.
--- drivers/gpu/drm/i915/intel_display.c | 47 ++++++++++++++---------------------- drivers/gpu/drm/i915/intel_drv.h | 1 - 2 files changed, 18 insertions(+), 30 deletions(-)
drivers/gpu/drm/i915/intel_display.c +18 -29
@@ -4718,17 +4718,6 @@ static void intel_pre_plane_update(struct intel_crtc *crtc)struct drm_device *dev = crtc->base.dev;struct drm_i915_private *dev_priv = dev->dev_private;struct intel_crtc_atomic_commit *atomic = &crtc->atomic; -struct drm_plane *p; - -/* Track fb's for any planes being disabled */ -drm_for_each_plane_mask (p, dev, atomic->disabled_planes) { -struct intel_plane *plane =to_intel_plane (p); - -mutex_lock (&dev->struct_mutex); -i915_gem_track_fb (intel_fb_obj (plane->base.fb),NULL , - plane->frontbuffer_bit); -mutex_unlock (&dev->struct_mutex); - }if (atomic->wait_for_flips)intel_crtc_wait_for_pending_flips (&crtc->base);
@@ -11511,14 +11500,6 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,return ret; } -/* -* Disabling a plane is always okay; we just need to update -* fb tracking in a special way since cleanup_fb() won't -* get called by the plane helpers. -*/ -if (old_plane_state->base.fb && !fb) - intel_crtc->atomic.disabled_planes |=1 << i; - was_visible = old_plane_state->visible; visible =to_intel_plane_state (plane_state)->visible;
@@ -13272,15 +13253,17 @@ intel_prepare_plane_fb(struct drm_plane *plane,struct drm_framebuffer *fb = new_state->fb;struct intel_plane *intel_plane =to_intel_plane (plane);struct drm_i915_gem_object *obj =intel_fb_obj (fb); -struct drm_i915_gem_object *old_obj =intel_fb_obj (plane->fb); +struct drm_i915_gem_object *old_obj =intel_fb_obj (plane->state->fb);int ret =0 ; -if (!obj) +if (!obj && !old_obj)return 0 ;mutex_lock (&dev->struct_mutex); -if (plane->type ==DRM_PLANE_TYPE_CURSOR && +if (!obj) { + ret =0 ; + }else if (plane->type ==DRM_PLANE_TYPE_CURSOR &&INTEL_INFO (dev)->cursor_needs_physical) {int align =IS_I830 (dev) ?16 *1024 :256 ; ret =i915_gem_object_attach_phys (obj, align);
@@ -13310,17 +13293,23 @@ intel_cleanup_plane_fb(struct drm_plane *plane, const struct drm_plane_state *old_state) {struct drm_device *dev = plane->dev; -struct drm_i915_gem_object *obj =intel_fb_obj (old_state->fb); +struct intel_plane *intel_plane =to_intel_plane (plane); +struct drm_i915_gem_object *old_obj =intel_fb_obj (old_state->fb); +struct drm_i915_gem_object *obj =intel_fb_obj (plane->fb); -if (!obj) +if (!obj && !old_obj)return ; -if (plane->type !=DRM_PLANE_TYPE_CURSOR || - !INTEL_INFO (dev)->cursor_needs_physical) { -mutex_lock (&dev->struct_mutex); +mutex_lock (&dev->struct_mutex); +if (old_obj && (plane->type !=DRM_PLANE_TYPE_CURSOR || + !INTEL_INFO (dev)->cursor_needs_physical))intel_unpin_fb_obj (old_state->fb, old_state); -mutex_unlock (&dev->struct_mutex); - } + +/* prepare_fb aborted? */ +if ((old_obj && (old_obj->frontbuffer_bits & intel_plane->frontbuffer_bit)) || + (obj && !(obj->frontbuffer_bits & intel_plane->frontbuffer_bit))) +i915_gem_track_fb (old_obj, obj, intel_plane->frontbuffer_bit); +mutex_unlock (&dev->struct_mutex); }int
drivers/gpu/drm/i915/intel_drv.h +0 -1
@@ -505,7 +505,6 @@ struct intel_crtc_atomic_commit {bool disable_cxsr;bool pre_disable_primary;bool update_wm_pre, update_wm_post; -unsigned disabled_planes;/* Sleepable operations to perform after commit */ unsigned fb_bits;
Signature · 6 lines
2.1.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Maarten Lankhorst
maintainerRe: [PATCH 2/2] drm/i915: Make plane fb tracking work correctly.
Op 02-09-15 om 10:42 schreef Maarten Lankhorst:
Quoted 75 lines
atomic->disabled_planesis a hack that had to exist becauseprepare_fbwas only called when a new fb was set. This messed up fb tracking in some circumstances like aborts from interruptible waits. As a result interruptible waiting inprepare_plane_fbwas forbidden, but other errors could still cause frontbuffer tracking to be messed up.Now that
prepare_fbis always called, this hack is no longer required andprepare_fbmay fail without consequences.Signed-off-by Maarten Lankhorst <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 47 ++++++++++++++---------------------- drivers/gpu/drm/i915/intel_drv.h | 1 - 2 files changed, 18 insertions(+), 30 deletions(-)drivers/gpu/drm/i915/intel_display.c +5
-22@@ -4718,17 +4718,6 @@ static void intel_pre_plane_update(struct intel_crtc *crtc)struct drm_device *dev = crtc->base.dev;struct drm_i915_private *dev_priv = dev->dev_private;struct intel_crtc_atomic_commit *atomic = &crtc->atomic; -struct drm_plane *p; - -/* Track fb's for any planes being disabled */ -drm_for_each_plane_mask (p, dev, atomic->disabled_planes) { -struct intel_plane *plane =to_intel_plane (p); - -mutex_lock (&dev->struct_mutex); -i915_gem_track_fb (intel_fb_obj (plane->base.fb),NULL , - plane->frontbuffer_bit); -mutex_unlock (&dev->struct_mutex); - }if (atomic->wait_for_flips)intel_crtc_wait_for_pending_flips (&crtc->base);@@ -11511,14 +11500,6 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,return ret; } -/* -* Disabling a plane is always okay; we just need to update -* fb tracking in a special way since cleanup_fb() won't -* get called by the plane helpers. -*/ -if (old_plane_state->base.fb && !fb) - intel_crtc->atomic.disabled_planes |=1 << i; - was_visible = old_plane_state->visible; visible =to_intel_plane_state (plane_state)->visible;@@ -13272,15 +13253,17 @@ intel_prepare_plane_fb(struct drm_plane *plane,struct drm_framebuffer *fb = new_state->fb;struct intel_plane *intel_plane =to_intel_plane (plane);struct drm_i915_gem_object *obj =intel_fb_obj (fb); -struct drm_i915_gem_object *old_obj =intel_fb_obj (plane->fb); +struct drm_i915_gem_object *old_obj =intel_fb_obj (plane->state->fb);int ret =0 ; -if (!obj) +if (!obj && !old_obj)return 0 ;mutex_lock (&dev->struct_mutex); -if (plane->type ==DRM_PLANE_TYPE_CURSOR && +if (!obj) { + ret =0 ; + }else if (plane->type ==DRM_PLANE_TYPE_CURSOR &&INTEL_INFO (dev)->cursor_needs_physical) {int align =IS_I830 (dev) ?16 *1024 :256 ; ret =i915_gem_object_attach_phys (obj, align);
drivers/gpu/drm/i915/intel_display.c intel_cleanup_plane_fb(struct drm_plane *plane, · line 13298
Quoted 7 lines
drivers/gpu/drm/i915/intel_display.c +3
-1@@ -13310,17 +13293,23 @@ intel_cleanup_plane_fb(struct drm_plane *plane, const struct drm_plane_state *old_state) {struct drm_device *dev = plane->dev; -struct drm_i915_gem_object *obj =intel_fb_obj (old_state->fb); +struct intel_plane *intel_plane =to_intel_plane (plane); +struct drm_i915_gem_object *old_obj =intel_fb_obj (old_state->fb); +struct drm_i915_gem_object *obj =intel_fb_obj (plane->fb);
^Oops, this one needs to be plane->state->fb, or a frontbuffer tracking mismatch would still occur when applying the interruptible pinning series.
Quoted 27 lines
drivers/gpu/drm/i915/intel_display.c +10
-6-if (!obj) +if (!obj && !old_obj)return ; -if (plane->type !=DRM_PLANE_TYPE_CURSOR || - !INTEL_INFO (dev)->cursor_needs_physical) { -mutex_lock (&dev->struct_mutex); +mutex_lock (&dev->struct_mutex); +if (old_obj && (plane->type !=DRM_PLANE_TYPE_CURSOR || + !INTEL_INFO (dev)->cursor_needs_physical))intel_unpin_fb_obj (old_state->fb, old_state); -mutex_unlock (&dev->struct_mutex); - } + +/* prepare_fb aborted? */ +if ((old_obj && (old_obj->frontbuffer_bits & intel_plane->frontbuffer_bit)) || + (obj && !(obj->frontbuffer_bits & intel_plane->frontbuffer_bit))) +i915_gem_track_fb (old_obj, obj, intel_plane->frontbuffer_bit); +mutex_unlock (&dev->struct_mutex); }int drivers/gpu/drm/i915/intel_drv.h +0
-0
drivers/gpu/drm/i915/intel_drv.h struct intel_crtc_atomic_commit { · line 510
Quoted 7 lines
drivers/gpu/drm/i915/intel_drv.h +0
-1@@ -505,7 +505,6 @@ struct intel_crtc_atomic_commit {bool disable_cxsr;bool pre_disable_primary;bool update_wm_pre, update_wm_post; -unsigned disabled_planes;/* Sleepable operations to perform after commit */ unsigned fb_bits;
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 10 lines · Maarten Lankhorst
This removes the need to separately track fb changes i915. That will be done as a separate commit, however.
Changes since v1:
- Add dri-devel to cc.
- Fix a check in intel's prepare and cleanup fb to take rotation into account.
Changes since v2:
- Split out i915 changes to a separate commit.
Quoted 2 lines
Signed-off-by Maarten Lankhorst <[email protected]>
I'd probably prefer to see the change to call them unconditionally (regardless of fb != NULL) in a separate patch, but with or without:
Cheers,
Daniel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Daniel Vetter
AppliedQuoted 12 lines · Daniel Stone
Quoted 10 lines · Maarten Lankhorst
This removes the need to separately track fb changes i915. That will be done as a separate commit, however.
Changes since v1:
- Add dri-devel to cc.
- Fix a check in intel's prepare and cleanup fb to take rotation into account.
Changes since v2:
- Split out i915 changes to a separate commit.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Maarten Lankhorst <[email protected]>I'd probably prefer to see the change to call them unconditionally (regardless of fb != NULL) in a separate patch, but with or without:
Reviewed-by Daniel Stone <[email protected]>
Applied to drm-misc, thanks.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Maarten Lankhorst
maintainerOp 02-09-15 om 17:24 schreef Daniel Vetter:
Quoted 13 lines · Daniel Stone
Quoted 12 lines
Quoted 10 lines · Maarten Lankhorst
This removes the need to separately track fb changes i915. That will be done as a separate commit, however.
Changes since v1:
- Add dri-devel to cc.
- Fix a check in intel's prepare and cleanup fb to take rotation into account.
Changes since v2:
- Split out i915 changes to a separate commit.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by Maarten Lankhorst <[email protected]>I'd probably prefer to see the change to call them unconditionally (regardless of fb != NULL) in a separate patch, but with or without:
Reviewed-by Daniel Stone <[email protected]>Applied to drm-misc, thanks.
-Daniel
Daniel Stone, can you review 2/2 too?
~Maarten
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel