drm: etnaviv: Switch to use drm_gem_object reservation_object
authorRob Herring <robh@kernel.org>
Sat, 2 Feb 2019 15:41:55 +0000 (09:41 -0600)
committerMaxime Ripard <maxime.ripard@bootlin.com>
Tue, 19 Feb 2019 10:08:40 +0000 (11:08 +0100)
Now that the base struct drm_gem_object has a reservation_object, use it
and remove the private BO one.

Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Russell King <linux+etnaviv@armlinux.org.uk>
Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: etnaviv@lists.freedesktop.org
Signed-off-by: Rob Herring <robh@kernel.org>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190202154158.10443-3-robh@kernel.org
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
drivers/gpu/drm/etnaviv/etnaviv_drv.c
drivers/gpu/drm/etnaviv/etnaviv_drv.h
drivers/gpu/drm/etnaviv/etnaviv_gem.c
drivers/gpu/drm/etnaviv/etnaviv_gem.h
drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c

index 18c27f795cf612c89304cab2e72e94aa46e199b3..9f42f7538236fdb7de43e9b21cf29b655bdeb8b6 100644 (file)
@@ -473,7 +473,6 @@ static struct drm_driver etnaviv_drm_driver = {
        .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
        .gem_prime_export   = drm_gem_prime_export,
        .gem_prime_import   = drm_gem_prime_import,
-       .gem_prime_res_obj  = etnaviv_gem_prime_res_obj,
        .gem_prime_pin      = etnaviv_gem_prime_pin,
        .gem_prime_unpin    = etnaviv_gem_prime_unpin,
        .gem_prime_get_sg_table = etnaviv_gem_prime_get_sg_table,
index a6a7ded37ef1d0678bd8fb1acad77012c841ddb8..6044ace6bb3eb313171bb7f70a5f66593e68ffcf 100644 (file)
@@ -60,7 +60,6 @@ void *etnaviv_gem_prime_vmap(struct drm_gem_object *obj);
 void etnaviv_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
 int etnaviv_gem_prime_mmap(struct drm_gem_object *obj,
                           struct vm_area_struct *vma);
-struct reservation_object *etnaviv_gem_prime_res_obj(struct drm_gem_object *obj);
 struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev,
        struct dma_buf_attachment *attach, struct sg_table *sg);
 int etnaviv_gem_prime_pin(struct drm_gem_object *obj);
