drm/nouveau: Fix error handling in nv50_disp_atomic_commit
Subsystems (10)
PATCH 1/12 drm/nouveau: Fix error handling in nv50_disp_atomic_commit
Make it more clear that post commit return ret is really return 0,
and add a missing drm_atomic_helper_cleanup_planes when drm_atomic_helper_wait_for_fences fails.
--- drivers/gpu/drm/nouveau/nv50_display.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nv50_display.c +5 -2
@@ -4120,7 +4120,7 @@ nv50_disp_atomic_commit(struct drm_device *dev,if (!nonblock) { ret =drm_atomic_helper_wait_for_fences (dev, state, true);if (ret) - goto done; + goto err_cleanup; }for_each_plane_in_state (state, plane, plane_state, i) {
@@ -4148,7 +4148,7 @@ nv50_disp_atomic_commit(struct drm_device *dev,if (crtc->state->enable) {if (!drm->have_disp_power_ref) { drm->have_disp_power_ref = true; -return ret; +return 0 ; } active = true;break ;
@@ -4160,6 +4160,9 @@ nv50_disp_atomic_commit(struct drm_device *dev, drm->have_disp_power_ref = false; } +err_cleanup: +if (ret) +drm_atomic_helper_cleanup_planes (dev, state); done:pm_runtime_put_autosuspend (dev->dev);return ret;
Signature · 6 lines
2.11.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
Maarten Lankhorst
maintainerPATCH 2/12 drm/atomic: Change drm_atomic_helper_swap_state to return an error.
We want to change swap_state to wait indefinitely, but to do this swap_state should wait interruptibly. This requires propagating the error to each driver.
--- drivers/gpu/drm/drm_atomic_helper.c | 26 ++++++++++++++++++-------- include/drm/drm_atomic_helper.h | 3 +-- 2 files changed, 19 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +18 -8
@@ -1510,10 +1510,8 @@ int drm_atomic_helper_commit(struct drm_device *dev,if (!nonblock) { ret =drm_atomic_helper_wait_for_fences (dev, state, true); -if (ret) { -drm_atomic_helper_cleanup_planes (dev, state); -return ret; - } +if (ret) + goto err; }/*
@@ -1522,7 +1520,9 @@ int drm_atomic_helper_commit(struct drm_device *dev,* the software side now. */ -drm_atomic_helper_swap_state (state, true); + ret =drm_atomic_helper_swap_state (state, true); +if (ret) + goto err;/* * Everything below can be run asynchronously without the need to grab
@@ -1551,6 +1551,10 @@ int drm_atomic_helper_commit(struct drm_device *dev,commit_tail (state);return 0 ; + +err: +drm_atomic_helper_cleanup_planes (dev, state); +return ret; }EXPORT_SYMBOL (drm_atomic_helper_commit);
@@ -2228,14 +2232,14 @@ EXPORT_SYMBOL(drm_atomic_helper_cleanup_planes);/** * drm_atomic_helper_swap_state - store atomic state into current sw state * @state: atomic state -* @stall: stall for proceeding commits +* @stall: stall for preceeding commits * * This function stores the atomic state into the current state pointers in all * driver objects. It should be called after all failing steps have been done * and succeeded, but before the actual hardware state is committed. * * For cleanup and error recovery the current state for all changed objects will -* be swaped into @state. +* be swapped into @state. * * With that sequence it fits perfectly into the plane prepare/cleanup sequence: *
@@ -2254,8 +2258,12 @@ EXPORT_SYMBOL(drm_atomic_helper_cleanup_planes);* the &drm_plane.state, &drm_crtc.state or &drm_connector.state pointer. With * the current atomic helpers this is almost always the case, since the helpers * don't pass the right state structures to the callbacks. +* +* Returns: +* +* Always returns 0, cannot fail yet. */ -void drm_atomic_helper_swap_state (struct drm_atomic_state *state, +int drm_atomic_helper_swap_state (struct drm_atomic_state *state,bool stall) {int i;
@@ -2339,6 +2347,8 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state, state->private_objs[i].state = old_obj_state; obj->state = new_obj_state; } + +return 0 ; }EXPORT_SYMBOL (drm_atomic_helper_swap_state);
include/drm/drm_atomic_helper.h +1 -2
@@ -86,8 +86,7 @@ void drm_atomic_helper_disable_planes_on_crtc(struct drm_crtc_state *old_crtc_state, bool atomic); -void drm_atomic_helper_swap_state (struct drm_atomic_state *state, -bool stall); +int drm_atomic_helper_swap_state (struct drm_atomic_state *state,bool stall);/* nonblocking commit helpers */ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/12 drm/nouveau: Handle drm_atomic_helper_swap_state failure
In reply to a message not in the archivedrm_atomic_helper_swap_state() will be changed to interruptible waiting in the next few commits, so all drivers have to be changed to handling failure.
--- drivers/gpu/drm/nouveau/nv50_display.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nv50_display.c +4 -1
@@ -4123,6 +4123,10 @@ nv50_disp_atomic_commit(struct drm_device *dev, goto err_cleanup; } + ret =drm_atomic_helper_swap_state (state, true); +if (ret) + goto err_cleanup; +for_each_plane_in_state (state, plane, plane_state, i) {struct nv50_wndw_atom *asyw =nv50_wndw_atom (plane_state);struct nv50_wndw *wndw =nv50_wndw (plane);
@@ -4136,7 +4140,6 @@ nv50_disp_atomic_commit(struct drm_device *dev, } } -drm_atomic_helper_swap_state (state, true);drm_atomic_state_get (state);if (nonblock)
Signature · 6 lines
2.11.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
Maarten Lankhorst
maintainerPATCH 6/12 drm/mediatek: Handle drm_atomic_helper_swap_state failure
In reply to Maarten Lankhorstdrm_atomic_helper_swap_state() will be changed to interruptible waiting in the next few commits, so all drivers have to be changed to handling failure.
--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +6 -1
@@ -109,7 +109,12 @@ static int mtk_atomic_commit(struct drm_device *drm,mutex_lock (&private->commit.lock);flush_work (&private->commit.work); -drm_atomic_helper_swap_state (state, true); + ret =drm_atomic_helper_swap_state (state, true); +if (ret) { +mutex_unlock (&private->commit.lock); +drm_atomic_helper_cleanup_planes (drm, state); +return ret; + }drm_atomic_state_get (state);if (async)
Signature · 1 line
2.11.0
PATCH 7/12 drm/msm: Handle drm_atomic_helper_swap_state failure
In reply to a message not in the archivedrm_atomic_helper_swap_state() will be changed to interruptible waiting in the next few commits, so all drivers have to be changed to handling failure.
MSM has its own busy tracking, which means the swap_state call can be done with stall = false, in which case it should never return an error. Handle failure with BUG_ON for this reason.
--- drivers/gpu/drm/msm/msm_atomic.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/msm/msm_atomic.c +8 -8
@@ -232,20 +232,18 @@ int msm_atomic_commit(struct drm_device *dev,* mark our set of crtc's as busy: */ ret =start_atomic (dev->dev_private, c->crtc_mask); -if (ret) { -kfree (c); - goto error; - } +if (ret) + goto err_free; + +BUG_ON (drm_atomic_helper_swap_state (state, false) <0 );/* * This is the point of no return - everything below never fails except * when the hw goes bonghits. Which means we can commit the new state on * the software side now. +* +* swap driver private state while still holding state_lock */ - -drm_atomic_helper_swap_state (state, true); - -/* swap driver private state while still holding state_lock */ if (to_kms_state (state)->state) priv->kms->funcs->swap_state (priv->kms, state);
@@ -275,6 +273,8 @@ int msm_atomic_commit(struct drm_device *dev,return 0 ; +err_free: +kfree (c); error:drm_atomic_helper_cleanup_planes (dev, state);return ret;
Signature · 6 lines
2.11.0 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH 8/12 drm/tegra: Handle drm_atomic_helper_swap_state failure
In reply to a message not in the archivedrm_atomic_helper_swap_state() will be changed to interruptible waiting in the next few commits, so all drivers have to be changed to handling failure.
--- drivers/gpu/drm/tegra/drm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/tegra/drm.c +6 -1
@@ -100,7 +100,12 @@ static int tegra_atomic_commit(struct drm_device *drm,* the software side now. */ -drm_atomic_helper_swap_state (state, true); + err =drm_atomic_helper_swap_state (state, true); +if (err) { +mutex_unlock (&tegra->commit.lock); +drm_atomic_helper_cleanup_planes (drm, state); +return err; + }drm_atomic_state_get (state);if (nonblock)
Signature · 1 line
2.11.0
Archit Taneja
Tested-byRe: [PATCH 07/12] drm/msm: Handle drm_atomic_helper_swap_state failure
In reply to a message not in the archiveQuoted 8 lines · Maarten Lankhorst
drm_atomic_helper_swap_state()will be changed to interruptible waiting in the next few commits, so all drivers have to be changed to handling failure.MSM has its own busy tracking, which means the
swap_statecall can be done with stall = false, in which case it should never return an error. Handle failure withBUG_ONfor this reason.
Applied #2/12 and tried this out.
Quoted 52 lines
Signed-off-by Maarten Lankhorst <[email protected]>Cc Rob Clark <[email protected]>Reviewed-by Daniel Vetter <[email protected]>Reviewed-by Sean Paul <[email protected]>--- drivers/gpu/drm/msm/msm_atomic.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)drivers/gpu/drm/msm/msm_atomic.c +8
-8@@ -232,20 +232,18 @@ int msm_atomic_commit(struct drm_device *dev,* mark our set of crtc's as busy: */ ret =start_atomic (dev->dev_private, c->crtc_mask); -if (ret) { -kfree (c); - goto error; - } +if (ret) + goto err_free; + +BUG_ON (drm_atomic_helper_swap_state (state, false) <0 );/* * This is the point of no return - everything below never fails except * when the hw goes bonghits. Which means we can commit the new state on * the software side now. +* +* swap driver private state while still holding state_lock */ - -drm_atomic_helper_swap_state (state, true); - -/* swap driver private state while still holding state_lock */ if (to_kms_state (state)->state) priv->kms->funcs->swap_state (priv->kms, state);@@ -275,6 +273,8 @@ int msm_atomic_commit(struct drm_device *dev,return 0 ; +err_free: +kfree (c); error:drm_atomic_helper_cleanup_planes (dev, state);return ret;
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
Maarten Lankhorst
AppliedRe: [PATCH 07/12] drm/msm: Handle drm_atomic_helper_swap_state failure
In reply to a message not in the archiveOp 19-07-17 om 11:24 schreef Archit Taneja:
Quoted 7 lines · Maarten Lankhorst
Quoted 4 lines
drm_atomic_helper_swap_state()will be changed to interruptible waiting in the next few commits, so all drivers have to be changed to handling failure.
Quoted 8 lines
Quoted 4 lines
MSM has its own busy tracking, which means the
swap_statecall can be done with stall = false, in which case it should never return an error. Handle failure withBUG_ONfor this reason.Applied #2/12 and tried this out.
Tested-by Archit Taneja <[email protected]>
Thanks, applied series.
I accidentally sent this out to everyone instead of trybot only, but applying your t-b to the commit. :)
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno