diff mbox series

[09/40] drm/i915/selftests: Free the batch along the contexts error path

Message ID 20180919195544.1511-9-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [01/40] drm: Use default dma_fence hooks where possible for null syncobj | expand

Commit Message

Chris Wilson Sept. 19, 2018, 7:55 p.m. UTC
Remember to release the batch bo reference if we hit an error trying to
submit our MI_STORE_DWORD_IMM.

References: https://bugs.freedesktop.org/show_bug.cgi?id=107979
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/selftests/i915_gem_context.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Mika Kuoppala Sept. 20, 2018, 8:30 a.m. UTC | #1
Chris Wilson <chris@chris-wilson.co.uk> writes:

> Remember to release the batch bo reference if we hit an error trying to
> submit our MI_STORE_DWORD_IMM.
>
> References: https://bugs.freedesktop.org/show_bug.cgi?id=107979
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/selftests/i915_gem_context.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_context.c b/drivers/gpu/drm/i915/selftests/i915_gem_context.c
> index 79f9bcaf0c05..a89d31075c7a 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_context.c
> @@ -195,6 +195,7 @@ static int gpu_fill(struct drm_i915_gem_object *obj,
>  	i915_request_add(rq);
>  err_batch:
>  	i915_vma_unpin(batch);
> +	i915_vma_put(batch);

Looks good in here but in gpu_fill_dw we have similar
problem? We release the object ref but don't
release the vma when returning ERR_PTR.

-Mika

>  err_vma:
>  	i915_vma_unpin(vma);
>  	return err;
> -- 
> 2.19.0
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Chris Wilson Sept. 20, 2018, 8:36 a.m. UTC | #2
Quoting Mika Kuoppala (2018-09-20 09:30:22)
> Chris Wilson <chris@chris-wilson.co.uk> writes:
> 
> > Remember to release the batch bo reference if we hit an error trying to
> > submit our MI_STORE_DWORD_IMM.
> >
> > References: https://bugs.freedesktop.org/show_bug.cgi?id=107979
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > ---
> >  drivers/gpu/drm/i915/selftests/i915_gem_context.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_context.c b/drivers/gpu/drm/i915/selftests/i915_gem_context.c
> > index 79f9bcaf0c05..a89d31075c7a 100644
> > --- a/drivers/gpu/drm/i915/selftests/i915_gem_context.c
> > +++ b/drivers/gpu/drm/i915/selftests/i915_gem_context.c
> > @@ -195,6 +195,7 @@ static int gpu_fill(struct drm_i915_gem_object *obj,
> >       i915_request_add(rq);
> >  err_batch:
> >       i915_vma_unpin(batch);
> > +     i915_vma_put(batch);
> 
> Looks good in here but in gpu_fill_dw we have similar
> problem? We release the object ref but don't
> release the vma when returning ERR_PTR.

The dirty secret is that vma don't have refs, they are owned by their
parent object (with a secondary lifetime constraint from the vm).
i915_vma_put(vma) == i915_gem_object_put(vma->obj);
-Chris
Mika Kuoppala Sept. 20, 2018, 9:19 a.m. UTC | #3
Chris Wilson <chris@chris-wilson.co.uk> writes:

> Quoting Mika Kuoppala (2018-09-20 09:30:22)
>> Chris Wilson <chris@chris-wilson.co.uk> writes:
>> 
>> > Remember to release the batch bo reference if we hit an error trying to
>> > submit our MI_STORE_DWORD_IMM.
>> >
>> > References: https://bugs.freedesktop.org/show_bug.cgi?id=107979
>> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
>> > ---
>> >  drivers/gpu/drm/i915/selftests/i915_gem_context.c | 1 +
>> >  1 file changed, 1 insertion(+)
>> >
>> > diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_context.c b/drivers/gpu/drm/i915/selftests/i915_gem_context.c
>> > index 79f9bcaf0c05..a89d31075c7a 100644
>> > --- a/drivers/gpu/drm/i915/selftests/i915_gem_context.c
>> > +++ b/drivers/gpu/drm/i915/selftests/i915_gem_context.c
>> > @@ -195,6 +195,7 @@ static int gpu_fill(struct drm_i915_gem_object *obj,
>> >       i915_request_add(rq);
>> >  err_batch:
>> >       i915_vma_unpin(batch);
>> > +     i915_vma_put(batch);
>> 
>> Looks good in here but in gpu_fill_dw we have similar
>> problem? We release the object ref but don't
>> release the vma when returning ERR_PTR.
>
> The dirty secret is that vma don't have refs, they are owned by their
> parent object (with a secondary lifetime constraint from the vm).
> i915_vma_put(vma) == i915_gem_object_put(vma->obj);

Ah. Worry not, your secret is safe with me.

Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_context.c b/drivers/gpu/drm/i915/selftests/i915_gem_context.c
index 79f9bcaf0c05..a89d31075c7a 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_context.c
@@ -195,6 +195,7 @@  static int gpu_fill(struct drm_i915_gem_object *obj,
 	i915_request_add(rq);
 err_batch:
 	i915_vma_unpin(batch);
+	i915_vma_put(batch);
 err_vma:
 	i915_vma_unpin(vma);
 	return err;