Commit e0329e6c authored by Lucas Stach's avatar Lucas Stach

drm/etnaviv: refcount the submit object

The submit object lifetime will get extended to the actual GPU
execution. As multiple users will depend on this, add a kref to
properly control destruction of the object.
Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
Reviewed-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
parent 08301d73
...@@ -101,6 +101,7 @@ struct etnaviv_gem_submit_bo { ...@@ -101,6 +101,7 @@ struct etnaviv_gem_submit_bo {
* lasts for the duration of the submit-ioctl. * lasts for the duration of the submit-ioctl.
*/ */
struct etnaviv_gem_submit { struct etnaviv_gem_submit {
struct kref refcount;
struct etnaviv_gpu *gpu; struct etnaviv_gpu *gpu;
struct dma_fence *out_fence, *in_fence; struct dma_fence *out_fence, *in_fence;
u32 flags; u32 flags;
...@@ -109,6 +110,8 @@ struct etnaviv_gem_submit { ...@@ -109,6 +110,8 @@ struct etnaviv_gem_submit {
/* No new members here, the previous one is variable-length! */ /* No new members here, the previous one is variable-length! */
}; };
void etnaviv_submit_put(struct etnaviv_gem_submit * submit);
int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj, int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj,
struct timespec *timeout); struct timespec *timeout);
int etnaviv_gem_new_private(struct drm_device *dev, size_t size, u32 flags, int etnaviv_gem_new_private(struct drm_device *dev, size_t size, u32 flags,
......
...@@ -43,6 +43,7 @@ static struct etnaviv_gem_submit *submit_create(struct drm_device *dev, ...@@ -43,6 +43,7 @@ static struct etnaviv_gem_submit *submit_create(struct drm_device *dev,
return NULL; return NULL;
submit->gpu = gpu; submit->gpu = gpu;
kref_init(&submit->refcount);
return submit; return submit;
} }
...@@ -341,8 +342,10 @@ static int submit_perfmon_validate(struct etnaviv_gem_submit *submit, ...@@ -341,8 +342,10 @@ static int submit_perfmon_validate(struct etnaviv_gem_submit *submit,
return 0; return 0;
} }
static void submit_cleanup(struct etnaviv_gem_submit *submit) static void submit_cleanup(struct kref *kref)
{ {
struct etnaviv_gem_submit *submit =
container_of(kref, struct etnaviv_gem_submit, refcount);
unsigned i; unsigned i;
for (i = 0; i < submit->nr_bos; i++) { for (i = 0; i < submit->nr_bos; i++) {
...@@ -367,6 +370,11 @@ static void submit_cleanup(struct etnaviv_gem_submit *submit) ...@@ -367,6 +370,11 @@ static void submit_cleanup(struct etnaviv_gem_submit *submit)
kfree(submit); kfree(submit);
} }
void etnaviv_submit_put(struct etnaviv_gem_submit *submit)
{
kref_put(&submit->refcount, submit_cleanup);
}
int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
struct drm_file *file) struct drm_file *file)
{ {
...@@ -544,7 +552,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, ...@@ -544,7 +552,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
args->fence = submit->out_fence->seqno; args->fence = submit->out_fence->seqno;
err_submit_objects: err_submit_objects:
submit_cleanup(submit); etnaviv_submit_put(submit);
err_submit_ww_acquire: err_submit_ww_acquire:
ww_acquire_fini(&ticket); ww_acquire_fini(&ticket);
......
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