From: Roland Dreier <rdreier@cisco.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Kernel Testers List <kernel-testers@vger.kernel.org>,
"Brandeburg\, Jesse" <jesse.brandeburg@intel.com>,
drivers_video-dri@kernel-bugs.osdl.org
Subject: Re: [Bug #12491] i915 lockdep warning
Date: Wed, 04 Feb 2009 14:37:34 -0800 [thread overview]
Message-ID: <adar62dltg1.fsf@cisco.com> (raw)
In-Reply-To: <pWZw1SZjMCH.A.ciH.4vYiJB@chimera> (Rafael J. Wysocki's message of "Wed, 4 Feb 2009 11:23:57 +0100 (CET)")
> Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=12491
> Subject : i915 lockdep warning
> Submitter : Brandeburg, Jesse <jesse.brandeburg@intel.com>
> Date : 2009-01-13 23:17 (23 days old)
> References : http://marc.info/?l=linux-kernel&m=123188898423532&w=4
Looking at the code, it seems that the issue is that the DRM
struct_mutex must be taken inside mmap_sem (because struct_mutex is
taken in drm_vm_open(), which is called with mmap_sem already held), but
i915_gem_execbuffer() does a copy_to_user() while holding struct_mutex,
and if this copy faults, then the VM tries to acquire mmap_sem -- ie
lockdep identifies correctly a potential AB/BA deadlock.
I don't pretend to fully understand the DRM or GEM, but a possible fix
is below -- would be worth it to test and review, and get into 2.6.29 if
it is a correct fix:
---
i915: Fix potential AB-BA deadlock in i915_gem_execbuffer()
Lockdep warns that i915_gem_execbuffer() can trigger a page fault (which
takes mmap_sem) while holding dev->struct_mutex, while drm_vm_open()
(which is called with mmap_sem already held) takes dev->struct_mutex.
So this is a potential AB-BA deadlock.
The way that i915_gem_execbuffer() triggers a page fault is by doing
copy_to_user() when returning new buffer offsets back to userspace;
however there is no reason to hold the struct_mutex when doing this
copy, since what is being copied is a private array anyway. So we can
fix the potential deadlock (and get rid of the lockdep warning) by
simply moving the copy_to_user() outside of where struct_mutex is held.
This fixes <http://bugzilla.kernel.org/show_bug.cgi?id=12491>.
Reported-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
---
drivers/gpu/drm/i915/i915_gem.c | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index debad5c..23aad8c 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2610,15 +2610,6 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
i915_verify_inactive(dev, __FILE__, __LINE__);
- /* Copy the new buffer offsets back to the user's exec list. */
- ret = copy_to_user((struct drm_i915_relocation_entry __user *)
- (uintptr_t) args->buffers_ptr,
- exec_list,
- sizeof(*exec_list) * args->buffer_count);
- if (ret)
- DRM_ERROR("failed to copy %d exec entries "
- "back to user (%d)\n",
- args->buffer_count, ret);
err:
for (i = 0; i < pinned; i++)
i915_gem_object_unpin(object_list[i]);
@@ -2628,6 +2619,18 @@ err:
mutex_unlock(&dev->struct_mutex);
+ if (!ret) {
+ /* Copy the new buffer offsets back to the user's exec list. */
+ ret = copy_to_user((struct drm_i915_relocation_entry __user *)
+ (uintptr_t) args->buffers_ptr,
+ exec_list,
+ sizeof(*exec_list) * args->buffer_count);
+ if (ret)
+ DRM_ERROR("failed to copy %d exec entries "
+ "back to user (%d)\n",
+ args->buffer_count, ret);
+ }
+
pre_mutex_err:
drm_free(object_list, sizeof(*object_list) * args->buffer_count,
DRM_MEM_DRIVER);
next prev parent reply other threads:[~2009-02-04 22:37 UTC|newest]
Thread overview: 162+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-04 10:21 2.6.29-rc3-git6: Reported regressions from 2.6.28 Rafael J. Wysocki
2009-02-04 10:21 ` [Bug #12400] git-latest: kernel oops in IOMMU setup Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12414] iwl4965 cannot use "ap auto" on latest 2.6.28/29? Rafael J. Wysocki
2009-02-04 19:15 ` Jeff Chua
2009-02-05 1:37 ` Rafael J. Wysocki
2009-02-05 14:34 ` Jeff Chua
2009-02-14 11:41 ` Jeff Chua
2009-02-14 18:46 ` Jeff Chua
2009-02-14 20:10 ` Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12416] Recent change to kernel spikes out ccache/distcc Rafael J. Wysocki
2009-02-05 1:57 ` Theodore Tso
2009-02-05 2:13 ` Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12415] WARNING: at drivers/net/wireless/iwlwifi/iwl-sta.c:689 Rafael J. Wysocki
2009-02-04 13:04 ` Christian Borntraeger
2009-02-05 1:39 ` Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12427] cpumask change causes sparc build bustage Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12419] possible circular locking dependency on i915 dma Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12417] glx performance drop with: "x86: PAT: implement track/untrack of pfnmap regions for x86 - v3" Rafael J. Wysocki
2009-02-04 13:46 ` Ingo Molnar
2009-02-04 16:02 ` Alexey Fisher
2009-02-04 16:42 ` Ingo Molnar
2009-02-05 0:55 ` Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12418] Repeated ioctl(4, 0x40046445, ..) loop in glxgears Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12441] Xorg can't use dri on radeon X1950 AGP Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12491] i915 lockdep warning Rafael J. Wysocki
2009-02-04 22:37 ` Roland Dreier [this message]
2009-02-05 1:03 ` Rafael J. Wysocki
2009-02-06 22:46 ` Roland Dreier
2009-02-06 23:40 ` Jesse Barnes
2009-02-07 1:20 ` Brandeburg, Jesse
2009-02-07 1:48 ` Roland Dreier
2009-02-07 13:53 ` Rafael J. Wysocki
2009-02-11 0:43 ` Eric Anholt
2009-02-11 18:14 ` Roland Dreier
2009-02-04 10:23 ` [Bug #12490] ath5k related kernel panic in 2.6.29-rc1 Rafael J. Wysocki
2009-02-06 18:48 ` Bob Copeland
2009-02-06 23:55 ` Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12444] X hangs following switch from radeonfb console - Bisected Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12495] thinkpad problems during resume Rafael J. Wysocki
2009-02-04 13:06 ` Christian Borntraeger
2009-02-05 1:41 ` Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12496] swsusp cannot find resume device (sometimes) Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12494] Sony backlight regression from 2.6.28 to 29-rc Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12493] ACPI related kernel panic when booting 2.6.29-rc2 Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12499] Problem with using bluetooth adaper connected to usb port Rafael J. Wysocki
2009-02-04 10:23 ` [Bug #12497] new barrier warnings in 2.6.29-rc1 Rafael J. Wysocki
2009-02-06 8:12 ` Christoph Hellwig
2009-02-04 10:23 ` [Bug #12501] build bug in eeepc-laptop.c Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12505] 2.6.29-rc1 Firefox crashing on page load Rafael J. Wysocki
2009-02-04 15:23 ` Justin Mattock
2009-02-04 16:46 ` Ingo Molnar
2009-02-04 18:15 ` Justin Mattock
2009-02-05 1:08 ` Rafael J. Wysocki
2009-02-05 1:37 ` Justin Mattock
2009-02-04 10:24 ` [Bug #12502] pipe_read oops on sh Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12503] [slab corruption] BUG key_jar: Poison overwritten Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12506] Undefined symbols when CONFIG_MFD_PCF50633 is enabled Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12510] 2.6.29-rc2 dies on startup Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12508] "powerpc/pci: Reserve legacy regions on PCI" broke my G3 Rafael J. Wysocki
2009-02-04 21:44 ` Benjamin Herrenschmidt
2009-02-06 18:55 ` Mikael Pettersson
2009-02-04 10:24 ` [Bug #12509] lockdep report. fb_mmap vs sys_mmap2 Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12551] end_request: I/O error, dev cciss/c0d0, sector 87435720 Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12511] WARNING: at drivers/dma/dmaengine.c:352 Rafael J. Wysocki
2009-02-04 16:03 ` Dan Williams
2009-02-05 1:13 ` Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12538] xfs_fsr fails on 2.6.29-rc kernels Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12518] BUG: using smp_processor_id() in preemptible [00000000] code: dellWirelessCtl/ Rafael J. Wysocki
2009-02-04 15:58 ` Alex Riesen
2009-02-04 10:24 ` [Bug #12571] Suspend-resume on Dell Latitude D410 newly broken in 2.6.29-rc* Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12591] NULL pointer dereference in blk_queue_io_stat Rafael J. Wysocki
2009-02-04 12:53 ` Jens Axboe
2009-02-05 1:21 ` Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12574] possible circular locking dependency detected Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12598] tg3 dead after resume Rafael J. Wysocki
2009-02-05 0:43 ` Parag Warudkar
2009-02-05 1:03 ` Jesse Barnes
2009-02-04 10:24 ` [Bug #12600] i915 lockdep warning Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12601] virt-manager broken on 2.6.29-rc2 Rafael J. Wysocki
2009-02-04 23:26 ` Stephen Hemminger
2009-02-05 1:25 ` Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12602] CRED changes causing setuid failures Rafael J. Wysocki
2009-02-04 18:09 ` David Smith
2009-02-05 1:15 ` Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12599] dri /dev node disappeared with 2.6.29-rc1 Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12605] Suspend regression, hang after matroxfb Rafael J. Wysocki
2009-02-05 12:16 ` Eric Sesterhenn
2009-02-05 16:12 ` Rafael J. Wysocki
2009-02-08 12:39 ` Eric Sesterhenn
2009-02-04 10:24 ` [Bug #12604] Commit 31a12666d8f0c22235297e1c1575f82061480029 slows down Berkeley DB Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12606] fb_mmap: circular locking dependency on hibernation Rafael J. Wysocki
2009-02-04 14:43 ` Andrey Borzenkov
2009-02-05 1:43 ` Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12609] v2.6.29-rc2 libata sff 32bit PIO regression Rafael J. Wysocki
2009-02-05 17:30 ` Hugh Dickins
2009-02-05 22:54 ` Rafael J. Wysocki
2009-02-06 23:10 ` Larry Finger
2009-02-06 23:58 ` Rafael J. Wysocki
2009-02-23 16:22 ` Larry Finger
2009-02-23 22:13 ` Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12611] kernel BUG at kernel/cgroup.c:398! Rafael J. Wysocki
2009-02-05 1:02 ` Li Zefan
2009-02-05 1:53 ` Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12610] sync-Regression in 2.6.28.2? Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12608] 2.6.29-rc powerpc G5 Xorg legacy_mem regression Rafael J. Wysocki
2009-02-04 23:48 ` Benjamin Herrenschmidt
2009-02-05 17:23 ` Hugh Dickins
2009-02-05 21:05 ` Benjamin Herrenschmidt
2009-02-05 21:20 ` Hugh Dickins
2009-02-05 21:45 ` Dave Airlie
2009-02-06 6:01 ` Benjamin Herrenschmidt
2009-02-05 22:33 ` Jesse Barnes
2009-02-05 23:57 ` Benjamin Herrenschmidt
2009-02-06 5:40 ` Benjamin Herrenschmidt
2009-02-06 12:56 ` Hugh Dickins
2009-02-06 16:49 ` Jesse Barnes
2009-02-06 22:17 ` Hugh Dickins
2009-02-06 22:45 ` Jesse Barnes
2009-02-07 0:50 ` Hugh Dickins
2009-02-07 1:47 ` Jesse Barnes
2009-02-07 3:05 ` Benjamin Herrenschmidt
2009-02-07 23:15 ` Jesse Barnes
2009-02-07 2:51 ` Benjamin Herrenschmidt
2009-02-04 10:24 ` [Bug #12615] boot hangs while bringing up gianfar ethernet Rafael J. Wysocki
2009-02-04 16:54 ` Ira Snyder
2009-02-05 1:23 ` Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12617] unable to compile e100 firmware into kernel Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12616] boot hang: async vs. kexec Rafael J. Wysocki
2009-02-04 16:50 ` Randy Dunlap
2009-02-05 1:26 ` Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12613] [Suspend regression][DRM, RADEON] Rafael J. Wysocki
2009-02-04 22:25 ` etienne
2009-02-05 1:18 ` Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12618] hackbench [pthread mode] regression with 2.6.29-rc3 Rafael J. Wysocki
2009-02-04 10:24 ` [Bug #12621] Resume broken on iBook Rafael J. Wysocki
2009-02-04 16:24 ` 2.6.29-rc3-git6: Reported regressions from 2.6.28 Linus Torvalds
2009-02-04 16:32 ` Ingo Molnar
2009-02-04 18:11 ` Norbert Preining
2009-02-04 18:17 ` Linus Torvalds
2009-02-04 18:21 ` Norbert Preining
2009-02-04 18:56 ` Ingo Molnar
2009-02-04 22:22 ` Bron Gondwana
2009-02-05 1:08 ` Ingo Molnar
2009-02-05 1:26 ` Bron Gondwana
2009-02-05 4:45 ` Eric Anholt
2009-02-05 14:51 ` Norbert Preining
2009-02-05 16:56 ` [PATCH] drm, i915: select framebuffer support automatically Ingo Molnar
2009-02-08 11:49 ` Dave Airlie
2009-02-05 17:17 ` 2.6.29-rc3-git6: Reported regressions from 2.6.28 Randy Dunlap
2009-02-05 19:12 ` Ingo Molnar
2009-02-05 19:14 ` Randy Dunlap
2009-02-05 19:20 ` Ingo Molnar
2009-02-05 19:23 ` Randy Dunlap
2009-02-05 19:36 ` Ingo Molnar
2009-02-11 0:33 ` Eric Anholt
2009-02-05 2:07 ` Rafael J. Wysocki
-- strict thread matches above, loose matches on Subject: below --
2009-02-23 21:45 2.6.29-rc6: " Rafael J. Wysocki
2009-02-23 21:48 ` [Bug #12491] i915 lockdep warning Rafael J. Wysocki
2009-02-24 1:36 ` Roland Dreier
2009-02-24 1:44 ` Rafael J. Wysocki
2009-02-14 20:35 2.6.29-rc5: Reported regressions from 2.6.28 Rafael J. Wysocki
2009-02-14 20:38 ` [Bug #12491] i915 lockdep warning Rafael J. Wysocki
2009-02-08 19:05 2.6.29-rc4: Reported regressions from 2.6.28 Rafael J. Wysocki
2009-02-08 19:21 ` [Bug #12491] i915 lockdep warning Rafael J. Wysocki
2009-01-19 21:28 2.6.29-rc2-git1: Reported regressions from 2.6.28 Rafael J. Wysocki
2009-01-19 21:32 ` [Bug #12491] i915 lockdep warning Rafael J. Wysocki
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=adar62dltg1.fsf@cisco.com \
--to=rdreier@cisco.com \
--cc=drivers_video-dri@kernel-bugs.osdl.org \
--cc=jesse.brandeburg@intel.com \
--cc=kernel-testers@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rjw@sisk.pl \
/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;
as well as URLs for NNTP newsgroup(s).