From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: "Pekka Paalanen" <pekka.paalanen@collabora.com>,
"Jonas Ådahl" <jadahl@gmail.com>,
"Daniel Vetter" <daniel.vetter@ffwll.ch>,
intel-gfx@lists.freedesktop.org,
"Simon Ser" <contact@emersion.fr>
Subject: [Intel-gfx] [PATCH 1/4] drm/atomic: Treat a nonblocking commit following a blocking commit as blocking commit
Date: Fri, 16 Sep 2022 19:33:28 +0300 [thread overview]
Message-ID: <20220916163331.6849-2-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20220916163331.6849-1-ville.syrjala@linux.intel.com>
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
Currently a nonblocking commit will actually block if it is
preceded by a blocking commit. It just happens block on the
mutex rather than on the completion. I shall call these as
not-actually-nonblocking commits.
I would like to make blocking commits execute locklessly,
just as nonblocking commits already do. The main benefit
would that parallel TEST_ONLY commits would not get blocked
on the mutexes until the parallel blocking commit is done.
To achieve that without a significant change in behaviour
for the not-actually-nonblocking commits let's treat them
exactly the same as blocking commit, ie. instead of
returning -EBUSY they will just block.
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Simon Ser <contact@emersion.fr>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
Cc: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
drivers/gpu/drm/drm_atomic_helper.c | 19 ++++++++++++-------
include/drm/drm_atomic.h | 7 +++++++
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index ee5fea48b5cb..bff087674cb5 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -2109,7 +2109,7 @@ static int stall_checks(struct drm_crtc *crtc, bool nonblock)
* Userspace is not allowed to get ahead of the previous
* commit with nonblocking ones.
*/
- if (!completed && nonblock) {
+ if (!completed && nonblock && commit->nonblock) {
spin_unlock(&crtc->commit_lock);
drm_dbg_atomic(crtc->dev,
"[CRTC:%d:%s] busy with a previous commit\n",
@@ -2152,7 +2152,7 @@ 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_crtc *crtc, bool nonblock)
{
init_completion(&commit->flip_done);
init_completion(&commit->hw_done);
@@ -2160,10 +2160,11 @@ static void init_commit(struct drm_crtc_commit *commit, struct drm_crtc *crtc)
INIT_LIST_HEAD(&commit->commit_entry);
kref_init(&commit->ref);
commit->crtc = crtc;
+ commit->nonblock = nonblock;
}
static struct drm_crtc_commit *
-crtc_or_fake_commit(struct drm_atomic_state *state, struct drm_crtc *crtc)
+crtc_or_fake_commit(struct drm_atomic_state *state, struct drm_crtc *crtc, bool nonblock)
{
if (crtc) {
struct drm_crtc_state *new_crtc_state;
@@ -2178,7 +2179,7 @@ crtc_or_fake_commit(struct drm_atomic_state *state, struct drm_crtc *crtc)
if (!state->fake_commit)
return NULL;
- init_commit(state->fake_commit, NULL);
+ init_commit(state->fake_commit, NULL, nonblock);
}
return state->fake_commit;
@@ -2250,7 +2251,7 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
if (!commit)
return -ENOMEM;
- init_commit(commit, crtc);
+ init_commit(commit, crtc, nonblock);
new_crtc_state->commit = commit;
@@ -2299,6 +2300,7 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
* commit with nonblocking ones.
*/
if (nonblock && old_conn_state->commit &&
+ old_conn_state->commit->nonblock &&
!try_wait_for_completion(&old_conn_state->commit->flip_done)) {
drm_dbg_atomic(conn->dev,
"[CONNECTOR:%d:%s] busy with a previous commit\n",
@@ -2308,7 +2310,8 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
}
/* Always track connectors explicitly for e.g. link retraining. */
- commit = crtc_or_fake_commit(state, new_conn_state->crtc ?: old_conn_state->crtc);
+ commit = crtc_or_fake_commit(state, new_conn_state->crtc ?: old_conn_state->crtc,
+ nonblock);
if (!commit)
return -ENOMEM;
@@ -2321,6 +2324,7 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
* commit with nonblocking ones.
*/
if (nonblock && old_plane_state->commit &&
+ old_plane_state->commit->nonblock &&
!try_wait_for_completion(&old_plane_state->commit->flip_done)) {
drm_dbg_atomic(plane->dev,
"[PLANE:%d:%s] busy with a previous commit\n",
@@ -2330,7 +2334,8 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
}
/* Always track planes explicitly for async pageflip support. */
- commit = crtc_or_fake_commit(state, new_plane_state->crtc ?: old_plane_state->crtc);
+ commit = crtc_or_fake_commit(state, new_plane_state->crtc ?: old_plane_state->crtc,
+ nonblock);
if (!commit)
return -ENOMEM;
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 10b1990bc1f6..0924c322ddfb 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -155,6 +155,13 @@ struct drm_crtc_commit {
* used by the free code to remove the second reference if commit fails.
*/
bool abort_completion;
+
+ /**
+ * @nonblock:
+ *
+ * Nonblocking commit?
+ */
+ bool nonblock;
};
struct __drm_planes_state {
--
2.35.1
next prev parent reply other threads:[~2022-09-16 16:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-16 16:33 [Intel-gfx] [PATCH 0/4] drm/atomic: Lockless blocking commits Ville Syrjala
2022-09-16 16:33 ` Ville Syrjala [this message]
2022-09-16 16:33 ` [Intel-gfx] [PATCH 2/4] drm/i915: Don't reuse commit_work for the cleanup Ville Syrjala
2022-09-16 16:33 ` [Intel-gfx] [PATCH 3/4] drm/atomic: Allow lockless blocking commits Ville Syrjala
2022-09-16 16:33 ` [Intel-gfx] [PATCH 4/4] drm/i915: Make blocking commits lockless Ville Syrjala
2022-09-16 18:09 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/atomic: Lockless blocking commits Patchwork
2022-09-16 18:28 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-09-16 22:57 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2022-09-20 7:34 ` [Intel-gfx] [PATCH 0/4] " Pekka Paalanen
2022-09-26 15:32 ` Ville Syrjälä
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220916163331.6849-2-ville.syrjala@linux.intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=contact@emersion.fr \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jadahl@gmail.com \
--cc=pekka.paalanen@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox