Skip to contentSkip to conversation

panfrost: Don't cleanup the job if it was successfully queued

PATCH In review Boris Brezillon 3 participants 3 messages Aug 31, 2021 – Sep 1, 2021

Subsystems (3)
lore
Share & tools
lore

Boris Brezillon

author maintainer
#0 lore raw

PATCH 1/1 panfrost: Don't cleanup the job if it was successfully queued

The labels are misleading. Even though they are all prefixed with 'fail_' the success case also takes that path, and we should definitely not cleanup the job if it's been queued. While at it, let's rename those labels so we don't do the same mistake again.

Fixes 53516280cc38 ("drm/panfrost: use scheduler dependency tracking")
---
 drivers/gpu/drm/panfrost/panfrost_drv.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/gpu/drm/panfrost/panfrost_drv.c +10 -9
index 16212b6b202e..077cbbfa506b 100644
@@ -253,7 +253,7 @@ static int panfrost_ioctl_submit(struct drm_device *dev, void *data,
 	job = kzalloc(sizeof(*job), GFP_KERNEL);
 	if (!job) {
 		ret = -ENOMEM;
-		goto fail_out_sync;
+		goto out_put_syncout;
 	}
 
 	kref_init(&job->refcount);
@@ -270,29 +270,30 @@ static int panfrost_ioctl_submit(struct drm_device *dev, void *data,
 				 &job->file_priv->sched_entity[slot],
 				 NULL);
 	if (ret)
-		goto fail_job_put;
+		goto out_put_job;
 
 	ret = panfrost_copy_in_sync(dev, file, args, job);
 	if (ret)
-		goto fail_job;
+		goto out_cleanup_job;
 
 	ret = panfrost_lookup_bos(dev, file, args, job);
 	if (ret)
-		goto fail_job;
+		goto out_cleanup_job;
 
 	ret = panfrost_job_push(job);
 	if (ret)
-		goto fail_job;
+		goto out_cleanup_job;
 
 	/* Update the return sync object for the job */
 	if (sync_out)
 		drm_syncobj_replace_fence(sync_out, job->render_done_fence);
 
-fail_job:
-	drm_sched_job_cleanup(&job->base);
-fail_job_put:
+out_cleanup_job:
+	if (ret)
+		drm_sched_job_cleanup(&job->base);
+out_put_job:
 	panfrost_job_put(job);
-fail_out_sync:
+out_put_syncout:
 	if (sync_out)
 		drm_syncobj_put(sync_out);
 
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Boris Brezillon

The labels are misleading. Even though they are all prefixed with 'fail_' the success case also takes that path, and we should definitely not cleanup the job if it's been queued. While at it, let's rename those labels so we don't do the same mistake again.

Fixes 53516280cc38 ("drm/panfrost: use scheduler dependency tracking")

Oops sorry about that, I thought I've had a t-b from panfrost already?

Anyway this looks good to me:

Quoted 59 lines
---
 drivers/gpu/drm/panfrost/panfrost_drv.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/gpu/drm/panfrost/panfrost_drv.c +10 -9
index 16212b6b202e..077cbbfa506b 100644
@@ -253,7 +253,7 @@ static int panfrost_ioctl_submit(struct drm_device *dev, void *data,
 	job = kzalloc(sizeof(*job), GFP_KERNEL);
 	if (!job) {
 		ret = -ENOMEM;
-		goto fail_out_sync;
+		goto out_put_syncout;
 	}
 
 	kref_init(&job->refcount);
@@ -270,29 +270,30 @@ static int panfrost_ioctl_submit(struct drm_device *dev, void *data,
 				 &job->file_priv->sched_entity[slot],
 				 NULL);
 	if (ret)
-		goto fail_job_put;
+		goto out_put_job;
 
 	ret = panfrost_copy_in_sync(dev, file, args, job);
 	if (ret)
-		goto fail_job;
+		goto out_cleanup_job;
 
 	ret = panfrost_lookup_bos(dev, file, args, job);
 	if (ret)
-		goto fail_job;
+		goto out_cleanup_job;
 
 	ret = panfrost_job_push(job);
 	if (ret)
-		goto fail_job;
+		goto out_cleanup_job;
 
 	/* Update the return sync object for the job */
 	if (sync_out)
 		drm_syncobj_replace_fence(sync_out, job->render_done_fence);
 
-fail_job:
-	drm_sched_job_cleanup(&job->base);
-fail_job_put:
+out_cleanup_job:
+	if (ret)
+		drm_sched_job_cleanup(&job->base);
+out_put_job:
 	panfrost_job_put(job);
-fail_out_sync:
+out_put_syncout:
 	if (sync_out)
 		drm_syncobj_put(sync_out);
 
Signature · 1 line
2.31.1
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
maintainer Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Boris Brezillon
Quoted 7 lines · Boris Brezillon

The labels are misleading. Even though they are all prefixed with 'fail_' the success case also takes that path, and we should definitely not cleanup the job if it's been queued. While at it, let's rename those labels so we don't do the same mistake again.

Fixes 53516280cc38 ("drm/panfrost: use scheduler dependency tracking")

And also unlike last time...

Thanks for the clean up - I should have actually tested the previous patch, but from the diff (and the previous label names) it was obviously correct™! But it of course blows up pretty quickly without this change.

Thanks,

Steve

Quoted 57 lines
---
 drivers/gpu/drm/panfrost/panfrost_drv.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/gpu/drm/panfrost/panfrost_drv.c +10 -9
index 16212b6b202e..077cbbfa506b 100644
@@ -253,7 +253,7 @@ static int panfrost_ioctl_submit(struct drm_device *dev, void *data,
 	job = kzalloc(sizeof(*job), GFP_KERNEL);
 	if (!job) {
 		ret = -ENOMEM;
-		goto fail_out_sync;
+		goto out_put_syncout;
 	}
 
 	kref_init(&job->refcount);
@@ -270,29 +270,30 @@ static int panfrost_ioctl_submit(struct drm_device *dev, void *data,
 				 &job->file_priv->sched_entity[slot],
 				 NULL);
 	if (ret)
-		goto fail_job_put;
+		goto out_put_job;
 
 	ret = panfrost_copy_in_sync(dev, file, args, job);
 	if (ret)
-		goto fail_job;
+		goto out_cleanup_job;
 
 	ret = panfrost_lookup_bos(dev, file, args, job);
 	if (ret)
-		goto fail_job;
+		goto out_cleanup_job;
 
 	ret = panfrost_job_push(job);
 	if (ret)
-		goto fail_job;
+		goto out_cleanup_job;
 
 	/* Update the return sync object for the job */
 	if (sync_out)
 		drm_syncobj_replace_fence(sync_out, job->render_done_fence);
 
-fail_job:
-	drm_sched_job_cleanup(&job->base);
-fail_job_put:
+out_cleanup_job:
+	if (ret)
+		drm_sched_job_cleanup(&job->base);
+out_put_job:
 	panfrost_job_put(job);
-fail_out_sync:
+out_put_syncout:
 	if (sync_out)
 		drm_syncobj_put(sync_out);