From patchwork Tue Oct 20 09:23:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Hoath X-Patchwork-Id: 7445251 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 337529F506 for ; Tue, 20 Oct 2015 09:28:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1E3502084A for ; Tue, 20 Oct 2015 09:28:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D904920851 for ; Tue, 20 Oct 2015 09:28:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C16C572170; Tue, 20 Oct 2015 02:28:07 -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 F1B6E6E71B for ; Tue, 20 Oct 2015 02:28:04 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 20 Oct 2015 02:28:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,706,1437462000"; d="scan'208";a="815078831" Received: from nthoath-linux2.isw.intel.com ([10.102.226.45]) by fmsmga001.fm.intel.com with ESMTP; 20 Oct 2015 02:24:09 -0700 From: Nick Hoath To: intel-gfx@lists.freedesktop.org Date: Tue, 20 Oct 2015 10:23:55 +0100 Message-Id: <1445333036-22164-6-git-send-email-nicholas.hoath@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445333036-22164-1-git-send-email-nicholas.hoath@intel.com> References: <1445333036-22164-1-git-send-email-nicholas.hoath@intel.com> Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 5/6] drm/i915: Add the CPU mapping of the hw context to the pinned items. 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=-4.2 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 Pin the hw ctx mapping so that it is not mapped/unmapped per bb when doing GuC submission. v2: Removed interim development extra mapping. (Daniel Vetter) Issue: VIZ-4277 Signed-off-by: Nick Hoath Cc: David Gordon Cc: Daniel Vetter --- drivers/gpu/drm/i915/i915_debugfs.c | 14 ++++------- drivers/gpu/drm/i915/i915_drv.h | 4 +++- drivers/gpu/drm/i915/intel_lrc.c | 46 ++++++++++++++++++++++++++----------- 3 files changed, 40 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index a3b22bd..f0a172e 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -1970,10 +1970,9 @@ static int i915_context_status(struct seq_file *m, void *unused) static void i915_dump_lrc_obj(struct seq_file *m, struct intel_engine_cs *ring, - struct drm_i915_gem_object *ctx_obj) + struct drm_i915_gem_object *ctx_obj, + uint32_t *reg_state) { - struct page *page; - uint32_t *reg_state; int j; unsigned long ggtt_offset = 0; @@ -1996,17 +1995,13 @@ static void i915_dump_lrc_obj(struct seq_file *m, return; } - page = i915_gem_object_get_page(ctx_obj, LRC_STATE_PN); - if (!WARN_ON(page == NULL)) { - reg_state = kmap_atomic(page); - + if (!WARN_ON(reg_state == NULL)) { for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) { seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n", ggtt_offset + 4096 + (j * 4), reg_state[j], reg_state[j + 1], reg_state[j + 2], reg_state[j + 3]); } - kunmap_atomic(reg_state); } seq_putc(m, '\n'); @@ -2034,7 +2029,8 @@ static int i915_dump_lrc(struct seq_file *m, void *unused) for_each_ring(ring, dev_priv, i) { if (ring->default_context != ctx) i915_dump_lrc_obj(m, ring, - ctx->engine[i].state); + ctx->engine[i].state, + ctx->engine[i].reg_state); } } diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 0dd4ace..dc69d67 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -881,8 +881,10 @@ struct intel_context { } legacy_hw_ctx; /* Execlists */ - struct { + struct intel_context_engine { struct drm_i915_gem_object *state; + uint32_t *reg_state; + struct page *page; struct intel_ringbuffer *ringbuf; int pin_count; } engine[I915_NUM_RINGS]; diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 069950e..a35efcd 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c @@ -360,16 +360,13 @@ static int execlists_update_context(struct drm_i915_gem_request *rq) struct i915_hw_ppgtt *ppgtt = rq->ctx->ppgtt; struct drm_i915_gem_object *ctx_obj = rq->ctx->engine[ring->id].state; struct drm_i915_gem_object *rb_obj = rq->ringbuf->obj; - struct page *page; - uint32_t *reg_state; + uint32_t *reg_state = rq->ctx->engine[ring->id].reg_state; BUG_ON(!ctx_obj); + WARN_ON(!reg_state); WARN_ON(!i915_gem_obj_is_pinned(ctx_obj)); WARN_ON(!i915_gem_obj_is_pinned(rb_obj)); - page = i915_gem_object_get_page(ctx_obj, LRC_STATE_PN); - reg_state = kmap_atomic(page); - reg_state[CTX_RING_TAIL+1] = rq->tail; reg_state[CTX_RING_BUFFER_START+1] = i915_gem_obj_ggtt_offset(rb_obj); @@ -385,8 +382,6 @@ static int execlists_update_context(struct drm_i915_gem_request *rq) ASSIGN_CTX_PDP(ppgtt, reg_state, 0); } - kunmap_atomic(reg_state); - return 0; } @@ -985,7 +980,31 @@ int logical_ring_flush_all_caches(struct drm_i915_gem_request *req) return 0; } -static int intel_lr_context_do_pin(struct intel_engine_cs *ring, +static int intel_mmap_hw_context(struct drm_i915_gem_object *obj, + bool unmap) +{ + int ret = 0; + struct intel_context_engine *ice = + (struct intel_context_engine *)obj->mappable; + struct page *page; + uint32_t *reg_state; + + if (unmap) { + kunmap(ice->page); + ice->reg_state = NULL; + ice->page = NULL; + } else { + page = i915_gem_object_get_page(obj, LRC_STATE_PN); + reg_state = kmap(page); + ice->reg_state = reg_state; + ice->page = page; + } + return ret; +} + +static int intel_lr_context_do_pin( + struct intel_context *ctx, + struct intel_engine_cs *ring, struct drm_i915_gem_object *ctx_obj, struct intel_ringbuffer *ringbuf) { @@ -1032,7 +1051,7 @@ static int intel_lr_context_pin(struct drm_i915_gem_request *rq) struct intel_ringbuffer *ringbuf = rq->ringbuf; if (rq->ctx->engine[ring->id].pin_count++ == 0) { - ret = intel_lr_context_do_pin(ring, ctx_obj, ringbuf); + ret = intel_lr_context_do_pin(rq->ctx, ring, ctx_obj, ringbuf); if (ret) goto reset_pin_count; } @@ -1921,6 +1940,7 @@ static int logical_ring_init(struct drm_device *dev, struct intel_engine_cs *rin /* As this is the default context, always pin it */ ret = intel_lr_context_do_pin( + ring->default_context, ring, ring->default_context->engine[ring->id].state, ring->default_context->engine[ring->id].ringbuf); @@ -2471,6 +2491,8 @@ int intel_lr_context_deferred_alloc(struct intel_context *ctx, goto error_ringbuf; } + ctx_obj->mmap = intel_mmap_hw_context; + ctx_obj->mappable = &(ctx->engine[ring->id]); ctx->engine[ring->id].ringbuf = ringbuf; ctx->engine[ring->id].state = ctx_obj; @@ -2518,7 +2540,6 @@ void intel_lr_context_reset(struct drm_device *dev, struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf; uint32_t *reg_state; - struct page *page; if (!ctx_obj) continue; @@ -2527,14 +2548,11 @@ void intel_lr_context_reset(struct drm_device *dev, WARN(1, "Failed get_pages for context obj\n"); continue; } - page = i915_gem_object_get_page(ctx_obj, LRC_STATE_PN); - reg_state = kmap_atomic(page); + reg_state = ctx->engine[ring->id].reg_state; reg_state[CTX_RING_HEAD+1] = 0; reg_state[CTX_RING_TAIL+1] = 0; - kunmap_atomic(reg_state); - ringbuf->head = 0; ringbuf->tail = 0;