All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: DRI Development <dri-devel@lists.freedesktop.org>
Cc: "Rob Herring" <robh@kernel.org>,
	"Thomas Hellstrom" <thellstrom@vmware.com>,
	"Tomeu Vizoso" <tomeu.vizoso@collabora.com>,
	"Daniel Vetter" <daniel.vetter@ffwll.ch>,
	"Intel Graphics Development" <intel-gfx@lists.freedesktop.org>,
	"VMware Graphics" <linux-graphics-maintainer@vmware.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Daniel Vetter" <daniel.vetter@intel.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Dave Airlie" <airlied@redhat.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Ben Skeggs" <bskeggs@redhat.com>
Subject: Re: [PATCH] dma_resv: prime lockdep annotations
Date: Thu, 22 Aug 2019 08:48:20 +0100	[thread overview]
Message-ID: <156646010077.20466.7748745707428507617@skylake-alporthouse-com> (raw)
In-Reply-To: <20190822065457.2830-1-daniel.vetter@ffwll.ch>

Quoting Daniel Vetter (2019-08-22 07:54:57)
> +#if IS_ENABLED(CONFIG_LOCKDEP)
> +static void dma_resv_lockdep(void)
> +{
> +       struct mm_struct *mm = mm_alloc();
> +       struct dma_resv obj;
> +
> +       if (!mm)
> +               return;
> +
> +       dma_resv_init(&obj);
> +
> +       down_read(&mm->mmap_sem);
> +       ww_mutex_lock(&obj.lock, NULL);
> +       fs_reclaim_acquire(GFP_KERNEL);
> +       fs_reclaim_release(GFP_KERNEL);
> +       ww_mutex_unlock(&obj.lock);
> +       up_read(&mm->mmap_sem);
> +       
> +       mmput(mm);
> +}
> +subsys_initcall(dma_resv_lockdep);
> +#endif

Adding a

	dma_resv_lock();
	might_lock(&i915->drm.struct_mutex);
	dma_resv_unlock();

yielded

[   18.513633] ======================================================
[   18.513636] WARNING: possible circular locking dependency detected
[   18.513639] 5.3.0-rc5+ #76 Not tainted
[   18.513640] ------------------------------------------------------
[   18.513643] insmod/655 is trying to acquire lock:
[   18.513645] 00000000877909e7 (&dev->struct_mutex){+.+.}, at: i915_driver_probe+0x89c/0x1470 [i915]
[   18.513671] 
[   18.513671] but task is already holding lock:
[   18.513673] 00000000a85ba8ec (reservation_ww_class_mutex){+.+.}, at: i915_driver_probe+0x8e1/0x1470 [i915]
[   18.513698] 
[   18.513698] which lock already depends on the new lock.
[   18.513698] 
[   18.513701] 
[   18.513701] the existing dependency chain (in reverse order) is:
[   18.513703] 
[   18.513703] -> #1 (reservation_ww_class_mutex){+.+.}:
[   18.513708]        __ww_mutex_lock.constprop.17+0xbc/0xf90
[   18.513739]        i915_gem_init+0x518/0x750 [i915]
[   18.513762]        i915_driver_probe+0x891/0x1470 [i915]
[   18.513785]        i915_pci_probe+0x2f/0x110 [i915]
[   18.513789]        pci_device_probe+0x99/0x110
[   18.513792]        really_probe+0xd1/0x360
[   18.513794]        driver_probe_device+0xaf/0xf0
[   18.513796]        device_driver_attach+0x4a/0x50
[   18.513799]        __driver_attach+0x80/0x140
[   18.513801]        bus_for_each_dev+0x5e/0x90
[   18.513804]        bus_add_driver+0x148/0x1e0
[   18.513806]        driver_register+0x66/0xb0
[   18.513809]        do_one_initcall+0x45/0x29f
[   18.513812]        do_init_module+0x55/0x200
[   18.513814]        load_module+0x2519/0x2690
[   18.513816]        __do_sys_finit_module+0x8f/0xd0
[   18.513818]        do_syscall_64+0x4f/0x220
[   18.513822]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
[   18.513824] 
[   18.513824] -> #0 (&dev->struct_mutex){+.+.}:
[   18.513828]        __lock_acquire+0xcb9/0x1520
[   18.513831]        lock_acquire+0x90/0x170
[   18.513853]        i915_driver_probe+0x8fd/0x1470 [i915]
[   18.513876]        i915_pci_probe+0x2f/0x110 [i915]
[   18.513879]        pci_device_probe+0x99/0x110
[   18.513881]        really_probe+0xd1/0x360
[   18.513883]        driver_probe_device+0xaf/0xf0
[   18.513886]        device_driver_attach+0x4a/0x50
[   18.513888]        __driver_attach+0x80/0x140
[   18.513891]        bus_for_each_dev+0x5e/0x90
[   18.513893]        bus_add_driver+0x148/0x1e0
[   18.513895]        driver_register+0x66/0xb0
[   18.513897]        do_one_initcall+0x45/0x29f
[   18.513899]        do_init_module+0x55/0x200
[   18.513902]        load_module+0x2519/0x2690
[   18.513904]        __do_sys_finit_module+0x8f/0xd0
[   18.513906]        do_syscall_64+0x4f/0x220
[   18.513909]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
[   18.513911] 
[   18.513911] other info that might help us debug this:
[   18.513911] 
[   18.513914]  Possible unsafe locking scenario:
[   18.513914] 
[   18.513916]        CPU0                    CPU1
[   18.513918]        ----                    ----
[   18.513920]   lock(reservation_ww_class_mutex);
[   18.513922]                                lock(&dev->struct_mutex);
[   18.513924]                                lock(reservation_ww_class_mutex);
[   18.513927]   lock(&dev->struct_mutex);
[   18.513929] 
[   18.513929]  *** DEADLOCK ***
[   18.513929] 
[   18.513932] 3 locks held by insmod/655:
[   18.513933]  #0: 000000004dccb591 (&dev->mutex){....}, at: device_driver_attach+0x18/0x50
[   18.513938]  #1: 000000009118ecae (&mm->mmap_sem#2){++++}, at: i915_driver_probe+0x8c8/0x1470 [i915]
[   18.513962]  #2: 00000000a85ba8ec (reservation_ww_class_mutex){+.+.}, at: i915_driver_probe+0x8e1/0x1470 [i915]

