From patchwork Sun May 15 17:32:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Zhi A" X-Patchwork-Id: 9096731 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 B39C8BF440 for ; Sun, 15 May 2016 17:39:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CC8D220122 for ; Sun, 15 May 2016 17:39:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B496D20260 for ; Sun, 15 May 2016 17:39:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 45B736E3AF; Sun, 15 May 2016 17:39:48 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 6825E6E39F for ; Sun, 15 May 2016 17:38:26 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 15 May 2016 10:38:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,623,1455004800"; d="scan'208";a="977259770" Received: from dev-inno.bj.intel.com ([10.238.135.69]) by orsmga002.jf.intel.com with ESMTP; 15 May 2016 10:38:24 -0700 From: Zhi Wang To: intel-gfx@lists.freedesktop.org, david.s.gordon@intel.com, joonas.lahtinen@linux.intel.com, kevin.tian@intel.com, zhiyuan.lv@intel.com Date: Mon, 16 May 2016 01:32:49 +0800 Message-Id: <1463333573-25112-12-git-send-email-zhi.a.wang@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1463333573-25112-1-git-send-email-zhi.a.wang@intel.com> References: <1463333573-25112-1-git-send-email-zhi.a.wang@intel.com> Subject: [Intel-gfx] [PATCH 11/15] drm/i915: Introduce execlist context status change notification 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.6 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 This patch introduces an approach to track the execlist context status change. GVT-g uses GVT context as the "shadow context". The content inside GVT context will be copied back to guest after the context is idle. So GVT-g has to know the status of the execlist context. This function is configurable in the context creation service. Currently, Only GVT-g will create the "status-change-notification" enabled GEM context. Signed-off-by: Zhi Wang --- drivers/gpu/drm/i915/i915_drv.h | 5 +++++ drivers/gpu/drm/i915/intel_lrc.c | 23 +++++++++++++++++++++++ drivers/gpu/drm/i915/intel_lrc.h | 5 +++++ 3 files changed, 33 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 7f050a3..1c9e865 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -884,6 +884,8 @@ struct intel_context { bool initialised; bool skip_init_context; u32 ring_buffer_size; + bool enable_status_change_notification; + struct atomic_notifier_head status_notifier_head; } engine[I915_NUM_ENGINES]; bool use_48bit_addressing_mode; @@ -2403,6 +2405,9 @@ struct drm_i915_gem_request { /** Execlists context hardware id. */ unsigned ctx_hw_id; + + /** GVT workload **/ + void *gvt_workload; }; struct drm_i915_gem_request * __must_check diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 0a96d4a..aeaea2e 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c @@ -415,6 +415,19 @@ static void execlists_submit_requests(struct drm_i915_gem_request *rq0, spin_unlock_irq(&dev_priv->uncore.lock); } +static inline void execlists_context_status_change( + struct drm_i915_gem_request *req, + unsigned long status) +{ + if (!req->ctx->engine[req->engine->id]. + enable_status_change_notification) + return; + + atomic_notifier_call_chain( + &req->ctx->engine[req->engine->id].status_notifier_head, + status, req->gvt_workload); +} + static void execlists_context_unqueue(struct intel_engine_cs *engine) { struct drm_i915_gem_request *req0 = NULL, *req1 = NULL; @@ -450,6 +463,11 @@ static void execlists_context_unqueue(struct intel_engine_cs *engine) if (unlikely(!req0)) return; + execlists_context_status_change(req0, CONTEXT_SCHEDULE_IN); + + if (req1) + execlists_context_status_change(req1, CONTEXT_SCHEDULE_IN); + if (req0->elsp_submitted & engine->idle_lite_restore_wa) { /* * WaIdleLiteRestore: make sure we never cause a lite restore @@ -488,6 +506,8 @@ execlists_check_remove_request(struct intel_engine_cs *engine, u32 ctx_id) if (--head_req->elsp_submitted > 0) return 0; + execlists_context_status_change(head_req, CONTEXT_SCHEDULE_OUT); + list_del(&head_req->execlist_link); i915_gem_request_unreference(head_req); @@ -2541,6 +2561,9 @@ static int execlists_context_deferred_alloc(struct intel_context *ctx, ctx->engine[engine->id].state = ctx_obj; ctx->engine[engine->id].initialised = engine_initialised(ctx, engine); + if (ctx->engine[engine->id].enable_status_change_notification) + ATOMIC_INIT_NOTIFIER_HEAD( + &ctx->engine[engine->id].status_notifier_head); return 0; error_ringbuf: diff --git a/drivers/gpu/drm/i915/intel_lrc.h b/drivers/gpu/drm/i915/intel_lrc.h index 1afba03..98c94ee 100644 --- a/drivers/gpu/drm/i915/intel_lrc.h +++ b/drivers/gpu/drm/i915/intel_lrc.h @@ -57,6 +57,11 @@ #define GEN8_CSB_READ_PTR(csb_status) \ (((csb_status) & GEN8_CSB_READ_PTR_MASK) >> 8) +enum { + CONTEXT_SCHEDULE_IN = 0, + CONTEXT_SCHEDULE_OUT, +}; + /* Logical Rings */ int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request); int intel_logical_ring_reserve_space(struct drm_i915_gem_request *request);