From patchwork Tue Mar 7 10:48:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13163133 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E44C5C678D5 for ; Tue, 7 Mar 2023 10:48:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5A91310E441; Tue, 7 Mar 2023 10:48:37 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 95FF410E40A; Tue, 7 Mar 2023 10:48:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678186114; x=1709722114; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cVF2ra7oTnbq4fpvT5foqJGinYsgG/tHcRGOAr/1f3s=; b=FIORNnzMdDvdB9gXwiiH9d2RP8XYRymKxsLU+yuezKDsmDEb2jD5jISN nVI8/EavVSWWC4aBsbVyykeaPUstbNWeq9YM5Jb0rs0Frt5f1sAk9E5sV NqVPCJH92sDsSXEgx1Hys1HNEeTxqmdYaXNwk8qovLpH0W9NAgDDS0URk Te5p4ZP/E29VIncvfPyIl2syo3QRKq+07gv6h5RyZPUbcMwOUj0djF6dn N0BR5u+X8/stgeQDH0cuAc1RbYhOh+kxr5pvEmnj1C4U/VtPEQbf/LT7K Wj6T+x4jl/MwtHHAG5nwoDOkcZMOOnutgr30/Pw7NNGMpykKzseC88Nta Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="400643406" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="400643406" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819712802" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="819712802" Received: from tanzeelu-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.205.53]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:32 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC 01/12] dma-fence: Move i915 helpers into common Date: Tue, 7 Mar 2023 10:48:13 +0000 Message-Id: <20230307104824.231094-2-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230307104824.231094-1-tvrtko.ursulin@linux.intel.com> References: <20230307104824.231094-1-tvrtko.ursulin@linux.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: Matt Turner , Tvrtko Ursulin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tvrtko Ursulin Unhide some i915 helpers which are used for splitting the signalled check vs notification stages during en masse fence processing. Signed-off-by: Tvrtko Ursulin --- drivers/dma-buf/dma-fence.c | 35 +++++++++++++++------ drivers/gpu/drm/i915/gt/intel_breadcrumbs.c | 22 ------------- include/linux/dma-fence.h | 4 +++ 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c index 0de0482cd36e..41da0da17eba 100644 --- a/drivers/dma-buf/dma-fence.c +++ b/drivers/dma-buf/dma-fence.c @@ -344,6 +344,30 @@ void __dma_fence_might_wait(void) } #endif +void __dma_fence_signal__timestamp(struct dma_fence *fence, ktime_t timestamp) +{ + lockdep_assert_held(fence->lock); + + fence->timestamp = timestamp; + set_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags); + trace_dma_fence_signaled(fence); +} +EXPORT_SYMBOL(__dma_fence_signal__timestamp); + +void +__dma_fence_signal__notify(struct dma_fence *fence, + const struct list_head *list) +{ + struct dma_fence_cb *cur, *tmp; + + lockdep_assert_held(fence->lock); + + list_for_each_entry_safe(cur, tmp, list, node) { + INIT_LIST_HEAD(&cur->node); + cur->func(fence, cur); + } +} +EXPORT_SYMBOL(__dma_fence_signal__notify); /** * dma_fence_signal_timestamp_locked - signal completion of a fence @@ -366,7 +390,6 @@ void __dma_fence_might_wait(void) int dma_fence_signal_timestamp_locked(struct dma_fence *fence, ktime_t timestamp) { - struct dma_fence_cb *cur, *tmp; struct list_head cb_list; lockdep_assert_held(fence->lock); @@ -378,14 +401,8 @@ int dma_fence_signal_timestamp_locked(struct dma_fence *fence, /* Stash the cb_list before replacing it with the timestamp */ list_replace(&fence->cb_list, &cb_list); - fence->timestamp = timestamp; - set_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags); - trace_dma_fence_signaled(fence); - - list_for_each_entry_safe(cur, tmp, &cb_list, node) { - INIT_LIST_HEAD(&cur->node); - cur->func(fence, cur); - } + __dma_fence_signal__timestamp(fence, timestamp); + __dma_fence_signal__notify(fence, &cb_list); return 0; } diff --git a/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c index ecc990ec1b95..26b6b777c479 100644 --- a/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c +++ b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c @@ -127,28 +127,6 @@ __dma_fence_signal(struct dma_fence *fence) return !test_and_set_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags); } -static void -__dma_fence_signal__timestamp(struct dma_fence *fence, ktime_t timestamp) -{ - fence->timestamp = timestamp; - set_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags); - trace_dma_fence_signaled(fence); -} - -static void -__dma_fence_signal__notify(struct dma_fence *fence, - const struct list_head *list) -{ - struct dma_fence_cb *cur, *tmp; - - lockdep_assert_held(fence->lock); - - list_for_each_entry_safe(cur, tmp, list, node) { - INIT_LIST_HEAD(&cur->node); - cur->func(fence, cur); - } -} - static void add_retire(struct intel_breadcrumbs *b, struct intel_timeline *tl) { if (b->irq_engine) diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h index 775cdc0b4f24..2af328a89468 100644 --- a/include/linux/dma-fence.h +++ b/include/linux/dma-fence.h @@ -367,6 +367,10 @@ static inline void dma_fence_end_signalling(bool cookie) {} static inline void __dma_fence_might_wait(void) {} #endif +void __dma_fence_signal__timestamp(struct dma_fence *fence, ktime_t timestamp); +void __dma_fence_signal__notify(struct dma_fence *fence, + const struct list_head *list); + int dma_fence_signal(struct dma_fence *fence); int dma_fence_signal_locked(struct dma_fence *fence); int dma_fence_signal_timestamp(struct dma_fence *fence, ktime_t timestamp); From patchwork Tue Mar 7 10:48:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13163135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 51410C678D4 for ; Tue, 7 Mar 2023 10:49:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ADC6610E46A; Tue, 7 Mar 2023 10:48:41 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 70A9210E433; Tue, 7 Mar 2023 10:48:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678186116; x=1709722116; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VAdPNmhggk8AJ/HP2lLLsL16Brg57NuNdC29Ei5z0is=; b=JSCsM7qYRW240ZzhnqqfOehWvno541IiTt2fvsa5EEII5AqATALb3hlS 6yYFVQnUrwGVawRSskena34s4vKZsjCIOr8CZRMx1eaYmKvkWX3cLGFsD kwXBleiQ/c1YU0pngJeMr75jCKCUwJPKhcWEvbaUK1nqQmdvQCOgOh/UJ Z3vQFHM8csSXTiZuVVllCXllDiaD7G5slDmHhMRkbIMFGV1duwbst7/We yyghbtyODaOz/kqrprIKWBSMS7bsa2x1odqkqyXSN+RIi28OJfWNmGcHu F82gnKxe0GyYArp/1+44zwIaQ7FawJoMvn1r/rG/KxP2nn1IExv9K09Is A==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="400643410" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="400643410" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819712811" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="819712811" Received: from tanzeelu-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.205.53]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:34 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC 02/12] dma-fence: Add callback initialization helper Date: Tue, 7 Mar 2023 10:48:14 +0000 Message-Id: <20230307104824.231094-3-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230307104824.231094-1-tvrtko.ursulin@linux.intel.com> References: <20230307104824.231094-1-tvrtko.ursulin@linux.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: Matt Turner , Tvrtko Ursulin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tvrtko Ursulin In preparation of adding a new field to struct dma_fence_cb we will need an initialization helper for those callers who add callbacks by open- coding. That will ensure they initialize all the fields so common code does not get confused by potential garbage in some fields. Signed-off-by: Tvrtko Ursulin --- drivers/dma-buf/dma-fence.c | 10 ++++------ include/linux/dma-fence.h | 7 +++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c index 41da0da17eba..ea4a1f82c9bf 100644 --- a/drivers/dma-buf/dma-fence.c +++ b/drivers/dma-buf/dma-fence.c @@ -662,21 +662,19 @@ int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb, unsigned long flags; int ret = 0; + __dma_fence_cb_init(cb, func); + if (WARN_ON(!fence || !func)) return -EINVAL; - if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) { - INIT_LIST_HEAD(&cb->node); + if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) return -ENOENT; - } spin_lock_irqsave(fence->lock, flags); if (__dma_fence_enable_signaling(fence)) { - cb->func = func; list_add_tail(&cb->node, &fence->cb_list); } else { - INIT_LIST_HEAD(&cb->node); ret = -ENOENT; } @@ -795,7 +793,7 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout) goto out; } - cb.base.func = dma_fence_default_wait_cb; + __dma_fence_cb_init(&cb.base, dma_fence_default_wait_cb); cb.task = current; list_add(&cb.base.node, &fence->cb_list); diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h index 2af328a89468..35933e0ae62c 100644 --- a/include/linux/dma-fence.h +++ b/include/linux/dma-fence.h @@ -629,4 +629,11 @@ static inline bool dma_fence_is_container(struct dma_fence *fence) return dma_fence_is_array(fence) || dma_fence_is_chain(fence); } +static inline void __dma_fence_cb_init(struct dma_fence_cb *cb, + dma_fence_func_t func) +{ + INIT_LIST_HEAD(&cb->node); + cb->func = func; +} + #endif /* __LINUX_DMA_FENCE_H */ From patchwork Tue Mar 7 10:48:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13163134 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 07AC0C678D5 for ; Tue, 7 Mar 2023 10:48:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D2DBA10E457; Tue, 7 Mar 2023 10:48:40 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id DF64D10E457; Tue, 7 Mar 2023 10:48:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678186117; x=1709722117; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cDh25AJd19dIerLRDdnUajP2eq4D/mJT6rlMOV8EWbk=; b=EsslgZp0dUteYenlG3QggyE/9eQNlFzRrHScDCaDusd2G63UpDoWPzNG s5db1/vmi+RTNnzbN8KzzAt2+LadbVe0+n7dqYYK9plDGDciUWaCWMRu/ Cen2vgI/mH6RSuZfsXSdzmjLH4TnyR9YDJgSv6jNv1MPe+BSp51xMc+7h EJWqREBUmNsSB1egdK/QsXmxk4cZRKj7z5mPiMNZXOtDm2NJq8qJU39Di PQpV4+w+KCs6AX3KtcjXr5kqTEjCbCGDH/9zr7mR5syfnPg3DVrcdG4Jm rZ/Ft34RXWk/c8+zY7bIzE3nBtUTO0tyIE+hwsyQAfaZW3LDAuTWZrDGy Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="400643413" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="400643413" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819712818" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="819712818" Received: from tanzeelu-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.205.53]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:36 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC 03/12] drm/i915: Use fence callback initialization helper Date: Tue, 7 Mar 2023 10:48:15 +0000 Message-Id: <20230307104824.231094-4-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230307104824.231094-1-tvrtko.ursulin@linux.intel.com> References: <20230307104824.231094-1-tvrtko.ursulin@linux.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: Matt Turner , Tvrtko Ursulin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tvrtko Ursulin Use the previously added initialization helper to ensure correct operation of the common code. Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_active.c | 2 +- drivers/gpu/drm/i915/i915_active.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c index a9fea115f2d2..a3ad64583520 100644 --- a/drivers/gpu/drm/i915/i915_active.c +++ b/drivers/gpu/drm/i915/i915_active.c @@ -890,7 +890,7 @@ int i915_active_acquire_preallocate_barrier(struct i915_active *ref, goto unwind; RCU_INIT_POINTER(node->base.fence, NULL); - node->base.cb.func = node_retire; + __dma_fence_cb_init(&node->base.cb, node_retire); node->timeline = idx; node->ref = ref; } diff --git a/drivers/gpu/drm/i915/i915_active.h b/drivers/gpu/drm/i915/i915_active.h index 7eb44132183a..da0c5b917cb1 100644 --- a/drivers/gpu/drm/i915/i915_active.h +++ b/drivers/gpu/drm/i915/i915_active.h @@ -65,7 +65,7 @@ __i915_active_fence_init(struct i915_active_fence *active, dma_fence_func_t fn) { RCU_INIT_POINTER(active->fence, fence); - active->cb.func = fn ?: i915_active_noop; + __dma_fence_cb_init(&active->cb, fn ?: i915_active_noop); } #define INIT_ACTIVE_FENCE(A) \ From patchwork Tue Mar 7 10:48:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13163136 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8E957C678D4 for ; Tue, 7 Mar 2023 10:49:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2874E10E479; Tue, 7 Mar 2023 10:48:44 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id AE10F10E457; Tue, 7 Mar 2023 10:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678186119; x=1709722119; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+aPUIYHD7DICRcKfwyOdEJV+UU5rx+U/9lVp66ESc/k=; b=AfpqSNPZwO129NoaorAcHcuSKIc4UGsgLFv9ZnZf2U/66JR7bMjkFQwD psIT/RePvzC9W/RVpWbKyWbYbZfrHaNEDrmsO+pTpxOzFXtLMXuDEpM7f gkyZlR4gZJDYq8dg1zgbB1LRnTsCMIWgSfD2/n0aKMR5DAI5iiHBGncFp L+4vF4pBoLHVhpvwWXPjBHIZl0kJqyIxGX/9t+RN0d1whl4QhZAdKwsit 7ZmnB+g47UIIYACFVrmeuTLSGjh83hrGHJeeQ/NpqTRR0itrGioWeC8kJ pr+gsUu/EulQVwnAAe6/Q2ch6OjpZHmuhzMhQ+3xk0I2z8UtH3gnsllk5 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="400643418" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="400643418" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819712833" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="819712833" Received: from tanzeelu-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.205.53]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:37 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC 04/12] drm/vmwgfx: Use fence callback initialization helper Date: Tue, 7 Mar 2023 10:48:16 +0000 Message-Id: <20230307104824.231094-5-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230307104824.231094-1-tvrtko.ursulin@linux.intel.com> References: <20230307104824.231094-1-tvrtko.ursulin@linux.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: Matt Turner , Tvrtko Ursulin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tvrtko Ursulin Use the previously added initialization helper to ensure correct operation of the common code. Signed-off-by: Tvrtko Ursulin Cc: Zack Rusin --- drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c index 2a0cda324703..0306596765e5 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c @@ -200,7 +200,7 @@ static long vmw_fence_wait(struct dma_fence *f, bool intr, signed long timeout) goto out; } - cb.base.func = vmwgfx_wait_cb; + __dma_fence_cb_init(&cb.base, vmwgfx_wait_cb); cb.task = current; list_add(&cb.base.node, &f->cb_list); From patchwork Tue Mar 7 10:48:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13163137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6619EC678D4 for ; Tue, 7 Mar 2023 10:49:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F197610E478; Tue, 7 Mar 2023 10:48:46 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F8E010E40E; Tue, 7 Mar 2023 10:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678186122; x=1709722122; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v4LfcB5TZ42W7SnV+Utkjpk0s4/jeJwTGxPpydGQFXA=; b=MN0QjfzvTKKMAVg5mrKOSk7Jz1YdYC1YGHmQpkJrtAIUXUqQzk84qlyV rCl8jS7VvVxYBDdPf+vf8hFTNojYBDPHjEI0jrHxlV0V833ESYGEXdp2e ndQjtC++U8JonDwCSIQFap3y4uHX9OwZ9pSeQAObTGv0FGCuFm3JoPtmO QFk37G5GR2ipAqPCWqJ6YpW7cwCVFoyF+8cJeTiAZhoy576zV7JRgSD+w OTbhNqF9aJ7js+/mXdQpv5BXghJn1BWZ8DPd8mqMh0VBilWEARQqaD5VK MDER7ip8A6UrG/gQLArNrKzcsxq1zkDiDGSXM+AAtlxMN5wjgqZal13XN w==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="400643427" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="400643427" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819712850" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="819712850" Received: from tanzeelu-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.205.53]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:39 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC 05/12] dma-fence: Track explicit waiters Date: Tue, 7 Mar 2023 10:48:17 +0000 Message-Id: <20230307104824.231094-6-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230307104824.231094-1-tvrtko.ursulin@linux.intel.com> References: <20230307104824.231094-1-tvrtko.ursulin@linux.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: Matt Turner , Tvrtko Ursulin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tvrtko Ursulin Track how many callers are explicity waiting on a fence to signal and allow querying that via new dma_fence_wait_count() API. This provides infrastructure on top of which generic "waitboost" concepts can be implemented by individual drivers. Wait-boosting is any reactive activity, such as raising the GPU clocks, which happens while there are active external waiters. Signed-off-by: Tvrtko Ursulin --- drivers/dma-buf/dma-fence.c | 98 +++++++++++++++++------ drivers/gpu/drm/i915/gt/intel_engine_pm.c | 1 - include/linux/dma-fence.h | 15 ++++ 3 files changed, 87 insertions(+), 27 deletions(-) diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c index ea4a1f82c9bf..bdba5a8e21b1 100644 --- a/drivers/dma-buf/dma-fence.c +++ b/drivers/dma-buf/dma-fence.c @@ -344,6 +344,25 @@ void __dma_fence_might_wait(void) } #endif +static void incr_wait_count(struct dma_fence *fence, struct dma_fence_cb *cb) +{ + lockdep_assert_held(fence->lock); + + __set_bit(DMA_FENCE_CB_FLAG_WAITCOUNT_BIT, &cb->flags); + fence->waitcount++; + WARN_ON_ONCE(!fence->waitcount); +} + +static void decr_wait_count(struct dma_fence *fence, struct dma_fence_cb *cb) +{ + lockdep_assert_held(fence->lock); + + if (__test_and_clear_bit(DMA_FENCE_CB_FLAG_WAITCOUNT_BIT, &cb->flags)) { + WARN_ON_ONCE(!fence->waitcount); + fence->waitcount--; + } +} + void __dma_fence_signal__timestamp(struct dma_fence *fence, ktime_t timestamp) { lockdep_assert_held(fence->lock); @@ -363,6 +382,7 @@ __dma_fence_signal__notify(struct dma_fence *fence, lockdep_assert_held(fence->lock); list_for_each_entry_safe(cur, tmp, list, node) { + decr_wait_count(fence, cur); INIT_LIST_HEAD(&cur->node); cur->func(fence, cur); } @@ -629,11 +649,44 @@ void dma_fence_enable_sw_signaling(struct dma_fence *fence) unsigned long flags; spin_lock_irqsave(fence->lock, flags); + fence->waitcount++; + WARN_ON_ONCE(!fence->waitcount); __dma_fence_enable_signaling(fence); spin_unlock_irqrestore(fence->lock, flags); } EXPORT_SYMBOL(dma_fence_enable_sw_signaling); +static int add_callback(struct dma_fence *fence, struct dma_fence_cb *cb, + dma_fence_func_t func, bool wait) +{ + unsigned long flags; + int ret = 0; + + __dma_fence_cb_init(cb, func); + + if (WARN_ON(!fence || !func)) + return -EINVAL; + + if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) + return -ENOENT; + + spin_lock_irqsave(fence->lock, flags); + + if (wait) + incr_wait_count(fence, cb); + + if (__dma_fence_enable_signaling(fence)) { + list_add_tail(&cb->node, &fence->cb_list); + } else { + decr_wait_count(fence, cb); + ret = -ENOENT; + } + + spin_unlock_irqrestore(fence->lock, flags); + + return ret; +} + /** * dma_fence_add_callback - add a callback to be called when the fence * is signaled @@ -659,31 +712,18 @@ EXPORT_SYMBOL(dma_fence_enable_sw_signaling); int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb, dma_fence_func_t func) { - unsigned long flags; - int ret = 0; - - __dma_fence_cb_init(cb, func); - - if (WARN_ON(!fence || !func)) - return -EINVAL; - - if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) - return -ENOENT; - - spin_lock_irqsave(fence->lock, flags); - - if (__dma_fence_enable_signaling(fence)) { - list_add_tail(&cb->node, &fence->cb_list); - } else { - ret = -ENOENT; - } - - spin_unlock_irqrestore(fence->lock, flags); - - return ret; + return add_callback(fence, cb, func, false); } EXPORT_SYMBOL(dma_fence_add_callback); +int dma_fence_add_wait_callback(struct dma_fence *fence, + struct dma_fence_cb *cb, + dma_fence_func_t func) +{ + return add_callback(fence, cb, func, true); +} +EXPORT_SYMBOL(dma_fence_add_wait_callback); + /** * dma_fence_get_status - returns the status upon completion * @fence: the dma_fence to query @@ -736,8 +776,10 @@ dma_fence_remove_callback(struct dma_fence *fence, struct dma_fence_cb *cb) spin_lock_irqsave(fence->lock, flags); ret = !list_empty(&cb->node); - if (ret) + if (ret) { + decr_wait_count(fence, cb); list_del_init(&cb->node); + } spin_unlock_irqrestore(fence->lock, flags); @@ -795,6 +837,7 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout) __dma_fence_cb_init(&cb.base, dma_fence_default_wait_cb); cb.task = current; + incr_wait_count(fence, &cb.base); list_add(&cb.base.node, &fence->cb_list); while (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags) && ret > 0) { @@ -811,8 +854,10 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout) ret = -ERESTARTSYS; } - if (!list_empty(&cb.base.node)) + if (!list_empty(&cb.base.node)) { + decr_wait_count(fence, &cb.base); list_del(&cb.base.node); + } __set_current_state(TASK_RUNNING); out: @@ -890,8 +935,8 @@ dma_fence_wait_any_timeout(struct dma_fence **fences, uint32_t count, struct dma_fence *fence = fences[i]; cb[i].task = current; - if (dma_fence_add_callback(fence, &cb[i].base, - dma_fence_default_wait_cb)) { + if (dma_fence_add_wait_callback(fence, &cb[i].base, + dma_fence_default_wait_cb)) { /* This fence is already signaled */ if (idx) *idx = i; @@ -972,6 +1017,7 @@ dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops, fence->context = context; fence->seqno = seqno; fence->flags = 0UL; + fence->waitcount = 0; fence->error = 0; trace_dma_fence_init(fence); diff --git a/drivers/gpu/drm/i915/gt/intel_engine_pm.c b/drivers/gpu/drm/i915/gt/intel_engine_pm.c index e971b153fda9..2693a0151a6b 100644 --- a/drivers/gpu/drm/i915/gt/intel_engine_pm.c +++ b/drivers/gpu/drm/i915/gt/intel_engine_pm.c @@ -218,7 +218,6 @@ static bool switch_to_kernel_context(struct intel_engine_cs *engine) * until the background request retirement running every * second or two). */ - BUILD_BUG_ON(sizeof(rq->duration) > sizeof(rq->submitq)); dma_fence_add_callback(&rq->fence, &rq->duration.cb, duration); rq->duration.emitted = ktime_get(); } diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h index 35933e0ae62c..2b696f9de276 100644 --- a/include/linux/dma-fence.h +++ b/include/linux/dma-fence.h @@ -92,6 +92,7 @@ struct dma_fence { u64 seqno; unsigned long flags; struct kref refcount; + unsigned int waitcount; int error; }; @@ -116,6 +117,11 @@ typedef void (*dma_fence_func_t)(struct dma_fence *fence, struct dma_fence_cb { struct list_head node; dma_fence_func_t func; + unsigned long flags; +}; + +enum dma_fence_cb_flag_bits { + DMA_FENCE_CB_FLAG_WAITCOUNT_BIT, }; /** @@ -381,6 +387,9 @@ signed long dma_fence_default_wait(struct dma_fence *fence, int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb, dma_fence_func_t func); +int dma_fence_add_wait_callback(struct dma_fence *fence, + struct dma_fence_cb *cb, + dma_fence_func_t func); bool dma_fence_remove_callback(struct dma_fence *fence, struct dma_fence_cb *cb); void dma_fence_enable_sw_signaling(struct dma_fence *fence); @@ -532,6 +541,11 @@ static inline int dma_fence_get_status_locked(struct dma_fence *fence) int dma_fence_get_status(struct dma_fence *fence); +static inline unsigned int dma_fence_wait_count(struct dma_fence *fence) +{ + return fence->waitcount; +} + /** * dma_fence_set_error - flag an error condition on the fence * @fence: the dma_fence @@ -634,6 +648,7 @@ static inline void __dma_fence_cb_init(struct dma_fence_cb *cb, { INIT_LIST_HEAD(&cb->node); cb->func = func; + cb->flags = 0; } #endif /* __LINUX_DMA_FENCE_H */ From patchwork Tue Mar 7 10:48:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13163138 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E4624C678D4 for ; Tue, 7 Mar 2023 10:49:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2172C10E488; Tue, 7 Mar 2023 10:48:48 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id E3D3810E478; Tue, 7 Mar 2023 10:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678186124; x=1709722124; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8Mu1PYjGW2s/WLRmT/+xzjXgFhwKvONBND9x8er3acQ=; b=h1scpi6dMS1Jzv08XIP9zELCqcNe5uivsrwe1z639S+7n7rn1b8rmh8M ieIhMHQFgIBdHSedPxYKu/FhZBrT+XeYf7HAzkmavmR/OcyqNmVgNv2Rn O86K8IMj2HZC2qMDgYRwZQYS8jGTnmRIn1onsUSHnaqcCp7vjgFP2jMfr 0TLLkWeuQ+fBQ6iVkdKKFh+m+EGBCx0XOunscDczKYe4dPJA4cFga8/St w6/Ihrl80PkcfeboEIJYr+AelnOdazh3ETKSuzkPSpR8rKtDSN+RhXNXe cgLpv+LOD5gf5usrrvMslvefPLSbDQc5W8YdcvbIfsJPkoHyX0bFVwTRa A==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="400643434" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="400643434" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819712871" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="819712871" Received: from tanzeelu-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.205.53]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:41 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC 06/12] dma-fence: Export __dma_fence_add_callback Date: Tue, 7 Mar 2023 10:48:18 +0000 Message-Id: <20230307104824.231094-7-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230307104824.231094-1-tvrtko.ursulin@linux.intel.com> References: <20230307104824.231094-1-tvrtko.ursulin@linux.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: Matt Turner , Tvrtko Ursulin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tvrtko Ursulin ... Signed-off-by: Tvrtko Ursulin --- drivers/dma-buf/dma-fence.c | 9 +++++---- include/linux/dma-fence.h | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c index bdba5a8e21b1..5607acdb6ccf 100644 --- a/drivers/dma-buf/dma-fence.c +++ b/drivers/dma-buf/dma-fence.c @@ -656,8 +656,8 @@ void dma_fence_enable_sw_signaling(struct dma_fence *fence) } EXPORT_SYMBOL(dma_fence_enable_sw_signaling); -static int add_callback(struct dma_fence *fence, struct dma_fence_cb *cb, - dma_fence_func_t func, bool wait) +int __dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb, + dma_fence_func_t func, bool wait) { unsigned long flags; int ret = 0; @@ -686,6 +686,7 @@ static int add_callback(struct dma_fence *fence, struct dma_fence_cb *cb, return ret; } +EXPORT_SYMBOL(__dma_fence_add_callback); /** * dma_fence_add_callback - add a callback to be called when the fence @@ -712,7 +713,7 @@ static int add_callback(struct dma_fence *fence, struct dma_fence_cb *cb, int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb, dma_fence_func_t func) { - return add_callback(fence, cb, func, false); + return __dma_fence_add_callback(fence, cb, func, false); } EXPORT_SYMBOL(dma_fence_add_callback); @@ -720,7 +721,7 @@ int dma_fence_add_wait_callback(struct dma_fence *fence, struct dma_fence_cb *cb, dma_fence_func_t func) { - return add_callback(fence, cb, func, true); + return __dma_fence_add_callback(fence, cb, func, true); } EXPORT_SYMBOL(dma_fence_add_wait_callback); diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h index 2b696f9de276..1f41d60ce6f7 100644 --- a/include/linux/dma-fence.h +++ b/include/linux/dma-fence.h @@ -384,6 +384,9 @@ int dma_fence_signal_timestamp_locked(struct dma_fence *fence, ktime_t timestamp); signed long dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout); +int __dma_fence_add_callback(struct dma_fence *fence, + struct dma_fence_cb *cb, + dma_fence_func_t func, bool wait); int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb, dma_fence_func_t func); From patchwork Tue Mar 7 10:48:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13163141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 63A95C678D5 for ; Tue, 7 Mar 2023 10:49:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 83F5A10E49A; Tue, 7 Mar 2023 10:48:52 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8378310E478; Tue, 7 Mar 2023 10:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678186125; x=1709722125; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HtfxNZ6V0OO/oxYVWnwzHilLqxmn1cFyQg7zcTM8kRg=; b=bTnFPl0gPFccIYAQbzDoHc69oiXjabwGF6UKF3D5tLHiJV0ZVHheBd9u AkNKhiQxsj4UNsCC39Obq4eExAf/RTl0knPE1CiZvn9ScRpRO4o0W+UFT O0c/MveJSP7rcZ8fKeVlbVtuJIXW35Gq1Q3DjJfRiXp6/TuoQglNTyAln DKAo6qqDHhVQW56qZ8uJB2O+i+zJxb9dnbEP39M5aAvaVJ11lHlCJPR9j 02GE6c//nFJKreUduHDJeC2NCoHXNFa8S805+8RKK4xowva+a4D3XuKS3 E/wc1TKzm4LPib0woYxgehvxyQVO7f65Fae4crHqCwqJ1blMmWAiGJTSj Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="400643441" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="400643441" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819712889" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="819712889" Received: from tanzeelu-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.205.53]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:43 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC 07/12] dma-fence-array: Propagate wait status to contained fences Date: Tue, 7 Mar 2023 10:48:19 +0000 Message-Id: <20230307104824.231094-8-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230307104824.231094-1-tvrtko.ursulin@linux.intel.com> References: <20230307104824.231094-1-tvrtko.ursulin@linux.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: Matt Turner , Tvrtko Ursulin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tvrtko Ursulin As signaling is enabled on the container fence we need to propagate any external waiting status to individual fences in order to enable owning drivers see it. Signed-off-by: Tvrtko Ursulin --- drivers/dma-buf/dma-fence-array.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c index 5c8a7084577b..e732adc230d1 100644 --- a/drivers/dma-buf/dma-fence-array.c +++ b/drivers/dma-buf/dma-fence-array.c @@ -84,8 +84,9 @@ static bool dma_fence_array_enable_signaling(struct dma_fence *fence) * insufficient). */ dma_fence_get(&array->base); - if (dma_fence_add_callback(array->fences[i], &cb[i].cb, - dma_fence_array_cb_func)) { + if (__dma_fence_add_callback(array->fences[i], &cb[i].cb, + dma_fence_array_cb_func, + fence->waitcount > 0)) { int error = array->fences[i]->error; dma_fence_array_set_pending_error(array, error); From patchwork Tue Mar 7 10:48:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13163140 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EBB92C678D4 for ; Tue, 7 Mar 2023 10:49:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 97F0A10E499; Tue, 7 Mar 2023 10:48:51 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2E0A910E488; Tue, 7 Mar 2023 10:48:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678186127; x=1709722127; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rnzRe13qhrrA5ljmMARPkyyrz5Rg225kZeF/vZZHOAI=; b=FpCj8au9euSKWul8i3Hy8qlYzNaQgsS7VGZAm7Kp5WrmLTW0+aa9QWOG wLPNV5RqFj7JGIYdJaP8rLnRWsdUPd5bz0IoT7ctE8ejO6yx0K0ug7RJU VXaCUTuRnLKrj+F9kd6KHtzysSRRmns4uFl/PslOioTirw5IEGF889nb4 9rmyoMx2rAHmoBhnEqMjUDf3ReCUKn+BjVA62YF82k2+qaUTNrehopD7R CeYktGxsbZXCeY4mH9lYNwk2zgZxQonjDF3MH/1xxtulXFZwBqL+nP6Ig AAREcRUk9r8cjtBcSDnPT7jpC0jP3ssI0Wbg0kLqHAcGqViGMkRjvfPQ/ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="400643449" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="400643449" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819712903" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="819712903" Received: from tanzeelu-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.205.53]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:45 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC 08/12] dma-fence-chain: Propagate wait status to contained fences Date: Tue, 7 Mar 2023 10:48:20 +0000 Message-Id: <20230307104824.231094-9-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230307104824.231094-1-tvrtko.ursulin@linux.intel.com> References: <20230307104824.231094-1-tvrtko.ursulin@linux.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: Matt Turner , Tvrtko Ursulin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tvrtko Ursulin As signaling is enabled on the container fence we need to propagate any external waiting status to individual fences in order to enable owning drivers see it. Signed-off-by: Tvrtko Ursulin --- drivers/dma-buf/dma-fence-chain.c | 22 ++++++++++++++++------ include/linux/dma-fence-chain.h | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/dma-buf/dma-fence-chain.c b/drivers/dma-buf/dma-fence-chain.c index a0d920576ba6..ef6a5988c8aa 100644 --- a/drivers/dma-buf/dma-fence-chain.c +++ b/drivers/dma-buf/dma-fence-chain.c @@ -145,20 +145,30 @@ static void dma_fence_chain_cb(struct dma_fence *f, struct dma_fence_cb *cb) static bool dma_fence_chain_enable_signaling(struct dma_fence *fence) { struct dma_fence_chain *head = to_dma_fence_chain(fence); + struct dma_fence *callback = NULL; dma_fence_get(&head->base); dma_fence_chain_for_each(fence, &head->base) { struct dma_fence *f = dma_fence_chain_contained(fence); - dma_fence_get(f); - if (!dma_fence_add_callback(f, &head->cb, dma_fence_chain_cb)) { + if (!callback) { + dma_fence_get(f); + if (!dma_fence_add_callback(f, &head->cb, + dma_fence_chain_cb)) + callback = f; + else + dma_fence_put(f); + } else if (head->base.waitcount && !head->waitcount) { + dma_fence_enable_sw_signaling(f); + } else { dma_fence_put(fence); - return true; + break; } - dma_fence_put(f); } - dma_fence_put(&head->base); - return false; + head->waitcount = head->base.waitcount; + if (!callback) + dma_fence_put(&head->base); + return callback; } static bool dma_fence_chain_signaled(struct dma_fence *fence) diff --git a/include/linux/dma-fence-chain.h b/include/linux/dma-fence-chain.h index 4bdf0b96da28..349b882d31ea 100644 --- a/include/linux/dma-fence-chain.h +++ b/include/linux/dma-fence-chain.h @@ -25,6 +25,7 @@ struct dma_fence_chain { struct dma_fence base; struct dma_fence __rcu *prev; + bool waitcount; u64 prev_seqno; struct dma_fence *fence; union { From patchwork Tue Mar 7 10:48:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13163139 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 761E5C678D5 for ; Tue, 7 Mar 2023 10:49:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4C64710E496; Tue, 7 Mar 2023 10:48:50 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 01F6C10E49A; Tue, 7 Mar 2023 10:48:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678186129; x=1709722129; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=URb0lCKRfLIha7WsBjPGOr3MHbHvX2Y/Iq0wYdVSRz8=; b=WEKXNG319mzvt558MDl9D+elv1OgQCI28L6aA75MkrtCfAhj4UGKfeZy phxUWZNc5GE3JuOa4Mf1VEkHxqK/nIGzVQ8K1CbAVVB449t2F6G8k4SLm ol2W7ufnPAJs0o4sr0z5H2pAIeTYc2nINWF8GziyiY0yiq9r1GRFPC0GV MeHgwtaSAkvaxDvKx1jCJ5ubvQX7WQwbupHfsPUH+GQY6v10E/im4+9x0 wjNu9x5aHJZBNHEmgJkjFgZODTMIyAomyctrPAyADVBPzRA/nW4+3HxOe fCr8tw1MhKlAhRpVcZ/LHsTYd5EcW2CE6Tm+KYHKNz6/HU9QQU+1Gt5pv Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="400643462" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="400643462" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819712933" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="819712933" Received: from tanzeelu-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.205.53]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:46 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC 09/12] drm/syncobj: Mark syncobj waits as external waiters Date: Tue, 7 Mar 2023 10:48:21 +0000 Message-Id: <20230307104824.231094-10-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230307104824.231094-1-tvrtko.ursulin@linux.intel.com> References: <20230307104824.231094-1-tvrtko.ursulin@linux.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: Matt Turner , Tvrtko Ursulin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tvrtko Ursulin Use the previously added dma-fence tracking of explicit waiters. Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/drm_syncobj.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 0c2be8360525..776b90774a64 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -1065,9 +1065,9 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, if ((flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE) || dma_fence_is_signaled(fence) || (!entries[i].fence_cb.func && - dma_fence_add_callback(fence, - &entries[i].fence_cb, - syncobj_wait_fence_func))) { + dma_fence_add_wait_callback(fence, + &entries[i].fence_cb, + syncobj_wait_fence_func))) { /* The fence has been signaled */ if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL) { signaled_count++; From patchwork Tue Mar 7 10:48:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13163142 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 87182C678D4 for ; Tue, 7 Mar 2023 10:49:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8476E10E49D; Tue, 7 Mar 2023 10:48:53 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 80A6610E49C; Tue, 7 Mar 2023 10:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678186130; x=1709722130; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zSi9XMQjKhlDhU66P/HKW+kdwHFQnJ/1owjm47W+ojc=; b=Fz2dX1j4D9oix92smTJzapAjIPs3mFnoNxBgPtrfk5lRT60FR7eghoUq CRkcQnqK0bX1+QuqjnaAeuHMosMhl1EskLTG1fn5WIHo4mLJ1abhdqxAH SmnfkuL5vQx7rQyYpLsXRnzQUT2XxjrSvJ702ayB51YX8IbY9eCJ1uAxU AOL9Tvz2Gra/qnevqbGvLtQ1MofsGm1qKAqdjwy940TtFkV4EcR/ZCR2z BPoPjCGwsaOzn2Ll1lieHMmiSjwhKc14Jr4pk4Q1Ut8cEBKOhW8n5n5P5 LrUDm7iPIfNXnfrSTxib61HQ0YPc0Qoq4UtNHUl6i1Y9OJCeAOrcrzO22 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="400643472" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="400643472" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819712942" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="819712942" Received: from tanzeelu-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.205.53]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:48 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC 10/12] drm/i915: Waitboost external waits Date: Tue, 7 Mar 2023 10:48:22 +0000 Message-Id: <20230307104824.231094-11-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230307104824.231094-1-tvrtko.ursulin@linux.intel.com> References: <20230307104824.231094-1-tvrtko.ursulin@linux.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: Matt Turner , Tvrtko Ursulin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tvrtko Ursulin Userspace waits coming via the drm_syncobj route have so far been bypassing the waitboost mechanism. Use the previously added dma-fence wait tracking API and apply the same waitboosting logic which applies to other entry points. This should fix the perfomance regressions experience by clvk and similar userspace which relies on drm_syncobj. Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_request.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c index 630a732aaecc..42b04cced6f0 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -93,7 +93,12 @@ static bool i915_fence_signaled(struct dma_fence *fence) static bool i915_fence_enable_signaling(struct dma_fence *fence) { - return i915_request_enable_breadcrumb(to_request(fence)); + struct i915_request *rq = to_request(fence); + + if (dma_fence_wait_count(&rq->fence) && !i915_request_started(rq)) + intel_rps_boost(rq); + + return i915_request_enable_breadcrumb(rq); } static signed long i915_fence_wait(struct dma_fence *fence, From patchwork Tue Mar 7 10:48:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13163143 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E0E9CC6FD1B for ; Tue, 7 Mar 2023 10:49:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1822210E4A0; Tue, 7 Mar 2023 10:48:59 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5DE7210E49D; Tue, 7 Mar 2023 10:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678186132; x=1709722132; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1MlL0hgd5hFopQMdoCbSJnG4ciIGZ62rg5TYtVfTMH4=; b=maO3G3Zuo0YQBosEf1hogt1n1voHYHZCKUd8CnX96zPSbouMme1+4pQJ vXQRhV6ZH2GRcCcYRQgQwjz9BbO80Gf/ZHMV8yTIBQtpKtveprlobAkjo RnvFSyFH9JEicudFz3XraIzzBRSO5goHFq1SWKcBpKEEPkd614yQn1DyT PWA1+oxWksxdrCQSRjAG0JdZCc+yHZtoha3hpmHsO8UoP7gy6cuSmBPPg uQmVsJS6XB6QnVa6WrEGbtGKgVZsHRrD/qVSrre5FfFQUMqwkZzX9cXcI +z9OHKAt6Bs22lXIqwMsSxY8bQQLhKGRnlA0KJOucl22pG9vlX1L/2LHv Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="400643493" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="400643493" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819712956" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="819712956" Received: from tanzeelu-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.205.53]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:50 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC 11/12] drm/i915: Mark waits as explicit Date: Tue, 7 Mar 2023 10:48:23 +0000 Message-Id: <20230307104824.231094-12-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230307104824.231094-1-tvrtko.ursulin@linux.intel.com> References: <20230307104824.231094-1-tvrtko.ursulin@linux.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: Matt Turner , Tvrtko Ursulin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tvrtko Ursulin Use the previously added dma-fence API to mark the direct i915 waits as explicit. This has no significant effect apart from following the new pattern. Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_request.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c index 42b04cced6f0..dd8a9045086a 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -2045,7 +2045,8 @@ long i915_request_wait_timeout(struct i915_request *rq, intel_rps_boost(rq); wait.tsk = current; - if (dma_fence_add_callback(&rq->fence, &wait.cb, request_wait_wake)) + if (dma_fence_add_wait_callback(&rq->fence, &wait.cb, + request_wait_wake)) goto out; /* From patchwork Tue Mar 7 10:48:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13163144 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4F9AFC678D4 for ; Tue, 7 Mar 2023 10:49:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CE31D10E4A3; Tue, 7 Mar 2023 10:48:59 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5039910E4A0; Tue, 7 Mar 2023 10:48:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678186134; x=1709722134; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rsTLryc6IfUvnPWE7k7B9yi3VVtvOkjvjdiIRVAT6H8=; b=KKGwCJg+YZAZ9uo7JCsQUhVUuPDvpxXg1aEAFUqSs2ER/E7wToH9C22R 7mJyZYvDGOuy9rYvoKGEDNjr838acUP54I8CSBPNqifZPuCn6CDwx3Mhk D3QuxI0MV4PPa9tLe9V5J4wLBHoPvLsrcjHNpqqgpPhhh8MULe9zwKiuY yq81v40+aM1T6bKzJL5SwMpUMlcgvFqMtMp1vOWaoHTaY3ytXVeC59SjF AmwDgY2zKu+Ltv6Zp3QPatbSCnk42ztxZSVqIEr2g/s9jhkivkcqmtvZV PIoPSZ2s2DhRIfyo+HbREFh5PF/Lz1x4zdxUR6s5WyGwKXPMtMdxewjbi Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="400643513" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="400643513" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819712976" X-IronPort-AV: E=Sophos;i="5.98,240,1673942400"; d="scan'208";a="819712976" Received: from tanzeelu-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.205.53]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2023 02:48:51 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [RFC 12/12] drm/i915: Wait boost requests waited upon by others Date: Tue, 7 Mar 2023 10:48:24 +0000 Message-Id: <20230307104824.231094-13-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230307104824.231094-1-tvrtko.ursulin@linux.intel.com> References: <20230307104824.231094-1-tvrtko.ursulin@linux.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: Matt Turner , Tvrtko Ursulin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tvrtko Ursulin Use the newly added dma-fence API to apply waitboost not only requests which have been marked with I915_WAIT_PRIORITY by i915, but which may be waited upon by others (such as for instance buffer sharing in multi-GPU scenarios). Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_request.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c index dd8a9045086a..c4adf34016d0 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -2041,7 +2041,8 @@ long i915_request_wait_timeout(struct i915_request *rq, * but at a cost of spending more power processing the workload * (bad for battery). */ - if (flags & I915_WAIT_PRIORITY && !i915_request_started(rq)) + if (((flags & I915_WAIT_PRIORITY) || dma_fence_wait_count(&rq->fence)) + && !i915_request_started(rq)) intel_rps_boost(rq); wait.tsk = current;