Skip to contentSkip to conversation

drm/amd/amdgpu: Recovery vcn instance iterate.

PATCH In review Peng Ju Zhou 4 participants 6 messages Jul 13, 2021 – Jul 20, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amd/amdgpu: Recovery vcn instance iterate.

The previous logic is recording the amount of valid vcn instances to use them on SRIOV, it is a hard task due to the vcn accessment is based on the index of the vcn instance.

Check if the vcn instance enabled before do instance init.

---
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 33 ++++++++++++++++-----------
 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +20 -13
index c3580de3ea9c..d11fea2c9d90 100644
@@ -88,9 +88,7 @@ static int vcn_v3_0_early_init(void *handle)
 	int i;
 
 	if (amdgpu_sriov_vf(adev)) {
-		for (i = 0; i < VCN_INSTANCES_SIENNA_CICHLID; i++)
-			if (amdgpu_vcn_is_disabled_vcn(adev, VCN_DECODE_RING, i))
-				adev->vcn.num_vcn_inst++;
+		adev->vcn.num_vcn_inst = VCN_INSTANCES_SIENNA_CICHLID;
 		adev->vcn.harvest_config = 0;
 		adev->vcn.num_enc_rings = 1;
 
@@ -151,8 +149,7 @@ static int vcn_v3_0_sw_init(void *handle)
 		adev->firmware.fw_size +=
 			ALIGN(le32_to_cpu(hdr->ucode_size_bytes), PAGE_SIZE);
 
-		if ((adev->vcn.num_vcn_inst == VCN_INSTANCES_SIENNA_CICHLID) ||
-		    (amdgpu_sriov_vf(adev) && adev->asic_type == CHIP_SIENNA_CICHLID)) {
+		if (adev->vcn.num_vcn_inst == VCN_INSTANCES_SIENNA_CICHLID) {
 			adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1].ucode_id = AMDGPU_UCODE_ID_VCN1;
 			adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1].fw = adev->vcn.fw;
 			adev->firmware.fw_size +=
@@ -322,18 +319,28 @@ static int vcn_v3_0_hw_init(void *handle)
 				continue;
 
 			ring = &adev->vcn.inst[i].ring_dec;
-			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 (amdgpu_vcn_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_enc_ring_set_wptr(ring);
+				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 (amdgpu_vcn_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;
+				}
+			}
 		}
 	} else {
 		for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Acked-by on v2 1/1
#1 lore raw
Quoted 8 lines · Peng Ju Zhou

The previous logic is recording the amount of valid vcn instances to use them on SRIOV, it is a hard task due to the vcn accessment is based on the index of the vcn instance.

Check if the vcn instance enabled before do instance init.

Quoted 69 lines
---
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 33 ++++++++++++++++-----------
 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +20 -14
index c3580de3ea9c..d11fea2c9d90 100644
@@ -88,9 +88,7 @@ static int vcn_v3_0_early_init(void *handle)
        int i;
 
        if (amdgpu_sriov_vf(adev)) {
-               for (i = 0; i < VCN_INSTANCES_SIENNA_CICHLID; i++)
-                       if (amdgpu_vcn_is_disabled_vcn(adev, VCN_DECODE_RING, i))
-                               adev->vcn.num_vcn_inst++;
+               adev->vcn.num_vcn_inst = VCN_INSTANCES_SIENNA_CICHLID;
                adev->vcn.harvest_config = 0;
                adev->vcn.num_enc_rings = 1;
 
@@ -151,8 +149,7 @@ static int vcn_v3_0_sw_init(void *handle)
                adev->firmware.fw_size +=
                        ALIGN(le32_to_cpu(hdr->ucode_size_bytes), PAGE_SIZE);
 
-               if ((adev->vcn.num_vcn_inst == VCN_INSTANCES_SIENNA_CICHLID) ||
-                   (amdgpu_sriov_vf(adev) && adev->asic_type == CHIP_SIENNA_CICHLID)) {
+               if (adev->vcn.num_vcn_inst == VCN_INSTANCES_SIENNA_CICHLID) {
                        adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1].ucode_id = AMDGPU_UCODE_ID_VCN1;
                        adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1].fw = adev->vcn.fw;
                        adev->firmware.fw_size +=
@@ -322,18 +319,28 @@ static int vcn_v3_0_hw_init(void *handle)
                                continue;
 
                        ring = &adev->vcn.inst[i].ring_dec;
-                       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 (amdgpu_vcn_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_enc_ring_set_wptr(ring);
+                               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 (amdgpu_vcn_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;
+                               }
+                       }
                }
        } else {
                for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
--

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

Reviewed-by Acked-by Alex Deucher
#2 lore raw

[AMD Official Use Only]

You might need @Liu, Leo's review as well

Thanks

------------------------------------------
Monk Liu | Cloud-GPU Core team
------------------------------------------

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Wednesday, July 14, 2021 10:49 PM
To: Zhou, Peng Ju <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: Re: [PATCH v2] drm/amd/amdgpu: Recovery vcn instance iterate.

Quoted 8 lines · Peng Ju Zhou

The previous logic is recording the amount of valid vcn instances to use them on SRIOV, it is a hard task due to the vcn accessment is based on the index of the vcn instance.

Check if the vcn instance enabled before do instance init.

Quoted 73 lines
---
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 33 
++++++++++++++++-----------
 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +3 -5
index c3580de3ea9c..d11fea2c9d90 100644
@@ -88,9 +88,7 @@ static int vcn_v3_0_early_init(void *handle)
        int i;
 
        if (amdgpu_sriov_vf(adev)) {
-               for (i = 0; i < VCN_INSTANCES_SIENNA_CICHLID; i++)
-                       if (amdgpu_vcn_is_disabled_vcn(adev, VCN_DECODE_RING, i))
-                               adev->vcn.num_vcn_inst++;
+               adev->vcn.num_vcn_inst = VCN_INSTANCES_SIENNA_CICHLID;
                adev->vcn.harvest_config = 0;
                adev->vcn.num_enc_rings = 1;
 
@@ -151,8 +149,7 @@ static int vcn_v3_0_sw_init(void *handle)
                adev->firmware.fw_size +=
                        ALIGN(le32_to_cpu(hdr->ucode_size_bytes), 
 PAGE_SIZE);
 
-               if ((adev->vcn.num_vcn_inst == VCN_INSTANCES_SIENNA_CICHLID) ||
-                   (amdgpu_sriov_vf(adev) && adev->asic_type == CHIP_SIENNA_CICHLID)) {
+               if (adev->vcn.num_vcn_inst == 
+ VCN_INSTANCES_SIENNA_CICHLID) {
                        adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1].ucode_id = AMDGPU_UCODE_ID_VCN1;
                        adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1].fw = adev->vcn.fw;
                        adev->firmware.fw_size += @@ -322,18 +319,28 

@@ static int vcn_v3_0_hw_init(void *handle)

                                continue;

                        ring = &adev->vcn.inst[i].ring_dec;
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +18 -9
-                       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 (amdgpu_vcn_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_enc_ring_set_wptr(ring);
+                               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 (amdgpu_vcn_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;
+                               }
+                       }
                }
        } else {
                for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
--

2.17.1

Quoted 10 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flist
s.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7Cmo nk.liu%40amd.com%7Ceee0db55446b43f11a5d08d946d69bda%7C3dd8961fe4884e60 8e11a82d994e183d%7C0%7C0%7C637618709836027968%7CUnknown%7CTWFpbGZsb3d8 eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1 000&amp;sdata=0lw4us%2FTz66cgN6I0kQSwQDQzYRKfa2VuSBemqDMhcs%3D&amp;res erved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7Cmonk.liu%40amd.com%7Ceee0db55446b43f11a5d08d946d69bda%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637618709836027968%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=0lw4us%2FTz66cgN6I0kQSwQDQzYRKfa2VuSBemqDMhcs%3D&amp;reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw

[AMD Official Use Only]

Hi @Liu, Leo

Can you help to review this patch?
Monk and Alex have reviewed it.

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

Quoted 140 lines

-----Original Message-----
From: Liu, Monk <[email protected]>
Sent: Thursday, July 15, 2021 7:54 AM
To: Alex Deucher <[email protected]>; Zhou, Peng Ju <[email protected]>; Liu, Leo <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: RE: [PATCH v2] drm/amd/amdgpu: Recovery vcn instance iterate.

[AMD Official Use Only]

You might need @Liu, Leo's review as well

Thanks

------------------------------------------
Monk Liu | Cloud-GPU Core team
------------------------------------------

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Wednesday, July 14, 2021 10:49 PM
To: Zhou, Peng Ju <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: Re: [PATCH v2] drm/amd/amdgpu: Recovery vcn instance iterate.

Quoted 8 lines · Peng Ju Zhou

The previous logic is recording the amount of valid vcn instances to use them on SRIOV, it is a hard task due to the vcn accessment is based on the index of the vcn instance.

Check if the vcn instance enabled before do instance init.

Quoted 22 lines
---
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 33
++++++++++++++++-----------
 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +1 -3
index c3580de3ea9c..d11fea2c9d90 100644
@@ -88,9 +88,7 @@ static int vcn_v3_0_early_init(void *handle)
        int i;
 
        if (amdgpu_sriov_vf(adev)) {
-               for (i = 0; i < VCN_INSTANCES_SIENNA_CICHLID; i++)
-                       if (amdgpu_vcn_is_disabled_vcn(adev, VCN_DECODE_RING, i))
-                               adev->vcn.num_vcn_inst++;
+               adev->vcn.num_vcn_inst = VCN_INSTANCES_SIENNA_CICHLID;
                adev->vcn.harvest_config = 0;
                adev->vcn.num_enc_rings = 1;
 

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

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +0 -1
@@ -151,8 +149,7 @@ static int vcn_v3_0_sw_init(void *handle)
                adev->firmware.fw_size +=
                        ALIGN(le32_to_cpu(hdr->ucode_size_bytes),
 PAGE_SIZE);
 
-               if ((adev->vcn.num_vcn_inst == VCN_INSTANCES_SIENNA_CICHLID)
||
> -                   (amdgpu_sriov_vf(adev) && adev->asic_type ==

CHIP_SIENNA_CICHLID)) {

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

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +2 -0
+               if (adev->vcn.num_vcn_inst ==
+ VCN_INSTANCES_SIENNA_CICHLID) {
                        adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1].ucode_id =

AMDGPU_UCODE_ID_VCN1;

Quoted 7 lines
                        adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1].fw = adev-
vcn.fw;
                        adev->firmware.fw_size += @@ -322,18 +319,28
@@ static int vcn_v3_0_hw_init(void *handle)
                                continue;

                        ring = &adev->vcn.inst[i].ring_dec;

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

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +1 -7
-                       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 (amdgpu_vcn_is_disabled_vcn(adev, VCN_DECODE_RING, i))

{

drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +2 -0
+                               ring->sched.ready = false;
+                               dev_info(adev->dev, "ring %s is disabled by hypervisor\n",

ring->name);

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

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +6 -1
+                       } else {
                                ring->wptr = 0;
                                ring->wptr_old = 0;
-                               vcn_v3_0_enc_ring_set_wptr(ring);
+                               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 (amdgpu_vcn_is_disabled_vcn(adev,

VCN_ENCODE_RING, i)) {

drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +2 -0
+                                       ring->sched.ready = false;
+                                       dev_info(adev->dev, "ring %s is disabled by

hypervisor\n", ring->name);

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +7 -1
+                               } else {
+                                       ring->wptr = 0;
+                                       ring->wptr_old = 0;
+                                       vcn_v3_0_enc_ring_set_wptr(ring);
+                                       ring->sched.ready = true;
+                               }
+                       }
                }
        } else {
                for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
--

2.17.1

Quoted 5 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flist
s.freedesktop.org%2Fmailman%2Flistinfo%2Famd-

gfx&amp;data=04%7C01%7Cmo

Quoted 1 line

nk.liu%40amd.com%7Ceee0db55446b43f11a5d08d946d69bda%7C3dd8961fe4 884e60

Quoted 1 line

8e11a82d994e183d%7C0%7C0%7C637618709836027968%7CUnknown%7CTW FpbGZsb3d8

Quoted 1 line

eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D %7C1

Quoted 1 line

000&amp;sdata=0lw4us%2FTz66cgN6I0kQSwQDQzYRKfa2VuSBemqDMhcs%3D &amp;res

Quoted 1 line

erved=0

Quoted 10 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.fr
eedesktop.org%2Fmailman%2Flistinfo%2Famd- gfx&amp;data=04%7C01%7Cmonk.liu%40amd.com%7Ceee0db55446b43f11a5 d08d946d69bda%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637 618709836027968%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=0lw4 us%2FTz66cgN6I0kQSwQDQzYRKfa2VuSBemqDMhcs%3D&amp;reserved=0

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

#4 lore raw

[AMD Official Use Only]

Hi Leo
Can you help to review this patch?

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

Quoted 188 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Zhou, Peng Ju
Sent: Friday, July 16, 2021 10:15 AM
To: Liu, Monk <[email protected]>; Alex Deucher <[email protected]>; Liu, Leo <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: RE: [PATCH v2] drm/amd/amdgpu: Recovery vcn instance iterate.

[AMD Official Use Only]

Hi @Liu, Leo

Can you help to review this patch?
Monk and Alex have reviewed it.

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

Quoted 29 lines

-----Original Message-----
From: Liu, Monk <[email protected]>
Sent: Thursday, July 15, 2021 7:54 AM
To: Alex Deucher <[email protected]>; Zhou, Peng Ju <[email protected]>; Liu, Leo <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: RE: [PATCH v2] drm/amd/amdgpu: Recovery vcn instance iterate.

[AMD Official Use Only]

You might need @Liu, Leo's review as well

Thanks

------------------------------------------
Monk Liu | Cloud-GPU Core team
------------------------------------------

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Wednesday, July 14, 2021 10:49 PM
To: Zhou, Peng Ju <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: Re: [PATCH v2] drm/amd/amdgpu: Recovery vcn instance iterate.

On Tue, Jul 13, 2021 at 6:31 AM Peng Ju Zhou <[email protected]>

Quoted 32 lines · wrote:
Quoted 8 lines

The previous logic is recording the amount of valid vcn instances to use them on SRIOV, it is a hard task due to the vcn accessment is based on the index of the vcn instance.

Check if the vcn instance enabled before do instance init.

Quoted 21 lines
---
 drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 33
++++++++++++++++-----------
 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +1 -3
index c3580de3ea9c..d11fea2c9d90 100644
@@ -88,9 +88,7 @@ static int vcn_v3_0_early_init(void *handle)
        int i;
 
        if (amdgpu_sriov_vf(adev)) {
-               for (i = 0; i < VCN_INSTANCES_SIENNA_CICHLID; i++)
-                       if (amdgpu_vcn_is_disabled_vcn(adev, VCN_DECODE_RING, i))
-                               adev->vcn.num_vcn_inst++;
+               adev->vcn.num_vcn_inst = VCN_INSTANCES_SIENNA_CICHLID;
                adev->vcn.harvest_config = 0;
                adev->vcn.num_enc_rings = 1;
 
Quoted 6 lines

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

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +0 -1
@@ -151,8 +149,7 @@ static int vcn_v3_0_sw_init(void *handle)
                adev->firmware.fw_size +=
                        ALIGN(le32_to_cpu(hdr->ucode_size_bytes),
 PAGE_SIZE);
 
-               if ((adev->vcn.num_vcn_inst ==

VCN_INSTANCES_SIENNA_CICHLID)

Quoted 6 lines
||
> -                   (amdgpu_sriov_vf(adev) && adev->asic_type ==

CHIP_SIENNA_CICHLID)) {

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +2 -0
+               if (adev->vcn.num_vcn_inst ==
+ VCN_INSTANCES_SIENNA_CICHLID) {
                        adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1].ucode_id

=

Quoted 2 lines

AMDGPU_UCODE_ID_VCN1;

Quoted 1 line
                        adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1].fw =

adev-

Quoted 5 lines
Quoted 5 lines
vcn.fw;
                        adev->firmware.fw_size += @@ -322,18 +319,28
@@ static int vcn_v3_0_hw_init(void *handle)
                                continue;
Quoted 9 lines

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

Quoted 9 lines
                        ring = &adev->vcn.inst[i].ring_dec;
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +1 -7
-                       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 (amdgpu_vcn_is_disabled_vcn(adev, VCN_DECODE_RING,

i))

Quoted 3 lines

{

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +2 -0
+                               ring->sched.ready = false;
+                               dev_info(adev->dev, "ring %s is disabled by

hypervisor\n",

Quoted 29 lines

ring->name);

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

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +6 -1
+                       } else {
                                ring->wptr = 0;
                                ring->wptr_old = 0;
-                               vcn_v3_0_enc_ring_set_wptr(ring);
+                               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 (amdgpu_vcn_is_disabled_vcn(adev,

VCN_ENCODE_RING, i)) {

drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +2 -0
+                                       ring->sched.ready = false;
+                                       dev_info(adev->dev, "ring %s is disabled by

hypervisor\n", ring->name);

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +7 -1
+                               } else {
+                                       ring->wptr = 0;
+                                       ring->wptr_old = 0;
+                                       vcn_v3_0_enc_ring_set_wptr(ring);
+                                       ring->sched.ready = true;
+                               }
+                       }
                }
        } else {
                for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
--

2.17.1

Quoted 8 lines
Quoted 5 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flist
s.freedesktop.org%2Fmailman%2Flistinfo%2Famd-

gfx&amp;data=04%7C01%7Cmo

Quoted 1 line

nk.liu%40amd.com%7Ceee0db55446b43f11a5d08d946d69bda%7C3dd8961fe4

Quoted 3 lines

884e60

Quoted 1 line

8e11a82d994e183d%7C0%7C0%7C637618709836027968%7CUnknown%7CTW

Quoted 3 lines

FpbGZsb3d8

Quoted 1 line

eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D

Quoted 3 lines

%7C1

Quoted 1 line

000&amp;sdata=0lw4us%2FTz66cgN6I0kQSwQDQzYRKfa2VuSBemqDMhcs%3D

Quoted 6 lines

&amp;res

Quoted 1 line

erved=0

_______________________________________________
amd-gfx mailing list
[email protected]

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.fr

Quoted 2 lines

eedesktop.org%2Fmailman%2Flistinfo%2Famd-

gfx&amp;data=04%7C01%7Cmonk.liu%40amd.com%7Ceee0db55446b43f11a5

Quoted 1 line

d08d946d69bda%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637

Quoted 1 line

618709836027968%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL

Quoted 1 line

CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=0lw4

Quoted 1 line

us%2FTz66cgN6I0kQSwQDQzYRKfa2VuSBemqDMhcs%3D&amp;reserved=0

Quoted 10 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.fr
eedesktop.org%2Fmailman%2Flistinfo%2Famd- gfx&amp;data=04%7C01%7CPengju.Zhou%40amd.com%7C954d8355dd564f7a 5d4c08d947ff8051%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C6 37619984967610886%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDA iLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=Rjt b0ufSZEt%2B6GFS%2FaXK4YA%2FbNeXr7ptGyFPBLut994%3D&amp;reserved=0

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

#5 lore raw
In reply to Zhou, Peng Ju

It looks good to me for the non-sriov part.

Regards,

Leo

Quoted 4 lines · Peng Ju

[AMD Official Use Only]

Hi @Liu, Leo

Quoted 154 lines

Can you help to review this patch?
Monk and Alex have reviewed it.

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

Quoted 144 lines

-----Original Message-----
From: Liu, Monk <[email protected]>
Sent: Thursday, July 15, 2021 7:54 AM
To: Alex Deucher <[email protected]>; Zhou, Peng Ju <[email protected]>; Liu, Leo <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: RE: [PATCH v2] drm/amd/amdgpu: Recovery vcn instance iterate.

[AMD Official Use Only]

You might need @Liu, Leo's review as well

Thanks

------------------------------------------
Monk Liu | Cloud-GPU Core team
------------------------------------------

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Wednesday, July 14, 2021 10:49 PM
To: Zhou, Peng Ju <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: Re: [PATCH v2] drm/amd/amdgpu: Recovery vcn instance iterate.

Quoted 7 lines · Peng Ju Zhou

The previous logic is recording the amount of valid vcn instances to use them on SRIOV, it is a hard task due to the vcn accessment is based on the index of the vcn instance.

Check if the vcn instance enabled before do instance init.

Quoted 22 lines
---
  drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 33
++++++++++++++++-----------
  1 file changed, 20 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +1 -3
index c3580de3ea9c..d11fea2c9d90 100644
@@ -88,9 +88,7 @@ static int vcn_v3_0_early_init(void *handle)
         int i;
 
         if (amdgpu_sriov_vf(adev)) {
-               for (i = 0; i < VCN_INSTANCES_SIENNA_CICHLID; i++)
-                       if (amdgpu_vcn_is_disabled_vcn(adev, VCN_DECODE_RING, i))
-                               adev->vcn.num_vcn_inst++;
+               adev->vcn.num_vcn_inst = VCN_INSTANCES_SIENNA_CICHLID;
                 adev->vcn.harvest_config = 0;
                 adev->vcn.num_enc_rings = 1;
 

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

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +0 -1
@@ -151,8 +149,7 @@ static int vcn_v3_0_sw_init(void *handle)
                 adev->firmware.fw_size +=
                         ALIGN(le32_to_cpu(hdr->ucode_size_bytes),
 PAGE_SIZE);
 
-               if ((adev->vcn.num_vcn_inst == VCN_INSTANCES_SIENNA_CICHLID)
||
> -                   (amdgpu_sriov_vf(adev) && adev->asic_type ==

CHIP_SIENNA_CICHLID)) {

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

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +2 -0
+               if (adev->vcn.num_vcn_inst ==
+ VCN_INSTANCES_SIENNA_CICHLID) {
                         adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1].ucode_id =

AMDGPU_UCODE_ID_VCN1;

Quoted 7 lines
                         adev->firmware.ucode[AMDGPU_UCODE_ID_VCN1].fw = adev-
vcn.fw;
                         adev->firmware.fw_size += @@ -322,18 +319,28
@@ static int vcn_v3_0_hw_init(void *handle)
                                 continue;

                         ring = &adev->vcn.inst[i].ring_dec;

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

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +1 -7
-                       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 (amdgpu_vcn_is_disabled_vcn(adev, VCN_DECODE_RING, i))

{

drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +2 -0
+                               ring->sched.ready = false;
+                               dev_info(adev->dev, "ring %s is disabled by hypervisor\n",

ring->name);

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

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +6 -1
+                       } else {
                                 ring->wptr = 0;
                                 ring->wptr_old = 0;
-                               vcn_v3_0_enc_ring_set_wptr(ring);
+                               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 (amdgpu_vcn_is_disabled_vcn(adev,

VCN_ENCODE_RING, i)) {

drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +2 -0
+                                       ring->sched.ready = false;
+                                       dev_info(adev->dev, "ring %s is disabled by

hypervisor\n", ring->name);

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +7 -1
+                               } else {
+                                       ring->wptr = 0;
+                                       ring->wptr_old = 0;
+                                       vcn_v3_0_enc_ring_set_wptr(ring);
+                                       ring->sched.ready = true;
+                               }
+                       }
                 }
         } else {
                 for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
--

2.17.1

Quoted 5 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flist
s.freedesktop.org%2Fmailman%2Flistinfo%2Famd-

gfx&amp;data=04%7C01%7Cmo nk.liu%40amd.com%7Ceee0db55446b43f11a5d08d946d69bda%7C3dd8961fe4 884e60 8e11a82d994e183d%7C0%7C0%7C637618709836027968%7CUnknown%7CTW FpbGZsb3d8 eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D %7C1 000&amp;sdata=0lw4us%2FTz66cgN6I0kQSwQDQzYRKfa2VuSBemqDMhcs%3D &amp;res

Quoted 1 line

erved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.fr
eedesktop.org%2Fmailman%2Flistinfo%2Famd- gfx&amp;data=04%7C01%7Cmonk.liu%40amd.com%7Ceee0db55446b43f11a5 d08d946d69bda%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637 618709836027968%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=0lw4 us%2FTz66cgN6I0kQSwQDQzYRKfa2VuSBemqDMhcs%3D&amp;reserved=0

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