AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Shirish S <shirish.s-5C7GfCeVMHo@public.gmane.org>
To: harry.wentland-5C7GfCeVMHo@public.gmane.org,
	sunpeng.li-5C7GfCeVMHo@public.gmane.org
Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	Shirish S <shirish.s-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH] drm/amd/display: move the nonblocking commit helpers appropriately
Date: Mon, 24 Sep 2018 19:01:47 +0530	[thread overview]
Message-ID: <1537795907-1168-1-git-send-email-shirish.s@amd.com> (raw)

[Why]
In multi-monitor scenario, if first crtc's flip done event occurs delayed
(but within timeout), due to non-blocking design of commit_tail(), there
are more than one commit's scheduled by the time the second crtc's
wait_for_completion_timeout() is called in drm_atomic_helper_wait_for_flip_done.

Due to these in-between additions and deletions in the atomic state, it is
found that the system fails while accessing common data structures of the
second crtc in drm_atomic_helper_wait_for_flip_done(), leading to crash as
below:

	BUG: unable to handle kernel paging request at 000000010000001c
	IP: do_raw_spin_lock+0xf/0x94
	PGD 0 P4D 0
	Oops: 0000 [#1] PREEMPT SMP NOPTI
	Call Trace:
	 __wait_for_common+0x36/0x60
	 drm_atomic_helper_wait_for_flip_done+0x47/0x89
	 amdgpu_dm_atomic_commit_tail+0xf4b/0xf84
	 ? drm_atomic_helper_wait_for_dependencies+0x1cd/0x217
	 commit_tail+0x41/0x5f

[How]
Move drm_atomic_helper_commit_hw_done() post wait_for_flip_done(),
which cleans up the atomic state's commit and completes pending hw_done and
flip_done works as a result there wont be dangling flip waits on random commits.

Signed-off-by: Shirish S <shirish.s@amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 0f10d92..41a1958 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4626,12 +4626,17 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 	}
 	spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
 
-	/* Signal HW programming completion */
-	drm_atomic_helper_commit_hw_done(state);
 
 	if (wait_for_vblank)
 		drm_atomic_helper_wait_for_flip_done(dev, state);
 
+	/* Atomic state pointer gets corrupted in case of frequent
+	 * modesets operations like changing resolutions.
+	 * Hence discard state->commit before signalling to user
+	 * space.
+	 */
+	drm_atomic_helper_commit_hw_done(state);
+
 	drm_atomic_helper_cleanup_planes(dev, state);
 
 	/*
-- 
2.7.4

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

             reply	other threads:[~2018-09-24 13:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-24 13:31 Shirish S [this message]
     [not found] ` <1537795907-1168-1-git-send-email-shirish.s-5C7GfCeVMHo@public.gmane.org>
2018-09-28 13:16   ` [PATCH] drm/amd/display: Work around race beetween hw_done and wait_for_flip Harry Wentland
     [not found]     ` <20180928131606.15931-1-harry.wentland-5C7GfCeVMHo@public.gmane.org>
2018-10-01  9:06       ` S, Shirish
2018-10-01 23:26   ` [PATCH v2] drm/amd/display: Signal hw_done() after waiting for flip_done() sunpeng.li-5C7GfCeVMHo
     [not found]     ` <1538436399-28084-1-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org>
2018-10-02 14:41       ` Harry Wentland

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=1537795907-1168-1-git-send-email-shirish.s@amd.com \
    --to=shirish.s-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=harry.wentland-5C7GfCeVMHo@public.gmane.org \
    --cc=sunpeng.li-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