[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 04/16] xen/riscv: add ioremap_*() variants using ioremap_attr()
Introduce ioremap_attr() as a shared helper to implement architecture-specific ioremap variants: - ioremap_nocache() - 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> --- Changes in v2: - Update the commit subject + message. - move out Svpbmt changes to separate patch. - Drop #ifdef SVPBMT for ioremap(). - Redefine ioremap_* in io.h. - Introduce ioremap_attr(). --- xen/arch/riscv/include/asm/io.h | 11 +++-------- xen/arch/riscv/mm.c | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/xen/arch/riscv/include/asm/io.h b/xen/arch/riscv/include/asm/io.h index 8bab4ffa03..921e334ce1 100644 --- a/xen/arch/riscv/include/asm/io.h +++ b/xen/arch/riscv/include/asm/io.h @@ -41,14 +41,9 @@ #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_nocache(paddr_t start, size_t len); +void __iomem *ioremap_cache(paddr_t start, size_t len); +void __iomem *ioremap_wc(paddr_t start, 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..c8526dd2ef 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,36 @@ void *__init arch_vmap_virt_end(void) { return (void *)(VMAP_VIRT_START + VMAP_VIRT_SIZE); } + +static void *ioremap_attr(paddr_t start, size_t len, pte_attr_t attributes) +{ + mfn_t mfn = _mfn(PFN_DOWN(start)); + unsigned int offs = start & (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_nocache(paddr_t start, size_t len) +{ + return ioremap_attr(start, len, PAGE_HYPERVISOR_NOCACHE); +} + +void __iomem *ioremap_cache(paddr_t start, size_t len) +{ + return ioremap_attr(start, len, PAGE_HYPERVISOR); +} + +void __iomem *ioremap_wc(paddr_t start, size_t len) +{ + return ioremap_attr(start, len, PAGE_HYPERVISOR_WC); +} + +void *ioremap(paddr_t pa, size_t len) +{ + return ioremap_attr(pa, len, PAGE_HYPERVISOR_NOCACHE); +} -- 2.49.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |