From patchwork Thu Feb 16 10:59: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: 13142950 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 DE892C64ED6 for ; Thu, 16 Feb 2023 10:59:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 231E110E314; Thu, 16 Feb 2023 10:59:31 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id D053110E2BE; Thu, 16 Feb 2023 10:59:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676545169; x=1708081169; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=b/JyHCbIjDPAM5EMAne4huPw7eYXOz7XyJMAeoQ79sc=; b=UmZyNTu8fvTDrNan25ZoJ4XgeFMvcYNHg/lc22cq3AuMqNKXmag14ozU AClrlbcsIYmyBdNFLMrMxQm+439j5+qBZFSFm26rVwzGqr+iDYqZQ63VO yHG4fnBnzKzralrIOUSYc+fIYZ/+70l/cezsvWnc2+p7O+vHvTnfG/1OG RbDfiPrz+XqWX5uBzJKCE/u/hvtGLl8tgW2E7t9s/scjkrogpzfixHBko VYcpccfynGhPfjVdR35IHo+dxODoohn9NvCw5lQ0qu7wrBmtO+dDLvJC0 RHt+o9frJlzbwmI4kFONxXNwnCW5mZOBbbzoEdUOgqjb09pn4f7wjEkFg w==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="311317597" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="311317597" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:29 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="812917907" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="812917907" Received: from murrayal-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.229.164]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:28 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Thu, 16 Feb 2023 10:59:13 +0000 Message-Id: <20230216105921.624960-2-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> References: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC 1/9] dma-fence: Move i915 helpers into common X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 Thu Feb 16 10:59: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: 13142952 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 7166AC636CC for ; Thu, 16 Feb 2023 10:59:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4FFCA10ED30; Thu, 16 Feb 2023 10:59:34 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id EAF9810E2BE; Thu, 16 Feb 2023 10:59:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676545170; x=1708081170; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=QutN+efEVB8E3nC/YDlbdNrmmmnI/0o9j6soojqaUuk=; b=bJJqDo34/36xl5jE8A7bU5hfBsLIcwEn9u+03Ap4SL4JZovFTxmIdoXP z7zKE13KMhJWztUIBZV6MQv6M+d+1mB1Dnw0AdjNSVBwksHv3ACBJ3tyw eMlgsJxpbjqoXbNPVilulcvRO2H1kF0BKt7vcOgaFad6KgJPy2Gx2JbI5 4mUVSEKG2oeS+BnFKlQ/cRud75+f9ZJt7JWReY0Tr3rdpa8NZzx4nU9Tx xnNma3wYnpJPy9xMbbOPbSlGnv9x9fbRL7mqpK2LngQ5RqVYXQbSbVmuw 7vfhmSZqefySHERHXBHTBLsMXTKG+tlX30r+s56UnUTxhjUUbdO1kByRa w==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="311317599" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="311317599" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:30 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="812917909" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="812917909" Received: from murrayal-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.229.164]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:29 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Thu, 16 Feb 2023 10:59:14 +0000 Message-Id: <20230216105921.624960-3-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> References: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC 2/9] dma-fence: Add callback initialization helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 Thu Feb 16 10:59: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: 13142956 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 7946EC636CC for ; Thu, 16 Feb 2023 11:00:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9216810ED41; Thu, 16 Feb 2023 10:59:38 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 11A9C10ED19; Thu, 16 Feb 2023 10:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676545172; x=1708081172; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=uk/GmpuW79W2EydXmlCYOB17kdJavbWT9XM7VhTE0PY=; b=JofHkxif2i9xyNTbwcZKleb+uDHYaKiN75D4lnuu+AyCd/Kj/Kj+1+Mg AUUZSGEf+OFPYGOs64DwPeX47hCplhJKmTno7snu2tAmM8giGiafYNg22 J7dzwVGmT25bZMMZaX4hzHjecWFSJHRaLJR3KRib3vhgaWSMnXJjRJzE6 nPTNWy1+WjcNmpVne9Tj4yeXVNAUkZlHksWryGesyxr2TWqxOR72eL+/j tEnfO8HhBAIPlMOFqE5c3Z7gKiQjzkulLCF7D77wOvUj+BxVzPf2BdhvG PZOW2IvwLY6+SBugV6DaW131qVhgIFCFmjhcctZ9D6OK4EnyFjJyERbH5 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="311317601" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="311317601" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:31 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="812917912" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="812917912" Received: from murrayal-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.229.164]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:30 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Thu, 16 Feb 2023 10:59:15 +0000 Message-Id: <20230216105921.624960-4-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> References: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC 3/9] drm/i915: Use fence callback initialization helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 7412abf166a8..a9483aadb0ff 100644 --- a/drivers/gpu/drm/i915/i915_active.c +++ b/drivers/gpu/drm/i915/i915_active.c @@ -887,7 +887,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 Thu Feb 16 10:59: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: 13142953 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 BB175C636D6 for ; Thu, 16 Feb 2023 10:59:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4841310ED3D; Thu, 16 Feb 2023 10:59:38 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5062610ED2F; Thu, 16 Feb 2023 10:59:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676545173; x=1708081173; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=QUM037SnX+6+bUI57gXj5vZBxJj3sCZQwdIJxBGM6ZA=; b=ZiZeG++0o32DP1QDUAldYCfHRR5rs9zXvtQB+DYrytxHotTmW3LqxZqN weQp2EbExyFtnKV0k75r2Hvd43A7aJYUlXELq7nAsftu6vbVI3Rz2pOte Xnbv5aEwkBFH9yVK+NS5hxic7MN1d5DM7vCML376dbyMiKKGczaS4ASaP K+1md7CF5UUbB9jWUQk/JS5rJzkN/i2t2AKcSKvB0e2xP3bZZJUKqRNjE ptBBRIVNulPZETKb49aKNMrULJWBoOaVDJPu5eYueUUeNQhpNLtlhTfq2 yO0jpecoMeUfLGhVe/yvEa3HFlTX2ki8Hjp/GxX+V4QHM3sMuUalpsYjh w==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="311317602" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="311317602" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:33 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="812917913" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="812917913" Received: from murrayal-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.229.164]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:32 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Thu, 16 Feb 2023 10:59:16 +0000 Message-Id: <20230216105921.624960-5-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> References: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC 4/9] drm/vmwgfx: Use fence callback initialization helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 Thu Feb 16 10:59: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: 13142955 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 8AAA2C64EC4 for ; Thu, 16 Feb 2023 10:59:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 824A110ED3E; Thu, 16 Feb 2023 10:59:38 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9B9BD10ED37; Thu, 16 Feb 2023 10:59: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=1676545174; x=1708081174; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=gIs+BSsQDcWCQfjF8xgobCfXmogy490JoiMFSXi7dJE=; b=UfaHdI+tpIE5FH4s9B2h56GnjKW7XBgUQrnkCW50o7fVGkjj+PpuZD13 w5OJCpnpiNQ1+bv0aNSB25M+mVTVwaaXzrCClrRbMpc6SzxTFxe8je7at mqIyUnqgzEqyHOxA6bO7VD2fj2CAi5RJRsy/AEAHLaHYHrYX3b6FjAc7O +jgG2c+QMUfSJPFnnscZsBxAFDpDFAWMMAywmywKUP9MPYgNkzSFZEpZz Po8W7jCLCheD95T3PDSqVLyufmDdnwY1nGVvJVX61PBz21dgEJROt1IeI VVkMwH/aK9wm5boeTuu6+XxgB/WAKb/Ku0FBZskPGlWVPUNac08w6fdhe w==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="311317606" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="311317606" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:34 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="812917917" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="812917917" Received: from murrayal-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.229.164]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:33 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Thu, 16 Feb 2023 10:59:17 +0000 Message-Id: <20230216105921.624960-6-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> References: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC 5/9] dma-fence: Track explicit waiters X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 Thu Feb 16 10:59: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: 13142954 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 BADF7C61DA4 for ; Thu, 16 Feb 2023 10:59:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8C46910ED40; Thu, 16 Feb 2023 10:59:38 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id C1FFA10ED38; Thu, 16 Feb 2023 10:59:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676545175; x=1708081175; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=zD70VZdjgnOic3K1qhG8DBPtshCjC6Dxxa8vF3F1mg4=; b=bh/1/GyxwTdvLRjXJoniti/8I7lqszqO2aexYcLW3bYF4VQDmdsag2Ul D8ROa8B5MjEBQPy9+hlXmKARan7SAyRdR7IuNgcyFBh57wk7GXdzbxU8y MUcTiFsoIob/0LcOGAhtwLQkV1RHYicGSsZtVchZm/STMitJQZd6pzhEp AK+mR8h1YwCxPpP/b4mDo3k4n/UipvtfcJoUM1k+XWPTZ8wdgBy/Qs1MZ F3o2IYWAApiqskG3F7eSgmsNVqiPOupEbwcOF7GtP7KMJMTuj6d5rcOll Iw6sehUIXxzhnaP+djyAHbAfuecYZA6ohsDi/6JW6HTCH3lGST+GTGhci w==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="311317610" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="311317610" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:35 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="812917919" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="812917919" Received: from murrayal-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.229.164]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:34 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Thu, 16 Feb 2023 10:59:18 +0000 Message-Id: <20230216105921.624960-7-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> References: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC 6/9] drm/syncobj: Mark syncobj waits as external waiters X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 Thu Feb 16 10:59: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: 13142959 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 B86DDC61DA4 for ; Thu, 16 Feb 2023 11:00:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6D2F910ED38; Thu, 16 Feb 2023 10:59:46 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id D805310ED3B; Thu, 16 Feb 2023 10:59: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=1676545176; x=1708081176; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=Q9YTKJ3u8YMMvKwr50O9Cd1SSM69KoIu6lzAW0teqGY=; b=QRNy8kzY0/WKisNzeQ+dlVwtYfVCaJXGfs6vhFKhqHIXnyjULX9opGZI mvUwspOhEa4O+5+YdHr+X4Tx3IPxc9Gda32J62+RUkici4bT0+RWgtDXz 2nEtKFZMqcckedoUmpseeP9l88QRTdkK/TfolMIKJ+50nTNxgDsXnpDzd aVH+KeRln3URBSXinot94uqNzfOaREcxba/V7/pzRJP9gNJ/U90fTWP3O dxK7epZ0HtS++5twudETrJyXKVH+vLsolKH0Wx27MWzpPpuOGQkgayfkg UX6cB1xkKrwYKNcBTva8KWUDnRlCCIdCI0aGd+7zQ7IKUoF3HLW+L5915 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="311317612" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="311317612" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:36 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="812917920" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="812917920" Received: from murrayal-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.229.164]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:35 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Thu, 16 Feb 2023 10:59:19 +0000 Message-Id: <20230216105921.624960-8-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> References: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC 7/9] drm/i915: Waitboost external waits X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 7503dcb9043b..8989f62a7fba 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -94,7 +94,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 Thu Feb 16 10:59: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: 13142957 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 278A9C636D6 for ; Thu, 16 Feb 2023 11:00:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EBC0810ED42; Thu, 16 Feb 2023 10:59:41 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id EEDFF10ED3B; Thu, 16 Feb 2023 10:59: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=1676545178; x=1708081178; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=fBvOEzsEUpuULwaHPJM994RuIgwkgHj0Lxh3VNlA7mU=; b=ei/zzFZAh5heFGAl5qo1K8UxFCG3YyO9kKGVsVFNhT4AD3oeS9kjQPX4 pAY7lPzOcrCLooHB/j9CPOOYsU4X12f+CtxiqYW5MBulxkFwqU36+OcL4 vjfocTPMrKpYH/TqT78aoPD1VJQT5jsTiLGPBBXtiPttSNH4rt9LAnH+I I1+DFRzuhGR7s9/xFtykY9m+mry/3BDwZgmrSoGDDr7acDFSncUWnxqZ7 oGlUzuwBjmzIT14lhl1CHVNqA3zLErm4qsneGC5c8MoJu4E2iNiqNqXpU shVJrSKgb6o36bek8mtMBuE6uYh2oyLwH9twNi7tl0p+QjxBIq2hufGXw g==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="311317617" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="311317617" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:37 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="812917923" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="812917923" Received: from murrayal-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.229.164]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:36 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Thu, 16 Feb 2023 10:59:20 +0000 Message-Id: <20230216105921.624960-9-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> References: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC 8/9] drm/i915: Mark waits as explicit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 8989f62a7fba..488b180f8821 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -2046,7 +2046,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 Thu Feb 16 10:59: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: 13142958 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 8CC75C636D6 for ; Thu, 16 Feb 2023 11:00:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EE4FE10ED43; Thu, 16 Feb 2023 10:59:42 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 14D0C10ED42; Thu, 16 Feb 2023 10:59: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=1676545179; x=1708081179; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=/CcC0aOeeAtqrOsPao/E+8cmDCKIM6s5J/aBXV6fZRc=; b=YOd5oEjHsZbpTwrSBFC34yseSXvmok4GErqCgzQySB8ubLtkB8ie/Kf5 De5QXzG1zWq60hnQ4a9oOAd3/MQKcyIENZFtPa27SCBTFTOcajczxZJje kh6qtQUXND9/KEAC48o2NDg5fqL/rcvf3knwbFlAlKCO67fwjvUdflyWY iBbVHhmMUAeBz5pFBtTlB0jmHW0UYI+8nHGzjuwAVddqLGcdmNVxAOvHX LeaFavkFZ/hPeNg5O828M468+ixDEKHvzDKX5cGmR7qzezCmV9idFA1fq KSSzj2CXEfLE6zrEPGQGXQu0uCU5Z2WUb1rBAW01EIsqkcJ+PYgWRx75S A==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="311317620" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="311317620" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:38 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="812917926" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="812917926" Received: from murrayal-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.229.164]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 02:59:37 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Thu, 16 Feb 2023 10:59:21 +0000 Message-Id: <20230216105921.624960-10-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> References: <20230216105921.624960-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC 9/9] drm/i915: Wait boost requests waited upon by others X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 488b180f8821..e24fac5c1567 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -2042,7 +2042,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;