Commit 08301d73 authored by Lucas Stach's avatar Lucas Stach

drm/etnaviv: move ww_acquire_ctx out of submit object

The acquire_ctx is special in that it needs to be released from the same
thread as has been used to initialize it. This collides with the intention to
extend the submit lifetime beyond the gem_submit function with potentially
other threads doing the final cleanup.

Move the ww_acquire_ctx to the function local stack as suggested in the
documentation.
Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
Reviewed-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
parent 33a63e68
...@@ -102,7 +102,6 @@ struct etnaviv_gem_submit_bo { ...@@ -102,7 +102,6 @@ struct etnaviv_gem_submit_bo {
*/ */
struct etnaviv_gem_submit { struct etnaviv_gem_submit {
struct etnaviv_gpu *gpu; struct etnaviv_gpu *gpu;
struct ww_acquire_ctx ticket;
struct dma_fence *out_fence, *in_fence; struct dma_fence *out_fence, *in_fence;
u32 flags; u32 flags;
unsigned int nr_bos; unsigned int nr_bos;
......
...@@ -44,8 +44,6 @@ static struct etnaviv_gem_submit *submit_create(struct drm_device *dev, ...@@ -44,8 +44,6 @@ static struct etnaviv_gem_submit *submit_create(struct drm_device *dev,
submit->gpu = gpu; submit->gpu = gpu;
ww_acquire_init(&submit->ticket, &reservation_ww_class);
return submit; return submit;
} }
...@@ -107,7 +105,8 @@ static void submit_unlock_object(struct etnaviv_gem_submit *submit, int i) ...@@ -107,7 +105,8 @@ static void submit_unlock_object(struct etnaviv_gem_submit *submit, int i)
} }
} }
static int submit_lock_objects(struct etnaviv_gem_submit *submit) static int submit_lock_objects(struct etnaviv_gem_submit *submit,
struct ww_acquire_ctx *ticket)
{ {
int contended, slow_locked = -1, i, ret = 0; int contended, slow_locked = -1, i, ret = 0;
...@@ -122,7 +121,7 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit) ...@@ -122,7 +121,7 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit)
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(&etnaviv_obj->resv->lock,
&submit->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",
i); i);
...@@ -132,7 +131,7 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit) ...@@ -132,7 +131,7 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit)
} }
} }
ww_acquire_done(&submit->ticket); ww_acquire_done(ticket);
return 0; return 0;
...@@ -150,7 +149,7 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit) ...@@ -150,7 +149,7 @@ static int submit_lock_objects(struct etnaviv_gem_submit *submit)
/* 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(&etnaviv_obj->resv->lock,
&submit->ticket); ticket);
if (!ret) { if (!ret) {
submit->bos[contended].flags |= BO_LOCKED; submit->bos[contended].flags |= BO_LOCKED;
slow_locked = contended; slow_locked = contended;
...@@ -361,7 +360,6 @@ static void submit_cleanup(struct etnaviv_gem_submit *submit) ...@@ -361,7 +360,6 @@ static void submit_cleanup(struct etnaviv_gem_submit *submit)
drm_gem_object_put_unlocked(&etnaviv_obj->base); drm_gem_object_put_unlocked(&etnaviv_obj->base);
} }
ww_acquire_fini(&submit->ticket);
if (submit->in_fence) if (submit->in_fence)
dma_fence_put(submit->in_fence); dma_fence_put(submit->in_fence);
if (submit->out_fence) if (submit->out_fence)
...@@ -381,6 +379,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, ...@@ -381,6 +379,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
struct etnaviv_cmdbuf *cmdbuf; struct etnaviv_cmdbuf *cmdbuf;
struct etnaviv_gpu *gpu; struct etnaviv_gpu *gpu;
struct sync_file *sync_file = NULL; struct sync_file *sync_file = NULL;
struct ww_acquire_ctx ticket;
int out_fence_fd = -1; int out_fence_fd = -1;
void *stream; void *stream;
int ret; int ret;
...@@ -466,10 +465,12 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, ...@@ -466,10 +465,12 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
} }
} }
ww_acquire_init(&ticket, &reservation_ww_class);
submit = submit_create(dev, gpu, args->nr_bos); submit = submit_create(dev, gpu, args->nr_bos);
if (!submit) { if (!submit) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_submit_cmds; goto err_submit_ww_acquire;
} }
submit->flags = args->flags; submit->flags = args->flags;
...@@ -478,7 +479,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, ...@@ -478,7 +479,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
if (ret) if (ret)
goto err_submit_objects; goto err_submit_objects;
ret = submit_lock_objects(submit); ret = submit_lock_objects(submit, &ticket);
if (ret) if (ret)
goto err_submit_objects; goto err_submit_objects;
...@@ -545,6 +546,9 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, ...@@ -545,6 +546,9 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
err_submit_objects: err_submit_objects:
submit_cleanup(submit); submit_cleanup(submit);
err_submit_ww_acquire:
ww_acquire_fini(&ticket);
err_submit_cmds: err_submit_cmds:
if (ret && (out_fence_fd >= 0)) if (ret && (out_fence_fd >= 0))
put_unused_fd(out_fence_fd); put_unused_fd(out_fence_fd);
......
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