From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752477AbcF1PSJ (ORCPT ); Tue, 28 Jun 2016 11:18:09 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:37949 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751879AbcF1PSH convert rfc822-to-8bit (ORCPT ); Tue, 28 Jun 2016 11:18:07 -0400 Date: Tue, 28 Jun 2016 12:17:52 -0300 From: Gustavo Padovan 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 , Chris Wilson Subject: Re: [RFC v2 2/3] dma-buf/fence-array: add fence_array_teardown() Message-ID: <20160628151752.GL2508@joana> References: <1467055762-25881-1-git-send-email-gustavo@padovan.org> <1467055762-25881-3-git-send-email-gustavo@padovan.org> <577249CB.6050707@amd.com> <20160628141703.GJ2508@joana> <57729235.7040308@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: <57729235.7040308@amd.com> User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2016-06-28 Christian König : > Am 28.06.2016 um 16:17 schrieb Gustavo Padovan: > > 2016-06-28 Christian König : > > > > > Am 27.06.2016 um 21:29 schrieb Gustavo Padovan: > > > > From: Gustavo Padovan > > > > > > > > As the array of fence callbacks held by an active struct fence_array > > > > each has a reference to the struct fence_array, when the owner of the > > > > fence_array is freed it must dispose of the callback references before > > > > it can free the fence_array. This can not happen simply during > > > > fence_release() because of the extra references and so we need a new > > > > function to run before the final fence_put(). > > > As I said previously as well, this is completely superfluous. > > > > > > The fence array keeps a reference to itself as long as not all callbacks are > > > signaled. > > > > > > So you only need to unregister your callback from the array itself and 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() > > does not release it because of the extra references from the non > > signalled fences so we need to clean up this somehow. > > No, there won't be any leak and you don't need to cleanup anything. > > The fences contained in the fence array are already enabled for signaling. > So they will eventually signal sooner or later and drop the reference to the > fence array freeing it when the last one finished. > > This was done to avoid the need to call fence_remove_callback() all the time > on the fences in the array because of the warning on the function. Right. I understand it now. Gustavo