So far vcn_v3_0_limit_sched() handles the harvested config and fails AV1 decoding job submissions when ring is not available, but under SR-IOV ring and it's scheduler can also be disabled in vcn_v3_0_hw_init() via the amdgpu_vcn_is_disabled_vcn() check.
In this case sched.ready is set to false, and vcn_v3_0_limit_sched() calls drm_sched_entity_modify_sched() with an un-ready scheduler, which makes drm_sched_entity_select_rq() null-ify entity->rq and the following job submission would trigger a null pointer dereference. Fix it by repeating the same amdgpu_vcn_is_disabled_vcn() check inside vcn_v3_0_limit_sched(). Signed-off-by: Tvrtko Ursulin <[email protected]> Fixes: 564e3dcf7962 ("drm/amd/amdgpu: Recovery vcn instance iterate.") Cc: Peng Ju Zhou <[email protected]> Cc: Monk Liu <[email protected]> Cc: Alex Deucher <[email protected]> Cc: Ruijing Dong <[email protected]> Cc: "Christian König" <[email protected]> Cc: Benjamin Cheng <[email protected]> Cc: Yinjie Yao <[email protected]> Cc: Philip Yang <[email protected]> Cc: <[email protected]> # v5.15+ --- I am not entirely sure whether this is the right Fixes: target, but it appears to have added sched->ready = false for the decode ring so I *think* it may just as well be first time NULL pointer deref became possible. Compile tested only. --- drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c index 2f7d5d562cb4..4f2cb70cb55e 100644 --- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c @@ -1902,6 +1902,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; + /* likewise if VCN0 decode is disabled (e.g. SR-IOV) */ + if (amdgpu_vcn_is_disabled_vcn(p->adev, VCN_DECODE_RING, 0)) + 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) { -- 2.56.0
