From: Lukas Wunner <lukas@wunner.de>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: Alex Deucher <alexander.deucher@amd.com>,
Nouveau Dev <nouveau@lists.freedesktop.org>,
intel-gfx@lists.freedesktop.org,
dri-devel <dri-devel@lists.freedesktop.org>,
Dave Airlie <airlied@redhat.com>
Subject: Re: [Nouveau] [PATCH 9/9] drm: Turn off crtc before tearing down its data structure
Date: Fri, 3 Jun 2016 09:30:06 +0200 [thread overview]
Message-ID: <20160603073006.GA15903@wunner.de> (raw)
In-Reply-To: <20160601144012.GW7231@phenom.ffwll.local>
On Wed, Jun 01, 2016 at 04:40:12PM +0200, Daniel Vetter wrote:
> On Wed, Jun 01, 2016 at 02:36:41PM +0200, Lukas Wunner wrote:
> > On Wed, May 25, 2016 at 03:43:42PM +0200, Daniel Vetter wrote:
> > > On Wed, May 25, 2016 at 12:51 PM, Lukas Wunner <lukas@wunner.de> wrote:
> > > > On Tue, May 24, 2016 at 11:30:42PM +0200, Daniel Vetter wrote:
> > > > > On Tue, May 24, 2016 at 06:03:27PM +0200, Lukas Wunner wrote:
> > > > > > When a drm_crtc structure is destroyed with drm_crtc_cleanup(), the DRM
> > > > > > core does not turn off the crtc first and neither do the drivers. With
> > > > > > nouveau, radeon and amdgpu, this causes a runtime pm ref to be leaked on
> > > > > > driver unload if at least one crtc was enabled.
> > > > > >
> > > > > > (See usage of have_disp_power_ref in nouveau_crtc_set_config(),
> > > > > > radeon_crtc_set_config() and amdgpu_crtc_set_config()).
> > > > > >
> > > > > > Fixes: 5addcf0a5f0f ("nouveau: add runtime PM support (v0.9)")
> > > > > > Cc: Dave Airlie <airlied@redhat.com>
> > > > > > Tested-by: Karol Herbst <nouveau@karolherbst.de>
> > > > > > Signed-off-by: Lukas Wunner <lukas@wunner.de>
> > >
> > > With legacy kms the only way to keep a crtc enabled is to display a
> > > drm_framebuffer on it. And drm_mode_config_cleanup has a WARN_ON if
> > > framebuffers are left behind. There's a bunch of options:
> > > - nouveau somehow manages to keep the crtc on without a framebuffer
> > > - nouveau somehow leaks a drm_framebuffer, but removes it from the fb_list
> > > - something else
> >
> > Found it. nouveau_fbcon_destroy() doesn't call drm_framebuffer_remove().
> > If I add that, the crtc gets properly disabled on unload.
> >
> > It does call drm_framebuffer_cleanup(). That's why there was no WARN,
> > drm_mode_config_cleanup() only WARNs if a framebuffer was left on the
> > mode_config.fb_list.
> >
> > radeon and amdgpu have the same problem. In fact there are very few
> > drivers that call drm_framebuffer_remove(): tegra, msm, exynos, omapdrm
> > and i915 (since Imre Deak's 9d6612516da0).
> >
> > Should we add a WARN to prevent this? How about WARN_ON(crtc->enabled)
> > in drm_crtc_cleanup()?
> >
> > Also, i915 calls drm_framebuffer_unregister_private() before it calls
> > drm_framebuffer_remove(). This ordering has the unfortunate side effect
> > that the drm_framebuffer has ID 0 in log messages emitted by
> > drm_framebuffer_remove():
> >
> > [ 39.680874] [drm:drm_mode_object_unreference] OBJ ID: 0 (3)
> > [ 39.680878] [drm:drm_mode_object_unreference] OBJ ID: 0 (2)
> > [ 39.680884] [drm:drm_mode_object_unreference] OBJ ID: 0 (1)
>
> Well we must first unregister it before we can remove it, so this is
> unavoidable.
Yes but drm_framebuffer_free() calls drm_mode_object_unregister()
and is invoked by drm_framebuffer_remove(), so the additional call to
drm_framebuffer_unregister_private() in intel_fbdev_destroy() seems
superfluous. Or is there some reason I'm missing that this needs to
be called before intel_unpin_fb_obj()?
> Wrt switching from _cleanup to _remove, iirc there was troubles with the
> later calling into the fb->funcs->destroy hook. But many drivers have
> their fbdev fb embedded into some struct (instead of a pointer like i915),
> and then things go sideways badly. That's why you can't just blindly
> replace them.
So the options seem to be:
(1) Refactor nouveau, radeon and amdgpu to not embed their framebuffer
struct in their fbdev struct, so that drm_framebuffer_remove() can
be used.
(2) Amend each of them to turn off crtcs which are using the fbdev
framebuffer, duplicating the code in drm_framebuffer_remove().
(3) Split drm_framebuffer_remove(), move the portion to turn off crtcs
into a separate helper, say, drm_framebuffer_deactivate(), call that
from nouveau, radeon and amdgpu.
(4) Go back to square one and use patch [9/9] of this series.
Which one would be most preferred? Is there another solution I've missed?
Thanks,
Lukas
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-06-03 7:30 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-24 16:03 [PATCH 0/9] Fix runtime pm ref leaks Lukas Wunner
[not found] ` <cover.1464103767.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2016-05-24 16:03 ` [PATCH 2/9] drm/nouveau: Forbid runtime pm on driver unload Lukas Wunner
2016-05-24 16:03 ` [PATCH 9/9] drm: Turn off crtc before tearing down its data structure Lukas Wunner
2016-05-24 21:30 ` [Nouveau] " Daniel Vetter
2016-05-24 22:07 ` Lukas Wunner
[not found] ` <20160524220753.GA5941-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2016-05-24 22:30 ` Daniel Vetter
[not found] ` <20160524213042.GC27098-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2016-05-25 10:51 ` Lukas Wunner
2016-05-25 13:43 ` [Nouveau] " Daniel Vetter
[not found] ` <CAKMK7uGFb9ihRtjeK7s0ezPPv-C6S9GKbE4h9MLoPyHyN=9W5Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-06-01 12:36 ` Lukas Wunner
[not found] ` <20160601123641.GA15243-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2016-06-01 14:40 ` Daniel Vetter
2016-06-03 7:30 ` Lukas Wunner [this message]
2016-06-03 18:21 ` [Nouveau] " Daniel Vetter
2016-06-08 16:55 ` Lukas Wunner
2016-05-24 16:03 ` [PATCH 1/9] drm/nouveau: Don't leak runtime pm ref on driver unload Lukas Wunner
[not found] ` <dd120a30cb769c93af8973cae41f61831d17e04b.1464103767.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2016-05-27 1:07 ` Peter Wu
2016-05-29 15:50 ` Lukas Wunner
[not found] ` <20160529155006.GA12909-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2016-05-30 17:03 ` Peter Wu
2016-05-31 11:34 ` Lukas Wunner
[not found] ` <20160531113443.GA14098-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2016-05-31 11:41 ` Peter Wu
2016-05-24 16:03 ` [PATCH 7/9] drm/amdgpu: Don't leak runtime pm ref on driver load Lukas Wunner
2016-05-24 16:03 ` [PATCH 6/9] drm/amdgpu: Don't leak runtime pm ref on driver unload Lukas Wunner
2016-05-24 16:03 ` [PATCH 5/9] drm/radeon: Forbid runtime pm " Lukas Wunner
2016-05-24 16:03 ` [PATCH 4/9] drm/radeon: Don't leak runtime pm ref on driver load Lukas Wunner
2016-05-24 16:03 ` [PATCH 8/9] drm/amdgpu: Forbid runtime pm on driver unload Lukas Wunner
2016-05-24 16:03 ` [PATCH 3/9] drm/radeon: Don't leak runtime pm ref " Lukas Wunner
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=20160603073006.GA15903@wunner.de \
--to=lukas@wunner.de \
--cc=airlied@redhat.com \
--cc=alexander.deucher@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=nouveau@lists.freedesktop.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.