Message ID | 20180301101855.670-1-matthew.auld@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Matthew Auld <matthew.auld@intel.com> writes: > Add some onion to populate_lr_context. > > Fixes: d2b4b97933f5 ("drm/i915: Record the default hw state after reset upon load") > Signed-off-by: Matthew Auld <matthew.auld@intel.com> > Cc: Chris Wilson <chris@chris-wilson.co.uk> > --- > drivers/gpu/drm/i915/intel_lrc.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c > index 14288743909f..9dd6440eb0e1 100644 > --- a/drivers/gpu/drm/i915/intel_lrc.c > +++ b/drivers/gpu/drm/i915/intel_lrc.c > @@ -2318,8 +2318,10 @@ populate_lr_context(struct i915_gem_context *ctx, > > defaults = i915_gem_object_pin_map(engine->default_state, > I915_MAP_WB); > - if (IS_ERR(defaults)) > - return PTR_ERR(defaults); > + if (IS_ERR(defaults)) { > + ret = PTR_ERR(defaults); > + goto error; I would have used goto unpin_out or error_unpin. This way you can read both parts separately and don't have to go back and forth pairing the parts of onion. Just a stylistic note and as this is the only goto in this func so we can improve if it ever grows. Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com> > + } > > memcpy(vaddr + start, defaults + start, engine->context_size); > i915_gem_object_unpin_map(engine->default_state); > @@ -2337,9 +2339,9 @@ populate_lr_context(struct i915_gem_context *ctx, > _MASKED_BIT_ENABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT | > CTX_CTRL_ENGINE_CTX_SAVE_INHIBIT); > > +error: > i915_gem_object_unpin_map(ctx_obj); > - > - return 0; > + return ret; > } > > static int execlists_context_deferred_alloc(struct i915_gem_context *ctx, > -- > 2.14.3 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Matthew Auld (2018-03-01 10:18:55) > Add some onion to populate_lr_context. > > Fixes: d2b4b97933f5 ("drm/i915: Record the default hw state after reset upon load") > Signed-off-by: Matthew Auld <matthew.auld@intel.com> > Cc: Chris Wilson <chris@chris-wilson.co.uk> Worth backporting? Not sure, as the leak will be forcibly freed when the context is freed. We should spit a warning in that case, which as you haven't quoted I presume this was found by inspection rather than hit? > drivers/gpu/drm/i915/intel_lrc.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c > index 14288743909f..9dd6440eb0e1 100644 > --- a/drivers/gpu/drm/i915/intel_lrc.c > +++ b/drivers/gpu/drm/i915/intel_lrc.c > @@ -2318,8 +2318,10 @@ populate_lr_context(struct i915_gem_context *ctx, > > defaults = i915_gem_object_pin_map(engine->default_state, > I915_MAP_WB); > - if (IS_ERR(defaults)) > - return PTR_ERR(defaults); > + if (IS_ERR(defaults)) { > + ret = PTR_ERR(defaults); > + goto error; > + } > > memcpy(vaddr + start, defaults + start, engine->context_size); > i915_gem_object_unpin_map(engine->default_state); > @@ -2337,9 +2339,9 @@ populate_lr_context(struct i915_gem_context *ctx, > _MASKED_BIT_ENABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT | > CTX_CTRL_ENGINE_CTX_SAVE_INHIBIT); > > +error: err_unpin_ctx: or out_unpin_ctx: if Joonas is listening. Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> -Chris
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 14288743909f..9dd6440eb0e1 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c @@ -2318,8 +2318,10 @@ populate_lr_context(struct i915_gem_context *ctx, defaults = i915_gem_object_pin_map(engine->default_state, I915_MAP_WB); - if (IS_ERR(defaults)) - return PTR_ERR(defaults); + if (IS_ERR(defaults)) { + ret = PTR_ERR(defaults); + goto error; + } memcpy(vaddr + start, defaults + start, engine->context_size); i915_gem_object_unpin_map(engine->default_state); @@ -2337,9 +2339,9 @@ populate_lr_context(struct i915_gem_context *ctx, _MASKED_BIT_ENABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT | CTX_CTRL_ENGINE_CTX_SAVE_INHIBIT); +error: i915_gem_object_unpin_map(ctx_obj); - - return 0; + return ret; } static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
Add some onion to populate_lr_context. Fixes: d2b4b97933f5 ("drm/i915: Record the default hw state after reset upon load") Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> --- drivers/gpu/drm/i915/intel_lrc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)