From patchwork Wed Jul 30 14:21:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Thierry X-Patchwork-Id: 4649681 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CA7B7C0338 for ; Wed, 30 Jul 2014 14:21:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F2E0620149 for ; Wed, 30 Jul 2014 14:21:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 09ACD200D6 for ; Wed, 30 Jul 2014 14:21:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 948EE6E13A; Wed, 30 Jul 2014 07:21:46 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 0B33F6E13A for ; Wed, 30 Jul 2014 07:21:45 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 30 Jul 2014 07:21:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,764,1400050800"; d="scan'208";a="569467434" Received: from michelth-linux.iwi.intel.com ([172.28.253.148]) by fmsmga001.fm.intel.com with ESMTP; 30 Jul 2014 07:21:43 -0700 From: Michel Thierry To: intel-gfx@lists.freedesktop.org Date: Wed, 30 Jul 2014 15:21:54 +0100 Message-Id: <1406730114-11469-1-git-send-email-michel.thierry@intel.com> X-Mailer: git-send-email 2.0.3 In-Reply-To: <1406719520-17071-1-git-send-email-michel.thierry@intel.com> References: <1406719520-17071-1-git-send-email-michel.thierry@intel.com> Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH] drm/i915: Remove context pointer from ppgtt struct X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 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=-4.9 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 After new vma/ppgtt lifetime rules, the ppgtt can outlive the context it was created for. - Renamed create_vm_for_ctx to i915_ppgtt_create as ctx/ppgtt are no longer referenced. - Updated per_file_stats to cope with this change. v2: Get the right context for this ppgtt. Cc: Daniel Vetter Signed-off-by: Michel Thierry --- drivers/gpu/drm/i915/i915_debugfs.c | 25 ++++++++++++++++++++++++- drivers/gpu/drm/i915/i915_gem_context.c | 5 ++--- drivers/gpu/drm/i915/i915_gem_gtt.h | 2 -- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 9e737b7..0f34d6a 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -308,6 +308,27 @@ struct file_stats { size_t active, inactive; }; +static struct intel_context * +i915_get_ppgtt_context(struct drm_i915_file_private *file_priv, + struct i915_hw_ppgtt *ppgtt) +{ + struct drm_i915_private *dev_priv = file_priv->dev_priv; + struct intel_context *ctx; + struct i915_hw_ppgtt *ctx_ppgtt; + + list_for_each_entry(ctx, &dev_priv->context_list, link) { + if (ctx->legacy_hw_ctx.rcs_state == NULL) + continue; + else { + ctx_ppgtt = ctx_to_ppgtt(ctx); + if (ppgtt == ctx_ppgtt) + return ctx; + } + } + + return NULL; +} + static int per_file_stats(int id, void *ptr, void *data) { struct drm_i915_gem_object *obj = ptr; @@ -322,6 +343,7 @@ static int per_file_stats(int id, void *ptr, void *data) if (USES_FULL_PPGTT(obj->base.dev)) { list_for_each_entry(vma, &obj->vma_list, vma_link) { + struct intel_context *ctx; struct i915_hw_ppgtt *ppgtt; if (!drm_mm_node_allocated(&vma->node)) @@ -333,7 +355,8 @@ static int per_file_stats(int id, void *ptr, void *data) } ppgtt = container_of(vma->vm, struct i915_hw_ppgtt, base); - if (ppgtt->ctx && ppgtt->ctx->file_priv != stats->file_priv) + ctx = i915_get_ppgtt_context(stats->file_priv, ppgtt); + if (ctx && ctx->file_priv != stats->file_priv) continue; if (obj->ring) /* XXX per-vma statistic */ diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 4cfb03a..0d741f2 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -182,7 +182,7 @@ i915_gem_alloc_context_obj(struct drm_device *dev, size_t size) } static struct i915_hw_ppgtt * -create_vm_for_ctx(struct drm_device *dev, struct intel_context *ctx) +i915_ppgtt_create(struct drm_device *dev) { struct i915_hw_ppgtt *ppgtt; int ret; @@ -197,7 +197,6 @@ create_vm_for_ctx(struct drm_device *dev, struct intel_context *ctx) return ERR_PTR(ret); } - ppgtt->ctx = ctx; return ppgtt; } @@ -287,7 +286,7 @@ i915_gem_create_context(struct drm_device *dev, } if (create_vm) { - struct i915_hw_ppgtt *ppgtt = create_vm_for_ctx(dev, ctx); + struct i915_hw_ppgtt *ppgtt = i915_ppgtt_create(dev); if (IS_ERR_OR_NULL(ppgtt)) { DRM_DEBUG_DRIVER("PPGTT setup failed (%ld)\n", diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h index 57d4013..b8806e9 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.h +++ b/drivers/gpu/drm/i915/i915_gem_gtt.h @@ -258,8 +258,6 @@ struct i915_hw_ppgtt { dma_addr_t *gen8_pt_dma_addr[4]; }; - struct intel_context *ctx; - int (*enable)(struct i915_hw_ppgtt *ppgtt); int (*switch_mm)(struct i915_hw_ppgtt *ppgtt, struct intel_engine_cs *ring,