* [PATCH] drm/i915: Unref context on failed eb_create
@ 2014-04-05 5:41 Ben Widawsky
2014-04-05 6:24 ` Chris Wilson
0 siblings, 1 reply; 3+ messages in thread
From: Ben Widawsky @ 2014-04-05 5:41 UTC (permalink / raw)
To: Intel GFX
I opted to do this instead of grabbing the context reference after
eb_create since eb_create can potentially call the shrinker, and that
makes things very complicated. This simple patch balances the ref count
without requiring a great deal of review to make sure the shrinker path
is safe.
Theoretically (by design) the shrinker can end up destroying a context,
which enforces the reasoning for doing the fix this way instead of
moving the reference to later in the function.
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
drivers/gpu/drm/i915/i915_gem_execbuffer.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index e4f0e2c..b785459 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1133,7 +1133,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
mutex_unlock(&dev->struct_mutex);
ret = PTR_ERR(ctx);
goto pre_mutex_err;
- }
+ }
i915_gem_context_reference(ctx);
@@ -1143,6 +1143,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
eb = eb_create(args);
if (eb == NULL) {
+ i915_gem_context_unreference(ctx);
mutex_unlock(&dev->struct_mutex);
ret = -ENOMEM;
goto pre_mutex_err;
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] drm/i915: Unref context on failed eb_create
2014-04-05 5:41 [PATCH] drm/i915: Unref context on failed eb_create Ben Widawsky
@ 2014-04-05 6:24 ` Chris Wilson
2014-04-05 15:24 ` Daniel Vetter
0 siblings, 1 reply; 3+ messages in thread
From: Chris Wilson @ 2014-04-05 6:24 UTC (permalink / raw)
To: Ben Widawsky; +Cc: Intel GFX
On Fri, Apr 04, 2014 at 10:41:07PM -0700, Ben Widawsky wrote:
> I opted to do this instead of grabbing the context reference after
> eb_create since eb_create can potentially call the shrinker, and that
> makes things very complicated. This simple patch balances the ref count
> without requiring a great deal of review to make sure the shrinker path
> is safe.
>
> Theoretically (by design) the shrinker can end up destroying a context,
> which enforces the reasoning for doing the fix this way instead of
> moving the reference to later in the function.
>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Even the whitespace fix is correct.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/i915: Unref context on failed eb_create
2014-04-05 6:24 ` Chris Wilson
@ 2014-04-05 15:24 ` Daniel Vetter
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2014-04-05 15:24 UTC (permalink / raw)
To: Chris Wilson, Ben Widawsky, Intel GFX
On Sat, Apr 05, 2014 at 07:24:01AM +0100, Chris Wilson wrote:
> On Fri, Apr 04, 2014 at 10:41:07PM -0700, Ben Widawsky wrote:
> > I opted to do this instead of grabbing the context reference after
> > eb_create since eb_create can potentially call the shrinker, and that
> > makes things very complicated. This simple patch balances the ref count
> > without requiring a great deal of review to make sure the shrinker path
> > is safe.
> >
> > Theoretically (by design) the shrinker can end up destroying a context,
> > which enforces the reasoning for doing the fix this way instead of
> > moving the reference to later in the function.
> >
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
>
> Even the whitespace fix is correct.
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Queued for -next, thanks for the patch.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-04-05 15:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-05 5:41 [PATCH] drm/i915: Unref context on failed eb_create Ben Widawsky
2014-04-05 6:24 ` Chris Wilson
2014-04-05 15:24 ` Daniel Vetter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox