Skip to contentSkip to conversation

drm/amd/amdgpu: Use IP discovery data to determine VCN enablement instead of MMSCH

PATCH Superseded Peng Ju Zhou 2 participants 6 messages Jun 3, 2021 – Jun 9, 2021

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amd/amdgpu: Use IP discovery data to determine VCN enablement instead of MMSCH

From: Bokun Zhang <[email protected]>

In the past, we use MMSCH to determine whether a VCN is enabled or not. This is not reliable since after a FLR, MMSCH may report junk data.

It is better to use IP discovery data.

---
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 73 +++++++++++++++++----------
 1 file changed, 45 insertions(+), 28 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +45 -28
index ce3c794c176f..92f88ea69035 100644
@@ -27,6 +27,7 @@
 #include "amdgpu_pm.h"
 #include "soc15.h"
 #include "soc15d.h"
+#include "soc15_hw_ip.h"
 #include "vcn_v2_0.h"
 #include "mmsch_v3_0.h"
 
@@ -63,6 +64,17 @@ static int amdgpu_ucode_id_vcns[] = {
 	AMDGPU_UCODE_ID_VCN1
 };
 
+#define VCN_BLOCK_ENCODE_DISABLE_MASK 0x80
+#define VCN_BLOCK_DECODE_DISABLE_MASK 0x40
+#define VCN_BLOCK_QUEUE_DISABLE_MASK 0xC0
+
+enum vcn_ring_type {
+	VCN_ENCODE_RING,
+	VCN_DECODE_RING,
+	VCN_UNIFIED_RING,
+};
+
+static bool vcn_v3_0_is_disabled_vcn(struct amdgpu_device *adev, enum vcn_ring_type type, uint32_t vcn_instance);
 static int vcn_v3_0_start_sriov(struct amdgpu_device *adev);
 static void vcn_v3_0_set_dec_ring_funcs(struct amdgpu_device *adev);
 static void vcn_v3_0_set_enc_ring_funcs(struct amdgpu_device *adev);
@@ -324,18 +336,26 @@ static int vcn_v3_0_hw_init(void *handle)
 				continue;
 
 			ring = &adev->vcn.inst[i].ring_dec;
-			if (ring->sched.ready) {
+			if (vcn_v3_0_is_disabled_vcn(adev, VCN_DECODE_RING, i)) {
+				ring->sched.ready = false;
+				dev_info(adev->dev, "ring %s is disabled by hypervisor\n", ring->name);
+			} else {
 				ring->wptr = 0;
 				ring->wptr_old = 0;
 				vcn_v3_0_dec_ring_set_wptr(ring);
+				ring->sched.ready = true;
 			}
 
 			for (j = 0; j < adev->vcn.num_enc_rings; ++j) {
 				ring = &adev->vcn.inst[i].ring_enc[j];
-				if (ring->sched.ready) {
+				if (vcn_v3_0_is_disabled_vcn(adev, VCN_ENCODE_RING, i)) {
+					ring->sched.ready = false;
+					dev_info(adev->dev, "ring %s is disabled by hypervisor\n", ring->name);
+				} else {
 					ring->wptr = 0;
 					ring->wptr_old = 0;
 					vcn_v3_0_enc_ring_set_wptr(ring);
+					ring->sched.ready = true;
 				}
 			}
 		}
@@ -1286,6 +1306,29 @@ static int vcn_v3_0_start(struct amdgpu_device *adev)
 	return 0;
 }
 
