From: Sidhartha Kumar <sidhartha.kumar@oracle.com>
To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Cc: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch,
willy@infradead.org, sidhartha.kumar@oracle.com,
jani.nikula@linux.intel.com
Subject: [PATCH v3 5/6] drm: Convert lessee_idr to XArray
Date: Tue, 26 Aug 2025 15:48:59 +0000 [thread overview]
Message-ID: <20250826154900.405480-6-sidhartha.kumar@oracle.com> (raw)
In-Reply-To: <20250826154900.405480-1-sidhartha.kumar@oracle.com>
From: Matthew Wilcox <willy@infradead.org>
From: Matthew Wilcox <willy@infradead.org>
Part of the mass conversion of IDR users to the XArray API.
lessee_id and lessee are not modified so the indentifiers are
unchanged.
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
drivers/gpu/drm/drm_auth.c | 4 +---
drivers/gpu/drm/drm_lease.c | 15 ++++++---------
include/drm/drm_auth.h | 4 ++--
3 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index 66a672384367..0605a649b27f 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -142,8 +142,7 @@ struct drm_master *drm_master_create(struct drm_device *dev)
/* initialize the tree of output resource lessees */
INIT_LIST_HEAD(&master->lessees);
INIT_LIST_HEAD(&master->lessee_list);
- idr_init(&master->leases);
- idr_init_base(&master->lessee_idr, 1);
+ xa_init_flags(&master->lessee_xa, XA_FLAGS_ALLOC1);
return master;
}
@@ -408,7 +407,6 @@ static void drm_master_destroy(struct kref *kref)
drm_lease_destroy(master);
idr_destroy(&master->leases);
- idr_destroy(&master->lessee_idr);
kfree(master->unique);
kfree(master);
diff --git a/drivers/gpu/drm/drm_lease.c b/drivers/gpu/drm/drm_lease.c
index 94375c6a5425..a9d5b8a48b24 100644
--- a/drivers/gpu/drm/drm_lease.c
+++ b/drivers/gpu/drm/drm_lease.c
@@ -82,7 +82,7 @@ static struct drm_master*
_drm_find_lessee(struct drm_master *master, int lessee_id)
{
lockdep_assert_held(&master->dev->mode_config.idr_mutex);
- return idr_find(&drm_lease_owner(master)->lessee_idr, lessee_id);
+ return xa_load(&drm_lease_owner(master)->lessee_xa, lessee_id);
}
static int _drm_lease_held_master(struct drm_master *master, int id)
@@ -210,7 +210,6 @@ static struct drm_master *drm_lease_create(struct drm_master *lessor, struct idr
int error;
struct drm_master *lessee;
int object;
- int id;
void *entry;
drm_dbg_lease(dev, "lessor %d\n", lessor->lessee_id);
@@ -237,13 +236,11 @@ static struct drm_master *drm_lease_create(struct drm_master *lessor, struct idr
}
/* Insert the new lessee into the tree */
- id = idr_alloc(&(drm_lease_owner(lessor)->lessee_idr), lessee, 1, 0, GFP_KERNEL);
- if (id < 0) {
- error = id;
+ error = xa_alloc(&drm_lease_owner(lessor)->lessee_xa,
+ &lessee->lessee_id, lessee, xa_limit_32b, GFP_KERNEL);
+ if (error < 0)
goto out_lessee;
- }
- lessee->lessee_id = id;
lessee->lessor = drm_master_get(lessor);
list_add_tail(&lessee->lessee_list, &lessor->lessees);
@@ -276,11 +273,11 @@ void drm_lease_destroy(struct drm_master *master)
*/
WARN_ON(!list_empty(&master->lessees));
- /* Remove this master from the lessee idr in the owner */
+ /* Remove this master from the lessee array in the owner */
if (master->lessee_id != 0) {
drm_dbg_lease(dev, "remove master %d from device list of lessees\n",
master->lessee_id);
- idr_remove(&(drm_lease_owner(master)->lessee_idr), master->lessee_id);
+ xa_erase(&drm_lease_owner(master)->lessee_xa, master->lessee_id);
}
/* Remove this master from any lessee list it may be on */
diff --git a/include/drm/drm_auth.h b/include/drm/drm_auth.h
index 3026aedbc205..1b6064afc8b0 100644
--- a/include/drm/drm_auth.h
+++ b/include/drm/drm_auth.h
@@ -120,12 +120,12 @@ struct drm_master {
struct idr leases;
/**
- * @lessee_idr:
+ * @lessee_xa:
*
* All lessees under this owner (only used where @lessor is NULL).
* Protected by &drm_device.mode_config's &drm_mode_config.idr_mutex.
*/
- struct idr lessee_idr;
+ struct xarray lessee_xa;
};
struct drm_master *drm_master_get(struct drm_master *master);
--
2.43.0
next prev parent reply other threads:[~2025-08-26 15:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 15:48 [PATCH v3 0/6] DRM IDR to Xarray conversions Sidhartha Kumar
2025-08-26 15:48 ` [PATCH v3 1/6] drm: Convert aux_idr to XArray Sidhartha Kumar
2025-08-26 15:48 ` [PATCH v3 2/6] drm: Convert object_name_idr " Sidhartha Kumar
2025-08-26 15:48 ` [PATCH v3 3/6] drm: Convert syncobj_idr " Sidhartha Kumar
2025-08-26 15:48 ` [PATCH v3 4/6] drm: Convert magic_map " Sidhartha Kumar
2025-08-26 15:48 ` Sidhartha Kumar [this message]
2025-08-26 15:49 ` [PATCH v3 6/6] drm: Convert tile_idr " Sidhartha Kumar
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=20250826154900.405480-6-sidhartha.kumar@oracle.com \
--to=sidhartha.kumar@oracle.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
--cc=willy@infradead.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;
as well as URLs for NNTP newsgroup(s).