aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhi Wang <zhi.a.wang@intel.com>2016-06-16 08:07:05 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2016-06-17 15:36:43 -0400
commitc8c35799f237d26e86139761c862944240ae6a23 (patch)
treedcbf6f430b464bef19666d8a088ff9e9d4d7bb65
parent80a9a8db1613cc5b76ec2bfdd0ce5aabcf4786bb (diff)
drm/i915: Introduce GVT context creation API
GVT workload scheduler needs special host LRC contexts, the so called "shadow LRC context" to submit guest workload to host i915. During the guest workload submission, workload scheduler fills the shadow LRC context with the content of guest LRC context: engine context is copied without changes, ring context is mostly owned by host i915. v8: - Remove the graph temporarily. (Chris) - Use interruptible mutex_lock. (Chris) - Rename the function name of creating a GVT context. (Chris) - Add the missing declaration in i915_drv.h (Chris) v7: - Move chart to a better place. (Joonas) v6: - Make GVT code as dead code when !CONFIG_DRM_I915_GVT. (Chris) v5: - Only compile this feature when CONFIG_DRM_I915_GVT is enabled. (Tvrtko) - Rebase the code into new repo. - Add a comment about the ring buffer size. (Joonas) v2: Mostly based on Daniel's idea. Call the refactored core logic of GEM context creation service and LRC context creation service to create the GVT context. Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Signed-off-by: Zhi Wang <zhi.a.wang@intel.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Link: http://patchwork.freedesktop.org/patch/msgid/1466078825-6662-10-git-send-email-zhi.a.wang@intel.com
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h2
-rw-r--r--drivers/gpu/drm/i915/i915_gem_context.c34
2 files changed, 36 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 34a1c185a0bc..6c1540d52a67 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3475,6 +3475,8 @@ int i915_switch_context(struct drm_i915_gem_request *req);
3475void i915_gem_context_free(struct kref *ctx_ref); 3475void i915_gem_context_free(struct kref *ctx_ref);
3476struct drm_i915_gem_object * 3476struct drm_i915_gem_object *
3477i915_gem_alloc_context_obj(struct drm_device *dev, size_t size); 3477i915_gem_alloc_context_obj(struct drm_device *dev, size_t size);
3478struct i915_gem_context *
3479i915_gem_context_create_gvt(struct drm_device *dev);
3478 3480
3479static inline struct i915_gem_context * 3481static inline struct i915_gem_context *
3480i915_gem_context_lookup(struct drm_i915_file_private *file_priv, u32 id) 3482i915_gem_context_lookup(struct drm_i915_file_private *file_priv, u32 id)
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index d9e30e111067..30d9b4fd30f3 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -343,6 +343,40 @@ i915_gem_create_context(struct drm_device *dev,
343 return ctx; 343 return ctx;
344} 344}
345 345
346/**
347 * i915_gem_context_create_gvt - create a GVT GEM context
348 * @dev: drm device *
349 *
350 * This function is used to create a GVT specific GEM context.
351 *
352 * Returns:
353 * pointer to i915_gem_context on success, error pointer if failed
354 *
355 */
356struct i915_gem_context *
357i915_gem_context_create_gvt(struct drm_device *dev)
358{
359 struct i915_gem_context *ctx;
360 int ret;
361
362 if (!IS_ENABLED(CONFIG_DRM_I915_GVT))
363 return ERR_PTR(-ENODEV);
364
365 ret = i915_mutex_lock_interruptible(dev);
366 if (ret)
367 return ERR_PTR(ret);
368
369 ctx = i915_gem_create_context(dev, NULL);
370 if (IS_ERR(ctx))
371 goto out;
372
373 ctx->execlists_force_single_submission = true;
374 ctx->ring_size = 512 * PAGE_SIZE; /* Max ring buffer size */
375out:
376 mutex_unlock(&dev->struct_mutex);
377 return ctx;
378}
379
346static void i915_gem_context_unpin(struct i915_gem_context *ctx, 380static void i915_gem_context_unpin(struct i915_gem_context *ctx,
347 struct intel_engine_cs *engine) 381 struct intel_engine_cs *engine)
348{ 382{