From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= Subject: Re: [PATCH] drm/i915: Unpin last_context at reset Date: Mon, 23 Jun 2014 13:07:50 +0300 Message-ID: <20140623100750.GU27580@intel.com> References: <1403118289-19550-1-git-send-email-ville.syrjala@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 562B06E23E for ; Mon, 23 Jun 2014 03:10:01 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1403118289-19550-1-git-send-email-ville.syrjala@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Wed, Jun 18, 2014 at 10:04:48PM +0300, ville.syrjala@linux.intel.com wro= te: > From: Ville Syrj=E4l=E4 > = > We're forgetting to unpin the last_context from the ggtt at GPU reset > time. This leads to the vma pin_count leaking at every reset if the > last context wasn't the ring default context. Further use of the same > context will trigger the pin_count check in i915_gem_object_pin() and > userspace will be faced with EBUSY as a result. > = > This plaques kms_flip rather badly since it performs lots of resets, > and every fd has its own default context these days. > = > Fix the problem by properly unpinning the last context at reset. > = > Testcase: igt/gem_ctx_exec/reset-pin-leak > Signed-off-by: Ville Syrj=E4l=E4 I pushed the igt, and also kms_flip hits this easily. It looks to me that the bug has been there since the introduction of i915_gem_context_reset() in [1], so I think we may want this patch merged with cc: stable. Afterwards people can work on killing i915_gem_context_reset() if they so wish. [1] commit acce9ffa4807027965ebd948456fa8385bbee32e Author: Ben Widawsky Date: Fri Dec 6 14:11:03 2013 -0800 drm/i915: Better reset handling for contexts > --- > drivers/gpu/drm/i915/i915_gem_context.c | 3 +++ > 1 file changed, 3 insertions(+) > = > diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i9= 15/i915_gem_context.c > index 3ffe308..e362c96 100644 > --- a/drivers/gpu/drm/i915/i915_gem_context.c > +++ b/drivers/gpu/drm/i915/i915_gem_context.c > @@ -382,6 +382,9 @@ void i915_gem_context_reset(struct drm_device *dev) > dctx->obj->active =3D 0; > } > = > + if (ring->last_context->obj && i =3D=3D RCS) > + i915_gem_object_ggtt_unpin(ring->last_context->obj); > + > i915_gem_context_unreference(ring->last_context); > i915_gem_context_reference(dctx); > ring->last_context =3D dctx; > -- = > 1.8.5.5 -- = Ville Syrj=E4l=E4 Intel OTC