Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE7E0C4724C for ; Fri, 1 May 2020 11:08:55 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96B0D208C3 for ; Fri, 1 May 2020 11:08:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96B0D208C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 178826EC44; Fri, 1 May 2020 11:08:55 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 659086EC44 for ; Fri, 1 May 2020 11:08:54 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EBF4A30E; Fri, 1 May 2020 04:08:53 -0700 (PDT) Received: from [10.57.39.240] (unknown [10.57.39.240]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B7C0A3F73D; Fri, 1 May 2020 04:08:50 -0700 (PDT) Subject: Re: [RFC][PATCH 3/4] dma-buf: cma_heap: Extend logic to export CMA regions tagged with "linux,cma-heap" To: Brian Starkey , John Stultz References: <20200501073949.120396-1-john.stultz@linaro.org> <20200501073949.120396-4-john.stultz@linaro.org> <20200501102143.xcckvsfecumbei3c@DESKTOP-E1NTVVP.localdomain> From: Robin Murphy Message-ID: <47e7eded-7240-887a-39e1-97c55bf752e7@arm.com> Date: Fri, 1 May 2020 12:08:48 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200501102143.xcckvsfecumbei3c@DESKTOP-E1NTVVP.localdomain> Content-Language: en-GB X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, nd@arm.com, Alistair Strachan , Sandeep Patil , Chenbo Feng , lkml , Liam Mark , "Andrew F. Davis" , linux-mm@kvack.org, Rob Herring , Christoph Hellwig , dri-devel@lists.freedesktop.org, Hridya Valsaraju , Andrew Morton , Laura Abbott , Pratik Patel , Marek Szyprowski Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 2020-05-01 11:21 am, Brian Starkey wrote: > Hi John, > > On Fri, May 01, 2020 at 07:39:48AM +0000, John Stultz wrote: >> This patch reworks the cma_heap initialization so that >> we expose both the default CMA region and any CMA regions >> tagged with "linux,cma-heap" in the device-tree. >> >> Cc: Rob Herring >> Cc: Sumit Semwal >> Cc: "Andrew F. Davis" >> Cc: Benjamin Gaignard >> Cc: Liam Mark >> Cc: Pratik Patel >> Cc: Laura Abbott >> Cc: Brian Starkey >> Cc: Chenbo Feng >> Cc: Alistair Strachan >> Cc: Sandeep Patil >> Cc: Hridya Valsaraju >> Cc: Christoph Hellwig >> Cc: Marek Szyprowski >> Cc: Robin Murphy >> Cc: Andrew Morton >> Cc: devicetree@vger.kernel.org >> Cc: dri-devel@lists.freedesktop.org >> Cc: linux-mm@kvack.org >> Signed-off-by: John Stultz >> --- >> drivers/dma-buf/heaps/cma_heap.c | 18 +++++++++--------- >> 1 file changed, 9 insertions(+), 9 deletions(-) >> >> diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c >> index 626cf7fd033a..dd154e2db101 100644 >> --- a/drivers/dma-buf/heaps/cma_heap.c >> +++ b/drivers/dma-buf/heaps/cma_heap.c >> @@ -141,6 +141,11 @@ static int __add_cma_heap(struct cma *cma, void *data) >> { >> struct cma_heap *cma_heap; >> struct dma_heap_export_info exp_info; >> + struct cma *default_cma = dev_get_cma_area(NULL); >> + >> + /* We only add the default heap and explicitly tagged heaps */ >> + if (cma != default_cma && !cma_dma_heap_enabled(cma)) >> + return 0; > > Thinking about the pl111 thread[1], I'm wondering if we should also > let drivers call this directly to expose their CMA pools, even if they > aren't tagged for dma-heaps in DT. But perhaps that's too close to > policy. That sounds much like what my first thoughts were - apologies if I'm wildly off-base here, but as far as I understand: - Device drivers know whether they have their own "memory-region" or not. - Device drivers already have to do *something* to participate in dma-buf. - Device drivers know best how they make use of both the above. - Therefore couldn't it be left to drivers to choose whether to register their CMA regions as heaps, without having to mess with DT at all? Robin. > > Cheers, > -Brian > > [1] https://lists.freedesktop.org/archives/dri-devel/2020-April/264358.html > >> >> cma_heap = kzalloc(sizeof(*cma_heap), GFP_KERNEL); >> if (!cma_heap) >> @@ -162,16 +167,11 @@ static int __add_cma_heap(struct cma *cma, void *data) >> return 0; >> } >> >> -static int add_default_cma_heap(void) >> +static int cma_heaps_init(void) >> { >> - struct cma *default_cma = dev_get_cma_area(NULL); >> - int ret = 0; >> - >> - if (default_cma) >> - ret = __add_cma_heap(default_cma, NULL); >> - >> - return ret; >> + cma_for_each_area(__add_cma_heap, NULL); >> + return 0; >> } >> -module_init(add_default_cma_heap); >> +module_init(cma_heaps_init); >> MODULE_DESCRIPTION("DMA-BUF CMA Heap"); >> MODULE_LICENSE("GPL v2"); >> -- >> 2.17.1 >> _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel