From patchwork Thu Aug 20 03:18:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiyuan Lv X-Patchwork-Id: 7040551 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 06302C05AC for ; Thu, 20 Aug 2015 03:31:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 23812203B6 for ; Thu, 20 Aug 2015 03:31:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 5E070203B4 for ; Thu, 20 Aug 2015 03:31:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F267189CA4; Wed, 19 Aug 2015 20:31:10 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id E835189C54 for ; Wed, 19 Aug 2015 20:31:09 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 19 Aug 2015 20:31:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,713,1432623600"; d="scan'208";a="772166362" Received: from zlv-hp-dev.bj.intel.com (HELO zlv-hp-dev) ([10.238.158.60]) by fmsmga001.fm.intel.com with ESMTP; 19 Aug 2015 20:31:08 -0700 Date: Thu, 20 Aug 2015 11:18:22 +0800 From: Zhiyuan Lv To: intel-gfx@lists.freedesktop.org Message-ID: <20150820031822.GA5497@zlv-hp-dev> Mail-Followup-To: intel-gfx@lists.freedesktop.org, igvt-g@lists.01.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Cc: igvt-g@lists.01.org Subject: [Intel-gfx] [PATCH 4/7] drm/i915: always pin lrc context for vgpu with Intel GVT-g X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Intel GVT-g will perform EXECLIST context shadowing and ring buffer shadowing. The shadow copy is created when guest creates a context. If a context changes its LRCA address, the hypervisor is hard to know whether it is a new context or not. We always pin context objects to global GTT to make life easier. Signed-off-by: Zhiyuan Lv Signed-off-by: Zhi Wang --- drivers/gpu/drm/i915/intel_lrc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 39df304..4b2ac37 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c @@ -2282,7 +2282,8 @@ void intel_lr_context_free(struct intel_context *ctx) ctx->engine[i].ringbuf; struct intel_engine_cs *ring = ringbuf->ring; - if (ctx == ring->default_context) { + if ((ctx == ring->default_context) || + (intel_vgpu_active(ring->dev))) { intel_unpin_ringbuffer_obj(ringbuf); i915_gem_object_ggtt_unpin(ctx_obj); } @@ -2353,6 +2354,8 @@ int intel_lr_context_deferred_create(struct intel_context *ctx, struct intel_engine_cs *ring) { const bool is_global_default_ctx = (ctx == ring->default_context); + const bool need_to_pin_ctx = (is_global_default_ctx || + (intel_vgpu_active(ring->dev))); struct drm_device *dev = ring->dev; struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_gem_object *ctx_obj; @@ -2374,7 +2377,7 @@ int intel_lr_context_deferred_create(struct intel_context *ctx, return -ENOMEM; } - if (is_global_default_ctx) { + if (need_to_pin_ctx) { ret = i915_gem_obj_ggtt_pin(ctx_obj, GEN8_LR_CONTEXT_ALIGN, PIN_OFFSET_BIAS | GUC_WOPCM_TOP); if (ret) { @@ -2415,7 +2418,7 @@ int intel_lr_context_deferred_create(struct intel_context *ctx, goto error_free_rbuf; } - if (is_global_default_ctx) { + if (need_to_pin_ctx) { ret = intel_pin_and_map_ringbuffer_obj(dev, ringbuf); if (ret) { DRM_ERROR( @@ -2464,14 +2467,14 @@ int intel_lr_context_deferred_create(struct intel_context *ctx, return 0; error: - if (is_global_default_ctx) + if (need_to_pin_ctx) intel_unpin_ringbuffer_obj(ringbuf); error_destroy_rbuf: intel_destroy_ringbuffer_obj(ringbuf); error_free_rbuf: kfree(ringbuf); error_unpin_ctx: - if (is_global_default_ctx) + if (need_to_pin_ctx) i915_gem_object_ggtt_unpin(ctx_obj); drm_gem_object_unreference(&ctx_obj->base); return ret;