Hi, On Fri, Jun 07, 2019 at 03:07:17AM +0000, John Stultz wrote: > This patch adds system heap to the dma-buf heaps framework. > > This allows applications to get a page-allocator backed dma-buf > for non-contiguous memory. > > 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 <labb...@redhat.com> > Cc: Benjamin Gaignard <benjamin.gaign...@linaro.org> > Cc: Sumit Semwal <sumit.sem...@linaro.org> > Cc: Liam Mark <lm...@codeaurora.org> > Cc: Pratik Patel <prat...@codeaurora.org> > Cc: Brian Starkey <brian.star...@arm.com> > Cc: Vincent Donnefort <vincent.donnef...@arm.com> > Cc: Sudipto Paul <sudipto.p...@arm.com> > Cc: Andrew F. Davis <a...@ti.com> > Cc: Christoph Hellwig <h...@infradead.org> > Cc: Chenbo Feng <fe...@google.com> > Cc: Alistair Strachan <astrac...@google.com> > Cc: dri-de...@lists.freedesktop.org > Reviewed-by: Benjamin Gaignard <benjamin.gaign...@linaro.org> > Signed-off-by: John Stultz <john.stu...@linaro.org> > Change-Id: I4dc5ff54ccb1f7ca3ac8675661114ca33813654b > --- > v2: > * Switch allocate to return dmabuf fd > * Simplify init code > * Checkpatch fixups > * Droped dead system-contig code > v3: > * Whitespace fixups from Benjamin > * Make sure we're zeroing the allocated pages (from Liam) > * Use PAGE_ALIGN() consistently (suggested by Brian) > * Fold in new registration style from Andrew > * Avoid needless dynamic allocation of sys_heap (suggested by > Christoph) > * Minor cleanups > * Folded in changes from Andrew to use simplified page list > from the heap helpers > v4: > * Optimization to allocate pages in chunks, similar to old > pagepool code > * Use fd_flags when creating dmabuf fd (Suggested by Benjamin) > v5: > * Back out large order page allocations (was leaking memory, > as the page array didn't properly track order size) > --- > drivers/dma-buf/Kconfig | 2 + > drivers/dma-buf/heaps/Kconfig | 6 ++ > drivers/dma-buf/heaps/Makefile | 1 + > drivers/dma-buf/heaps/system_heap.c | 123 ++++++++++++++++++++++++++++ > 4 files changed, 132 insertions(+) > create mode 100644 drivers/dma-buf/heaps/Kconfig > create mode 100644 drivers/dma-buf/heaps/system_heap.c > > diff --git a/drivers/dma-buf/Kconfig b/drivers/dma-buf/Kconfig > index 9b93f86f597c..434cfe646dad 100644 > --- a/drivers/dma-buf/Kconfig > +++ b/drivers/dma-buf/Kconfig > @@ -47,4 +47,6 @@ menuconfig DMABUF_HEAPS > this allows userspace to allocate dma-bufs that can be shared between > drivers. > > +source "drivers/dma-buf/heaps/Kconfig" > + > endmenu > diff --git a/drivers/dma-buf/heaps/Kconfig b/drivers/dma-buf/heaps/Kconfig > new file mode 100644 > index 000000000000..205052744169 > --- /dev/null > +++ b/drivers/dma-buf/heaps/Kconfig > @@ -0,0 +1,6 @@ > +config DMABUF_HEAPS_SYSTEM > + bool "DMA-BUF System Heap" > + depends on DMABUF_HEAPS > + help > + Choose this option to enable the system dmabuf heap. The system heap > + is backed by pages from the buddy allocator. If in doubt, say Y. > diff --git a/drivers/dma-buf/heaps/Makefile b/drivers/dma-buf/heaps/Makefile > index de49898112db..d1808eca2581 100644 > --- a/drivers/dma-buf/heaps/Makefile > +++ b/drivers/dma-buf/heaps/Makefile > @@ -1,2 +1,3 @@ > # SPDX-License-Identifier: GPL-2.0 > obj-y += heap-helpers.o > +obj-$(CONFIG_DMABUF_HEAPS_SYSTEM) += system_heap.o > diff --git a/drivers/dma-buf/heaps/system_heap.c > b/drivers/dma-buf/heaps/system_heap.c > new file mode 100644 > index 000000000000..863834499ce1 > --- /dev/null > +++ b/drivers/dma-buf/heaps/system_heap.c > @@ -0,0 +1,123 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * DMABUF System heap exporter > + * > + * Copyright (C) 2011 Google, Inc. > + * Copyright (C) 2019 Linaro Ltd. > + */ > + > +#include <asm/page.h> > +#include <linux/dma-buf.h> > +#include <linux/dma-mapping.h> > +#include <linux/dma-heap.h> > +#include <linux/err.h> > +#include <linux/highmem.h> > +#include <linux/mm.h> > +#include <linux/scatterlist.h> > +#include <linux/slab.h> > + > +#include "heap-helpers.h" > + > +struct system_heap { > + struct dma_heap *heap; > +} sys_heap; > + > +
extra newline. Otherwise, LGTM: Reviewed-by: Brian Starkey <brian.star...@arm.com>