mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Maxime Ripard <mripard@kernel.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	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
Subject: Re: [PATCH v12 1/9] drm/lease: Add a helper to tell whether a lease was revoked
Date: Tue, 1 Dec 2026 09:48:54 +0100	[thread overview]
Message-ID: <7d14c4fb-cf18-4e67-aa37-ac0522f5d731@suse.de> (raw)
In-Reply-To: <20261120-drm-reset-state-flag-v12-1-42d63d7417fc@kernel.org>

Hi

Am 20.11.26 um 14:10 schrieb Maxime Ripard:
> 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>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

There's a style comment below.

> ---
>   drivers/gpu/drm/drm_lease.c | 30 ++++++++++++++++++++++++++++++
>   include/drm/drm_auth.h      | 11 +++++++++++
>   include/drm/drm_lease.h     |  2 ++
>   3 files changed, 43 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_lease.c b/drivers/gpu/drm/drm_lease.c
> index 5d2cf724cbd7..f2370a9a18fc 100644
> --- a/drivers/gpu/drm/drm_lease.c
> +++ b/drivers/gpu/drm/drm_lease.c
> @@ -145,10 +145,38 @@ bool drm_lease_held(struct drm_file *file_priv, int id)
>   out:
>   	drm_master_put(&master);
>   	return ret;
>   }
>   
> +/*
> + * Checks whether the file is a lessee whose lease has been revoked. A
> + * lease is always revoked as a whole, but empty leases can also be
> + * created on purpose, so the revocation is tracked explicitly in
> + * drm_master rather than inferred from an empty lease.
> + */
> +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 = master->lease_revoked;
> +		mutex_unlock(&master->dev->mode_config.idr_mutex);

Style-wise, I'd use a scoped guard here.

Best regard
Thomas

> +	}
> +
> +	drm_master_put(&master);
> +	return ret;
> +}
> +
>   /*
>    * Given a bitmask of crtcs to check, reconstructs a crtc mask based on the
>    * crtcs which are visible through the specified file.
>    */
>   uint32_t drm_lease_filter_crtcs(struct drm_file *file_priv, uint32_t crtcs_in)
> @@ -315,10 +343,12 @@ static void _drm_lease_revoke(struct drm_master *top)
>   
>   		/* Evacuate the lease */
>   		idr_for_each_entry(&master->leases, entry, object)
>   			idr_remove(&master->leases, object);
>   
> +		master->lease_revoked = true;
> +
>   		/* Depth-first list walk */
>   
>   		/* Down */
>   		if (!list_empty(&master->lessees)) {
>   			master = list_first_entry(&master->lessees, struct drm_master, lessee_list);
> diff --git a/include/drm/drm_auth.h b/include/drm/drm_auth.h
> index 50131383ed81..b1962f197b05 100644
> --- a/include/drm/drm_auth.h
> +++ b/include/drm/drm_auth.h
> @@ -118,10 +118,21 @@ struct drm_master {
>   	 * Objects are leased all together in drm_lease_create(), and are
>   	 * removed all together when the lease is revoked.
>   	 */
>   	struct idr leases;
>   
> +	/**
> +	 * @lease_revoked:
> +	 *
> +	 * Whether the lease of this drm_master has been revoked. Since empty
> +	 * leases can be created on purpose, an empty &leases doesn't imply a
> +	 * revocation, so it has to be tracked explicitly. Never cleared once
> +	 * set: a revoked master cannot be leased anything again. Protected by
> +	 * &drm_device.mode_config's &drm_mode_config.idr_mutex.
> +	 */
> +	bool lease_revoked;
> +
>   	/**
>   	 * @lessee_idr:
>   	 *
>   	 * All lessees under this owner (only used where @lessor is NULL).
>   	 * Protected by &drm_device.mode_config's &drm_mode_config.idr_mutex.
> 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
> @@ -18,10 +18,12 @@ void drm_lease_destroy(struct drm_master *lessee);
>   
>   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);
>   
>   uint32_t drm_lease_filter_crtcs(struct drm_file *file_priv, uint32_t crtcs);
>   
>   int drm_mode_create_lease_ioctl(struct drm_device *dev,
>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)



  reply	other threads:[~2026-12-01  8:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 13:10 [PATCH v12 0/9] drm: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-11-20 13:10 ` [PATCH v12 1/9] drm/lease: Add a helper to tell whether a lease was revoked Maxime Ripard
2026-12-01  8:48   ` Thomas Zimmermann [this message]
2026-11-20 13:10 ` [PATCH v12 2/9] drm/atomic: Add drm_atomic_implements_create_state() helper Maxime Ripard
2026-12-01  8:54   ` Thomas Zimmermann
2026-12-01  9:20     ` Maxime Ripard
2026-11-20 13:10 ` [PATCH v12 3/9] drm/atomic: Allow filling a commit with pristine object states Maxime Ripard
2026-12-01  9:08   ` Thomas Zimmermann
2026-12-01  9:52     ` Maxime Ripard
2026-11-20 13:10 ` [PATCH v12 4/9] drm/tests: atomic: Add tests for drm_atomic_commit_fill_with_defaults() Maxime Ripard
2026-11-20 13:10 ` [PATCH v12 5/9] drm/amd/display: Take over the current stream and dc_state Maxime Ripard
2026-11-20 13:10 ` [PATCH v12 6/9] drm/vc4: Carry the HVS channel over to created CRTC states Maxime Ripard
2026-11-20 13:10 ` [PATCH v12 7/9] drm/msm/dpu1: Carry the mixers " Maxime Ripard
2026-11-20 13:10 ` [PATCH v12 8/9] drm/atomic-uapi: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-12-01  9:19   ` Thomas Zimmermann
2026-11-20 13:10 ` [PATCH v12 9/9] 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=7d14c4fb-cf18-4e67-aa37-ac0522f5d731@suse.de \
    --to=tzimmermann@suse.de \
    --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=mripard@kernel.org \
    --cc=pekka.paalanen@collabora.com \
    --cc=sebastian.wick@redhat.com \
    --cc=simona@ffwll.ch \
    --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®