From: Ville Syrjälä <[email protected]> drm_crtc_commit_wait() gets the device for its timeout messages from commit->crtc, which is NULL for the fake commit that tracks unbound planes and connectors. If waiting for the fake commit's hw_done ever times out we oops instead of printing the message.
Store the device in the commit and use it for the messages instead, and also print the CRTC when there is one so the messages say which commit timed out. Document that drm_crtc_commit.crtc is NULL for the fake commit. Cc: Maarten Lankhorst <[email protected]> Signed-off-by: Ville Syrjälä <[email protected]> --- drivers/gpu/drm/drm_atomic.c | 14 ++++++++++++-- drivers/gpu/drm/drm_atomic_helper.c | 8 +++++--- include/drm/drm_atomic.h | 9 ++++++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 81591173265d..ec5a8f32a0b0 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -136,6 +136,16 @@ void __drm_crtc_commit_free(struct kref *kref) } EXPORT_SYMBOL(__drm_crtc_commit_free); +static void drm_crtc_commit_wait_timeout(struct drm_crtc_commit *commit, + const char *what) +{ + if (commit->crtc) + drm_err(commit->dev, "[CRTC:%d:%s] %s timed out\n", + commit->crtc->base.id, commit->crtc->name, what); + else + drm_err(commit->dev, "fake commit %s timed out\n", what); +} + /** * drm_crtc_commit_wait - Waits for a commit to complete * @commit: &drm_crtc_commit to wait for @@ -156,7 +166,7 @@ int drm_crtc_commit_wait(struct drm_crtc_commit *commit) ret = wait_for_completion_timeout(&commit->hw_done, timeout); if (!ret) { - drm_err(commit->crtc->dev, "hw_done timed out\n"); + drm_crtc_commit_wait_timeout(commit, "hw_done"); return -ETIMEDOUT; } @@ -166,7 +176,7 @@ int drm_crtc_commit_wait(struct drm_crtc_commit *commit) */ ret = wait_for_completion_timeout(&commit->flip_done, timeout); if (!ret) { - drm_err(commit->crtc->dev, "flip_done timed out\n"); + drm_crtc_commit_wait_timeout(commit, "flip_done"); return -ETIMEDOUT; } diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 1ef1bc06ad5c..72aa0be5622c 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -2462,13 +2462,15 @@ static void release_crtc_commit(struct completion *completion) drm_crtc_commit_put(commit); } -static void init_commit(struct drm_crtc_commit *commit, struct drm_crtc *crtc) +static void init_commit(struct drm_crtc_commit *commit, struct drm_device *dev, + struct drm_crtc *crtc) { init_completion(&commit->flip_done); init_completion(&commit->hw_done); init_completion(&commit->cleanup_done); INIT_LIST_HEAD(&commit->commit_entry); kref_init(&commit->ref); + commit->dev = dev; commit->crtc = crtc; } @@ -2488,7 +2490,7 @@ crtc_or_fake_commit(struct drm_atomic_commit *state, struct drm_crtc *crtc) if (!state->fake_commit) return NULL; - init_commit(state->fake_commit, NULL); + init_commit(state->fake_commit, state->dev, NULL); /* * There is no event nor flip for the fake commit, so @@ -2569,7 +2571,7 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_commit *state, if (!commit) return -ENOMEM; - init_commit(commit, crtc); + init_commit(commit, state->dev, crtc); new_crtc_state->commit = commit; diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h index 5d075763c445..b5bd7d75bc82 100644 --- a/include/drm/drm_atomic.h +++ b/include/drm/drm_atomic.h @@ -70,10 +70,17 @@ * See also drm_crtc_commit_wait(). */ struct drm_crtc_commit { + /** + * @dev: + * + * DRM device for this commit. + */ + struct drm_device *dev; + /** * @crtc: * - * DRM CRTC for this commit. + * DRM CRTC for this commit. NULL for &drm_atomic_commit.fake_commit. */ struct drm_crtc *crtc; -- 2.56.0
