dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Rob Clark <robdclark@gmail.com>
Cc: Andrzej Hajda <a.hajda@samsung.com>,
	dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: Possible fb ref count issue with drm_plane_force_disable()
Date: Tue, 15 Apr 2014 16:30:21 +0300	[thread overview]
Message-ID: <534D346D.4000001@ti.com> (raw)
In-Reply-To: <CAF6AEGt0yFU_vFT+Bqj8DdmPqCKYzZgPA+LfTZqzvq217U3kfw@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1921 bytes --]

On 15/04/14 15:24, Rob Clark wrote:

> probably split out omap_plane_mode_set_internal(), call that directly
> from update_plane() for plane operations.  And then do the refcnt
> dance in the new omap_plane_mode_set() which calls _internal()..

We don't actually need that. This did the trick:

diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c
b/drivers/gpu/drm/omapdrm/omap_plane.c
index df1725247cca..3cf31ee59aac 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.c
+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
@@ -225,6 +225,11 @@ int omap_plane_mode_set(struct drm_plane *plane,
                omap_plane->apply_done_cb.arg = arg;
        }

+       if (plane->fb)
+               drm_framebuffer_unreference(plane->fb);
+
+       drm_framebuffer_reference(fb);
+
        plane->fb = fb;
        plane->crtc = crtc;

@@ -241,11 +246,6 @@ static int omap_plane_update(struct drm_plane *plane,
        struct omap_plane *omap_plane = to_omap_plane(plane);
        omap_plane->enabled = true;

-       if (plane->fb)
-               drm_framebuffer_unreference(plane->fb);
-
-       drm_framebuffer_reference(fb);
-
        /* omap_plane_mode_set() takes adjusted src */
        switch (omap_plane->win.rotation & 0xf) {
        case BIT(DRM_ROTATE_90):

With quick tests, works fine so far.

Still I have to say that the ref counting doesn't feel quite right (or
I'm missing something).

As far as I understand, the drm_mode_setplane() gets a ref to the fb,
and stores it in plane->fb. Why do we take a new ref in
omap_plane_update (or with the patch above, in omap_plane_mode_set), and
also store it in plane->fb there? Feels like the same task is done in
two places.

It looks to me like drm_mode_setplane() doesn't really presume that the
update_plane would set plane->fb or plane->crtc, as it does that itself
(and only if update_plane has succeeded).

 Tomi



[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2014-04-15 13:30 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ä
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 [this message]
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=534D346D.4000001@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=a.hajda@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=robdclark@gmail.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