* [PATCH] drm/amd/amdgpu: S3 resumed failed after 4-5 times loop
@ 2016-08-18 12:42 jimqu
[not found] ` <1471524131-5357-1-git-send-email-Jim.Qu-5C7GfCeVMHo@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: jimqu @ 2016-08-18 12:42 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: jimqu
phenomenon: software hang when device resume back, read UVD fence is 0xffffffff
and read pcie pid is 0xffff.
the issue is caused by VCE reset when update cg setting. according to HW programming
guide, adjust update VCE cg sequence.
Change-Id: I18b12eea21c045908cdd23f93a0b196b87bfed6c
Signed-off-by: JimQu <Jim.Qu@amd.com>
---
drivers/gpu/drm/amd/amdgpu/vce_v2_0.c | 123 +++++++++++++++++++++++-----------
1 file changed, 84 insertions(+), 39 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
index 9e70df9..6ce7c07 100644
--- a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
@@ -40,10 +40,12 @@
#define VCE_V2_0_FW_SIZE (256 * 1024)
#define VCE_V2_0_STACK_SIZE (64 * 1024)
#define VCE_V2_0_DATA_SIZE (23552 * AMDGPU_MAX_VCE_HANDLES)
+#define VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK 0x02
static void vce_v2_0_mc_resume(struct amdgpu_device *adev);
static void vce_v2_0_set_ring_funcs(struct amdgpu_device *adev);
static void vce_v2_0_set_irq_funcs(struct amdgpu_device *adev);
+static int vce_v2_0_wait_for_idle(void *handle);
/**
* vce_v2_0_ring_get_rptr - get read pointer
@@ -96,6 +98,49 @@ static void vce_v2_0_ring_set_wptr(struct amdgpu_ring *ring)
WREG32(mmVCE_RB_WPTR2, ring->wptr);
}
+static int vce_v2_0_lmi_clean(struct amdgpu_device *adev)
+{
+ int i, j;
+
+ for (i = 0; i < 10; ++i) {
+ for (j = 0; j < 100; ++j) {
+ uint32_t status = RREG32(mmVCE_LMI_STATUS);
+
+ if (status & 0x337f)
+ return 0;
+ mdelay(10);
+ }
+ }
+
+ return -ETIMEDOUT;
+}
+
+static int vce_v2_0_firmware_loaded(struct amdgpu_device *adev)
+{
+ int i, j;
+
+ for (i = 0; i < 10; ++i) {
+ for (j = 0; j < 100; ++j) {
+ uint32_t status = RREG32(mmVCE_STATUS);
+
+ if (status & VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK)
+ return 0;
+ mdelay(10);
+ }
+
+ DRM_ERROR("VCE not responding, trying to reset the ECPU!!!\n");
+ WREG32_P(mmVCE_SOFT_RESET,
+ VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
+ ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
+ mdelay(10);
+ WREG32_P(mmVCE_SOFT_RESET, 0,
+ ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
+ mdelay(10);
+ }
+
+ return -ETIMEDOUT;
+}
+
/**
* vce_v2_0_start - start VCE block
*
@@ -106,7 +151,7 @@ static void vce_v2_0_ring_set_wptr(struct amdgpu_ring *ring)
static int vce_v2_0_start(struct amdgpu_device *adev)
{
struct amdgpu_ring *ring;
- int i, j, r;
+ int r;
vce_v2_0_mc_resume(adev);
@@ -137,26 +182,7 @@ static int vce_v2_0_start(struct amdgpu_device *adev)
WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
- for (i = 0; i < 10; ++i) {
- uint32_t status;
- for (j = 0; j < 100; ++j) {
- status = RREG32(mmVCE_STATUS);
- if (status & 2)
- break;
- mdelay(10);
- }
- r = 0;
- if (status & 2)
- break;
-
- DRM_ERROR("VCE not responding, trying to reset the ECPU!!!\n");
- WREG32_P(mmVCE_SOFT_RESET, VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
- ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
- mdelay(10);
- WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
- mdelay(10);
- r = -1;
- }
+ r = vce_v2_0_firmware_loaded(adev);
/* clear BUSY flag */
WREG32_P(mmVCE_STATUS, 0, ~1);
@@ -338,31 +364,50 @@ static void vce_v2_0_set_sw_cg(struct amdgpu_device *adev, bool gated)
static void vce_v2_0_set_dyn_cg(struct amdgpu_device *adev, bool gated)
{
- u32 orig, tmp;
+ if (vce_v2_0_wait_for_idle(adev)) {
+ DRM_INFO("VCE is busy, Can't set clock gateing");
+ return;
+ }
- tmp = RREG32(mmVCE_CLOCK_GATING_B);
- tmp &= ~0x00060006;
+ WREG32_P(mmVCE_LMI_CTRL2, 0x100, ~0x100);
+
+ if (vce_v2_0_lmi_clean(adev)) {
+ DRM_INFO("LMI is busy, Can't set clock gateing");
+ return;
+ }
+
+ WREG32_P(mmVCE_VCPU_CNTL, 0, ~VCE_VCPU_CNTL__CLK_EN_MASK);
+ WREG32_P(mmVCE_SOFT_RESET,
+ VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
+ ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
+ WREG32(mmVCE_STATUS, 0);
+
+ if (gated)
+ WREG32(mmVCE_CGTT_CLK_OVERRIDE, 0);
+ /* LMI_MC/LMI_UMC always set in dynamic, set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {0, 0} */
if (gated) {
- tmp |= 0xe10000;
+ /* Force CLOCK OFF , set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {*, 1} */
+ WREG32(mmVCE_CLOCK_GATING_B, 0xe90010);
} else {
- tmp |= 0xe1;
- tmp &= ~0xe10000;
+ /* Force CLOCK ON, set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {1, 0} */
+ WREG32(mmVCE_CLOCK_GATING_B, 0x800f1);
}
- WREG32(mmVCE_CLOCK_GATING_B, tmp);
- orig = tmp = RREG32(mmVCE_UENC_CLOCK_GATING);
- tmp &= ~0x1fe000;
- tmp &= ~0xff000000;
- if (tmp != orig)
- WREG32(mmVCE_UENC_CLOCK_GATING, tmp);
+ /* Set VCE_UENC_CLOCK_GATING always in dynamic mode {*_FORCE_ON, *_FORCE_OFF} = {0, 0}*/;
+ WREG32(mmVCE_UENC_CLOCK_GATING, 0x40);
- orig = tmp = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
- tmp &= ~0x3fc;
- if (tmp != orig)
- WREG32(mmVCE_UENC_REG_CLOCK_GATING, tmp);
+ /* set VCE_UENC_REG_CLOCK_GATING always in dynamic mode */
+ WREG32(mmVCE_UENC_REG_CLOCK_GATING, 0x00);
- if (gated)
- WREG32(mmVCE_CGTT_CLK_OVERRIDE, 0);
+ WREG32_P(mmVCE_LMI_CTRL2, 0, ~0x100);
+ if(!gated) {
+ WREG32_P(mmVCE_VCPU_CNTL, VCE_VCPU_CNTL__CLK_EN_MASK, ~VCE_VCPU_CNTL__CLK_EN_MASK);
+ mdelay(100);
+ WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
+
+ vce_v2_0_firmware_loaded(adev);
+ WREG32_P(mmVCE_STATUS, 0, ~VCE_STATUS__JOB_BUSY_MASK);
+ }
}
static void vce_v2_0_disable_cg(struct amdgpu_device *adev)
--
1.9.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/amd/amdgpu: S3 resumed failed after 4-5 times loop
[not found] ` <1471524131-5357-1-git-send-email-Jim.Qu-5C7GfCeVMHo@public.gmane.org>
@ 2016-08-18 13:27 ` Christian König
[not found] ` <8b1a399d-0054-c356-8775-60cdd83d5004-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Christian König @ 2016-08-18 13:27 UTC (permalink / raw)
To: jimqu, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Am 18.08.2016 um 14:42 schrieb jimqu:
> phenomenon: software hang when device resume back, read UVD fence is 0xffffffff
> and read pcie pid is 0xffff.
> the issue is caused by VCE reset when update cg setting. according to HW programming
> guide, adjust update VCE cg sequence.
>
> Change-Id: I18b12eea21c045908cdd23f93a0b196b87bfed6c
> Signed-off-by: JimQu <Jim.Qu@amd.com>
You should probably note in the commit log that this only applies to
systems with VCE2, e.g. CIK.
Additional to that please make sure that it applies cleanly to the
amd-staging-4.6 branch.
With that made sure the patch is Reviewed-by: Christian König
<christian.koenig@amd.com>
Regards,
Christian.
> ---
> drivers/gpu/drm/amd/amdgpu/vce_v2_0.c | 123 +++++++++++++++++++++++-----------
> 1 file changed, 84 insertions(+), 39 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> index 9e70df9..6ce7c07 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> @@ -40,10 +40,12 @@
> #define VCE_V2_0_FW_SIZE (256 * 1024)
> #define VCE_V2_0_STACK_SIZE (64 * 1024)
> #define VCE_V2_0_DATA_SIZE (23552 * AMDGPU_MAX_VCE_HANDLES)
> +#define VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK 0x02
>
> static void vce_v2_0_mc_resume(struct amdgpu_device *adev);
> static void vce_v2_0_set_ring_funcs(struct amdgpu_device *adev);
> static void vce_v2_0_set_irq_funcs(struct amdgpu_device *adev);
> +static int vce_v2_0_wait_for_idle(void *handle);
>
> /**
> * vce_v2_0_ring_get_rptr - get read pointer
> @@ -96,6 +98,49 @@ static void vce_v2_0_ring_set_wptr(struct amdgpu_ring *ring)
> WREG32(mmVCE_RB_WPTR2, ring->wptr);
> }
>
> +static int vce_v2_0_lmi_clean(struct amdgpu_device *adev)
> +{
> + int i, j;
> +
> + for (i = 0; i < 10; ++i) {
> + for (j = 0; j < 100; ++j) {
> + uint32_t status = RREG32(mmVCE_LMI_STATUS);
> +
> + if (status & 0x337f)
> + return 0;
> + mdelay(10);
> + }
> + }
> +
> + return -ETIMEDOUT;
> +}
> +
> +static int vce_v2_0_firmware_loaded(struct amdgpu_device *adev)
> +{
> + int i, j;
> +
> + for (i = 0; i < 10; ++i) {
> + for (j = 0; j < 100; ++j) {
> + uint32_t status = RREG32(mmVCE_STATUS);
> +
> + if (status & VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK)
> + return 0;
> + mdelay(10);
> + }
> +
> + DRM_ERROR("VCE not responding, trying to reset the ECPU!!!\n");
> + WREG32_P(mmVCE_SOFT_RESET,
> + VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
> + ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> + mdelay(10);
> + WREG32_P(mmVCE_SOFT_RESET, 0,
> + ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> + mdelay(10);
> + }
> +
> + return -ETIMEDOUT;
> +}
> +
> /**
> * vce_v2_0_start - start VCE block
> *
> @@ -106,7 +151,7 @@ static void vce_v2_0_ring_set_wptr(struct amdgpu_ring *ring)
> static int vce_v2_0_start(struct amdgpu_device *adev)
> {
> struct amdgpu_ring *ring;
> - int i, j, r;
> + int r;
>
> vce_v2_0_mc_resume(adev);
>
> @@ -137,26 +182,7 @@ static int vce_v2_0_start(struct amdgpu_device *adev)
>
> WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
>
> - for (i = 0; i < 10; ++i) {
> - uint32_t status;
> - for (j = 0; j < 100; ++j) {
> - status = RREG32(mmVCE_STATUS);
> - if (status & 2)
> - break;
> - mdelay(10);
> - }
> - r = 0;
> - if (status & 2)
> - break;
> -
> - DRM_ERROR("VCE not responding, trying to reset the ECPU!!!\n");
> - WREG32_P(mmVCE_SOFT_RESET, VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
> - ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> - mdelay(10);
> - WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> - mdelay(10);
> - r = -1;
> - }
> + r = vce_v2_0_firmware_loaded(adev);
>
> /* clear BUSY flag */
> WREG32_P(mmVCE_STATUS, 0, ~1);
> @@ -338,31 +364,50 @@ static void vce_v2_0_set_sw_cg(struct amdgpu_device *adev, bool gated)
>
> static void vce_v2_0_set_dyn_cg(struct amdgpu_device *adev, bool gated)
> {
> - u32 orig, tmp;
> + if (vce_v2_0_wait_for_idle(adev)) {
> + DRM_INFO("VCE is busy, Can't set clock gateing");
> + return;
> + }
>
> - tmp = RREG32(mmVCE_CLOCK_GATING_B);
> - tmp &= ~0x00060006;
> + WREG32_P(mmVCE_LMI_CTRL2, 0x100, ~0x100);
> +
> + if (vce_v2_0_lmi_clean(adev)) {
> + DRM_INFO("LMI is busy, Can't set clock gateing");
> + return;
> + }
> +
> + WREG32_P(mmVCE_VCPU_CNTL, 0, ~VCE_VCPU_CNTL__CLK_EN_MASK);
> + WREG32_P(mmVCE_SOFT_RESET,
> + VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
> + ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> + WREG32(mmVCE_STATUS, 0);
> +
> + if (gated)
> + WREG32(mmVCE_CGTT_CLK_OVERRIDE, 0);
> + /* LMI_MC/LMI_UMC always set in dynamic, set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {0, 0} */
> if (gated) {
> - tmp |= 0xe10000;
> + /* Force CLOCK OFF , set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {*, 1} */
> + WREG32(mmVCE_CLOCK_GATING_B, 0xe90010);
> } else {
> - tmp |= 0xe1;
> - tmp &= ~0xe10000;
> + /* Force CLOCK ON, set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {1, 0} */
> + WREG32(mmVCE_CLOCK_GATING_B, 0x800f1);
> }
> - WREG32(mmVCE_CLOCK_GATING_B, tmp);
>
> - orig = tmp = RREG32(mmVCE_UENC_CLOCK_GATING);
> - tmp &= ~0x1fe000;
> - tmp &= ~0xff000000;
> - if (tmp != orig)
> - WREG32(mmVCE_UENC_CLOCK_GATING, tmp);
> + /* Set VCE_UENC_CLOCK_GATING always in dynamic mode {*_FORCE_ON, *_FORCE_OFF} = {0, 0}*/;
> + WREG32(mmVCE_UENC_CLOCK_GATING, 0x40);
>
> - orig = tmp = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
> - tmp &= ~0x3fc;
> - if (tmp != orig)
> - WREG32(mmVCE_UENC_REG_CLOCK_GATING, tmp);
> + /* set VCE_UENC_REG_CLOCK_GATING always in dynamic mode */
> + WREG32(mmVCE_UENC_REG_CLOCK_GATING, 0x00);
>
> - if (gated)
> - WREG32(mmVCE_CGTT_CLK_OVERRIDE, 0);
> + WREG32_P(mmVCE_LMI_CTRL2, 0, ~0x100);
> + if(!gated) {
> + WREG32_P(mmVCE_VCPU_CNTL, VCE_VCPU_CNTL__CLK_EN_MASK, ~VCE_VCPU_CNTL__CLK_EN_MASK);
> + mdelay(100);
> + WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> +
> + vce_v2_0_firmware_loaded(adev);
> + WREG32_P(mmVCE_STATUS, 0, ~VCE_STATUS__JOB_BUSY_MASK);
> + }
> }
>
> static void vce_v2_0_disable_cg(struct amdgpu_device *adev)
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/amd/amdgpu: S3 resumed failed after 4-5 times loop
[not found] ` <8b1a399d-0054-c356-8775-60cdd83d5004-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
@ 2016-08-18 15:24 ` Zhu, Rex
[not found] ` <CY4PR12MB1687869929F2F96EF9541E0BFB150-rpdhrqHFk06Y0SjTqZDccQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Zhu, Rex @ 2016-08-18 15:24 UTC (permalink / raw)
To: Christian König, Qu, Jim,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
[-- Attachment #1.1: Type: text/plain, Size: 8158 bytes --]
do we need to check those status(lmi status,firmware loaded, vce status and etc) when vce suspend?
it is weird that we didn't implement vce suspend function as hw spec suggested.
Best Regards
Rex
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Christian König <deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
Sent: Thursday, August 18, 2016 9:27:57 PM
To: Qu, Jim; amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH] drm/amd/amdgpu: S3 resumed failed after 4-5 times loop
Am 18.08.2016 um 14:42 schrieb jimqu:
> phenomenon: software hang when device resume back, read UVD fence is 0xffffffff
> and read pcie pid is 0xffff.
> the issue is caused by VCE reset when update cg setting. according to HW programming
> guide, adjust update VCE cg sequence.
>
> Change-Id: I18b12eea21c045908cdd23f93a0b196b87bfed6c
> Signed-off-by: JimQu <Jim.Qu-5C7GfCeVMHo@public.gmane.org>
You should probably note in the commit log that this only applies to
systems with VCE2, e.g. CIK.
Additional to that please make sure that it applies cleanly to the
amd-staging-4.6 branch.
With that made sure the patch is Reviewed-by: Christian König
<christian.koenig-5C7GfCeVMHo@public.gmane.org>
Regards,
Christian.
> ---
> drivers/gpu/drm/amd/amdgpu/vce_v2_0.c | 123 +++++++++++++++++++++++-----------
> 1 file changed, 84 insertions(+), 39 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> index 9e70df9..6ce7c07 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> @@ -40,10 +40,12 @@
> #define VCE_V2_0_FW_SIZE (256 * 1024)
> #define VCE_V2_0_STACK_SIZE (64 * 1024)
> #define VCE_V2_0_DATA_SIZE (23552 * AMDGPU_MAX_VCE_HANDLES)
> +#define VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK 0x02
>
> static void vce_v2_0_mc_resume(struct amdgpu_device *adev);
> static void vce_v2_0_set_ring_funcs(struct amdgpu_device *adev);
> static void vce_v2_0_set_irq_funcs(struct amdgpu_device *adev);
> +static int vce_v2_0_wait_for_idle(void *handle);
>
> /**
> * vce_v2_0_ring_get_rptr - get read pointer
> @@ -96,6 +98,49 @@ static void vce_v2_0_ring_set_wptr(struct amdgpu_ring *ring)
> WREG32(mmVCE_RB_WPTR2, ring->wptr);
> }
>
> +static int vce_v2_0_lmi_clean(struct amdgpu_device *adev)
> +{
> + int i, j;
> +
> + for (i = 0; i < 10; ++i) {
> + for (j = 0; j < 100; ++j) {
> + uint32_t status = RREG32(mmVCE_LMI_STATUS);
> +
> + if (status & 0x337f)
> + return 0;
> + mdelay(10);
> + }
> + }
> +
> + return -ETIMEDOUT;
> +}
> +
> +static int vce_v2_0_firmware_loaded(struct amdgpu_device *adev)
> +{
> + int i, j;
> +
> + for (i = 0; i < 10; ++i) {
> + for (j = 0; j < 100; ++j) {
> + uint32_t status = RREG32(mmVCE_STATUS);
> +
> + if (status & VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK)
> + return 0;
> + mdelay(10);
> + }
> +
> + DRM_ERROR("VCE not responding, trying to reset the ECPU!!!\n");
> + WREG32_P(mmVCE_SOFT_RESET,
> + VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
> + ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> + mdelay(10);
> + WREG32_P(mmVCE_SOFT_RESET, 0,
> + ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> + mdelay(10);
> + }
> +
> + return -ETIMEDOUT;
> +}
> +
> /**
> * vce_v2_0_start - start VCE block
> *
> @@ -106,7 +151,7 @@ static void vce_v2_0_ring_set_wptr(struct amdgpu_ring *ring)
> static int vce_v2_0_start(struct amdgpu_device *adev)
> {
> struct amdgpu_ring *ring;
> - int i, j, r;
> + int r;
>
> vce_v2_0_mc_resume(adev);
>
> @@ -137,26 +182,7 @@ static int vce_v2_0_start(struct amdgpu_device *adev)
>
> WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
>
> - for (i = 0; i < 10; ++i) {
> - uint32_t status;
> - for (j = 0; j < 100; ++j) {
> - status = RREG32(mmVCE_STATUS);
> - if (status & 2)
> - break;
> - mdelay(10);
> - }
> - r = 0;
> - if (status & 2)
> - break;
> -
> - DRM_ERROR("VCE not responding, trying to reset the ECPU!!!\n");
> - WREG32_P(mmVCE_SOFT_RESET, VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
> - ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> - mdelay(10);
> - WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> - mdelay(10);
> - r = -1;
> - }
> + r = vce_v2_0_firmware_loaded(adev);
>
> /* clear BUSY flag */
> WREG32_P(mmVCE_STATUS, 0, ~1);
> @@ -338,31 +364,50 @@ static void vce_v2_0_set_sw_cg(struct amdgpu_device *adev, bool gated)
>
> static void vce_v2_0_set_dyn_cg(struct amdgpu_device *adev, bool gated)
> {
> - u32 orig, tmp;
> + if (vce_v2_0_wait_for_idle(adev)) {
> + DRM_INFO("VCE is busy, Can't set clock gateing");
> + return;
> + }
>
> - tmp = RREG32(mmVCE_CLOCK_GATING_B);
> - tmp &= ~0x00060006;
> + WREG32_P(mmVCE_LMI_CTRL2, 0x100, ~0x100);
> +
> + if (vce_v2_0_lmi_clean(adev)) {
> + DRM_INFO("LMI is busy, Can't set clock gateing");
> + return;
> + }
> +
> + WREG32_P(mmVCE_VCPU_CNTL, 0, ~VCE_VCPU_CNTL__CLK_EN_MASK);
> + WREG32_P(mmVCE_SOFT_RESET,
> + VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
> + ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> + WREG32(mmVCE_STATUS, 0);
> +
> + if (gated)
> + WREG32(mmVCE_CGTT_CLK_OVERRIDE, 0);
> + /* LMI_MC/LMI_UMC always set in dynamic, set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {0, 0} */
> if (gated) {
> - tmp |= 0xe10000;
> + /* Force CLOCK OFF , set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {*, 1} */
> + WREG32(mmVCE_CLOCK_GATING_B, 0xe90010);
> } else {
> - tmp |= 0xe1;
> - tmp &= ~0xe10000;
> + /* Force CLOCK ON, set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {1, 0} */
> + WREG32(mmVCE_CLOCK_GATING_B, 0x800f1);
> }
> - WREG32(mmVCE_CLOCK_GATING_B, tmp);
>
> - orig = tmp = RREG32(mmVCE_UENC_CLOCK_GATING);
> - tmp &= ~0x1fe000;
> - tmp &= ~0xff000000;
> - if (tmp != orig)
> - WREG32(mmVCE_UENC_CLOCK_GATING, tmp);
> + /* Set VCE_UENC_CLOCK_GATING always in dynamic mode {*_FORCE_ON, *_FORCE_OFF} = {0, 0}*/;
> + WREG32(mmVCE_UENC_CLOCK_GATING, 0x40);
>
> - orig = tmp = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
> - tmp &= ~0x3fc;
> - if (tmp != orig)
> - WREG32(mmVCE_UENC_REG_CLOCK_GATING, tmp);
> + /* set VCE_UENC_REG_CLOCK_GATING always in dynamic mode */
> + WREG32(mmVCE_UENC_REG_CLOCK_GATING, 0x00);
>
> - if (gated)
> - WREG32(mmVCE_CGTT_CLK_OVERRIDE, 0);
> + WREG32_P(mmVCE_LMI_CTRL2, 0, ~0x100);
> + if(!gated) {
> + WREG32_P(mmVCE_VCPU_CNTL, VCE_VCPU_CNTL__CLK_EN_MASK, ~VCE_VCPU_CNTL__CLK_EN_MASK);
> + mdelay(100);
> + WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> +
> + vce_v2_0_firmware_loaded(adev);
> + WREG32_P(mmVCE_STATUS, 0, ~VCE_STATUS__JOB_BUSY_MASK);
> + }
> }
>
> static void vce_v2_0_disable_cg(struct amdgpu_device *adev)
_______________________________________________
amd-gfx mailing list
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
[-- Attachment #1.2: Type: text/html, Size: 17261 bytes --]
[-- Attachment #2: Type: text/plain, Size: 154 bytes --]
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* 答复: [PATCH] drm/amd/amdgpu: S3 resumed failed after 4-5 times loop
[not found] ` <CY4PR12MB1687869929F2F96EF9541E0BFB150-rpdhrqHFk06Y0SjTqZDccQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
@ 2016-08-19 0:48 ` Qu, Jim
0 siblings, 0 replies; 4+ messages in thread
From: Qu, Jim @ 2016-08-19 0:48 UTC (permalink / raw)
To: Zhu, Rex, Christian König,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
if it is required, we can continue to optimize driver in the future.
Thanks
JimQu
________________________________________
发件人: Zhu, Rex
发送时间: 2016年8月18日 23:24:19
收件人: Christian König; Qu, Jim; amd-gfx@lists.freedesktop.org
主题: Re: [PATCH] drm/amd/amdgpu: S3 resumed failed after 4-5 times loop
do we need to check those status(lmi status,firmware loaded, vce status and etc) when vce suspend?
it is weird that we didn't implement vce suspend function as hw spec suggested.
Best Regards
Rex
________________________________
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Christian König <deathsimple@vodafone.de>
Sent: Thursday, August 18, 2016 9:27:57 PM
To: Qu, Jim; amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/amd/amdgpu: S3 resumed failed after 4-5 times loop
Am 18.08.2016 um 14:42 schrieb jimqu:
> phenomenon: software hang when device resume back, read UVD fence is 0xffffffff
> and read pcie pid is 0xffff.
> the issue is caused by VCE reset when update cg setting. according to HW programming
> guide, adjust update VCE cg sequence.
>
> Change-Id: I18b12eea21c045908cdd23f93a0b196b87bfed6c
> Signed-off-by: JimQu <Jim.Qu@amd.com>
You should probably note in the commit log that this only applies to
systems with VCE2, e.g. CIK.
Additional to that please make sure that it applies cleanly to the
amd-staging-4.6 branch.
With that made sure the patch is Reviewed-by: Christian König
<christian.koenig@amd.com>
Regards,
Christian.
> ---
> drivers/gpu/drm/amd/amdgpu/vce_v2_0.c | 123 +++++++++++++++++++++++-----------
> 1 file changed, 84 insertions(+), 39 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> index 9e70df9..6ce7c07 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
> @@ -40,10 +40,12 @@
> #define VCE_V2_0_FW_SIZE (256 * 1024)
> #define VCE_V2_0_STACK_SIZE (64 * 1024)
> #define VCE_V2_0_DATA_SIZE (23552 * AMDGPU_MAX_VCE_HANDLES)
> +#define VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK 0x02
>
> static void vce_v2_0_mc_resume(struct amdgpu_device *adev);
> static void vce_v2_0_set_ring_funcs(struct amdgpu_device *adev);
> static void vce_v2_0_set_irq_funcs(struct amdgpu_device *adev);
> +static int vce_v2_0_wait_for_idle(void *handle);
>
> /**
> * vce_v2_0_ring_get_rptr - get read pointer
> @@ -96,6 +98,49 @@ static void vce_v2_0_ring_set_wptr(struct amdgpu_ring *ring)
> WREG32(mmVCE_RB_WPTR2, ring->wptr);
> }
>
> +static int vce_v2_0_lmi_clean(struct amdgpu_device *adev)
> +{
> + int i, j;
> +
> + for (i = 0; i < 10; ++i) {
> + for (j = 0; j < 100; ++j) {
> + uint32_t status = RREG32(mmVCE_LMI_STATUS);
> +
> + if (status & 0x337f)
> + return 0;
> + mdelay(10);
> + }
> + }
> +
> + return -ETIMEDOUT;
> +}
> +
> +static int vce_v2_0_firmware_loaded(struct amdgpu_device *adev)
> +{
> + int i, j;
> +
> + for (i = 0; i < 10; ++i) {
> + for (j = 0; j < 100; ++j) {
> + uint32_t status = RREG32(mmVCE_STATUS);
> +
> + if (status & VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK)
> + return 0;
> + mdelay(10);
> + }
> +
> + DRM_ERROR("VCE not responding, trying to reset the ECPU!!!\n");
> + WREG32_P(mmVCE_SOFT_RESET,
> + VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
> + ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> + mdelay(10);
> + WREG32_P(mmVCE_SOFT_RESET, 0,
> + ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> + mdelay(10);
> + }
> +
> + return -ETIMEDOUT;
> +}
> +
> /**
> * vce_v2_0_start - start VCE block
> *
> @@ -106,7 +151,7 @@ static void vce_v2_0_ring_set_wptr(struct amdgpu_ring *ring)
> static int vce_v2_0_start(struct amdgpu_device *adev)
> {
> struct amdgpu_ring *ring;
> - int i, j, r;
> + int r;
>
> vce_v2_0_mc_resume(adev);
>
> @@ -137,26 +182,7 @@ static int vce_v2_0_start(struct amdgpu_device *adev)
>
> WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
>
> - for (i = 0; i < 10; ++i) {
> - uint32_t status;
> - for (j = 0; j < 100; ++j) {
> - status = RREG32(mmVCE_STATUS);
> - if (status & 2)
> - break;
> - mdelay(10);
> - }
> - r = 0;
> - if (status & 2)
> - break;
> -
> - DRM_ERROR("VCE not responding, trying to reset the ECPU!!!\n");
> - WREG32_P(mmVCE_SOFT_RESET, VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
> - ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> - mdelay(10);
> - WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> - mdelay(10);
> - r = -1;
> - }
> + r = vce_v2_0_firmware_loaded(adev);
>
> /* clear BUSY flag */
> WREG32_P(mmVCE_STATUS, 0, ~1);
> @@ -338,31 +364,50 @@ static void vce_v2_0_set_sw_cg(struct amdgpu_device *adev, bool gated)
>
> static void vce_v2_0_set_dyn_cg(struct amdgpu_device *adev, bool gated)
> {
> - u32 orig, tmp;
> + if (vce_v2_0_wait_for_idle(adev)) {
> + DRM_INFO("VCE is busy, Can't set clock gateing");
> + return;
> + }
>
> - tmp = RREG32(mmVCE_CLOCK_GATING_B);
> - tmp &= ~0x00060006;
> + WREG32_P(mmVCE_LMI_CTRL2, 0x100, ~0x100);
> +
> + if (vce_v2_0_lmi_clean(adev)) {
> + DRM_INFO("LMI is busy, Can't set clock gateing");
> + return;
> + }
> +
> + WREG32_P(mmVCE_VCPU_CNTL, 0, ~VCE_VCPU_CNTL__CLK_EN_MASK);
> + WREG32_P(mmVCE_SOFT_RESET,
> + VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
> + ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> + WREG32(mmVCE_STATUS, 0);
> +
> + if (gated)
> + WREG32(mmVCE_CGTT_CLK_OVERRIDE, 0);
> + /* LMI_MC/LMI_UMC always set in dynamic, set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {0, 0} */
> if (gated) {
> - tmp |= 0xe10000;
> + /* Force CLOCK OFF , set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {*, 1} */
> + WREG32(mmVCE_CLOCK_GATING_B, 0xe90010);
> } else {
> - tmp |= 0xe1;
> - tmp &= ~0xe10000;
> + /* Force CLOCK ON, set {CGC_*_GATE_MODE, CGC_*_SW_GATE} = {1, 0} */
> + WREG32(mmVCE_CLOCK_GATING_B, 0x800f1);
> }
> - WREG32(mmVCE_CLOCK_GATING_B, tmp);
>
> - orig = tmp = RREG32(mmVCE_UENC_CLOCK_GATING);
> - tmp &= ~0x1fe000;
> - tmp &= ~0xff000000;
> - if (tmp != orig)
> - WREG32(mmVCE_UENC_CLOCK_GATING, tmp);
> + /* Set VCE_UENC_CLOCK_GATING always in dynamic mode {*_FORCE_ON, *_FORCE_OFF} = {0, 0}*/;
> + WREG32(mmVCE_UENC_CLOCK_GATING, 0x40);
>
> - orig = tmp = RREG32(mmVCE_UENC_REG_CLOCK_GATING);
> - tmp &= ~0x3fc;
> - if (tmp != orig)
> - WREG32(mmVCE_UENC_REG_CLOCK_GATING, tmp);
> + /* set VCE_UENC_REG_CLOCK_GATING always in dynamic mode */
> + WREG32(mmVCE_UENC_REG_CLOCK_GATING, 0x00);
>
> - if (gated)
> - WREG32(mmVCE_CGTT_CLK_OVERRIDE, 0);
> + WREG32_P(mmVCE_LMI_CTRL2, 0, ~0x100);
> + if(!gated) {
> + WREG32_P(mmVCE_VCPU_CNTL, VCE_VCPU_CNTL__CLK_EN_MASK, ~VCE_VCPU_CNTL__CLK_EN_MASK);
> + mdelay(100);
> + WREG32_P(mmVCE_SOFT_RESET, 0, ~VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK);
> +
> + vce_v2_0_firmware_loaded(adev);
> + WREG32_P(mmVCE_STATUS, 0, ~VCE_STATUS__JOB_BUSY_MASK);
> + }
> }
>
> static void vce_v2_0_disable_cg(struct amdgpu_device *adev)
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-08-19 0:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-18 12:42 [PATCH] drm/amd/amdgpu: S3 resumed failed after 4-5 times loop jimqu
[not found] ` <1471524131-5357-1-git-send-email-Jim.Qu-5C7GfCeVMHo@public.gmane.org>
2016-08-18 13:27 ` Christian König
[not found] ` <8b1a399d-0054-c356-8775-60cdd83d5004-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2016-08-18 15:24 ` Zhu, Rex
[not found] ` <CY4PR12MB1687869929F2F96EF9541E0BFB150-rpdhrqHFk06Y0SjTqZDccQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2016-08-19 0:48 ` 答复: " Qu, Jim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.