Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1243003lfc; Wed, 1 Jun 2022 12:52:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyo3totC30ojBneDiWftCym0YVs4VVcM3+gmNL4wdb9YWp8RD8HCx3YGYL0SEQC4cgtspwG X-Received: by 2002:a63:69c2:0:b0:3fa:78b6:aa2b with SMTP id e185-20020a6369c2000000b003fa78b6aa2bmr836373pgc.503.1654113137869; Wed, 01 Jun 2022 12:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654113137; cv=none; d=google.com; s=arc-20160816; b=BljmOgyvk4ncz8RpwxFyJaP0sUB58XlTfZdycjdc3pMOfiIAtPGLGp0mXIQ9U29Bv8 1m1zzfI37D3mHIj7PwUSAGxr9DPhZsR9XbwYdf8v8RCfr180AyejEAw5LzrDTJcc14UI vMmyLRqzGUl1XkHGwi1iR3bI+HiuvwCNu0UQCX81gL52BY4E1Www455BAwL5FI1DrZHe 4AIIUgJ1alQop9jCzUAHJRBuf00OC/E2YsOgzL1X6JvygNq3cUWou92Rk96yTzPMjsov XMZD2plZY8rZyHUZjhzD977MTekTB7pgIBo5y2dIs5Vl79zUY7/DY5eOql/Zsq9/HzI0 CmWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=grujjgVk78/kTeNAsYLCQutjse2S4qIjwux8s5I8vnE=; b=qNB86epILr0hvC5meXb3W7db0WjKFTmw5loKaG9Zd/8sq4/UcfW8n+bBV7zRpE5kjg ktwu+MKLa99965xel/A19qLYdpi8jrcFW2YLdMEJID8Xzz+9MbC9XTdvpH3Slz5Ad8GI HxG3thFzsJc+OGmKf16d5z6BW6fPbyOn94EAUYIqPTR+ufZUEQiJ4f+wgZjmFgwaJyXX oQyJTifuat8pc4dK4/eRFQPhbWunxMG8HXGifRc3EnskIz7mX3SJyexUnry4oJ67N6HH 1W+elqt3PoYimffn8Eb27aqtZ9Ax0oucEUQkzT4PmkzbWk1BDLWHcIaCjaH/87iDVT90 0uNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=lbp9nbUH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n7-20020a17090ac68700b001df53d6dbc7si7243895pjt.117.2022.06.01.12.52.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 12:52:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=lbp9nbUH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 096831FE381; Wed, 1 Jun 2022 12:14:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353235AbiFANWj (ORCPT + 99 others); Wed, 1 Jun 2022 09:22:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353201AbiFANWe (ORCPT ); Wed, 1 Jun 2022 09:22:34 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45F8850000 for ; Wed, 1 Jun 2022 06:22:32 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id p10so2326553wrg.12 for ; Wed, 01 Jun 2022 06:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=grujjgVk78/kTeNAsYLCQutjse2S4qIjwux8s5I8vnE=; b=lbp9nbUHl8ofN+dxS0sdOLugDeZaytx+OeJ/NUuXNjLXcor8DTOBLfkafd9Ko2hYX8 495GS2cLePb2F5knyThcbWf3wiId5H9lTMY9NZabHJK5EZ3R9hCa++G7oLq2EYPVKmNI +UytFWz/nCngyWhhtdQW0HcQWOK9ikTgTBhTk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=grujjgVk78/kTeNAsYLCQutjse2S4qIjwux8s5I8vnE=; b=4Xfy+bKo4v85XSAKTFJmPi/RFQqPrIke48NRlXS8BUW7MYJtW/Ka6+FriZCEE7RrGT B7msNaCYFuKlQnMX9sPzw5xGv+0drXaEZZUj4FjhdXek9oA+A1lJ+GedRxZadtr+1bgj OZOm0DOFUzQmxNx3QwbqaJscjnRtNQYwUW40WGkOFMjXng6Ab83g6pjP4CNrNHnc5zWX LZBywYRtcMioftYpqrTItXCP1Qac6r/UhJEG72AXSvlwg/aCp63hzkS1nDa1VtkaZUWq fUIjegAkuchMPzv4HtYZzMf3hogt9igStKPOXyPdKAYjnDX+yYs3W8Y690MYuukTI9oz HhlQ== X-Gm-Message-State: AOAM533FeHcttY+qliwkYL0P6Ve/LMpuFYl23XBFMdQI8r/wz2aRahv9 LlQjAZvWOlg2u+/X6F1Jm3PILg== X-Received: by 2002:a5d:4646:0:b0:210:3e3c:86dc with SMTP id j6-20020a5d4646000000b002103e3c86dcmr2982159wrs.277.1654089751161; Wed, 01 Jun 2022 06:22:31 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id d13-20020adfef8d000000b0020fc40d006bsm1609106wro.17.2022.06.01.06.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 06:22:30 -0700 (PDT) Date: Wed, 1 Jun 2022 15:22:27 +0200 From: Daniel Vetter To: Christian =?iso-8859-1?Q?K=F6nig?= Cc: Sergey Senozhatsky , Christian =?iso-8859-1?Q?K=F6nig?= , Sumit Semwal , Gustavo Padovan , Tomasz Figa , Ricardo Ribalda , Christoph Hellwig , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org Subject: Re: [Linaro-mm-sig] Re: [PATCH] dma-fence: allow dma fence to have their own lock Message-ID: Mail-Followup-To: Christian =?iso-8859-1?Q?K=F6nig?= , Sergey Senozhatsky , Christian =?iso-8859-1?Q?K=F6nig?= , Sumit Semwal , Gustavo Padovan , Tomasz Figa , Ricardo Ribalda , Christoph Hellwig , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org References: <20220530142232.2871634-1-senozhatsky@chromium.org> <7eee4274-bd69-df8d-9067-771366217804@amd.com> <33aba213-b6ad-4a15-9272-c62f5dfb1fb7@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <33aba213-b6ad-4a15-9272-c62f5dfb1fb7@gmail.com> X-Operating-System: Linux phenom 5.10.0-8-amd64 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 01, 2022 at 02:45:42PM +0200, Christian K?nig wrote: > Am 31.05.22 um 04:51 schrieb Sergey Senozhatsky: > > On (22/05/30 16:55), Christian K?nig wrote: > > > Am 30.05.22 um 16:22 schrieb Sergey Senozhatsky: > > > > [SNIP] > > > > So the `lock` should have at least same lifespan as the DMA fence > > > > that borrows it, which is impossible to guarantee in our case. > > > Nope, that's not correct. The lock should have at least same lifespan as the > > > context of the DMA fence. > > How does one know when it's safe to release the context? DMA fence > > objects are still transparently refcount-ed and "live their own lives", > > how does one synchronize lifespans? > > Well, you don't. > > If you have a dynamic context structure you need to reference count that as > well. In other words every time you create a fence in your context you need > to increment the reference count and every time a fence is release you > decrement it. > > If you have a static context structure like most drivers have then you must > make sure that all fences at least signal before you unload your driver. We > still somewhat have a race when you try to unload a driver and the fence_ops > structure suddenly disappear, but we currently live with that. > > Apart from that you are right, fences can live forever and we need to deal > with that. Yeah this entire thing is a bit an "oops we might have screwed up" moment. I think the cleanest way is to essentially do what the drm/sched codes does, which is split the gpu job into the public dma_fence (which can live forever) and the internal job fence (which has to deal with all the resource refcounting issues). And then make sure that only ever the public fence escapes to places where the fence can live forever (dma_resv, drm_syncobj, sync_file as our uapi container objects are the prominent cases really). It sucks a bit. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch