[PATCH 07/34] drm: Convert lessee_idr to XArray
Matthew Wilcox
willy at infradead.org
Thu Feb 21 18:41:33 UTC 2019
Signed-off-by: Matthew Wilcox <willy at infradead.org>
---
drivers/gpu/drm/drm_auth.c | 3 +--
drivers/gpu/drm/drm_lease.c | 15 ++++++---------
include/drm/drm_auth.h | 2 +-
3 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index 268189e9e2e0..28767f55b30b 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -113,7 +113,7 @@ struct drm_master *drm_master_create(struct drm_device *dev)
INIT_LIST_HEAD(&master->lessees);
INIT_LIST_HEAD(&master->lessee_list);
idr_init(&master->leases);
- idr_init(&master->lessee_idr);
+ xa_init_flags(&master->lessee_xa, XA_FLAGS_ALLOC1);
return master;
}
@@ -348,7 +348,6 @@ static void drm_master_destroy(struct kref *kref)
drm_legacy_master_rmmaps(dev, 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 99cba8ea5d82..c02587443b61 100644
--- a/drivers/gpu/drm/drm_lease.c
+++ b/drivers/gpu/drm/drm_lease.c
@@ -54,7 +54,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);
}
/**
@@ -203,7 +203,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_DEBUG_LEASE("lessor %d\n", lessor->lessee_id);
@@ -232,13 +231,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);
@@ -279,10 +276,10 @@ 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_DEBUG_LEASE("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 c719fe375967..f1e092406caa 100644
--- a/include/drm/drm_auth.h
+++ b/include/drm/drm_auth.h
@@ -93,7 +93,7 @@ struct drm_master {
struct list_head lessee_list;
struct list_head lessees;
struct idr leases;
- struct idr lessee_idr;
+ struct xarray lessee_xa;
};
struct drm_master *drm_master_get(struct drm_master *master);
--
2.20.1
More information about the dri-devel
mailing list