From mboxrd@z Thu Jan 1 00:00:00 1970 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 82FEEC47258 for ; Fri, 1 May 2020 11:08:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4287024955 for ; Fri, 1 May 2020 11:08:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4287024955 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B70208E0016; Fri, 1 May 2020 07:08:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B20C18E0001; Fri, 1 May 2020 07:08:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0F768E0016; Fri, 1 May 2020 07:08:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id 8A67D8E0001 for ; Fri, 1 May 2020 07:08:55 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4E4EE52A6 for ; Fri, 1 May 2020 11:08:55 +0000 (UTC) X-FDA: 76767877830.09.men30_30b7d83e7fa13 X-HE-Tag: men30_30b7d83e7fa13 X-Filterd-Recvd-Size: 5480 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf01.hostedemail.com (Postfix) with ESMTP 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 Cc: lkml , Rob Herring , Sumit Semwal , "Andrew F. Davis" , Benjamin Gaignard , Liam Mark , Pratik Patel , Laura Abbott , Chenbo Feng , Alistair Strachan , Sandeep Patil , Hridya Valsaraju , Christoph Hellwig , Marek Szyprowski , Andrew Morton , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org, nd@arm.com 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-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 >>