From owner-svn-src-all@freebsd.org Sat Mar 12 20:05:24 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8CF12ACE8DC; Sat, 12 Mar 2016 20:05:24 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 464371B1C; Sat, 12 Mar 2016 20:05:24 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u2CK5NYA093368; Sat, 12 Mar 2016 20:05:23 GMT (envelope-from dumbbell@FreeBSD.org) Received: (from dumbbell@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u2CK5NUm093367; Sat, 12 Mar 2016 20:05:23 GMT (envelope-from dumbbell@FreeBSD.org) Message-Id: <201603122005.u2CK5NUm093367@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dumbbell set sender to dumbbell@FreeBSD.org using -f From: =?UTF-8?Q?Jean-S=c3=a9bastien_P=c3=a9dron?= Date: Sat, 12 Mar 2016 20:05:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r296768 - head/sys/dev/drm2/i915 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Mar 2016 20:05:24 -0000 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 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 Reviewed-by: Ben Widawsky Signed-off-by: Daniel Vetter 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); }