Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8315862ybi; Tue, 23 Jul 2019 06:32:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxL8iuCoNVODdKaFuDWMxy32bZds0gDdhCKs4TYS1i1bhZrbTD2gKlD/TUKWyBxkovctHt6 X-Received: by 2002:a17:90a:ac13:: with SMTP id o19mr82604702pjq.143.1563888749684; Tue, 23 Jul 2019 06:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563888749; cv=none; d=google.com; s=arc-20160816; b=biFTISMnlCEJsG7uYNjYBjEPsBU1ACi597XOACA0T565xdzbdtX12/SWxry64YTMu/ sBuGQtFT5S8eCzF6KyG3jzsx8VQtMFTthpxsC3MLpXxkk5xG8MwCQPUfcI03nGBoDwbz zou9kScxn7INlcMmEE3g3cdTOOCsHJD1IkxF522F5Bo5ZXfEG3Gfp+tImRi5d86DqFaV 4uGeGrV5hZgq3/cywHjl59dpq8VQu6CxWwi2tSt9NU5jd8YeHTKDit4oEkembn0Suq7T DCyd962sNUwXAxoRmoW5u/tZtDINvtdIOZWPd6SJ/ywQnWdNppeTcaIc7Wj7thwHUPb1 CduQ== 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=8oVnWnzi5t2ouuMP0eGavMEOYBbckZs3soRWMye7A3o=; b=pf8TFNkA00mXZau8SFdJDdx0BhHqHPD+iCx8R0dxUpOAiKUu+K4Fq/pcQL2yiEtS1D FToCo1oU6LfKNHwy0Pg8Stw+TsN2cKTy2cKCYxNeIF8EDuVMOSjgXfZYwdXLg+LHmlVq jAUM70CeEmfVQ5CAkp9y+fPy1ziCmfZ5y3eUi1ekxu1ekdvJqxB935Bg6u6pab/UUfFx vtxP82Yuml3hKKPjnLBK1TXncTTf0q9KCj7DZ/zt5PYeQhsDc2XhdaUtUg5Z5b4xBApN Rpq3P8oVwQB8I43zwEzSA+o25NaO5mLhqZQCJwoUIPUrNuwNWT2SZ5XWdvGOjePfwY7A QfdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=coS07tBP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id j64si16750934pge.556.2019.07.23.06.31.45; Tue, 23 Jul 2019 06:32:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=coS07tBP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1732158AbfGWFEV (ORCPT + 99 others); Tue, 23 Jul 2019 01:04:21 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:54052 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726504AbfGWFEV (ORCPT ); Tue, 23 Jul 2019 01:04:21 -0400 Received: by mail-wm1-f68.google.com with SMTP id x15so37141201wmj.3 for ; Mon, 22 Jul 2019 22:04:20 -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=8oVnWnzi5t2ouuMP0eGavMEOYBbckZs3soRWMye7A3o=; b=coS07tBPBC7wYQb0eVBCkLCJHa4uo26V40PmAD1PciVsJ9+1hh8Sm5UEYObGVO9BS8 fYSi/QHlhVoWMRoubXXhjAb0XeKWwvUKRxoDlnFaMRplWhdjd9PpR7S84tE/HxAJh3FG WydE/5pV6kYzUGuIlLDDCOOMAjLLEnakhWMOls8hMz8lJqj4rnEcrEKIF9OwwYFH260M yklxy5IVbUa66uso0MGCvPw4QdLDNT9A+/y39rvSm4nqLHSwh0O+hUaxivHVz7JNka6X iMRMF5Nou7E0g8FGl7rRGa6uP0e/j9AiyujcAcKjZBeLatsFzNa6vTOx+hth40ePL85e b+AQ== 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=8oVnWnzi5t2ouuMP0eGavMEOYBbckZs3soRWMye7A3o=; b=QUwn/eQnDI4hk0uBjt3+4cQbFTLwW1Beh8Tq/2JRPjvFQp2I3vkCp+GAVPJK9vUIMK Vd3LBguffquWQucFr6gtORIW8iC/mGtyramQJCx+NR5wkNRoZ0eD1JjHyt7mBN0awhce w/8s4GYFRA2A5GKAu+oxfL11oDsebE4AXVOCs8mDYSzDlGLPMOLwgWdSB2jO98sV+1AH AnfeWxIPW6OtaTkJASjt4FIGLaZcRAtzpvupUMrTKvkoxuAt9VVY9V4Peuw7inFxTH9y dhY5MmUkdN9hw5Q2rvsZLyaJAnnhVCegR5GLmuzHag1Z0TwN+Z2sd4hVspf1rmZBS6zQ uQsQ== X-Gm-Message-State: APjAAAXreoeV0kKzyT8fIERndBUM1D1ivDYzRyDE+p3kcMgw3Get0XxJ 7wFOAcuNJhsDGSuCDZAhorESLpt0bklD3b8iDsdKpg== X-Received: by 2002:a1c:d10c:: with SMTP id i12mr66789877wmg.152.1563858259317; Mon, 22 Jul 2019 22:04:19 -0700 (PDT) MIME-Version: 1.0 References: <20190624194908.121273-1-john.stultz@linaro.org> <20190624194908.121273-5-john.stultz@linaro.org> <20190718100840.GB19666@infradead.org> In-Reply-To: <20190718100840.GB19666@infradead.org> From: John Stultz Date: Mon, 22 Jul 2019 22:04:06 -0700 Message-ID: Subject: Re: [PATCH v6 4/5] dma-buf: heaps: Add CMA heap to dmabuf heaps To: Christoph Hellwig Cc: lkml , Laura Abbott , Benjamin Gaignard , Sumit Semwal , Liam Mark , Pratik Patel , Brian Starkey , Vincent Donnefort , Sudipto Paul , "Andrew F . Davis" , Xu YiPing , "Chenfeng (puck)" , butao , "Xiaqing (A)" , Yudongbin , Chenbo Feng , Alistair Strachan , dri-devel 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, Jul 18, 2019 at 3:08 AM Christoph Hellwig wrote: > > This and the previous one seem very much duplicated boilerplate > code. So yes, there is some duplicate boilerplate between the system and cma heaps particularly in the allocation function, where we allocate and set up the helper buffer structure, allocate the pages, then create and export the dmabuf. I took a pass at trying to minimize some of this earlier, but those efforts ended up adding helper functions that take a ton of arguments, and had some trouble properly handling error paths without leaking memory, so I left it as is. I'll try to take another pass myself but if you have specific suggestions for improving here, I'd be happy to try them. > Why can't just normal branches for allocating and freeing > normal pages vs cma? We even have an existing helper for that > with dma_alloc_contiguous(). Apologies, I'm not sure I'm understanding your suggestion here. dma_alloc_contiguous() does have some interesting optimizations (avoiding allocating single page from cma), though its focus on default area vs specific device area doesn't quite match up the usage model for dma heaps. Instead of allocating memory for a single device, we want to be able to allow userland, for a given usage mode, to be able to allocate a dmabuf from a specific heap of memory which will satisfy the usage mode for that buffer pipeline (across multiple devices). Now, indeed, the system and cma heaps in this patchset are a bit simple/trivial (though useful with my devices that require contiguous buffers for the display driver), but more complex ION heaps have traditionally stayed out of tree in vendor code, in many cases making incompatible tweaks to the ION core dmabuf exporter logic. That's why dmabuf heaps is trying to destage ION in a way that allows heaps to implement their exporter logic themselves, so we can start pulling those more complicated heaps out of their vendor hidey-holes and get some proper upstream review. But I suspect I just am confused as to what your suggesting. Maybe could you expand a bit? Apologies for being a bit dense. Thanks again for the input! -john