diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2018-02-12 09:55:33 -0500 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2018-02-19 07:21:24 -0500 |
commit | e86584c5377f4219781492ca164664bce40c0090 (patch) | |
tree | 698538cd75ff23e18cbb95b54bece446ef37e1fc /drivers/gpu/drm/drm_gem.c | |
parent | a5ef65673667fc37ffa55884915f953cb5cc3b3e (diff) |
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: 6ce711f27500 ("idr: Make 1-based IDRs more efficient")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Christian Konig <christian.koenig@amd.com>
Cc: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Christian König <christian.koenig@amd.com> as well.
Link: https://patchwork.freedesktop.org/patch/msgid/20180212145533.30046-1-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/drm_gem.c')
-rw-r--r-- | drivers/gpu/drm/drm_gem.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 01f8d9481211..4975ba9a7bc8 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c | |||
@@ -98,7 +98,7 @@ drm_gem_init(struct drm_device *dev) | |||
98 | struct drm_vma_offset_manager *vma_offset_manager; | 98 | struct drm_vma_offset_manager *vma_offset_manager; |
99 | 99 | ||
100 | mutex_init(&dev->object_name_lock); | 100 | mutex_init(&dev->object_name_lock); |
101 | idr_init(&dev->object_name_idr); | 101 | idr_init_base(&dev->object_name_idr, 1); |
102 | 102 | ||
103 | vma_offset_manager = kzalloc(sizeof(*vma_offset_manager), GFP_KERNEL); | 103 | vma_offset_manager = kzalloc(sizeof(*vma_offset_manager), GFP_KERNEL); |
104 | if (!vma_offset_manager) { | 104 | if (!vma_offset_manager) { |
@@ -776,7 +776,7 @@ drm_gem_open_ioctl(struct drm_device *dev, void *data, | |||
776 | void | 776 | void |
777 | drm_gem_open(struct drm_device *dev, struct drm_file *file_private) | 777 | drm_gem_open(struct drm_device *dev, struct drm_file *file_private) |
778 | { | 778 | { |
779 | idr_init(&file_private->object_idr); | 779 | idr_init_base(&file_private->object_idr, 1); |
780 | spin_lock_init(&file_private->table_lock); | 780 | spin_lock_init(&file_private->table_lock); |
781 | } | 781 | } |
782 | 782 | ||