mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-23 12:43:55 +08:00
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: 6ce711f275
("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
This commit is contained in:
parent
a5ef656736
commit
e86584c537
@ -98,7 +98,7 @@ drm_gem_init(struct drm_device *dev)
|
||||
struct drm_vma_offset_manager *vma_offset_manager;
|
||||
|
||||
mutex_init(&dev->object_name_lock);
|
||||
idr_init(&dev->object_name_idr);
|
||||
idr_init_base(&dev->object_name_idr, 1);
|
||||
|
||||
vma_offset_manager = kzalloc(sizeof(*vma_offset_manager), GFP_KERNEL);
|
||||
if (!vma_offset_manager) {
|
||||
@ -776,7 +776,7 @@ drm_gem_open_ioctl(struct drm_device *dev, void *data,
|
||||
void
|
||||
drm_gem_open(struct drm_device *dev, struct drm_file *file_private)
|
||||
{
|
||||
idr_init(&file_private->object_idr);
|
||||
idr_init_base(&file_private->object_idr, 1);
|
||||
spin_lock_init(&file_private->table_lock);
|
||||
}
|
||||
|
||||
|
@ -546,7 +546,7 @@ err_put_fd:
|
||||
void
|
||||
drm_syncobj_open(struct drm_file *file_private)
|
||||
{
|
||||
idr_init(&file_private->syncobj_idr);
|
||||
idr_init_base(&file_private->syncobj_idr, 1);
|
||||
spin_lock_init(&file_private->syncobj_table_lock);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user