From: Daniel Vetter <daniel@ffwll.ch>
To: Ben Widawsky <ben@bwidawsk.net>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH] drm/i915: fix up error cleanup in i915_gem_object_bind_to_gtt
Date: Mon, 22 Jul 2013 23:02:08 +0200 [thread overview]
Message-ID: <20130722210208.GC5939@phenom.ffwll.local> (raw)
In-Reply-To: <20130722201230.GE7663@bwidawsk.net>
On Mon, Jul 22, 2013 at 01:12:30PM -0700, Ben Widawsky wrote:
> On Mon, Jul 22, 2013 at 12:12:38PM +0200, Daniel Vetter wrote:
> > This has been broken in
> >
> > commit 2f63315692b1d3c055972ad33fc7168ae908b97b
> > Author: Ben Widawsky <ben@bwidawsk.net>
> > Date: Wed Jul 17 12:19:03 2013 -0700
> >
> > drm/i915: Create VMAs
> >
> > which resulted in an OOPS the first time around we've hit -ENOSPC.
> >
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67156
> > Cc: Imre Deak <imre.deak@intel.com>
> > Cc: Ben Widawsky <ben@bwidawsk.net>
> > Tested-by: meng <mengmeng.meng@intel.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > ---
> > drivers/gpu/drm/i915/i915_gem.c | 14 ++++++++------
> > 1 file changed, 8 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> > index cfa6588..c87a6ec 100644
> > --- a/drivers/gpu/drm/i915/i915_gem.c
> > +++ b/drivers/gpu/drm/i915/i915_gem.c
> > @@ -3121,8 +3121,8 @@ i915_gem_object_bind_to_gtt(struct drm_i915_gem_object *obj,
> >
> > vma = i915_gem_vma_create(obj, &dev_priv->gtt.base);
> > if (IS_ERR(vma)) {
> > - i915_gem_object_unpin_pages(obj);
> > - return PTR_ERR(vma);
> > + ret = PTR_ERR(vma);
> > + goto err_unpin;
> > }
>
> Adding the extra goto here seems pointless to me.
Like explained on irc, that's just to have a nice OCD reverse err_foo:
label stacking at the end of the function.
>
> >
> > search_free:
> > @@ -3138,17 +3138,17 @@ search_free:
> > if (ret == 0)
> > goto search_free;
> >
> > - goto err_out;
> > + goto err_free_vma;
> > }
>
> My preference would be to exit early in drm_mm_remove_node() if the node
> isn't allocated. I think at least we should add a WARN to
> drm_mm_remove_node if the node->allocated == 0.
Hm, good idea. I'll create a quick patch.
> > if (WARN_ON(!i915_gem_valid_gtt_space(dev, &vma->node,
> > obj->cache_level))) {
> > ret = -EINVAL;
> > - goto err_out;
> > + goto err_remove_node;
> > }
> >
> > ret = i915_gem_gtt_prepare_object(obj);
> > if (ret)
> > - goto err_out;
> > + goto err_remove_node;
> >
> > list_move_tail(&obj->global_list, &dev_priv->mm.bound_list);
> > list_add_tail(&obj->mm_list, &vm->inactive_list);
> > @@ -3167,9 +3167,11 @@ search_free:
> > i915_gem_verify_gtt(dev);
> > return 0;
> >
> > -err_out:
> > +err_remove_node:
> > drm_mm_remove_node(&vma->node);
> > +err_free_vma:
> > i915_gem_vma_destroy(vma);
> > +err_unpin:
> > i915_gem_object_unpin_pages(obj);
> > return ret;
> > }
>
> Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
Queued for -next, thanks for the review.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
next prev parent reply other threads:[~2013-07-22 21:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-22 10:12 [PATCH] drm/i915: fix up error cleanup in i915_gem_object_bind_to_gtt Daniel Vetter
2013-07-22 10:34 ` Chris Wilson
2013-07-22 20:12 ` Ben Widawsky
2013-07-22 21:02 ` Daniel Vetter [this message]
2013-07-23 6:10 ` 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=20130722210208.GC5939@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=ben@bwidawsk.net \
--cc=daniel.vetter@ffwll.ch \
--cc=intel-gfx@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.