dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jerry Zuo <Jerry.Zuo-5C7GfCeVMHo@public.gmane.org>
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: daniel.vetter-/w4YWyX8dFk@public.gmane.org,
	Jerry Zuo <Jerry.Zuo-5C7GfCeVMHo@public.gmane.org>,
	harry.wentland-5C7GfCeVMHo@public.gmane.org
Subject: [PATCH] drm/atomic: put commit when -ERESTARTSYS received
Date: Thu, 17 Aug 2017 10:21:18 -0400	[thread overview]
Message-ID: <20170817142118.28295-1-Jerry.Zuo@amd.com> (raw)

During page flip atomic_check and atomic_commit can return
-ERESTARTSYS to restart the ioctl. When this happens we fail to
put the commit object leading to a memory leak.

v2: Changed subject tag to drm/atomic

Signed-off-by: Jerry Zuo <Jerry.Zuo@amd.com>
---
 drivers/gpu/drm/drm_atomic.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index f32506a7c1d6..f2f623dacf90 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1642,14 +1642,35 @@ int drm_atomic_nonblocking_commit(struct drm_atomic_state *state)
 {
 	struct drm_mode_config *config = &state->dev->mode_config;
 	int ret;
+	int i;
+	struct drm_crtc *crtc;
+	struct drm_crtc_state *crtc_state;
 
 	ret = drm_atomic_check_only(state);
-	if (ret)
+	if (ret) {
+		if (ret == -ERESTARTSYS)
+			goto fail;
+
 		return ret;
+	}
 
 	DRM_DEBUG_ATOMIC("commiting %p nonblocking\n", state);
 
-	return config->funcs->atomic_commit(state->dev, state, true);
+	ret = config->funcs->atomic_commit(state->dev, state, true);
+	if (ret == -ERESTARTSYS)
+		goto fail;
+
+	return ret;
+
+	/* cleanup commit object if commit fails with ERESTARTSYS */
+fail:
+	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+		if (state->crtcs[i].commit) {
+			drm_crtc_commit_put(state->crtcs[i].commit);
+		}
+	}
+
+	return ret;
 }
 EXPORT_SYMBOL(drm_atomic_nonblocking_commit);
 
-- 
2.11.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

             reply	other threads:[~2017-08-17 14:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-17 14:21 Jerry Zuo [this message]
2017-08-18  7:42 ` [PATCH] drm/atomic: put commit when -ERESTARTSYS received Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170817142118.28295-1-Jerry.Zuo@amd.com \
    --to=jerry.zuo-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=daniel.vetter-/w4YWyX8dFk@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=harry.wentland-5C7GfCeVMHo@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox