Skip to contentSkip to conversation

drm/amdgpu: add support to query vram info from firmware

PATCH Superseded Gangliang Xie 2 participants 2 messages Mar 24

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amdgpu: add support to query vram info from firmware

add support to query vram info from firmware

v2: change APU vram type, add multi-aid check

---
 .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c  | 13 ++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c         | 56 ++++++++++---------
 2 files changed, 43 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c +12 -1
index 7f4751e5caaf..504b5f0a74ab 100644
@@ -399,6 +399,9 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
 		switch (amdgpu_ip_version(adev, GC_HWIP, 0)) {
 		case IP_VERSION(12, 0, 0):
 		case IP_VERSION(12, 0, 1):
+		case IP_VERSION(9, 5, 0):
+		case IP_VERSION(9, 4, 4):
+		case IP_VERSION(9, 4, 3):
 			index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, umc_info);
 			break;
 		default:
@@ -475,6 +478,9 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
 			switch (amdgpu_ip_version(adev, GC_HWIP, 0)) {
 			case IP_VERSION(12, 0, 0):
 			case IP_VERSION(12, 0, 1):
+			case IP_VERSION(9, 5, 0):
+			case IP_VERSION(9, 4, 4):
+			case IP_VERSION(9, 4, 3):
 				umc_info = (union umc_info *)(mode_info->atom_context->bios + data_offset);
 
 				if (frev == 4) {
@@ -488,8 +494,13 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
 							*vram_vendor = mem_vendor;
 						if (vram_type)
 							*vram_type = convert_atom_mem_type_to_vram_type(adev, mem_type);
-						if (vram_width)
+						if (vram_width) {
 							*vram_width = mem_channel_number * (1 << mem_channel_width);
+							if (amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 5, 0) ||
+							    amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 4) ||
+							    amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 3))
+								*vram_width *= 4;
+						}
 						break;
 					default:
 						return -EINVAL;
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +31 -25

80 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw
Quoted 35 lines · Gangliang Xie

add support to query vram info from firmware

v2: change APU vram type, add multi-aid check

---
  .../gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c  | 13 ++++-
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c         | 56 ++++++++++---------
  2 files changed, 43 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c +6 -0
index 7f4751e5caaf..504b5f0a74ab 100644
@@ -399,6 +399,9 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
  		switch (amdgpu_ip_version(adev, GC_HWIP, 0)) {
  		case IP_VERSION(12, 0, 0):
  		case IP_VERSION(12, 0, 1):
+		case IP_VERSION(9, 5, 0):
+		case IP_VERSION(9, 4, 4):
+		case IP_VERSION(9, 4, 3):
  			index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1, umc_info);
  			break;
  		default:
@@ -475,6 +478,9 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
  			switch (amdgpu_ip_version(adev, GC_HWIP, 0)) {
  			case IP_VERSION(12, 0, 0):
  			case IP_VERSION(12, 0, 1):
+			case IP_VERSION(9, 5, 0):
+			case IP_VERSION(9, 4, 4):
+			case IP_VERSION(9, 4, 3):
  				umc_info = (union umc_info *)(mode_info->atom_context->bios + data_offset);
 
  				if (frev == 4) {

drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev, · line 502

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c +5 -1
@@ -488,8 +494,13 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
  							*vram_vendor = mem_vendor;
  						if (vram_type)
  							*vram_type = convert_atom_mem_type_to_vram_type(adev, mem_type);
-						if (vram_width)
+						if (vram_width) {
  							*vram_width = mem_channel_number * (1 << mem_channel_width);
+							if (amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 5, 0) ||
+							    amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 4) ||
+							    amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 3))
+								*vram_width *= 4;

This is not the place to do this and this is not the way also. It should be based on total number of AIDs available.

Thanks,
Lijo

Quoted 91 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c +1 -0
+						}
  						break;
  					default:
  						return -EINVAL;
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +31 -25
index 1ca0202cfdea..285eecb65522 100644
@@ -1823,24 +1823,37 @@ static void gmc_v9_0_save_registers(struct amdgpu_device *adev)
  		adev->gmc.sdpif_register = RREG32_SOC15(DCE, 0, mmDCHUBBUB_SDPIF_MMIO_CNTRL_0);
  }
 
-static void gmc_v9_4_3_init_vram_info(struct amdgpu_device *adev)
+static void gmc_v9_0_init_vram_info(struct amdgpu_device *adev)
  {
  	static const u32 regBIF_BIOS_SCRATCH_4 = 0x50;
+	int dev_var = adev->pdev->device & 0xF;
  	u32 vram_info;
 
-	adev->gmc.vram_type = AMDGPU_VRAM_TYPE_HBM;
-	adev->gmc.vram_width = 128 * 64;
-
-	if (amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 5, 0))
-		adev->gmc.vram_type = AMDGPU_VRAM_TYPE_HBM3E;
-
-	if (amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 4) &&
-		adev->rev_id == 0x3)
-		adev->gmc.vram_type = AMDGPU_VRAM_TYPE_HBM3E;
-
-	if (!(adev->flags & AMD_IS_APU) && !amdgpu_sriov_vf(adev)) {
-		vram_info = RREG32(regBIF_BIOS_SCRATCH_4);
-		adev->gmc.vram_vendor = vram_info & 0xF;
+	if (adev->gmc.is_app_apu) {
+		adev->gmc.vram_type = AMDGPU_VRAM_TYPE_HBM;
+		adev->gmc.vram_width = 128 * 64;
+	} else if (adev->flags & AMD_IS_APU) {
+		adev->gmc.vram_type = AMDGPU_VRAM_TYPE_DDR4;
+		adev->gmc.vram_width = 64 * 64;
+	} else if (amdgpu_is_multi_aid(adev)) {
+		adev->gmc.vram_type = AMDGPU_VRAM_TYPE_HBM;
+		adev->gmc.vram_width = 128 * 64;
+
+		if (amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 5, 0))
+			adev->gmc.vram_type = AMDGPU_VRAM_TYPE_HBM3E;
+
+		if (amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 4) &&
+		    adev->rev_id == 0x3)
+			adev->gmc.vram_type = AMDGPU_VRAM_TYPE_HBM3E;
+
+		if (amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 4, 3) &&
+		    (dev_var == 0x5))
+			adev->gmc.vram_type = AMDGPU_VRAM_TYPE_HBM3E;
+
+		if (!(adev->flags & AMD_IS_APU) && !amdgpu_sriov_vf(adev)) {
+			vram_info = RREG32(regBIF_BIOS_SCRATCH_4);
+			adev->gmc.vram_vendor = vram_info & 0xF;
+		}
  	}
  }
 
@@ -1856,19 +1869,11 @@ static int gmc_v9_0_sw_init(struct amdgpu_ip_block *ip_block)
 
  	spin_lock_init(&adev->gmc.invalidate_lock);
 
-	if (amdgpu_is_multi_aid(adev)) {
-		gmc_v9_4_3_init_vram_info(adev);
-	} else if (!adev->bios) {
-		if (adev->flags & AMD_IS_APU) {
-			adev->gmc.vram_type = AMDGPU_VRAM_TYPE_DDR4;
-			adev->gmc.vram_width = 64 * 64;
-		} else {
-			adev->gmc.vram_type = AMDGPU_VRAM_TYPE_HBM;
-			adev->gmc.vram_width = 128 * 64;
-		}
+	if (!adev->bios) {
+		gmc_v9_0_init_vram_info(adev);
  	} else {
  		r = amdgpu_atomfirmware_get_vram_info(adev,
-			&vram_width, &vram_type, &vram_vendor);
+				&vram_width, &vram_type, &vram_vendor);
  		if (amdgpu_sriov_vf(adev))
  			/* For Vega10 SR-IOV, vram_width can't be read from ATOM as RAVEN,
  			 * and DF related registers is not readable, seems hardcord is the
@@ -1896,6 +1901,7 @@ static int gmc_v9_0_sw_init(struct amdgpu_ip_block *ip_block)
  		adev->gmc.vram_type = vram_type;
  		adev->gmc.vram_vendor = vram_vendor;
  	}
+
  	switch (amdgpu_ip_version(adev, GC_HWIP, 0)) {
  	case IP_VERSION(9, 1, 0):
  	case IP_VERSION(9, 2, 2):