linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: lorenx4@gmail.com (Lorenzo Nava)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH v2] arm DMA: Fix allocation from CMA for coherent DMA
Date: Tue, 26 May 2015 20:55:30 +0200	[thread overview]
Message-ID: <1432666530-4210-1-git-send-email-lorenx4@gmail.com> (raw)

This patch allows the use of CMA for DMA coherent memory allocation.
At the moment if "is_coherent" is set to true the allocation can't use the CMA, which I think is not the desired behaviour.

Changes in v2:
 correct __arm_dma_free() according to __dma_alloc() allocation

---
 arch/arm/mm/dma-mapping.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 7e7583d..15643b9 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -645,9 +645,9 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
 	size = PAGE_ALIGN(size);
 	want_vaddr = !dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs);
 
-	if (is_coherent || nommu())
+	if (nommu())
 		addr = __alloc_simple_buffer(dev, size, gfp, &page);
-	else if (!(gfp & __GFP_WAIT))
+	else if (!is_coherent && !(gfp & __GFP_WAIT))
 		addr = __alloc_from_pool(size, &page);
 	else if (!dev_get_cma_area(dev))
 		addr = __alloc_remap_buffer(dev, size, gfp, prot, &page, caller, want_vaddr);
@@ -735,7 +735,7 @@ static void __arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
 
 	size = PAGE_ALIGN(size);
 
-	if (is_coherent || nommu()) {
+	if (nommu()) {
 		__dma_free_buffer(page, size);
 	} else if (__free_from_pool(cpu_addr, size)) {
 		return;
-- 
1.7.10.4

             reply	other threads:[~2015-05-26 18:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-26 18:55 Lorenzo Nava [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-06-03 17:15 [RFC PATCH v2] arm DMA: Fix allocation from CMA for coherent DMA Lorenzo Nava
2015-06-10 11:20 ` Lorenzo Nava
2015-06-10 16:28 ` Catalin Marinas
2015-06-10 19:34   ` Lorenzo Nava
2015-06-11 14:26     ` Catalin Marinas
2015-06-11 21:42       ` Lorenzo Nava
2015-06-12  6:34       ` Lorenzo Nava

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=1432666530-4210-1-git-send-email-lorenx4@gmail.com \
    --to=lorenx4@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).