drm/amdgpu: remove unnecessary check for mem train
authorLikun Gao <Likun.Gao@amd.com>
Fri, 22 May 2020 06:42:35 +0000 (14:42 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 1 Jul 2020 05:59:14 +0000 (01:59 -0400)
a.Check whether mem train support when try to reserve related memory.
b.Remove ASIC check and atom firmware table version check as the check
of firmware capability is enough to achieve that purpose.

Signed-off-by: Likun Gao <Likun.Gao@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

index 922d5bca14c0dd78127887c2504023fa825d5386..135530286f34fe9f4946f755d6f92604eb35b028 100644 (file)
@@ -652,10 +652,6 @@ struct amdgpu_fw_vram_usage {
        u64 size;
        struct amdgpu_bo *reserved_bo;
        void *va;
-
-       /* GDDR6 training support flag.
-       */
-       bool mem_train_support;
 };
 
 /*
index fdd52d86a4d7558184401ca454ee831d1ca4ac9b..c687432da4262df577093a6109a280c2ff8e57ed 100644 (file)
@@ -2022,11 +2022,6 @@ int amdgpu_atombios_init(struct amdgpu_device *adev)
        if (adev->is_atom_fw) {
                amdgpu_atomfirmware_scratch_regs_init(adev);
                amdgpu_atomfirmware_allocate_fb_scratch(adev);
-               ret = amdgpu_atomfirmware_get_mem_train_info(adev);
-               if (ret) {
-                       DRM_ERROR("Failed to get mem train fb location.\n");
-                       return ret;
-               }
        } else {
                amdgpu_atombios_scratch_regs_init(adev);
                amdgpu_atombios_allocate_fb_scratch(adev);
index 2b55ccd5cb44d8920ff9b4d2e3697a042ebf89e1..e249b22fef549dc5d3b2eb94204b00965c2f88ba 100644 (file)
@@ -516,7 +516,7 @@ static bool gddr6_mem_train_vbios_support(struct amdgpu_device *adev)
        return false;
 }
 
-static int gddr6_mem_train_support(struct amdgpu_device *adev)
+int amdgpu_mem_train_support(struct amdgpu_device *adev)
 {
        int ret;
        uint32_t major, minor, revision, hw_v;
@@ -551,51 +551,6 @@ static int gddr6_mem_train_support(struct amdgpu_device *adev)
        return ret;
 }
 
-int amdgpu_atomfirmware_get_mem_train_info(struct amdgpu_device *adev)
-{
-       struct atom_context *ctx = adev->mode_info.atom_context;
-       int index;
-       uint8_t frev, crev;
-       uint16_t data_offset, size;
-       int ret;
-
-       adev->fw_vram_usage.mem_train_support = false;
-
-       if (adev->asic_type != CHIP_NAVI10 &&
-           adev->asic_type != CHIP_NAVI14 &&
-           adev->asic_type != CHIP_SIENNA_CICHLID)
-               return 0;
-
-       if (amdgpu_sriov_vf(adev))
-               return 0;
-
-       ret = gddr6_mem_train_support(adev);
-       if (ret == -1)
-               return -EINVAL;
-       else if (ret == 0)
-               return 0;
-
-       index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
-                                           vram_usagebyfirmware);
-       ret = amdgpu_atom_parse_data_header(ctx, index, &size, &frev, &crev,
-                                           &data_offset);
-       if (ret == 0) {
-               DRM_ERROR("parse data header failed.\n");
-               return -EINVAL;
-       }
-
-       DRM_DEBUG("atom firmware common table header size:0x%04x, frev:0x%02x,"
-                 " crev:0x%02x, data_offset:0x%04x.\n", size, frev, crev, data_offset);
-       /* only support 2.1+ */
-       if (((uint16_t)frev << 8 | crev) < 0x0201) {
-               DRM_ERROR("frev:0x%02x, crev:0x%02x < 2.1 !\n", frev, crev);
-               return -EINVAL;
-       }
-
-       adev->fw_vram_usage.mem_train_support = true;
-       return 0;
-}
-
 int amdgpu_atomfirmware_get_fw_reserved_fb_size(struct amdgpu_device *adev)
 {
        struct atom_context *ctx = adev->mode_info.atom_context;
index 3a5ed339903ef062485aa84e3af54f65a04105a3..9f0d4356e8df1952f395b9399f2b753ce755ade1 100644 (file)
@@ -31,11 +31,11 @@ void amdgpu_atomfirmware_scratch_regs_init(struct amdgpu_device *adev);
 int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev);
 int amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
        int *vram_width, int *vram_type, int *vram_vendor);
-int amdgpu_atomfirmware_get_mem_train_info(struct amdgpu_device *adev);
 int amdgpu_atomfirmware_get_clock_info(struct amdgpu_device *adev);
 int amdgpu_atomfirmware_get_gfx_info(struct amdgpu_device *adev);
 bool amdgpu_atomfirmware_mem_ecc_supported(struct amdgpu_device *adev);
 bool amdgpu_atomfirmware_sram_ecc_supported(struct amdgpu_device *adev);
 int amdgpu_atomfirmware_get_fw_reserved_fb_size(struct amdgpu_device *adev);
+int amdgpu_mem_train_support(struct amdgpu_device *adev);
 
 #endif
index 60225a3241e1e0b74e021d1f4ac1fa95a2f7e03c..faf505de5482a2b98d2d2b037dddc41bb3c6cb3d 100644 (file)
@@ -1860,10 +1860,13 @@ static int amdgpu_ttm_reserve_tmr(struct amdgpu_device *adev)
        bool mem_train_support = false;
 
        if (!amdgpu_sriov_vf(adev)) {
-               if (adev->fw_vram_usage.mem_train_support) {
+               ret = amdgpu_mem_train_support(adev);
+               if (ret == 1) {
                        mem_train_support = true;
                        amdgpu_ttm_training_data_block_init(adev);
-               } else
+               } else if (ret == -1)
+                       return -EINVAL;
+               else
                        DRM_DEBUG("memory training does not support!\n");
        }