]> Git Repo - linux.git/blobdiff - drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
drm/amdgpu: Split amdgpu_ucode_init/fini_bo into two functions
[linux.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_ucode.c
index acb4c66fe89b2c708136fff4efe569fa075d50e1..57ed38422089a8a5325f6d21a39d4431cfbc4d62 100644 (file)
@@ -297,13 +297,11 @@ amdgpu_ucode_get_load_type(struct amdgpu_device *adev, int load_type)
        case CHIP_POLARIS11:
        case CHIP_POLARIS12:
        case CHIP_VEGAM:
-               if (!load_type)
-                       return AMDGPU_FW_LOAD_DIRECT;
-               else
-                       return AMDGPU_FW_LOAD_SMU;
+               if (load_type != AMDGPU_FW_LOAD_SMU)
+                       pr_warning("%d is not supported on VI\n", load_type);
+               return AMDGPU_FW_LOAD_SMU;
        case CHIP_VEGA10:
        case CHIP_RAVEN:
-       case CHIP_PICASSO:
        case CHIP_VEGA12:
        case CHIP_VEGA20:
                if (!load_type)
@@ -424,32 +422,42 @@ static int amdgpu_ucode_patch_jt(struct amdgpu_firmware_info *ucode,
        return 0;
 }
 
+int amdgpu_ucode_create_bo(struct amdgpu_device *adev)
+{
+       if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT) {
+               amdgpu_bo_create_kernel(adev, adev->firmware.fw_size, PAGE_SIZE,
+                       amdgpu_sriov_vf(adev) ? AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT,
+                       &adev->firmware.fw_buf,
+                       &adev->firmware.fw_buf_mc,
+                       &adev->firmware.fw_buf_ptr);
+               if (!adev->firmware.fw_buf) {
+                       dev_err(adev->dev, "failed to create kernel buffer for firmware.fw_buf\n");
+                       return -ENOMEM;
+               } else if (amdgpu_sriov_vf(adev)) {
+                       memset(adev->firmware.fw_buf_ptr, 0, adev->firmware.fw_size);
+               }
+       }
+       return 0;
+}
+
+void amdgpu_ucode_free_bo(struct amdgpu_device *adev)
+{
+       if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT)
+               amdgpu_bo_free_kernel(&adev->firmware.fw_buf,
+               &adev->firmware.fw_buf_mc,
+               &adev->firmware.fw_buf_ptr);
+}
+
 int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
 {
        uint64_t fw_offset = 0;
-       int i, err;
+       int i;
        struct amdgpu_firmware_info *ucode = NULL;
        const struct common_firmware_header *header = NULL;
 
-       if (!adev->firmware.fw_size) {
-               dev_warn(adev->dev, "No ip firmware need to load\n");
+ /* for baremetal, the ucode is allocated in gtt, so don't need to fill the bo when reset/suspend */
+       if (!amdgpu_sriov_vf(adev) && (adev->in_gpu_reset || adev->in_suspend))
                return 0;
-       }
-
-       if (!adev->in_gpu_reset) {
-               err = amdgpu_bo_create_kernel(adev, adev->firmware.fw_size, PAGE_SIZE,
-                                       amdgpu_sriov_vf(adev) ? AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT,
-                                       &adev->firmware.fw_buf,
-                                       &adev->firmware.fw_buf_mc,
-                                       &adev->firmware.fw_buf_ptr);
-               if (err) {
-                       dev_err(adev->dev, "failed to create kernel buffer for firmware.fw_buf\n");
-                       goto failed;
-               }
-       }
-
-       memset(adev->firmware.fw_buf_ptr, 0, adev->firmware.fw_size);
-
        /*
         * if SMU loaded firmware, it needn't add SMC, UVD, and VCE
         * ucode info here
@@ -481,12 +489,6 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
                }
        }
        return 0;
-
-failed:
-       if (err)
-               adev->firmware.load_type = AMDGPU_FW_LOAD_DIRECT;
-
-       return err;
 }
 
 int amdgpu_ucode_fini_bo(struct amdgpu_device *adev)
@@ -505,9 +507,5 @@ int amdgpu_ucode_fini_bo(struct amdgpu_device *adev)
                }
        }
 
-       amdgpu_bo_free_kernel(&adev->firmware.fw_buf,
-                               &adev->firmware.fw_buf_mc,
-                               &adev->firmware.fw_buf_ptr);
-
        return 0;
 }
This page took 0.038027 seconds and 4 git commands to generate.