On 2020-03-03 7:50 a.m., Nirmoy Das wrote:
> Switch to appropriate sched list for an entity on priority override.
> 
> Signed-off-by: Nirmoy Das <nirmoy....@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 32 +++++++++++++++++++++----
>  1 file changed, 28 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> index 8c52152e3a6e..a0bf14ab9d33 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> @@ -522,6 +522,32 @@ struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx 
> *ctx,
>       return fence;
>  }
> 
> +static void amdgpu_ctx_set_entity_priority(struct amdgpu_ctx *ctx,
> +                                struct amdgpu_ctx_entity *aentity,
> +                                int hw_ip, enum drm_sched_priority priority)
> +{
> +     struct amdgpu_device *adev = ctx->adev;
> +     enum gfx_pipe_priority hw_prio;
> +     struct drm_gpu_scheduler **scheds = NULL;
> +     unsigned num_scheds;
> +
> +     /* set sw priority */
> +     drm_sched_entity_set_priority(&aentity->entity, priority);
> +
> +     /* set hw priority */
> +     switch (hw_ip) {
> +     case AMDGPU_HW_IP_COMPUTE:
> +             hw_prio = amdgpu_ctx_sched_prio_to_compute_prio(priority);
> +             scheds = adev->gfx.compute_prio_sched[hw_prio];
> +             num_scheds = adev->gfx.num_compute_sched[hw_prio];
> +             break;
> +     default:
> +             return;
> +     }
> +
> +     drm_sched_entity_modify_sched(&aentity->entity, scheds, num_scheds);
> +}

I'd rather this not be over-engineered (in expectations of more case labels,
and a simple if-else to do it. Over-engineering it "just in case" creates
difficult to maintain code. I believe there is a document about this somewhere
in Documentation/.

You don't need a break only to execute one statement, which you can pull
into the case: label. If you did this you'll see that you just want to do:

static void amdgpu_ctx_set_entity_priority(struct amdgpu_ctx *ctx,
                                           struct amdgpu_ctx_entity *aentity,
                                           int hw_ip, enum drm_sched_priority 
priority)
{

        ...

        /* Set software priority.
         */
        drm_sched_entity_set_priority(&aentity->entity, priority);

        /* Set hardware priority.
         */
        if (hw_ip == AMDGPU_HW_IP_COMPUTE) {
                hw_prio = s2p_prio_map(priority - 2);  ## or perhaps from a 
static inline from a header file, so we wouldn't care for the - 2 here
                scheds = adev->gfx.compute_prio_sched[hw_prio];
                num_scheds = adev->gfx.num_compute_sched[hw_prio];
                drm_sched_entity_modify_sched(&aentity->entity, scheds, 
num_scheds);
        }
}

Regards,
Luben

> +
>  void amdgpu_ctx_priority_override(struct amdgpu_ctx *ctx,
>                                 enum drm_sched_priority priority)
>  {
> @@ -534,13 +560,11 @@ void amdgpu_ctx_priority_override(struct amdgpu_ctx 
> *ctx,
>                       ctx->init_priority : ctx->override_priority;
>       for (i = 0; i < AMDGPU_HW_IP_NUM; ++i) {
>               for (j = 0; j < amdgpu_ctx_num_entities[i]; ++j) {
> -                     struct drm_sched_entity *entity;
> -
>                       if (!ctx->entities[i][j])
>                               continue;
> 
> -                     entity = &ctx->entities[i][j]->entity;
> -                     drm_sched_entity_set_priority(entity, ctx_prio);
> +                     amdgpu_ctx_set_entity_priority(ctx, ctx->entities[i][j],
> +                                                    i, ctx_prio);
>               }
>       }
>  }
> --
> 2.25.0
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cluben.tuikov%40amd.com%7Cf436ca206d94469f4ed908d7bf710856%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637188364522588061&amp;sdata=kPMrGVCt00XTJVIG5lDFugkv5CxZne8W1Hqqc2baZZg%3D&amp;reserved=0
> 

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to