Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1693569pxa; Thu, 13 Aug 2020 15:07:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwznz6leDYOj+Kza+DEgeJciccYfBQIP0azJ1ii6ktyd/4RjiEi7QOvBuxGvEWPjR8/wjXS X-Received: by 2002:a17:906:7b83:: with SMTP id s3mr5338340ejo.2.1597356471659; Thu, 13 Aug 2020 15:07:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597356471; cv=none; d=google.com; s=arc-20160816; b=G/R8VYPWN5lGH8vtJhJFC54uAdPltHLKWkNaDAmi64kF0SOyPXld5yoPuggi0leXwK bF9RY5+X0DT/Bf1mlPo1LTGm8R9VPmoJEz3ZU1XYyl/OTNDjg2LP/LccA8X7kxTOse5e pLDPvQTejcZCeRcuXsE2d2wHxibMFTwayPIRkoLted7QH8lkt0Y16+XwOR7a6vzi8Ljz VRu6+a5af5QVZZKsK6CWWn3pe/xeLjKviokl8GPv8zABE9hvNDFuwtY7ucJYoWsZBtcE m8jPgTyugLB+NNuTTz4FO3k3WeE2eY1Rp/7zeAmQfte0toB58/GpTVk0NYp4xYbAww4l ZfaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=3xfqWmRtflhotperG6NWnIwC3g3Q247SCA9p41kwBGs=; b=Jn456ElvRUj140nmhSlj1pTq85C1t+lS+8LPzt8oTJ1M7qk0uM7wZcGdxVDO7esnCK tiOuFAsi0/hV8Upej0eGsaWIQTvxEijdBpBd1W9qGAjb+Q3M+bt2Tt/b7WbPXNzs5KKT PzSpKwMxD3f5/5od8GQVPwruJy+Q4y9XW4pav4jZRu9kQnFUe3pRpFaZe8zuvYTDSPsc R//e01zwUw/xhUCe0MaXR3DHBaId8HkDMX3Ou2exTnKNP6Aqw18DWJeo3nDR8mrmQ+xp fGU/l333Ef1VJdb1CGwPC+VTjbgfl0pXFNuII39IPky4hyEXwkM9a4tNYcLD6SpSlebC jzug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UolcndJs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id df2si4116174edb.520.2020.08.13.15.07.29; Thu, 13 Aug 2020 15:07:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UolcndJs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726583AbgHMWEx (ORCPT + 99 others); Thu, 13 Aug 2020 18:04:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgHMWEw (ORCPT ); Thu, 13 Aug 2020 18:04:52 -0400 Received: from mail-oo1-xc42.google.com (mail-oo1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 520ADC061757 for ; Thu, 13 Aug 2020 15:04:52 -0700 (PDT) Received: by mail-oo1-xc42.google.com with SMTP id x6so1530424ooe.8 for ; Thu, 13 Aug 2020 15:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3xfqWmRtflhotperG6NWnIwC3g3Q247SCA9p41kwBGs=; b=UolcndJsDVYSOyRpQ9JTr2zGfNCUwNjMdyqIq4GBD+js16X0QMFHU5pkdTbeMN4D3J uwZsx83sUIAi5fU+Gbv5X5jO0+tv/noXUjIKV7uJOsz6DBylNxDXlnygKa+NedmkkH6d qTEw+QDw3sG5vtR/zRjLg8lz8ckaz7kKb1JsiOEOYroIvUHv+ofhMZxfUi+xgv5arPwO UvRKnfgaTxRKRU7o9D3LtRh/ubS9wF0j9Y88CIhCLROepZJfUBs77IHt62o8ek1hDQ8/ mNQPIZ4ViJW7nKvDYb/zMZHPeb8DTESKlnSV27oRfA8E5Jq7vDISu7SxEKObQ/gQCYMS /TPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3xfqWmRtflhotperG6NWnIwC3g3Q247SCA9p41kwBGs=; b=bMF0XHo4DSWoS0XpG4HbMNhvbw+L+kxBfSGoBx7H5wXY4y5g5MR9V0YoLWBkD2GXAv H9OZ9mgG3PMB/AbbIhVGLp3+V5hwNlJLE0BrXvGkfU9pBrgEiO5b0CCh3CPZObhn8qH/ dF0lMbTAqzdFawujvQVNTp0VFkwHldznHhgGcAk9FPIxJJ0/9VQxxbY+1ZdBDd0zdgDy L7OcfIXaMMNTbMwpa1zDZvjk0skQ6/whWP1RjHCp7X4mZYBt9nvzAhz79DepE8FgiM0N /feCB5P1gOKk6W9iFqLRfRbQyUJCKVaDAVfFFPRrukeBPjghkCgXYfZbZA25hbTpngEW nGHw== X-Gm-Message-State: AOAM533TbJIlV0zN7OD4p9itlEx+0MfxrksjbwacKn2UN5BkXVwyrvXK NmlMgmHC7uBv4JkLIVNUL2S1yz5LIIwgTeEP+le9mA== X-Received: by 2002:a4a:ca11:: with SMTP id w17mr6358838ooq.88.1597356291596; Thu, 13 Aug 2020 15:04:51 -0700 (PDT) MIME-Version: 1.0 References: <20200725032633.125006-1-john.stultz@linaro.org> <20200813100411.3gh2awfbmdjupbnw@DESKTOP-E1NTVVP.localdomain> In-Reply-To: <20200813100411.3gh2awfbmdjupbnw@DESKTOP-E1NTVVP.localdomain> From: John Stultz Date: Thu, 13 Aug 2020 15:04:40 -0700 Message-ID: Subject: Re: [RFC][PATCH] dma-heap: Add proper kref handling on dma-buf heaps To: Brian Starkey Cc: lkml , Sumit Semwal , "Andrew F . Davis" , Benjamin Gaignard , Liam Mark , Laura Abbott , linux-media@vger.kernel.org, dri-devel , nd Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 13, 2020 at 3:04 AM Brian Starkey wrote: > On Sat, Jul 25, 2020 at 03:26:33AM +0000, John Stultz wrote: > > Add proper refcounting on the dma_heap structure. > > While existing heaps are built-in, we may eventually > > have heaps loaded from modules, and we'll need to be > > able to properly handle the references to the heaps > > I'm not 100% clear on the intention here. What would take/drop a > reference on a heap? Yea. At the moment nothing, but I did this cleanup as part of some other changes which would allow drivers that want to produce a dmabuf without having to create their own exporter to find an existing heap and allocate from that. Thus we needed to do proper reference counting on the handles to the heap. Those changes are stuck for now waiting for an user to be publicly submitted, but this change initially seemed like a reasonable correctness cleanup, so I went ahead and sent it, but as Daniel noted we can wait for real users to be submitted before adding any extra complexity upstream. > In the case of modules I think the bigger problem is how to prevent > the module getting removed while there's still something using it. That's true. Probably need something like a kref on each buffer allocated. thanks -john