Skip to content

Commit 3318f2d

Browse files
nowrepalexdeucher
authored andcommitted
drm/amdgpu/vcn: Allow limiting ctx to instance 0 for AV1 at any time
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
1 parent 2b10cb5 commit 3318f2d

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
@@ -1888,15 +1888,19 @@ static int vcn_v3_0_limit_sched(struct amdgpu_cs_parser *p,
18881888
struct amdgpu_job *job)
18891889
{
18901890
struct drm_gpu_scheduler **scheds;
1891-
1892-
/* The create msg must be in the first IB submitted */
1893-
if (atomic_read(&job->base.entity->fence_seq))
1894-
return -EINVAL;
1891+
struct dma_fence *fence;
18951892

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

1897+
/* wait for all jobs to finish before switching to instance 0 */
1898+
fence = amdgpu_ctx_get_fence(p->ctx, job->base.entity, ~0ull);
1899+
if (fence) {
1900+
dma_fence_wait(fence, false);
1901+
dma_fence_put(fence);
1902+
}
1903+
19001904
scheds = p->adev->gpu_sched[AMDGPU_HW_IP_VCN_DEC]
19011905
[AMDGPU_RING_PRIO_DEFAULT].sched;
19021906
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
@@ -1808,15 +1808,19 @@ static int vcn_v4_0_limit_sched(struct amdgpu_cs_parser *p,
18081808
struct amdgpu_job *job)
18091809
{
18101810
struct drm_gpu_scheduler **scheds;
1811-
1812-
/* The create msg must be in the first IB submitted */
1813-
if (atomic_read(&job->base.entity->fence_seq))
1814-
return -EINVAL;
1811+
struct dma_fence *fence;
18151812

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

1817+
/* wait for all jobs to finish before switching to instance 0 */
1818+
fence = amdgpu_ctx_get_fence(p->ctx, job->base.entity, ~0ull);
1819+
if (fence) {
1820+
dma_fence_wait(fence, false);
1821+
dma_fence_put(fence);
1822+
}
1823+
18201824
scheds = p->adev->gpu_sched[AMDGPU_HW_IP_VCN_ENC]
18211825
[AMDGPU_RING_PRIO_0].sched;
18221826
drm_sched_entity_modify_sched(job->base.entity, scheds, 1);

0 commit comments

Comments
 (0)