diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2019-08-09 19:25:16 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2019-08-09 20:18:30 +0100 |
commit | 4c60b1aaa255207eea2892d2d55b718db90d1ad8 (patch) | |
tree | 8d080b17064d7de4d686ecb01f44d6c62a555f7d /drivers/gpu/drm/i915/gt/mock_engine.c | |
parent | 72e277759340dacdf3d68b0b2b4eae267e601d55 (diff) | |
download | linux-4c60b1aaa255207eea2892d2d55b718db90d1ad8.tar.gz linux-4c60b1aaa255207eea2892d2d55b718db90d1ad8.tar.bz2 linux-4c60b1aaa255207eea2892d2d55b718db90d1ad8.zip |
drm/i915/gt: Make deferred context allocation explicit
Refactor the backends to handle the deferred context allocation in a
consistent manner, and allow calling it as an explicit first step in
pinning a context for the first time. This should make it easier for
backends to keep track of partially constructed contexts from
initialisation.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190809182518.20486-2-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/gt/mock_engine.c')
-rw-r--r-- | drivers/gpu/drm/i915/gt/mock_engine.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/gpu/drm/i915/gt/mock_engine.c b/drivers/gpu/drm/i915/gt/mock_engine.c index dd02e59b192f..848a83a38b08 100644 --- a/drivers/gpu/drm/i915/gt/mock_engine.c +++ b/drivers/gpu/drm/i915/gt/mock_engine.c @@ -147,16 +147,19 @@ static void mock_context_destroy(struct kref *ref) intel_context_free(ce); } +static int mock_context_alloc(struct intel_context *ce) +{ + ce->ring = mock_ring(ce->engine); + if (!ce->ring) + return -ENOMEM; + + return 0; +} + static int mock_context_pin(struct intel_context *ce) { int ret; - if (!ce->ring) { - ce->ring = mock_ring(ce->engine); - if (!ce->ring) - return -ENOMEM; - } - ret = intel_context_active_acquire(ce); if (ret) return ret; @@ -166,6 +169,8 @@ static int mock_context_pin(struct intel_context *ce) } static const struct intel_context_ops mock_context_ops = { + .alloc = mock_context_alloc, + .pin = mock_context_pin, .unpin = mock_context_unpin, |