+static bool vcn_v3_0_is_disabled_vcn(struct amdgpu_device *adev, enum vcn_ring_type type, uint32_t vcn_instance)
+{
+	bool ret = false;
+
+	int major;
+	int minor;
+	int revision;
+
+	/* if cannot find IP data, then this VCN does not exist */
+	if (amdgpu_discovery_get_ip_version(adev, VCN_HWID, vcn_instance, &major, &minor, &revision) != 0)
+		return true;
+
+	if ((type == VCN_ENCODE_RING) && (revision & VCN_BLOCK_ENCODE_DISABLE_MASK)) {
+		ret = true;
+	} else if ((type == VCN_DECODE_RING) && (revision & VCN_BLOCK_DECODE_DISABLE_MASK)) {
+		ret = true;
+	} else if ((type == VCN_UNIFIED_RING) && (revision & VCN_BLOCK_QUEUE_DISABLE_MASK)) {
+		ret = true;
+	}
+
+	return ret;
+}
+
 static int vcn_v3_0_start_sriov(struct amdgpu_device *adev)
 {
 	int i, j;
@@ -1303,8 +1346,6 @@ static int vcn_v3_0_start_sriov(struct amdgpu_device *adev)
 	uint32_t table_size;
 	uint32_t size, size_dw;
 
-	bool is_vcn_ready;
-
 	struct mmsch_v3_0_cmd_direct_write
 		direct_wt = { {0} };
 	struct mmsch_v3_0_cmd_direct_read_modify_write
@@ -1496,30 +1537,6 @@ static int vcn_v3_0_start_sriov(struct amdgpu_device *adev)
 		}
 	}
 
-	/* 6, check each VCN's init_status
-	 * if it remains as 0, then this VCN is not assigned to current VF
-	 * do not start ring for this VCN
-	 */
-	size = sizeof(struct mmsch_v3_0_init_header);
-	table_loc = (uint32_t *)table->cpu_addr;
-	memcpy(&header, (void *)table_loc, size);
-
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i))
-			continue;
-
-		is_vcn_ready = (header.inst[i].init_status == 1);
-		if (!is_vcn_ready)
-			DRM_INFO("VCN(%d) engine is disabled by hypervisor\n", i);
-
-		ring = &adev->vcn.inst[i].ring_dec;
-		ring->sched.ready = is_vcn_ready;
-		for (j = 0; j < adev->vcn.num_enc_rings; ++j) {
-			ring = &adev->vcn.inst[i].ring_enc[j];
-			ring->sched.ready = is_vcn_ready;
-		}
-	}
-
 	return 0;
 }
 
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw

PATCH 2/2 drm/amd/amdgpu: add instance_number check in amdgpu_discovery_get_ip_version

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

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +2 -2
index 99255c2f08f4..f949ed8bfd9e 100644
@@ -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)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h +1 -1
index 1b1ae21b1037..02e340cd3a38 100644
@@ -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);
 
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#2 lore raw

RE: [PATCH 2/2] drm/amd/amdgpu: add instance_number check in amdgpu_discovery_get_ip_version

[AMD Official Use Only]

Hi Alex
The following patch series were ported from amd-staging-dkms to fix VCN IB test fail. Can you help to review it?

[PATCH 1/2] drm/amd/amdgpu: Use IP discovery data to determine VCN enablement instead of MMSCH [PATCH 2/2] drm/amd/amdgpu: add instance_number check in amdgpu_discovery_get_ip_version

----------------------------------------------------------------------
BW
Pengju Zhou

Quoted 69 lines

-----Original Message-----
From: Peng Ju Zhou <[email protected]>
Sent: Thursday, June 3, 2021 6:42 PM
To: [email protected]
Cc: Zhou, Peng Ju <[email protected]>; Zhang, Bokun <[email protected]>
Subject: [PATCH 2/2] drm/amd/amdgpu: add instance_number check in amdgpu_discovery_get_ip_version

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

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 4 ++--
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +3 -2
index 99255c2f08f4..f949ed8bfd9e 100644
@@ -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-
Quoted 1 line

number_instance ==

drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +1 -0
+number_instance)) {
 				if (major)
 					*major = ip->major;
 				if (minor)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h +0 -0
index 1b1ae21b1037..02e340cd3a38 100644
@@ -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,

drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h +2 -0
+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);

Quoted 2 lines

--
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw

RE: [PATCH 2/2] drm/amd/amdgpu: add instance_number check in amdgpu_discovery_get_ip_version

[AMD Official Use Only]

Ping on this series

--------------------------
Pengju Zhou

Quoted 99 lines

-----Original Message-----
From: Zhou, Peng Ju <[email protected]>
Sent: Monday, June 7, 2021 4:13 PM
To: Zhou, Peng Ju <[email protected]>; [email protected]; Deucher, Alexander <[email protected]>
Cc: Zhang, Bokun <[email protected]>
Subject: RE: [PATCH 2/2] drm/amd/amdgpu: add instance_number check in amdgpu_discovery_get_ip_version

