linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: lauraa@codeaurora.org (Laura Abbott)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv2 2/3] arm64: Support DMA_ATTR_WRITE_COMBINE
Date: Fri, 14 Mar 2014 12:52:24 -0700	[thread overview]
Message-ID: <1394826745-24191-2-git-send-email-lauraa@codeaurora.org> (raw)
In-Reply-To: <1394732716-11507-2-git-send-email-lauraa@codeaurora.org>

DMA_ATTR_WRITE_COMBINE is currently ignored. Set the pgprot
appropriately for non coherent opperations.

Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
---
 arch/arm64/mm/dma-mapping.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 0cdd2f6..608c343 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -29,6 +29,17 @@
 struct dma_map_ops *dma_ops;
 EXPORT_SYMBOL(dma_ops);
 
+
+static inline pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot,
+					bool coherent)
+{
+	if (dma_get_attr(DMA_ATTR_WRITE_COMBINE, attrs))
+		return pgprot_writecombine(prot)
+	else if (!coherent)
+		return pgprot_dmacoherent(prot);
+	return prot;
+}
+
 static void *arm64_swiotlb_alloc_coherent(struct device *dev, size_t size,
 					  dma_addr_t *dma_handle, gfp_t flags,
 					  struct dma_attrs *attrs)
@@ -72,7 +83,7 @@ static void *arm64_swiotlb_alloc_noncoherent(struct device *dev, size_t size,
 	for (i = 0; i < (size >> PAGE_SHIFT); i++)
 		map[i] = page + i;
 	coherent_ptr = vmap(map, size >> PAGE_SHIFT, VM_MAP,
-			    pgprot_dmacoherent(pgprot_default));
+			    __get_dma_pgprot(attrs, pgprot_default, false));
 	kfree(map);
 	if (!coherent_ptr)
 		goto no_map;
@@ -223,7 +234,7 @@ static int arm64_swiotlb_mmap_noncoherent(struct device *dev,
 		void *cpu_addr, dma_addr_t dma_addr, size_t size,
 		struct dma_attrs *attrs)
 {
-	vma->vm_page_prot = pgprot_dmacoherent(vma->vm_page_prot);
+	vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot, false);
 	return __dma_common_mmap(dev, vma, cpu_addr, dma_addr, size);
 }
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

  parent reply	other threads:[~2014-03-14 19:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-05 20:46 Query on patch to be upstream ? Ritesh Harjani
2014-03-11 12:15 ` Catalin Marinas
2014-03-11 18:04   ` Laura Abbott
2014-03-11 18:26     ` Catalin Marinas
2014-03-12 18:20       ` Laura Abbott
2014-03-13 17:45         ` [PATCH 1/2] arm64: Implement custom mmap functions for dma mapping Laura Abbott
2014-03-13 17:49           ` Catalin Marinas
2014-03-14  1:53             ` Laura Abbott
2014-03-13 17:45         ` [PATCH 2/2] arm64: Support DMA_ATTR_WRITE_COMBINE Laura Abbott
2014-03-13 17:52           ` Catalin Marinas
2014-03-14  2:02             ` Laura Abbott
2014-03-14 19:52           ` [PATCHv2 1/3] arm64: Implement custom mmap functions for dma mapping Laura Abbott
2014-03-24 10:33             ` Catalin Marinas
     [not found]             ` <CALk7dXr3cZSkQ6dTUyCjUDStOd6=ghGN9-iO5RQiTfHCciGxLg@mail.gmail.com>
2014-03-28 10:37               ` Catalin Marinas
2014-03-14 19:52           ` Laura Abbott [this message]
2014-03-14 20:24             ` [PATCHv2 2/3] arm64: Support DMA_ATTR_WRITE_COMBINE Rob Herring
2014-03-14 23:07               ` Catalin Marinas
2014-03-14 19:52           ` [PATCHv2 3/3] arm64: Use arm64 coherent APIs for non-coherent freeing Laura Abbott

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=1394826745-24191-2-git-send-email-lauraa@codeaurora.org \
    --to=lauraa@codeaurora.org \
    --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).