drm/amdgpu: add function to decode ip version
authorLikun Gao <Likun.Gao@amd.com>
Fri, 10 Dec 2021 07:05:57 +0000 (15:05 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 28 Apr 2022 21:46:28 +0000 (17:46 -0400)
Add function to decode IP version.

Signed-off-by: Likun Gao <Likun.Gao@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.h
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h

index f26c3320ae97abc968f1c21f75df7bc8385255eb..d557f4db2565b933693d0335bd70c79a7f62d9cd 100644 (file)
@@ -670,6 +670,9 @@ enum amd_hw_ip_block_type {
 
 #define HW_ID_MAX              300
 #define IP_VERSION(mj, mn, rv) (((mj) << 16) | ((mn) << 8) | (rv))
+#define IP_VERSION_MAJ(ver) ((ver) >> 16)
+#define IP_VERSION_MIN(ver) (((ver) >> 8) & 0xFF)
+#define IP_VERSION_REV(ver) ((ver) & 0xFF)
 
 struct amd_powerplay {
        void *pp_handle;
index ca3350502618918bcdbddedaa219ce240c3be1ea..016477fa2f90a7af416d25ddccbb3ca1b622bfd2 100644 (file)
@@ -760,3 +760,36 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
        }
        return 0;
 }
+
+void amdgpu_ucode_ip_version_decode(struct amdgpu_device *adev, int block_type, char *ucode_prefix, int len)
+{
+       int maj, min, rev;
+       char *ip_name;
+       uint32_t version = adev->ip_versions[block_type][0];
+
+       switch (block_type) {
+       case GC_HWIP:
+               ip_name = "gc";
+               break;
+       case SDMA0_HWIP:
+               ip_name = "sdma";
+               break;
+       case MP0_HWIP:
+               ip_name = "psp";
+               break;
+       case MP1_HWIP:
+               ip_name = "smu";
+               break;
+       case UVD_HWIP:
+               ip_name = "vcn";
+               break;
+       default:
+               BUG();
+       }
+
+       maj = IP_VERSION_MAJ(version);
+       min = IP_VERSION_MIN(version);
+       rev = IP_VERSION_REV(version);
+
+       snprintf(ucode_prefix, len, "%s_%d_%d_%d", ip_name, maj, min, rev);
+}
index 40dffbac85a08476a7bdc02c4542c86de37a8bcf..864984d0d3ef1ae8b7408b3b8c4d0b26f9679cf6 100644 (file)
@@ -463,4 +463,6 @@ amdgpu_ucode_get_load_type(struct amdgpu_device *adev, int load_type);
 
 const char *amdgpu_ucode_name(enum AMDGPU_UCODE_ID ucode_id);
 
+void amdgpu_ucode_ip_version_decode(struct amdgpu_device *adev, int block_type, char *ucode_prefix, int len);
+
 #endif