Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp549085ybz; Fri, 1 May 2020 04:10:47 -0700 (PDT) X-Google-Smtp-Source: APiQypIShOuBsx9nGGis1J8zE7amgGwILzUqMK6N1H1gOJ5fgQkMdgirLimkTA/1ptW7M2QdMGab X-Received: by 2002:aa7:cb56:: with SMTP id w22mr3068038edt.345.1588331447660; Fri, 01 May 2020 04:10:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588331447; cv=none; d=google.com; s=arc-20160816; b=QqddtvTg/8dV/M81DRU7N3dU6/TYQSnO9x1vC8E5h1ZjKb51q1ZudsWrHva/qY19cS MDFMlGsagYGBhub/u+6sfzds3T5+tHtkhgRJJRK5T9VNlNkMgNz4N6ioA/9B4rlEDlxW +rcG0xwVRMCFM6j+FOyavOPhOoGGWsx+SsygU0MTzJ3D5RqYo9Ki23qsH0tAuTvw5kjg BJrfbxem13ONgIDXnJKE7xJv/JKYpkJaA2G+C9jncTUHJbNpNLN1XduN/XBy/hQ926qG hfUQBuQwA8B5r5JH1X9aRnWn/Rb8p8Y6qf6WOv+m13dKDReGd+dI2r3azZtPnpTGcM+6 geFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=TojBivRqgMCK7EnYjkLPr0mZ/7hanriZDBKwQzp3Jkk=; b=B3ppYgSK5R4sQ2nAEgLYBswsX0WE3BnmeJpn7NR7gLyOEG9zfGU6HcJO/cxZCULaQ3 IAMYJI/z47QmAAhkekI1IWdSE7RQdoqxPu2c7kHPJxqBM3+q6ID5gOMsfMJ1oyoaFTiY /B8B3zOXzjJMkwec4Bs868AbRJLvgaYV+MoL5xW42ga7BqRwBU2QC9Ks19LDfzY3htA3 lxS6FjpFeaiLUb/eMFk8CtqWIHqE/VUe60JNX2tTA8zocE0ikDS9OvcbQnGvkRQdtyrm jPWop61Lp+vr20+4uiY/yUZMivOT8r1dUwqqUgZkhVCQL/l38VChJIU1DJck3uj+Rfo+ j0gA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n8si1388645edt.33.2020.05.01.04.10.23; Fri, 01 May 2020 04:10:47 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728585AbgEALIz (ORCPT + 99 others); Fri, 1 May 2020 07:08:55 -0400 Received: from foss.arm.com ([217.140.110.172]:38750 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728532AbgEALIy (ORCPT ); Fri, 1 May 2020 07:08:54 -0400 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >>