Skip to content

Commit 9adb902

Browse files
nowrepgregkh
authored andcommitted
drm/amdgpu/vcn: Allow limiting ctx to instance 0 for AV1 at any time
commit 3318f2d upstream. There is no reason to require this to happen on first submitted IB only. We need to wait for the queue to be idle, but it can be done at any time (including when there are multiple video sessions active). Signed-off-by: David Rosca <david.rosca@amd.com> Reviewed-by: Leo Liu <leo.liu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 8908fdc) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b2fbe0f commit 9adb902

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,15 +1765,19 @@ static int vcn_v3_0_limit_sched(struct amdgpu_cs_parser *p,
17651765
struct amdgpu_job *job)
17661766
{
17671767
struct drm_gpu_scheduler **scheds;
1768-
1769-
/* The create msg must be in the first IB submitted */
1770-
if (atomic_read(&job->base.entity->fence_seq))
1771-
return -EINVAL;
1768+
struct dma_fence *fence;
17721769

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

1774+
/* wait for all jobs to finish before switching to instance 0 */
1775+
fence = amdgpu_ctx_get_fence(p->ctx, job->base.entity, ~0ull);
1776+
if (fence) {
1777+
dma_fence_wait(fence, false);
1778+
dma_fence_put(fence);
1779+
}
1780+
17771781
scheds = p->adev->gpu_sched[AMDGPU_HW_IP_VCN_DEC]
17781782
[AMDGPU_RING_PRIO_DEFAULT].sched;
17791783
drm_sched_entity_modify_sched(job->base.entity, scheds, 1);

drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,15 +1644,19 @@ static int vcn_v4_0_limit_sched(struct amdgpu_cs_parser *p,
16441644
struct amdgpu_job *job)
16451645
{
16461646
struct drm_gpu_scheduler **scheds;
1647-
1648-
/* The create msg must be in the first IB submitted */
1649-
if (atomic_read(&job->base.entity->fence_seq))
1650-
return -EINVAL;
1647+
struct dma_fence *fence;
16511648

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

1653+
/* wait for all jobs to finish before switching to instance 0 */
1654+
fence = amdgpu_ctx_get_fence(p->ctx, job->base.entity, ~0ull);
1655+
if (fence) {
1656+
dma_fence_wait(fence, false);
1657+
dma_fence_put(fence);
1658+
}
1659+
16561660
scheds = p->adev->gpu_sched[AMDGPU_HW_IP_VCN_ENC]
16571661
[AMDGPU_RING_PRIO_0].sched;
16581662
drm_sched_entity_modify_sched(job->base.entity, scheds, 1);

0 commit comments

Comments
 (0)