@@ -54,6 +54,7 @@ static int vcn_v1_0_pause_dpg_mode(struct amdgpu_device *adev,
5454 int inst_idx , struct dpg_pause_state * new_state );
5555
5656static void vcn_v1_0_idle_work_handler (struct work_struct * work );
57+ static void vcn_v1_0_ring_begin_use (struct amdgpu_ring * ring );
5758
5859/**
5960 * vcn_v1_0_early_init - set function pointers
@@ -1804,11 +1805,24 @@ static void vcn_v1_0_idle_work_handler(struct work_struct *work)
18041805 }
18051806}
18061807
1807- void vcn_v1_0_ring_begin_use (struct amdgpu_ring * ring )
1808+ static void vcn_v1_0_ring_begin_use (struct amdgpu_ring * ring )
18081809{
1809- struct amdgpu_device * adev = ring -> adev ;
1810+ struct amdgpu_device * adev = ring -> adev ;
18101811 bool set_clocks = !cancel_delayed_work_sync (& adev -> vcn .idle_work );
18111812
1813+ mutex_lock (& adev -> vcn .vcn1_jpeg1_workaround );
1814+
1815+ if (amdgpu_fence_wait_empty (& ring -> adev -> jpeg .inst -> ring_dec ))
1816+ DRM_ERROR ("VCN dec: jpeg dec ring may not be empty\n" );
1817+
1818+ vcn_v1_0_set_pg_for_begin_use (ring , set_clocks );
1819+
1820+ }
1821+
1822+ void vcn_v1_0_set_pg_for_begin_use (struct amdgpu_ring * ring , bool set_clocks )
1823+ {
1824+ struct amdgpu_device * adev = ring -> adev ;
1825+
18121826 if (set_clocks ) {
18131827 amdgpu_gfx_off_ctrl (adev , false);
18141828 if (adev -> pm .dpm_enabled )
@@ -1844,6 +1858,12 @@ void vcn_v1_0_ring_begin_use(struct amdgpu_ring *ring)
18441858 }
18451859}
18461860
1861+ void vcn_v1_0_ring_end_use (struct amdgpu_ring * ring )
1862+ {
1863+ schedule_delayed_work (& ring -> adev -> vcn .idle_work , VCN_IDLE_TIMEOUT );
1864+ mutex_unlock (& ring -> adev -> vcn .vcn1_jpeg1_workaround );
1865+ }
1866+
18471867static const struct amd_ip_funcs vcn_v1_0_ip_funcs = {
18481868 .name = "vcn_v1_0" ,
18491869 .early_init = vcn_v1_0_early_init ,
@@ -1891,7 +1911,7 @@ static const struct amdgpu_ring_funcs vcn_v1_0_dec_ring_vm_funcs = {
18911911 .insert_end = vcn_v1_0_dec_ring_insert_end ,
18921912 .pad_ib = amdgpu_ring_generic_pad_ib ,
18931913 .begin_use = vcn_v1_0_ring_begin_use ,
1894- .end_use = amdgpu_vcn_ring_end_use ,
1914+ .end_use = vcn_v1_0_ring_end_use ,
18951915 .emit_wreg = vcn_v1_0_dec_ring_emit_wreg ,
18961916 .emit_reg_wait = vcn_v1_0_dec_ring_emit_reg_wait ,
18971917 .emit_reg_write_reg_wait = amdgpu_ring_emit_reg_write_reg_wait_helper ,
@@ -1923,7 +1943,7 @@ static const struct amdgpu_ring_funcs vcn_v1_0_enc_ring_vm_funcs = {
19231943 .insert_end = vcn_v1_0_enc_ring_insert_end ,
19241944 .pad_ib = amdgpu_ring_generic_pad_ib ,
19251945 .begin_use = vcn_v1_0_ring_begin_use ,
1926- .end_use = amdgpu_vcn_ring_end_use ,
1946+ .end_use = vcn_v1_0_ring_end_use ,
19271947 .emit_wreg = vcn_v1_0_enc_ring_emit_wreg ,
19281948 .emit_reg_wait = vcn_v1_0_enc_ring_emit_reg_wait ,
19291949 .emit_reg_write_reg_wait = amdgpu_ring_emit_reg_write_reg_wait_helper ,
0 commit comments