[AMD Official Use Only]

Hi Alex
The following patch series were ported from amd-staging-dkms to fix VCN IB test fail.
Can you help to review it?

[PATCH 1/2] drm/amd/amdgpu: Use IP discovery data to determine VCN enablement instead of MMSCH [PATCH 2/2] drm/amd/amdgpu: add instance_number check in amdgpu_discovery_get_ip_version

----------------------------------------------------------------------
BW
Pengju Zhou

Quoted 44 lines

-----Original Message-----
From: Peng Ju Zhou <[email protected]>
Sent: Thursday, June 3, 2021 6:42 PM
To: [email protected]
Cc: Zhou, Peng Ju <[email protected]>; Zhang, Bokun <[email protected]>
Subject: [PATCH 2/2] drm/amd/amdgpu: add instance_number check in amdgpu_discovery_get_ip_version

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

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 4 ++--
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +2 -1
index 99255c2f08f4..f949ed8bfd9e 100644
@@ -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;

drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c int amdgpu_discovery_get_ip_version(struct · line 359

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +0 -0
@@ -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);

Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +1 -1
-			if (le16_to_cpu(ip->hw_id) == hw_id) {
+			if ((le16_to_cpu(ip->hw_id) == hw_id) && (ip-
Quoted 1 line

number_instance ==

drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +1 -0
+number_instance)) {
 				if (major)
 					*major = ip->major;
 				if (minor)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h +0 -0
index 1b1ae21b1037..02e340cd3a38 100644
@@ -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,

drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h +2 -0
+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);

Quoted 2 lines
Quoted 2 lines

--
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] drm/amd/amdgpu: add instance_number check in amdgpu_discovery_get_ip_version

In reply to Peng Ju Zhou
Quoted 11 lines · Peng Ju Zhou

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

This patch is:

Quoted 43 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +2 -2
index 99255c2f08f4..f949ed8bfd9e 100644
@@ -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)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.h +1 -2
index 1b1ae21b1037..02e340cd3a38 100644
@@ -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);
 
--

2.17.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#5 lore raw
In reply to Peng Ju Zhou
Quoted 60 lines · Peng Ju Zhou

From: Bokun Zhang <[email protected]>

In the past, we use MMSCH to determine whether a VCN is enabled or not. This is not reliable since after a FLR, MMSCH may report junk data.

It is better to use IP discovery data.

---
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 73 +++++++++++++++++----------
 1 file changed, 45 insertions(+), 28 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +17 -1
index ce3c794c176f..92f88ea69035 100644
@@ -27,6 +27,7 @@
 #include "amdgpu_pm.h"
 #include "soc15.h"
 #include "soc15d.h"
+#include "soc15_hw_ip.h"
 #include "vcn_v2_0.h"
 #include "mmsch_v3_0.h"
 
@@ -63,6 +64,17 @@ static int amdgpu_ucode_id_vcns[] = {
        AMDGPU_UCODE_ID_VCN1
 };
 
+#define VCN_BLOCK_ENCODE_DISABLE_MASK 0x80
+#define VCN_BLOCK_DECODE_DISABLE_MASK 0x40
+#define VCN_BLOCK_QUEUE_DISABLE_MASK 0xC0
+
+enum vcn_ring_type {
+       VCN_ENCODE_RING,
+       VCN_DECODE_RING,
+       VCN_UNIFIED_RING,
+};
+
+static bool vcn_v3_0_is_disabled_vcn(struct amdgpu_device *adev, enum vcn_ring_type type, uint32_t vcn_instance);
 static int vcn_v3_0_start_sriov(struct amdgpu_device *adev);
 static void vcn_v3_0_set_dec_ring_funcs(struct amdgpu_device *adev);
 static void vcn_v3_0_set_enc_ring_funcs(struct amdgpu_device *adev);
@@ -324,18 +336,26 @@ static int vcn_v3_0_hw_init(void *handle)
                                continue;
 
                        ring = &adev->vcn.inst[i].ring_dec;
