]> www.infradead.org Git - users/willy/xarray.git/commitdiff
drm/amd/amdgpu: add instance_number check in amdgpu_discovery_get_ip_version
authorPeng Ju Zhou <PengJu.Zhou@amd.com>
Thu, 3 Jun 2021 10:32:14 +0000 (18:32 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 11 Jun 2021 20:02:50 +0000 (16:02 -0400)
The original code returns IP version of instantce_0 for every IP. This implementation may be correct for most of IPs.

However, for certain IP block (VCN for example), it may have 2 instances and
both of them have the same hw_id, BUT they have different revision number (0 and 1).

In this case, the original amdgpu_discovery_get_ip_version cannot correct reflects
the result and returns false information

Signed-off-by: Bokun Zhang <Bokun.Zhang@amd.com>
Signed-off-by: Peng Ju Zhou <PengJu.Zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h

index e1b6f5891759957811c29572dc5815653e60e302..4fa4f78137c925a67e01a95015a815f9245f6bef 100644 (file)
@@ -325,7 +325,7 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
        return 0;
 }
 
-int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id,
+int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id, int number_instance,
                                    int *major, int *minor, int *revision)
 {
        struct binary_header *bhdr;
@@ -357,7 +357,7 @@ int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id,
                for (j = 0; j < num_ips; j++) {
                        ip = (struct ip *)(adev->mman.discovery_bin + ip_offset);
 
-                       if (le16_to_cpu(ip->hw_id) == hw_id) {
+                       if ((le16_to_cpu(ip->hw_id) == hw_id) && (ip->number_instance == number_instance)) {
                                if (major)
                                        *major = ip->major;
                                if (minor)
index 1b1ae21b10375262e315c378dc47d32b4f3d91f4..02e340cd3a383343b02522e3fefbafe751918930 100644 (file)
@@ -30,7 +30,7 @@
 void amdgpu_discovery_fini(struct amdgpu_device *adev);
 int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev);
 void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev);
-int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id,
+int amdgpu_discovery_get_ip_version(struct amdgpu_device *adev, int hw_id, int number_instance,
                                     int *major, int *minor, int *revision);
 int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev);