From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754033AbcESHrL (ORCPT ); Thu, 19 May 2016 03:47:11 -0400 Received: from mail-bl2on0061.outbound.protection.outlook.com ([65.55.169.61]:5984 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753902AbcESHrI (ORCPT ); Thu, 19 May 2016 03:47:08 -0400 Authentication-Results: samsung.com; dkim=none (message not signed) header.d=none;samsung.com; dmarc=none action=none header.from=amd.com; Subject: Re: [PATCH 1/2] dma-buf/fence: add fence_collection fences To: Chris Wilson , Gustavo Padovan , , , Daniel Stone , , Daniel Vetter , , , "Alex Deucher" , Gustavo Padovan , John Harrison , References: <1463605193-18040-1-git-send-email-gustavo@padovan.org> <20160518225710.GA32627@nuc-i3427.alporthouse.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <573D6F67.7070109@amd.com> Date: Thu, 19 May 2016 09:46:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <20160518225710.GA32627@nuc-i3427.alporthouse.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [2a02:908:1250:ae81:e06e:5e9b:4940:a9d7] X-ClientProxiedBy: AM4PR01CA0037.eurprd01.prod.exchangelabs.com (10.164.74.175) To SN1PR12MB0143.namprd12.prod.outlook.com (10.162.3.142) X-MS-Office365-Filtering-Correlation-Id: 479b0f84-7565-4fe4-3fcd-08d37fb9c581 X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0143;2:kU4ciF9EyMBdqEHA8kerad7VM2m5FpxRPBn+GDaAyaje/BWhpZL/lkEEiQeAro5y1TVPrG+ckqtfccmn15Ac/hdePN087JOJHJ/YkAKwHsMBAo3DwHn/22susDcyE2o9H18/bba5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SN1PR12MB0143;20:2/lih95ToS0ojxOW/Mnxcdg5Fc3ObyC0ByCK9t+a15R9x46USZ4+vmsxDfTvirZ+8XshsZA2MbcKP6xt4VvucUP43ifI9lGFuEqk5tXiTAg9RVpwgeXp1O8fcbdX/TzZFQXgQpa2DzRqRzGCTNb4OH96WchAF+YWqZcdL3UCdTgecCrFnnup0twEc0D+mo06oO55vvBstAImZfDkE/ARXdL7ir9+8EEByux8S9uZZ+/i/ZEEz3SfrOLjBSAyS3j29vmbrzyX3LAEmmlqmGzgEBJie4AYsELFZsFcSMxHlxbqv7xbcMh8U3UtcORZPeeaKa3blLdD8+vtbs9LEoqk7DGVi9zMjU3nGokwxftHLPupfF80phxQE7ECxWnWf/YSh6+Bnn+tJ+YChwNklct+8YtdSWqtZMRHN8xOmJ3+3R/YyjhUIET3uVfxzckY7cX52WsQMdE++VGly77ujB5+q5F5kkwJxnWwkxmYSzxht49ztA8kqMSm/TQx+2pUzBSL;4:UjljConpuWUPSUWamHeTvUIaec05pW4KhO70eBHqLqgFndh0ZtOfmBPnYNXumWkVelwkPLLEcrbarsC383yK/MJzmPLYy9cONHUF0p80mdycEgZ3OFepWK6/bvvwLUb/E1iXdW5fCQIrxow6L5UUJYwVw7eoIZBejQoVShtaq11ygnrm6xSalPIqorxnwbncqmKgRg84QuZF5jQ9yMkvcXG9ZfiZlTLiPqvTkzyanQNL/uCMJDUu6X6mrGrF9ewopeI4Bz0Lvi0K5WjP3wEFqX4wSy5/xRU56pzcESN4AOLnq6+nCxsgGW+Up51TE3H1WC8wo43S8FLClHrATLMjbC2biD+b3TvN8a0RwG5FVTIW+0uft4jp8rJtBnxgBhRk5eaGn1Hl+t9TmcmlGCD0Ng== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026);SRVR:SN1PR12MB0143;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0143; X-Forefront-PRVS: 094700CA91 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(24454002)(5004730100002)(2906002)(6116002)(42186005)(586003)(5001770100001)(23746002)(65956001)(50466002)(36756003)(8676002)(81166006)(107886002)(2201001)(189998001)(86362001)(87266999)(5008740100001)(80316001)(65816999)(92566002)(54356999)(76176999)(230700001)(64126003)(50986999)(77096005)(2950100001)(33656002)(83506001)(921003)(3826002)(83996005)(1121003)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR12MB0143;H:[IPv6:2a02:908:1250:ae81:e06e:5e9b:4940:a9d7];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;SN1PR12MB0143;23:yvZpw5Mhg32ONFT/fQz/EYzCS/tqVI1aY+M8c?= =?Windows-1252?Q?Zb8mtX7fZMv1y7N/7zZt28ePO6yLx4ZhreOvMfsI2U9+XJfuinloFRzm?= =?Windows-1252?Q?g+RDKFOvWnMxq2+g5g7Dz5tuh5y41UbDd5XCTGuW2heOJjxDf5DRcS+o?= =?Windows-1252?Q?nV3q6RdxCvJCcTKacMs2/sVTKnpDAthlrFzNCGnZeBqkV25t99wu8wnI?= =?Windows-1252?Q?cPRq8RfOZWGOG23ocBUfbOjMFElgWAN78rc3tgYBygY/Y/oE6GRtUSo/?= =?Windows-1252?Q?eAvxR9myIVDMIGdSQ0AGtE1XWAQS+xi2VtxRBrhO5pim1c7fETZvacjp?= =?Windows-1252?Q?eZYj/GImUgmz7eQ6yut9eiQWnqcP7K27VV5sJcn6PaYpbBjD+m4iQ2zd?= =?Windows-1252?Q?C+6BkOrlwiq5kzrEn0AFbKh0kHMGrZ0nO4BylkyAcHGJmrvGR2/EJc28?= =?Windows-1252?Q?1/4kq5FzS482RRDeuHOgRdsGeicF5HxDVrF08xfN6BGkXIxcgdM+HWAy?= =?Windows-1252?Q?nSsud2wjcgAt7qebttaApG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YmKLa64fL/8Y504Rpxf38ruedOk891jSlRGqXphRuJWwV84oG+bo=;20:qJujAgCBKXUdTj5iWh+galRitPQ2TpYK0K7KotyHKlxFxWpEcK3jnI7bvP3dAsnyPm0/Bx9O9cAKfA7RJMD+m9x+bSC9OiDlDe3CamFudIcdQXH5t9NeIBpzpPeubLXXvS2hjV2rcWdPNPp2/3/DeUo1X1hyqMBCZC53Uf4FbFsdICFHg3ZVzhSSP2T7jVKdVvdXSY687DcnqCfox/KRt9o2dOTOyZZCb/PvfbgDpJjdmKkMcC/7zculNtcK9GhL X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2016 07:47:01.7380 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0143 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 19.05.2016 um 00:57 schrieb Chris Wilson: > On Wed, May 18, 2016 at 05:59:52PM -0300, Gustavo Padovan wrote: >> +static void collection_check_cb_func(struct fence *fence, struct fence_cb *cb) >> +{ >> + struct fence_collection_cb *f_cb; >> + struct fence_collection *collection; >> + >> + f_cb = container_of(cb, struct fence_collection_cb, cb); >> + collection = f_cb->collection; >> + >> + if (atomic_dec_and_test(&collection->num_pending_fences)) >> + fence_signal(&collection->base); >> +} >> + >> +static bool fence_collection_enable_signaling(struct fence *fence) >> +{ >> + struct fence_collection *collection = to_fence_collection(fence); >> + int i; >> + >> + for (i = 0 ; i < collection->num_fences ; i++) { >> + if (fence_add_callback(collection->fences[i].fence, >> + &collection->fences[i].cb, >> + collection_check_cb_func)) { >> + atomic_dec(&collection->num_pending_fences); >> + } >> + } > We don't always have a convenient means to preallocate an array of > fences to use. Keeping a list of fences in addition to the array would > be easier to user in many circumstances. I agree that there is use for such an implementation as well, but as mentioned in the last review cycle we intentionally chose an array instead of a more complex implementation here. This way the array can be passed to function like fence_wait_any_timeout() as well. I also suggested to rename it to fence_array to make that difference clear and allow for another implementation to live side by side with this. My crux at the moment is that I need both for the amdgpu driver, an array based implementation and a collection like one. Gustavo would you mind if I take your patches and work a bit on this? > > Just means we need a > > struct fence_collection_entry { > struct fence *fence; > struct list_head link; > }; > > int fence_collection_add(struct fence *_collection, > struct fence *fence) > { > struct fence_collection *collection = > to_fence_collection(_collection); > struct fence_collection_entry *entry; > > entry = kmalloc(sizeof(*entry), GFP_KERNEL); > if (!entry) > return -ENOMEM; > > entry->fence = fence_get(fence); > list_add_tail(&entry->link, &collection->fence_list); > atomic_inc(&collection->num_pending_fences); > > return 0; > } > > and a couple of list iterations as well as walking the arrays. > > (This fence_collection_add() needs to be documented to only be valid > from the constructing thread before the fence is sealed for export/use.) As suggested by Daniel as well I would prefer that the the array implementation only gets the fences as already filled array in the constructor. This is much more fail save. Christian. > -Chris >