Commit bd7de1e8 authored by Rob Herring's avatar Rob Herring Committed by Maxime Ripard

drm: vc4: Switch to use drm_gem_object reservation_object

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: default avatarEric Anholt <eric@anholt.net>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190202154158.10443-6-robh@kernel.orgSigned-off-by: default avatarMaxime Ripard <maxime.ripard@bootlin.com>
parent 8d668309
...@@ -201,8 +201,6 @@ static void vc4_bo_destroy(struct vc4_bo *bo) ...@@ -201,8 +201,6 @@ static void vc4_bo_destroy(struct vc4_bo *bo)
bo->validated_shader = NULL; bo->validated_shader = NULL;
} }
reservation_object_fini(&bo->_resv);
drm_gem_cma_free_object(obj); drm_gem_cma_free_object(obj);
} }
...@@ -427,8 +425,6 @@ struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size) ...@@ -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].num_allocated++;
vc4->bo_labels[VC4_BO_TYPE_KERNEL].size_allocated += size; vc4->bo_labels[VC4_BO_TYPE_KERNEL].size_allocated += size;
mutex_unlock(&vc4->bo_lock); mutex_unlock(&vc4->bo_lock);
bo->resv = &bo->_resv;
reservation_object_init(bo->resv);
return &bo->base.base; return &bo->base.base;
} }
...@@ -684,13 +680,6 @@ static void vc4_bo_cache_time_timer(struct timer_list *t) ...@@ -684,13 +680,6 @@ static void vc4_bo_cache_time_timer(struct timer_list *t)
schedule_work(&vc4->bo_cache.time_work); 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 * struct dma_buf *
vc4_prime_export(struct drm_device *dev, struct drm_gem_object *obj, int flags) 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, ...@@ -822,14 +811,12 @@ vc4_prime_import_sg_table(struct drm_device *dev,
struct sg_table *sgt) struct sg_table *sgt)
{ {
struct drm_gem_object *obj; struct drm_gem_object *obj;
struct vc4_bo *bo;
obj = drm_gem_cma_prime_import_sg_table(dev, attach, sgt); obj = drm_gem_cma_prime_import_sg_table(dev, attach, sgt);
if (IS_ERR(obj)) if (IS_ERR(obj))
return obj; return obj;
bo = to_vc4_bo(obj); obj->resv = attach->dmabuf->resv;
bo->resv = attach->dmabuf->resv;
return obj; return obj;
} }
......
...@@ -200,7 +200,6 @@ static struct drm_driver vc4_drm_driver = { ...@@ -200,7 +200,6 @@ static struct drm_driver vc4_drm_driver = {
.prime_fd_to_handle = drm_gem_prime_fd_to_handle, .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_import = drm_gem_prime_import, .gem_prime_import = drm_gem_prime_import,
.gem_prime_export = vc4_prime_export, .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_get_sg_table = drm_gem_cma_prime_get_sg_table,
.gem_prime_import_sg_table = vc4_prime_import_sg_table, .gem_prime_import_sg_table = vc4_prime_import_sg_table,
.gem_prime_vmap = vc4_prime_vmap, .gem_prime_vmap = vc4_prime_vmap,
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
*/ */
#include <linux/mm_types.h> #include <linux/mm_types.h>
#include <linux/reservation.h>
#include <drm/drmP.h> #include <drm/drmP.h>
#include <drm/drm_util.h> #include <drm/drm_util.h>
#include <drm/drm_encoder.h> #include <drm/drm_encoder.h>
...@@ -240,10 +239,6 @@ struct vc4_bo { ...@@ -240,10 +239,6 @@ struct vc4_bo {
*/ */
struct vc4_validated_shader_info *validated_shader; 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 /* One of enum vc4_kernel_bo_type, or VC4_BO_TYPE_COUNT + i
* for user-allocated labels. * for user-allocated labels.
*/ */
...@@ -685,7 +680,6 @@ int vc4_label_bo_ioctl(struct drm_device *dev, void *data, ...@@ -685,7 +680,6 @@ int vc4_label_bo_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv); struct drm_file *file_priv);
vm_fault_t vc4_fault(struct vm_fault *vmf); vm_fault_t vc4_fault(struct vm_fault *vmf);
int vc4_mmap(struct file *filp, struct vm_area_struct *vma); 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); 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 drm_gem_object *vc4_prime_import_sg_table(struct drm_device *dev,
struct dma_buf_attachment *attach, struct dma_buf_attachment *attach,
......
...@@ -536,7 +536,7 @@ vc4_update_bo_seqnos(struct vc4_exec_info *exec, uint64_t seqno) ...@@ -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 = to_vc4_bo(&exec->bo[i]->base);
bo->seqno = seqno; 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) { 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) ...@@ -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 = to_vc4_bo(&exec->rcl_write_bo[i]->base);
bo->write_seqno = seqno; 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, ...@@ -559,7 +559,7 @@ vc4_unlock_bo_reservations(struct drm_device *dev,
int i; int i;
for (i = 0; i < exec->bo_count; 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); ww_mutex_unlock(&bo->resv->lock);
} }
...@@ -581,13 +581,13 @@ vc4_lock_bo_reservations(struct drm_device *dev, ...@@ -581,13 +581,13 @@ vc4_lock_bo_reservations(struct drm_device *dev,
{ {
int contended_lock = -1; int contended_lock = -1;
int i, ret; int i, ret;
struct vc4_bo *bo; struct drm_gem_object *bo;
ww_acquire_init(acquire_ctx, &reservation_ww_class); ww_acquire_init(acquire_ctx, &reservation_ww_class);
retry: retry:
if (contended_lock != -1) { 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, ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock,
acquire_ctx); acquire_ctx);
if (ret) { if (ret) {
...@@ -600,19 +600,19 @@ vc4_lock_bo_reservations(struct drm_device *dev, ...@@ -600,19 +600,19 @@ vc4_lock_bo_reservations(struct drm_device *dev,
if (i == contended_lock) if (i == contended_lock)
continue; continue;
bo = to_vc4_bo(&exec->bo[i]->base); bo = &exec->bo[i]->base;
ret = ww_mutex_lock_interruptible(&bo->resv->lock, acquire_ctx); ret = ww_mutex_lock_interruptible(&bo->resv->lock, acquire_ctx);
if (ret) { if (ret) {
int j; int j;
for (j = 0; j < i; 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); ww_mutex_unlock(&bo->resv->lock);
} }
if (contended_lock != -1 && contended_lock >= i) { 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); ww_mutex_unlock(&bo->resv->lock);
} }
...@@ -633,7 +633,7 @@ vc4_lock_bo_reservations(struct drm_device *dev, ...@@ -633,7 +633,7 @@ vc4_lock_bo_reservations(struct drm_device *dev,
* before we commit the CL to the hardware. * before we commit the CL to the hardware.
*/ */
for (i = 0; i < exec->bo_count; i++) { 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); ret = reservation_object_reserve_shared(bo->resv, 1);
if (ret) { if (ret) {
......
...@@ -1082,7 +1082,7 @@ static int vc4_prepare_fb(struct drm_plane *plane, ...@@ -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); 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); drm_atomic_set_fence_for_plane(state, fence);
if (plane->state->fb == state->fb) if (plane->state->fb == state->fb)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment