radeon error on resume: "cp failed to get scratch reg" - anyone interested?
Subsystems (2)
Hi,
I've noticed that on resume from suspend, dmesg reports:
[21895.997536] [drm] radeon: 1 quad pipes, 2 z pipes initialized. [21896.012072] [drm] PCIE GART of 512M enabled (table at 0x0000000000040000). [21896.012082] radeon 0000:01:00.0: WB enabled [21896.012085] radeon 0000:01:00.0: fence driver on ring 0 use gpu addr 0x0000000010000000 and cpu addr 0xffccb000 [21896.012138] [drm] radeon: ring at 0x0000000010001000 [21896.012157] [drm:r100_ring_test] *ERROR* radeon: cp failed to get scratch reg (-22). [21896.012158] [drm:r100_cp_init] *ERROR* radeon: cp isn't working (-22). [21896.012160] radeon 0000:01:00.0: failed initializing CP (-22).
Graphics still seems to work fine though.
Is this info of interest to anyone? I'm happy to do additional testing if that is useful.
System: Radeon Mobility X1600 RV530 (about 5 year old laptop), kernel 3.6.0-rc5+ 32-bit
Cheers,
Simon
Quoted 16 lines · Simon Kitching
Hi,
I've noticed that on resume from suspend, dmesg reports:
[21895.997536] [drm] radeon: 1 quad pipes, 2 z pipes initialized. [21896.012072] [drm] PCIE GART of 512M enabled (table at 0x0000000000040000). [21896.012082] radeon 0000:01:00.0: WB enabled [21896.012085] radeon 0000:01:00.0: fence driver on ring 0 use gpu addr 0x0000000010000000 and cpu addr 0xffccb000 [21896.012138] [drm] radeon: ring at 0x0000000010001000 [21896.012157] [drm:r100_ring_test] *ERROR* radeon: cp failed to get scratch reg (-22). [21896.012158] [drm:r100_cp_init] *ERROR* radeon: cp isn't working (-22). [21896.012160] radeon 0000:01:00.0: failed initializing CP (-22).
Quoted 4 lines
Graphics still seems to work fine though.
Is this info of interest to anyone? I'm happy to do additional testing if that is useful.
Does the patch below fix the failure to get a scratch register?
Quoted 1 line
From
6780dca112752e1fc4e7d410441b39874565b754Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <[email protected]>
Date: Wed, 19 Sep 2012 11:09:14 +0200
Subject: [PATCH] drm/radeon: Fix scratch register leak in IB test.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Restructure the code to jump out via labels instead of directly returning early.
--- drivers/gpu/drm/radeon/r100.c | 12 ++++++------ drivers/gpu/drm/radeon/r600.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/gpu/drm/radeon/r100.c +6 -6
@@ -3818,7 +3818,7 @@ int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)WREG32 (scratch,0xCAFEDEAD ); r =radeon_ib_get (rdev,RADEON_RING_TYPE_GFX_INDEX , &ib,256 );if (r) { -return r; + goto free_scratch; } ib.ptr[0 ] =PACKET0 (scratch,0 ); ib.ptr[1 ] =0xDEADBEEF ;
@@ -3831,13 +3831,11 @@ int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) ib.length_dw =8 ; r =radeon_ib_schedule (rdev, &ib,NULL );if (r) { -radeon_scratch_free (rdev, scratch); -radeon_ib_free (rdev, &ib); -return r; + goto free_ib; } r =radeon_fence_wait (ib.fence, false);if (r) { -return r; + goto free_ib; }for (i =0 ; i < rdev->usec_timeout; i++) { tmp =RREG32 (scratch);
@@ -3853,8 +3851,10 @@ int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) scratch, tmp); r = -EINVAL ; } -radeon_scratch_free (rdev, scratch); +free_ib:radeon_ib_free (rdev, &ib); +free_scratch: +radeon_scratch_free (rdev, scratch);return r; }
drivers/gpu/drm/radeon/r600.c +6 -6
@@ -2638,7 +2638,7 @@ int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) r =radeon_ib_get (rdev, ring->idx, &ib,256 );if (r) {DRM_ERROR ("radeon: failed to get ib (%d).\n" , r); -return r; + goto free_scratch; } ib.ptr[0 ] =PACKET3 (PACKET3_SET_CONFIG_REG ,1 ); ib.ptr[1 ] = ((scratch -PACKET3_SET_CONFIG_REG_OFFSET ) >>2 );
@@ -2646,15 +2646,13 @@ int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) ib.length_dw =3 ; r =radeon_ib_schedule (rdev, &ib,NULL );if (r) { -radeon_scratch_free (rdev, scratch); -radeon_ib_free (rdev, &ib);DRM_ERROR ("radeon: failed to schedule ib (%d).\n" , r); -return r; + goto free_ib; } r =radeon_fence_wait (ib.fence, false);if (r) {DRM_ERROR ("radeon: fence wait failed (%d).\n" , r); -return r; + goto free_ib; }for (i =0 ; i < rdev->usec_timeout; i++) { tmp =RREG32 (scratch);
@@ -2669,8 +2667,10 @@ int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) scratch, tmp); r = -EINVAL ; } -radeon_scratch_free (rdev, scratch); +free_ib:radeon_ib_free (rdev, &ib); +free_scratch: +radeon_scratch_free (rdev, scratch);return r; }
Signature · 7 lines
1.7.10.4 -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Debian, X and DRI developer
Quoted 113 lines · Michel Dänzer
Quoted 16 lines · Simon Kitching
Hi,
I've noticed that on resume from suspend, dmesg reports:
[21895.997536] [drm] radeon: 1 quad pipes, 2 z pipes initialized. [21896.012072] [drm] PCIE GART of 512M enabled (table at 0x0000000000040000). [21896.012082] radeon 0000:01:00.0: WB enabled [21896.012085] radeon 0000:01:00.0: fence driver on ring 0 use gpu addr 0x0000000010000000 and cpu addr 0xffccb000 [21896.012138] [drm] radeon: ring at 0x0000000010001000 [21896.012157] [drm:r100_ring_test] *ERROR* radeon: cp failed to get scratch reg (-22). [21896.012158] [drm:r100_cp_init] *ERROR* radeon: cp isn't working (-22). [21896.012160] radeon 0000:01:00.0: failed initializing CP (-22).Quoted 4 lines
Graphics still seems to work fine though.
Is this info of interest to anyone? I'm happy to do additional testing if that is useful.
Does the patch below fix the failure to get a scratch register?
From
6780dca112752e1fc4e7d410441b39874565b754Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <[email protected]>
Date: Wed, 19 Sep 2012 11:09:14 +0200
Subject: [PATCH] drm/radeon: Fix scratch register leak in IB test.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitRestructure the code to jump out via labels instead of directly returning early.
--- drivers/gpu/drm/radeon/r100.c | 12 ++++++------ drivers/gpu/drm/radeon/r600.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-)drivers/gpu/drm/radeon/r100.c +6
-6@@ -3818,7 +3818,7 @@ int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)WREG32 (scratch,0xCAFEDEAD ); r =radeon_ib_get (rdev,RADEON_RING_TYPE_GFX_INDEX , &ib,256 );if (r) { -return r; + goto free_scratch; } ib.ptr[0 ] =PACKET0 (scratch,0 ); ib.ptr[1 ] =0xDEADBEEF ;@@ -3831,13 +3831,11 @@ int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) ib.length_dw =8 ; r =radeon_ib_schedule (rdev, &ib,NULL );if (r) { -radeon_scratch_free (rdev, scratch); -radeon_ib_free (rdev, &ib); -return r; + goto free_ib; } r =radeon_fence_wait (ib.fence, false);if (r) { -return r; + goto free_ib; }for (i =0 ; i < rdev->usec_timeout; i++) { tmp =RREG32 (scratch);@@ -3853,8 +3851,10 @@ int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) scratch, tmp); r = -EINVAL ; } -radeon_scratch_free (rdev, scratch); +free_ib:radeon_ib_free (rdev, &ib); +free_scratch: +radeon_scratch_free (rdev, scratch);return r; }drivers/gpu/drm/radeon/r600.c +3
-5@@ -2638,7 +2638,7 @@ int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) r =radeon_ib_get (rdev, ring->idx, &ib,256 );if (r) {DRM_ERROR ("radeon: failed to get ib (%d).\n" , r); -return r; + goto free_scratch; } ib.ptr[0 ] =PACKET3 (PACKET3_SET_CONFIG_REG ,1 ); ib.ptr[1 ] = ((scratch -PACKET3_SET_CONFIG_REG_OFFSET ) >>2 );@@ -2646,15 +2646,13 @@ int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) ib.length_dw =3 ; r =radeon_ib_schedule (rdev, &ib,NULL );if (r) { -radeon_scratch_free (rdev, scratch); -radeon_ib_free (rdev, &ib);DRM_ERROR ("radeon: failed to schedule ib (%d).\n" , r); -return r; + goto free_ib; } r =radeon_fence_wait (ib.fence, false);if (r) {DRM_ERROR ("radeon: fence wait failed (%d).\n" , r); -return r; + goto free_ib; }for (i =0 ; i < rdev->usec_timeout; i++) { tmp =RREG32 (scratch);@@ -2669,8 +2667,10 @@ int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) scratch, tmp);
drivers/gpu/drm/radeon/r600.c int r600_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) · line 2676
Quoted 10 lines
drivers/gpu/drm/radeon/r600.c +3
-1r = -EINVAL ; } -radeon_scratch_free (rdev, scratch); +free_ib:radeon_ib_free (rdev, &ib); +free_scratch: +radeon_scratch_free (rdev, scratch);return r; }
Sadly the patch does not fix the issue. However I agree that this patch is a good thing - the original code does clearly leak scratch registers in some failure conditions.
Maybe this patch could also add the DRM_ERROR calls for these error cases from the r600 version into the r100 version?
Note that on failure of radeon_ib_schedule, the order of resource releases *was*
radeon_scratch_free
radeon_ib_free
and with this patch is:
radeon_ib_free
radeon_scratch_free
This change looks correct to me, ie post-patch the frees are in reverse order to original allocation.
If you do submit this patch, please add "reviewed-by [email protected]" or "tested-by" or whatever you think the appropriate tag is.
Thanks to this patch pointing me to the appropriate area, I have actually found the real cause of the scratch-register leak, and will post a candidate patch today.
Regards,Simon
[email protected]
Reviewed-by Christian KönigRe: Re: radeon error on resume: "cp failed to get scratch reg" - anyoneinterested?
----------------------------------------------------------------------
From: "Simon Kitching" <[email protected]>
To: "Michel Dänzer" <[email protected]>
Date: Thu, 20 Sep 2012 09:38:56 +0200
Subject: Re: radeon error on resume: "cp failed to get scratch reg" - anyoneinterested?
Quoted 40 lines · Michel Dänzer
Quoted 39 lines · Simon Kitching
Quoted 16 lines
Hi,
I've noticed that on resume from suspend, dmesg reports:
[21895.997536] [drm] radeon: 1 quad pipes, 2 z pipes initialized. [21896.012072] [drm] PCIE GART of 512M enabled (table at 0x0000000000040000). [21896.012082] radeon 0000:01:00.0: WB enabled [21896.012085] radeon 0000:01:00.0: fence driver on ring 0 use gpu addr 0x0000000010000000 and cpu addr 0xffccb000 [21896.012138] [drm] radeon: ring at 0x0000000010001000 [21896.012157] [drm:r100_ring_test] *ERROR* radeon: cp failed to get scratch reg (-22). [21896.012158] [drm:r100_cp_init] *ERROR* radeon: cp isn't working (-22). [21896.012160] radeon 0000:01:00.0: failed initializing CP (-22).Quoted 4 lines
Graphics still seems to work fine though.
Is this info of interest to anyone? I'm happy to do additional testing if that is useful.
Does the patch below fix the failure to get a scratch register?
From
6780dca112752e1fc4e7d410441b39874565b754Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <[email protected]>
Date: Wed, 19 Sep 2012 11:09:14 +0200
Subject: [PATCH] drm/radeon: Fix scratch register leak in IB test.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitRestructure the code to jump out via labels instead of directly returning early.
--- drivers/gpu/drm/radeon/r100.c | 12 ++++++------ drivers/gpu/drm/radeon/r600.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-)
Quoted 5 lines
drivers/gpu/drm/radeon/r100.c int r100_ib_test(struct radeon_device *rdev,
Quoted 5 lines
drivers/gpu/drm/radeon/r100.c +0
-0@@ -3818,7 +3818,7 @@ int r100_ib_test(struct radeon_device *rdev,
struct radeon_ring *ring)
Quoted 9 lines
drivers/gpu/drm/radeon/r100.c int r100_ib_test(struct radeon_device *rdev,
Quoted 9 lines
drivers/gpu/drm/radeon/r100.c +1
-1WREG32 (scratch,0xCAFEDEAD ); r =radeon_ib_get (rdev,RADEON_RING_TYPE_GFX_INDEX , &ib,256 );if (r) { -return r; + goto free_scratch; } ib.ptr[0 ] =PACKET0 (scratch,0 ); ib.ptr[1 ] =0xDEADBEEF ;@@ -3831,13 +3831,11 @@ int r100_ib_test(struct radeon_device *rdev,
struct radeon_ring *ring)
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/radeon/r100.c +1
-3ib.length_dw =8 ; r =radeon_ib_schedule (rdev, &ib,NULL );if (r) { -radeon_scratch_free (rdev, scratch); -radeon_ib_free (rdev, &ib); -return r; + goto free_ib; }
Quoted 8 lines
drivers/gpu/drm/radeon/r100.c int r100_ib_test(struct radeon_device *rdev,
Quoted 8 lines
drivers/gpu/drm/radeon/r100.c +1
-1r =radeon_fence_wait (ib.fence, false);if (r) { -return r; + goto free_ib; }for (i =0 ; i < rdev->usec_timeout; i++) { tmp =RREG32 (scratch);@@ -3853,8 +3851,10 @@ int r100_ib_test(struct radeon_device *rdev,
struct radeon_ring *ring)
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/radeon/r100.c +3
-1scratch, tmp); r = -EINVAL ; } -radeon_scratch_free (rdev, scratch); +free_ib:radeon_ib_free (rdev, &ib); +free_scratch: +radeon_scratch_free (rdev, scratch);return r; }
Quoted 5 lines
drivers/gpu/drm/radeon/r600.c int r600_ib_test(struct radeon_device *rdev,
Quoted 5 lines
drivers/gpu/drm/radeon/r600.c +0
-0@@ -2638,7 +2638,7 @@ int r600_ib_test(struct radeon_device *rdev,
struct radeon_ring *ring)
Quoted 9 lines
drivers/gpu/drm/radeon/r600.c int r600_ib_test(struct radeon_device *rdev,
Quoted 9 lines
drivers/gpu/drm/radeon/r600.c +1
-1r =radeon_ib_get (rdev, ring->idx, &ib,256 );if (r) {DRM_ERROR ("radeon: failed to get ib (%d).\n" , r); -return r; + goto free_scratch; } ib.ptr[0 ] =PACKET3 (PACKET3_SET_CONFIG_REG ,1 ); ib.ptr[1 ] = ((scratch -PACKET3_SET_CONFIG_REG_OFFSET ) >>2 );@@ -2646,15 +2646,13 @@ int r600_ib_test(struct radeon_device *rdev,
struct radeon_ring *ring)
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/radeon/r600.c +1
-3ib.length_dw =3 ; r =radeon_ib_schedule (rdev, &ib,NULL );if (r) { -radeon_scratch_free (rdev, scratch); -radeon_ib_free (rdev, &ib);DRM_ERROR ("radeon: failed to schedule ib (%d).\n" , r); -return r; + goto free_ib; } r =radeon_fence_wait (ib.fence, false);
Quoted 8 lines
drivers/gpu/drm/radeon/r600.c int r600_ib_test(struct radeon_device *rdev,
Quoted 8 lines
drivers/gpu/drm/radeon/r600.c +1
-1if (r) {DRM_ERROR ("radeon: fence wait failed (%d).\n" , r); -return r; + goto free_ib; }for (i =0 ; i < rdev->usec_timeout; i++) { tmp =RREG32 (scratch);@@ -2669,8 +2667,10 @@ int r600_ib_test(struct radeon_device *rdev,
struct radeon_ring *ring)
Quoted 15 lines
drivers/gpu/drm/radeon/r600.c int r600_ib_test(struct radeon_device *rdev, · line 2676
Quoted 11 lines
drivers/gpu/drm/radeon/r600.c +3
-1scratch, tmp); r = -EINVAL ; } -radeon_scratch_free (rdev, scratch); +free_ib:radeon_ib_free (rdev, &ib); +free_scratch: +radeon_scratch_free (rdev, scratch);return r; }Sadly the patch does not fix the issue. However I agree that this patch is a good thing - the original code does clearly leak scratch registers in some failure conditions.
Quoted 2 lines
Maybe this patch could also add the
DRM_ERRORcalls for these error cases from the r600 version into the r100 version?
Sounds like a good idea to me.
Quoted 10 lines
Note that on failure of
radeon_ib_schedule, the order of resource releases *was*
radeon_scratch_free
radeon_ib_free
and with this patch is:
radeon_ib_free
radeon_scratch_free
This change looks correct to me, ie post-patch the frees are in reverse order to original allocation.
The order doesn't really matter in that case, so the patch Michel proposed should do quite fine. So please add:
Quoted 8 lines
If you do submit this patch, please add "reviewed-by [email protected]" or "tested-by" or whatever you think the appropriate tag is.
Thanks to this patch pointing me to the appropriate area, I have actually found the real cause of the scratch-register leak, and will post a candidate patch today.
Sounds good, please post the patch, or at least a description of what is really going wrong here.
Cheers,
Christian.
Quoted 7 lines
Regards,Simon
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 23 lines · Simon Kitching
Quoted 22 lines · Michel Dänzer
Quoted 16 lines · Simon Kitching
Hi,
I've noticed that on resume from suspend, dmesg reports:
[21895.997536] [drm] radeon: 1 quad pipes, 2 z pipes initialized. [21896.012072] [drm] PCIE GART of 512M enabled (table at 0x0000000000040000). [21896.012082] radeon 0000:01:00.0: WB enabled [21896.012085] radeon 0000:01:00.0: fence driver on ring 0 use gpu addr 0x0000000010000000 and cpu addr 0xffccb000 [21896.012138] [drm] radeon: ring at 0x0000000010001000 [21896.012157] [drm:r100_ring_test] *ERROR* radeon: cp failed to get scratch reg (-22). [21896.012158] [drm:r100_cp_init] *ERROR* radeon: cp isn't working (-22). [21896.012160] radeon 0000:01:00.0: failed initializing CP (-22).Quoted 4 lines
Graphics still seems to work fine though.
Is this info of interest to anyone? I'm happy to do additional testing if that is useful.
Does the patch below fix the failure to get a scratch register?
[...]
Quoted 6 lines
Sadly the patch does not fix the issue. However I agree that this patch is a good thing - the original code does clearly leak scratch registers in some failure conditions.
Maybe this patch could also add the
DRM_ERRORcalls for these error cases from the r600 version into the r100 version?
Yeah, that's a good idea, done.
Quoted 9 lines
Note that on failure of
radeon_ib_schedule, the order of resource releases *was*
radeon_scratch_free
radeon_ib_free
and with this patch is:
radeon_ib_free
radeon_scratch_free
This change looks correct to me, ie post-patch the frees are in reverse order to original allocation.
Right, this is necessary for the new label exit structure to work.
Quoted 3 lines
If you do submit this patch, please add "reviewed-by [email protected]" or "tested-by" or whatever you think the appropriate tag is.
I used the former, thanks for your (and Christian's) review!
Quoted 3 lines
Thanks to this patch pointing me to the appropriate area, I have actually found the real cause of the scratch-register leak, and will post a candidate patch today.
Excellent, looking forward to it.
Signature · 2 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Debian, X and DRI developer