drm/amdgpu: add atomfirmware helper funciton to query reserved fb size
authorHawking Zhang <Hawking.Zhang@amd.com>
Wed, 22 Jan 2020 20:13:01 +0000 (04:13 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 1 Jul 2020 05:59:10 +0000 (01:59 -0400)
fw_reserved_size_in_kb is introduced for driver to query
the TMR region reserved by PSP BL in Sienna_Cichlid and onwards

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

index 659d845dbebe5828308fe312507dea6c388055b7..a9adccfda4c0f4edfb3862689e97885dbf8521ee 100644 (file)
@@ -325,6 +325,9 @@ bool amdgpu_atomfirmware_mem_ecc_supported(struct amdgpu_device *adev)
 
 union firmware_info {
        struct atom_firmware_info_v3_1 v31;
+       struct atom_firmware_info_v3_2 v32;
+       struct atom_firmware_info_v3_3 v33;
+       struct atom_firmware_info_v3_4 v34;
 };
 
 /*
@@ -590,3 +593,38 @@ int amdgpu_atomfirmware_get_mem_train_info(struct amdgpu_device *adev)
        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;
+       union firmware_info *firmware_info;
+       int index;
+       u16 data_offset, size;
+       u8 frev, crev;
+       int fw_reserved_fb_size;
+
+       index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
+                       firmwareinfo);
+
+       if (!amdgpu_atom_parse_data_header(ctx, index, &size,
+                               &frev, &crev, &data_offset))
+               /* fail to parse data_header */
+               return 0;
+
+       firmware_info = (union firmware_info *)(ctx->bios + data_offset);
+
+       if (frev !=3)
+               return -EINVAL;
+
+       switch (crev) {
+       case 4:
+               fw_reserved_fb_size =
+                       (firmware_info->v34.fw_reserved_size_in_kb << 10);
+               break;
+       default:
+               fw_reserved_fb_size = 0;
+               break;
+       }
+
+       return fw_reserved_fb_size;
+}
index 434fe2fa0089d485fa8387216fa2334cd6fa7f94..3a5ed339903ef062485aa84e3af54f65a04105a3 100644 (file)
@@ -36,5 +36,6 @@ 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);
 
 #endif