Skip to contentSkip to conversation

drm/amd/display: put commit when -ERESTARTSYS received

PATCH In review Jerry Zuo 4 participants 4 messages Aug 16, 2017

Subsystems (2)
lore
Share & tools
lore

Jerry Zuo

author
#0 lore raw

PATCH 1/1 drm/amd/display: put commit when -ERESTARTSYS received

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.

---
 drivers/gpu/drm/drm_atomic.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic.c +23 -2
index f32506a7c1d6..f2f623dacf90 100644
@@ -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);
 
Signature · 6 lines
2.11.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw
Quoted 5 lines · Jerry Zuo

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.

The subject should be:
drm/atomic: put commit when -ERESTARTSYS received
Since the change is in the core atomic code.

Alex

Quoted 49 lines
---
 drivers/gpu/drm/drm_atomic.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic.c +23 -3
index f32506a7c1d6..f2f623dacf90 100644
@@ -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

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 10 lines · Alex Deucher
Quoted 5 lines · Jerry Zuo

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.

The subject should be:
drm/atomic: put commit when -ERESTARTSYS received
Since the change is in the core atomic code.

Do we have an igt testcase to exercise this? This is the kind of error case handling igt really is made for, and igt has ready-made helpers to interrupt ioctls. I think Maarten was even working on such a testcase, adding him.
-Daniel

Quoted 56 lines

Alex

Quoted 53 lines
---
 drivers/gpu/drm/drm_atomic.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic.c +23 -3
index f32506a7c1d6..f2f623dacf90 100644
@@ -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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
Quoted 8 lines · Daniel Vetter
Quoted 7 lines · Alex Deucher
Quoted 5 lines · Jerry Zuo

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.

Quoted 8 lines
Quoted 3 lines

The subject should be:
drm/atomic: put commit when -ERESTARTSYS received
Since the change is in the core atomic code.

Do we have an igt testcase to exercise this? This is the kind of error case handling igt really is made for, and igt has ready-made helpers to interrupt ioctls. I think Maarten was even working on such a testcase, adding him.

I'm not aware of an IGT test for this. We triggered this scenario when running mode changes while glxgears is running. We observed no user-visible issue, only a memory leak. Is IGT able to capture those (semi-)reliably?

I agree that it would be great to have an IGT test for these corner cases.

Harry

Quoted 50 lines

-Daniel

Quoted 49 lines
Quoted 1 line

Alex

Quoted 46 lines
---
 drivers/gpu/drm/drm_atomic.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic.c +23 -2
index f32506a7c1d6..f2f623dacf90 100644
@@ -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);
 
Quoted 10 lines
Quoted 7 lines
Quoted 7 lines

--
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel