drm: vc4: Switch to use drm_gem_object reservation_object
authorRob Herring <robh@kernel.org>
Sat, 2 Feb 2019 15:41:58 +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: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Eric Anholt <eric@anholt.net>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190202154158.10443-6-robh@kernel.org
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
drivers/gpu/drm/vc4/vc4_bo.c
drivers/gpu/drm/vc4/vc4_drv.c
drivers/gpu/drm/vc4/vc4_drv.h
drivers/gpu/drm/vc4/vc4_gem.c
drivers/gpu/drm/vc4/vc4_plane.c

index 8dcce7182bb7c06e23187dea7852388bf9d350b3..92e3f98d8478011bca5a1a4643d6a453d77d3d58 100644 (file)
@@ -201,8 +201,6 @@ static void vc4_bo_destroy(struct vc4_bo *bo)
                bo->validated_shader = NULL;
        }
 
-       reservation_object_fini(&bo->_resv);
-
        drm_gem_cma_free_object(obj);
 }
 
@@ -427,8 +425,6 @@ struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size)
        vc4->bo_labels[VC4_BO_TYPE_KERNEL].num_allocated++;
        vc4->bo_labels[VC4_BO_TYPE_KERNEL].size_allocated += size;
        mutex_unlock(&vc4->bo_lock);
-       bo->resv = &bo->_resv;
-       reservation_object_init(bo->resv);
 
        return &bo->base.base;
 }
@@ -684,13 +680,6 @@ static void vc4_bo_cache_time_timer(struct timer_list *t)
        schedule_work(&vc4->bo_cache.time_work);
 }
 
