drm/i915: Unref context on failed eb_create
Subsystems (2)
PATCH 1/1 drm/i915: Unref context on failed eb_create
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.
--- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +2 -1
@@ -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;
Signature · 1 line
1.9.1
Quoted 6 lines · Ben Widawsky
I opted to do this instead of grabbing the context reference after
eb_createsinceeb_createcan 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.
Quoted 6 lines
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 <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
Even the whitespace fix is correct.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Daniel Vetter
AppliedQuoted 11 lines · Chris Wilson
Quoted 10 lines · Ben Widawsky
I opted to do this instead of grabbing the context reference after
eb_createsinceeb_createcan 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.
Quoted 5 lines
Quoted 2 lines
Cc Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>Even the whitespace fix is correct.
Reviewed-by Chris Wilson <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch