Skip to contentSkip to conversation

drm/amdgpu/mes: fetch fw version from firmware header

PATCH In review Alex Deucher 2 participants 2 messages Nov 4, 2024

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu/mes: fetch fw version from firmware header

We need this prior to the firmware being loaded so fetch from the header.

v2: fetch directly from the firmware
v3: store both fw versions

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 5 +++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 1 +
 2 files changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +5 -0
index 83d0f731fb65..dc751bdac2cc 100644
@@ -1591,6 +1591,7 @@ int amdgpu_mes_init_microcode(struct amdgpu_device *adev, int pipe)
 	char ucode_prefix[30];
 	char fw_name[50];
 	bool need_retry = false;
+	u32 *ucode_ptr;
 	int r;
 
 	amdgpu_ucode_ip_version_decode(adev, GC_HWIP, ucode_prefix,
@@ -1628,6 +1629,10 @@ int amdgpu_mes_init_microcode(struct amdgpu_device *adev, int pipe)
 	adev->mes.data_start_addr[pipe] =
 		le32_to_cpu(mes_hdr->mes_data_start_addr_lo) |
 		((uint64_t)(le32_to_cpu(mes_hdr->mes_data_start_addr_hi)) << 32);
+	ucode_ptr = (u32 *)(adev->mes.fw[pipe]->data +
+			  sizeof(union amdgpu_firmware_header));
+	adev->mes.fw_version[pipe] =
+		le32_to_cpu(ucode_ptr[24]) & AMDGPU_MES_VERSION_MASK;
 
 	if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
 		int ucode, ucode_data;
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +1 -0
index 45e3508f0f8e..56f36182c9ba 100644
@@ -75,6 +75,7 @@ struct amdgpu_mes {
 
 	uint32_t			sched_version;
 	uint32_t			kiq_version;
+	uint32_t			fw_version[AMDGPU_MAX_MES_PIPES];
 	bool                            enable_legacy_queue_map;
 
 	uint32_t                        total_max_queue;
Signature · 1 line
2.47.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 40 lines · Alex Deucher

We need this prior to the firmware being loaded so fetch from the header.

v2: fetch directly from the firmware
v3: store both fw versions

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 5 +++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 1 +
  2 files changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +5 -0
index 83d0f731fb65..dc751bdac2cc 100644
@@ -1591,6 +1591,7 @@ int amdgpu_mes_init_microcode(struct amdgpu_device *adev, int pipe)
  	char ucode_prefix[30];
  	char fw_name[50];
  	bool need_retry = false;
+	u32 *ucode_ptr;
  	int r;
 
  	amdgpu_ucode_ip_version_decode(adev, GC_HWIP, ucode_prefix,
@@ -1628,6 +1629,10 @@ int amdgpu_mes_init_microcode(struct amdgpu_device *adev, int pipe)
  	adev->mes.data_start_addr[pipe] =
  		le32_to_cpu(mes_hdr->mes_data_start_addr_lo) |
  		((uint64_t)(le32_to_cpu(mes_hdr->mes_data_start_addr_hi)) << 32);
+	ucode_ptr = (u32 *)(adev->mes.fw[pipe]->data +
+			  sizeof(union amdgpu_firmware_header));
+	adev->mes.fw_version[pipe] =
+		le32_to_cpu(ucode_ptr[24]) & AMDGPU_MES_VERSION_MASK;
 
  	if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
  		int ucode, ucode_data;
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +0 -0
index 45e3508f0f8e..56f36182c9ba 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h struct amdgpu_mes { · line 81

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +1 -0
@@ -75,6 +75,7 @@ struct amdgpu_mes {
 
  	uint32_t			sched_version;
  	uint32_t			kiq_version;
+	uint32_t			fw_version[AMDGPU_MAX_MES_PIPES];
  	bool                            enable_legacy_queue_map;
 
  	uint32_t                        total_max_queue;

This is really needed to extract MES fw version, before fw gets loaded.