All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jiri Slaby <jirislaby@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	dri-devel@lists.freedesktop.org,
	Hans de Goede <hdegoede@redhat.com>,
	Ingo Molnar <mingo@redhat.com>, Ben Skeggs <bskeggs@redhat.com>
Subject: Re: 4.9-rc1 lockdep warning suggesting a deadlock between nouveau and i915 with prime video outputs active
Date: Thu, 13 Jul 2017 20:59:06 +0200	[thread overview]
Message-ID: <20170713185906.6ut6yczk7gae32ry@phenom.ffwll.local> (raw)
In-Reply-To: <149995469805.29380.5405466287939095053@mail.alporthouse.com>

On Thu, Jul 13, 2017 at 03:04:58PM +0100, Chris Wilson wrote:
> Quoting Jiri Slaby (2017-07-13 14:57:31)
> > Stealing this thread as an opensuse user hit that too:
> > https://bugzilla.suse.com/show_bug.cgi?id=1045105
> 
> It's a false positive. I did once upon a time send some patches to move
> the lockdep warning to kref so that didn't need to call it from drm
> before an unlocked path. Basically you want
> 
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 8dc11064253d..3118aed844f1 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -826,7 +826,6 @@ drm_gem_object_put_unlocked(struct drm_gem_object *obj)
>                 return;
>  
>         dev = obj->dev;
> -       might_lock(&dev->struct_mutex);
>  
>         if (dev->driver->gem_free_object_unlocked)
>                 kref_put(&obj->refcount, drm_gem_object_free);
> diff --git a/include/linux/kref.h b/include/linux/kref.h
> index 29220724bf1c..4b1133cd5d20 100644
> --- a/include/linux/kref.h
> +++ b/include/linux/kref.h
> @@ -77,6 +77,8 @@ static inline int kref_put_mutex(struct kref *kref,
>                                  void (*release)(struct kref *kref),
>                                  struct mutex *lock)
>  {
> +       might_lock(lock);
> +
>         if (refcount_dec_and_mutex_lock(&kref->refcount, lock)) {
>                 release(kref);
>                 return 1;
> 
> 
> Though now we probably want to move that might_lock() into refcount.

I think we want this here:

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 8dc11064253d..9663a79dd363 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -826,13 +826,15 @@ drm_gem_object_put_unlocked(struct drm_gem_object *obj)
 		return;
 
 	dev = obj->dev;
-	might_lock(&dev->struct_mutex);
 
 	if (dev->driver->gem_free_object_unlocked)
 		kref_put(&obj->refcount, drm_gem_object_free);
-	else if (kref_put_mutex(&obj->refcount, drm_gem_object_free,
+	else {
+		might_lock(&dev->struct_mutex);
+		if (kref_put_mutex(&obj->refcount, drm_gem_object_free,
 				&dev->struct_mutex))
-		mutex_unlock(&dev->struct_mutex);
+			mutex_unlock(&dev->struct_mutex);
+	}
 }
 EXPORT_SYMBOL(drm_gem_object_put_unlocked);
 
If it works I'll wrap it into a patch. Note you need rather new-ish kernel
to make sure we're sufficiently struct_mutex free in i915 (otherwise
there's still the locking loop). v4.10 should be new enough afaics.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      reply	other threads:[~2017-07-13 18:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-09 17:02 4.9-rc1 lockdep warning suggesting a deadlock between nouveau and i915 with prime video outputs active Hans de Goede
2016-11-09 17:26 ` Chris Wilson
2016-11-09 18:36   ` Hans de Goede
2017-07-13 13:57   ` Jiri Slaby
2017-07-13 14:01     ` Peter Zijlstra
2017-07-13 14:04     ` Chris Wilson
2017-07-13 18:59       ` Daniel Vetter [this message]

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=20170713185906.6ut6yczk7gae32ry@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=bskeggs@redhat.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hdegoede@redhat.com \
    --cc=jirislaby@gmail.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.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 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.