-                       if (ring->sched.ready) {
+                       if (vcn_v3_0_is_disabled_vcn(adev, VCN_DECODE_RING, i)) {
+                               ring->sched.ready = false;
+                               dev_info(adev->dev, "ring %s is disabled by hypervisor\n", ring->name);
+                       } else {
                                ring->wptr = 0;
                                ring->wptr_old = 0;
                                vcn_v3_0_dec_ring_set_wptr(ring);
+                               ring->sched.ready = true;
                        }
 
                        for (j = 0; j < adev->vcn.num_enc_rings; ++j) {

drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c static int vcn_v3_0_hw_init(void *handle) · line 358

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +5 -1
                                ring = &adev->vcn.inst[i].ring_enc[j];
-                               if (ring->sched.ready) {
+                               if (vcn_v3_0_is_disabled_vcn(adev, VCN_ENCODE_RING, i)) {
+                                       ring->sched.ready = false;
+                                       dev_info(adev->dev, "ring %s is disabled by hypervisor\n", ring->name);
+                               } else {
                                        ring->wptr = 0;
                                        ring->wptr_old = 0;
                                        vcn_v3_0_enc_ring_set_wptr(ring);
+                                       ring->sched.ready = true;

I think it would be cleaner to use the IP discovery data in vcn_v3_0_early_init() to set the harvest config and just use that here.

Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +13 -0
                                }
                        }
                }
@@ -1286,6 +1306,29 @@ static int vcn_v3_0_start(struct amdgpu_device *adev)
        return 0;
 }
 
+static bool vcn_v3_0_is_disabled_vcn(struct amdgpu_device *adev, enum vcn_ring_type type, uint32_t vcn_instance)
+{
+       bool ret = false;
+
+       int major;
+       int minor;
+       int revision;
+
+       /* if cannot find IP data, then this VCN does not exist */
+       if (amdgpu_discovery_get_ip_version(adev, VCN_HWID, vcn_instance, &major, &minor, &revision) != 0)
+               return true;
+
+       if ((type == VCN_ENCODE_RING) && (revision & VCN_BLOCK_ENCODE_DISABLE_MASK)) {

drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c static int vcn_v3_0_start(struct amdgpu_device *adev) · line 1331

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +10 -0
+               ret = true;
+       } else if ((type == VCN_DECODE_RING) && (revision & VCN_BLOCK_DECODE_DISABLE_MASK)) {
+               ret = true;
+       } else if ((type == VCN_UNIFIED_RING) && (revision & VCN_BLOCK_QUEUE_DISABLE_MASK)) {
+               ret = true;
+       }
+
+       return ret;
+}
+

I don't think this is VCN 3.0 specific. This could probably be moved to amdgpu_vcn.c or amdgpu_discovery.c

Alex

Quoted 46 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +0 -27
 static int vcn_v3_0_start_sriov(struct amdgpu_device *adev)
 {
        int i, j;
@@ -1303,8 +1346,6 @@ static int vcn_v3_0_start_sriov(struct amdgpu_device *adev)
        uint32_t table_size;
        uint32_t size, size_dw;
 
-       bool is_vcn_ready;
-
        struct mmsch_v3_0_cmd_direct_write
                direct_wt = { {0} };
        struct mmsch_v3_0_cmd_direct_read_modify_write
@@ -1496,30 +1537,6 @@ static int vcn_v3_0_start_sriov(struct amdgpu_device *adev)
                }
        }
 
-       /* 6, check each VCN's init_status
-        * if it remains as 0, then this VCN is not assigned to current VF
-        * do not start ring for this VCN
-        */
-       size = sizeof(struct mmsch_v3_0_init_header);
-       table_loc = (uint32_t *)table->cpu_addr;
-       memcpy(&header, (void *)table_loc, size);
-
-       for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-               if (adev->vcn.harvest_config & (1 << i))
-                       continue;
-
-               is_vcn_ready = (header.inst[i].init_status == 1);
-               if (!is_vcn_ready)
-                       DRM_INFO("VCN(%d) engine is disabled by hypervisor\n", i);
-
-               ring = &adev->vcn.inst[i].ring_dec;
-               ring->sched.ready = is_vcn_ready;
-               for (j = 0; j < adev->vcn.num_enc_rings; ++j) {
-                       ring = &adev->vcn.inst[i].ring_enc[j];
-                       ring->sched.ready = is_vcn_ready;
-               }
-       }
-
        return 0;
 }
 
--

2.17.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx