[PATCH 20/27] drm/etnaviv: refcount the submit object
Philipp Zabel
p.zabel at pengutronix.de
Mon Dec 11 12:41:21 UTC 2017
On Fri, 2017-12-01 at 11:36 +0100, Lucas Stach wrote:
> 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 destuction of the object.
>
> Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
Reviewed-by: Philipp Zabel <p.zabel at pengutronix.de>
regards
Philipp
> drivers/gpu/drm/etnaviv/etnaviv_gem.h | 3 +++
> drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 12 ++++++++++--
> 2 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.h b/drivers/gpu/drm/etnaviv/etnaviv_gem.h
> index 6b78d059ed2d..4238f8d8541d 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.h
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.h
> @@ -101,6 +101,7 @@ struct etnaviv_gem_submit_bo {
> * lasts for the duration of the submit-ioctl.
> */
> struct etnaviv_gem_submit {
> + struct kref refcount;
> struct etnaviv_gpu *gpu;
> struct dma_fence *out_fence, *in_fence;
> u32 flags;
> @@ -109,6 +110,8 @@ struct etnaviv_gem_submit {
> /* 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,
> struct timespec *timeout);
> int etnaviv_gem_new_private(struct drm_device *dev, size_t size, u32 flags,
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> index 3090a46979af..9b4436c380ea 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> @@ -43,6 +43,7 @@ static struct etnaviv_gem_submit *submit_create(struct drm_device *dev,
> return NULL;
>
> submit->gpu = gpu;
> + kref_init(&submit->refcount);
>
> return submit;
> }
> @@ -341,8 +342,10 @@ static int submit_perfmon_validate(struct etnaviv_gem_submit *submit,
> 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;
>
> for (i = 0; i < submit->nr_bos; i++) {
> @@ -367,6 +370,11 @@ static void submit_cleanup(struct etnaviv_gem_submit *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,
> struct drm_file *file)
> {
> @@ -544,7 +552,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
> args->fence = submit->out_fence->seqno;
>
> err_submit_objects:
> - submit_cleanup(submit);
> + etnaviv_submit_put(submit);
>
> err_submit_ww_acquire:
> ww_acquire_fini(&ticket);
More information about the dri-devel
mailing list