GVT context will use its own shadow PPGTT, and it doesn't need a i915_hw_ppgtt. This patch adds a "has_ppgtt" param to i915_gem_context(), which allows the caller to create a context without PPGTT Signed-off-by: Zhi Wang <zhi.a.wang@xxxxxxxxx> --- drivers/gpu/drm/i915/i915_gem_context.c | 34 ++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 21498e5..b952e37 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -298,7 +298,8 @@ err_out: */ static struct intel_context * i915_gem_create_context(struct drm_device *dev, - struct drm_i915_file_private *file_priv) + struct drm_i915_file_private *file_priv, + bool has_ppgtt) { struct drm_i915_private *dev_priv = dev->dev_private; const bool is_global_default_ctx = file_priv == NULL; @@ -327,19 +328,22 @@ i915_gem_create_context(struct drm_device *dev, } } - if (USES_FULL_PPGTT(dev)) { - struct i915_hw_ppgtt *ppgtt = i915_ppgtt_create(dev, file_priv); + if (has_ppgtt) { + if (USES_FULL_PPGTT(dev)) { + struct i915_hw_ppgtt *ppgtt = + i915_ppgtt_create(dev, file_priv); - if (IS_ERR_OR_NULL(ppgtt)) { - DRM_DEBUG_DRIVER("PPGTT setup failed (%ld)\n", - PTR_ERR(ppgtt)); - ret = PTR_ERR(ppgtt); - goto err_unpin; - } + if (IS_ERR_OR_NULL(ppgtt)) { + DRM_DEBUG_DRIVER("PPGTT setup failed (%ld)\n", + PTR_ERR(ppgtt)); + ret = PTR_ERR(ppgtt); + goto err_unpin; + } - ctx->ppgtt = ppgtt; - } else - ctx->ppgtt = dev_priv->mm.aliasing_ppgtt; + ctx->ppgtt = ppgtt; + } else + ctx->ppgtt = dev_priv->mm.aliasing_ppgtt; + } trace_i915_context_create(ctx); @@ -416,7 +420,7 @@ int i915_gem_context_init(struct drm_device *dev) } } - ctx = i915_gem_create_context(dev, NULL); + ctx = i915_gem_create_context(dev, NULL, true); if (IS_ERR(ctx)) { DRM_ERROR("Failed to create default global context (error %ld)\n", PTR_ERR(ctx)); @@ -478,7 +482,7 @@ int i915_gem_context_open(struct drm_device *dev, struct drm_file *file) idr_init(&file_priv->context_idr); mutex_lock(&dev->struct_mutex); - ctx = i915_gem_create_context(dev, file_priv); + ctx = i915_gem_create_context(dev, file_priv, true); mutex_unlock(&dev->struct_mutex); if (IS_ERR(ctx)) { @@ -912,7 +916,7 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, if (ret) return ret; - ctx = i915_gem_create_context(dev, file_priv); + ctx = i915_gem_create_context(dev, file_priv, true); mutex_unlock(&dev->struct_mutex); if (IS_ERR(ctx)) return PTR_ERR(ctx); -- 1.9.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx