|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] xen/riscv: add ioremap_*() variants using ioremap_attr()
commit c8ff4d60a696292038e01a51a60085e5906123bb
Author: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
AuthorDate: Mon Jun 2 12:42:49 2025 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Jun 2 12:42:49 2025 +0200
xen/riscv: add ioremap_*() variants using ioremap_attr()
Introduce ioremap_attr() as a shared helper to implement
architecture-specific
ioremap variants:
- ioremap_cache()
- ioremap_wc()
These functions use __vmap() internally and apply appropriate memory
attributes
for RISC-V.
These functions are implemned not as static inline function or macros as it
will
require to include asm/page.h into asm/io.h what will lead to compilation
issue.
Also, remove the unused ioremap_wt() macro from asm/io.h, as write-through
mappings are not expected to be used on RISC-V.
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
xen/arch/riscv/include/asm/io.h | 10 ++--------
xen/arch/riscv/mm.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/xen/arch/riscv/include/asm/io.h b/xen/arch/riscv/include/asm/io.h
index 8bab4ffa03..9aeafd6b3b 100644
--- a/xen/arch/riscv/include/asm/io.h
+++ b/xen/arch/riscv/include/asm/io.h
@@ -41,14 +41,8 @@
#include <xen/macros.h>
#include <xen/types.h>
-/*
- * The RISC-V ISA doesn't yet specify how to query or modify PMAs, so we can't
- * change the properties of memory regions. This should be fixed by the
- * upcoming platform spec.
- */
-#define ioremap_nocache(addr, size) ioremap(addr, size)
-#define ioremap_wc(addr, size) ioremap(addr, size)
-#define ioremap_wt(addr, size) ioremap(addr, size)
+void __iomem *ioremap_cache(paddr_t pa, size_t len);
+void __iomem *ioremap_wc(paddr_t pa, size_t len);
/* Generic IO read/write. These perform native-endian accesses. */
static inline void __raw_writeb(uint8_t val, volatile void __iomem *addr)
diff --git a/xen/arch/riscv/mm.c b/xen/arch/riscv/mm.c
index d3ece9f132..4047d67c0e 100644
--- a/xen/arch/riscv/mm.c
+++ b/xen/arch/riscv/mm.c
@@ -11,6 +11,7 @@
#include <xen/pfn.h>
#include <xen/sections.h>
#include <xen/sizes.h>
+#include <xen/vmap.h>
#include <asm/early_printk.h>
#include <asm/csr.h>
@@ -583,3 +584,32 @@ void *__init arch_vmap_virt_end(void)
{
return (void *)(VMAP_VIRT_START + VMAP_VIRT_SIZE);
}
+
+static void __iomem *ioremap_attr(paddr_t pa, size_t len,
+ pte_attr_t attributes)
+{
+ mfn_t mfn = _mfn(PFN_DOWN(pa));
+ unsigned int offs = pa & (PAGE_SIZE - 1);
+ unsigned int nr = PFN_UP(offs + len);
+ void *ptr = __vmap(&mfn, nr, 1, 1, attributes, VMAP_DEFAULT);
+
+ if ( ptr == NULL )
+ return NULL;
+
+ return ptr + offs;
+}
+
+void __iomem *ioremap_cache(paddr_t pa, size_t len)
+{
+ return ioremap_attr(pa, len, PAGE_HYPERVISOR);
+}
+
+void __iomem *ioremap_wc(paddr_t pa, size_t len)
+{
+ return ioremap_attr(pa, len, PAGE_HYPERVISOR_WC);
+}
+
+void __iomem *ioremap(paddr_t pa, size_t len)
+{
+ return ioremap_attr(pa, len, PAGE_HYPERVISOR_NOCACHE);
+}
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |