diff options
author | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2015-02-02 10:44:15 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-02-13 17:27:59 -0500 |
commit | ab8d66752a9c28cd6c94fa173feacdfc1554aa03 (patch) | |
tree | 5b10a80a6d0b84283e2689de61e2cc3925cee7de /drivers/gpu | |
parent | 3f678c96abb43a977d2ea41aefccdc49e8a3e896 (diff) |
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>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/i915/intel_display.c | 14 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_drv.h | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index ebf973c303b7..213b870ae06e 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -9055,9 +9055,9 @@ static void intel_unpin_work_fn(struct work_struct *__work) | |||
9055 | enum pipe pipe = to_intel_crtc(work->crtc)->pipe; | 9055 | enum pipe pipe = to_intel_crtc(work->crtc)->pipe; |
9056 | 9056 | ||
9057 | mutex_lock(&dev->struct_mutex); | 9057 | 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)); |
9059 | drm_gem_object_unreference(&work->pending_flip_obj->base); | 9059 | 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); |
9061 | 9061 | ||
9062 | intel_fbc_update(dev); | 9062 | intel_fbc_update(dev); |
9063 | 9063 | ||
@@ -9760,7 +9760,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, | |||
9760 | 9760 | ||
9761 | work->event = event; | 9761 | work->event = event; |
9762 | work->crtc = crtc; | 9762 | work->crtc = crtc; |
9763 | work->old_fb_obj = intel_fb_obj(old_fb); | 9763 | work->old_fb = old_fb; |
9764 | INIT_WORK(&work->work, intel_unpin_work_fn); | 9764 | INIT_WORK(&work->work, intel_unpin_work_fn); |
9765 | 9765 | ||
9766 | ret = drm_crtc_vblank_get(crtc); | 9766 | ret = drm_crtc_vblank_get(crtc); |
@@ -9796,7 +9796,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, | |||
9796 | goto cleanup; | 9796 | goto cleanup; |
9797 | 9797 | ||
9798 | /* Reference the objects for the scheduled work. */ | 9798 | /* Reference the objects for the scheduled work. */ |
9799 | drm_gem_object_reference(&work->old_fb_obj->base); | 9799 | drm_framebuffer_reference(work->old_fb); |
9800 | drm_gem_object_reference(&obj->base); | 9800 | drm_gem_object_reference(&obj->base); |
9801 | 9801 | ||
9802 | crtc->primary->fb = fb; | 9802 | crtc->primary->fb = fb; |
@@ -9818,7 +9818,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, | |||
9818 | 9818 | ||
9819 | if (IS_VALLEYVIEW(dev)) { | 9819 | if (IS_VALLEYVIEW(dev)) { |
9820 | ring = &dev_priv->ring[BCS]; | 9820 | 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) |
9822 | /* vlv: DISPLAY_FLIP fails to change tiling */ | 9822 | /* vlv: DISPLAY_FLIP fails to change tiling */ |
9823 | ring = NULL; | 9823 | ring = NULL; |
9824 | } else if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev)) { | 9824 | } else if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev)) { |
@@ -9859,7 +9859,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, | |||
9859 | work->flip_queued_vblank = drm_vblank_count(dev, intel_crtc->pipe); | 9859 | work->flip_queued_vblank = drm_vblank_count(dev, intel_crtc->pipe); |
9860 | work->enable_stall_check = true; | 9860 | work->enable_stall_check = true; |
9861 | 9861 | ||
9862 | i915_gem_track_fb(work->old_fb_obj, obj, | 9862 | i915_gem_track_fb(intel_fb_obj(work->old_fb), obj, |
9863 | INTEL_FRONTBUFFER_PRIMARY(pipe)); | 9863 | INTEL_FRONTBUFFER_PRIMARY(pipe)); |
9864 | 9864 | ||
9865 | intel_fbc_disable(dev); | 9865 | intel_fbc_disable(dev); |
@@ -9875,7 +9875,7 @@ cleanup_unpin: | |||
9875 | cleanup_pending: | 9875 | cleanup_pending: |
9876 | atomic_dec(&intel_crtc->unpin_work_count); | 9876 | atomic_dec(&intel_crtc->unpin_work_count); |
9877 | crtc->primary->fb = old_fb; | 9877 | crtc->primary->fb = old_fb; |
9878 | drm_gem_object_unreference(&work->old_fb_obj->base); | 9878 | drm_framebuffer_unreference(work->old_fb); |
9879 | drm_gem_object_unreference(&obj->base); | 9879 | drm_gem_object_unreference(&obj->base); |
9880 | mutex_unlock(&dev->struct_mutex); | 9880 | mutex_unlock(&dev->struct_mutex); |
9881 | 9881 | ||
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index eef79ccd0b7c..f048f8bb8beb 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h | |||
@@ -710,7 +710,7 @@ intel_get_crtc_for_plane(struct drm_device *dev, int plane) | |||
710 | struct intel_unpin_work { | 710 | struct intel_unpin_work { |
711 | struct work_struct work; | 711 | struct work_struct work; |
712 | struct drm_crtc *crtc; | 712 | struct drm_crtc *crtc; |
713 | struct drm_i915_gem_object *old_fb_obj; | 713 | struct drm_framebuffer *old_fb; |
714 | struct drm_i915_gem_object *pending_flip_obj; | 714 | struct drm_i915_gem_object *pending_flip_obj; |
715 | struct drm_pending_vblank_event *event; | 715 | struct drm_pending_vblank_event *event; |
716 | atomic_t pending; | 716 | atomic_t pending; |