Skip to content

Commit ab8d667

Browse files
tursulindanvet
authored andcommitted
drm/i915: Track old framebuffer instead of object
Daniel Vetter spotted a bug while reviewing some of my refactoring in this are of the code. I'll quote: """ > @@ -9764,6 +9768,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, > work->event = event; > work->crtc = crtc; > work->old_fb_obj = intel_fb_obj(old_fb); > + work->old_tiling_mode = to_intel_framebuffer(old_fb)->tiling_mode; Hm, that's actually an interesting bugfix - currently userspace could be sneaky and destroy the old fb immediately after the flip completes and the change the tiling of the underlying object before the unpin work had a chance to run (needs some fudgin with rt prios to starve workers to make this work though). Imo the right fix is to hold a reference onto the fb and not the underlying gem object. With that tiling is guaranteed not to change. """ This patch tries to implement the above proposed change. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent 3f678c9 commit ab8d667

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎drivers/gpu/drm/i915/intel_display.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9055,9 +9055,9 @@ static void intel_unpin_work_fn(struct work_struct *__work)
90559055
enum pipe pipe = to_intel_crtc(work->crtc)->pipe;
90569056

90579057
mutex_lock(&dev->struct_mutex);
9058-
intel_unpin_fb_obj(work->old_fb_obj);
9058+
intel_unpin_fb_obj(intel_fb_obj(work->old_fb));
90599059
drm_gem_object_unreference(&work->pending_flip_obj->base);
9060-
drm_gem_object_unreference(&work->old_fb_obj->base);
9060+
drm_framebuffer_unreference(work->old_fb);
90619061

90629062
intel_fbc_update(dev);
90639063

@@ -9760,7 +9760,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
97609760

97619761
work->event = event;
97629762
work->crtc = crtc;
9763-
work->old_fb_obj = intel_fb_obj(old_fb);
9763+
work->old_fb = old_fb;
97649764
INIT_WORK(&work->work, intel_unpin_work_fn);
97659765

97669766
ret = drm_crtc_vblank_get(crtc);
@@ -9796,7 +9796,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
97969796
goto cleanup;
97979797

97989798
/* Reference the objects for the scheduled work. */
9799-
drm_gem_object_reference(&work->old_fb_obj->base);
9799+
drm_framebuffer_reference(work->old_fb);
98009800
drm_gem_object_reference(&obj->base);
98019801

98029802
crtc->primary->fb = fb;
@@ -9818,7 +9818,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
98189818

98199819
if (IS_VALLEYVIEW(dev)) {
98209820
ring = &dev_priv->ring[BCS];
9821-
if (obj->tiling_mode != work->old_fb_obj->tiling_mode)
9821+
if (obj->tiling_mode != intel_fb_obj(work->old_fb)->tiling_mode)
98229822
/* vlv: DISPLAY_FLIP fails to change tiling */
98239823
ring = NULL;
98249824
} else if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev)) {
@@ -9859,7 +9859,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
98599859
work->flip_queued_vblank = drm_vblank_count(dev, intel_crtc->pipe);
98609860
work->enable_stall_check = true;
98619861

9862-
i915_gem_track_fb(work->old_fb_obj, obj,
9862+
i915_gem_track_fb(intel_fb_obj(work->old_fb), obj,
98639863
INTEL_FRONTBUFFER_PRIMARY(pipe));
98649864

98659865
intel_fbc_disable(dev);
@@ -9875,7 +9875,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
98759875
cleanup_pending:
98769876
atomic_dec(&intel_crtc->unpin_work_count);
98779877
crtc->primary->fb = old_fb;
9878-
drm_gem_object_unreference(&work->old_fb_obj->base);
9878+
drm_framebuffer_unreference(work->old_fb);
98799879
drm_gem_object_unreference(&obj->base);
98809880
mutex_unlock(&dev->struct_mutex);
98819881

‎drivers/gpu/drm/i915/intel_drv.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ intel_get_crtc_for_plane(struct drm_device *dev, int plane)
710710
struct intel_unpin_work {
711711
struct work_struct work;
712712
struct drm_crtc *crtc;
713-
struct drm_i915_gem_object *old_fb_obj;
713+
struct drm_framebuffer *old_fb;
714714
struct drm_i915_gem_object *pending_flip_obj;
715715
struct drm_pending_vblank_event *event;
716716
atomic_t pending;

0 commit comments

Comments
 (0)