From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gustavo Padovan Subject: Re: [RFC v2 2/3] dma-buf/fence-array: add fence_array_teardown() Date: Tue, 28 Jun 2016 11:17:03 -0300 Message-ID: <20160628141703.GJ2508@joana> References: <1467055762-25881-1-git-send-email-gustavo@padovan.org> <1467055762-25881-3-git-send-email-gustavo@padovan.org> <577249CB.6050707@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Content-Disposition: inline In-Reply-To: <577249CB.6050707@amd.com> Sender: linux-kernel-owner@vger.kernel.org To: Christian =?iso-8859-1?Q?K=F6nig?= Cc: Gustavo Padovan , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Daniel Stone , Daniel Vetter , Rob Clark , Greg Hackmann , John Harrison , laurent.pinchart@ideasonboard.com, seanpaul@google.com, marcheu@google.com, m.chehab@samsung.com, Sumit Semwal , Maarten Lankhorst , Gustavo Padovan , Chris Wilson List-Id: dri-devel@lists.freedesktop.org 2016-06-28 Christian K=F6nig : > Am 27.06.2016 um 21:29 schrieb Gustavo Padovan: > > From: Gustavo Padovan > >=20 > > As the array of fence callbacks held by an active struct fence_arra= y > > each has a reference to the struct fence_array, when the owner of t= he > > fence_array is freed it must dispose of the callback references bef= ore > > it can free the fence_array. This can not happen simply during > > fence_release() because of the extra references and so we need a ne= w > > function to run before the final fence_put(). >=20 > As I said previously as well, this is completely superfluous. >=20 > The fence array keeps a reference to itself as long as not all callba= cks are > signaled. >=20 > So you only need to unregister your callback from the array itself an= d drop > your reference when you don't need it any more in the sync file. Exactly, this should be called from sync_file_free() because of the following use case: 1. You create 2 sync_file with 1 fence each 2. Merge both fences, which creates a fence array 3. Close the sync_file fd without waiting for the fences to signal At this point you leak the fence-array because the final fence_put()=20 does not release it because of the extra references from the non signalled fences so we need to clean up this somehow. Gustavo