RFC: duct-tape for the gpu reset vs. modeset deadlock
Subsystems (3)
cover RFC: duct-tape for the gpu reset vs. modeset deadlock
Hi all,
Here's my patch series to unbreak the gpu reset vs. modeset deadlock.
First things first: This needs Maarten's swap_state series, otherwise the atomic commit machinery will sooner or later shoot itself, keel over and take the entire kernel with it.
There's two important bits in here:
- Reduce the scope of modeset locking, we accidentally encumbered all platforms with this problem instead of just pre-g4x (and igt testing in special test-only modes).
- Decouple the TDR from the atomic machinery. I've done this in 2 stage, first explicit wedge at the right spot, as a proof of concept and for testing. Then refine that hammer into just unbreaking the depency and so making sure TDR can do it's thing everywhere.
Seems to all work, but definitely needs more testing.
The only glitch left now is that on affected platforms you might spot a short glitch until TDR has done its thing and rendering and atomic are in lockstep again.
Cheers, Daniel
Daniel Vetter (7):
drm/i915: Nuke legacy flip queueing code
drm/i915: Unbreak gpu reset vs. modeset locking drm/atomic-helper: add sync_all helper for gpu reset drm/i915: only disable outputs in simulated gpu resets drm/i915: Avoid the gpu reset vs. modeset deadlock drm/i915: Push i915_sw_fence_wait into the nonblocking atomic commit drm/i915: More surgically unbreak the modeset vs reset deadlock
drivers/gpu/drm/drm_atomic_helper.c | 38 ++ drivers/gpu/drm/i915/i915_drv.h | 6 +- drivers/gpu/drm/i915/intel_display.c | 768 +++-------------------------------- include/drm/drm_atomic_helper.h | 1 + 4 files changed, 100 insertions(+), 713 deletions(-)
Signature · 6 lines
2.13.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/7 drm/i915: Nuke legacy flip queueing code
Just a very minimal patch to nuke that code. Lots of the flip interrupt handling stuff is still around.
--- drivers/gpu/drm/i915/i915_drv.h | 5 - drivers/gpu/drm/i915/intel_display.c | 656 ----------------------------------- 2 files changed, 661 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -5
@@ -715,11 +715,6 @@ struct drm_i915_display_funcs {void (*fdi_link_train)(struct intel_crtc *crtc,const struct intel_crtc_state *crtc_state);void (*init_clock_gating)(struct drm_i915_private *dev_priv); -int (*queue_flip)(struct drm_device *dev,struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_i915_gem_object *obj, -struct drm_i915_gem_request *req, -uint32_t flags);void (*hpd_irq_setup)(struct drm_i915_private *dev_priv);/* clock updates for mode set */ /* cursor updates */
drivers/gpu/drm/i915/intel_display.c +0 -656
686 lines not on this page · raw message
Signature · 6 lines
2.13.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/7 drm/i915: Unbreak gpu reset vs. modeset locking
In reply to Daniel VetterTaking the modeset locks unconditionally isn't the greatest idea, because atm that part is still broken and times out (and then atomic keels over). And there's really no reason to do so, the old code didn't do that either.
To make the patch a bit simpler let's also nuke 2 cases that are only around for the old mmioflip paths. Atomic nonblocking workers will not die (minus bugs) when a gpu reset happens.
And of course this doesn't fix any of the gpu reset vs. modeset deadlock fun, but it at least stop modern CI machines from keeling over all over the place for no reason at all.
And we still have the explicit testcases to run the fake gpu reset, so coverage isn't that much worse.
v2: Split out additional changes on top, restrict this to purely reducing the critical section of modeset locks.
--- drivers/gpu/drm/i915/intel_display.c | 53 +++++++++--------------------------- 1 file changed, 13 insertions(+), 40 deletions(-)
drivers/gpu/drm/i915/intel_display.c +13 -40
@@ -3413,26 +3413,6 @@ static void intel_complete_page_flips(struct drm_i915_private *dev_priv)intel_finish_page_flip_cs (dev_priv, crtc->pipe); } -static void intel_update_primary_planes (struct drm_device *dev) -{ -struct drm_crtc *crtc; - -for_each_crtc (dev, crtc) { -struct intel_plane *plane =to_intel_plane (crtc->primary); -struct intel_plane_state *plane_state = -to_intel_plane_state (plane->base.state); - -if (plane_state->base.visible) { -trace_intel_update_plane (&plane->base, -to_intel_crtc (crtc)); - - plane->update_plane (plane, -to_intel_crtc_state (crtc->state), - plane_state); - } - } -} - static int __intel_display_resume(struct drm_device *dev, struct drm_atomic_state *state,
@@ -3485,6 +3465,12 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv)struct drm_atomic_state *state;int ret; + +/* reset doesn't touch the display, but flips might get nuked anyway, */ +if (!i915.force_reset_modeset_test && + !gpu_reset_clobbers_display (dev_priv)) +return ; +/* * Need mode_config.mutex so that we don't * trample ongoing ->detect() and whatnot.
@@ -3498,12 +3484,6 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv)drm_modeset_backoff (ctx); } - -/* reset doesn't touch the display, but flips might get nuked anyway, */ -if (!i915.force_reset_modeset_test && - !gpu_reset_clobbers_display (dev_priv)) -return ; -/* * Disabling the crtcs gracefully seems nicer. Also the * g33 docs say we should at least disable all the planes.
@@ -3533,6 +3513,11 @@ void intel_finish_reset(struct drm_i915_private *dev_priv)struct drm_atomic_state *state = dev_priv->modeset_restore_state;int ret; +/* reset doesn't touch the display, but flips might get nuked anyway, */ +if (!i915.force_reset_modeset_test && + !gpu_reset_clobbers_display (dev_priv)) +return ; +/* * Flips in the rings will be nuked by the reset, * so complete all pending flips so that user space
@@ -3544,22 +3529,10 @@ void intel_finish_reset(struct drm_i915_private *dev_priv)/* reset doesn't touch the display */ if (!gpu_reset_clobbers_display (dev_priv)) { -if (!state) { -/* -* Flips in the rings have been nuked by the reset, -* so update the base address of all primary -* planes to the the last fb to make sure we're -* showing the correct fb after a reset. -* -* FIXME: Atomic will make this obsolete since we won't schedule -* CS-based flips (which might get lost in gpu resets) any more. -*/ -intel_update_primary_planes (dev); - }else { - ret =__intel_display_resume (dev, state, ctx); +/* for testing only restore the display */ + ret =__intel_display_resume (dev, state, ctx);if (ret)DRM_ERROR ("Restoring old state failed with %i\n" , ret); - } }else {/* * The display has been reset as well,
Signature · 6 lines
2.13.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/7] drm/i915: Unbreak gpu reset vs. modeset locking
Op 15-07-17 om 13:40 schreef Daniel Vetter:
Quoted 59 lines
Taking the modeset locks unconditionally isn't the greatest idea, because atm that part is still broken and times out (and then atomic keels over). And there's really no reason to do so, the old code didn't do that either.
To make the patch a bit simpler let's also nuke 2 cases that are only around for the old mmioflip paths. Atomic nonblocking workers will not die (minus bugs) when a gpu reset happens.
And of course this doesn't fix any of the gpu reset vs. modeset deadlock fun, but it at least stop modern CI machines from keeling over all over the place for no reason at all.
And we still have the explicit testcases to run the fake gpu reset, so coverage isn't that much worse.
v2: Split out additional changes on top, restrict this to purely reducing the critical section of modeset locks.
Fixes 739748939974 ("drm/i915: Fix modeset handling during gpu reset, v5.")Cc Maarten Lankhorst <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 53 +++++++++--------------------------- 1 file changed, 13 insertions(+), 40 deletions(-)drivers/gpu/drm/i915/intel_display.c +0
-20@@ -3413,26 +3413,6 @@ static void intel_complete_page_flips(struct drm_i915_private *dev_priv)intel_finish_page_flip_cs (dev_priv, crtc->pipe); } -static void intel_update_primary_planes (struct drm_device *dev) -{ -struct drm_crtc *crtc; - -for_each_crtc (dev, crtc) { -struct intel_plane *plane =to_intel_plane (crtc->primary); -struct intel_plane_state *plane_state = -to_intel_plane_state (plane->base.state); - -if (plane_state->base.visible) { -trace_intel_update_plane (&plane->base, -to_intel_crtc (crtc)); - - plane->update_plane (plane, -to_intel_crtc_state (crtc->state), - plane_state); - } - } -} - static int __intel_display_resume(struct drm_device *dev, struct drm_atomic_state *state,
drivers/gpu/drm/i915/intel_display.c void intel_prepare_reset(struct drm_i915_private *dev_priv) · line 3469
Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +2
-0@@ -3485,6 +3465,12 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv)struct drm_atomic_state *state;int ret; + +/* reset doesn't touch the display, but flips might get nuked anyway, */
I think this comment was meant to address the reasoning for taking all locks, so the part about flips being nuked no longer applies with mmio flips gone.
Quoted 21 lines
drivers/gpu/drm/i915/intel_display.c +4
-6+if (!i915.force_reset_modeset_test && + !gpu_reset_clobbers_display (dev_priv)) +return ; +/* * Need mode_config.mutex so that we don't * trample ongoing ->detect() and whatnot. @@ -3498,12 +3484,6 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv)drm_modeset_backoff (ctx); } - -/* reset doesn't touch the display, but flips might get nuked anyway, */ -if (!i915.force_reset_modeset_test && - !gpu_reset_clobbers_display (dev_priv)) -return ; -/* * Disabling the crtcs gracefully seems nicer. Also the * g33 docs say we should at least disable all the planes.
drivers/gpu/drm/i915/intel_display.c void intel_finish_reset(struct drm_i915_private *dev_priv) · line 3519
Quoted 7 lines
drivers/gpu/drm/i915/intel_display.c +4
-0@@ -3533,6 +3513,11 @@ void intel_finish_reset(struct drm_i915_private *dev_priv)struct drm_atomic_state *state = dev_priv->modeset_restore_state;int ret; +/* reset doesn't touch the display, but flips might get nuked anyway, */ +if (!i915.force_reset_modeset_test && + !gpu_reset_clobbers_display (dev_priv)) +return ;
Same thing about comment here. Perhaps change the
if (!i915.force_reset_modeset_test && !gpu_reset_clobbers_display())
to
if (!state && !gpu_reset_clobbers_display())
so we don't run into a kernel panic if we change the parameter during reset?
Hm perhaps also either add if (state) to the __intel_display_resume call for <g4x, or remove the one for drm_atomic_state_put.
With those changes I'm happy, and you can add
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/7 drm/atomic-helper: add sync_all helper for gpu reset
In reply to Daniel Vetteri915 needs this.
--- drivers/gpu/drm/drm_atomic_helper.c | 38 +++++++++++++++++++++++++++++++++++++ include/drm/drm_atomic_helper.h | 1 + 2 files changed, 39 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +38 -0
@@ -1763,6 +1763,44 @@ static struct drm_crtc_commit *preceeding_commit(struct drm_crtc *crtc) }/** +* drm_atomic_helper_sync_all - synchronize with all pending nonblocking commits +* @dev: DRM device +* +* This function synchronizes with all pending atomic commits using the +* nonblocking helpers (see drm_atomic_helper_setup_commit()) up to the point +* where all hardware commits are completed (as signalled using +* drm_atomic_helper_commit_hw_done(). +* +* This is useful you need to synchronize with all nonblocking comits, but do +* not want to or cannot do a full atomic commit touching all CRTC. All CRTC +* looks must be held to prevent a concurrent thread from queuing yet another +* update. Drivers can use this for e.g. their gpu reset handling, when a gpu +* reset also affects the display block. +*/ +void drm_atomic_helper_sync_all (struct drm_device *dev) +{ +struct drm_crtc *crtc; +struct drm_crtc_commit *commit; + +drm_for_each_crtc (crtc, dev) { +spin_lock (&crtc->commit_lock); + commit =list_first_entry_or_null (&crtc->commit_list, + struct drm_crtc_commit, commit_entry); +if (commit) +drm_crtc_commit_get (commit); +spin_unlock (&crtc->commit_lock); + +if (!commit) +continue ; + +wait_for_completion (&commit->hw_done); + +drm_crtc_commit_put (commit); + } +} +EXPORT_SYMBOL (drm_atomic_helper_sync_all); + +/** * drm_atomic_helper_wait_for_dependencies - wait for required preceeding commits * @old_state: atomic state object with old state structures *
include/drm/drm_atomic_helper.h +1 -0
@@ -92,6 +92,7 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,/* nonblocking commit helpers */ int drm_atomic_helper_setup_commit (struct drm_atomic_state *state,bool nonblock); +void drm_atomic_helper_sync_all (struct drm_device *dev);void drm_atomic_helper_wait_for_dependencies (struct drm_atomic_state *state);void drm_atomic_helper_commit_hw_done (struct drm_atomic_state *state);void drm_atomic_helper_commit_cleanup_done (struct drm_atomic_state *state);
Signature · 6 lines
2.13.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/7] drm/atomic-helper: add sync_all helper for gpu reset
Quoted 17 lines · Daniel Vetter
i915 needs this.
Cc Maarten Lankhorst <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 38 +++++++++++++++++++++++++++++++++++++ include/drm/drm_atomic_helper.h | 1 + 2 files changed, 39 insertions(+)drivers/gpu/drm/drm_atomic_helper.c +0
-0@@ -1763,6 +1763,44 @@ static struct drm_crtc_commit *preceeding_commit(struct drm_crtc *crtc) }
drivers/gpu/drm/drm_atomic_helper.c static struct drm_crtc_commit *preceeding_commit(struct drm_crtc *crtc) · line 1774
Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +9
-0/** +* drm_atomic_helper_sync_all - synchronize with all pending nonblocking commits +* @dev: DRM device +* +* This function synchronizes with all pending atomic commits using the +* nonblocking helpers (see drm_atomic_helper_setup_commit()) up to the point +* where all hardware commits are completed (as signalled using +* drm_atomic_helper_commit_hw_done(). +* +* This is useful you need to synchronize with all nonblocking comits, but do
s/comits/commits
drivers/gpu/drm/drm_atomic_helper.c static struct drm_crtc_commit *preceeding_commit(struct drm_crtc *crtc) · line 1776
Quoted 2 lines
drivers/gpu/drm/drm_atomic_helper.c +2
-0+* not want to or cannot do a full atomic commit touching all CRTC. All CRTC +* looks must be held to prevent a concurrent thread from queuing yet another
s/looks/locks
Quoted 15 lines
drivers/gpu/drm/drm_atomic_helper.c +15
-0+* update. Drivers can use this for e.g. their gpu reset handling, when a gpu +* reset also affects the display block. +*/ +void drm_atomic_helper_sync_all (struct drm_device *dev) +{ +struct drm_crtc *crtc; +struct drm_crtc_commit *commit; + +drm_for_each_crtc (crtc, dev) { +spin_lock (&crtc->commit_lock); + commit =list_first_entry_or_null (&crtc->commit_list, + struct drm_crtc_commit, commit_entry); +if (commit) +drm_crtc_commit_get (commit); +spin_unlock (&crtc->commit_lock);
drivers/gpu/drm/drm_atomic_helper.c static struct drm_crtc_commit *preceeding_commit(struct drm_crtc *crtc) · line 1801
Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10
-0+ +if (!commit) +continue ; + +wait_for_completion (&commit->hw_done); + +drm_crtc_commit_put (commit); + } +} +EXPORT_SYMBOL (drm_atomic_helper_sync_all);
Quoted 24 lines
drivers/gpu/drm/drm_atomic_helper.c +2
-0+ +/** * drm_atomic_helper_wait_for_dependencies - wait for required preceeding commits * @old_state: atomic state object with old state structures * include/drm/drm_atomic_helper.h +1
-0@@ -92,6 +92,7 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,/* nonblocking commit helpers */ int drm_atomic_helper_setup_commit (struct drm_atomic_state *state,bool nonblock); +void drm_atomic_helper_sync_all (struct drm_device *dev);void drm_atomic_helper_wait_for_dependencies (struct drm_atomic_state *state);void drm_atomic_helper_commit_hw_done (struct drm_atomic_state *state);void drm_atomic_helper_commit_cleanup_done (struct drm_atomic_state *state);Signature · 6 lines
2.13.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/7 drm/i915: only disable outputs in simulated gpu resets
In reply to Daniel VetterFor the old chips where the reset also kills the display we don't need to do this, it all goes down on its own. We only need to do this for gpu resets where the interaction with the display side is simulated.
This means we're not 100% faithful with what we test, but there's a big pile of other small differences (like having to restore interrupts and hpd handling and everything else).
Doing that means we don't have a full commit to synchronize with all outstanding changes, so use the new helper to do that instead.
--- drivers/gpu/drm/i915/intel_display.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_display.c +11 -5
@@ -3484,6 +3484,8 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv)drm_modeset_backoff (ctx); } +drm_atomic_helper_sync_all (dev); +/* * Disabling the crtcs gracefully seems nicer. Also the * g33 docs say we should at least disable all the planes.
@@ -3495,11 +3497,15 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv)return ; } - ret =drm_atomic_helper_disable_all (dev, ctx); -if (ret) { -DRM_ERROR ("Suspending crtc's failed with %i\n" , ret); -drm_atomic_state_put (state); -return ; +/* only when we test this through force_reset_modeset_test shut down the +* entire display manually. For hw where gpu reset kills the display +* this happens automatically. This avoids unecessary trouble with +* double-commit. +*/ +if (!gpu_reset_clobbers_display (dev_priv)) { + ret =drm_atomic_helper_disable_all (dev, ctx); +if (ret) +DRM_ERROR ("Suspending crtc's failed with %i\n" , ret); } dev_priv->modeset_restore_state = state;
Signature · 6 lines
2.13.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/7 drm/i915: Avoid the gpu reset vs. modeset deadlock
In reply to Daniel Vetter... using the biggest hammer we have. This is essentially a weaponized version of the timeout-based wedging Chris added in
commit 36703e79a982c8ce5a8e43833291f2719e92d0d1
Author: Chris Wilson <[email protected]> Date: Thu Jun 22 11:56:25 2017 +0100
drm/i915: Break modeset deadlocks on reset
Because defense-in-depth is good it's good to still have both. Also note that with the locking change we can now restrict this a lot (old gpus and special testing only), so this doesn't kill the TDR benefits on at least anything remotely modern.
And futuremore with a few tricks it should be possible to make a much more educated guess about whether an atomic commit is stuck waiting on the gpu (atomic_t counting the pending i915_sw_fence used by the atomic modeset code should do it), so we can improve this.
But for now just start with something that is guaranteed to recover faster, for much better CI througput.
This defacto reverts TDR on these platforms, but there's not really a single commit to specify as the sole offender.
--- drivers/gpu/drm/i915/intel_display.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/intel_display.c +5 -0
@@ -3471,6 +3471,11 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv) !gpu_reset_clobbers_display(dev_priv))return ; +/* We have a modeset vs reset deadlock, defensively unbreak it. +* +* FIXME: We can do a _lot_ better, this is just a first iteration.*/ +i915_gem_set_wedged (dev_priv); +/* * Need mode_config.mutex so that we don't * trample ongoing ->detect() and whatnot.
Signature · 6 lines
2.13.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/7 drm/i915: Push i915_sw_fence_wait into the nonblocking atomic commit
In reply to Daniel VetterBlocking in a worker is ok, that's what the unbound_wq is for. And it unifies the paths between the blocking and nonblocking commit, giving me just one path where I have to implement the deadlock avoidance trickery in the next patch.
--- drivers/gpu/drm/i915/intel_display.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_display.c +7 -8
@@ -12390,6 +12390,8 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)unsigned crtc_vblank_mask =0 ;int i; +i915_sw_fence_wait (&intel_state->commit_ready); +drm_atomic_helper_wait_for_dependencies (state);if (intel_state->modeset)
@@ -12557,10 +12559,7 @@ intel_atomic_commit_ready(struct i915_sw_fence *fence,switch (notify) {case FENCE_COMPLETE : -if (state->base.commit_work.func) -queue_work (system_unbound_wq, &state->base.commit_work);break ; -case FENCE_FREE : { struct intel_atomic_helper *helper =
@@ -12656,14 +12655,14 @@ static int intel_atomic_commit(struct drm_device *dev, }drm_atomic_state_get (state); -INIT_WORK (&state->commit_work, - nonblock ? intel_atomic_commit_work :NULL ); +INIT_WORK (&state->commit_work, intel_atomic_commit_work);i915_sw_fence_commit (&intel_state->commit_ready); -if (!nonblock) { -i915_sw_fence_wait (&intel_state->commit_ready); +if (nonblock) +queue_work (system_unbound_wq, &state->commit_work); +else intel_atomic_commit_tail (state); - } +return 0 ; }
Signature · 6 lines
2.13.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/7 drm/i915: More surgically unbreak the modeset vs reset deadlock
In reply to Daniel VetterThere's no reason to entirely wedge the gpu, for the minimal deadlock bugfix we only need to unbreak/decouple the atomic commit from the gpu reset. The simplest wait to fix that is by replacing the unconditional fence wait a the top of commit_tail by a wait which completes either when the fences are done (normal case, or when a reset doesn't need to touch the display state). Or when the gpu reset needs to force-unblock all pending modeset states.
Note that in both cases TDR itself keeps working, so from a userspace pov this trickery isn't observable. Users themselvs might spot a short glitch while the rendering is catching up again, but that's still better than pre-TDR where we've thrown away all the rendering, including innocent batches. Also, this fixes the regression TDR introduced of making gpu resets deadlock-prone when we do need to touch the display.
One thing I noticed is that gpu_error.flags seems to use both our own wait-queue in gpu_error.wait_queue, and the generic wait_on_bit facilities. Not entirely sure why this inconsistency exists, I just picked one style.
A possible future avenue could be to insert the gpu reset in-between ongoing modeset changes, which would avoid the momentary glitch. But that's a lot more work to implement in the atomic commit machinery, and given that we only need this for pre-g4x hw, of questionable utility just for the sake of polishing gpu reset even more on those old boxes. It might be useful for other features though.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -1564,6 +1564,7 @@ struct i915_gpu_error {unsigned long flags;#define I915_RESET_BACKOFF 0#define I915_RESET_HANDOFF 1 +#define I915_RESET_MODESET 2#define I915_WEDGED (BITS_PER_LONG - 1)#define I915_RESET_ENGINE (I915_WEDGED - I915_NUM_ENGINES)
drivers/gpu/drm/i915/intel_display.c +30 -5
@@ -3471,10 +3471,9 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv) !gpu_reset_clobbers_display(dev_priv))return ; -/* We have a modeset vs reset deadlock, defensively unbreak it. -* -* FIXME: We can do a _lot_ better, this is just a first iteration.*/ -i915_gem_set_wedged (dev_priv); +/* We have a modeset vs reset deadlock, defensively unbreak it. */ +set_bit (I915_RESET_MODESET , &dev_priv->gpu_error.flags); +wake_up_all (&dev_priv->gpu_error.wait_queue);/* * Need mode_config.mutex so that we don't
@@ -3572,6 +3571,8 @@ void intel_finish_reset(struct drm_i915_private *dev_priv)drm_modeset_drop_locks (ctx);drm_modeset_acquire_fini (ctx);mutex_unlock (&dev->mode_config.mutex); + +clear_bit (I915_RESET_MODESET , &dev_priv->gpu_error.flags); }static bool abort_flip_on_reset (struct intel_crtc *crtc)
@@ -12377,6 +12378,30 @@ static void intel_atomic_helper_free_state_worker(struct work_struct *work)intel_atomic_helper_free_state (dev_priv); } +static void intel_atomic_commit_fence_wait (struct intel_atomic_state *intel_state) +{ +wait_queue_t wait_fence, wait_reset; +struct drm_i915_private *dev_priv =to_i915 (intel_state->base.dev); + +init_wait_entry (&wait_fence,0 ); +init_wait_entry (&wait_reset,0 ); +for (;;) { +prepare_to_wait (&intel_state->commit_ready.wait, + &wait_fence,TASK_UNINTERRUPTIBLE ); +prepare_to_wait (&dev_priv->gpu_error.wait_queue, + &wait_reset,TASK_UNINTERRUPTIBLE ); + + +if (i915_sw_fence_done (&intel_state->commit_ready) + || (dev_priv->gpu_error.flags &I915_RESET_MODESET )) +break ; + +schedule (); + } +finish_wait (&intel_state->commit_ready.wait, &wait_fence); +finish_wait (&dev_priv->gpu_error.wait_queue, &wait_reset); +} +static void intel_atomic_commit_tail (struct drm_atomic_state *state) {struct drm_device *dev = state->dev;
@@ -12390,7 +12415,7 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)unsigned crtc_vblank_mask =0 ;int i; -i915_sw_fence_wait (&intel_state->commit_ready); +intel_atomic_commit_fence_wait (intel_state);drm_atomic_helper_wait_for_dependencies (state);
Signature · 6 lines
2.13.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: warning for RFC: duct-tape for the gpu reset vs. modeset deadlock
In reply to Daniel Vetter== Series Details ==
== Series Details ==
Series: RFC: duct-tape for the gpu reset vs. modeset deadlock
URL : https://patchwork.freedesktop.org/series/27345/
State : warning
== Summary ==
Series 27345v1 RFC: duct-tape for the gpu reset vs. modeset deadlock
https://patchwork.freedesktop.org/api/1.0/series/27345/revisions/1/mbox/
Test drv_hangman:
Subgroup error-state-basic:
pass -> DMESG-WARN (fi-blb-e6850)
pass -> DMESG-WARN (fi-pnv-d510)
Test gem_busy:
Subgroup basic-hang-default:
pass -> DMESG-WARN (fi-blb-e6850)
pass -> DMESG-WARN (fi-pnv-d510)
Test gem_exec_fence:
Subgroup await-hang-default:
pass -> DMESG-WARN (fi-blb-e6850)
pass -> DMESG-WARN (fi-pnv-d510)
Test gem_exec_flush:
Subgroup basic-batch-kernel-default-uc:
fail -> PASS (fi-snb-2600) fdo#100007
Test kms_pipe_crc_basic:
Subgroup hang-read-crc-pipe-a:
pass -> DMESG-WARN (fi-pnv-d510) fdo#101597
Subgroup suspend-read-crc-pipe-b:
pass -> DMESG-WARN (fi-byt-j1900) fdo#101705fdo#100007 https://bugs.freedesktop.org/show_bug.cgi?id=100007
fdo#101597 https://bugs.freedesktop.org/show_bug.cgi?id=101597
fdo#101705 https://bugs.freedesktop.org/show_bug.cgi?id=101705
fi-bdw-5557u total:279 pass:268 dwarn:0 dfail:0 fail:0 skip:11 time:437s fi-bdw-gvtdvm total:279 pass:265 dwarn:0 dfail:0 fail:0 skip:14 time:429s fi-blb-e6850 total:279 pass:221 dwarn:4 dfail:0 fail:0 skip:54 time:354s fi-bsw-n3050 total:279 pass:243 dwarn:0 dfail:0 fail:0 skip:36 time:531s fi-bxt-j4205 total:279 pass:260 dwarn:0 dfail:0 fail:0 skip:19 time:518s fi-byt-j1900 total:279 pass:254 dwarn:1 dfail:0 fail:0 skip:24 time:493s fi-byt-n2820 total:279 pass:250 dwarn:1 dfail:0 fail:0 skip:28 time:479s fi-glk-2a total:279 pass:260 dwarn:0 dfail:0 fail:0 skip:19 time:601s fi-hsw-4770 total:279 pass:263 dwarn:0 dfail:0 fail:0 skip:16 time:435s fi-hsw-4770r total:279 pass:263 dwarn:0 dfail:0 fail:0 skip:16 time:411s fi-ilk-650 total:279 pass:229 dwarn:0 dfail:0 fail:0 skip:50 time:421s fi-ivb-3520m total:279 pass:261 dwarn:0 dfail:0 fail:0 skip:18 time:499s fi-ivb-3770 total:279 pass:261 dwarn:0 dfail:0 fail:0 skip:18 time:475s fi-kbl-7500u total:279 pass:261 dwarn:0 dfail:0 fail:0 skip:18 time:471s fi-kbl-7560u total:279 pass:269 dwarn:0 dfail:0 fail:0 skip:10 time:577s fi-kbl-r total:279 pass:260 dwarn:1 dfail:0 fail:0 skip:18 time:584s fi-pnv-d510 total:279 pass:219 dwarn:5 dfail:0 fail:0 skip:55 time:564s fi-skl-6260u total:279 pass:269 dwarn:0 dfail:0 fail:0 skip:10 time:464s fi-skl-6700hq total:279 pass:262 dwarn:0 dfail:0 fail:0 skip:17 time:586s fi-skl-6700k total:279 pass:257 dwarn:4 dfail:0 fail:0 skip:18 time:475s fi-skl-6770hq total:279 pass:269 dwarn:0 dfail:0 fail:0 skip:10 time:484s fi-skl-gvtdvm total:279 pass:266 dwarn:0 dfail:0 fail:0 skip:13 time:432s fi-skl-x1585l total:279 pass:268 dwarn:0 dfail:0 fail:0 skip:11 time:474s fi-snb-2520m total:279 pass:251 dwarn:0 dfail:0 fail:0 skip:28 time:546s fi-snb-2600 total:279 pass:250 dwarn:0 dfail:0 fail:0 skip:29 time:403s
bd5641a8649223257233c4e1c45fc94abec1cdbe drm-tip: 2017y-07m-14d-19h-18m-56s UTC integration manifest a9fddee drm/i915: More surgically unbreak the modeset vs reset deadlock
9bf2209 drm/i915: Push i915_sw_fence_wait into the nonblocking atomic commit
4c27139 drm/i915: Avoid the gpu reset vs. modeset deadlock
1bd5c02 drm/i915: only disable outputs in simulated gpu resets
ad9cbab drm/atomic-helper: add sync_all helper for gpu reset
8e0c068 drm/i915: Unbreak gpu reset vs. modeset locking
78406cd drm/i915: Nuke legacy flip queueing code
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_5202/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: ✗ Fi.CI.BAT: warning for RFC: duct-tape for the gpu reset vs. modeset deadlock
Quoted 12 lines · Patchwork
== Series Details ==
Series: RFC: duct-tape for the gpu reset vs. modeset deadlock
URL : https://patchwork.freedesktop.org/series/27345/
State : warning== Summary ==
Series 27345v1 RFC: duct-tape for the gpu reset vs. modeset deadlock
https://patchwork.freedesktop.org/api/1.0/series/27345/revisions/1/mbox/Test
drv_hangman:
Quoted 11 lines
Subgroup error-state-basic:
pass -> DMESG-WARN (fi-blb-e6850)
pass -> DMESG-WARN (fi-pnv-d510)
Test gem_busy:
Subgroup basic-hang-default:
pass -> DMESG-WARN (fi-blb-e6850)
pass -> DMESG-WARN (fi-pnv-d510)
Test gem_exec_fence:
Subgroup await-hang-default:
pass -> DMESG-WARN (fi-blb-e6850)
pass -> DMESG-WARN (fi-pnv-d510)Looks like I wreaked something on gpus where the hw reset kills the display. I'll check it out.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: ✗ Fi.CI.BAT: warning for RFC: duct-tape for the gpu reset vs. modeset deadlock
Quoted 26 lines · Daniel Vetter
Quoted 12 lines · Patchwork
== Series Details ==
Series: RFC: duct-tape for the gpu reset vs. modeset deadlock
URL : https://patchwork.freedesktop.org/series/27345/
State : warning== Summary ==
Series 27345v1 RFC: duct-tape for the gpu reset vs. modeset deadlock
https://patchwork.freedesktop.org/api/1.0/series/27345/revisions/1/mbox/Test
drv_hangman:Quoted 11 lines
Subgroup error-state-basic: pass -> DMESG-WARN (fi-blb-e6850) pass -> DMESG-WARN (fi-pnv-d510) Test gem_busy: Subgroup basic-hang-default: pass -> DMESG-WARN (fi-blb-e6850) pass -> DMESG-WARN (fi-pnv-d510) Test gem_exec_fence: Subgroup await-hang-default: pass -> DMESG-WARN (fi-blb-e6850) pass -> DMESG-WARN (fi-pnv-d510)
Quoted 2 lines
Looks like I wreaked something on gpus where the hw reset kills the display. I'll check it out.
Ok, simplest solution seems to be to just not do the special casing between real hw reset and fake reset, and unconditionally shut down all the CRTC. Probably a lot more than just the power domain tracking will get out of whack. I wasn't really sold on that idea either way, so I'll drop both "drm/i915: only disable outputs in simulated gpu resets" and "drm/atomic-helper: add sync_all helper for gpu reset" from the series. They're not needed really anyway.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: ✗ Fi.CI.BAT: warning for RFC: duct-tape for the gpu reset vs. modeset deadlock
Op 15-07-17 om 15:45 schreef Daniel Vetter:
Quoted 28 lines · Daniel Vetter
Quoted 25 lines
Quoted 12 lines · Patchwork
== Series Details ==
Series: RFC: duct-tape for the gpu reset vs. modeset deadlock
URL : https://patchwork.freedesktop.org/series/27345/
State : warning== Summary ==
Series 27345v1 RFC: duct-tape for the gpu reset vs. modeset deadlock
https://patchwork.freedesktop.org/api/1.0/series/27345/revisions/1/mbox/Test
drv_hangman:Quoted 11 lines
Subgroup error-state-basic: pass -> DMESG-WARN (fi-blb-e6850) pass -> DMESG-WARN (fi-pnv-d510) Test gem_busy: Subgroup basic-hang-default: pass -> DMESG-WARN (fi-blb-e6850) pass -> DMESG-WARN (fi-pnv-d510) Test gem_exec_fence: Subgroup await-hang-default: pass -> DMESG-WARN (fi-blb-e6850) pass -> DMESG-WARN (fi-pnv-d510)Quoted 2 lines
Looks like I wreaked something on gpus where the hw reset kills the display. I'll check it out.
Quoted 8 lines
Ok, simplest solution seems to be to just not do the special casing between real hw reset and fake reset, and unconditionally shut down all the CRTC. Probably a lot more than just the power domain tracking will get out of whack. I wasn't really sold on that idea either way, so I'll drop both "drm/i915: only disable outputs in simulated gpu resets" and "drm/atomic-helper: add
sync_allhelper for gpu reset" from the series. They're not needed really anyway.
-Daniel
Agreed, sync_all helper should have been done by the disable_all call.
The thing I didn't like was that you didn't shut down the GPU unconditionally, but with that fixed series looks good. :) I like patch 6/7, it makes everything more clear.
I'm not sure if calling prepare_to_wait twice is allowed, but don't see why not.
So with those taken out and feedback addressed.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx