drm/sched: drop the unused entity argument from drm_sched_fence_alloc()
Subsystems (3)
PATCH 1/1 drm/sched: drop the unused entity argument from drm_sched_fence_alloc()
drm_sched_fence_alloc() takes a struct drm_sched_entity *entity but never uses it. Its only use, fence->sched = entity->rq->sched, moved into drm_sched_fence_init() by commit dbe48d030b28 ("drm/sched: Split drm_sched_job_init"), which separated fence allocation in drm_sched_job_init() from arming in drm_sched_job_arm(). The deref belongs at arm: drm_sched_job_arm() selects the run-queue via drm_sched_entity_select_rq(), so for an entity with more than one scheduler, entity->rq need not yet point at the scheduler the job lands on. Reading it at allocation time could bind the fence to the wrong scheduler.
Drop the argument. The sole caller still passes the entity to drm_sched_fence_init() at arm time, so behavior is unchanged. This also removes the parameter-name mismatch between the declaration (s_entity) and the definition (entity).
---
Targets drm-misc-next. No functional change; compile-tested with W=1.
--- drivers/gpu/drm/scheduler/sched_fence.c | 3 +-- drivers/gpu/drm/scheduler/sched_internal.h | 3 +-- drivers/gpu/drm/scheduler/sched_main.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/scheduler/sched_fence.c +1 -2
@@ -205,8 +205,7 @@ struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f) }EXPORT_SYMBOL (to_drm_sched_fence); -struct drm_sched_fence *drm_sched_fence_alloc (struct drm_sched_entity *entity, -void *owner, +struct drm_sched_fence *drm_sched_fence_alloc (void *owner,u64 drm_client_id) {struct drm_sched_fence *fence =NULL ;
drivers/gpu/drm/scheduler/sched_internal.h +1 -2
@@ -58,8 +58,7 @@ drm_sched_rq_select_entity(struct drm_gpu_scheduler *sched,void drm_sched_entity_select_rq (struct drm_sched_entity *entity);struct drm_sched_job *drm_sched_entity_pop_job (struct drm_sched_entity *entity); -struct drm_sched_fence *drm_sched_fence_alloc (struct drm_sched_entity *s_entity, -void *owner,u64 drm_client_id); +struct drm_sched_fence *drm_sched_fence_alloc (void *owner,u64 drm_client_id);void drm_sched_fence_init (struct drm_sched_fence *fence,struct drm_sched_entity *entity);void drm_sched_fence_free (struct drm_sched_fence *fence);
drivers/gpu/drm/scheduler/sched_main.c +1 -1
@@ -612,7 +612,7 @@ int drm_sched_job_init(struct drm_sched_job *job, job->entity = entity; job->credits = credits; - job->s_fence =drm_sched_fence_alloc (entity, owner, drm_client_id); + job->s_fence =drm_sched_fence_alloc (owner, drm_client_id);if (!job->s_fence)return -ENOMEM ;
Signature · 1 line
2.53.0
Quoted 10 lines · Donggeun Yoo
drm_sched_fence_alloc()takes a structdrm_sched_entity*entity but never uses it. Its only use,fence->sched=entity->rq->sched, moved intodrm_sched_fence_init()by commitdbe48d030b28("drm/sched: Splitdrm_sched_job_init"), which separated fence allocation indrm_sched_job_init()from arming indrm_sched_job_arm(). The deref belongs at arm:drm_sched_job_arm()selects the run-queue viadrm_sched_entity_select_rq(), so for an entity with more than one scheduler,entity->rqneed not yet point at the scheduler the job lands on. Reading it at allocation time could bind the fence to the wrong scheduler.
I think that paragraph is a bit overkill ;)
Especially the last sentence reads a bit like you're addressing a bug, but it's just about removing an unused parameter.
I think saying "In commit dbe48d030b28 ("… … it was forgotten to remove a now unused function argument" is enough. Who's interested in details can then look at the commit.
Quoted 5 lines
Drop the argument. The sole caller still passes the entity to
drm_sched_fence_init()at arm time, so behavior is unchanged. This also removes the parameter-name mismatch between the declaration (s_entity) and the definition (entity).
This paragraph is good.
P.