drm/amdgpu: enhance amdgpu_vcn_suspend
Subsystems (2)
PATCH 1/2 drm/amdgpu: enhance amdgpu_vcn_suspend
During vcn suspends, stop ring continue to receive new requests, and try to wait for all vcn jobs to finish gracefully.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +19 -1
@@ -275,9 +275,27 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev) {unsigned size;void *ptr; +int retry_max =6 ;int i; -cancel_delayed_work_sync (&adev->vcn.idle_work); +for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) { +if (adev->vcn.harvest_config & (1 << i)) +continue ; + ring = &adev->vcn.inst[i].ring_dec; + ring->sched.ready = false; + +for (j =0 ; j < adev->vcn.num_enc_rings; ++j) { + ring = &adev->vcn.inst[i].ring_enc[j]; + ring->sched.ready = false; + } + } + +while (retry_max--) { +if (cancel_delayed_work_sync (&adev->vcn.idle_work)) { +dev_warn (adev->dev,"Waiting for left VCN job(s) to finish gracefully ..." ); +mdelay (5 ); + } + }for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) {if (adev->vcn.harvest_config & (1 << i))
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/2 drm/amdgpu: remove unsued vcn_v3_0_hw_fini
Removed unsued vcn_v3_0_hw_fini when enhanced
common amdgpu_vicn_suspend is applied.
--- drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +0 -4
@@ -411,10 +411,6 @@ static int vcn_v3_0_suspend(void *handle)int r;struct amdgpu_device *adev = (struct amdgpu_device *)handle; - r =vcn_v3_0_hw_fini (adev); -if (r) -return r; - r =amdgpu_vcn_suspend (adev);return r;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v2 1/2 drm/amdgpu: enhance amdgpu_vcn_suspend
In reply to James ZhuDuring vcn suspends, stop ring continue to receive new requests, and try to wait for all vcn jobs to finish gracefully.
v2: Forced powering gate vcn hardware after few wainting retry.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +21 -1
@@ -275,9 +275,29 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev) {unsigned size;void *ptr; +int retry_max =6 ;int i; -cancel_delayed_work_sync (&adev->vcn.idle_work); +for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) { +if (adev->vcn.harvest_config & (1 << i)) +continue ; + ring = &adev->vcn.inst[i].ring_dec; + ring->sched.ready = false; + +for (j =0 ; j < adev->vcn.num_enc_rings; ++j) { + ring = &adev->vcn.inst[i].ring_enc[j]; + ring->sched.ready = false; + } + } + +while (retry_max-- &&cancel_delayed_work_sync (&adev->vcn.idle_work)) +mdelay (5 ); +if (!retry_max && !amdgpu_sriov_vf (adev)) { +if (RREG32_SOC15 (VCN , i, mmUVD_STATUS)) { +dev_warn (adev->dev,"Forced powering gate vcn hardware!" ); +vcn_v3_0_set_powergating_state (adev,AMD_PG_STATE_GATE ); + } + }for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) {if (adev->vcn.harvest_config & (1 << i))
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 26 lines · James Zhu
During vcn suspends, stop ring continue to receive new requests, and try to wait for all vcn jobs to finish gracefully.
v2: Forced powering gate vcn hardware after few wainting retry.
Signed-off-by James Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +5
-1@@ -275,9 +275,29 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev) {unsigned size;void *ptr; +int retry_max =6 ;int i; -cancel_delayed_work_sync (&adev->vcn.idle_work); +for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) { +if (adev->vcn.harvest_config & (1 << i)) +continue ; + ring = &adev->vcn.inst[i].ring_dec;
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c int amdgpu_vcn_suspend(struct amdgpu_device *adev) · line 294
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +10
-0+ ring->sched.ready = false; + +for (j =0 ; j < adev->vcn.num_enc_rings; ++j) { + ring = &adev->vcn.inst[i].ring_enc[j]; + ring->sched.ready = false; + } + } + +while (retry_max-- &&cancel_delayed_work_sync (&adev->vcn.idle_work)) +mdelay (5 );
I think it's possible to have one pending job unprocessed with VCN when suspend sequence getting here, but it shouldn't be more than one, cancel_delayed_work_sync probably return false after the first time, so calling cancel_delayed_work_sync once should be enough here. we probably need to wait longer from:
SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1, UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);
to make sure the unprocessed job get done.
Regards,
Leo
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c int amdgpu_vcn_suspend(struct amdgpu_device *adev) · line 303
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0+if (!retry_max && !amdgpu_sriov_vf (adev)) { +if (RREG32_SOC15 (VCN , i, mmUVD_STATUS)) { +dev_warn (adev->dev,"Forced powering gate vcn hardware!" ); +vcn_v3_0_set_powergating_state (adev,AMD_PG_STATE_GATE ); + } + }for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) {if (adev->vcn.harvest_config & (1 << i))
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
I am wondering if there are still some jobs kept in the queue, it is lucky to check
UVD_POWER_STATUS done, but after, fw start a new job that list in the queue.
To handle this situation perfectly, we need add mechanism to suspend fw first.
Another case, if it is unlucky, that vcn fw hung at that time, UVD_POWER_STATUS
always keeps busy. then it needs force powering gate the vcn hw after certain time waiting.
Best Regards!
James
Quoted 44 lines · Leo Liu
Quoted 26 lines · James Zhu
During vcn suspends, stop ring continue to receive new requests, and try to wait for all vcn jobs to finish gracefully.
v2: Forced powering gate vcn hardware after few wainting retry.
Signed-off-by James Zhu <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c| 22 +++++++++++++++++++++-1 file changed, 21 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0@@ -275,9 +275,29 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev) { unsigned size; void *ptr; + int retry_max = 6; int i; - cancel_delayed_work_sync(&adev->vcn.idle_work); + for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { + if (adev->vcn.harvest_config & (1 << i)) + continue; + ring = &adev->vcn.inst[i].ring_dec; + ring->sched.ready = false;drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c int amdgpu_vcn_suspend(struct amdgpu_device *adev) · line 295
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +9
-0+ + for (j = 0; j < adev->vcn.num_enc_rings; ++j) { + ring = &adev->vcn.inst[i].ring_enc[j]; + ring->sched.ready = false; + } + } + + while (retry_max-- &&cancel_delayed_work_sync (&adev->vcn.idle_work)) + mdelay(5);I think it's possible to have one pending job unprocessed with VCN when suspend sequence getting here, but it shouldn't be more than one,
cancel_delayed_work_syncprobably return false after the first time, so callingcancel_delayed_work_synconce should be enough here. we probably need to wait longer from:
SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1, UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);
Quoted 16 lines
to make sure the unprocessed job get done.
Regards,
Leo
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0+ if (!retry_max && !amdgpu_sriov_vf(adev)) { + if (RREG32_SOC15(VCN, i, mmUVD_STATUS)) { + dev_warn(adev->dev, "Forced powering gate vcn hardware!"); + vcn_v3_0_set_powergating_state(adev, AMD_PG_STATE_GATE); + } + } for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { if (adev->vcn.harvest_config & (1 << i))
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 1 line · James Zhu
I am wondering if there are still some jobs kept in the queue, it is lucky to check
Yes it's possible, in this case delayed handler is set, so cancelling once is enough.
Quoted 4 lines
UVD_POWER_STATUSdone, but after, fw start a new job that list in the queue.To handle this situation perfectly, we need add mechanism to suspend fw first.
I think that should be handled by the sequence from vcn_v3_0_stop_dpg_mode().
Quoted 4 lines
Another case, if it is unlucky, that vcn fw hung at that time,
UVD_POWER_STATUSalways keeps busy. then it needs force powering gate the vcn hw after certain time waiting.
Yep, we still need to gate VCN power after certain timeout.
Regards,
Leo
Quoted 66 lines
Best Regards!
James
Quoted 60 lines · Leo Liu
Quoted 26 lines · James Zhu
During vcn suspends, stop ring continue to receive new requests, and try to wait for all vcn jobs to finish gracefully.
v2: Forced powering gate vcn hardware after few wainting retry.
Signed-off-by James Zhu <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c| 22 +++++++++++++++++++++-1 file changed, 21 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0@@ -275,9 +275,29 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev) { unsigned size; void *ptr; + int retry_max = 6; int i; - cancel_delayed_work_sync(&adev->vcn.idle_work); + for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { + if (adev->vcn.harvest_config & (1 << i)) + continue; + ring = &adev->vcn.inst[i].ring_dec; + ring->sched.ready = false;drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c int amdgpu_vcn_suspend(struct amdgpu_device *adev) · line 295
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +9
-0+ + for (j = 0; j < adev->vcn.num_enc_rings; ++j) { + ring = &adev->vcn.inst[i].ring_enc[j]; + ring->sched.ready = false; + } + } + + while (retry_max-- &&cancel_delayed_work_sync (&adev->vcn.idle_work)) + mdelay(5);I think it's possible to have one pending job unprocessed with VCN when suspend sequence getting here, but it shouldn't be more than one,
cancel_delayed_work_syncprobably return false after the first time, so callingcancel_delayed_work_synconce should be enough here. we probably need to wait longer from:
SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1, UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);to make sure the unprocessed job get done.
Regards,
Leo
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0+ if (!retry_max && !amdgpu_sriov_vf(adev)) { + if (RREG32_SOC15(VCN, i, mmUVD_STATUS)) { + dev_warn(adev->dev, "Forced powering gate vcn hardware!"); + vcn_v3_0_set_powergating_state(adev, AMD_PG_STATE_GATE); + } + } for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { if (adev->vcn.harvest_config & (1 << i))
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Then we forgot the proposal I provided before.
I think the below seq may fixed the race condition issue that we are facing.
1. stop scheduling new jobs
for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { if (adev->vcn.harvest_config & (1 << i)) continue;
ring = &adev->vcn.inst[i].ring_dec;
ring->sched.ready = false;
for (j = 0; j < adev->vcn.num_enc_rings; ++j) { ring = &adev->vcn.inst[i].ring_enc[j]; ring->sched.ready = false;
}
}
2. cancel_delayed_work_sync(&adev->vcn.idle_work);
3. SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1, UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);
4. amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN, AMD_PG_STATE_GATE);
5. saved_bo
Best Regards!
James
Quoted 18 lines · Leo Liu
Quoted 1 line · James Zhu
I am wondering if there are still some jobs kept in the queue, it is lucky to check
Yes it's possible, in this case delayed handler is set, so cancelling once is enough.
Quoted 4 lines
UVD_POWER_STATUSdone, but after, fw start a new job that list in the queue.To handle this situation perfectly, we need add mechanism to suspend fw first.
I think that should be handled by the sequence from
vcn_v3_0_stop_dpg_mode().Quoted 3 lines
Another case, if it is unlucky, that vcn fw hung at that time,
UVD_POWER_STATUS
Quoted 79 lines
Quoted 1 line
always keeps busy. then it needs force powering gate the vcn hw after certain time waiting.
Yep, we still need to gate VCN power after certain timeout.
Regards,
Leo
Quoted 68 lines
Best Regards!
James
Quoted 62 lines · Leo Liu
Quoted 27 lines · James Zhu
During vcn suspends, stop ring continue to receive new requests, and try to wait for all vcn jobs to finish gracefully.
v2: Forced powering gate vcn hardware after few wainting retry.
Signed-off-by James Zhu <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c| 22 +++++++++++++++++++++-1 file changed, 21 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0@@ -275,9 +275,29 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev) { unsigned size; void *ptr; + int retry_max = 6; int i; - cancel_delayed_work_sync(&adev->vcn.idle_work); + for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { + if (adev->vcn.harvest_config & (1 << i)) + continue; + ring = &adev->vcn.inst[i].ring_dec; + ring->sched.ready = false;drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c int amdgpu_vcn_suspend(struct amdgpu_device · line 296
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +9
-0+ + for (j = 0; j < adev->vcn.num_enc_rings; ++j) { + ring = &adev->vcn.inst[i].ring_enc[j]; + ring->sched.ready = false; + } + } + + while (retry_max-- &&cancel_delayed_work_sync (&adev->vcn.idle_work)) + mdelay(5);I think it's possible to have one pending job unprocessed with VCN when suspend sequence getting here, but it shouldn't be more than one,
cancel_delayed_work_syncprobably return false after the first time, so callingcancel_delayed_work_synconce should be enough here. we probably need to wait longer from:
SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1, UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);to make sure the unprocessed job get done.
Regards,
Leo
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0+ if (!retry_max && !amdgpu_sriov_vf(adev)) { + if (RREG32_SOC15(VCN, i, mmUVD_STATUS)) { + dev_warn(adev->dev, "Forced powering gate vcn hardware!"); + vcn_v3_0_set_powergating_state(adev, AMD_PG_STATE_GATE); + } + }for (i = 0; i <
adev->vcn.num_vcn_inst; ++i) { if (adev->vcn.harvest_config& (1 << i))
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Definitely, we need to move cancel_delayed_work_sync moved to before power gate.
Should "save_bo" be step 4 before power gate ?
Regards,
Leo
Quoted 27 lines · James Zhu
Then we forgot the proposal I provided before.
I think the below seq may fixed the race condition issue that we are facing.
1. stop scheduling new jobs
for (i = 0; i <
adev->vcn.num_vcn_inst; ++i) { if (adev->vcn.harvest_config& (1 << i)) continue;ring = &adev->vcn.inst[i].ring_dec;
ring->sched.ready= false;for (j = 0; j <
adev->vcn.num_enc_rings; ++j) { ring = &adev->vcn.inst[i].ring_enc[j];ring->sched.ready= false;
}
}2.
cancel_delayed_work_sync(&adev->vcn.idle_work);3.
SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1, UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);4.
amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN, AMD_PG_STATE_GATE);
Quoted 104 lines
5.
saved_boBest Regards!
James
Quoted 97 lines · Leo Liu
Quoted 1 line · James Zhu
I am wondering if there are still some jobs kept in the queue, it is lucky to check
Yes it's possible, in this case delayed handler is set, so cancelling once is enough.
Quoted 4 lines
UVD_POWER_STATUSdone, but after, fw start a new job that list in the queue.To handle this situation perfectly, we need add mechanism to suspend fw first.
I think that should be handled by the sequence from
vcn_v3_0_stop_dpg_mode().Quoted 4 lines
Another case, if it is unlucky, that vcn fw hung at that time,
UVD_POWER_STATUSalways keeps busy. then it needs force powering gate the vcn hw after certain time waiting.
Yep, we still need to gate VCN power after certain timeout.
Regards,
Leo
Quoted 68 lines
Best Regards!
James
Quoted 62 lines · Leo Liu
Quoted 27 lines · James Zhu
During vcn suspends, stop ring continue to receive new requests, and try to wait for all vcn jobs to finish gracefully.
v2: Forced powering gate vcn hardware after few wainting retry.
Signed-off-by James Zhu <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c| 22 +++++++++++++++++++++-1 file changed, 21 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0@@ -275,9 +275,29 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev) { unsigned size; void *ptr; + int retry_max = 6; int i; - cancel_delayed_work_sync(&adev->vcn.idle_work); + for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { + if (adev->vcn.harvest_config & (1 << i)) + continue; + ring = &adev->vcn.inst[i].ring_dec; + ring->sched.ready = false;drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c int amdgpu_vcn_suspend(struct amdgpu_device · line 296
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +9
-0+ + for (j = 0; j < adev->vcn.num_enc_rings; ++j) { + ring = &adev->vcn.inst[i].ring_enc[j]; + ring->sched.ready = false; + } + } + + while (retry_max-- &&cancel_delayed_work_sync (&adev->vcn.idle_work)) + mdelay(5);I think it's possible to have one pending job unprocessed with VCN when suspend sequence getting here, but it shouldn't be more than one,
cancel_delayed_work_syncprobably return false after the first time, so callingcancel_delayed_work_synconce should be enough here. we probably need to wait longer from:
SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1, UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);to make sure the unprocessed job get done.
Regards,
Leo
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0+ if (!retry_max && !amdgpu_sriov_vf(adev)) { + if (RREG32_SOC15(VCN, i, mmUVD_STATUS)) { + dev_warn(adev->dev, "Forced powering gate vcn hardware!"); + vcn_v3_0_set_powergating_state(adev, AMD_PG_STATE_GATE); + } + }for (i = 0; i <
adev->vcn.num_vcn_inst; ++i) { if (adev->vcn.harvest_config& (1 << i))
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
[AMD Official Use Only - Internal Distribution Only]
save_bo needn't ungate vcn, it just keeps data in memory.
Thanks & Best Regards!
James Zhu
________________________________
From: Liu, Leo <[email protected]>
Sent: Monday, May 17, 2021 2:07 PM
To: Zhu, James <[email protected]>; Zhu, James <[email protected]>; [email protected] <[email protected]>
Subject: Re: [PATCH v2 1/2] drm/amdgpu: enhance amdgpu_vcn_suspend
Definitely, we need to move cancel_delayed_work_sync moved to before power gate.
Should "save_bo" be step 4 before power gate ?
Regards,
Leo
On 2021-05-17 1:59 p.m., James Zhu wrote:
Then we forgot the proposal I provided before.
I think the below seq may fixed the race condition issue that we are facing.
1. stop scheduling new jobs
for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
if (adev->vcn.harvest_config & (1 << i))
continue;
ring = &adev->vcn.inst[i].ring_dec;
ring->sched.ready = false;
for (j = 0; j < adev->vcn.num_enc_rings; ++j) {
ring = &adev->vcn.inst[i].ring_enc[j];
ring->sched.ready = false;
}
}2. cancel_delayed_work_sync(&adev->vcn.idle_work);
3. SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1,
UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);
4. amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN, AMD_PG_STATE_GATE);
5. saved_bo
Best Regards!
James
On 2021-05-17 1:43 p.m., Leo Liu wrote:
On 2021-05-17 12:54 p.m., James Zhu wrote:
I am wondering if there are still some jobs kept in the queue, it is lucky to check
Yes it's possible, in this case delayed handler is set, so cancelling once is enough.
UVD_POWER_STATUS done, but after, fw start a new job that list in the queue.
To handle this situation perfectly, we need add mechanism to suspend fw first.
I think that should be handled by the sequence from vcn_v3_0_stop_dpg_mode().
Another case, if it is unlucky, that vcn fw hung at that time, UVD_POWER_STATUS
always keeps busy. then it needs force powering gate the vcn hw after certain time waiting.
Yep, we still need to gate VCN power after certain timeout.
Regards,
Leo
Best Regards!
James
On 2021-05-17 12:34 p.m., Leo Liu wrote:
On 2021-05-17 11:52 a.m., James Zhu wrote:
During vcn suspends, stop ring continue to receive new requests, and try to wait for all vcn jobs to finish gracefully.
v2: Forced powering gate vcn hardware after few wainting retry.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +15 -0
@@ -275,9 +275,29 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev) {unsigned size;void *ptr; +int retry_max =6 ;int i; -cancel_delayed_work_sync (&adev->vcn.idle_work); +for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) { +if (adev->vcn.harvest_config & (1 << i)) +continue ; + ring = &adev->vcn.inst[i].ring_dec; + ring->sched.ready = false; + +for (j =0 ; j < adev->vcn.num_enc_rings; ++j) { + ring = &adev->vcn.inst[i].ring_enc[j]; + ring->sched.ready = false; + } + } + +while (retry_max-- &&cancel_delayed_work_sync (&adev->vcn.idle_work)) +mdelay (5 );
I think it's possible to have one pending job unprocessed with VCN when suspend sequence getting here, but it shouldn't be more than one, cancel_delayed_work_sync probably return false after the first time, so calling cancel_delayed_work_sync once should be enough here. we probably need to wait longer from:
SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1,
UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);
to make sure the unprocessed job get done.
Regards,
Leo
+ if (!retry_max && !amdgpu_sriov_vf(adev)) {
+ if (RREG32_SOC15(VCN, i, mmUVD_STATUS)) {
+ dev_warn(adev->dev, "Forced powering gate vcn hardware!");
+ vcn_v3_0_set_powergating_state(adev, AMD_PG_STATE_GATE);
+ }
+ }
for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
if (adev->vcn.harvest_config & (1 << i))_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
The saved data are from the engine cache, it's the runtime of engine before suspend, it might be different after you have the engine powered off.
Regards,
Leo
Quoted 19 lines · James
[AMD Official Use Only - Internal Distribution Only]
save_boneedn't ungate vcn, it just keeps data in memory.Thanks & Best Regards!
James Zhu
------------------------------------------------------------------------
*From:* Liu, Leo <[email protected]>
*Sent:* Monday, May 17, 2021 2:07 PM
*To:* Zhu, James <[email protected]>; Zhu, James <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [PATCH v2 1/2] drm/amdgpu: enhanceamdgpu_vcn_suspendDefinitely, we need to move
cancel_delayed_work_syncmoved to before power gate.
Quoted 141 lines
Should "
save_bo" be step 4 before power gate ?Regards,
Leo
Quoted 133 lines · James Zhu
Then we forgot the proposal I provided before.
I think the below seq may fixed the race condition issue that we are facing.
1. stop scheduling new jobs
for (i = 0; i <
adev->vcn.num_vcn_inst; ++i) { if (adev->vcn.harvest_config& (1 << i)) continue;ring = &adev->vcn.inst[i].ring_dec;
ring->sched.ready= false;for (j = 0; j <
adev->vcn.num_enc_rings; ++j) { ring = &adev->vcn.inst[i].ring_enc[j];ring->sched.ready= false;
}
}2.
cancel_delayed_work_sync(&adev->vcn.idle_work);3.
SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1, UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);4.
amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN, AMD_PG_STATE_GATE);5.
saved_boBest Regards!
James
Quoted 99 lines · Leo Liu
Quoted 1 line · James Zhu
I am wondering if there are still some jobs kept in the queue, it is lucky to check
Yes it's possible, in this case delayed handler is set, so cancelling once is enough.
Quoted 4 lines
UVD_POWER_STATUSdone, but after, fw start a new job that list in the queue.To handle this situation perfectly, we need add mechanism to suspend fw first.
I think that should be handled by the sequence from
vcn_v3_0_stop_dpg_mode().Quoted 4 lines
Another case, if it is unlucky, that vcn fw hung at that time,
UVD_POWER_STATUSalways keeps busy. then it needs force powering gate the vcn hw after certain time waiting.
Yep, we still need to gate VCN power after certain timeout.
Regards,
Leo
Quoted 70 lines
Best Regards!
James
Quoted 64 lines · Leo Liu
Quoted 28 lines · James Zhu
During vcn suspends, stop ring continue to receive new requests, and try to wait for all vcn jobs to finish gracefully.
v2: Forced powering gate vcn hardware after few wainting retry.
Signed-off-by James Zhu <[email protected]> <mailto:[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c| 22
+++++++++++++++++++++-1 file changed, 21 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0@@ -275,9 +275,29 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev) { unsigned size; void *ptr; + int retry_max = 6; int i; - cancel_delayed_work_sync(&adev->vcn.idle_work); + for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { + if (adev->vcn.harvest_config & (1 << i)) + continue; + ring = &adev->vcn.inst[i].ring_dec; + ring->sched.ready = false;drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c int amdgpu_vcn_suspend(struct amdgpu_device · line 296
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +9
-0+ + for (j = 0; j < adev->vcn.num_enc_rings; ++j) { + ring = &adev->vcn.inst[i].ring_enc[j]; + ring->sched.ready = false; + } + } + + while (retry_max-- &&cancel_delayed_work_sync (&adev->vcn.idle_work)) + mdelay(5);I think it's possible to have one pending job unprocessed with VCN when suspend sequence getting here, but it shouldn't be more than one,
cancel_delayed_work_syncprobably return false after the first time, so callingcancel_delayed_work_synconce should be enough here. we probably need to wait longer from:
SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1, UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);to make sure the unprocessed job get done.
Regards,
Leo
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0+ if (!retry_max && !amdgpu_sriov_vf(adev)) { + if (RREG32_SOC15(VCN, i, mmUVD_STATUS)) { + dev_warn(adev->dev, "Forced powering gate vcn hardware!"); + vcn_v3_0_set_powergating_state(adev,AMD_PG_STATE_GATE ); + } + }for (i = 0; i <
adev->vcn.num_vcn_inst; ++i) { if (adev->vcn.harvest_config& (1 << i))
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
To be accurate, the Bo is mapped to engine cache window, and the runtime of engine stacks, so we should save it before the poweroff.
Quoted 172 lines · Leo Liu
The saved data are from the engine cache, it's the runtime of engine before suspend, it might be different after you have the engine powered off.
Regards,
Leo
Quoted 19 lines · James
[AMD Official Use Only - Internal Distribution Only]
save_boneedn't ungate vcn, it just keeps data in memory.Thanks & Best Regards!
James Zhu
------------------------------------------------------------------------
*From:* Liu, Leo <[email protected]>
*Sent:* Monday, May 17, 2021 2:07 PM
*To:* Zhu, James <[email protected]>; Zhu, James <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [PATCH v2 1/2] drm/amdgpu: enhanceamdgpu_vcn_suspendDefinitely, we need to move
cancel_delayed_work_syncmoved to before power gate.Quoted 141 lines
Should "
save_bo" be step 4 before power gate ?Regards,
Leo
Quoted 133 lines · James Zhu
Then we forgot the proposal I provided before.
I think the below seq may fixed the race condition issue that we are facing.
1. stop scheduling new jobs
for (i = 0; i <
adev->vcn.num_vcn_inst; ++i) { if (adev->vcn.harvest_config& (1 << i)) continue;ring = &adev->vcn.inst[i].ring_dec;
ring->sched.ready= false;for (j = 0; j <
adev->vcn.num_enc_rings; ++j) { ring = &adev->vcn.inst[i].ring_enc[j];ring->sched.ready= false;
}
}2.
cancel_delayed_work_sync(&adev->vcn.idle_work);3.
SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1, UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);4.
amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN, AMD_PG_STATE_GATE);5.
saved_boBest Regards!
James
Quoted 99 lines · Leo Liu
Quoted 1 line · James Zhu
I am wondering if there are still some jobs kept in the queue, it is lucky to check
Yes it's possible, in this case delayed handler is set, so cancelling once is enough.
Quoted 4 lines
UVD_POWER_STATUSdone, but after, fw start a new job that list in the queue.To handle this situation perfectly, we need add mechanism to suspend fw first.
I think that should be handled by the sequence from
vcn_v3_0_stop_dpg_mode().Quoted 4 lines
Another case, if it is unlucky, that vcn fw hung at that time,
UVD_POWER_STATUSalways keeps busy. then it needs force powering gate the vcn hw after certain time waiting.
Yep, we still need to gate VCN power after certain timeout.
Regards,
Leo
Quoted 70 lines
Best Regards!
James
Quoted 64 lines · Leo Liu
Quoted 28 lines · James Zhu
During vcn suspends, stop ring continue to receive new requests, and try to wait for all vcn jobs to finish gracefully.
v2: Forced powering gate vcn hardware after few wainting retry.
Signed-off-by James Zhu <[email protected]> <mailto:[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c| 22
+++++++++++++++++++++-1 file changed, 21 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0@@ -275,9 +275,29 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev) { unsigned size; void *ptr; + int retry_max = 6; int i; - cancel_delayed_work_sync(&adev->vcn.idle_work); + for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { + if (adev->vcn.harvest_config & (1 << i)) + continue; + ring = &adev->vcn.inst[i].ring_dec; + ring->sched.ready = false;drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c int amdgpu_vcn_suspend(struct amdgpu_device · line 296
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +9
-0+ + for (j = 0; j < adev->vcn.num_enc_rings; ++j) { + ring = &adev->vcn.inst[i].ring_enc[j]; + ring->sched.ready = false; + } + } + + while (retry_max-- &&cancel_delayed_work_sync (&adev->vcn.idle_work)) + mdelay(5);I think it's possible to have one pending job unprocessed with VCN when suspend sequence getting here, but it shouldn't be more than one,
cancel_delayed_work_syncprobably return false after the first time, so callingcancel_delayed_work_synconce should be enough here. we probably need to wait longer from:
SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1, UVD_POWER_STATUS__UVD_POWER_STATUS_MASK);to make sure the unprocessed job get done.
Regards,
Leo
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0+ if (!retry_max && !amdgpu_sriov_vf(adev)) { + if (RREG32_SOC15(VCN, i, mmUVD_STATUS)) { + dev_warn(adev->dev, "Forced powering gate vcn hardware!"); + vcn_v3_0_set_powergating_state(adev,AMD_PG_STATE_GATE ); + } + }for (i = 0; i <
adev->vcn.num_vcn_inst; ++i) { if (adev->vcn.harvest_config& (1 << i))
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
Am 17.05.21 um 16:57 schrieb James Zhu:
Quoted 28 lines
During vcn suspends, stop ring continue to receive new requests, and try to wait for all vcn jobs to finish gracefully.
Signed-off-by James Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +9
-1@@ -275,9 +275,27 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev) {unsigned size;void *ptr; +int retry_max =6 ;int i; -cancel_delayed_work_sync (&adev->vcn.idle_work); +for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) { +if (adev->vcn.harvest_config & (1 << i)) +continue ; + ring = &adev->vcn.inst[i].ring_dec; + ring->sched.ready = false; + +for (j =0 ; j < adev->vcn.num_enc_rings; ++j) { + ring = &adev->vcn.inst[i].ring_enc[j];
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c int amdgpu_vcn_suspend(struct amdgpu_device *adev) · line 298
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +10
-0+ ring->sched.ready = false; + } + } + +while (retry_max--) { +if (cancel_delayed_work_sync (&adev->vcn.idle_work)) { +dev_warn (adev->dev,"Waiting for left VCN job(s) to finish gracefully ..." ); +mdelay (5 ); + } + }
Ok that just makes no sense at all.
A cancel_delayed_work_sync() call is final, you never need to call it more than once.
Christian.
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c int amdgpu_vcn_suspend(struct amdgpu_device *adev) · line 301
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +0
-0for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) {if (adev->vcn.harvest_config & (1 << i))
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 42 lines · Christian König
Am 17.05.21 um 16:57 schrieb James Zhu:
Quoted 28 lines
During vcn suspends, stop ring continue to receive new requests, and try to wait for all vcn jobs to finish gracefully.
Signed-off-by James Zhu <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c| 20 +++++++++++++++++++-1 file changed, 19 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +10
-0@@ -275,9 +275,27 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev) { unsigned size; void *ptr; + int retry_max = 6; int i; - cancel_delayed_work_sync(&adev->vcn.idle_work); + for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { + if (adev->vcn.harvest_config & (1 << i)) + continue; + ring = &adev->vcn.inst[i].ring_dec; + ring->sched.ready = false; + + for (j = 0; j < adev->vcn.num_enc_rings; ++j) { + ring = &adev->vcn.inst[i].ring_enc[j]; + ring->sched.ready = false;drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c int amdgpu_vcn_suspend(struct amdgpu_device *adev) · line 299
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +9
-0+ } + } + + while (retry_max--) { + if (cancel_delayed_work_sync(&adev->vcn.idle_work)) { + dev_warn(adev->dev, "Waiting for left VCN job(s) to finish gracefully ..."); + mdelay(5); + } + }Ok that just makes no sense at all.
Quoted 2 lines
A
cancel_delayed_work_sync()call is final, you never need to call it more than once.
yeah, I am preparing a new patch. Thanks! James
Quoted 5 lines
Christian.
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +0
-0for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { if (adev->vcn.harvest_config & (1 << i))
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx