From: Rabin Vincent <rabin.vincent@axis.com>
To: linux@arm.linux.org.uk
Cc: mina86@mina86.com, akpm@linux-foundation.org,
linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Rabin Vincent <rabinv@axis.com>
Subject: [PATCH 1/2] mm: cma: split out in_cma check to separate function
Date: Fri, 19 Feb 2016 09:12:03 +0100 [thread overview]
Message-ID: <1455869524-13874-1-git-send-email-rabin.vincent@axis.com> (raw)
Split out the logic in cma_release() which checks if the page is in the
contiguous area to a new function which can be called separately. ARM
will use this.
Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
---
include/linux/cma.h | 12 ++++++++++++
mm/cma.c | 27 +++++++++++++++++++--------
2 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/include/linux/cma.h b/include/linux/cma.h
index 29f9e77..6e7fd2d 100644
--- a/include/linux/cma.h
+++ b/include/linux/cma.h
@@ -27,5 +27,17 @@ extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
unsigned int order_per_bit,
struct cma **res_cma);
extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align);
+
extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count);
+#ifdef CONFIG_CMA
+extern bool in_cma(struct cma *cma, const struct page *pages,
+ unsigned int count);
+#else
+static inline bool in_cma(struct cma *cma, const struct page *pages,
+ unsigned int count)
+{
+ return false;
+}
+#endif
+
#endif
diff --git a/mm/cma.c b/mm/cma.c
index ea506eb..55cda16 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -426,6 +426,23 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align)
return page;
}
+bool in_cma(struct cma *cma, const struct page *pages, unsigned int count)
+{
+ unsigned long pfn;
+
+ if (!cma || !pages)
+ return false;
+
+ pfn = page_to_pfn(pages);
+
+ if (pfn < cma->base_pfn || pfn >= cma->base_pfn + cma->count)
+ return false;
+
+ VM_BUG_ON(pfn + count > cma->base_pfn + cma->count);
+
+ return true;
+}
+
/**
* cma_release() - release allocated pages
* @cma: Contiguous memory region for which the allocation is performed.
@@ -440,18 +457,12 @@ bool cma_release(struct cma *cma, const struct page *pages, unsigned int count)
{
unsigned long pfn;
- if (!cma || !pages)
- return false;
-
pr_debug("%s(page %p)\n", __func__, (void *)pages);
- pfn = page_to_pfn(pages);
-
- if (pfn < cma->base_pfn || pfn >= cma->base_pfn + cma->count)
+ if (!in_cma(cma, pages, count))
return false;
- VM_BUG_ON(pfn + count > cma->base_pfn + cma->count);
-
+ pfn = page_to_pfn(pages);
free_contig_range(pfn, count);
cma_clear_bitmap(cma, pfn, count);
trace_cma_release(pfn, pages, count);
--
2.7.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2016-02-19 8:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-19 8:12 Rabin Vincent [this message]
2016-02-19 8:12 ` [PATCH 2/2] ARM: dma-mapping: fix alloc/free for coherent + CMA + gfp=0 Rabin Vincent
2016-02-19 13:50 ` Michal Nazarewicz
2016-02-23 15:30 ` Rabin Vincent
2016-02-19 14:06 ` Russell King - ARM Linux
2016-02-23 15:23 ` Rabin Vincent
2016-02-19 13:46 ` [PATCH 1/2] mm: cma: split out in_cma check to separate function Michal Nazarewicz
2016-02-19 21:23 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1455869524-13874-1-git-send-email-rabin.vincent@axis.com \
--to=rabin.vincent@axis.com \
--cc=akpm@linux-foundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@arm.linux.org.uk \
--cc=mina86@mina86.com \
--cc=rabinv@axis.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox