From patchwork Fri Nov 27 12:06:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 11935941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13E44C2D0E4 for ; Fri, 27 Nov 2020 12:11:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C176D221FF for ; Fri, 27 Nov 2020 12:11:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C176D221FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7769E6ECAD; Fri, 27 Nov 2020 12:10:10 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2A7396ECA1; Fri, 27 Nov 2020 12:10:06 +0000 (UTC) IronPort-SDR: MpQERDhaARDfC6OFl7xTReymzbDNwixoLxYFkrCYG0m74p+MegwA2KMwlYEPLYEprzhvaOvM5g KXz1lHS2KSgg== X-IronPort-AV: E=McAfee;i="6000,8403,9817"; a="172540761" X-IronPort-AV: E=Sophos;i="5.78,374,1599548400"; d="scan'208";a="172540761" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2020 04:10:06 -0800 IronPort-SDR: HPSOdiyDateGmOsqEJoCuv32kbz3gxkLbNtU9hatM+4vYXWGBq0UtFiJNE3ZCJKMJNfFxOk7sX rwGNr60cCnOQ== X-IronPort-AV: E=Sophos;i="5.78,374,1599548400"; d="scan'208";a="548029221" Received: from mjgleeso-mobl.ger.corp.intel.com (HELO mwauld-desk1.ger.corp.intel.com) ([10.251.85.2]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2020 04:10:04 -0800 From: Matthew Auld To: intel-gfx@lists.freedesktop.org Subject: [RFC PATCH 086/162] drm/i915: Add blit functions that can be called from within a WW transaction Date: Fri, 27 Nov 2020 12:06:02 +0000 Message-Id: <20201127120718.454037-87-matthew.auld@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201127120718.454037-1-matthew.auld@intel.com> References: <20201127120718.454037-1-matthew.auld@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Thomas_Hellstr=C3=B6m?= , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thomas Hellström We want to be able to blit from within a ww transaction, so add blit functions that are able to do that. Also take care to unlock the blit batch-buffer after use so it isn't recycled locked. Signed-off-by: Thomas Hellström Cc: Matthew Auld --- .../gpu/drm/i915/gem/i915_gem_object_blt.c | 91 +++++++++++++------ .../gpu/drm/i915/gem/i915_gem_object_blt.h | 10 ++ 2 files changed, 72 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c b/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c index e0b873c3f46a..b41b076f6864 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_object_blt.c @@ -145,11 +145,11 @@ move_obj_to_gpu(struct drm_i915_gem_object *obj, return i915_request_await_object(rq, obj, write); } -int i915_gem_object_fill_blt(struct drm_i915_gem_object *obj, - struct intel_context *ce, - u32 value) +int i915_gem_object_ww_fill_blt(struct drm_i915_gem_object *obj, + struct i915_gem_ww_ctx *ww, + struct intel_context *ce, + u32 value) { - struct i915_gem_ww_ctx ww; struct i915_request *rq; struct i915_vma *batch; struct i915_vma *vma; @@ -159,22 +159,16 @@ int i915_gem_object_fill_blt(struct drm_i915_gem_object *obj, if (IS_ERR(vma)) return PTR_ERR(vma); - i915_gem_ww_ctx_init(&ww, true); intel_engine_pm_get(ce->engine); -retry: - err = i915_gem_object_lock(obj, &ww); + err = intel_context_pin_ww(ce, ww); if (err) goto out; - err = intel_context_pin_ww(ce, &ww); - if (err) - goto out; - - err = i915_vma_pin_ww(vma, &ww, 0, 0, PIN_USER); + err = i915_vma_pin_ww(vma, ww, 0, 0, PIN_USER); if (err) goto out_ctx; - batch = intel_emit_vma_fill_blt(ce, vma, &ww, value); + batch = intel_emit_vma_fill_blt(ce, vma, ww, value); if (IS_ERR(batch)) { err = PTR_ERR(batch); goto out_vma; @@ -210,22 +204,43 @@ int i915_gem_object_fill_blt(struct drm_i915_gem_object *obj, i915_request_add(rq); out_batch: + i915_gem_ww_unlock_single(batch->obj); intel_emit_vma_release(ce, batch); out_vma: i915_vma_unpin(vma); out_ctx: intel_context_unpin(ce); out: + intel_engine_pm_put(ce->engine); + return err; +} + +int i915_gem_object_fill_blt(struct drm_i915_gem_object *obj, + struct intel_context *ce, + u32 value) +{ + struct i915_gem_ww_ctx ww; + int err; + + i915_gem_ww_ctx_init(&ww, true); +retry: + err = i915_gem_object_lock(obj, &ww); + if (err) + goto out_err; + + err = i915_gem_object_ww_fill_blt(obj, &ww, ce, value); +out_err: if (err == -EDEADLK) { err = i915_gem_ww_ctx_backoff(&ww); if (!err) goto retry; } i915_gem_ww_ctx_fini(&ww); - intel_engine_pm_put(ce->engine); + return err; } + /* Wa_1209644611:icl,ehl */ static bool wa_1209644611_applies(struct drm_i915_private *i915, u32 size) { @@ -354,13 +369,13 @@ struct i915_vma *intel_emit_vma_copy_blt(struct intel_context *ce, return ERR_PTR(err); } -int i915_gem_object_copy_blt(struct drm_i915_gem_object *src, - struct drm_i915_gem_object *dst, - struct intel_context *ce) +int i915_gem_object_ww_copy_blt(struct drm_i915_gem_object *src, + struct drm_i915_gem_object *dst, + struct i915_gem_ww_ctx *ww, + struct intel_context *ce) { struct i915_address_space *vm = ce->vm; struct i915_vma *vma[2], *batch; - struct i915_gem_ww_ctx ww; struct i915_request *rq; int err, i; @@ -372,26 +387,20 @@ int i915_gem_object_copy_blt(struct drm_i915_gem_object *src, if (IS_ERR(vma[1])) return PTR_ERR(vma[1]); - i915_gem_ww_ctx_init(&ww, true); intel_engine_pm_get(ce->engine); -retry: - err = i915_gem_object_lock(src, &ww); - if (!err) - err = i915_gem_object_lock(dst, &ww); - if (!err) - err = intel_context_pin_ww(ce, &ww); + err = intel_context_pin_ww(ce, ww); if (err) goto out; - err = i915_vma_pin_ww(vma[0], &ww, 0, 0, PIN_USER); + err = i915_vma_pin_ww(vma[0], ww, 0, 0, PIN_USER); if (err) goto out_ctx; - err = i915_vma_pin_ww(vma[1], &ww, 0, 0, PIN_USER); + err = i915_vma_pin_ww(vma[1], ww, 0, 0, PIN_USER); if (unlikely(err)) goto out_unpin_src; - batch = intel_emit_vma_copy_blt(ce, &ww, vma[0], vma[1]); + batch = intel_emit_vma_copy_blt(ce, ww, vma[0], vma[1]); if (IS_ERR(batch)) { err = PTR_ERR(batch); goto out_unpin_dst; @@ -437,6 +446,7 @@ int i915_gem_object_copy_blt(struct drm_i915_gem_object *src, i915_request_add(rq); out_batch: + i915_gem_ww_unlock_single(batch->obj); intel_emit_vma_release(ce, batch); out_unpin_dst: i915_vma_unpin(vma[1]); @@ -445,13 +455,36 @@ int i915_gem_object_copy_blt(struct drm_i915_gem_object *src, out_ctx: intel_context_unpin(ce); out: + intel_engine_pm_put(ce->engine); + return err; +} + +int i915_gem_object_copy_blt(struct drm_i915_gem_object *src, + struct drm_i915_gem_object *dst, + struct intel_context *ce) +{ + struct i915_gem_ww_ctx ww; + int err; + + i915_gem_ww_ctx_init(&ww, true); +retry: + err = i915_gem_object_lock(src, &ww); + if (err) + goto out_err; + + err = i915_gem_object_lock(dst, &ww); + if (err) + goto out_err; + + err = i915_gem_object_ww_copy_blt(src, dst, &ww, ce); +out_err: if (err == -EDEADLK) { err = i915_gem_ww_ctx_backoff(&ww); if (!err) goto retry; } i915_gem_ww_ctx_fini(&ww); - intel_engine_pm_put(ce->engine); + return err; } diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_blt.h b/drivers/gpu/drm/i915/gem/i915_gem_object_blt.h index 2409fdcccf0e..da3d66abde64 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object_blt.h +++ b/drivers/gpu/drm/i915/gem/i915_gem_object_blt.h @@ -36,4 +36,14 @@ int i915_gem_object_copy_blt(struct drm_i915_gem_object *src, struct drm_i915_gem_object *dst, struct intel_context *ce); +int i915_gem_object_ww_fill_blt(struct drm_i915_gem_object *obj, + struct i915_gem_ww_ctx *ww, + struct intel_context *ce, + u32 value); + +int i915_gem_object_ww_copy_blt(struct drm_i915_gem_object *src, + struct drm_i915_gem_object *dst, + struct i915_gem_ww_ctx *ww, + struct intel_context *ce); + #endif