diff mbox series

[RFC,1/2] mm: cma: Export cma symbols for cma heap as a module

Message ID 20191025234834.28214-2-john.stultz@linaro.org
State New
Headers show
Series Allow DMA BUF heaps to be loaded as modules | expand

Commit Message

John Stultz Oct. 25, 2019, 11:48 p.m. UTC
From: Sandeep Patil <sspatil@google.com>


Export cma_get_name, cma_alloc, cma_release, cma_for_each_area
and dma_contiguous_default_area so that we can use these from
the dmabuf cma heap when it is built as module.

Cc: Laura Abbott <labbott@redhat.com>
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Liam Mark <lmark@codeaurora.org>
Cc: Pratik Patel <pratikp@codeaurora.org>
Cc: Brian Starkey <Brian.Starkey@arm.com>
Cc: Andrew F. Davis <afd@ti.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Yue Hu <huyue2@yulong.com>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Cc: Chenbo Feng <fengc@google.com>
Cc: Alistair Strachan <astrachan@google.com>
Cc: Sandeep Patil <sspatil@google.com>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Sandeep Patil <sspatil@google.com>

[jstultz: Rewrote commit message, added
 dma_contiguous_default_area to the set of exported symbols]
Signed-off-by: John Stultz <john.stultz@linaro.org>

---
 kernel/dma/contiguous.c | 1 +
 mm/cma.c                | 5 +++++
 2 files changed, 6 insertions(+)

-- 
2.17.1

Comments

Christoph Hellwig Oct. 28, 2019, 7:46 a.m. UTC | #1
On Fri, Oct 25, 2019 at 11:48:33PM +0000, John Stultz wrote:
>  struct cma *dma_contiguous_default_area;

> +EXPORT_SYMBOL(dma_contiguous_default_area);


Please CC the dma maintainer.  And no, you have no business using this.

Even if you did, internals like this should always be EXPORT_SYMBOL_GPL.
John Stultz Oct. 28, 2019, 6:39 p.m. UTC | #2
On Mon, Oct 28, 2019 at 12:46 AM Christoph Hellwig <hch@infradead.org> wrote:
>

> On Fri, Oct 25, 2019 at 11:48:33PM +0000, John Stultz wrote:

> >  struct cma *dma_contiguous_default_area;

> > +EXPORT_SYMBOL(dma_contiguous_default_area);

>

> Please CC the dma maintainer.  And no, you have no business using this.


Sure thing. And I'll look again to see why I was needing to pull that
one in to get it to build.

> Even if you did, internals like this should always be EXPORT_SYMBOL_GPL.


Certainly! My mistake here!

Thanks for the feedback!
-john
Sandeep Patil Oct. 28, 2019, 7:12 p.m. UTC | #3
On Fri, Oct 25, 2019 at 11:48:33PM +0000, John Stultz wrote:
> From: Sandeep Patil <sspatil@google.com>

> 

> Export cma_get_name, cma_alloc, cma_release, cma_for_each_area

> and dma_contiguous_default_area so that we can use these from

> the dmabuf cma heap when it is built as module.

> 

> Cc: Laura Abbott <labbott@redhat.com>

> Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>

> Cc: Sumit Semwal <sumit.semwal@linaro.org>

> Cc: Liam Mark <lmark@codeaurora.org>

> Cc: Pratik Patel <pratikp@codeaurora.org>

> Cc: Brian Starkey <Brian.Starkey@arm.com>

> Cc: Andrew F. Davis <afd@ti.com>

> Cc: Andrew Morton <akpm@linux-foundation.org>

> Cc: Yue Hu <huyue2@yulong.com>

> Cc: Mike Rapoport <rppt@linux.ibm.com>

> Cc: Chenbo Feng <fengc@google.com>

> Cc: Alistair Strachan <astrachan@google.com>

> Cc: Sandeep Patil <sspatil@google.com>

> Cc: Hridya Valsaraju <hridya@google.com>

> Cc: dri-devel@lists.freedesktop.org

> Signed-off-by: Sandeep Patil <sspatil@google.com>

> [jstultz: Rewrote commit message, added

>  dma_contiguous_default_area to the set of exported symbols]

> Signed-off-by: John Stultz <john.stultz@linaro.org>

> ---

>  kernel/dma/contiguous.c | 1 +

>  mm/cma.c                | 5 +++++

>  2 files changed, 6 insertions(+)

> 

> diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c

> index 69cfb4345388..ff6cba63ea6f 100644

> --- a/kernel/dma/contiguous.c

> +++ b/kernel/dma/contiguous.c

> @@ -31,6 +31,7 @@

>  #endif

>  

>  struct cma *dma_contiguous_default_area;

> +EXPORT_SYMBOL(dma_contiguous_default_area);


I didn't need to do this for the (out-of-tree) ion cma heap [1].
Any reason why you had to?

Other than that, thanks for doing this John.

Acked-by: Sandeep Patil <sspatil@google.com>


- ssp

1] https://android-review.googlesource.com/c/kernel/common/+/1121591
diff mbox series

Patch

diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index 69cfb4345388..ff6cba63ea6f 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -31,6 +31,7 @@ 
 #endif
 
 struct cma *dma_contiguous_default_area;
+EXPORT_SYMBOL(dma_contiguous_default_area);
 
 /*
  * Default global CMA area size can be defined in kernel's .config.
diff --git a/mm/cma.c b/mm/cma.c
index 7fe0b8356775..db4642e58058 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -24,6 +24,7 @@ 
 #include <linux/memblock.h>
 #include <linux/err.h>
 #include <linux/mm.h>
+#include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>
@@ -54,6 +55,7 @@  const char *cma_get_name(const struct cma *cma)
 {
 	return cma->name ? cma->name : "(undefined)";
 }
+EXPORT_SYMBOL_GPL(cma_get_name);
 
 static unsigned long cma_bitmap_aligned_mask(const struct cma *cma,
 					     unsigned int align_order)
@@ -500,6 +502,7 @@  struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
 	pr_debug("%s(): returned %p\n", __func__, page);
 	return page;
 }
+EXPORT_SYMBOL_GPL(cma_alloc);
 
 /**
  * cma_release() - release allocated pages
@@ -533,6 +536,7 @@  bool cma_release(struct cma *cma, const struct page *pages, unsigned int count)
 
 	return true;
 }
+EXPORT_SYMBOL_GPL(cma_release);
 
 int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data)
 {
@@ -547,3 +551,4 @@  int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(cma_for_each_area);