[PATCH 32/34] drm/via: Convert object_idr to XArray
Matthew Wilcox
willy at infradead.org
Thu Feb 21 18:42:22 UTC 2019
Signed-off-by: Matthew Wilcox <willy at infradead.org>
---
drivers/gpu/drm/via/via_drv.h | 2 +-
drivers/gpu/drm/via/via_map.c | 4 +---
drivers/gpu/drm/via/via_mm.c | 11 +++++------
3 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
index 6d1ae834484c..df0f451908e2 100644
--- a/drivers/gpu/drm/via/via_drv.h
+++ b/drivers/gpu/drm/via/via_drv.h
@@ -95,7 +95,7 @@ typedef struct drm_via_private {
int agp_initialized;
struct drm_mm agp_mm;
/** Mapping of userspace keys to mm objects */
- struct idr object_idr;
+ struct xarray objects;
unsigned long vram_offset;
unsigned long agp_offset;
drm_via_blitq_t blit_queues[VIA_NUM_BLIT_ENGINES];
diff --git a/drivers/gpu/drm/via/via_map.c b/drivers/gpu/drm/via/via_map.c
index 2ad865870372..c47630105f5b 100644
--- a/drivers/gpu/drm/via/via_map.c
+++ b/drivers/gpu/drm/via/via_map.c
@@ -100,7 +100,7 @@ int via_driver_load(struct drm_device *dev, unsigned long chipset)
if (dev_priv == NULL)
return -ENOMEM;
- idr_init(&dev_priv->object_idr);
+ xa_init_flags(&dev_priv->objects, XA_FLAGS_ALLOC1);
dev->dev_private = (void *)dev_priv;
dev_priv->chipset = chipset;
@@ -120,7 +120,5 @@ void via_driver_unload(struct drm_device *dev)
{
drm_via_private_t *dev_priv = dev->dev_private;
- idr_destroy(&dev_priv->object_idr);
-
kfree(dev_priv);
}
diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c
index 4217d66a5cc6..aaa90a096e52 100644
--- a/drivers/gpu/drm/via/via_mm.c
+++ b/drivers/gpu/drm/via/via_mm.c
@@ -148,10 +148,10 @@ int via_mem_alloc(struct drm_device *dev, void *data,
if (retval)
goto fail_alloc;
- retval = idr_alloc(&dev_priv->object_idr, item, 1, 0, GFP_KERNEL);
+ retval = xa_alloc(&dev_priv->objects, &user_key, item,
+ xa_limit_31b, GFP_KERNEL);
if (retval < 0)
- goto fail_idr;
- user_key = retval;
+ goto fail_xa;
list_add(&item->owner_list, &file_priv->obj_list);
mutex_unlock(&dev->struct_mutex);
@@ -163,7 +163,7 @@ int via_mem_alloc(struct drm_device *dev, void *data,
return 0;
-fail_idr:
+fail_xa:
drm_mm_remove_node(&item->mm_node);
fail_alloc:
kfree(item);
@@ -184,13 +184,12 @@ int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv)
struct via_memblock *obj;
mutex_lock(&dev->struct_mutex);
- obj = idr_find(&dev_priv->object_idr, mem->index);
+ obj = xa_erase(&dev_priv->objects, mem->index);
if (obj == NULL) {
mutex_unlock(&dev->struct_mutex);
return -EINVAL;
}
- idr_remove(&dev_priv->object_idr, mem->index);
list_del(&obj->owner_list);
drm_mm_remove_node(&obj->mm_node);
kfree(obj);
--
2.20.1
More information about the dri-devel
mailing list