* [PATCH 1/1] drm/radeon: check return value of radeon_ring_lock
@ 2017-04-24 8:38 Pan Bian
2017-04-24 9:08 ` Christian König
0 siblings, 1 reply; 6+ messages in thread
From: Pan Bian @ 2017-04-24 8:38 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie
Cc: amd-gfx, dri-devel, linux-kernel, Pan Bian
From: Pan Bian <bianpan2016@163.com>
Function radeon_ring_lock() returns an errno on failure, and its return
value should be validated. However, in functions r420_cp_errata_init()
and r420_cp_errata_fini(), its return value is not checked. This patch
adds the checks.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/gpu/drm/radeon/r420.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
index 2828605..391c764 100644
--- a/drivers/gpu/drm/radeon/r420.c
+++ b/drivers/gpu/drm/radeon/r420.c
@@ -206,6 +206,7 @@ static void r420_clock_resume(struct radeon_device *rdev)
static void r420_cp_errata_init(struct radeon_device *rdev)
{
+ int r;
struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
/* RV410 and R420 can lock up if CP DMA to host memory happens
@@ -215,7 +216,8 @@ static void r420_cp_errata_init(struct radeon_device *rdev)
* of the CP init, apparently.
*/
radeon_scratch_get(rdev, &rdev->config.r300.resync_scratch);
- radeon_ring_lock(rdev, ring, 8);
+ r = radeon_ring_lock(rdev, ring, 8);
+ WARN_ON(r);
radeon_ring_write(ring, PACKET0(R300_CP_RESYNC_ADDR, 1));
radeon_ring_write(ring, rdev->config.r300.resync_scratch);
radeon_ring_write(ring, 0xDEADBEEF);
@@ -224,12 +226,14 @@ static void r420_cp_errata_init(struct radeon_device *rdev)
static void r420_cp_errata_fini(struct radeon_device *rdev)
{
+ int r;
struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
/* Catch the RESYNC we dispatched all the way back,
* at the very beginning of the CP init.
*/
- radeon_ring_lock(rdev, ring, 8);
+ r = radeon_ring_lock(rdev, ring, 8);
+ WARN_ON(r);
radeon_ring_write(ring, PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));
radeon_ring_write(ring, R300_RB3D_DC_FINISH);
radeon_ring_unlock_commit(rdev, ring, false);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] drm/radeon: check return value of radeon_ring_lock
2017-04-24 8:38 [PATCH 1/1] drm/radeon: check return value of radeon_ring_lock Pan Bian
@ 2017-04-24 9:08 ` Christian König
0 siblings, 0 replies; 6+ messages in thread
From: Christian König @ 2017-04-24 9:08 UTC (permalink / raw)
To: Pan Bian, Alex Deucher, David Airlie
Cc: amd-gfx, dri-devel, linux-kernel, Pan Bian
Am 24.04.2017 um 10:38 schrieb Pan Bian:
> From: Pan Bian <bianpan2016@163.com>
>
> Function radeon_ring_lock() returns an errno on failure, and its return
> value should be validated. However, in functions r420_cp_errata_init()
> and r420_cp_errata_fini(), its return value is not checked. This patch
> adds the checks.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/radeon/r420.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
> index 2828605..391c764 100644
> --- a/drivers/gpu/drm/radeon/r420.c
> +++ b/drivers/gpu/drm/radeon/r420.c
> @@ -206,6 +206,7 @@ static void r420_clock_resume(struct radeon_device *rdev)
>
> static void r420_cp_errata_init(struct radeon_device *rdev)
> {
> + int r;
> struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
>
> /* RV410 and R420 can lock up if CP DMA to host memory happens
> @@ -215,7 +216,8 @@ static void r420_cp_errata_init(struct radeon_device *rdev)
> * of the CP init, apparently.
> */
> radeon_scratch_get(rdev, &rdev->config.r300.resync_scratch);
> - radeon_ring_lock(rdev, ring, 8);
> + r = radeon_ring_lock(rdev, ring, 8);
> + WARN_ON(r);
> radeon_ring_write(ring, PACKET0(R300_CP_RESYNC_ADDR, 1));
> radeon_ring_write(ring, rdev->config.r300.resync_scratch);
> radeon_ring_write(ring, 0xDEADBEEF);
> @@ -224,12 +226,14 @@ static void r420_cp_errata_init(struct radeon_device *rdev)
>
> static void r420_cp_errata_fini(struct radeon_device *rdev)
> {
> + int r;
> struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
>
> /* Catch the RESYNC we dispatched all the way back,
> * at the very beginning of the CP init.
> */
> - radeon_ring_lock(rdev, ring, 8);
> + r = radeon_ring_lock(rdev, ring, 8);
> + WARN_ON(r);
> radeon_ring_write(ring, PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));
> radeon_ring_write(ring, R300_RB3D_DC_FINISH);
> radeon_ring_unlock_commit(rdev, ring, false);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] drm/radeon: check return value of radeon_ring_lock
@ 2017-04-24 9:08 ` Christian König
0 siblings, 0 replies; 6+ messages in thread
From: Christian König @ 2017-04-24 9:08 UTC (permalink / raw)
To: Pan Bian, Alex Deucher, David Airlie
Cc: amd-gfx, dri-devel, linux-kernel, Pan Bian
Am 24.04.2017 um 10:38 schrieb Pan Bian:
> From: Pan Bian <bianpan2016@163.com>
>
> Function radeon_ring_lock() returns an errno on failure, and its return
> value should be validated. However, in functions r420_cp_errata_init()
> and r420_cp_errata_fini(), its return value is not checked. This patch
> adds the checks.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/radeon/r420.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
> index 2828605..391c764 100644
> --- a/drivers/gpu/drm/radeon/r420.c
> +++ b/drivers/gpu/drm/radeon/r420.c
> @@ -206,6 +206,7 @@ static void r420_clock_resume(struct radeon_device *rdev)
>
> static void r420_cp_errata_init(struct radeon_device *rdev)
> {
> + int r;
> struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
>
> /* RV410 and R420 can lock up if CP DMA to host memory happens
> @@ -215,7 +216,8 @@ static void r420_cp_errata_init(struct radeon_device *rdev)
> * of the CP init, apparently.
> */
> radeon_scratch_get(rdev, &rdev->config.r300.resync_scratch);
> - radeon_ring_lock(rdev, ring, 8);
> + r = radeon_ring_lock(rdev, ring, 8);
> + WARN_ON(r);
> radeon_ring_write(ring, PACKET0(R300_CP_RESYNC_ADDR, 1));
> radeon_ring_write(ring, rdev->config.r300.resync_scratch);
> radeon_ring_write(ring, 0xDEADBEEF);
> @@ -224,12 +226,14 @@ static void r420_cp_errata_init(struct radeon_device *rdev)
>
> static void r420_cp_errata_fini(struct radeon_device *rdev)
> {
> + int r;
> struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
>
> /* Catch the RESYNC we dispatched all the way back,
> * at the very beginning of the CP init.
> */
> - radeon_ring_lock(rdev, ring, 8);
> + r = radeon_ring_lock(rdev, ring, 8);
> + WARN_ON(r);
> radeon_ring_write(ring, PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));
> radeon_ring_write(ring, R300_RB3D_DC_FINISH);
> radeon_ring_unlock_commit(rdev, ring, false);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] drm/radeon: check return value of radeon_ring_lock
@ 2017-04-24 7:47 ` Christian König
0 siblings, 0 replies; 6+ messages in thread
From: Christian König @ 2017-04-24 7:47 UTC (permalink / raw)
To: Pan Bian, Alex Deucher, Christian König, David Airlie
Cc: Pan Bian, dri-devel, amd-gfx, linux-kernel
Am 23.04.2017 um 15:36 schrieb Pan Bian:
> From: Pan Bian <bianpan2016@163.com>
>
> Function radeon_ring_lock() returns an errno on failure, and its return
> value should be validated. However, in functions r420_cp_errata_init()
> and r420_cp_errata_fini(), its return value is not checked. This patch
> adds the checks.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
> drivers/gpu/drm/radeon/r420.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
> index 2828605..a8c2b37 100644
> --- a/drivers/gpu/drm/radeon/r420.c
> +++ b/drivers/gpu/drm/radeon/r420.c
> @@ -215,7 +215,8 @@ static void r420_cp_errata_init(struct radeon_device *rdev)
> * of the CP init, apparently.
> */
> radeon_scratch_get(rdev, &rdev->config.r300.resync_scratch);
> - radeon_ring_lock(rdev, ring, 8);
> + if (radeon_ring_lock(rdev, ring, 8))
> + return;
Nice that somebody wants to clean that up, but just returning here is
not a good idea.
Additional to that radeon_ring_lock() can only fail if we try to
allocate to many dw (impossible with only 8) or the hardware is crashed
and then it doesn't matter anyway.
I suggest to just add a WARN_ON() here.
Regards,
Christian.
> radeon_ring_write(ring, PACKET0(R300_CP_RESYNC_ADDR, 1));
> radeon_ring_write(ring, rdev->config.r300.resync_scratch);
> radeon_ring_write(ring, 0xDEADBEEF);
> @@ -229,7 +230,8 @@ static void r420_cp_errata_fini(struct radeon_device *rdev)
> /* Catch the RESYNC we dispatched all the way back,
> * at the very beginning of the CP init.
> */
> - radeon_ring_lock(rdev, ring, 8);
> + if (radeon_ring_lock(rdev, ring, 8))
> + return;
> radeon_ring_write(ring, PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));
> radeon_ring_write(ring, R300_RB3D_DC_FINISH);
> radeon_ring_unlock_commit(rdev, ring, false);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] drm/radeon: check return value of radeon_ring_lock
@ 2017-04-24 7:47 ` Christian König
0 siblings, 0 replies; 6+ messages in thread
From: Christian König @ 2017-04-24 7:47 UTC (permalink / raw)
To: Pan Bian, Alex Deucher, Christian König, David Airlie
Cc: Pan Bian, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Am 23.04.2017 um 15:36 schrieb Pan Bian:
> From: Pan Bian <bianpan2016@163.com>
>
> Function radeon_ring_lock() returns an errno on failure, and its return
> value should be validated. However, in functions r420_cp_errata_init()
> and r420_cp_errata_fini(), its return value is not checked. This patch
> adds the checks.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
> drivers/gpu/drm/radeon/r420.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
> index 2828605..a8c2b37 100644
> --- a/drivers/gpu/drm/radeon/r420.c
> +++ b/drivers/gpu/drm/radeon/r420.c
> @@ -215,7 +215,8 @@ static void r420_cp_errata_init(struct radeon_device *rdev)
> * of the CP init, apparently.
> */
> radeon_scratch_get(rdev, &rdev->config.r300.resync_scratch);
> - radeon_ring_lock(rdev, ring, 8);
> + if (radeon_ring_lock(rdev, ring, 8))
> + return;
Nice that somebody wants to clean that up, but just returning here is
not a good idea.
Additional to that radeon_ring_lock() can only fail if we try to
allocate to many dw (impossible with only 8) or the hardware is crashed
and then it doesn't matter anyway.
I suggest to just add a WARN_ON() here.
Regards,
Christian.
> radeon_ring_write(ring, PACKET0(R300_CP_RESYNC_ADDR, 1));
> radeon_ring_write(ring, rdev->config.r300.resync_scratch);
> radeon_ring_write(ring, 0xDEADBEEF);
> @@ -229,7 +230,8 @@ static void r420_cp_errata_fini(struct radeon_device *rdev)
> /* Catch the RESYNC we dispatched all the way back,
> * at the very beginning of the CP init.
> */
> - radeon_ring_lock(rdev, ring, 8);
> + if (radeon_ring_lock(rdev, ring, 8))
> + return;
> radeon_ring_write(ring, PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));
> radeon_ring_write(ring, R300_RB3D_DC_FINISH);
> radeon_ring_unlock_commit(rdev, ring, false);
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/1] drm/radeon: check return value of radeon_ring_lock
@ 2017-04-23 13:36 Pan Bian
2017-04-24 7:47 ` Christian König
0 siblings, 1 reply; 6+ messages in thread
From: Pan Bian @ 2017-04-23 13:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie
Cc: amd-gfx, dri-devel, linux-kernel, Pan Bian
From: Pan Bian <bianpan2016@163.com>
Function radeon_ring_lock() returns an errno on failure, and its return
value should be validated. However, in functions r420_cp_errata_init()
and r420_cp_errata_fini(), its return value is not checked. This patch
adds the checks.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/gpu/drm/radeon/r420.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
index 2828605..a8c2b37 100644
--- a/drivers/gpu/drm/radeon/r420.c
+++ b/drivers/gpu/drm/radeon/r420.c
@@ -215,7 +215,8 @@ static void r420_cp_errata_init(struct radeon_device *rdev)
* of the CP init, apparently.
*/
radeon_scratch_get(rdev, &rdev->config.r300.resync_scratch);
- radeon_ring_lock(rdev, ring, 8);
+ if (radeon_ring_lock(rdev, ring, 8))
+ return;
radeon_ring_write(ring, PACKET0(R300_CP_RESYNC_ADDR, 1));
radeon_ring_write(ring, rdev->config.r300.resync_scratch);
radeon_ring_write(ring, 0xDEADBEEF);
@@ -229,7 +230,8 @@ static void r420_cp_errata_fini(struct radeon_device *rdev)
/* Catch the RESYNC we dispatched all the way back,
* at the very beginning of the CP init.
*/
- radeon_ring_lock(rdev, ring, 8);
+ if (radeon_ring_lock(rdev, ring, 8))
+ return;
radeon_ring_write(ring, PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));
radeon_ring_write(ring, R300_RB3D_DC_FINISH);
radeon_ring_unlock_commit(rdev, ring, false);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-04-24 9:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-24 8:38 [PATCH 1/1] drm/radeon: check return value of radeon_ring_lock Pan Bian
2017-04-24 9:08 ` Christian König
2017-04-24 9:08 ` Christian König
-- strict thread matches above, loose matches on Subject: below --
2017-04-23 13:36 Pan Bian
2017-04-24 7:47 ` Christian König
2017-04-24 7:47 ` Christian König
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.