[PATCH RFC 077/111] staging: etnaviv: fix event allocation failure path

Lucas Stach l.stach at pengutronix.de
Thu Apr 2 08:30:19 PDT 2015


From: Russell King <rmk+kernel at arm.linux.org.uk>

If we fail to allocate an event, we leave the submitted fence number
incremented.  This can cause an already running hangcheck timer to
believe that we should be waiting for further events when no event has
actually been queued.

Resolve this by moving the fence allocation (which can never fail)
after the event allocation.

Signed-off-by: Russell King <rmk+kernel at arm.linux.org.uk>
---
 drivers/staging/etnaviv/etnaviv_gpu.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/etnaviv/etnaviv_gpu.c b/drivers/staging/etnaviv/etnaviv_gpu.c
index 2ed8de8c522a..ffecce5236f9 100644
--- a/drivers/staging/etnaviv/etnaviv_gpu.c
+++ b/drivers/staging/etnaviv/etnaviv_gpu.c
@@ -890,13 +890,8 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
 {
 	struct drm_device *dev = gpu->drm;
 	struct etnaviv_drm_private *priv = dev->dev_private;
-	int ret = 0;
 	unsigned int event, i;
 
-	submit->fence = ++priv->next_fence;
-
-	gpu->submitted_fence = submit->fence;
-
 	/*
 	 * TODO
 	 *
@@ -909,10 +904,13 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
 	event = event_alloc(gpu);
 	if (unlikely(event == ~0U)) {
 		DRM_ERROR("no free event\n");
-		ret = -EBUSY;
-		goto fail;
+		return -EBUSY;
 	}
 
+	submit->fence = ++priv->next_fence;
+
+	gpu->submitted_fence = submit->fence;
+
 	etnaviv_buffer_queue(gpu, event, submit);
 
 	priv->lastctx = ctx;
@@ -942,8 +940,7 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
 	}
 	hangcheck_timer_reset(gpu);
 
-fail:
-	return ret;
+	return 0;
 }
 
 /*
-- 
2.1.4



More information about the dri-devel mailing list