* [PATCH 0/6] DRM IDR to Xarray conversions
@ 2025-08-18 19:00 Sidhartha Kumar
2025-08-18 19:00 ` [PATCH 1/6] drm: Convert aux_idr to XArray Sidhartha Kumar
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Sidhartha Kumar @ 2025-08-18 19:00 UTC (permalink / raw)
To: linux-kernel, dri-devel
Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona, willy,
sidhartha.kumar
From: Sidhartha <sidhartha.kumar@oracle.com>
This series is part of a project to depcrecate the IDR in favor
of the Xarray. This simplifies the code as locking is handled by
the Xarray internally and removes the need for a seperate mutex to
proect the IDR.
The patches are from this tree and have been rebased to drm-next-2025-06-06
https://git.infradead.org/?p=users/willy/xarray.git;a=shortlog;h=refs/heads/xarray-conv
The series has been compiled and tested with drivers/gpu/drm/tests/.kunitconfig
and passes all tests.
[15:22:04] Testing complete. Ran 608 tests: passed: 608
[15:22:04] Elapsed time: 34.792s total, 3.086s configuring, 31.541s building, 0.141s running
Matthew Wilcox (6):
drm: Convert aux_idr to XArray
drm: Convert object_name_idr to XArray
drm: Convert syncobj_idr to XArray
drm: Convert magic_map to XArray
drm: Convert lessee_idr to XArray
drm: Convert tile_idr to XArray
drivers/gpu/drm/display/drm_dp_aux_dev.c | 38 ++++++--------
drivers/gpu/drm/drm_auth.c | 22 ++++----
drivers/gpu/drm/drm_connector.c | 26 ++++------
drivers/gpu/drm/drm_debugfs.c | 19 +++----
drivers/gpu/drm/drm_gem.c | 11 ++--
drivers/gpu/drm/drm_lease.c | 15 +++---
drivers/gpu/drm/drm_mode_config.c | 3 +-
drivers/gpu/drm/drm_syncobj.c | 64 ++++++++----------------
include/drm/drm_auth.h | 9 ++--
include/drm/drm_device.h | 4 +-
include/drm/drm_file.h | 6 +--
include/drm/drm_mode_config.h | 12 ++---
12 files changed, 86 insertions(+), 143 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/6] drm: Convert aux_idr to XArray
2025-08-18 19:00 [PATCH 0/6] DRM IDR to Xarray conversions Sidhartha Kumar
@ 2025-08-18 19:00 ` Sidhartha Kumar
2025-08-19 10:35 ` kernel test robot
2025-08-18 19:00 ` [PATCH 2/6] drm: Convert object_name_idr " Sidhartha Kumar
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Sidhartha Kumar @ 2025-08-18 19:00 UTC (permalink / raw)
To: linux-kernel, dri-devel
Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona, willy,
sidhartha.kumar
From: Matthew Wilcox <willy@infradead.org>
Remove aux_idr_mutex by converting aux_idr to an XArray.
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
drivers/gpu/drm/display/drm_dp_aux_dev.c | 38 ++++++++++--------------
1 file changed, 15 insertions(+), 23 deletions(-)
diff --git a/drivers/gpu/drm/display/drm_dp_aux_dev.c b/drivers/gpu/drm/display/drm_dp_aux_dev.c
index 29555b9f03c8..edecfea44da8 100644
--- a/drivers/gpu/drm/display/drm_dp_aux_dev.c
+++ b/drivers/gpu/drm/display/drm_dp_aux_dev.c
@@ -52,8 +52,7 @@ struct drm_dp_aux_dev {
#define DRM_AUX_MINORS 256
#define AUX_MAX_OFFSET (1 << 20)
-static DEFINE_IDR(aux_idr);
-static DEFINE_MUTEX(aux_idr_mutex);
+static DEFINE_XARRAY_ALLOC(aux_xa);
static struct class *drm_dp_aux_dev_class;
static int drm_dev_major = -1;
@@ -61,11 +60,11 @@ static struct drm_dp_aux_dev *drm_dp_aux_dev_get_by_minor(unsigned index)
{
struct drm_dp_aux_dev *aux_dev = NULL;
- mutex_lock(&aux_idr_mutex);
- aux_dev = idr_find(&aux_idr, index);
+ xa_lock(&aux_xa);
+ aux_dev = xa_load(&aux_xa, index);
if (aux_dev && !kref_get_unless_zero(&aux_dev->refcount))
aux_dev = NULL;
- mutex_unlock(&aux_idr_mutex);
+ xa_unlock(&aux_xa);
return aux_dev;
}
@@ -73,7 +72,7 @@ static struct drm_dp_aux_dev *drm_dp_aux_dev_get_by_minor(unsigned index)
static struct drm_dp_aux_dev *alloc_drm_dp_aux_dev(struct drm_dp_aux *aux)
{
struct drm_dp_aux_dev *aux_dev;
- int index;
+ int err;
aux_dev = kzalloc(sizeof(*aux_dev), GFP_KERNEL);
if (!aux_dev)
@@ -82,14 +81,12 @@ static struct drm_dp_aux_dev *alloc_drm_dp_aux_dev(struct drm_dp_aux *aux)
atomic_set(&aux_dev->usecount, 1);
kref_init(&aux_dev->refcount);
- mutex_lock(&aux_idr_mutex);
- index = idr_alloc(&aux_idr, aux_dev, 0, DRM_AUX_MINORS, GFP_KERNEL);
- mutex_unlock(&aux_idr_mutex);
- if (index < 0) {
+ err = xa_alloc(&aux_xa, &aux_dev->index,
+ XA_LIMIT(0, DRM_AUX_MINORS - 1), aux_dev, GFP_KERNEL);
+ if (err < 0) {
kfree(aux_dev);
- return ERR_PTR(index);
+ return ERR_PTR(err);
}
- aux_dev->index = index;
return aux_dev;
}
@@ -250,22 +247,19 @@ static const struct file_operations auxdev_fops = {
static struct drm_dp_aux_dev *drm_dp_aux_dev_get_by_aux(struct drm_dp_aux *aux)
{
- struct drm_dp_aux_dev *iter, *aux_dev = NULL;
- int id;
+ struct drm_dp_aux_dev *aux_dev;
+ unsigned long id;
/* don't increase kref count here because this function should only be
* used by drm_dp_aux_unregister_devnode. Thus, it will always have at
* least one reference - the one that drm_dp_aux_register_devnode
* created
*/
- mutex_lock(&aux_idr_mutex);
- idr_for_each_entry(&aux_idr, iter, id) {
- if (iter->aux == aux) {
- aux_dev = iter;
+ xa_for_each(&aux_xa, id, aux_dev) {
+ if (aux_dev->aux == aux)
break;
- }
}
- mutex_unlock(&aux_idr_mutex);
+
return aux_dev;
}
@@ -284,9 +278,7 @@ void drm_dp_aux_unregister_devnode(struct drm_dp_aux *aux)
*/
aux->drm_dev = NULL;
- mutex_lock(&aux_idr_mutex);
- idr_remove(&aux_idr, aux_dev->index);
- mutex_unlock(&aux_idr_mutex);
+ xa_erase(&aux_xa, aux_dev->index);
atomic_dec(&aux_dev->usecount);
wait_var_event(&aux_dev->usecount, !atomic_read(&aux_dev->usecount));
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/6] drm: Convert object_name_idr to XArray
2025-08-18 19:00 [PATCH 0/6] DRM IDR to Xarray conversions Sidhartha Kumar
2025-08-18 19:00 ` [PATCH 1/6] drm: Convert aux_idr to XArray Sidhartha Kumar
@ 2025-08-18 19:00 ` Sidhartha Kumar
2025-08-18 19:00 ` [PATCH 4/6] drm: Convert magic_map " Sidhartha Kumar
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Sidhartha Kumar @ 2025-08-18 19:00 UTC (permalink / raw)
To: linux-kernel, dri-devel
Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona, willy,
sidhartha.kumar
From: Matthew Wilcox <willy@infradead.org>
It's not possible to replace object_name_lock as it protects more
code than should be reasonably be run under a spinlock, so the xa_lock
is nested under the object_name_lock.
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
drivers/gpu/drm/drm_debugfs.c | 19 ++++++-------------
drivers/gpu/drm/drm_gem.c | 11 +++++------
include/drm/drm_device.h | 4 ++--
3 files changed, 13 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 3dfd8b34dceb..2d37ee7f70fb 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -117,27 +117,20 @@ static int drm_clients_info(struct seq_file *m, void *data)
return 0;
}
-static int drm_gem_one_name_info(int id, void *ptr, void *data)
-{
- struct drm_gem_object *obj = ptr;
- struct seq_file *m = data;
-
- seq_printf(m, "%6d %8zd %7d %8d\n",
- obj->name, obj->size,
- obj->handle_count,
- kref_read(&obj->refcount));
- return 0;
-}
-
static int drm_gem_name_info(struct seq_file *m, void *data)
{
struct drm_debugfs_entry *entry = m->private;
struct drm_device *dev = entry->dev;
+ struct drm_gem_object *obj;
+ unsigned long index;
seq_printf(m, " name size handles refcount\n");
mutex_lock(&dev->object_name_lock);
- idr_for_each(&dev->object_name_idr, drm_gem_one_name_info, m);
+ xa_for_each(&dev->object_names, index, obj) {
+ seq_printf(m, "%6d %8zd %7d %8d\n", obj->name, obj->size,
+ obj->handle_count, kref_read(&obj->refcount));
+ }
mutex_unlock(&dev->object_name_lock);
return 0;
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 4bf0a76bb35e..27a7069d819d 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -96,7 +96,7 @@ drm_gem_init(struct drm_device *dev)
struct drm_vma_offset_manager *vma_offset_manager;
mutex_init(&dev->object_name_lock);
- idr_init_base(&dev->object_name_idr, 1);
+ xa_init_flags(&dev->object_names, XA_FLAGS_ALLOC1);
vma_offset_manager = drmm_kzalloc(dev, sizeof(*vma_offset_manager),
GFP_KERNEL);
@@ -257,7 +257,7 @@ static void drm_gem_object_handle_free(struct drm_gem_object *obj)
/* Remove any name for this object */
if (obj->name) {
- idr_remove(&dev->object_name_idr, obj->name);
+ xa_erase(&dev->object_names, obj->name);
obj->name = 0;
}
}
@@ -908,11 +908,10 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,
}
if (!obj->name) {
- ret = idr_alloc(&dev->object_name_idr, obj, 1, 0, GFP_KERNEL);
+ ret = xa_alloc(&dev->object_names, &obj->name, obj,
+ xa_limit_32b, GFP_KERNEL);
if (ret < 0)
goto err;
-
- obj->name = ret;
}
args->name = (uint64_t) obj->name;
@@ -948,7 +947,7 @@ drm_gem_open_ioctl(struct drm_device *dev, void *data,
return -EOPNOTSUPP;
mutex_lock(&dev->object_name_lock);
- obj = idr_find(&dev->object_name_idr, (int) args->name);
+ obj = xa_load(&dev->object_names, (int) args->name);
if (obj) {
drm_gem_object_get(obj);
} else {
diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
index e2f894f1b90a..7d8244078d51 100644
--- a/include/drm/drm_device.h
+++ b/include/drm/drm_device.h
@@ -314,8 +314,8 @@ struct drm_device {
/** @object_name_lock: GEM information */
struct mutex object_name_lock;
- /** @object_name_idr: GEM information */
- struct idr object_name_idr;
+ /** @object_names: GEM information */
+ struct xarray object_names;
/** @vma_offset_manager: GEM information */
struct drm_vma_offset_manager *vma_offset_manager;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/6] drm: Convert magic_map to XArray
2025-08-18 19:00 [PATCH 0/6] DRM IDR to Xarray conversions Sidhartha Kumar
2025-08-18 19:00 ` [PATCH 1/6] drm: Convert aux_idr to XArray Sidhartha Kumar
2025-08-18 19:00 ` [PATCH 2/6] drm: Convert object_name_idr " Sidhartha Kumar
@ 2025-08-18 19:00 ` Sidhartha Kumar
2025-08-18 19:00 ` [PATCH 5/6] drm: Convert lessee_idr " Sidhartha Kumar
2025-08-18 19:00 ` [PATCH 6/6] drm: Convert tile_idr " Sidhartha Kumar
4 siblings, 0 replies; 7+ messages in thread
From: Sidhartha Kumar @ 2025-08-18 19:00 UTC (permalink / raw)
To: linux-kernel, dri-devel
Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona, willy,
sidhartha.kumar
From: Matthew Wilcox <willy@infradead.org>
Part of the mass conversion of IDR users to the XArray API.
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
drivers/gpu/drm/drm_auth.c | 18 ++++++++----------
include/drm/drm_auth.h | 5 ++---
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index 22aa015df387..41aa20144a9d 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -97,17 +97,16 @@ int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
mutex_lock(&dev->master_mutex);
if (!file_priv->magic) {
- ret = idr_alloc(&file_priv->master->magic_map, file_priv,
- 1, 0, GFP_KERNEL);
- if (ret >= 0)
- file_priv->magic = ret;
+ ret = xa_alloc(&file_priv->master->magic_map,
+ &file_priv->magic, file_priv,
+ xa_limit_31b, GFP_KERNEL);
}
auth->magic = file_priv->magic;
mutex_unlock(&dev->master_mutex);
drm_dbg_core(dev, "%u\n", auth->magic);
- return ret < 0 ? ret : 0;
+ return ret;
}
int drm_authmagic(struct drm_device *dev, void *data,
@@ -119,10 +118,10 @@ int drm_authmagic(struct drm_device *dev, void *data,
drm_dbg_core(dev, "%u\n", auth->magic);
mutex_lock(&dev->master_mutex);
- file = idr_find(&file_priv->master->magic_map, auth->magic);
+ file = xa_load(&file_priv->master->magic_map, auth->magic);
if (file) {
file->authenticated = 1;
- idr_replace(&file_priv->master->magic_map, NULL, auth->magic);
+ xa_store(&file_priv->master->magic_map, auth->magic, NULL, 0);
}
mutex_unlock(&dev->master_mutex);
@@ -138,7 +137,7 @@ struct drm_master *drm_master_create(struct drm_device *dev)
return NULL;
kref_init(&master->refcount);
- idr_init_base(&master->magic_map, 1);
+ xa_init_flags(&master->magic_map, XA_FLAGS_ALLOC1);
master->dev = dev;
/* initialize the tree of output resource lessees */
@@ -358,7 +357,7 @@ void drm_master_release(struct drm_file *file_priv)
mutex_lock(&dev->master_mutex);
master = file_priv->master;
if (file_priv->magic)
- idr_remove(&file_priv->master->magic_map, file_priv->magic);
+ xa_erase(&file_priv->master->magic_map, file_priv->magic);
if (!drm_is_current_master_locked(file_priv))
goto out;
@@ -425,7 +424,6 @@ static void drm_master_destroy(struct kref *kref)
if (drm_core_check_feature(dev, DRIVER_MODESET))
drm_lease_destroy(master);
- idr_destroy(&master->magic_map);
idr_destroy(&master->leases);
idr_destroy(&master->lessee_idr);
diff --git a/include/drm/drm_auth.h b/include/drm/drm_auth.h
index 50131383ed81..3026aedbc205 100644
--- a/include/drm/drm_auth.h
+++ b/include/drm/drm_auth.h
@@ -58,10 +58,9 @@ struct drm_master {
*/
int unique_len;
/**
- * @magic_map: Map of used authentication tokens. Protected by
- * &drm_device.master_mutex.
+ * @magic_map: Map of used authentication tokens.
*/
- struct idr magic_map;
+ struct xarray magic_map;
void *driver_priv;
/**
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/6] drm: Convert lessee_idr to XArray
2025-08-18 19:00 [PATCH 0/6] DRM IDR to Xarray conversions Sidhartha Kumar
` (2 preceding siblings ...)
2025-08-18 19:00 ` [PATCH 4/6] drm: Convert magic_map " Sidhartha Kumar
@ 2025-08-18 19:00 ` Sidhartha Kumar
2025-08-18 19:00 ` [PATCH 6/6] drm: Convert tile_idr " Sidhartha Kumar
4 siblings, 0 replies; 7+ messages in thread
From: Sidhartha Kumar @ 2025-08-18 19:00 UTC (permalink / raw)
To: linux-kernel, dri-devel
Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona, willy,
sidhartha.kumar
From: Matthew Wilcox <willy@infradead.org>
Part of the mass conversion of IDR users to the XArray API.
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 41aa20144a9d..ca94d148b889 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -143,8 +143,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;
}
@@ -425,7 +424,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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6/6] drm: Convert tile_idr to XArray
2025-08-18 19:00 [PATCH 0/6] DRM IDR to Xarray conversions Sidhartha Kumar
` (3 preceding siblings ...)
2025-08-18 19:00 ` [PATCH 5/6] drm: Convert lessee_idr " Sidhartha Kumar
@ 2025-08-18 19:00 ` Sidhartha Kumar
4 siblings, 0 replies; 7+ messages in thread
From: Sidhartha Kumar @ 2025-08-18 19:00 UTC (permalink / raw)
To: linux-kernel, dri-devel
Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona, willy,
sidhartha.kumar
From: Matthew Wilcox <willy@infradead.org>
Convert tile_idr to an Xarray.
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
drivers/gpu/drm/drm_connector.c | 26 ++++++++++----------------
drivers/gpu/drm/drm_mode_config.c | 3 +--
include/drm/drm_mode_config.h | 12 ++++++------
3 files changed, 17 insertions(+), 24 deletions(-)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 48b08c9611a7..91cfe06ca199 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -3489,9 +3489,7 @@ static void drm_tile_group_free(struct kref *kref)
struct drm_tile_group *tg = container_of(kref, struct drm_tile_group, refcount);
struct drm_device *dev = tg->dev;
- mutex_lock(&dev->mode_config.idr_mutex);
- idr_remove(&dev->mode_config.tile_idr, tg->id);
- mutex_unlock(&dev->mode_config.idr_mutex);
+ xa_erase(&dev->mode_config.tiles, tg->id);
kfree(tg);
}
@@ -3523,19 +3521,18 @@ struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
const char topology[8])
{
struct drm_tile_group *tg;
- int id;
+ unsigned long id;
- mutex_lock(&dev->mode_config.idr_mutex);
- idr_for_each_entry(&dev->mode_config.tile_idr, tg, id) {
+ xa_lock(&dev->mode_config.tiles);
+ xa_for_each(&dev->mode_config.tiles, id, tg) {
if (!memcmp(tg->group_data, topology, 8)) {
if (!kref_get_unless_zero(&tg->refcount))
tg = NULL;
- mutex_unlock(&dev->mode_config.idr_mutex);
- return tg;
+ break;
}
}
- mutex_unlock(&dev->mode_config.idr_mutex);
- return NULL;
+ xa_unlock(&dev->mode_config.tiles);
+ return tg;
}
EXPORT_SYMBOL(drm_mode_get_tile_group);
@@ -3564,16 +3561,13 @@ struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
memcpy(tg->group_data, topology, 8);
tg->dev = dev;
- mutex_lock(&dev->mode_config.idr_mutex);
- ret = idr_alloc(&dev->mode_config.tile_idr, tg, 1, 0, GFP_KERNEL);
- if (ret >= 0) {
- tg->id = ret;
- } else {
+ ret = xa_alloc(&dev->mode_config.tiles, &tg->id, tg, xa_limit_32b,
+ GFP_KERNEL);
+ if (ret < 0) {
kfree(tg);
tg = NULL;
}
- mutex_unlock(&dev->mode_config.idr_mutex);
return tg;
}
EXPORT_SYMBOL(drm_mode_create_tile_group);
diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index b4239fd04e9d..c3d1a6d81bc7 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -438,7 +438,7 @@ int drmm_mode_config_init(struct drm_device *dev)
INIT_LIST_HEAD(&dev->mode_config.plane_list);
INIT_LIST_HEAD(&dev->mode_config.privobj_list);
idr_init_base(&dev->mode_config.object_idr, 1);
- idr_init_base(&dev->mode_config.tile_idr, 1);
+ xa_init_flags(&dev->mode_config.tiles, XA_FLAGS_ALLOC1);
ida_init(&dev->mode_config.connector_ida);
spin_lock_init(&dev->mode_config.connector_list_lock);
@@ -577,7 +577,6 @@ void drm_mode_config_cleanup(struct drm_device *dev)
}
ida_destroy(&dev->mode_config.connector_ida);
- idr_destroy(&dev->mode_config.tile_idr);
idr_destroy(&dev->mode_config.object_idr);
drm_modeset_lock_fini(&dev->mode_config.connection_mutex);
}
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 9e524b51a001..8412013914d9 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -392,8 +392,8 @@ struct drm_mode_config {
/**
* @idr_mutex:
*
- * Mutex for KMS ID allocation and management. Protects both @object_idr
- * and @tile_idr.
+ * Mutex for KMS ID allocation and management. Protects the
+ * objects in @object_idr.
*/
struct mutex idr_mutex;
@@ -406,12 +406,12 @@ struct drm_mode_config {
struct idr object_idr;
/**
- * @tile_idr:
+ * @tiles:
*
- * Use this idr for allocating new IDs for tiled sinks like use in some
- * high-res DP MST screens.
+ * Use this for allocating new IDs for tiled sinks like those
+ * used in some high-res DP MST screens.
*/
- struct idr tile_idr;
+ struct xarray tiles;
/** @fb_lock: Mutex to protect fb the global @fb_list and @num_fb. */
struct mutex fb_lock;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/6] drm: Convert aux_idr to XArray
2025-08-18 19:00 ` [PATCH 1/6] drm: Convert aux_idr to XArray Sidhartha Kumar
@ 2025-08-19 10:35 ` kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2025-08-19 10:35 UTC (permalink / raw)
To: Sidhartha Kumar, linux-kernel, dri-devel
Cc: llvm, oe-kbuild-all, maarten.lankhorst, mripard, tzimmermann,
airlied, simona, willy, sidhartha.kumar
Hi Sidhartha,
kernel test robot noticed the following build errors:
[auto build test ERROR on v6.16]
[also build test ERROR on next-20250819]
[cannot apply to drm-exynos/exynos-drm-next linus/master v6.17-rc2 v6.17-rc1]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sidhartha-Kumar/drm-Convert-aux_idr-to-XArray/20250819-031755
base: v6.16
patch link: https://lore.kernel.org/r/20250818190046.157962-2-sidhartha.kumar%40oracle.com
patch subject: [PATCH 1/6] drm: Convert aux_idr to XArray
config: x86_64-buildonly-randconfig-002-20250819 (https://download.01.org/0day-ci/archive/20250819/202508191844.VZB7euYb-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250819/202508191844.VZB7euYb-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202508191844.VZB7euYb-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/gpu/drm/display/drm_dp_aux_dev.c:85:5: error: passing 'struct xa_limit' to parameter of incompatible type 'void *'
85 | XA_LIMIT(0, DRM_AUX_MINORS - 1), aux_dev, GFP_KERNEL);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/xarray.h:248:30: note: expanded from macro 'XA_LIMIT'
248 | #define XA_LIMIT(_min, _max) (struct xa_limit) { .min = _min, .max = _max }
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/xarray.h:872:9: note: passing argument to parameter 'entry' here
872 | void *entry, struct xa_limit limit, gfp_t gfp)
| ^
1 error generated.
vim +85 drivers/gpu/drm/display/drm_dp_aux_dev.c
71
72 static struct drm_dp_aux_dev *alloc_drm_dp_aux_dev(struct drm_dp_aux *aux)
73 {
74 struct drm_dp_aux_dev *aux_dev;
75 int err;
76
77 aux_dev = kzalloc(sizeof(*aux_dev), GFP_KERNEL);
78 if (!aux_dev)
79 return ERR_PTR(-ENOMEM);
80 aux_dev->aux = aux;
81 atomic_set(&aux_dev->usecount, 1);
82 kref_init(&aux_dev->refcount);
83
84 err = xa_alloc(&aux_xa, &aux_dev->index,
> 85 XA_LIMIT(0, DRM_AUX_MINORS - 1), aux_dev, GFP_KERNEL);
86 if (err < 0) {
87 kfree(aux_dev);
88 return ERR_PTR(err);
89 }
90
91 return aux_dev;
92 }
93
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-08-19 10:36 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-18 19:00 [PATCH 0/6] DRM IDR to Xarray conversions Sidhartha Kumar
2025-08-18 19:00 ` [PATCH 1/6] drm: Convert aux_idr to XArray Sidhartha Kumar
2025-08-19 10:35 ` kernel test robot
2025-08-18 19:00 ` [PATCH 2/6] drm: Convert object_name_idr " Sidhartha Kumar
2025-08-18 19:00 ` [PATCH 4/6] drm: Convert magic_map " Sidhartha Kumar
2025-08-18 19:00 ` [PATCH 5/6] drm: Convert lessee_idr " Sidhartha Kumar
2025-08-18 19:00 ` [PATCH 6/6] drm: Convert tile_idr " Sidhartha Kumar
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).