Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1629027 > unrolled thread

[PATCH 1/1] drm/radeon: check return value of radeon_ring_lock

Started byPan Bian <bianpan201603@163.com>
First post2017-04-23 15:40 +0200
Last post2017-04-24 09:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/1] drm/radeon: check return value of radeon_ring_lock Pan Bian <bianpan201603@163.com> - 2017-04-23 15:40 +0200
    Re: [PATCH 1/1] drm/radeon: check return value of radeon_ring_lock Christian König <deathsimple@vodafone.de> - 2017-04-24 09:50 +0200

#1629027 — [PATCH 1/1] drm/radeon: check return value of radeon_ring_lock

FromPan Bian <bianpan201603@163.com>
Date2017-04-23 15:40 +0200
Subject[PATCH 1/1] drm/radeon: check return value of radeon_ring_lock
Message-ID<tzpU5-Fe-7@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1629273

FromChristian König <deathsimple@vodafone.de>
Date2017-04-24 09:50 +0200
Message-ID<tzGUW-48t-5@gated-at.bofh.it>
In reply to#1629027
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);

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web