Include subrevision and variant fileds also to IP version.

Signed-off-by: Lijo Lazar <lijo.la...@amd.com>
Reviewed-by: Alex Deucher <alexander.deuc...@amd.com>
---
v2:
        Use major/min/rev format in drm_amdgpu_info_hw_ip discovery version

 drivers/gpu/drm/amd/amdgpu/amdgpu.h           | 18 ++++++++++++-----
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 20 ++++++++++++++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c       |  8 ++++----
 3 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 30f44db6c9c5..d62c245d8ad7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -681,10 +681,15 @@ enum amd_hw_ip_block_type {
 #define HWIP_MAX_INSTANCE      44
 
 #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)
+#define IP_VERSION_FULL(mj, mn, rv, var, srev) \
+       (((mj) << 24) | ((mn) << 16) | ((rv) << 8) | ((var) << 4) | (srev))
+#define IP_VERSION(mj, mn, rv)         IP_VERSION_FULL(mj, mn, rv, 0, 0)
+#define IP_VERSION_MAJ(ver)            ((ver) >> 24)
+#define IP_VERSION_MIN(ver)            (((ver) >> 16) & 0xFF)
+#define IP_VERSION_REV(ver)            (((ver) >> 8) & 0xFF)
+#define IP_VERSION_VARIANT(ver)                (((ver) >> 4) & 0xF)
+#define IP_VERSION_SUBREV(ver)         ((ver) & 0xF)
+#define IP_VERSION_MAJ_MIN_REV(ver)    ((ver) >> 8)
 
 struct amdgpu_ip_map_info {
        /* Map of logical to actual dev instances/mask */
@@ -1109,7 +1114,10 @@ struct amdgpu_device {
 static inline uint32_t amdgpu_ip_version(const struct amdgpu_device *adev,
                                         uint8_t ip, uint8_t inst)
 {
-       return adev->ip_versions[ip][inst];
+       /* This considers only major/minor/rev and ignores
+        * subrevision/variant fields.
+        */
+       return adev->ip_versions[ip][inst] & ~0xFFU;
 }
 
 static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index 430ee7f64a97..42d379956ef3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -1191,6 +1191,7 @@ static void amdgpu_discovery_sysfs_fini(struct 
amdgpu_device *adev)
 
 static int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
 {
+       uint8_t num_base_address, subrev, variant;
        struct binary_header *bhdr;
        struct ip_discovery_header *ihdr;
        struct die_header *dhdr;
@@ -1199,7 +1200,6 @@ static int amdgpu_discovery_reg_base_init(struct 
amdgpu_device *adev)
        uint16_t ip_offset;
        uint16_t num_dies;
        uint16_t num_ips;
-       uint8_t num_base_address;
        int hw_ip;
        int i, j, k;
        int r;
@@ -1337,8 +1337,22 @@ static int amdgpu_discovery_reg_base_init(struct 
amdgpu_device *adev)
                                         * example.  On most chips there are 
multiple instances
                                         * with the same HWID.
                                         */
-                                       
adev->ip_versions[hw_ip][ip->instance_number] =
-                                               IP_VERSION(ip->major, 
ip->minor, ip->revision);
+
+                                       if (ihdr->version < 3) {
+                                               subrev = 0;
+                                               variant = 0;
+                                       } else {
+                                               subrev = ip->sub_revision;
+                                               variant = ip->variant;
+                                       }
+
+                                       adev->ip_versions[hw_ip]
+                                                        [ip->instance_number] =
+                                               IP_VERSION_FULL(ip->major,
+                                                               ip->minor,
+                                                               ip->revision,
+                                                               variant,
+                                                               subrev);
                                }
                        }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index dfd24a582391..1bf545154e8e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -502,21 +502,21 @@ static int amdgpu_hw_ip_info(struct amdgpu_device *adev,
                switch (type) {
                case AMD_IP_BLOCK_TYPE_GFX:
                        result->ip_discovery_version =
-                               amdgpu_ip_version(adev, GC_HWIP, 0);
+                               IP_VERSION_MAJ_MIN_REV(amdgpu_ip_version(adev, 
GC_HWIP, 0));
                        break;
                case AMD_IP_BLOCK_TYPE_SDMA:
                        result->ip_discovery_version =
-                               amdgpu_ip_version(adev, SDMA0_HWIP, 0);
+                               IP_VERSION_MAJ_MIN_REV(amdgpu_ip_version(adev, 
SDMA0_HWIP, 0));
                        break;
                case AMD_IP_BLOCK_TYPE_UVD:
                case AMD_IP_BLOCK_TYPE_VCN:
                case AMD_IP_BLOCK_TYPE_JPEG:
                        result->ip_discovery_version =
-                               amdgpu_ip_version(adev, UVD_HWIP, 0);
+                               IP_VERSION_MAJ_MIN_REV(amdgpu_ip_version(adev, 
UVD_HWIP, 0));
                        break;
                case AMD_IP_BLOCK_TYPE_VCE:
                        result->ip_discovery_version =
-                               amdgpu_ip_version(adev, VCE_HWIP, 0);
+                               IP_VERSION_MAJ_MIN_REV(amdgpu_ip_version(adev, 
VCE_HWIP, 0));
                        break;
                default:
                        result->ip_discovery_version = 0;
-- 
2.25.1

Reply via email to