From: Daniel Vetter Subject: Re: [PATCH] drm/i915: fix gpu hang vs. flip stall deadlocks Date: Thu, 5 Sep 2013 14:38:38 +0200 Message-ID: <20130905123838.GE27291@phenom.ffwll.local> References: <20130904102343.GJ24319@nuc-i3427.alporthouse.com> <1378308974-25829-1-git-send-email-daniel.vetter@ffwll.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Content-Disposition: inline In-Reply-To: <1378308974-25829-1-git-send-email-daniel.vetter@ffwll.ch> Sender: stable-owner@vger.kernel.org To: Intel Graphics Development Cc: Daniel Vetter , Thomas Gleixner , stable@vger.kernel.org, Ville =?iso-8859-1?Q?Syrj=E4l=E4?= , Chris Wilson List-Id: intel-gfx@lists.freedesktop.org On Wed, Sep 04, 2013 at 05:36:14PM +0200, Daniel Vetter wrote: > Since we've started to clean up pending flips when the gpu hangs in >=20 > commit 96a02917a0131e52efefde49c2784c0421d6c439 > Author: Ville Syrj=E4l=E4 > Date: Mon Feb 18 19:08:49 2013 +0200 >=20 > drm/i915: Finish page flips and update primary planes after a GPU= reset >=20 > the gpu reset work now also grabs modeset locks. But since since work > items on our private work queue are not allowed to do that due to the > flush_workqueue from the pageflip code this results in a neat > deadlock: >=20 > INFO: task kms_flip:14676 blocked for more than 120 seconds. > "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this mess= age. > kms_flip D ffff88019283a5c0 0 14676 13344 0x00000004 > ffff88018e62dbf8 0000000000000046 ffff88013bdb12e0 ffff88018e62dfd8 > ffff88018e62dfd8 00000000001d3b00 ffff88019283a5c0 ffff88018ec21000 > ffff88018f693f00 ffff88018eece000 ffff88018e62dd60 ffff88018eece898 > Call Trace: > [] schedule+0x60/0x62 > [] intel_crtc_wait_for_pending_flips+0xb2/0x114 [i= 915] > [] ? finish_wait+0x60/0x60 > [] intel_crtc_set_config+0x7f3/0x81e [i915] > [] drm_mode_set_config_internal+0x4f/0xc6 [drm] > [] drm_mode_setcrtc+0x44d/0x4f9 [drm] > [] ? might_fault+0x38/0x86 > [] drm_ioctl+0x2f9/0x447 [drm] > [] ? trace_hardirqs_off+0xd/0xf > [] ? drm_mode_setplane+0x343/0x343 [drm] > [] ? mntput_no_expire+0x3e/0x13d > [] vfs_ioctl+0x18/0x34 > [] do_vfs_ioctl+0x396/0x454 > [] ? sysret_check+0x1b/0x56 > [] SyS_ioctl+0x52/0x7d > [] system_call_fastpath+0x16/0x1b > 2 locks held by kms_flip/14676: > #0: (&dev->mode_config.mutex){+.+.+.}, at: [] drm= _modeset_lock_all+0x22/0x59 [drm] > #1: (&crtc->mutex){+.+.+.}, at: [] drm_modeset_lo= ck_all+0x48/0x59 [drm] > INFO: task kworker/u8:4:175 blocked for more than 120 seconds. > "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this mess= age. > kworker/u8:4 D ffff88018de9a5c0 0 175 2 0x00000000 > Workqueue: i915 i915_error_work_func [i915] > ffff88018e37dc30 0000000000000046 ffff8801938ab8a0 ffff88018e37dfd8 > ffff88018e37dfd8 00000000001d3b00 ffff88018de9a5c0 ffff88018ec21018 > 0000000000000246 ffff88018e37dca0 000000005a865a86 ffff88018de9a5c0 > Call Trace: > [] schedule+0x60/0x62 > [] schedule_preempt_disabled+0x9/0xb > [] mutex_lock_nested+0x205/0x3b1 > [] ? intel_display_handle_reset+0x7e/0xbd [i915] > [] ? intel_display_handle_reset+0x7e/0xbd [i915] > [] intel_display_handle_reset+0x7e/0xbd [i915] > [] i915_error_work_func+0x128/0x147 [i915] > [] process_one_work+0x1d4/0x35a > [] ? process_one_work+0x15b/0x35a > [] worker_thread+0x144/0x1f0 > [] ? rescuer_thread+0x275/0x275 > [] kthread+0xac/0xb4 > [] ? finish_task_switch+0x3b/0xc0 > [] ? __kthread_parkme+0x60/0x60 > [] ret_from_fork+0x7c/0xb0 > [] ? __kthread_parkme+0x60/0x60 > 3 locks held by kworker/u8:4/175: > #0: (i915){.+.+.+}, at: [] process_one_work+0x15b= /0x35a > #1: ((&dev_priv->gpu_error.work)){+.+.+.}, at: []= process_one_work+0x15b/0x35a > #2: (&crtc->mutex){+.+.+.}, at: [] intel_display_= handle_reset+0x7e/0xbd [i915] >=20 > This blew up while running kms_flip/flip-vs-panning-vs-hang-interrupt= ible > on one of my older machines. >=20 > Unfortunately (despite the proper lockdep annotations for > flush_workqueue) lockdep still doesn't detect this correctly, so we > need to rely on change to discover these bugs. >=20 > Apply the usual bugfix and schedule the reset work on the system > workqueue to keep our own driver workqueue free of any modeset lock > grabbing. >=20 > Note that this is not a terribly serious regression since before the > offending commit we'd simply have stalled userspace forever due to > failing to abort all outstanding pageflips. >=20 > v2: Add a comment as requested by Chris. >=20 > Cc: Thomas Gleixner > Cc: stable@vger.kernel.org > Cc: Ville Syrj=E4l=E4 > Cc: Chris Wilson > Signed-off-by: Daniel Vetter Picked up for -fixes with a bit of the spelling fail rectified and Chri= s' irc r-b added (he still suffers from overtly hungry mail eating demons = in his cellar ...). -Daniel --=20 Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch