Date: Tue, 23 May 2017 12:04:00 +0000 (UTC) From: Michal Meloun <mmel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r318742 - in stable/11/sys/arm: arm include Message-ID: <201705231204.v4NC40Ll092888@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mmel Date: Tue May 23 12:03:59 2017 New Revision: 318742 URL: https://svnweb.freebsd.org/changeset/base/318742 Log: MFC r318021,r318251: r318021: Introduce pmap_remap_vm_attr(), it allows to remap one VM memattr class to another. r318251: Clarify usage rules for pmap_remap_vm_attr(). Not a functional change. Modified: stable/11/sys/arm/arm/pmap-v6.c stable/11/sys/arm/include/pmap-v6.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/arm/pmap-v6.c ============================================================================== --- stable/11/sys/arm/arm/pmap-v6.c Tue May 23 12:00:08 2017 (r318741) +++ stable/11/sys/arm/arm/pmap-v6.c Tue May 23 12:03:59 2017 (r318742) @@ -497,6 +497,42 @@ pmap_set_tex(void) } /* + * Remap one vm_meattr class to another one. This can be useful as + * workaround for SOC errata, e.g. if devices must be accessed using + * SO memory class. + * + * !!! Please note that this function is absolutely last resort thing. + * It should not be used under normal circumstances. !!! + * + * Usage rules: + * - it shall be called after pmap_bootstrap_prepare() and before + * cpu_mp_start() (thus only on boot CPU). In practice, it's expected + * to be called from platform_attach() or platform_late_init(). + * + * - if remapping doesn't change caching mode, or until uncached class + * is remapped to any kind of cached one, then no other restriction exists. + * + * - if pmap_remap_vm_attr() changes caching mode, but both (original and + * remapped) remain cached, then caller is resposible for calling + * of dcache_wbinv_poc_all(). + * + * - remapping of any kind of cached class to uncached is not permitted. + */ +void +pmap_remap_vm_attr(vm_memattr_t old_attr, vm_memattr_t new_attr) +{ + int old_idx, new_idx; + + /* Map VM memattrs to indexes to tex_class table. */ + old_idx = pte2_attr_tab[(int)old_attr]; + new_idx = pte2_attr_tab[(int)new_attr]; + + /* Replace TEX attribute and apply it. */ + tex_class[old_idx] = tex_class[new_idx]; + pmap_set_tex(); +} + +/* * KERNBASE must be multiple of NPT2_IN_PG * PTE1_SIZE. In other words, * KERNBASE is mapped by first L2 page table in L2 page table page. It * meets same constrain due to PT2MAP being placed just under KERNBASE. Modified: stable/11/sys/arm/include/pmap-v6.h ============================================================================== --- stable/11/sys/arm/include/pmap-v6.h Tue May 23 12:00:08 2017 (r318741) +++ stable/11/sys/arm/include/pmap-v6.h Tue May 23 12:03:59 2017 (r318742) @@ -189,6 +189,7 @@ vm_offset_t pmap_preboot_reserve_pages(u vm_offset_t pmap_preboot_get_vpages(u_int); void pmap_preboot_map_attr(vm_paddr_t, vm_offset_t, vm_size_t, vm_prot_t, vm_memattr_t); +void pmap_remap_vm_attr(vm_memattr_t old_attr, vm_memattr_t new_attr); #endif /* _KERNEL */ #endif /* !_MACHINE_PMAP_V6_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705231204.v4NC40Ll092888>