public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Dave Airlie <airlied@gmail.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/mst: fix recursive sleep warning on qlock
Date: Wed, 28 Jan 2015 10:02:23 +0100	[thread overview]
Message-ID: <20150128090223.GE4764@phenom.ffwll.local> (raw)
In-Reply-To: <1422416221-3484-1-git-send-email-airlied@gmail.com>

On Wed, Jan 28, 2015 at 04:37:01PM +1300, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> With drm-next, we can get a backtrace like below,
> this is due to the callback checking the txmsg state taking
> the mutex, which can cause a sleep inside a sleep,
> 
> Fix this my creating a spinlock protecting the txmsg state
> and locking it in appropriate places.
> 
> : ------------[ cut here ]------------
> : WARNING: CPU: 3 PID: 252 at kernel/sched/core.c:7300 __might_sleep+0xbd/0xd0()
> : do not call blocking ops when !TASK_RUNNING; state=2 set at [<ffffffff810db8ad>] prepare_to_wait_event+0x5d/0x110
> : Modules linked in: i915 i2c_algo_bit drm_kms_helper drm e1000e ptp pps_core i2c_core video
> : CPU: 3 PID: 252 Comm: kworker/3:2 Not tainted 3.19.0-rc5+ #18
> : Hardware name: LENOVO 20ARS25701/20ARS25701, BIOS GJET72WW (2.22 ) 02/21/2014
> : Workqueue: events_long drm_dp_mst_link_probe_work [drm_kms_helper]
> :  ffffffff81a4027c ffff88030a763af8 ffffffff81752699 0000000000000000
> :  ffff88030a763b48 ffff88030a763b38 ffffffff810974ca ffff88030a763b38
> :  ffffffff81a41123 000000000000026d 0000000000000000 0000000000000fa0
> : Call Trace:
> :  [<ffffffff81752699>] dump_stack+0x4c/0x65
> :  [<ffffffff810974ca>] warn_slowpath_common+0x8a/0xc0
> :  [<ffffffff81097546>] warn_slowpath_fmt+0x46/0x50
> :  [<ffffffff810db8ad>] ? prepare_to_wait_event+0x5d/0x110
> :  [<ffffffff810db8ad>] ? prepare_to_wait_event+0x5d/0x110
> :  [<ffffffff810bdaad>] __might_sleep+0xbd/0xd0
> :  [<ffffffff817566de>] mutex_lock_nested+0x2e/0x3e0
> :  [<ffffffff810db8e8>] ? prepare_to_wait_event+0x98/0x110
> :  [<ffffffffa00e43d7>] drm_dp_mst_wait_tx_reply+0xa7/0x220 [drm_kms_helper]
> :  [<ffffffff810db790>] ? wait_woken+0xc0/0xc0
> :  [<ffffffffa00e6401>] drm_dp_send_link_address+0x61/0x240 [drm_kms_helper]
> :  [<ffffffff810b1aaf>] ? process_one_work+0x14f/0x530
> :  [<ffffffffa00e6abd>] drm_dp_check_and_send_link_address+0x8d/0xa0 [drm_kms_helper]
> :  [<ffffffffa00e6aec>] drm_dp_mst_link_probe_work+0x1c/0x20 [drm_kms_helper]
> :  [<ffffffff810b1b26>] process_one_work+0x1c6/0x530
> :  [<ffffffff810b1aaf>] ? process_one_work+0x14f/0x530
> :  [<ffffffff810b224b>] worker_thread+0x6b/0x490
> :  [<ffffffff810b21e0>] ? rescuer_thread+0x350/0x350
> :  [<ffffffff810b73ea>] kthread+0x10a/0x120
> :  [<ffffffff8175a800>] ? _raw_spin_unlock_irq+0x30/0x50
> :  [<ffffffff810b72e0>] ? kthread_create_on_node+0x220/0x220
> :  [<ffffffff8175b1fc>] ret_from_fork+0x7c/0xb0
> :  [<ffffffff810b72e0>] ? kthread_create_on_node+0x220/0x220
> : ---[ end trace bb11c9634a7217c6 ]---
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Imo much simpler with the below diff. Not tested though.
-Daniel
--
diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 9a5b68717ec8..379ab4555756 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -733,10 +733,14 @@ static bool check_txmsg_state(struct drm_dp_mst_topology_mgr *mgr,
 			      struct drm_dp_sideband_msg_tx *txmsg)
 {
 	bool ret;
-	mutex_lock(&mgr->qlock);
+
+	/*
+	 * All updates to txmsg->state are protected by mgr->qlock, and the two
+	 * cases we check here are terminal states. For those the barriers
+	 * provided by the wake_up/wait_event pair are enough.
+	 */
 	ret = (txmsg->state == DRM_DP_SIDEBAND_TX_RX ||
 	       txmsg->state == DRM_DP_SIDEBAND_TX_TIMEOUT);
-	mutex_unlock(&mgr->qlock);
 	return ret;
 }
 
@@ -1363,12 +1367,13 @@ static int process_single_tx_qlock(struct drm_dp_mst_topology_mgr *mgr,
 	return 0;
 }
 
-/* must be called holding qlock */
 static void process_single_down_tx_qlock(struct drm_dp_mst_topology_mgr *mgr)
 {
 	struct drm_dp_sideband_msg_tx *txmsg;
 	int ret;
 
+	WARN_ON(!mutex_is_locked(&mgr->qlock));
+
 	/* construct a chunk from the first msg in the tx_msg queue */
 	if (list_empty(&mgr->tx_msg_downq)) {
 		mgr->tx_down_in_progress = false;
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-01-28  9:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-28  3:37 [PATCH] drm/mst: fix recursive sleep warning on qlock Dave Airlie
2015-01-28  9:02 ` Daniel Vetter [this message]
2015-02-01 10:52 ` shuang.he

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=20150128090223.GE4764@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.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