Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec3e9963 authored by Oscar Mateo's avatar Oscar Mateo Committed by Daniel Vetter
Browse files

drm/i915/bdw: Deferred creation of user-created LRCs



The backing objects and ringbuffers for contexts created via open
fd are actually empty until the user starts sending execbuffers to
them. At that point, we allocate & populate them. We do this because,
at create time, we really don't know which engine is going to be used
with the context later on (and we don't want to waste memory on
objects that we might never use).

v2: As contexts created via ioctl can only be used with the render
ring, we have enough information to allocate & populate them right
away.

v3: Defer the creation always, even with ioctl-created contexts, as
requested by Daniel Vetter.

Signed-off-by: default avatarOscar Mateo <oscar.mateo@intel.com>
Reviewed-by: default avatarDamien Lespiau <damien.lespiau@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 8670d6f9
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -782,9 +782,9 @@ int i915_switch_context(struct intel_engine_cs *ring,
	return do_switch(ring, to);
}

static bool hw_context_enabled(struct drm_device *dev)
static bool contexts_enabled(struct drm_device *dev)
{
	return to_i915(dev)->hw_context_size;
	return i915.enable_execlists || to_i915(dev)->hw_context_size;
}

int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
@@ -795,8 +795,7 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
	struct intel_context *ctx;
	int ret;

	/* FIXME: allow user-created LR contexts as well */
	if (!hw_context_enabled(dev))
	if (!contexts_enabled(dev))
		return -ENODEV;

	ret = i915_mutex_lock_interruptible(dev);
+8 −0
Original line number Diff line number Diff line
@@ -931,6 +931,14 @@ i915_gem_validate_context(struct drm_device *dev, struct drm_file *file,
		return ERR_PTR(-EIO);
	}

	if (i915.enable_execlists && !ctx->engine[ring->id].state) {
		int ret = intel_lr_context_deferred_create(ctx, ring);
		if (ret) {
			DRM_DEBUG("Could not create LRC %u: %d\n", ctx_id, ret);
			return ERR_PTR(ret);
		}
	}

	return ctx;
}