drm/amdgpu: Add APU support in vi_set_vce_clocks
authorRex Zhu <Rex.Zhu@amd.com>
Tue, 10 Apr 2018 09:49:56 +0000 (17:49 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 8 Jul 2018 13:30:48 +0000 (15:30 +0200)
commit 08ebb6e9f4fd7098c28e0ebbb42847cf0488ebb8 upstream.

1. fix set vce clocks failed on Cz/St
   which lead 1s delay when boot up.
2. remove the workaround in vce_v3_0.c

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Acked-by: Shirish S <shirish.s@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
drivers/gpu/drm/amd/amdgpu/vi.c

index cf81065e3c5ab95030f24f4a883924f27c71bc90..5183b46563f6cd4311b94cd2bd628f558427aec4 100644 (file)
@@ -467,8 +467,8 @@ static int vce_v3_0_hw_init(void *handle)
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
        vce_v3_0_override_vce_clock_gating(adev, true);
-       if (!(adev->flags & AMD_IS_APU))
-               amdgpu_asic_set_vce_clocks(adev, 10000, 10000);
+
+       amdgpu_asic_set_vce_clocks(adev, 10000, 10000);
 
        for (i = 0; i < adev->vce.num_rings; i++)
                adev->vce.ring[i].ready = false;
index 81b0bd7e79a90b919a98df7bf60e07cbf9bd23a0..0327e0a6802b79f18581900b542d6a0c65c1c3d2 100644 (file)
@@ -758,6 +758,8 @@ static int vi_set_uvd_clock(struct amdgpu_device *adev, u32 clock,
 #define ixGNB_CLK1_STATUS   0xD822010C
 #define ixGNB_CLK2_DFS_CNTL 0xD8220110
 #define ixGNB_CLK2_STATUS   0xD822012C
+#define ixGNB_CLK3_DFS_CNTL 0xD8220130
+#define ixGNB_CLK3_STATUS   0xD822014C
 
 static int vi_set_uvd_clocks(struct amdgpu_device *adev, u32 vclk, u32 dclk)
 {
@@ -789,6 +791,22 @@ static int vi_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk)
        int r, i;
        struct atom_clock_dividers dividers;
        u32 tmp;
+       u32 reg_ctrl;
+       u32 reg_status;
+       u32 status_mask;
+       u32 reg_mask;
+
+       if (adev->flags & AMD_IS_APU) {
+               reg_ctrl = ixGNB_CLK3_DFS_CNTL;
+               reg_status = ixGNB_CLK3_STATUS;
+               status_mask = 0x00010000;
+               reg_mask = CG_ECLK_CNTL__ECLK_DIVIDER_MASK;
+       } else {
+               reg_ctrl = ixCG_ECLK_CNTL;
+               reg_status = ixCG_ECLK_STATUS;
+               status_mask = CG_ECLK_STATUS__ECLK_STATUS_MASK;
+               reg_mask = CG_ECLK_CNTL__ECLK_DIR_CNTL_EN_MASK | CG_ECLK_CNTL__ECLK_DIVIDER_MASK;
+       }
 
        r = amdgpu_atombios_get_clock_dividers(adev,
                                               COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK,
@@ -797,24 +815,25 @@ static int vi_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk)
                return r;
 
        for (i = 0; i < 100; i++) {
-               if (RREG32_SMC(ixCG_ECLK_STATUS) & CG_ECLK_STATUS__ECLK_STATUS_MASK)
+               if (RREG32_SMC(reg_status) & status_mask)
                        break;
                mdelay(10);
        }
+
        if (i == 100)
                return -ETIMEDOUT;
 
-       tmp = RREG32_SMC(ixCG_ECLK_CNTL);
-       tmp &= ~(CG_ECLK_CNTL__ECLK_DIR_CNTL_EN_MASK |
-               CG_ECLK_CNTL__ECLK_DIVIDER_MASK);
+       tmp = RREG32_SMC(reg_ctrl);
+       tmp &= ~reg_mask;
        tmp |= dividers.post_divider;
-       WREG32_SMC(ixCG_ECLK_CNTL, tmp);
+       WREG32_SMC(reg_ctrl, tmp);
 
        for (i = 0; i < 100; i++) {
-               if (RREG32_SMC(ixCG_ECLK_STATUS) & CG_ECLK_STATUS__ECLK_STATUS_MASK)
+               if (RREG32_SMC(reg_status) & status_mask)
                        break;
                mdelay(10);
        }
+
        if (i == 100)
                return -ETIMEDOUT;