mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "open list:BAREBOX" <barebox@lists.infradead.org>
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2 13/15] ARM: ARM64: implement dma_alloc_writecombine()
Date: Fri, 27 Sep 2024 12:37:46 +0200	[thread overview]
Message-ID: <20240927-vop2-v2-13-dc8dcfc651d5@pengutronix.de> (raw)
In-Reply-To: <20240927-vop2-v2-0-dc8dcfc651d5@pengutronix.de>

We currently only have dma_alloc_writecombine() for aarch32. Implement
it for aarch64 as it is useful for mapping framebuffer memory.

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/cpu/mmu_64.c | 11 ++++++++++-
 arch/arm/cpu/mmu_64.h | 15 ++++++---------
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/arch/arm/cpu/mmu_64.c b/arch/arm/cpu/mmu_64.c
index 7c7834201b..7854f71f4c 100644
--- a/arch/arm/cpu/mmu_64.c
+++ b/arch/arm/cpu/mmu_64.c
@@ -24,6 +24,8 @@
 
 #include "mmu_64.h"
 
+#define ARCH_MAP_WRITECOMBINE  ((unsigned)-1)
+
 static uint64_t *get_ttb(void)
 {
 	return (uint64_t *)get_ttbr(current_el());
@@ -172,9 +174,11 @@ static unsigned long get_pte_attrs(unsigned flags)
 	case MAP_CACHED:
 		return CACHED_MEM;
 	case MAP_UNCACHED:
-		return attrs_uncached_mem();
+		return attrs_xn() | UNCACHED_MEM;
 	case MAP_FAULT:
 		return 0x0;
+	case ARCH_MAP_WRITECOMBINE:
+		return attrs_xn() | MEM_ALLOC_WRITECOMBINE;
 	default:
 		return ~0UL;
 	}
@@ -295,6 +299,11 @@ void dma_flush_range(void *ptr, size_t size)
 	v8_flush_dcache_range(start, end);
 }
 
+void *dma_alloc_writecombine(size_t size, dma_addr_t *dma_handle)
+{
+	return dma_alloc_map(size, dma_handle, ARCH_MAP_WRITECOMBINE);
+}
+
 static void init_range(size_t total_level0_tables)
 {
 	uint64_t *ttb = get_ttb();
diff --git a/arch/arm/cpu/mmu_64.h b/arch/arm/cpu/mmu_64.h
index e3959e4407..d3c39dabb5 100644
--- a/arch/arm/cpu/mmu_64.h
+++ b/arch/arm/cpu/mmu_64.h
@@ -8,22 +8,19 @@
 #define UNCACHED_MEM    (PTE_BLOCK_MEMTYPE(MT_DEVICE_nGnRnE) | \
 			 PTE_BLOCK_OUTER_SHARE | \
 			 PTE_BLOCK_AF)
+#define MEM_ALLOC_WRITECOMBINE	(PTE_BLOCK_MEMTYPE(MT_NORMAL_NC) | \
+				 PTE_BLOCK_OUTER_SHARE | \
+				 PTE_BLOCK_AF)
 
-static inline unsigned long attrs_uncached_mem(void)
+static inline unsigned long attrs_xn(void)
 {
-	unsigned long attrs = UNCACHED_MEM;
-
 	switch (current_el()) {
 	case 3:
 	case 2:
-		attrs |= PTE_BLOCK_UXN;
-		break;
+		return PTE_BLOCK_UXN;
 	default:
-		attrs |= PTE_BLOCK_UXN | PTE_BLOCK_PXN;
-		break;
+		return PTE_BLOCK_UXN | PTE_BLOCK_PXN;
 	}
-
-	return attrs;
 }
 
 /*

-- 
2.39.5




  parent reply	other threads:[~2024-09-27 10:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-27 10:37 [PATCH v2 00/15] video: Add Rockchip VOP2 support Sascha Hauer
2024-09-27 10:37 ` [PATCH v2 01/15] clk: rockchip: rk3568: Fix HDMI clocks Sascha Hauer
2024-09-27 10:37 ` [PATCH v2 02/15] video: add videomode helpers Sascha Hauer
2024-09-27 10:37 ` [PATCH v2 03/15] media-bus-format: update from kernel Sascha Hauer
2024-09-27 10:37 ` [PATCH v2 04/15] regmap: add regfield support Sascha Hauer
2024-09-27 10:37 ` [PATCH v2 05/15] video: add include/video/drm/drm_connector.h Sascha Hauer
2024-09-27 10:37 ` [PATCH v2 06/15] fb: add fb_rect functions Sascha Hauer
2024-09-27 10:37 ` [PATCH v2 07/15] video: Add Sitronix st7789v panel driver Sascha Hauer
2024-09-27 10:37 ` [PATCH v2 08/15] video: add dw-hdmi driver Sascha Hauer
2024-09-27 10:37 ` [PATCH v2 09/15] video: i.MX ipuv3: switch to upstream hdmi driver Sascha Hauer
2024-09-27 10:37 ` [PATCH v2 10/15] fb: Accept overlay framebuffers without modes Sascha Hauer
2024-09-27 10:37 ` [PATCH v2 11/15] fb: print more information on devinfo Sascha Hauer
2024-09-27 10:37 ` [PATCH v2 12/15] fbconsole: Adjust fbconsole names for overlays Sascha Hauer
2024-09-27 10:37 ` Sascha Hauer [this message]
2024-09-27 10:37 ` [PATCH v2 14/15] vpl: make vpl deep probe aware Sascha Hauer
2024-09-27 10:37 ` [PATCH v2 15/15] video: Rockchip: Add VOP2 driver Sascha Hauer
2024-09-30  6:35   ` Ahmad Fatoum
2024-10-01  6:35     ` Sascha Hauer
2024-10-01  6:32 ` [PATCH v2 00/15] video: Add Rockchip VOP2 support 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=20240927-vop2-v2-13-dc8dcfc651d5@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=a.fatoum@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