* [PATCH] drm/scheduler: Unwrap job dependencies
@ 2023-12-05 19:02 Rob Clark
2023-12-10 2:00 ` Luben Tuikov
2023-12-11 10:47 ` [Linaro-mm-sig] " Christian König
0 siblings, 2 replies; 3+ messages in thread
From: Rob Clark @ 2023-12-05 19:02 UTC (permalink / raw)
To: dri-devel
Cc: Rob Clark, Luben Tuikov, linux-arm-msm, open list, Maxime Ripard,
Sumit Semwal,
moderated list:DMA BUFFER SHARING FRAMEWORK:Keyword:bdma_?:buf|fence|resvb,
Thomas Zimmermann, freedreno, Christian König,
open list:DMA BUFFER SHARING FRAMEWORK:Keyword:bdma_?:buf|fence|resvb
From: Rob Clark <robdclark@chromium.org>
Container fences have burner contexts, which makes the trick to store at
most one fence per context somewhat useless if we don't unwrap array or
chain fences.
Signed-off-by: Rob Clark <robdclark@chromium.org>
---
drivers/gpu/drm/scheduler/sched_main.c | 47 ++++++++++++++++++--------
1 file changed, 32 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index 9762464e3f99..16b550949c57 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -52,6 +52,7 @@
#include <linux/wait.h>
#include <linux/sched.h>
#include <linux/completion.h>
+#include <linux/dma-fence-unwrap.h>
#include <linux/dma-resv.h>
#include <uapi/linux/sched/types.h>
@@ -684,27 +685,14 @@ void drm_sched_job_arm(struct drm_sched_job *job)
}
EXPORT_SYMBOL(drm_sched_job_arm);
-/**
- * drm_sched_job_add_dependency - adds the fence as a job dependency
- * @job: scheduler job to add the dependencies to
- * @fence: the dma_fence to add to the list of dependencies.
- *
- * Note that @fence is consumed in both the success and error cases.
- *
- * Returns:
- * 0 on success, or an error on failing to expand the array.
- */
-int drm_sched_job_add_dependency(struct drm_sched_job *job,
- struct dma_fence *fence)
+static int drm_sched_job_add_single_dependency(struct drm_sched_job *job,
+ struct dma_fence *fence)
{
struct dma_fence *entry;
unsigned long index;
u32 id = 0;
int ret;
- if (!fence)
- return 0;
-
/* Deduplicate if we already depend on a fence from the same context.
* This lets the size of the array of deps scale with the number of
* engines involved, rather than the number of BOs.
@@ -728,6 +716,35 @@ int drm_sched_job_add_dependency(struct drm_sched_job *job,
return ret;
}
+
+/**
+ * drm_sched_job_add_dependency - adds the fence as a job dependency
+ * @job: scheduler job to add the dependencies to
+ * @fence: the dma_fence to add to the list of dependencies.
+ *
+ * Note that @fence is consumed in both the success and error cases.
+ *
+ * Returns:
+ * 0 on success, or an error on failing to expand the array.
+ */
+int drm_sched_job_add_dependency(struct drm_sched_job *job,
+ struct dma_fence *fence)
+{
+ struct dma_fence_unwrap iter;
+ struct dma_fence *f;
+ int ret = 0;
+
+ dma_fence_unwrap_for_each (f, &iter, fence) {
+ dma_fence_get(f);
+ ret = drm_sched_job_add_single_dependency(job, f);
+ if (ret)
+ break;
+ }
+
+ dma_fence_put(fence);
+
+ return ret;
+}
EXPORT_SYMBOL(drm_sched_job_add_dependency);
/**
--
2.42.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] drm/scheduler: Unwrap job dependencies
2023-12-05 19:02 [PATCH] drm/scheduler: Unwrap job dependencies Rob Clark
@ 2023-12-10 2:00 ` Luben Tuikov
2023-12-11 10:47 ` [Linaro-mm-sig] " Christian König
1 sibling, 0 replies; 3+ messages in thread
From: Luben Tuikov @ 2023-12-10 2:00 UTC (permalink / raw)
To: Rob Clark, Christian König
Cc: Rob Clark, linux-arm-msm, open list, Maxime Ripard,
moderated list:DMA BUFFER SHARING FRAMEWORK:Keyword:bdma_(?:buf|fence|resv)b,
dri-devel, Thomas Zimmermann, freedreno, Sumit Semwal,
open list:DMA BUFFER SHARING FRAMEWORK:Keyword:bdma_(?:buf|fence|resv)b
[-- Attachment #1.1.1: Type: text/plain, Size: 3212 bytes --]
Hi,
On 2023-12-05 14:02, Rob Clark wrote:
> From: Rob Clark <robdclark@chromium.org>
>
> Container fences have burner contexts, which makes the trick to store at
> most one fence per context somewhat useless if we don't unwrap array or
> chain fences.
>
> Signed-off-by: Rob Clark <robdclark@chromium.org>
Link: https://lore.kernel.org/all/20230322224403.35742-1-robdclark@gmail.com/
Let's include a link to the original thread, as the main discussion can be found
therein.
Christian, could you review this patch please?
Thanks!
--
Regards,
Luben
> ---
> drivers/gpu/drm/scheduler/sched_main.c | 47 ++++++++++++++++++--------
> 1 file changed, 32 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index 9762464e3f99..16b550949c57 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -52,6 +52,7 @@
> #include <linux/wait.h>
> #include <linux/sched.h>
> #include <linux/completion.h>
> +#include <linux/dma-fence-unwrap.h>
> #include <linux/dma-resv.h>
> #include <uapi/linux/sched/types.h>
>
> @@ -684,27 +685,14 @@ void drm_sched_job_arm(struct drm_sched_job *job)
> }
> EXPORT_SYMBOL(drm_sched_job_arm);
>
> -/**
> - * drm_sched_job_add_dependency - adds the fence as a job dependency
> - * @job: scheduler job to add the dependencies to
> - * @fence: the dma_fence to add to the list of dependencies.
> - *
> - * Note that @fence is consumed in both the success and error cases.
> - *
> - * Returns:
> - * 0 on success, or an error on failing to expand the array.
> - */
> -int drm_sched_job_add_dependency(struct drm_sched_job *job,
> - struct dma_fence *fence)
> +static int drm_sched_job_add_single_dependency(struct drm_sched_job *job,
> + struct dma_fence *fence)
> {
> struct dma_fence *entry;
> unsigned long index;
> u32 id = 0;
> int ret;
>
> - if (!fence)
> - return 0;
> -
> /* Deduplicate if we already depend on a fence from the same context.
> * This lets the size of the array of deps scale with the number of
> * engines involved, rather than the number of BOs.
> @@ -728,6 +716,35 @@ int drm_sched_job_add_dependency(struct drm_sched_job *job,
>
> return ret;
> }
> +
> +/**
> + * drm_sched_job_add_dependency - adds the fence as a job dependency
> + * @job: scheduler job to add the dependencies to
> + * @fence: the dma_fence to add to the list of dependencies.
> + *
> + * Note that @fence is consumed in both the success and error cases.
> + *
> + * Returns:
> + * 0 on success, or an error on failing to expand the array.
> + */
> +int drm_sched_job_add_dependency(struct drm_sched_job *job,
> + struct dma_fence *fence)
> +{
> + struct dma_fence_unwrap iter;
> + struct dma_fence *f;
> + int ret = 0;
> +
> + dma_fence_unwrap_for_each (f, &iter, fence) {
> + dma_fence_get(f);
> + ret = drm_sched_job_add_single_dependency(job, f);
> + if (ret)
> + break;
> + }
> +
> + dma_fence_put(fence);
> +
> + return ret;
> +}
> EXPORT_SYMBOL(drm_sched_job_add_dependency);
>
> /**
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 677 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [Linaro-mm-sig] [PATCH] drm/scheduler: Unwrap job dependencies
2023-12-05 19:02 [PATCH] drm/scheduler: Unwrap job dependencies Rob Clark
2023-12-10 2:00 ` Luben Tuikov
@ 2023-12-11 10:47 ` Christian König
1 sibling, 0 replies; 3+ messages in thread
From: Christian König @ 2023-12-11 10:47 UTC (permalink / raw)
To: Rob Clark, dri-devel
Cc: Rob Clark, Luben Tuikov, linux-arm-msm, open list, Maxime Ripard,
Sumit Semwal,
moderated list:DMA BUFFER SHARING FRAMEWORK:Keyword:bdma_?:buf|fence|resvb,
Thomas Zimmermann, freedreno, Christian König,
open list:DMA BUFFER SHARING FRAMEWORK:Keyword:bdma_?:buf|fence|resvb
Am 05.12.23 um 20:02 schrieb Rob Clark:
> From: Rob Clark <robdclark@chromium.org>
>
> Container fences have burner contexts, which makes the trick to store at
> most one fence per context somewhat useless if we don't unwrap array or
> chain fences.
>
> Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/scheduler/sched_main.c | 47 ++++++++++++++++++--------
> 1 file changed, 32 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index 9762464e3f99..16b550949c57 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -52,6 +52,7 @@
> #include <linux/wait.h>
> #include <linux/sched.h>
> #include <linux/completion.h>
> +#include <linux/dma-fence-unwrap.h>
> #include <linux/dma-resv.h>
> #include <uapi/linux/sched/types.h>
>
> @@ -684,27 +685,14 @@ void drm_sched_job_arm(struct drm_sched_job *job)
> }
> EXPORT_SYMBOL(drm_sched_job_arm);
>
> -/**
> - * drm_sched_job_add_dependency - adds the fence as a job dependency
> - * @job: scheduler job to add the dependencies to
> - * @fence: the dma_fence to add to the list of dependencies.
> - *
> - * Note that @fence is consumed in both the success and error cases.
> - *
> - * Returns:
> - * 0 on success, or an error on failing to expand the array.
> - */
> -int drm_sched_job_add_dependency(struct drm_sched_job *job,
> - struct dma_fence *fence)
> +static int drm_sched_job_add_single_dependency(struct drm_sched_job *job,
> + struct dma_fence *fence)
> {
> struct dma_fence *entry;
> unsigned long index;
> u32 id = 0;
> int ret;
>
> - if (!fence)
> - return 0;
> -
> /* Deduplicate if we already depend on a fence from the same context.
> * This lets the size of the array of deps scale with the number of
> * engines involved, rather than the number of BOs.
> @@ -728,6 +716,35 @@ int drm_sched_job_add_dependency(struct drm_sched_job *job,
>
> return ret;
> }
> +
> +/**
> + * drm_sched_job_add_dependency - adds the fence as a job dependency
> + * @job: scheduler job to add the dependencies to
> + * @fence: the dma_fence to add to the list of dependencies.
> + *
> + * Note that @fence is consumed in both the success and error cases.
> + *
> + * Returns:
> + * 0 on success, or an error on failing to expand the array.
> + */
> +int drm_sched_job_add_dependency(struct drm_sched_job *job,
> + struct dma_fence *fence)
> +{
> + struct dma_fence_unwrap iter;
> + struct dma_fence *f;
> + int ret = 0;
> +
> + dma_fence_unwrap_for_each (f, &iter, fence) {
> + dma_fence_get(f);
> + ret = drm_sched_job_add_single_dependency(job, f);
> + if (ret)
> + break;
> + }
> +
> + dma_fence_put(fence);
> +
> + return ret;
> +}
> EXPORT_SYMBOL(drm_sched_job_add_dependency);
>
> /**
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-11 10:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-05 19:02 [PATCH] drm/scheduler: Unwrap job dependencies Rob Clark
2023-12-10 2:00 ` Luben Tuikov
2023-12-11 10:47 ` [Linaro-mm-sig] " Christian König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).