Message ID | 20250113103341.43914-1-tvrtko.ursulin@igalia.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [1/2] drm/sched: Add helper to check job dependencies | expand |
On 13.01.2025 11:33, Tvrtko Ursulin wrote: > Lets isolate scheduler internals from drivers such as pvr which currently > walks the dependency array to look for fences. > > Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> > Cc: Christian König <christian.koenig@amd.com> > Cc: Danilo Krummrich <dakr@redhat.com> > Cc: Matthew Brost <matthew.brost@intel.com> > Cc: Philipp Stanner <pstanner@redhat.com> > Reviewed-by: Matt Coster <matt.coster@imgtec.com> Acked-by: Danilo Krummrich <dakr@kernel.org> > --- > drivers/gpu/drm/scheduler/sched_main.c | 23 +++++++++++++++++++++++ > include/drm/gpu_scheduler.h | 3 ++- > 2 files changed, 25 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c > index 57da84908752..e6f1f2a8e033 100644 > --- a/drivers/gpu/drm/scheduler/sched_main.c > +++ b/drivers/gpu/drm/scheduler/sched_main.c > @@ -997,6 +997,29 @@ int drm_sched_job_add_implicit_dependencies(struct drm_sched_job *job, > } > EXPORT_SYMBOL(drm_sched_job_add_implicit_dependencies); > > +/** > + * drm_sched_job_has_dependency - check whether fence is the job's dependency > + * @job: scheduler job to check > + * @fence: fence to look for > + * > + * Returns: > + * True if @fence is found within the job's dependencies, or otherwise false. > + */ > +bool drm_sched_job_has_dependency(struct drm_sched_job *job, > + struct dma_fence *fence) > +{ > + struct dma_fence *f; > + unsigned long index; > + > + xa_for_each(&job->dependencies, index, f) { > + if (f == fence) > + return true; > + } > + > + return false; > +} > +EXPORT_SYMBOL(drm_sched_job_has_dependency); > + > /** > * drm_sched_job_cleanup - clean up scheduler job resources > * @job: scheduler job to clean up > diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h > index 95e17504e46a..d118a0a57ab1 100644 > --- a/include/drm/gpu_scheduler.h > +++ b/include/drm/gpu_scheduler.h > @@ -577,7 +577,8 @@ int drm_sched_job_add_resv_dependencies(struct drm_sched_job *job, > int drm_sched_job_add_implicit_dependencies(struct drm_sched_job *job, > struct drm_gem_object *obj, > bool write); > - > +bool drm_sched_job_has_dependency(struct drm_sched_job *job, > + struct dma_fence *fence); > > void drm_sched_entity_modify_sched(struct drm_sched_entity *entity, > struct drm_gpu_scheduler **sched_list,
Hi, On 13/01/2025 13:12, Danilo Krummrich wrote: > On 13.01.2025 11:33, Tvrtko Ursulin wrote: >> Lets isolate scheduler internals from drivers such as pvr which currently >> walks the dependency array to look for fences. >> >> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> >> Cc: Christian König <christian.koenig@amd.com> >> Cc: Danilo Krummrich <dakr@redhat.com> >> Cc: Matthew Brost <matthew.brost@intel.com> >> Cc: Philipp Stanner <pstanner@redhat.com> >> Reviewed-by: Matt Coster <matt.coster@imgtec.com> > > Acked-by: Danilo Krummrich <dakr@kernel.org> Thanks! Would you also be happy to merge the two? Regards, Tvrtko >> --- >> drivers/gpu/drm/scheduler/sched_main.c | 23 +++++++++++++++++++++++ >> include/drm/gpu_scheduler.h | 3 ++- >> 2 files changed, 25 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c >> index 57da84908752..e6f1f2a8e033 100644 >> --- a/drivers/gpu/drm/scheduler/sched_main.c >> +++ b/drivers/gpu/drm/scheduler/sched_main.c >> @@ -997,6 +997,29 @@ int drm_sched_job_add_implicit_dependencies(struct drm_sched_job *job, >> } >> EXPORT_SYMBOL(drm_sched_job_add_implicit_dependencies); >> >> +/** >> + * drm_sched_job_has_dependency - check whether fence is the job's dependency >> + * @job: scheduler job to check >> + * @fence: fence to look for >> + * >> + * Returns: >> + * True if @fence is found within the job's dependencies, or otherwise false. >> + */ >> +bool drm_sched_job_has_dependency(struct drm_sched_job *job, >> + struct dma_fence *fence) >> +{ >> + struct dma_fence *f; >> + unsigned long index; >> + >> + xa_for_each(&job->dependencies, index, f) { >> + if (f == fence) >> + return true; >> + } >> + >> + return false; >> +} >> +EXPORT_SYMBOL(drm_sched_job_has_dependency); >> + >> /** >> * drm_sched_job_cleanup - clean up scheduler job resources >> * @job: scheduler job to clean up >> diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h >> index 95e17504e46a..d118a0a57ab1 100644 >> --- a/include/drm/gpu_scheduler.h >> +++ b/include/drm/gpu_scheduler.h >> @@ -577,7 +577,8 @@ int drm_sched_job_add_resv_dependencies(struct drm_sched_job *job, >> int drm_sched_job_add_implicit_dependencies(struct drm_sched_job *job, >> struct drm_gem_object *obj, >> bool write); >> - >> +bool drm_sched_job_has_dependency(struct drm_sched_job *job, >> + struct dma_fence *fence); >> >> void drm_sched_entity_modify_sched(struct drm_sched_entity *entity, >> struct drm_gpu_scheduler **sched_list, >
diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 57da84908752..e6f1f2a8e033 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -997,6 +997,29 @@ int drm_sched_job_add_implicit_dependencies(struct drm_sched_job *job, } EXPORT_SYMBOL(drm_sched_job_add_implicit_dependencies); +/** + * drm_sched_job_has_dependency - check whether fence is the job's dependency + * @job: scheduler job to check + * @fence: fence to look for + * + * Returns: + * True if @fence is found within the job's dependencies, or otherwise false. + */ +bool drm_sched_job_has_dependency(struct drm_sched_job *job, + struct dma_fence *fence) +{ + struct dma_fence *f; + unsigned long index; + + xa_for_each(&job->dependencies, index, f) { + if (f == fence) + return true; + } + + return false; +} +EXPORT_SYMBOL(drm_sched_job_has_dependency); + /** * drm_sched_job_cleanup - clean up scheduler job resources * @job: scheduler job to clean up diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h index 95e17504e46a..d118a0a57ab1 100644 --- a/include/drm/gpu_scheduler.h +++ b/include/drm/gpu_scheduler.h @@ -577,7 +577,8 @@ int drm_sched_job_add_resv_dependencies(struct drm_sched_job *job, int drm_sched_job_add_implicit_dependencies(struct drm_sched_job *job, struct drm_gem_object *obj, bool write); - +bool drm_sched_job_has_dependency(struct drm_sched_job *job, + struct dma_fence *fence); void drm_sched_entity_modify_sched(struct drm_sched_entity *entity, struct drm_gpu_scheduler **sched_list,