-struct reservation_object *vc4_prime_res_obj(struct drm_gem_object *obj)
-{
-       struct vc4_bo *bo = to_vc4_bo(obj);
-
-       return bo->resv;
-}
-
 struct dma_buf *
 vc4_prime_export(struct drm_device *dev, struct drm_gem_object *obj, int flags)
 {
@@ -822,14 +811,12 @@ vc4_prime_import_sg_table(struct drm_device *dev,
                          struct sg_table *sgt)
 {
        struct drm_gem_object *obj;
-       struct vc4_bo *bo;
 
        obj = drm_gem_cma_prime_import_sg_table(dev, attach, sgt);
        if (IS_ERR(obj))
                return obj;
 
-       bo = to_vc4_bo(obj);
-       bo->resv = attach->dmabuf->resv;
+       obj->resv = attach->dmabuf->resv;
 
        return obj;
 }
index 5fcd2f0da7f7c56236150a1c2f4784ab6094a9eb..52576dee809e77d016576c30e988602e26caddf3 100644 (file)
@@ -200,7 +200,6 @@ static struct drm_driver vc4_drm_driver = {
        .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
        .gem_prime_import = drm_gem_prime_import,
        .gem_prime_export = vc4_prime_export,
-       .gem_prime_res_obj = vc4_prime_res_obj,
        .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
        .gem_prime_import_sg_table = vc4_prime_import_sg_table,
        .gem_prime_vmap = vc4_prime_vmap,
index 2c635f001c711b03b83614d1fba7fbe472b094dc..ce1af06cc197bae14da588bbce3224b118dceef4 100644 (file)
@@ -7,7 +7,6 @@
  */
 
 #include <linux/mm_types.h>
-#include <linux/reservation.h>
 #include <drm/drmP.h>
 #include <drm/drm_util.h>
 #include <drm/drm_encoder.h>
@@ -240,10 +239,6 @@ struct vc4_bo {
         */
        struct vc4_validated_shader_info *validated_shader;
 
-       /* normally (resv == &_resv) except for imported bo's */
-       struct reservation_object *resv;
-       struct reservation_object _resv;
-
        /* One of enum vc4_kernel_bo_type, or VC4_BO_TYPE_COUNT + i
         * for user-allocated labels.
         */
@@ -685,7 +680,6 @@ int vc4_label_bo_ioctl(struct drm_device *dev, void *data,
                       struct drm_file *file_priv);
 vm_fault_t vc4_fault(struct vm_fault *vmf);
 int vc4_mmap(struct file *filp, struct vm_area_struct *vma);
-struct reservation_object *vc4_prime_res_obj(struct drm_gem_object *obj);
 int vc4_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
 struct drm_gem_object *vc4_prime_import_sg_table(struct drm_device *dev,
                                                 struct dma_buf_attachment *attach,
index aea2b8dfec1717648e1251c3610753dcf659679c..5ee5bf7fedf7bdd63477a26711fe8e9491a4d61d 100644 (file)
@@ -536,7 +536,7 @@ vc4_update_bo_seqnos(struct vc4_exec_info *exec, uint64_t seqno)
                bo = to_vc4_bo(&exec->bo[i]->base);
                bo->seqno = seqno;
 
-               reservation_object_add_shared_fence(bo->resv, exec->fence);
+               reservation_object_add_shared_fence(bo->base.base.resv, exec->fence);
        }
 
        list_for_each_entry(bo, &exec->unref_list, unref_head) {
@@ -547,7 +547,7 @@ vc4_update_bo_seqnos(struct vc4_exec_info *exec, uint64_t seqno)
                bo = to_vc4_bo(&exec->rcl_write_bo[i]->base);
                bo->write_seqno = seqno;
 
-               reservation_object_add_excl_fence(bo->resv, exec->fence);
+               reservation_object_add_excl_fence(bo->base.base.resv, exec->fence);
        }
 }
 
@@ -559,7 +559,7 @@ vc4_unlock_bo_reservations(struct drm_device *dev,
        int i;
 
        for (i = 0; i < exec->bo_count; i++) {
-               struct vc4_bo *bo = to_vc4_bo(&exec->bo[i]->base);
+               struct drm_gem_object *bo = &exec->bo[i]->base;
 
                ww_mutex_unlock(&bo->resv->lock);
        }
@@ -581,13 +581,13 @@ vc4_lock_bo_reservations(struct drm_device *dev,
 {
        int contended_lock = -1;
        int i, ret;
-       struct vc4_bo *bo;
+       struct drm_gem_object *bo;
 
        ww_acquire_init(acquire_ctx, &reservation_ww_class);
 
 retry:
        if (contended_lock != -1) {
-               bo = to_vc4_bo(&exec->bo[contended_lock]->base);
+               bo = &exec->bo[contended_lock]->base;
                ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock,
                                                       acquire_ctx);
                if (ret) {
@@ -600,19 +600,19 @@ retry:
                if (i == contended_lock)
                        continue;
 
-               bo = to_vc4_bo(&exec->bo[i]->base);
+               bo = &exec->bo[i]->base;
 
                ret = ww_mutex_lock_interruptible(&bo->resv->lock, acquire_ctx);
                if (ret) {
                        int j;
 
                        for (j = 0; j < i; j++) {
-                               bo = to_vc4_bo(&exec->bo[j]->base);
+                               bo = &exec->bo[j]->base;
                                ww_mutex_unlock(&bo->resv->lock);
                        }
 
                        if (contended_lock != -1 && contended_lock >= i) {
-                               bo = to_vc4_bo(&exec->bo[contended_lock]->base);
+                               bo = &exec->bo[contended_lock]->base;
 
                                ww_mutex_unlock(&bo->resv->lock);
                        }
@@ -633,7 +633,7 @@ retry:
         * before we commit the CL to the hardware.
         */
        for (i = 0; i < exec->bo_count; i++) {
-               bo = to_vc4_bo(&exec->bo[i]->base);
+               bo = &exec->bo[i]->base;
 
                ret = reservation_object_reserve_shared(bo->resv, 1);
                if (ret) {
index d098337c10e9394d843c192ab08595566f631c59..1babfeca0c92b7e880f2a63fa4602cd7a9f79658 100644 (file)
@@ -1082,7 +1082,7 @@ static int vc4_prepare_fb(struct drm_plane *plane,
 
        bo = to_vc4_bo(&drm_fb_cma_get_gem_obj(state->fb, 0)->base);
 
-       fence = reservation_object_get_excl_rcu(bo->resv);
+       fence = reservation_object_get_excl_rcu(bo->base.base.resv);
        drm_atomic_set_fence_for_plane(state, fence);
 
        if (plane->state->fb == state->fb)