index 5c48915f492dee7b83ca7ea276efc9cca281b859..c60752ef73244298f48dc0e732eddf8849896f79 100644 (file)
@@ -397,13 +397,13 @@ int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op,
        }
 
        if (op & ETNA_PREP_NOSYNC) {
-               if (!reservation_object_test_signaled_rcu(etnaviv_obj->resv,
+               if (!reservation_object_test_signaled_rcu(obj->resv,
                                                          write))
                        return -EBUSY;
        } else {
                unsigned long remain = etnaviv_timeout_to_jiffies(timeout);
 
-               ret = reservation_object_wait_timeout_rcu(etnaviv_obj->resv,
+               ret = reservation_object_wait_timeout_rcu(obj->resv,
                                                          write, true, remain);
                if (ret <= 0)
                        return ret == 0 ? -ETIMEDOUT : ret;
@@ -459,7 +459,7 @@ static void etnaviv_gem_describe_fence(struct dma_fence *fence,
 static void etnaviv_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
 {
        struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj);
-       struct reservation_object *robj = etnaviv_obj->resv;
+       struct reservation_object *robj = obj->resv;
        struct reservation_object_list *fobj;
        struct dma_fence *fence;
        unsigned long off = drm_vma_node_start(&obj->vma_node);
@@ -549,8 +549,6 @@ void etnaviv_gem_free_object(struct drm_gem_object *obj)
 
        drm_gem_free_mmap_offset(obj);
        etnaviv_obj->ops->release(etnaviv_obj);
-       if (etnaviv_obj->resv == &etnaviv_obj->_resv)
-               reservation_object_fini(&etnaviv_obj->_resv);
        drm_gem_object_release(obj);
 
        kfree(etnaviv_obj);
@@ -596,12 +594,8 @@ static int etnaviv_gem_new_impl(struct drm_device *dev, u32 size, u32 flags,
 
        etnaviv_obj->flags = flags;
        etnaviv_obj->ops = ops;
-       if (robj) {
-               etnaviv_obj->resv = robj;
-       } else {
-               etnaviv_obj->resv = &etnaviv_obj->_resv;
-               reservation_object_init(&etnaviv_obj->_resv);
-       }
+       if (robj)
+               etnaviv_obj->base.resv = robj;
 
        mutex_init(&etnaviv_obj->lock);
        INIT_LIST_HEAD(&etnaviv_obj->vram_list);
index 76079c2291f88336521e412246a0646d2fcfb215..7015837ccc1ca861537882aa3b33e73aa94cfc71 100644 (file)
@@ -47,10 +47,6 @@ struct etnaviv_gem_object {
        struct sg_table *sgt;
        void *vaddr;
 
-       /* normally (resv == &_resv) except for imported bo's */
-       struct reservation_object *resv;
-       struct reservation_object _resv;
-
        struct list_head vram_list;
 
        /* cache maintenance */
index 0566171f8df22f65e0236bf37afe204e828f688b..01e7ad96339cdadd23ae1cd5d828bc794b35eb38 100644 (file)
@@ -139,10 +139,3 @@ fail:
 
        return ERR_PTR(ret);
 }
-
-struct reservation_object *etnaviv_gem_prime_res_obj(struct drm_gem_object *obj)
-{
-       struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj);
-
-       return etnaviv_obj->resv;
-}
index 30875f8f293371ccd240be02b826302a8abeed08..a10281e915e53fc32408dfaa6c6eac274e5628a3 100644 (file)
@@ -108,9 +108,9 @@ out_unlock:
 static void submit_unlock_object(struct etnaviv_gem_submit *submit, int i)
 {
        if (submit->bos[i].flags & BO_LOCKED) {
-               struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj;
+               struct drm_gem_object *obj = &submit->bos[i].obj->base;
 
-               ww_mutex_unlock(&etnaviv_obj->resv->lock);
+               ww_mutex_unlock(&obj->resv->lock);
                submit->bos[i].flags &= ~BO_LOCKED;
        }
 }
@@ -122,7 +122,7 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit,
 
 retry:
        for (i = 0; i < submit->nr_bos; i++) {
-               struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj;
+               struct drm_gem_object *obj = &submit->bos[i].obj->base;
 
                if (slow_locked == i)
                        slow_locked = -1;
@@ -130,7 +130,7 @@ retry:
                contended = i;
 
                if (!(submit->bos[i].flags & BO_LOCKED)) {
-                       ret = ww_mutex_lock_interruptible(&etnaviv_obj->resv->lock,
+                       ret = ww_mutex_lock_interruptible(&obj->resv->lock,
                                                          ticket);
                        if (ret == -EALREADY)
                                DRM_ERROR("BO at index %u already on submit list\n",
@@ -153,12 +153,12 @@ fail:
                submit_unlock_object(submit, slow_locked);
 
        if (ret == -EDEADLK) {
-               struct etnaviv_gem_object *etnaviv_obj;
+               struct drm_gem_object *obj;
 
-               etnaviv_obj = submit->bos[contended].obj;
+               obj = &submit->bos[contended].obj->base;
 
                /* we lost out in a seqno race, lock and retry.. */
-               ret = ww_mutex_lock_slow_interruptible(&etnaviv_obj->resv->lock,
+               ret = ww_mutex_lock_slow_interruptible(&obj->resv->lock,
                                                       ticket);
                if (!ret) {
                        submit->bos[contended].flags |= BO_LOCKED;
@@ -176,7 +176,7 @@ static int submit_fence_sync(struct etnaviv_gem_submit *submit)
 
        for (i = 0; i < submit->nr_bos; i++) {
                struct etnaviv_gem_submit_bo *bo = &submit->bos[i];
-               struct reservation_object *robj = bo->obj->resv;
+               struct reservation_object *robj = bo->obj->base.resv;
 
                if (!(bo->flags & ETNA_SUBMIT_BO_WRITE)) {
                        ret = reservation_object_reserve_shared(robj, 1);
@@ -207,13 +207,13 @@ static void submit_attach_object_fences(struct etnaviv_gem_submit *submit)
        int i;
 
        for (i = 0; i < submit->nr_bos; i++) {
-               struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj;
+               struct drm_gem_object *obj = &submit->bos[i].obj->base;
 
                if (submit->bos[i].flags & ETNA_SUBMIT_BO_WRITE)
-                       reservation_object_add_excl_fence(etnaviv_obj->resv,
+                       reservation_object_add_excl_fence(obj->resv,
                                                          submit->out_fence);
                else
-                       reservation_object_add_shared_fence(etnaviv_obj->resv,
+                       reservation_object_add_shared_fence(obj->resv,
                                                            submit->out_fence);
 
                submit_unlock_object(submit, i);