Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915: add i915_address_space_fini

We already have an i915_address_space_init, so for symmetry we should
also have a _fini, plus we already open code it twice. This then also
fixes a bug where we leak the timeline for the ggtt vm.

v2: don't forget about the struct_mutex for the ggtt path.

Fixes: 80b204bce8f2 ("drm/i915: Enable multiple timelines")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/20161117210411.14044-1-chris@chris-wilson.co.uk

authored by

Matthew Auld and committed by
Chris Wilson
ed9724dd 6288c79e

+12 -6
+12 -6
drivers/gpu/drm/i915/i915_gem_gtt.c
··· 2196 2196 list_add_tail(&vm->global_link, &dev_priv->vm_list); 2197 2197 } 2198 2198 2199 + static void i915_address_space_fini(struct i915_address_space *vm) 2200 + { 2201 + i915_gem_timeline_fini(&vm->timeline); 2202 + drm_mm_takedown(&vm->mm); 2203 + list_del(&vm->global_link); 2204 + } 2205 + 2199 2206 static void gtt_write_workarounds(struct drm_i915_private *dev_priv) 2200 2207 { 2201 2208 /* This function is for gtt related workarounds. This function is ··· 2285 2278 return ppgtt; 2286 2279 } 2287 2280 2288 - void i915_ppgtt_release(struct kref *kref) 2281 + void i915_ppgtt_release(struct kref *kref) 2289 2282 { 2290 2283 struct i915_hw_ppgtt *ppgtt = 2291 2284 container_of(kref, struct i915_hw_ppgtt, ref); ··· 2297 2290 WARN_ON(!list_empty(&ppgtt->base.inactive_list)); 2298 2291 WARN_ON(!list_empty(&ppgtt->base.unbound_list)); 2299 2292 2300 - i915_gem_timeline_fini(&ppgtt->base.timeline); 2301 - list_del(&ppgtt->base.global_link); 2302 - drm_mm_takedown(&ppgtt->base.mm); 2293 + i915_address_space_fini(&ppgtt->base); 2303 2294 2304 2295 ppgtt->base.cleanup(&ppgtt->base); 2305 2296 kfree(ppgtt); ··· 2838 2833 if (drm_mm_initialized(&ggtt->base.mm)) { 2839 2834 intel_vgt_deballoon(dev_priv); 2840 2835 2841 - drm_mm_takedown(&ggtt->base.mm); 2842 - list_del(&ggtt->base.global_link); 2836 + mutex_lock(&dev_priv->drm.struct_mutex); 2837 + i915_address_space_fini(&ggtt->base); 2838 + mutex_unlock(&dev_priv->drm.struct_mutex); 2843 2839 } 2844 2840 2845 2841 ggtt->base.cleanup(&ggtt->base);