Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4334527ybx; Mon, 4 Nov 2019 11:35:44 -0800 (PST) X-Google-Smtp-Source: APXvYqzMrAVOL6akb8EJHfLeEeAxZAye9OoLaJvo+tZBFxPzIlUyUwCB661oExy2yFDLspyqOu4q X-Received: by 2002:a50:9269:: with SMTP id j38mr31044979eda.5.1572896143260; Mon, 04 Nov 2019 11:35:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572896143; cv=none; d=google.com; s=arc-20160816; b=yKBr3Xm57dv6bJK10F/qn0iFxkgqFgLJf6q7nIDGBVzoW+2VcRZcpB5IdQFtyCxqxl n0gymcFvl/4mJMr/Xqi0jB0Je/mz7oqKxEk33M+MQ239xbPD9lwV6mScLU2cVPs2i3Dw uClr+ZOZFXu4cA+/eeq++nmvjrVMh/zr2Cb2tnCJb69r/iBuJkAQCB64iPVrNpbm0evB EnZtv1SJtSCS6xHBuUlLYA2O+rcaznU3+yB64002PFt57ovoDv1FdhrAlyQXEKp0dJF1 /Mv+oTxtYvxGaLGdYgb+z5shklv52DEPSxcW7DsCC6IxF/5MF45dgZset3QgFQgNWfr3 lr1A== 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=dJyiWygwO7PaAAF+lCbsOZbNEjf6c5RFpg3e51aDY1s=; b=O/pUkcUtFwV409amgqUn7OjRhxHEb77xcIMun9DjVDajALgY0nQGOVXMZUolytCoap Lhnlwri3KLMXBsVd5HqitbsCnAbF4a/oayOd7ISDqCwUjz0lUsdWsboDSxajbqfp6FzV U+CwiZ0nuImlGWaVOjneutC3AtMljR5VXPyPCoSWd0/7xnbZwYBPYDScqgrkt/fZI91Q vKpaskZIfg+coOR1/SWmfieQnO9vJ1OVgJezcJxB/Flfq5F8WRE+KJ3JOvjt6qMa6zBg y912RrBFWqRC6jfs3Mn4sHrisbmxbRrgXAUXViG9b7XuW98mcI+6VzCyoFSCPyW1YknB PB6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UQwKNKSE; 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 y51si8107781edb.29.2019.11.04.11.35.20; Mon, 04 Nov 2019 11:35:43 -0800 (PST) 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=UQwKNKSE; 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 S1729614AbfKDTed (ORCPT + 99 others); Mon, 4 Nov 2019 14:34:33 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:35360 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729010AbfKDTed (ORCPT ); Mon, 4 Nov 2019 14:34:33 -0500 Received: by mail-ot1-f66.google.com with SMTP id z6so15475330otb.2 for ; Mon, 04 Nov 2019 11:34:31 -0800 (PST) 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=dJyiWygwO7PaAAF+lCbsOZbNEjf6c5RFpg3e51aDY1s=; b=UQwKNKSETHUfngej3ca5qu8vH/tpViAxu1vSuRQ4v7yKRXVLeRKNmUp6a40oLzMEDJ QwOF4aDftrFrZok2yMaCbey3j8gBRBNqhwmK0HpI0nf359KY672zbyQoIaEq6RH71WbF 4j+wHs2mBB5TibJ8MMPiP1UB4x9Wwfh3W73sqxRH9RdSMe47rTW4AHLdXoptHFqGeM9+ 0dK9PrEw+RB0oCgrfZ6QXlZCF70J+UFWAxUXOg7qVO6OjL5Wkc52P4HWHLBPoWOIV+yf V46+kY6zDBZ3+iYGHS+/t1Fo5JQDCbBUh5LHuaNchwWvIJQwkFcD9mRIn97og8H1Qqzc 0Ljw== 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=dJyiWygwO7PaAAF+lCbsOZbNEjf6c5RFpg3e51aDY1s=; b=la7I8U4FNfUVZq0EFY7xAUdjJ0QM7EOJWbH6kk3IqdNhNHACAA3L11Lo42hbNgMnkn 5OFUgMDrBW7Xr5APdu/nxhBlBucaJZfdZygIftGe9uM8XNfGMvtKmpX1GpZ9iT7JR4uD U6DpuxX7/NP1VIykVd7ZN8E1yxfXQSwvfBF1sbfTLWtJ/XMJpO2Xy2D5cfxU7P+sTGzj 1EHgJtn5WOgqRzBVokY5JL6f8dhIOj53iVHqJrLr/B5DUUPBwjG0tYUGgmTpmZxbDBxo +rQvYHhviSFaZ0ff8MbfoYLlcs0e5QYOH7mh8OdmCb+/pQsXcqqF83DFz7cOrib1ZmRd Eb/w== X-Gm-Message-State: APjAAAWU6Z2t8iPaAMf00hvf0c7jAY9BAD2XzRYR7TeTjdJugk47/bed 3hw2KLyvGUEfwCVuaKbZoNUS2cSus9KNNvYiXWLyDA== X-Received: by 2002:a05:6830:ca:: with SMTP id x10mr18721750oto.221.1572896071138; Mon, 04 Nov 2019 11:34:31 -0800 (PST) MIME-Version: 1.0 References: <20191101214238.78015-1-john.stultz@linaro.org> <20191101214238.78015-3-john.stultz@linaro.org> <20191103161348.GB13344@google.com> In-Reply-To: <20191103161348.GB13344@google.com> From: John Stultz Date: Mon, 4 Nov 2019 11:34:19 -0800 Message-ID: Subject: Re: [PATCH v14 2/5] dma-buf: heaps: Add heap helpers To: Sandeep Patil Cc: lkml , Laura Abbott , Benjamin Gaignard , Sumit Semwal , Liam Mark , Pratik Patel , Brian Starkey , Vincent Donnefort , Sudipto Paul , Christoph Hellwig , Chenbo Feng , Hridya Valsaraju , Hillf Danton , Dave Airlie , dri-devel , sspatil+mutt@google.com, "Andrew F . Davis" , Alistair Strachan 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 Sun, Nov 3, 2019 at 8:13 AM wrote: > On Fri, Nov 01, 2019 at 09:42:35PM +0000, John Stultz wrote: > > Add generic helper dmabuf ops for dma heaps, so we can reduce > > the amount of duplicative code for the exported dmabufs. > > > > This code is an evolution of the Android ION implementation, so > > thanks to its original authors and maintainters: > > Rebecca Schultz Zavin, Colin Cross, Laura Abbott, and others! > > > > Cc: Laura Abbott > > Cc: Benjamin Gaignard > > Cc: Sumit Semwal > > Cc: Liam Mark > > Cc: Pratik Patel > > Cc: Brian Starkey > > Cc: Vincent Donnefort > > Cc: Sudipto Paul > > Cc: Andrew F. Davis > > Cc: Christoph Hellwig > > Cc: Chenbo Feng > > Cc: Alistair Strachan > > Cc: Hridya Valsaraju > > Cc: Sandeep Patil > > Cc: Hillf Danton > > Cc: Dave Airlie > > Cc: dri-devel@lists.freedesktop.org > > Reviewed-by: Benjamin Gaignard > > Reviewed-by: Brian Starkey > > Acked-by: Laura Abbott > > Tested-by: Ayan Kumar Halder > > Signed-off-by: John Stultz > > I have one question and a naming suggestin below (sorry). > > Acked-by: Sandeep Patil > > + > > +static void dma_heap_buffer_vmap_put(struct heap_helper_buffer *buffer) > > +{ > > + if (!--buffer->vmap_cnt) { > > nit: just checking here cause I don't know the order in which vmap_get() and > vmap_put() is expected to be called from dmabuf, the manual refcounting > based map/unmap is ok? > > I know ion had this for a while and it worked fine over the years, but I > don't know if anybody saw any issues with it. > > + vunmap(buffer->vaddr); > > + buffer->vaddr = NULL; > > + } > > +} > > + > > +#ifndef _HEAP_HELPERS_H > > +#define _HEAP_HELPERS_H > > + > > +#include > > +#include > > + > > +/** > > + * struct heap_helper_buffer - helper buffer metadata > > + * @heap: back pointer to the heap the buffer came from > > + * @dmabuf: backing dma-buf for this buffer > > + * @size: size of the buffer > > + * @flags: buffer specific flags > nit: Are thee dmabuf flags, or dmabuf_heap specific / allocation related flags? Good point. They were going to be for the generic flags but as there's no supported flags yet, there's no reason to track that in the helper code. I'll drop it > > + * @priv_virt pointer to heap specific private value > nit: text looks misaligned (or is it my editor?) Looks ok to me in vim. > > + * @lock mutext to protect the data in this structure > > + * @vmap_cnt count of vmap references on the buffer > > + * @vaddr vmap'ed virtual address > > + * @pagecount number of pages in the buffer > > + * @pages list of page pointers > > + * @attachments list of device attachments > ditto > > + * > > + * @free heap callback to free the buffer > > + */ > > +struct heap_helper_buffer { > /bikeshed/ > s/heap_helper_buffer/dma_heap_buffer ? > > The "heap helper buffer" doesn't really convey what it is. So its the helper structure that is used with all the helper functions. Since other dmabuf heaps don't have to use the helper infrastructure, they wouldn't need this structure, so I don't want to name it too generically to confuse folks. thanks -john