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

drm: etnaviv: 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: 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: default avatarRob Herring <robh@kernel.org>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: default avatarChristian Gmeiner <christian.gmeiner@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190202154158.10443-3-robh@kernel.orgSigned-off-by: default avatarMaxime Ripard <maxime.ripard@bootlin.com>
parent 1ba62714
...@@ -473,7 +473,6 @@ static struct drm_driver etnaviv_drm_driver = { ...@@ -473,7 +473,6 @@ static struct drm_driver etnaviv_drm_driver = {
.prime_fd_to_handle = drm_gem_prime_fd_to_handle, .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_export = drm_gem_prime_export, .gem_prime_export = drm_gem_prime_export,
.gem_prime_import = drm_gem_prime_import, .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_pin = etnaviv_gem_prime_pin,
.gem_prime_unpin = etnaviv_gem_prime_unpin, .gem_prime_unpin = etnaviv_gem_prime_unpin,
.gem_prime_get_sg_table = etnaviv_gem_prime_get_sg_table, .gem_prime_get_sg_table = etnaviv_gem_prime_get_sg_table,
......
...@@ -60,7 +60,6 @@ void *etnaviv_gem_prime_vmap(struct drm_gem_object *obj); ...@@ -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); void etnaviv_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
int etnaviv_gem_prime_mmap(struct drm_gem_object *obj, int etnaviv_gem_prime_mmap(struct drm_gem_object *obj,
struct vm_area_struct *vma); 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 drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev,
struct dma_buf_attachment *attach, struct sg_table *sg); struct dma_buf_attachment *attach, struct sg_table *sg);
int etnaviv_gem_prime_pin(struct drm_gem_object *obj); int etnaviv_gem_prime_pin(struct drm_gem_object *obj);
......
...@@ -397,13 +397,13 @@ int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op, ...@@ -397,13 +397,13 @@ int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op,
} }
if (op & ETNA_PREP_NOSYNC) { if (op & ETNA_PREP_NOSYNC) {
if (!reservation_object_test_signaled_rcu(etnaviv_obj->resv, if (!reservation_object_test_signaled_rcu(obj->resv,
write)) write))
return -EBUSY; return -EBUSY;
} else { } else {
unsigned long remain = etnaviv_timeout_to_jiffies(timeout); 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); write, true, remain);
if (ret <= 0) if (ret <= 0)
return ret == 0 ? -ETIMEDOUT : ret; return ret == 0 ? -ETIMEDOUT : ret;
...@@ -459,7 +459,7 @@ static void etnaviv_gem_describe_fence(struct dma_fence *fence, ...@@ -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) 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 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 reservation_object_list *fobj;
struct dma_fence *fence; struct dma_fence *fence;
unsigned long off = drm_vma_node_start(&obj->vma_node); unsigned long off = drm_vma_node_start(&obj->vma_node);
...@@ -549,8 +549,6 @@ void etnaviv_gem_free_object(struct drm_gem_object *obj) ...@@ -549,8 +549,6 @@ void etnaviv_gem_free_object(struct drm_gem_object *obj)
drm_gem_free_mmap_offset(obj); drm_gem_free_mmap_offset(obj);
etnaviv_obj->ops->release(etnaviv_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); drm_gem_object_release(obj);
kfree(etnaviv_obj); kfree(etnaviv_obj);
...@@ -596,12 +594,8 @@ static int etnaviv_gem_new_impl(struct drm_device *dev, u32 size, u32 flags, ...@@ -596,12 +594,8 @@ static int etnaviv_gem_new_impl(struct drm_device *dev, u32 size, u32 flags,
etnaviv_obj->flags = flags; etnaviv_obj->flags = flags;
etnaviv_obj->ops = ops; etnaviv_obj->ops = ops;
if (robj) { if (robj)
etnaviv_obj->resv = robj; etnaviv_obj->base.resv = robj;
} else {
etnaviv_obj->resv = &etnaviv_obj->_resv;
reservation_object_init(&etnaviv_obj->_resv);
}
mutex_init(&etnaviv_obj->lock); mutex_init(&etnaviv_obj->lock);
INIT_LIST_HEAD(&etnaviv_obj->vram_list); INIT_LIST_HEAD(&etnaviv_obj->vram_list);
......
...@@ -47,10 +47,6 @@ struct etnaviv_gem_object { ...@@ -47,10 +47,6 @@ struct etnaviv_gem_object {
struct sg_table *sgt; struct sg_table *sgt;
void *vaddr; void *vaddr;
/* normally (resv == &_resv) except for imported bo's */
struct reservation_object *resv;
struct reservation_object _resv;
struct list_head vram_list; struct list_head vram_list;
/* cache maintenance */ /* cache maintenance */
......
...@@ -139,10 +139,3 @@ struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev, ...@@ -139,10 +139,3 @@ struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev,
return ERR_PTR(ret); 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;
}
...@@ -108,9 +108,9 @@ static int submit_lookup_objects(struct etnaviv_gem_submit *submit, ...@@ -108,9 +108,9 @@ static int submit_lookup_objects(struct etnaviv_gem_submit *submit,
static void submit_unlock_object(struct etnaviv_gem_submit *submit, int i) static void submit_unlock_object(struct etnaviv_gem_submit *submit, int i)
{ {
if (submit->bos[i].flags & BO_LOCKED) { 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; submit->bos[i].flags &= ~BO_LOCKED;
} }
} }
...@@ -122,7 +122,7 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit, ...@@ -122,7 +122,7 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit,
retry: retry:
for (i = 0; i < submit->nr_bos; 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 (slow_locked == i) if (slow_locked == i)
slow_locked = -1; slow_locked = -1;
...@@ -130,7 +130,7 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit, ...@@ -130,7 +130,7 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit,
contended = i; contended = i;
if (!(submit->bos[i].flags & BO_LOCKED)) { 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); ticket);
if (ret == -EALREADY) if (ret == -EALREADY)
DRM_ERROR("BO at index %u already on submit list\n", DRM_ERROR("BO at index %u already on submit list\n",
...@@ -153,12 +153,12 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit, ...@@ -153,12 +153,12 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit,
submit_unlock_object(submit, slow_locked); submit_unlock_object(submit, slow_locked);
if (ret == -EDEADLK) { 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.. */ /* 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); ticket);
if (!ret) { if (!ret) {
submit->bos[contended].flags |= BO_LOCKED; submit->bos[contended].flags |= BO_LOCKED;
...@@ -176,7 +176,7 @@ static int submit_fence_sync(struct etnaviv_gem_submit *submit) ...@@ -176,7 +176,7 @@ static int submit_fence_sync(struct etnaviv_gem_submit *submit)
for (i = 0; i < submit->nr_bos; i++) { for (i = 0; i < submit->nr_bos; i++) {
struct etnaviv_gem_submit_bo *bo = &submit->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)) { if (!(bo->flags & ETNA_SUBMIT_BO_WRITE)) {
ret = reservation_object_reserve_shared(robj, 1); ret = reservation_object_reserve_shared(robj, 1);
...@@ -207,13 +207,13 @@ static void submit_attach_object_fences(struct etnaviv_gem_submit *submit) ...@@ -207,13 +207,13 @@ static void submit_attach_object_fences(struct etnaviv_gem_submit *submit)
int i; int i;
for (i = 0; i < submit->nr_bos; 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) 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); submit->out_fence);
else else
reservation_object_add_shared_fence(etnaviv_obj->resv, reservation_object_add_shared_fence(obj->resv,
submit->out_fence); submit->out_fence);
submit_unlock_object(submit, i); submit_unlock_object(submit, i);
......
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