[RFC PATCH 1/2] drm/sched: implement drm_sched_entity_num_jobs

Andrey Grodzovsky Andrey.Grodzovsky at amd.com
Wed Mar 11 17:23:51 UTC 2020


On 3/11/20 1:18 PM, Nirmoy Das wrote:
> Implement drm_sched_entity_num_jobs() so that drm drivers can
> query number of jobs in an entity.
>
> Signed-off-by: Nirmoy Das <nirmoy.das at amd.com>
> ---
>   drivers/gpu/drm/scheduler/sched_entity.c | 15 +++++++++++++++
>   include/drm/gpu_scheduler.h              |  1 +
>   2 files changed, 16 insertions(+)
>
> diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
> index 90fd9c30ae5a..dfe8216f2d52 100644
> --- a/drivers/gpu/drm/scheduler/sched_entity.c
> +++ b/drivers/gpu/drm/scheduler/sched_entity.c
> @@ -119,6 +119,21 @@ static bool drm_sched_entity_is_idle(struct drm_sched_entity *entity)
>   	return false;
>   }
>   
> +/**
> + * drm_sched_entity_num_job - Get number of jobs in the entity
> + *
> + * @entity: scheduler entity
> + *
> + * Returns number of jobs in the entity
> + */
> +int drm_sched_entity_num_jobs(struct drm_sched_entity *entity)
> +{
> +	if (drm_sched_entity_is_idle(entity))
> +		return 0;
> +
> +	return spsc_queue_count(&entity->job_queue);
> +}


What about the jobs which already have been dequeued from job_queue and 
are in progress in the HW ring but yet to complete - don't they count ?

Andrey



> +EXPORT_SYMBOL(drm_sched_entity_num_jobs);
>   /**
>    * drm_sched_entity_is_ready - Check if entity is ready
>    *
> diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h
> index d8972836d248..b5ceff75cbbe 100644
> --- a/include/drm/gpu_scheduler.h
> +++ b/include/drm/gpu_scheduler.h
> @@ -341,5 +341,6 @@ void drm_sched_fence_finished(struct drm_sched_fence *fence);
>   unsigned long drm_sched_suspend_timeout(struct drm_gpu_scheduler *sched);
>   void drm_sched_resume_timeout(struct drm_gpu_scheduler *sched,
>   		                unsigned long remaining);
> +int drm_sched_entity_num_jobs(struct drm_sched_entity *entity);
>   
>   #endif


More information about the amd-gfx mailing list