From: Daniel Vetter <daniel@ffwll.ch>
To: Jeffy Chen <jeffy.chen@rock-chips.com>
Cc: linux-kernel@vger.kernel.org, briannorris@chromium.org,
dianders@chromium.org, tfiga@chromium.org,
dri-devel@lists.freedesktop.org,
Daniel Vetter <daniel.vetter@intel.com>,
zyw@rock-chips.com, marcheu@chromium.org, hshi@chromium.org
Subject: Re: [PATCH v7 2/2] drm: Prevent release fb after cleanup drm_mode_config
Date: Wed, 12 Apr 2017 08:36:10 +0200 [thread overview]
Message-ID: <20170412063610.55zrqja6uqlfz6lh@phenom.ffwll.local> (raw)
In-Reply-To: <1491881502-24357-3-git-send-email-jeffy.chen@rock-chips.com>
On Tue, Apr 11, 2017 at 11:31:42AM +0800, Jeffy Chen wrote:
> We are freeing all framebuffers in drm_mode_config_cleanup without
> sync the drm_file's fbs list.
>
> So if someone try to unbind drm before release drm dev fd, the fbs
> list would remain some invalid fb references. And that would cause
> crash later in drm_fb_release.
>
> Add a sanity check to prevent that.
>
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
This feels like duct-tape. The problem is that when we unplug a drm
device, we don't properly clean this up. I think we should first clean up
all the drm files (and make sure all ioctl and anything else completed),
before we proceed further in the driver cleanup.
Like I said, fixing unplug is going to be serious amounts of work, not
sure you really want to do this just for a pure debug use-cases.
-Daniel
>
> ---
>
> Changes in v7:
> Update commit message.
>
> Changes in v6: None
> Changes in v5: None
> Changes in v2: None
>
> drivers/gpu/drm/drm_framebuffer.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> index e8f9c13..03c1632 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -583,6 +583,11 @@ void drm_fb_release(struct drm_file *priv)
> {
> struct drm_framebuffer *fb, *tfb;
> struct drm_mode_rmfb_work arg;
> + struct drm_minor *minor = priv->minor;
> + struct drm_device *dev = minor->dev;
> +
> + if (WARN_ON(!dev->mode_config.num_fb && !list_empty(&priv->fbs)))
> + return;
>
> INIT_LIST_HEAD(&arg.fbs);
>
> --
> 2.1.4
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2017-04-12 6:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-11 3:31 [PATCH v7 0/2] drm: rockchip: Fix rockchip drm unbind crash error Jeffy Chen
2017-04-11 3:31 ` [PATCH v7 1/2] drm: Unplug drm device when unregistering it Jeffy Chen
2017-04-12 6:33 ` Daniel Vetter
2017-04-12 8:17 ` jeffy
2017-04-12 8:44 ` jeffy
2017-04-11 3:31 ` [PATCH v7 2/2] drm: Prevent release fb after cleanup drm_mode_config Jeffy Chen
2017-04-12 6:36 ` Daniel Vetter [this message]
2017-04-12 8:39 ` jeffy
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=20170412063610.55zrqja6uqlfz6lh@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=briannorris@chromium.org \
--cc=daniel.vetter@intel.com \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=hshi@chromium.org \
--cc=jeffy.chen@rock-chips.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marcheu@chromium.org \
--cc=tfiga@chromium.org \
--cc=zyw@rock-chips.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;
as well as URLs for NNTP newsgroup(s).