diff mbox series

drm/atomic-helper: Call stall_checks() before allocate drm_crtc_commit

Message ID 20231106073742.158905-1-oushixiong@kylinos.cn (mailing list archive)
State New, archived
Headers show
Series drm/atomic-helper: Call stall_checks() before allocate drm_crtc_commit | expand

Commit Message

oushixiong Nov. 6, 2023, 7:37 a.m. UTC
From: Shixiong Ou <oushixiong@kylinos.cn>

Calling stall_checks() before allocating drm_crtc_commit not after that.

Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
---
 drivers/gpu/drm/drm_atomic_helper.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

mripard@kernel.org Nov. 6, 2023, 10:32 a.m. UTC | #1
Hi,

On Mon, Nov 06, 2023 at 03:37:42PM +0800, oushixiong wrote:
> From: Shixiong Ou <oushixiong@kylinos.cn>
> 
> Calling stall_checks() before allocating drm_crtc_commit not after that.
> 
> Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>

Generally speaking, we need much more context than that.

What bug did you encounter that makes you say that it should be moved?
How can we reproduce it? How long has that issue been in the code? What
makes you say that this is the right solution?

Maxime
oushixiong Nov. 6, 2023, 1:26 p.m. UTC | #2
Hi,  
I think it will cause memory leaks if too many nonblock commit works return
-EBUSY.
You can try to send large number of nonblock commits by
drmModeAtomicCommit().

-----邮件原件-----
发件人: Maxime Ripard <mripard@kernel.org> 
发送时间: 2023年11月6日 18:33
收件人: oushixiong <oushixiong@kylinos.cn>
抄送: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>; Thomas
Zimmermann <tzimmermann@suse.de>; David Airlie <airlied@gmail.com>; Daniel
Vetter <daniel@ffwll.ch>; dri-devel@lists.freedesktop.org;
linux-kernel@vger.kernel.org
主题: Re: [PATCH] drm/atomic-helper: Call stall_checks() before allocate
drm_crtc_commit

Hi,

On Mon, Nov 06, 2023 at 03:37:42PM +0800, oushixiong wrote:
> From: Shixiong Ou <oushixiong@kylinos.cn>
> 
> Calling stall_checks() before allocating drm_crtc_commit not after that.
> 
> Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>

Generally speaking, we need much more context than that.

What bug did you encounter that makes you say that it should be moved?
How can we reproduce it? How long has that issue been in the code? What
makes you say that this is the right solution?

Maxime
mripard@kernel.org Nov. 6, 2023, 3:37 p.m. UTC | #3
Hi,

On Mon, Nov 06, 2023 at 09:26:15PM +0800, oushixiong@kylinos.cn wrote:
> I think it will cause memory leaks if too many nonblock commit works return
> -EBUSY.

Do you *think* or are you sure?

If you are sure, then please write down everything I mentioned earlier
in the commit log and resend the patch.

Maxime
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 2444fc33dd7c..94ea878b240d 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -2283,6 +2283,10 @@  int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 	funcs = state->dev->mode_config.helper_private;
 
 	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+		ret = stall_checks(crtc, nonblock);
+		if (ret)
+			return ret;
+
 		commit = kzalloc(sizeof(*commit), GFP_KERNEL);
 		if (!commit)
 			return -ENOMEM;
@@ -2291,10 +2295,6 @@  int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 
 		new_crtc_state->commit = commit;
 
-		ret = stall_checks(crtc, nonblock);
-		if (ret)
-			return ret;
-
 		/*
 		 * Drivers only send out events when at least either current or
 		 * new CRTC state is active. Complete right away if everything