{
struct kfd_process *p = pdd->process;
void *mem;
- int id;
+ unsigned long id;
/*
- * Remove all handles from idr and release appropriate
+ * Remove all handles and release appropriate
* local memory object
*/
- idr_for_each_entry(&pdd->alloc_idr, mem, id) {
+ xa_for_each(&pdd->allocations, id, mem) {
struct kfd_process_device *peer_pdd;
list_for_each_entry(peer_pdd, &p->per_device_data,
get_order(KFD_CWSR_TBA_TMA_SIZE));
kfree(pdd->qpd.doorbell_bitmap);
- idr_destroy(&pdd->alloc_idr);
-
kfree(pdd);
}
}
pdd->already_dequeued = false;
list_add(&pdd->per_device_list, &p->per_device_data);
- /* Init idr used for memory handle translation */
- idr_init(&pdd->alloc_idr);
+ xa_init_flags(&pdd->allocations, XA_FLAGS_ALLOC);
return pdd;
}
return !(list_empty(&p->per_device_data));
}
-/* Create specific handle mapped to mem from process local memory idr
+/* Create specific handle mapped to mem from process local memory
* Assumes that the process lock is held.
*/
int kfd_process_device_create_obj_handle(struct kfd_process_device *pdd,
void *mem)
{
- return idr_alloc(&pdd->alloc_idr, mem, 0, 0, GFP_KERNEL);
+ int id, ret;
+
+ ret = xa_alloc(&pdd->allocations, &id, mem, xa_limit_31b, GFP_KERNEL);
+ if (ret < 0)
+ return ret;
+ return id;
}
-/* Translate specific handle from process local memory idr
+/* Translate specific handle from process local memory
* Assumes that the process lock is held.
*/
void *kfd_process_device_translate_handle(struct kfd_process_device *pdd,
int handle)
{
- if (handle < 0)
- return NULL;
-
- return idr_find(&pdd->alloc_idr, handle);
+ return xa_load(&pdd->allocations, handle);
}
-/* Remove specific handle from process local memory idr
+/* Remove specific handle from process local memory
* Assumes that the process lock is held.
*/
void kfd_process_device_remove_obj_handle(struct kfd_process_device *pdd,
int handle)
{
- if (handle >= 0)
- idr_remove(&pdd->alloc_idr, handle);
+ xa_erase(&pdd->allocations, handle);
}
/* This increments the process->ref counter. */