[Intel-gfx] [PATCH] Release front buffer bo when quit X

Eric Anholt eric at anholt.net
Thu Apr 16 23:39:19 CEST 2009


On Wed, 2009-04-15 at 09:39 +0800, Shuang He wrote:
> Fix indentation in the previous patch, Thanks for anholt.

Please send patches to the mailing list using git send-email, with
proper commit messages so they can be applied.

> Shuang He wrote: 
> > Forget to mention that, this leak happens with KMS or DRI2 is enabled
> > 
> > Thanks
> >     --Shuang
> > 
> > Shuang He wrote:
> >   
> > > As I checked X with valgrind, a memory leak is detected when quit X.
> > > 
> > > ==23357== 0 bytes in 1 blocks are definitely lost in loss record 1 of 116
> > > ==23357==    at 0x55A962F: drm_intel_gem_bo_alloc_internal 
> > > (intel_bufmgr_gem.c:428)
> > > ==23357==    by 0x55A5192: drm_intel_bo_alloc (intel_bufmgr.c:51)
> > > ==23357==    by 0x55459CC: i830_allocate_memory (i830_memory.c:829)
> > > ==23357==    by 0x55463F5: i830_allocate_framebuffer (i830_memory.c:1268)
> > > ==23357==    by 0x556F786: drmmode_xf86crtc_resize (drmmode_display.c:674)
> > > ==23357==    by 0x816F530: xf86RandR12ScreenSetSize (xf86RandR12.c:705)
> > > ==23357==    by 0x816FC10: xf86RandR12CreateScreenResources 
> > > (xf86RandR12.c:833)
> > > ==23357==    by 0x80A225F: xf86CrtcCreateScreenResources (xf86Crtc.c:708)
> > > ==23357==    by 0x8064BD0: main (main.c:324)
> > > 
> > > The attached patch would fix that.
> > > 
> > > Thanks
> > >     --Shuang
> > >   
> > >     
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/intel-gfx
> >   
> 
> plain text document attachment (free_front_buffer.patch)
> diff --git a/src/i830_driver.c b/src/i830_driver.c
> index 32ca6c9..ab73871 100644
> --- a/src/i830_driver.c
> +++ b/src/i830_driver.c
> @@ -3710,6 +3710,12 @@ I830CloseScreen(int scrnIndex, ScreenPtr pScreen)
>         pI830->uxa_driver = NULL;
>     }
>  #endif
> +   if (pI830->front_buffer) {
> +	i830_set_pixmap_bo(pScreen->GetScreenPixmap(pScreen), NULL);
> +	i830_free_memory(pScrn, pI830->front_buffer);
> +   	pI830->front_buffer = NULL;
> +   }
> +
>     xf86_cursors_fini (pScreen);
>  
>     i830_allocator_fini(pScrn);
> diff --git a/src/i830_exa.c b/src/i830_exa.c
> index 39011bc..2b3b42b 100644
> --- a/src/i830_exa.c
> +++ b/src/i830_exa.c
> @@ -812,7 +812,8 @@ i830_set_pixmap_bo(PixmapPtr pixmap, dri_bo *bo)
>  	dri_bo_unreference (old_bo);
>  #if I830_USE_UXA
>      if (i830->accel == ACCEL_UXA) {
> -	dri_bo_reference(bo);
> +	if (bo != NULL)
> +	    dri_bo_reference(bo);
>  	dixSetPrivate(&pixmap->devPrivates, &uxa_pixmap_index, bo);
>      }
>  #endif
> @@ -821,7 +822,8 @@ i830_set_pixmap_bo(PixmapPtr pixmap, dri_bo *bo)
>  	struct i830_exa_pixmap_priv *driver_priv =
>  	    exaGetPixmapDriverPrivate(pixmap);
>  	if (driver_priv) {
> -	    dri_bo_reference(bo);
> +	    if (bo != NULL)
> +	    	dri_bo_reference(bo);
>  	    driver_priv->bo = bo;
>  	}
>      }
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
-- 
Eric Anholt
eric at anholt.net                         eric.anholt at intel.com


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/intel-gfx/attachments/20090416/adfc0629/attachment-0001.sig>


More information about the Intel-gfx mailing list