Date: Fri, 2 May 2025 15:45:05 GMT From: Andrew Turner <andrew@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: a5d9ecfa8e99 - main - subr_devmap: Reduce the use of the static devmap Message-ID: <202505021545.542Fj59a097653@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=a5d9ecfa8e99961c4282fecc8315dbd12a8a11b3 commit a5d9ecfa8e99961c4282fecc8315dbd12a8a11b3 Author: Andrew Turner <andrew@FreeBSD.org> AuthorDate: 2025-05-02 15:34:35 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2025-05-02 15:39:04 +0000 subr_devmap: Reduce the use of the static devmap We only create the static devmap on arm. Stop building this code on other architectures. Reviewed by: mhorne, imp Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D50016 --- sys/arm/include/param.h | 2 ++ sys/arm64/arm64/machdep.c | 3 --- sys/kern/subr_devmap.c | 21 +++++++++++++-------- sys/riscv/riscv/machdep.c | 6 ------ sys/sys/devmap.h | 2 ++ 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/sys/arm/include/param.h b/sys/arm/include/param.h index 14cd32631a5f..67f49ec14a99 100644 --- a/sys/arm/include/param.h +++ b/sys/arm/include/param.h @@ -68,6 +68,8 @@ #define MAXMEMDOM 1 #endif +#define __HAVE_STATIC_DEVMAP + #define ALIGNBYTES _ALIGNBYTES #define ALIGN(p) _ALIGN(p) /* diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index 9c7d7892aa10..7cacc77173a4 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -38,7 +38,6 @@ #include <sys/cons.h> #include <sys/cpu.h> #include <sys/csan.h> -#include <sys/devmap.h> #include <sys/efi.h> #include <sys/efi_map.h> #include <sys/exec.h> @@ -852,8 +851,6 @@ initarm(struct arm64_bootparams *abp) physmem_init_kernel_globals(); - devmap_bootstrap(); - valid = bus_probe(); cninit(); diff --git a/sys/kern/subr_devmap.c b/sys/kern/subr_devmap.c index 79f3c75269ca..609c9b142312 100644 --- a/sys/kern/subr_devmap.c +++ b/sys/kern/subr_devmap.c @@ -41,6 +41,7 @@ #include <machine/pte.h> #endif +#ifdef __HAVE_STATIC_DEVMAP #define DEVMAP_PADDR_NOTFOUND ((vm_paddr_t)(-1)) static const struct devmap_entry *devmap_table; @@ -55,12 +56,14 @@ static boolean_t devmap_bootstrap_done = false; #define AKVA_DEVMAP_MAX_ENTRIES 32 static struct devmap_entry akva_devmap_entries[AKVA_DEVMAP_MAX_ENTRIES]; static u_int akva_devmap_idx; +#endif static vm_offset_t akva_devmap_vaddr = DEVMAP_MAX_VADDR; #if defined(__aarch64__) || defined(__riscv) extern int early_boot; #endif +#ifdef __HAVE_STATIC_DEVMAP /* * Print the contents of the static mapping table using the provided printf-like * output function (which will be either printf or db_printf). @@ -139,7 +142,6 @@ devmap_add_entry(vm_paddr_t pa, vm_size_t sz) devmap_register_table(akva_devmap_entries); /* Allocate virtual address space from the top of kva downwards. */ -#ifdef __arm__ /* * If the range being mapped is aligned and sized to 1MB boundaries then * also align the virtual address to the next-lower 1MB boundary so that @@ -147,9 +149,7 @@ devmap_add_entry(vm_paddr_t pa, vm_size_t sz) */ if ((pa & L1_S_OFFSET) == 0 && (sz & L1_S_OFFSET) == 0) { akva_devmap_vaddr = trunc_1mpage(akva_devmap_vaddr - sz); - } else -#endif - { + } else { akva_devmap_vaddr = trunc_page(akva_devmap_vaddr - sz); } m = &akva_devmap_entries[akva_devmap_idx++]; @@ -187,12 +187,8 @@ devmap_bootstrap(void) return; for (pd = devmap_table; pd->pd_size != 0; ++pd) { -#if defined(__arm__) pmap_preboot_map_attr(pd->pd_pa, pd->pd_va, pd->pd_size, VM_PROT_READ | VM_PROT_WRITE, VM_MEMATTR_DEVICE); -#elif defined(__aarch64__) || defined(__riscv) - pmap_kenter_device(pd->pd_va, pd->pd_size, pd->pd_pa); -#endif } } @@ -237,6 +233,7 @@ devmap_vtop(void * vpva, vm_size_t size) return (DEVMAP_PADDR_NOTFOUND); } +#endif /* * Map a set of physical memory pages into the kernel virtual address space. @@ -253,11 +250,13 @@ void * pmap_mapdev(vm_paddr_t pa, vm_size_t size) { vm_offset_t va, offset; +#ifdef __HAVE_STATIC_DEVMAP void * rva; /* First look in the static mapping table. */ if ((rva = devmap_ptov(pa, size)) != NULL) return (rva); +#endif offset = pa & PAGE_MASK; pa = trunc_page(pa); @@ -292,11 +291,13 @@ void * pmap_mapdev_attr(vm_paddr_t pa, vm_size_t size, vm_memattr_t ma) { vm_offset_t va, offset; +#ifdef __HAVE_STATIC_DEVMAP void * rva; /* First look in the static mapping table. */ if ((rva = devmap_ptov(pa, size)) != NULL) return (rva); +#endif offset = pa & PAGE_MASK; pa = trunc_page(pa); @@ -333,9 +334,11 @@ pmap_unmapdev(void *p, vm_size_t size) { vm_offset_t offset, va; +#ifdef __HAVE_STATIC_DEVMAP /* Nothing to do if we find the mapping in the static table. */ if (devmap_vtop(p, size) != DEVMAP_PADDR_NOTFOUND) return; +#endif va = (vm_offset_t)p; offset = va & PAGE_MASK; @@ -347,6 +350,7 @@ pmap_unmapdev(void *p, vm_size_t size) } #ifdef DDB +#ifdef __HAVE_STATIC_DEVMAP #include <ddb/ddb.h> DB_SHOW_COMMAND_FLAGS(devmap, db_show_devmap, DB_CMD_MEMSAFE) @@ -354,4 +358,5 @@ DB_SHOW_COMMAND_FLAGS(devmap, db_show_devmap, DB_CMD_MEMSAFE) devmap_dump_table(db_printf); } +#endif #endif /* DDB */ diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c index f253bc9a853b..235cc651b87e 100644 --- a/sys/riscv/riscv/machdep.c +++ b/sys/riscv/riscv/machdep.c @@ -44,7 +44,6 @@ #include <sys/bus.h> #include <sys/cons.h> #include <sys/cpu.h> -#include <sys/devmap.h> #include <sys/efi_map.h> #include <sys/exec.h> #include <sys/imgact.h> @@ -157,8 +156,6 @@ cpu_startup(void *dummy) printf("avail memory = %ju (%ju MB)\n", ptoa((uintmax_t)vm_free_count()), ptoa((uintmax_t)vm_free_count()) / (1024 * 1024)); - if (bootverbose) - devmap_print_table(); bufinit(); vm_pager_bufferinit(); @@ -636,9 +633,6 @@ initriscv(struct riscv_bootparams *rvbp) physmem_init_kernel_globals(); - /* Establish static device mappings */ - devmap_bootstrap(); - cninit(); /* diff --git a/sys/sys/devmap.h b/sys/sys/devmap.h index 69e696a20fc9..4e74c2212059 100644 --- a/sys/sys/devmap.h +++ b/sys/sys/devmap.h @@ -33,6 +33,7 @@ #error "no user-serviceable parts inside" #endif +#ifdef __HAVE_STATIC_DEVMAP /* * This structure is used by MD code to describe static mappings of devices * which are established as part of bringing up the MMU early in the boot. @@ -78,5 +79,6 @@ void devmap_bootstrap(void); /* Print the static mapping table; used for bootverbose output. */ void devmap_print_table(void); +#endif #endif /* !_SYS_DEVMAP_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202505021545.542Fj59a097653>