From mboxrd@z Thu Jan 1 00:00:00 1970 From: Imre Deak Subject: Re: [PATCH 1/9] [v2] drm/i915/bdw: Free PPGTT struct Date: Mon, 24 Feb 2014 18:43:47 +0200 Message-ID: <1393260227.13131.123.camel@intelbox> References: <1392876349-24684-2-git-send-email-benjamin.widawsky@intel.com> <1392925627-6033-1-git-send-email-benjamin.widawsky@intel.com> <1392925627-6033-2-git-send-email-benjamin.widawsky@intel.com> Reply-To: imre.deak@intel.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0539454208==" Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id BF480FAB52 for ; Mon, 24 Feb 2014 08:43:50 -0800 (PST) In-Reply-To: <1392925627-6033-2-git-send-email-benjamin.widawsky@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org To: Ben Widawsky Cc: Intel GFX , Ben Widawsky List-Id: intel-gfx@lists.freedesktop.org --===============0539454208== Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-eZnIkNgGpcLqY/Ic5/rw" --=-eZnIkNgGpcLqY/Ic5/rw Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 2014-02-20 at 11:47 -0800, Ben Widawsky wrote: > GEN8 never freed the PPGTT struct. As GEN8 doesn't use full PPGTT, the > leak is small and only found on a module reload. ie. I don't think this > needs to go to stable. >=20 > v2: The very naive, kfree in gen8 ppgtt cleanup, is subject to a double > free on PPGTT initialization failure. (Spotted by Imre). Instead this > patch pulls the ppgtt struct freeing out of the cleanup and leaves it to > the allocators/callers or the one doing the last kref_put as in standard > convention >=20 > Reported-by: Ville Syrj=C3=A4l=C3=A4 > Signed-off-by: Ben Widawsky Reviewed-by: Imre Deak > --- > drivers/gpu/drm/i915/i915_gem_context.c | 12 ++++++++++-- > drivers/gpu/drm/i915/i915_gem_gtt.c | 1 - > 2 files changed, 10 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i9= 15/i915_gem_context.c > index 171a2ef..9096e2a 100644 > --- a/drivers/gpu/drm/i915/i915_gem_context.c > +++ b/drivers/gpu/drm/i915/i915_gem_context.c > @@ -99,9 +99,8 @@ > static int do_switch(struct intel_ring_buffer *ring, > struct i915_hw_context *to); > =20 > -static void ppgtt_release(struct kref *kref) > +static void do_ppgtt_cleanup(struct i915_hw_ppgtt *ppgtt) > { > - struct i915_hw_ppgtt *ppgtt =3D container_of(kref, struct i915_hw_ppgtt= , ref); > struct drm_device *dev =3D ppgtt->base.dev; > struct drm_i915_private *dev_priv =3D dev->dev_private; > struct i915_address_space *vm =3D &ppgtt->base; > @@ -135,6 +134,15 @@ static void ppgtt_release(struct kref *kref) > ppgtt->base.cleanup(&ppgtt->base); > } > =20 > +static void ppgtt_release(struct kref *kref) > +{ > + struct i915_hw_ppgtt *ppgtt =3D > + container_of(kref, struct i915_hw_ppgtt, ref); > + > + do_ppgtt_cleanup(ppgtt); > + kfree(ppgtt); > +} > + > static size_t get_context_alignment(struct drm_device *dev) > { > if (IS_GEN6(dev)) > diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i= 915_gem_gtt.c > index 69a88d4..49e79fb 100644 > --- a/drivers/gpu/drm/i915/i915_gem_gtt.c > +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c > @@ -859,7 +859,6 @@ static void gen6_ppgtt_cleanup(struct i915_address_sp= ace *vm) > for (i =3D 0; i < ppgtt->num_pd_entries; i++) > __free_page(ppgtt->pt_pages[i]); > kfree(ppgtt->pt_pages); > - kfree(ppgtt); > } > =20 > static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt) --=-eZnIkNgGpcLqY/Ic5/rw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) iQEcBAABAgAGBQJTC3bDAAoJEORIIAnNuWDFiZsIAMwf75L03dQRYRtmjDj9WWal TwrYFXHlBXx36tiiNNSxlTnJBaLr4ID2ecbbh8W8V3Bi5tRteeoZMAFsv+LtSHrf XzfTZgdRctsN5PXLk8tvQ7QYKT4W/DD7noSd41ZzYrBUbQwck2zBOkX5plyx4UKs mAsMz7fhGfYLiiCUN+B6JKbFOARaYnT/3kPGUhtkVzyf6dsLK6i24lIrQtt8iX/N UQwcvUysfX+CiFkip9JM5qXkSyEhll9UbNZGWu1j9NfcjcP76hgpxQ6NGGKeA/sR pNn9sv6hRRQuGw7t1/Q9KX1tZe2FLi7NY87neilHkYOg/kRPE1R9H+868QWJEoE= =FRcV -----END PGP SIGNATURE----- --=-eZnIkNgGpcLqY/Ic5/rw-- --===============0539454208== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx --===============0539454208==--