mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 3/4] ARM: implement dma_alloc_writecombine
Date: Fri,  7 Aug 2015 15:40:08 +0200	[thread overview]
Message-ID: <1438954809-5962-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1438954809-5962-1-git-send-email-s.hauer@pengutronix.de>

Writecombined memory is nice for video framebuffers, so implement it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/cpu/mmu.c | 20 ++++++++++++++++++++
 include/dma.h      |  1 +
 2 files changed, 21 insertions(+)

diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 37bfa05..2d00fa7 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -66,6 +66,7 @@ static inline void tlb_invalidate(void)
 }
 
 #define PTE_FLAGS_CACHED_V7 (PTE_EXT_TEX(1) | PTE_BUFFERABLE | PTE_CACHEABLE)
+#define PTE_FLAGS_WC_V7 PTE_EXT_TEX(1)
 #define PTE_FLAGS_UNCACHED_V7 (0)
 #define PTE_FLAGS_CACHED_V4 (PTE_SMALL_AP_UNO_SRW | PTE_BUFFERABLE | PTE_CACHEABLE)
 #define PTE_FLAGS_UNCACHED_V4 PTE_SMALL_AP_UNO_SRW
@@ -75,6 +76,7 @@ static inline void tlb_invalidate(void)
  * This will be determined at runtime.
  */
 static uint32_t pte_flags_cached;
+static uint32_t pte_flags_wc;
 static uint32_t pte_flags_uncached;
 
 #define PTE_MASK ((1 << 12) - 1)
@@ -325,9 +327,11 @@ static int mmu_init(void)
 
 	if (cpu_architecture() >= CPU_ARCH_ARMv7) {
 		pte_flags_cached = PTE_FLAGS_CACHED_V7;
+		pte_flags_wc = PTE_FLAGS_WC_V7;
 		pte_flags_uncached = PTE_FLAGS_UNCACHED_V7;
 	} else {
 		pte_flags_cached = PTE_FLAGS_CACHED_V4;
+		pte_flags_wc = PTE_FLAGS_UNCACHED_V4;
 		pte_flags_uncached = PTE_FLAGS_UNCACHED_V4;
 	}
 
@@ -408,6 +412,22 @@ void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
 	return ret;
 }
 
+void *dma_alloc_writecombine(size_t size, dma_addr_t *dma_handle)
+{
+	void *ret;
+
+	size = PAGE_ALIGN(size);
+	ret = xmemalign(PAGE_SIZE, size);
+	if (dma_handle)
+		*dma_handle = (dma_addr_t)ret;
+
+	dma_inv_range((unsigned long)ret, (unsigned long)ret + size);
+
+	remap_range(ret, size, pte_flags_wc);
+
+	return ret;
+}
+
 unsigned long virt_to_phys(volatile void *virt)
 {
 	return (unsigned long)virt;
diff --git a/include/dma.h b/include/dma.h
index 800d8b1..4d31797 100644
--- a/include/dma.h
+++ b/include/dma.h
@@ -39,5 +39,6 @@ void dma_sync_single_for_device(unsigned long address, size_t size,
 
 void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle);
 void dma_free_coherent(void *mem, dma_addr_t dma_handle, size_t size);
+void *dma_alloc_writecombine(size_t size, dma_addr_t *dma_handle);
 
 #endif /* __DMA_H */
-- 
2.4.6


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-08-07 13:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-07 13:40 video: update imx-ipu-v3 and hdmi support Sascha Hauer
2015-08-07 13:40 ` [PATCH 1/4] video: imx-hdmi: sync with kernel Sascha Hauer
2015-08-07 13:40 ` [PATCH 2/4] video: ipuv3: Adjust videomode to IPU limitations Sascha Hauer
2015-08-07 13:40 ` Sascha Hauer [this message]
2015-08-07 13:40 ` [PATCH 4/4] video: imx-ipu-v3: Use writecombine memory for fb Sascha Hauer

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=1438954809-5962-4-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@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