Date: Sat, 12 Mar 2016 20:05:23 +0000 (UTC) From: =?UTF-8?Q?Jean-S=c3=a9bastien_P=c3=a9dron?= <dumbbell@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r296768 - head/sys/dev/drm2/i915 Message-ID: <201603122005.u2CK5NUm093367@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dumbbell Date: Sat Mar 12 20:05:23 2016 New Revision: 296768 URL: https://svnweb.freebsd.org/changeset/base/296768 Log: drm/i915: Import Linux commit 168f83660211b9e059e3bc0638daaa01e9ea0b71 This makes sure the default context of each ring is cleaned up with the ring itself and fixes a memory leak. Author: Mika Kuoppala <mika.kuoppala@linux.intel.com> Date: Fri May 3 16:29:08 2013 +0300 drm/i915: unreference default context on module unload Before module unload is called, gpu_idle() will switch to default context. This will increment ref count of base object as the default context is 'running' on module unload time. Unreference the drm object so that when context is freed, base object is freed as well. v2: added comment to explain the refcounts (Ben Widawsky) Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com> Reviewed-by: Ben Widawsky <ben@bwidawsk.net> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Obtained from: Linux Modified: head/sys/dev/drm2/i915/i915_gem_context.c Modified: head/sys/dev/drm2/i915/i915_gem_context.c ============================================================================== --- head/sys/dev/drm2/i915/i915_gem_context.c Sat Mar 12 19:55:22 2016 (r296767) +++ head/sys/dev/drm2/i915/i915_gem_context.c Sat Mar 12 20:05:23 2016 (r296768) @@ -297,6 +297,14 @@ void i915_gem_context_fini(struct drm_de i915_gem_object_unpin(dev_priv->ring[RCS].default_context->obj); + /* When default context is created and switched to, base object refcount + * will be 2 (+1 from object creation and +1 from do_switch()). + * i915_gem_context_fini() will be called after gpu_idle() has switched + * to default context. So we need to unreference the base object once + * to offset the do_switch part, so that i915_gem_context_unreference() + * can then free the base object correctly. */ + drm_gem_object_unreference(&dev_priv->ring[RCS].default_context->obj->base); + do_destroy(dev_priv->ring[RCS].default_context); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201603122005.u2CK5NUm093367>