dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: Possible fb ref count issue with drm_plane_force_disable()
Date: Fri, 11 Apr 2014 14:50:54 +0300	[thread overview]
Message-ID: <20140411115054.GC18465@intel.com> (raw)
In-Reply-To: <534684E8.9000203@ti.com>

On Thu, Apr 10, 2014 at 02:47:52PM +0300, Tomi Valkeinen wrote:
> Hi,
> 
> I've been debugging omapdrm issues on top of the latest drm mainline
> changes. Sometimes a drm_framebuffer ref count drops to -1 when aborting
> a drm application, or unloading the modules.
> 
> The setup is very basic, just a single crtc with the crtc's primary plane.
> 
> What seems to happen is:
> 
> - App is started
> 
> - fb is created, and taken into use by omapdrm. omapdrm takes a ref to
> the fb.
> 
> - the app is starts to shut down
> 
> - drm_framebuffer_remove is called
> 
> - fb->refcount.refcount > 1, so it goes to disable stuff
> 
> - drm_plane_force_disable is called for the primary plane
> 
> - drm_plane_force_disable does plane->disable_plane, which on omapdrm
> puts stuff on a workqueue as plane cannot be disabled immediately
> 
> - drm_plane_force_disable calls __drm_framebuffer_unreference()
> 
> - at the end of drm_framebuffer_remove(), there's
> drm_framebuffer_unreference, which causes ref count to go to zero, and
> the fb to be destroyed
> 
> - a bit later, the queued work is ran, which does
> drm_framebuffer_unreference(), and ref count goes to -1. Here omapdrm is
> removing the ref that had been taken in the beginning.
> 
> 
> So the explicit unref done by drm_plane_force_disable() seems a bit out
> of place. I can't figure out which drm_framebuffer_reference() would be
> the matching one for the unref done by drm_plane_force_disable().
> 
> Any ideas what ref is that? Or is the __drm_framebuffer_unreference()
> extra in drm_plane_force_disable()?

That's the reference that was taken by the drm_mode_setplane() when it
succesfully called the .update_plane() hook.

__drm_framebuffer_unregister() drops the "idr reference" taken in
drm_framebuffer_init().

And the last ref dropped by drm_framebuffer_remove() is the initial ref
from kref_init() which I suppose is what the 'fpriv->fbs reference'
comments are referring to.
 
-- 
Ville Syrjälä
Intel OTC

  parent reply	other threads:[~2014-04-11 11:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-10 11:47 Possible fb ref count issue with drm_plane_force_disable() Tomi Valkeinen
2014-04-11  6:31 ` Archit Taneja
2014-04-11  6:40   ` Tomi Valkeinen
2014-04-11  6:57     ` Archit Taneja
2014-04-11  7:03       ` Tomi Valkeinen
2014-04-11  7:19 ` Daniel Vetter
2014-04-11 11:50 ` Ville Syrjälä [this message]
2014-04-14  8:43   ` Tomi Valkeinen
2014-04-15  9:16     ` Tomi Valkeinen
2014-04-15 10:10       ` Rob Clark
2014-04-15 10:29         ` Andrzej Hajda
2014-04-15 10:44           ` Tomi Valkeinen
2014-04-15 12:24             ` Rob Clark
2014-04-15 13:30               ` Tomi Valkeinen
2014-04-15 22:01                 ` Daniel Vetter
2014-04-15 12:00         ` Tomi Valkeinen
2014-04-15 21:57         ` Daniel Vetter

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=20140411115054.GC18465@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=tomi.valkeinen@ti.com \
    /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