Skip to contentSkip to conversation

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

PATCH New Alex Deucher 1 participant 1 message Sep 20, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

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.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c +8 -2
index daf687428cdb..aad9b340f3ad 100644
@@ -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;
Signature · 6 lines
2.20.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx