]> www.infradead.org Git - users/willy/xarray.git/commitdiff
drm/etnaviv: Convert fence_idr to XArray
authorMatthew Wilcox <willy@infradead.org>
Tue, 8 Jan 2019 14:28:28 +0000 (09:28 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 8 Aug 2019 03:39:32 +0000 (23:39 -0400)
Signed-off-by: Matthew Wilcox <willy@infradead.org>
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
drivers/gpu/drm/etnaviv/etnaviv_gpu.c
drivers/gpu/drm/etnaviv/etnaviv_gpu.h
drivers/gpu/drm/etnaviv/etnaviv_sched.c

index 50c575118522bde72df8e3cd7d4e9400f789c0b9..f1338402512c7a0dc54818271f3d0a25e21831bd 100644 (file)
@@ -377,9 +377,7 @@ static void submit_cleanup(struct kref *kref)
                dma_fence_put(submit->in_fence);
        if (submit->out_fence) {
                /* first remove from IDR, so fence can not be found anymore */
-               mutex_lock(&submit->gpu->fence_lock);
-               idr_remove(&submit->gpu->fence_idr, submit->out_fence_id);
-               mutex_unlock(&submit->gpu->fence_lock);
+               xa_erase(&submit->gpu->fences, submit->out_fence_id);
                dma_fence_put(submit->out_fence);
        }
        kfree(submit->pmrs);
index 5418a1a87b2cb8f1a12e69de3dcbf881d00317ca..12f60def964f63f7874c0374de9430c3323850fc 100644 (file)
@@ -1148,7 +1148,7 @@ int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu,
         * pretends we didn't find a fence in that case.
         */
        rcu_read_lock();
-       fence = idr_find(&gpu->fence_idr, id);
+       fence = xa_load(&gpu->fences, id);
        if (fence)
                fence = dma_fence_get_rcu(fence);
        rcu_read_unlock();
@@ -1631,7 +1631,7 @@ static int etnaviv_gpu_bind(struct device *dev, struct device *master,
 
        gpu->drm = drm;
        gpu->fence_context = dma_fence_context_alloc(1);
-       idr_init(&gpu->fence_idr);
+       xa_init_flags(&gpu->fences, XA_FLAGS_ALLOC);
        spin_lock_init(&gpu->fence_spinlock);
 
        INIT_WORK(&gpu->sync_point_work, sync_point_worker);
@@ -1690,7 +1690,6 @@ static void etnaviv_gpu_unbind(struct device *dev, struct device *master,
        }
 
        gpu->drm = NULL;
-       idr_destroy(&gpu->fence_idr);
 
        if (IS_ENABLED(CONFIG_DRM_ETNAVIV_THERMAL))
                thermal_cooling_device_unregister(gpu->cooling);
index 9bcf151f706bb7d1da8d518a92d2b446134fbad9..d87406ffecb511f0be8f5e670833ef8611c2276c 100644 (file)
@@ -117,7 +117,8 @@ struct etnaviv_gpu {
 
        /* Fencing support */
        struct mutex fence_lock;
-       struct idr fence_idr;
+       struct xarray fences;
+       u32 fences_next;        /* For the XArray allocation */
        u32 next_fence;
        u32 completed_fence;
        wait_queue_head_t fence_event;
index a813c824e154458f4eae55936270d9338a9e2240..8be325edf659ff18624dbcf34067361d83beb492 100644 (file)
@@ -158,10 +158,10 @@ int etnaviv_sched_push_job(struct drm_sched_entity *sched_entity,
                goto out_unlock;
 
        submit->out_fence = dma_fence_get(&submit->sched_job.s_fence->finished);
-       submit->out_fence_id = idr_alloc_cyclic(&submit->gpu->fence_idr,
-                                               submit->out_fence, 0,
-                                               INT_MAX, GFP_KERNEL);
-       if (submit->out_fence_id < 0) {
+       ret = xa_alloc_cyclic(&submit->gpu->fences, &submit->out_fence_id,
+                               submit->out_fence, xa_limit_31b,
+                               &submit->gpu->fences_next, GFP_KERNEL);
+       if (ret < 0) {
                drm_sched_job_cleanup(&submit->sched_job);
                ret = -ENOMEM;
                goto out_unlock;