so

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Tested-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-08-22  7:48 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-21 21:50 [PATCH 1/3] dma_resv: prime lockdep annotations Daniel Vetter
     [not found] ` <20190821215030.31660-1-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
2019-08-21 21:50   ` [PATCH 2/3] drm/nouveau: slowpath for pushbuf ioctl Daniel Vetter
     [not found]     ` <20190821215030.31660-2-daniel.vetter-/w4YWyX8dFk@public.gmane.org>
2019-09-03  8:17       ` Daniel Vetter
     [not found]         ` <20190903081714.GO2112-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2019-09-18  9:29           ` Daniel Vetter
2019-08-21 21:50 ` [PATCH 3/3] drm/ttm: remove ttm_bo_wait_unreserved Daniel Vetter
2019-08-21 22:20 ` [PATCH 1/3] dma_resv: prime lockdep annotations Chris Wilson
2019-08-21 22:22 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/3] " Patchwork
2019-08-21 22:46 ` ✓ Fi.CI.BAT: success " Patchwork
2019-08-22  6:49 ` [PATCH] drm/ttm: remove ttm_bo_wait_unreserved Daniel Vetter
2019-08-22  7:56   ` Koenig, Christian
2019-08-22  8:47     ` Daniel Vetter
2019-08-22  9:53       ` Thomas Hellström (VMware)
2019-08-22 13:06     ` Daniel Vetter
2019-08-22 14:02       ` Koenig, Christian
2019-08-22 14:24         ` Thomas Hellström (VMware)
2019-08-22 14:30           ` Thomas Hellström (VMware)
2019-08-22  6:54 ` [PATCH] dma_resv: prime lockdep annotations Daniel Vetter
2019-08-22  7:48   ` Chris Wilson [this message]
2019-08-22  7:53   ` Koenig, Christian
2019-09-03  8:16     ` Daniel Vetter
2019-09-03  9:02       ` Koenig, Christian
2019-08-22 12:56   ` Rob Herring
2019-08-22  8:40 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with dma_resv: prime lockdep annotations (rev3) Patchwork
2019-08-22  9:16 ` ✓ Fi.CI.BAT: success " Patchwork
2019-08-22 13:07 ` [PATCH] dma_resv: prime lockdep annotations Daniel Vetter
2019-08-22 13:30   ` Thomas Hellström (VMware)
2019-08-22 13:36     ` Daniel Vetter
2019-08-22 14:56       ` Thomas Hellström (VMware)
2019-08-22 14:46 ` ✓ Fi.CI.IGT: success for series starting with [1/3] " Patchwork
2019-08-23  1:43 ` ✓ Fi.CI.IGT: success for series starting with dma_resv: prime lockdep annotations (rev3) Patchwork

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=156646010077.20466.7748745707428507617@skylake-alporthouse-com \
    --to=chris@chris-wilson.co.uk \
    --cc=airlied@redhat.com \
    --cc=alexander.deucher@amd.com \
    --cc=bskeggs@redhat.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=linux-graphics-maintainer@vmware.com \
    --cc=robh@kernel.org \
    --cc=thellstrom@vmware.com \
    --cc=tomeu.vizoso@collabora.com \
    --cc=tzimmermann@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.