[PATCH] drm/amdgpu/atomfirmware: use proper index for querying vram type

Alex Deucher alexdeucher at gmail.com
Fri Sep 20 19:49:01 UTC 2019


The index is stored in scratch register 4 after asic init.  Use
that index.  No functional change since all asics in a family
use the same type of vram (G5, G6, HBM) and that is all we use
at the monent, but if we ever need to query other info, we will
now have the proper index.

Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
index daf687428cdb..aad9b340f3ad 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
@@ -232,6 +232,7 @@ int amdgpu_atomfirmware_get_vram_type(struct amdgpu_device *adev)
 	union vram_info *vram_info;
 	u8 frev, crev;
 	u8 mem_type;
+	u32 vram_idx;
 
 	if (adev->flags & AMD_IS_APU)
 		index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
@@ -255,12 +256,17 @@ int amdgpu_atomfirmware_get_vram_type(struct amdgpu_device *adev)
 		} else {
 			vram_info = (union vram_info *)
 				(mode_info->atom_context->bios + data_offset);
+			vram_idx = (RREG32(adev->bios_scratch_reg_offset + 4) & 0x00ff0000) >> 16;
 			switch (crev) {
 			case 3:
-				mem_type = vram_info->v23.vram_module[0].memory_type;
+				if (vram_idx >= vram_info->v23.vram_module_num)
+					vram_idx = 0;
+				mem_type = vram_info->v23.vram_module[vram_idx].memory_type;
 				return convert_atom_mem_type_to_vram_type(adev, mem_type);
 			case 4:
-				mem_type = vram_info->v24.vram_module[0].memory_type;
+				if (vram_idx >= vram_info->v24.vram_module_num)
+					vram_idx = 0;
+				mem_type = vram_info->v24.vram_module[vram_idx].memory_type;
 				return convert_atom_mem_type_to_vram_type(adev, mem_type);
 			default:
 				return 0;
-- 
2.20.1



More information about the amd-gfx mailing list