From patchwork Tue Apr 19 06:49:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 8877151 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 BACD39F1D3 for ; Tue, 19 Apr 2016 06:49:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 89A5420149 for ; Tue, 19 Apr 2016 06:49:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 89CDC2026C for ; Tue, 19 Apr 2016 06:49:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 554396E6A9; Tue, 19 Apr 2016 06:49:41 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id D6CB76E6A9 for ; Tue, 19 Apr 2016 06:49:38 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id l6so2227881wml.3 for ; Mon, 18 Apr 2016 23:49:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=87m2RjE7BN4uCpaVY8xEfZ52jo+YgdMJPDzq+C0X92E=; b=d7cH7gFku0hwMA9vIkWFkIetwW6lLqDFJkiqRkV4m/3NzlHYrK1tmlrf2fe++AYWBJ c1wXQeSiBNwhBC4t6XNrRaVtG7dLLvxkfiyU7E7x7I0ZUBbykCnmXIWUCCezSj67L8BO DsEO+ST5Xg5N2s2WL0SZvKFJk6FkApBYWS/bn88TdLfDiVfL049U9Fs2Bg7HQi4KL61O JfGZz2QTKv4qQa61/e4wgnKnsX9vDglIQlnQgZY24TMb1LYesxGPyb06rM6b34QSJtfc HtIWwa+1oMr7Nr+fBWSMVJxNZzWZ9U6cro8jkrp1XFwCNSU3+6irXTq72PeEarkQTisp W2pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=87m2RjE7BN4uCpaVY8xEfZ52jo+YgdMJPDzq+C0X92E=; b=inu4NhK/EnnDtvc4v6SZ8q54RVSXC15rvzFXVVfk6RWv5t5IEcsmKGQXUVpUfL9YN8 8AcxbyzkrKv1CEqp/6GiW6MfV4mrf0OgO+S5/XcTZ7aD4WVsyF9iiOmEBP/UUo/6GOWr C7Z02+L5f+wg1utKA99JHrHLRRmEWZR1XnayafobK4Xhwpmx/kO40vgm/pSDAcp0eOlL FLtl6krynZnrQ/lWCbgXFSRj3JQd0JAwTBuTtFW6F2mWxEVG8PmfgMScNQwHtLSPP4q1 TvP2UyFjk3HQNxrhFBUwfeMMFTqTAFiZWoBr+PFJck7fa8sudIRDtKD8+fyzKBIyGjop hesw== X-Gm-Message-State: AOPr4FWpBlCol5VKJ1G3expvnlwSHYQ4A18Zm5YuzOHysOsXKEUPg/6PI4tH9L/PsoSwjw== X-Received: by 10.28.45.212 with SMTP id t203mr22743649wmt.71.1461048576229; Mon, 18 Apr 2016 23:49:36 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id w10sm56479720wjz.9.2016.04.18.23.49.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Apr 2016 23:49:35 -0700 (PDT) From: Chris Wilson To: intel-gfx@lists.freedesktop.org, Tvrtko Ursulin Date: Tue, 19 Apr 2016 07:49:17 +0100 Message-Id: <1461048560-31983-7-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1461048560-31983-1-git-send-email-chris@chris-wilson.co.uk> References: <1460721275-1001-1-git-send-email-tvrtko.ursulin@linux.intel.com> <1461048560-31983-1-git-send-email-chris@chris-wilson.co.uk> Subject: [Intel-gfx] [PATCH 6/9] drm/i915: Move context initialisation to first-use 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 Instead of allocating a new request when allocating a context, use the request that initiated the allocation to emit the context initialisation. Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_lrc.c | 39 ++++++++++++++++++--------------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 77becfd5a09d..b65e3b16e1b0 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -870,6 +870,7 @@ struct intel_context { struct i915_vma *lrc_vma; u64 lrc_desc; uint32_t *lrc_reg_state; + bool initialised; } engine[I915_NUM_ENGINES]; struct list_head link; diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 79ac6f06a502..c104015813d3 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c @@ -669,9 +669,10 @@ static int execlists_move_to_gpu(struct drm_i915_gem_request *req, int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request) { - int ret = 0; + struct intel_engine_cs *engine = request->engine; + int ret; - request->ringbuf = request->ctx->engine[request->engine->id].ringbuf; + request->ringbuf = request->ctx->engine[engine->id].ringbuf; if (i915.enable_guc_submission) { /* @@ -686,7 +687,20 @@ int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request return ret; } - return intel_lr_context_pin(request->ctx, request->engine); + ret = intel_lr_context_pin(request->ctx, engine); + if (ret) + return ret; + + if (!request->ctx->engine[engine->id].initialised) { + ret = engine->init_context(request); + if (ret) { + intel_lr_context_unpin(request->ctx, engine); + return ret; + } + request->ctx->engine[engine->id].initialised = true; + } + + return 0; } static int logical_ring_wait_for_space(struct drm_i915_gem_request *req, @@ -2576,25 +2590,8 @@ int intel_lr_context_deferred_alloc(struct intel_context *ctx, ctx->engine[engine->id].ringbuf = ringbuf; ctx->engine[engine->id].state = ctx_obj; + ctx->engine[engine->id].initialised = engine->init_context == NULL; - if (ctx != ctx->i915->kernel_context && engine->init_context) { - struct drm_i915_gem_request *req; - - req = i915_gem_request_alloc(engine, ctx); - if (IS_ERR(req)) { - ret = PTR_ERR(req); - DRM_ERROR("ring create req: %d\n", ret); - goto error_ringbuf; - } - - ret = engine->init_context(req); - i915_add_request_no_flush(req); - if (ret) { - DRM_ERROR("ring init context: %d\n", - ret); - goto error_ringbuf; - } - } return 0; error_ringbuf: