diff mbox series

drm/i915/selftests: Add a mock i915_vma to the mock_ring

Message ID 20200114124925.2208458-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series drm/i915/selftests: Add a mock i915_vma to the mock_ring | expand

Commit Message

Chris Wilson Jan. 14, 2020, 12:49 p.m. UTC
Add a i915_vma to the mock_engine/mock_ring so that the core code can
always assume the presence of ring->vma.

Fixes: 8ccfc20a7d56 ("drm/i915/gt: Mark ring->vma as active while pinned")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gt/mock_engine.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Mika Kuoppala Jan. 14, 2020, 3:55 p.m. UTC | #1
Chris Wilson <chris@chris-wilson.co.uk> writes:

> Add a i915_vma to the mock_engine/mock_ring so that the core code can
> always assume the presence of ring->vma.
>
> Fixes: 8ccfc20a7d56 ("drm/i915/gt: Mark ring->vma as active while pinned")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/gt/mock_engine.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gt/mock_engine.c b/drivers/gpu/drm/i915/gt/mock_engine.c
> index a560b7eee2cd..54bd5461738b 100644
> --- a/drivers/gpu/drm/i915/gt/mock_engine.c
> +++ b/drivers/gpu/drm/i915/gt/mock_engine.c
> @@ -59,6 +59,13 @@ static struct intel_ring *mock_ring(struct intel_engine_cs *engine)
>  	ring->vaddr = (void *)(ring + 1);
>  	atomic_set(&ring->pin_count, 1);
>  
> +	ring->vma = i915_vma_alloc();
> +	if (ring->vma == NULL) {
> +		kfree(ring);
> +		return NULL;
> +	}
> +	i915_active_init(&ring->vma->active, NULL, NULL);
> +
>  	intel_ring_update_space(ring);
>  
>  	return ring;
> @@ -121,6 +128,7 @@ static void mock_context_destroy(struct kref *ref)
>  	GEM_BUG_ON(intel_context_is_pinned(ce));
>  
>  	if (test_bit(CONTEXT_ALLOC_BIT, &ce->flags)) {
> +		i915_vma_free(ce->ring->vma);
>  		kfree(ce->ring);
>  		mock_timeline_unpin(ce->timeline);

with i915_active_fini() added also,

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

>  	}
> -- 
> 2.25.0.rc2
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/mock_engine.c b/drivers/gpu/drm/i915/gt/mock_engine.c
index a560b7eee2cd..54bd5461738b 100644
--- a/drivers/gpu/drm/i915/gt/mock_engine.c
+++ b/drivers/gpu/drm/i915/gt/mock_engine.c
@@ -59,6 +59,13 @@  static struct intel_ring *mock_ring(struct intel_engine_cs *engine)
 	ring->vaddr = (void *)(ring + 1);
 	atomic_set(&ring->pin_count, 1);
 
+	ring->vma = i915_vma_alloc();
+	if (ring->vma == NULL) {
+		kfree(ring);
+		return NULL;
+	}
+	i915_active_init(&ring->vma->active, NULL, NULL);
+
 	intel_ring_update_space(ring);
 
 	return ring;
@@ -121,6 +128,7 @@  static void mock_context_destroy(struct kref *ref)
 	GEM_BUG_ON(intel_context_is_pinned(ce));
 
 	if (test_bit(CONTEXT_ALLOC_BIT, &ce->flags)) {
+		i915_vma_free(ce->ring->vma);
 		kfree(ce->ring);
 		mock_timeline_unpin(ce->timeline);
 	}