Skip to contentSkip to conversation

drm/amdgpu: handle VCN instances when harvesting (v2)

PATCH In review Alex Deucher 3 participants 4 messages Aug 10, 2021

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu: handle VCN instances when harvesting (v2)

There may be multiple instances and only one is harvested.

v2: fix typo in commit message

Fixes 83a0b8639185 ("drm/amdgpu: add judgement when add ip blocks (v2)")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +9 -3
index 43e7b61d1c5c..ada7bc19118a 100644
@@ -299,6 +299,9 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
 				  ip->major, ip->minor,
 				  ip->revision);
 
+			if (le16_to_cpu(ip->hw_id) == VCN_HWID)
+				adev->vcn.num_vcn_inst++;
+
 			for (k = 0; k < num_base_address; k++) {
 				/*
 				 * convert the endianness of base addresses in place,
@@ -385,7 +388,7 @@ void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
 {
 	struct binary_header *bhdr;
 	struct harvest_table *harvest_info;
-	int i;
+	int i, vcn_harvest_count = 0;
 
 	bhdr = (struct binary_header *)adev->mman.discovery_bin;
 	harvest_info = (struct harvest_table *)(adev->mman.discovery_bin +
@@ -397,8 +400,7 @@ void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
 
 		switch (le32_to_cpu(harvest_info->list[i].hw_id)) {
 		case VCN_HWID:
-			adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK;
-			adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK;
+			vcn_harvest_count++;
 			break;
 		case DMU_HWID:
 			adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK;
@@ -407,6 +409,10 @@ void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
 			break;
 		}
 	}
+	if (vcn_harvest_count == adev->vcn.num_vcn_inst) {
+		adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK;
+		adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK;
+	}
 }
 
 int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
Signature · 1 line
2.31.1
Reviewed-by Reviewed-by James Zhu on v1 1/1
#1 lore raw

[Public]

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Tuesday, August 10, 2021 11:03 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhu, James <[email protected]>
Subject: [PATCH] drm/amdgpu: handle VCN instances when harvesting (v2)

There may be multiple instances and only one is harvested.

v2: fix typo in commit message

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +3 -0
index 43e7b61d1c5c..ada7bc19118a 100644
@@ -299,6 +299,9 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
 				  ip->major, ip->minor,
 				  ip->revision);
 
+			if (le16_to_cpu(ip->hw_id) == VCN_HWID)
+				adev->vcn.num_vcn_inst++;
+
 			for (k = 0; k < num_base_address; k++) {
 				/*
 				 * convert the endianness of base addresses in place, @@ -385,7 +388,7 @@ void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)  {

struct binary_header *bhdr;
struct harvest_table *harvest_info;
- int i;
+ int i, vcn_harvest_count = 0;

bhdr = (struct binary_header *)adev->mman.discovery_bin;
harvest_info = (struct harvest_table *)(adev->mman.discovery_bin + @@ -397,8 +400,7 @@ void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)

switch (le32_to_cpu(harvest_info->list[i].hw_id)) {
case VCN_HWID:
- adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK;
- adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK;
+ vcn_harvest_count++;
break;
case DMU_HWID:
adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK; @@ -407,6 +409,10 @@ void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev) break;
}
}
+ if (vcn_harvest_count == adev->vcn.num_vcn_inst) {
+ adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK;
+ adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK;
+ }
}

int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
--
2.31.1

#2 lore raw
In reply to Alex Deucher
Quoted 46 lines · Alex Deucher

There may be multiple instances and only one is harvested.

v2: fix typo in commit message

Fixes 83a0b8639185 ("drm/amdgpu: add judgement when add ip blocks (v2)")
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 12 +++++++++---
  1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +5 -3
index 43e7b61d1c5c..ada7bc19118a 100644
@@ -299,6 +299,9 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
  				  ip->major, ip->minor,
  				  ip->revision);
 
+			if (le16_to_cpu(ip->hw_id) == VCN_HWID)
+				adev->vcn.num_vcn_inst++;
+
  			for (k = 0; k < num_base_address; k++) {
  				/*
  				 * convert the endianness of base addresses in place,
@@ -385,7 +388,7 @@ void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
  {
  	struct binary_header *bhdr;
  	struct harvest_table *harvest_info;
-	int i;
+	int i, vcn_harvest_count = 0;
 
  	bhdr = (struct binary_header *)adev->mman.discovery_bin;
  	harvest_info = (struct harvest_table *)(adev->mman.discovery_bin +
@@ -397,8 +400,7 @@ void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
 
  		switch (le32_to_cpu(harvest_info->list[i].hw_id)) {
  		case VCN_HWID:
-			adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK;
-			adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK;
+			vcn_harvest_count++;
  			break;
  		case DMU_HWID:
  			adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK;

drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev) · line 415

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +4 -0
@@ -407,6 +409,10 @@ void amdgpu_discovery_harvest_ip(struct amdgpu_device *adev)
  			break;
  		}
  	}
+	if (vcn_harvest_count == adev->vcn.num_vcn_inst) {
+		adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK;
+		adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK;
+	}

If there is only one out of two harvested, I think we should add something like

	adev->vcn.num_vcn_inst -= vcn_harvest_count;

at the end to reflect the actual number of VCN instances available.

Thanks,
Lijo

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +0 -0
  }
 
  int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)
#3 lore raw

Please ignore the comment. Checked again - num_vcn_inst denotes the maximum VCN instances and not the actual number of instances.

Thanks,
Lijo

Quoted 70 lines · Lijo
Quoted 47 lines · Alex Deucher

There may be multiple instances and only one is harvested.

v2: fix typo in commit message

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 12 +++++++++---

  1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +4 -1
index 43e7b61d1c5c..ada7bc19118a 100644
@@ -299,6 +299,9 @@ int amdgpu_discovery_reg_base_init(struct 
 amdgpu_device *adev)
                     ip->major, ip->minor,
                     ip->revision);
+            if (le16_to_cpu(ip->hw_id) == VCN_HWID)
+                adev->vcn.num_vcn_inst++;
+
               for (k = 0; k < num_base_address; k++) {
                   /*
                    * convert the endianness of base addresses in place,
@@ -385,7 +388,7 @@ void amdgpu_discovery_harvest_ip(struct 
 amdgpu_device *adev)
   {
       struct binary_header *bhdr;
       struct harvest_table *harvest_info;
-    int i;
+    int i, vcn_harvest_count = 0;
       bhdr = (struct binary_header *)adev->mman.discovery_bin;

      harvest_info = (struct harvest_table *)(adev->mman.discovery_bin +

drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +0 -0
@@ -397,8 +400,7 @@ void amdgpu_discovery_harvest_ip(struct 
 amdgpu_device *adev)
           switch (le32_to_cpu(harvest_info->list[i].hw_id)) {

          case VCN_HWID:
-            adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK; -            adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK; +            vcn_harvest_count++;
              break;
          case DMU_HWID:
              adev->harvest_ip_mask |= AMD_HARVEST_IP_DMU_MASK;

drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c void amdgpu_discovery_harvest_ip(struct · line 416

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +4 -0
@@ -407,6 +409,10 @@ void amdgpu_discovery_harvest_ip(struct 
 amdgpu_device *adev)
               break;
           }
       }
+    if (vcn_harvest_count == adev->vcn.num_vcn_inst) {
+        adev->harvest_ip_mask |= AMD_HARVEST_IP_VCN_MASK;
+        adev->harvest_ip_mask |= AMD_HARVEST_IP_JPEG_MASK;
+    }

If there is only one out of two harvested, I think we should add something like
    adev->vcn.num_vcn_inst -= vcn_harvest_count;

at the end to reflect the actual number of VCN instances available.

Thanks,
Lijo

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +0 -0
   }
   int amdgpu_discovery_get_gfx_info(struct amdgpu_device *adev)