Skip to content

Commit e86584c

Browse files
committed
drm: Use idr_init_base(1) when using id==0 for invalid
Use the new idr_init_base() function to create an IDR that knows id==0 is never allocated as it maps to an invalid identifier. By knowing that id==0 is invalid, the IDR can start from id=1 instead avoiding the issue of having to start each lookup from the zeroth leaf as id==0 is always unused (and thus the tree-of-bitmaps indicate that is the first available). References: 6ce711f ("idr: Make 1-based IDRs more efficient") Signed-off-by: Chris Wilson <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Christian Konig <[email protected]> Cc: Dave Airlie <[email protected]> Reviewed-by: Ville Syrjälä <[email protected]> Acked-by: Christian König <[email protected]> as well. Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent a5ef656 commit e86584c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

drivers/gpu/drm/drm_gem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ drm_gem_init(struct drm_device *dev)
9898
struct drm_vma_offset_manager *vma_offset_manager;
9999

100100
mutex_init(&dev->object_name_lock);
101-
idr_init(&dev->object_name_idr);
101+
idr_init_base(&dev->object_name_idr, 1);
102102

103103
vma_offset_manager = kzalloc(sizeof(*vma_offset_manager), GFP_KERNEL);
104104
if (!vma_offset_manager) {
@@ -776,7 +776,7 @@ drm_gem_open_ioctl(struct drm_device *dev, void *data,
776776
void
777777
drm_gem_open(struct drm_device *dev, struct drm_file *file_private)
778778
{
779-
idr_init(&file_private->object_idr);
779+
idr_init_base(&file_private->object_idr, 1);
780780
spin_lock_init(&file_private->table_lock);
781781
}
782782

drivers/gpu/drm/drm_syncobj.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ static int drm_syncobj_export_sync_file(struct drm_file *file_private,
546546
void
547547
drm_syncobj_open(struct drm_file *file_private)
548548
{
549-
idr_init(&file_private->syncobj_idr);
549+
idr_init_base(&file_private->syncobj_idr, 1);
550550
spin_lock_init(&file_private->syncobj_table_lock);
551551
}
552552

0 commit comments

Comments
 (0)