drm/amdgpu: move amdgpu_ucode_init_bo to amdgpu_device.c
authorRex Zhu <Rex.Zhu@amd.com>
Fri, 22 Sep 2017 10:03:59 +0000 (18:03 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 28 Sep 2017 20:03:31 +0000 (16:03 -0400)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c

index 284d5c82d92649055313f17f00d7be856c2a5899..1949d8aedf49ef2c4b0f0a59edd7efa7e486aa6c 100644 (file)
@@ -1604,6 +1604,7 @@ static int amdgpu_init(struct amdgpu_device *adev)
                        return r;
                }
                adev->ip_blocks[i].status.sw = true;
+
                /* need to do gmc hw init early so we can allocate gpu mem */
                if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) {
                        r = amdgpu_vram_scratch_init(adev);
@@ -1634,6 +1635,11 @@ static int amdgpu_init(struct amdgpu_device *adev)
                }
        }
 
+       mutex_lock(&adev->firmware.mutex);
+       if (amdgpu_ucode_init_bo(adev))
+               adev->firmware.load_type = AMDGPU_FW_LOAD_DIRECT;
+       mutex_unlock(&adev->firmware.mutex);
+
        for (i = 0; i < adev->num_ip_blocks; i++) {
                if (!adev->ip_blocks[i].status.sw)
                        continue;
@@ -1769,6 +1775,8 @@ static int amdgpu_fini(struct amdgpu_device *adev)
 
                adev->ip_blocks[i].status.hw = false;
        }
+       if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT)
+               amdgpu_ucode_fini_bo(adev);
 
        for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
                if (!adev->ip_blocks[i].status.sw)
index 1ad632388c955d67c93a07f74b85814e6be90f39..c05e5a86e7ccbe13f9132676b0cd8be7ec61e78f 100644 (file)
@@ -174,8 +174,6 @@ static int amdgpu_pp_hw_init(void *handle)
        int ret = 0;
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
-       if (adev->pp_enabled && adev->firmware.load_type == AMDGPU_FW_LOAD_SMU)
-               amdgpu_ucode_init_bo(adev);
 
        if (adev->powerplay.ip_funcs->hw_init)
                ret = adev->powerplay.ip_funcs->hw_init(
@@ -201,9 +199,6 @@ static int amdgpu_pp_hw_fini(void *handle)
                ret = adev->powerplay.ip_funcs->hw_fini(
                                        adev->powerplay.pp_handle);
 
-       if (adev->pp_enabled && adev->firmware.load_type == AMDGPU_FW_LOAD_SMU)
-               amdgpu_ucode_fini_bo(adev);
-
        return ret;
 }
 
index 447d446b50150d475cb9a01945706b17bbfc2e78..f1035a689d354349aaac7b7b79e1eaa51cf6e4a8 100644 (file)
@@ -411,13 +411,6 @@ static int psp_hw_init(void *handle)
                return 0;
 
        mutex_lock(&adev->firmware.mutex);
-       /*
-        * This sequence is just used on hw_init only once, no need on
-        * resume.
-        */
-       ret = amdgpu_ucode_init_bo(adev);
-       if (ret)
-               goto failed;
 
        ret = psp_load_fw(adev);
        if (ret) {
@@ -442,8 +435,6 @@ static int psp_hw_fini(void *handle)
        if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
                return 0;
 
-       amdgpu_ucode_fini_bo(adev);
-
        psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
        amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);