+ Christian

Please see below:

On 17/11/2026 10:46, [email protected] wrote:

@@ -192,7 +192,15 @@ void drm_sched_entity_modify_sched(struct drm_sched_entity 
*entity,
                                    struct drm_gpu_scheduler **sched_list,
                                    unsigned int num_sched_list)
  {
-       WARN_ON(!num_sched_list || !sched_list);
+       unsigned int i;
+
+       if (WARN_ON(!num_sched_list || !sched_list))
+               return;
+
+       for (i = 0; i < num_sched_list; i++) {
+               if (WARN_ON(!sched_list[i] || !sched_list[i]->sched_rq))
+                       return;
+       }

[Severity: Medium]
Can vcn_v3_0_limit_sched() hit this WARN_ON() when VCN0 decode is disabled
by the hypervisor under SR-IOV?

During vcn_v3_0_sw_init(), amdgpu_ring_init() places &inst[0].ring_dec.sched
into adev->gpu_sched[AMDGPU_HW_IP_VCN_DEC][AMDGPU_RING_PRIO_DEFAULT].sched[0].
Later, vcn_v3_0_hw_init() sets ring->no_scheduler = true when the hypervisor
has disabled VCN0 decode, which causes amdgpu_device_init_schedulers() to
skip drm_sched_init() and leave sched[0]->sched_rq NULL:

drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c:vcn_v3_0_hw_init() {
     ...
                        if (amdgpu_vcn_is_disabled_vcn(adev, VCN_DECODE_RING, 
i)) {
                                ring->sched.ready = false;
                                ring->no_scheduler = true;
                                dev_info(adev->dev, "ring %s is disabled by 
hypervisor\n", ring->name);
                        }
     ...
}

Because vcn_v3_0_early_init() sets adev->vcn.harvest_config = 0 on SR-IOV,
an AV1 decode submission on VCN1 reaches vcn_v3_0_limit_sched(), passes the
AMDGPU_VCN_HARVEST_VCN0 check, and passes that uninitialized sched[0] to
drm_sched_entity_modify_sched():

drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c:vcn_v3_0_limit_sched() {
        struct drm_gpu_scheduler **scheds;

        /* The create msg must be in the first IB submitted */
        if (atomic_read(&job->base.entity->fence_seq))
                return -EINVAL;

        /* if VCN0 is harvested, we can't support AV1 */
        if (p->adev->vcn.harvest_config & AMDGPU_VCN_HARVEST_VCN0)
                return -EINVAL;

        scheds = p->adev->gpu_sched[AMDGPU_HW_IP_VCN_DEC]
                [AMDGPU_RING_PRIO_DEFAULT].sched;
        drm_sched_entity_modify_sched(job->base.entity, scheds, 1);
        return 0;
}

An unprivileged guest user submitting an AV1 decode job can trigger the
WARN_ON(), and the early return leaves the unsupported AV1 job scheduled on
VCN1.

If this is true then without this patch on SR-IOV, calling drm_sched_entity_modify_sched() with an un-initialized scheduler leaves entity->rq as NULL which surely explodes badly. At least I cannot see that it is gracefully handled anywhere.

In any case perhaps we should add this to vcn 3 and 4:

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
index 2f7d5d562cb4..adcb94041274 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
@@ -1895,6 +1895,7 @@ static const struct amdgpu_ring_funcs vcn_v3_0_dec_sw_ring_vm_funcs = {
 static int vcn_v3_0_limit_sched(struct amdgpu_cs_parser *p,
                                struct amdgpu_job *job)
 {
+       struct amdgpu_ring *ring = amdgpu_job_ring(job);
        struct drm_gpu_scheduler **scheds;
        struct dma_fence *fence;

@@ -1902,6 +1903,10 @@ static int vcn_v3_0_limit_sched(struct amdgpu_cs_parser *p,
        if (p->adev->vcn.harvest_config & AMDGPU_VCN_HARVEST_VCN0)
                return -EINVAL;

+       /* If VCN0 is disabled we also cannot support AV1. */
+       if (ring->no_scheduler)
+               return -EINVAL;
+
        /* wait for all jobs to finish before switching to instance 0 */
        fence = amdgpu_ctx_get_fence(p->ctx, job->base.entity, ~0ull);
        if (fence) {

This way submission fails explicitly and -EINVAL trickles out all the way to cs ioctl. Thoughts?

Regards,

Tvrtko

Reply via email to