mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 00:22:00 +02:00
drm/i915: Create a full object for mock_ring, v2.
This allows us to finally get rid of all the assumptions that vma->obj is NULL. Changes since v1: - Ensure the mock_ring vma is pinned to prevent a fault. - Pin it high to avoid failure in evict_for_vma selftest. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Signed-off-by: Matthew Auld <matthew.auld@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20211117142024.1043017-3-matthew.auld@intel.com
This commit is contained in:
parent
b0b0f2d225
commit
d03a29e0b1
|
|
@ -35,9 +35,31 @@ static void mock_timeline_unpin(struct intel_timeline *tl)
|
|||
atomic_dec(&tl->pin_count);
|
||||
}
|
||||
|
||||
static struct i915_vma *create_ring_vma(struct i915_ggtt *ggtt, int size)
|
||||
{
|
||||
struct i915_address_space *vm = &ggtt->vm;
|
||||
struct drm_i915_private *i915 = vm->i915;
|
||||
struct drm_i915_gem_object *obj;
|
||||
struct i915_vma *vma;
|
||||
|
||||
obj = i915_gem_object_create_internal(i915, size);
|
||||
if (IS_ERR(obj))
|
||||
return ERR_CAST(obj);
|
||||
|
||||
vma = i915_vma_instance(obj, vm, NULL);
|
||||
if (IS_ERR(vma))
|
||||
goto err;
|
||||
|
||||
return vma;
|
||||
|
||||
err:
|
||||
i915_gem_object_put(obj);
|
||||
return vma;
|
||||
}
|
||||
|
||||
static struct intel_ring *mock_ring(struct intel_engine_cs *engine)
|
||||
{
|
||||
const unsigned long sz = PAGE_SIZE / 2;
|
||||
const unsigned long sz = PAGE_SIZE;
|
||||
struct intel_ring *ring;
|
||||
|
||||
ring = kzalloc(sizeof(*ring) + sz, GFP_KERNEL);
|
||||
|
|
@ -50,15 +72,11 @@ 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) {
|
||||
ring->vma = create_ring_vma(engine->gt->ggtt, PAGE_SIZE);
|
||||
if (IS_ERR(ring->vma)) {
|
||||
kfree(ring);
|
||||
return NULL;
|
||||
}
|
||||
i915_active_init(&ring->vma->active, NULL, NULL, 0);
|
||||
__set_bit(I915_VMA_GGTT_BIT, __i915_vma_flags(ring->vma));
|
||||
__set_bit(DRM_MM_NODE_ALLOCATED_BIT, &ring->vma->node.flags);
|
||||
ring->vma->node.size = sz;
|
||||
|
||||
intel_ring_update_space(ring);
|
||||
|
||||
|
|
@ -67,8 +85,7 @@ static struct intel_ring *mock_ring(struct intel_engine_cs *engine)
|
|||
|
||||
static void mock_ring_free(struct intel_ring *ring)
|
||||
{
|
||||
i915_active_fini(&ring->vma->active);
|
||||
i915_vma_free(ring->vma);
|
||||
i915_vma_put(ring->vma);
|
||||
|
||||
kfree(ring);
|
||||
}
|
||||
|
|
@ -125,6 +142,7 @@ static void mock_context_unpin(struct intel_context *ce)
|
|||
|
||||
static void mock_context_post_unpin(struct intel_context *ce)
|
||||
{
|
||||
i915_vma_unpin(ce->ring->vma);
|
||||
}
|
||||
|
||||
static void mock_context_destroy(struct kref *ref)
|
||||
|
|
@ -169,7 +187,7 @@ static int mock_context_alloc(struct intel_context *ce)
|
|||
static int mock_context_pre_pin(struct intel_context *ce,
|
||||
struct i915_gem_ww_ctx *ww, void **unused)
|
||||
{
|
||||
return 0;
|
||||
return i915_vma_pin_ww(ce->ring->vma, ww, 0, 0, PIN_GLOBAL | PIN_HIGH);
|
||||
}
|
||||
|
||||
static int mock_context_pin(struct intel_context *ce, void *unused)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user