Straightforward conversion.
Signed-off-by: Matthew Wilcox <willy@infradead.org>
static void lut_close(struct i915_gem_context *ctx)
{
- struct radix_tree_iter iter;
- void __rcu **slot;
+ XA_STATE(xas, &ctx->handles_vma, 0);
+ struct i915_vma *vma;
lockdep_assert_held(&ctx->mutex);
rcu_read_lock();
- radix_tree_for_each_slot(slot, &ctx->handles_vma, &iter, 0) {
- struct i915_vma *vma = rcu_dereference_raw(*slot);
+ xas_for_each(&xas, vma, ULONG_MAX) {
struct drm_i915_gem_object *obj = vma->obj;
struct i915_lut_handle *lut;
if (lut->ctx != ctx)
continue;
- if (lut->handle != iter.index)
+ if (lut->handle != xas.xa_index)
continue;
list_del(&lut->obj_link);
if (&lut->obj_link != &obj->lut_list) {
i915_lut_handle_free(lut);
- radix_tree_iter_delete(&ctx->handles_vma, &iter, slot);
+ xas_store(&xas, NULL);
if (atomic_dec_and_test(&vma->open_count) &&
!i915_vma_is_ggtt(vma))
i915_vma_close(vma);
}
RCU_INIT_POINTER(ctx->engines, e);
- INIT_RADIX_TREE(&ctx->handles_vma, GFP_KERNEL);
+ xa_init(&ctx->handles_vma);
INIT_LIST_HEAD(&ctx->hw_id_link);
/* NB: Mark all slices as needing a remap so that when the context first
u8 remap_slice;
/**
- * handles_vma: rbtree to look up our context specific obj/vma for
- * the user handle. (user handles are per fd, but the binding is
- * per vm, which may be one per context or shared with the global GTT)
+ * handles_vma: map user_handle to our context specific obj/vma.
+ * User handles are per fd, but the binding is per vm, which may
+ * be one per context or shared with the global GTT.
*/
- struct radix_tree_root handles_vma;
+ struct xarray handles_vma;
};
#endif /* __I915_GEM_CONTEXT_TYPES_H__ */
static int eb_lookup_vmas(struct i915_execbuffer *eb)
{
- struct radix_tree_root *handles_vma = &eb->gem_context->handles_vma;
+ struct xarray *handles_vma = &eb->gem_context->handles_vma;
struct drm_i915_gem_object *obj;
unsigned int i, batch;
int err;
struct i915_lut_handle *lut;
struct i915_vma *vma;
- vma = radix_tree_lookup(handles_vma, handle);
+ vma = xa_load(handles_vma, handle);
if (likely(vma))
goto add_vma;
goto err_obj;
}
- err = radix_tree_insert(handles_vma, handle, vma);
+ err = xa_err(xa_store(handles_vma, handle, vma, GFP_KERNEL));
if (unlikely(err)) {
i915_lut_handle_free(lut);
goto err_obj;
*/
mutex_lock(&ctx->mutex);
- vma = radix_tree_delete(&ctx->handles_vma, lut->handle);
+ vma = xa_erase(&ctx->handles_vma, lut->handle);
if (vma) {
GEM_BUG_ON(vma->obj != obj);
GEM_BUG_ON(!atomic_read(&vma->open_count));
goto err_free;
RCU_INIT_POINTER(ctx->engines, e);
- INIT_RADIX_TREE(&ctx->handles_vma, GFP_KERNEL);
+ xa_init(&ctx->handles_vma);
INIT_LIST_HEAD(&ctx->hw_id_link);
mutex_init(&ctx->mutex);