Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/sched: drm_sched_entity_init() breaks v3d_open() on V3D 3.3
--

commit c97e2213d0d6c3fa3066c68d77008ddc604e5ff1
Author: Tvrtko Ursulin <[email protected]>

drm/sched: Disallow initializing entities with un-initialized schedulers

This commit rejects uninitialized schedulers in drm_sched_entity_init() and
drm_sched_entity_modify_sched() by checking that every scheduler in
sched_list has a non-NULL sched_rq.

> diff --git a/drivers/gpu/drm/scheduler/sched_entity.c 
> b/drivers/gpu/drm/scheduler/sched_entity.c
> index 03e68b4102d50..69bcefdf2c55a 100644
> --- a/drivers/gpu/drm/scheduler/sched_entity.c
> +++ b/drivers/gpu/drm/scheduler/sched_entity.c
> @@ -90,6 +90,19 @@ ktime_t drm_sched_entity_stats_job_add_gpu_time(struct 
> drm_sched_job *job)
>       return duration;
>  }
>  
> +static bool drm_sched_list_is_initialized(struct drm_gpu_scheduler 
> **sched_list,
> +                                       unsigned int num_sched_list)
> +{
> +     unsigned int i;
> +
> +     for (i = 0; i < num_sched_list; i++) {
> +             if (!sched_list[i] || !sched_list[i]->sched_rq)
> +                     return false;
> +     }
> +
> +     return true;
> +}
> +
>  /**
>   * drm_sched_entity_init - Init a context entity used by scheduler when
>   * submit to HW ring.
> @@ -119,7 +132,10 @@ int drm_sched_entity_init(struct drm_sched_entity 
> *entity,
>                         unsigned int num_sched_list,
>                         atomic_t *guilty)
>  {
> -     if (!entity || !sched_list || !num_sched_list || !sched_list[0])
> +     if (!entity || !sched_list || !num_sched_list)
> +             return -EINVAL;
> +
> +     if (!drm_sched_list_is_initialized(sched_list, num_sched_list))
>               return -EINVAL;

[Severity: High]
Does returning -EINVAL here break v3d_open() on V3D 3.3?

On V3D 3.3 (brcm,7268-v3d), v3d_has_csd() is false, so v3d_sched_init() in
drivers/gpu/drm/v3d/v3d_sched.c skips initializing the V3D_CSD and
V3D_CACHE_CLEAN schedulers and leaves their sched_rq NULL.

v3d_open() in drivers/gpu/drm/v3d/v3d_drv.c still calls
drm_sched_entity_init() for all V3D_MAX_QUEUES, so every open() of the V3D
device node now fails with -EINVAL.

v3d_open() (and v3d_postclose(), which calls drm_sched_entity_destroy() for
all queues) would need to skip V3D_CSD and V3D_CACHE_CLEAN when
!v3d_has_csd(v3d) before enforcing this check.

-- 
Sashiko AI review · 
https://sashiko.dev/#/patchset/[email protected]?part=6

Reply via email to