]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
drm/amdgpu/vcn2.0: stall DPG when WPTR/RPTR reset
authorJames Zhu <James.Zhu@amd.com>
Tue, 18 Feb 2020 22:44:39 +0000 (17:44 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 1 Apr 2020 18:44:45 +0000 (14:44 -0400)
Add vcn dpg harware synchronization to fix race condition
issue between vcn driver and hardware.

Signed-off-by: James Zhu <James.Zhu@amd.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c

index b3b5e5cac40062ec7b18a31c4fb3931f0baea7f1..a0bd183ddf36f38fb0a6ba743d67deddeb977ac7 100644 (file)
@@ -867,6 +867,10 @@ static int vcn_v2_0_start_dpg_mode(struct amdgpu_device *adev, bool indirect)
        tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_RPTR_WR_EN, 1);
        WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_CNTL, tmp);
 
+       /* Stall DPG before WPTR/RPTR reset */
+       WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_POWER_STATUS),
+               UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK,
+               ~UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK);
        /* set the write pointer delay */
        WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR_CNTL, 0);
 
@@ -889,6 +893,9 @@ static int vcn_v2_0_start_dpg_mode(struct amdgpu_device *adev, bool indirect)
        WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR,
                lower_32_bits(ring->wptr));
 
+       /* Unstall DPG */
+       WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_POWER_STATUS),
+               0, ~UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK);
        return 0;
 }
 
@@ -1184,8 +1191,13 @@ static int vcn_v2_0_pause_dpg_mode(struct amdgpu_device *adev,
                                           UVD_DPG_PAUSE__NJ_PAUSE_DPG_ACK_MASK,
                                           UVD_DPG_PAUSE__NJ_PAUSE_DPG_ACK_MASK, ret_code);
 
+                               /* Stall DPG before WPTR/RPTR reset */
+                               WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_POWER_STATUS),
+                                          UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK,
+                                          ~UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK);
                                /* Restore */
                                ring = &adev->vcn.inst->ring_enc[0];
+                               ring->wptr = 0;
                                WREG32_SOC15(UVD, 0, mmUVD_RB_BASE_LO, ring->gpu_addr);
                                WREG32_SOC15(UVD, 0, mmUVD_RB_BASE_HI, upper_32_bits(ring->gpu_addr));
                                WREG32_SOC15(UVD, 0, mmUVD_RB_SIZE, ring->ring_size / 4);
@@ -1193,6 +1205,7 @@ static int vcn_v2_0_pause_dpg_mode(struct amdgpu_device *adev,
                                WREG32_SOC15(UVD, 0, mmUVD_RB_WPTR, lower_32_bits(ring->wptr));
 
                                ring = &adev->vcn.inst->ring_enc[1];
+                               ring->wptr = 0;
                                WREG32_SOC15(UVD, 0, mmUVD_RB_BASE_LO2, ring->gpu_addr);
                                WREG32_SOC15(UVD, 0, mmUVD_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));
                                WREG32_SOC15(UVD, 0, mmUVD_RB_SIZE2, ring->ring_size / 4);
@@ -1201,6 +1214,9 @@ static int vcn_v2_0_pause_dpg_mode(struct amdgpu_device *adev,
 
                                WREG32_SOC15(UVD, 0, mmUVD_RBC_RB_WPTR,
                                           RREG32_SOC15(UVD, 0, mmUVD_SCRATCH2) & 0x7FFFFFFF);
+                               /* Unstall DPG */
+                               WREG32_P(SOC15_REG_OFFSET(UVD, 0, mmUVD_POWER_STATUS),
+                                          0, ~UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK);
 
                                SOC15_WAIT_ON_RREG(UVD, 0, mmUVD_POWER_STATUS,
                                           UVD_PGFSM_CONFIG__UVDM_UVDU_PWR_ON,