From: Maxime Ripard <mripard@kernel.org>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Louis Chauvet <louis.chauvet@bootlin.com>,
Haneen Mohammed <hamohammed.sa@gmail.com>,
Melissa Wen <melissa.srw@gmail.com>
Cc: "Daniel Stone" <daniels@collabora.com>,
"Harry Wentland" <harry.wentland@amd.com>,
"Jocelyn Falempe" <jfalempe@redhat.com>,
"Jonas Ådahl" <jadahl@redhat.com>,
"Michel Dänzer" <mdaenzer@redhat.com>,
"Pekka Paalanen" <pekka.paalanen@collabora.com>,
"Sebastian Wick" <sebastian.wick@redhat.com>,
"Simon Ser" <contact@emersion.fr>,
"Victoria Brekenfeld" <victoria@system76.com>,
"Xaver Hugl" <xaver.hugl@kde.org>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
"Maxime Ripard" <mripard@kernel.org>
Subject: [PATCH v8 3/7] drm/lease: Add a helper to tell whether a lease was revoked
Date: Fri, 06 Nov 2026 16:11:41 +0100 [thread overview]
Message-ID: <20261106-drm-reset-state-flag-v8-3-50fd046b705f@kernel.org> (raw)
In-Reply-To: <20261106-drm-reset-state-flag-v8-0-50fd046b705f@kernel.org>
drm_lease_held() only answers whether a given object is part of a lease,
and the answer can change from one call to the next. Code that needs to
look at several objects in a row has no way to tell whether the lease it
has been checking against is still around by the time it is done.
Add a helper reporting whether a lease has been revoked, so that such
code can bail out instead of acting on a lease that went away.
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
drivers/gpu/drm/drm_lease.c | 26 ++++++++++++++++++++++++++
include/drm/drm_lease.h | 2 ++
2 files changed, 28 insertions(+)
diff --git a/drivers/gpu/drm/drm_lease.c b/drivers/gpu/drm/drm_lease.c
index 5d2cf724cbd7..dd59df14dcc0 100644
--- a/drivers/gpu/drm/drm_lease.c
+++ b/drivers/gpu/drm/drm_lease.c
@@ -148,4 +148,30 @@ bool drm_lease_held(struct drm_file *file_priv, int id)
}
+/*
+ * Checks whether the file is a lessee whose lease has been revoked. A
+ * lease is always revoked as a whole, so an empty one has been revoked.
+ */
+bool drm_lease_revoked(struct drm_file *file_priv)
+{
+ struct drm_master *master;
+ bool ret = false;
+
+ if (!file_priv)
+ return false;
+
+ master = drm_file_get_master(file_priv);
+ if (!master)
+ return false;
+
+ if (master->lessor) {
+ mutex_lock(&master->dev->mode_config.idr_mutex);
+ ret = idr_is_empty(&master->leases);
+ mutex_unlock(&master->dev->mode_config.idr_mutex);
+ }
+
+ drm_master_put(&master);
+ return ret;
+}
+
/*
* Given a bitmask of crtcs to check, reconstructs a crtc mask based on the
diff --git a/include/drm/drm_lease.h b/include/drm/drm_lease.h
index 53545b4ca9ef..03f7ea36c37c 100644
--- a/include/drm/drm_lease.h
+++ b/include/drm/drm_lease.h
@@ -21,4 +21,6 @@ bool drm_lease_held(struct drm_file *file_priv, int id);
bool _drm_lease_held(struct drm_file *file_priv, int id);
+bool drm_lease_revoked(struct drm_file *file_priv);
+
void drm_lease_revoke(struct drm_master *master);
--
2.55.0
next prev parent reply other threads:[~2026-11-06 15:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 15:11 [PATCH v8 0/7] drm: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-11-06 15:11 ` [PATCH v8 1/7] drm/amd/display: Fix planes atomic_create_state implementation Maxime Ripard
2026-11-06 15:11 ` [PATCH v8 2/7] drm/atomic: Add drm_atomic_implements_create_state() helper Maxime Ripard
2026-11-06 15:11 ` Maxime Ripard [this message]
2026-11-06 15:11 ` [PATCH v8 4/7] drm/atomic: Allow filling a commit with pristine object states Maxime Ripard
2026-11-06 15:11 ` [PATCH v8 5/7] drm/tests: atomic: Add tests for drm_atomic_commit_fill_with_defaults() Maxime Ripard
2026-11-06 15:11 ` [PATCH v8 6/7] drm/atomic-uapi: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-11-06 15:11 ` [PATCH v8 7/7] drm/vkms: Add driver-specific plane property for testing Maxime Ripard
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=20261106-drm-reset-state-flag-v8-3-50fd046b705f@kernel.org \
--to=mripard@kernel.org \
--cc=airlied@gmail.com \
--cc=contact@emersion.fr \
--cc=daniels@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hamohammed.sa@gmail.com \
--cc=harry.wentland@amd.com \
--cc=jadahl@redhat.com \
--cc=jfalempe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=louis.chauvet@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mdaenzer@redhat.com \
--cc=melissa.srw@gmail.com \
--cc=pekka.paalanen@collabora.com \
--cc=sebastian.wick@redhat.com \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
--cc=victoria@system76.com \
--cc=xaver.hugl@kde.org \
/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
all inboxes | Powered by JetHome®