Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/mips/mips We use the common uvm pmap now.
details: https://anonhg.NetBSD.org/src/rev/28f361d193f2
branches: trunk
changeset: 346410:28f361d193f2
user: matt <matt%NetBSD.org@localhost>
date: Tue Jul 12 06:03:11 2016 +0000
description:
We use the common uvm pmap now.
diffstat:
sys/arch/mips/mips/pmap_segtab.c | 490 -----------------
sys/arch/mips/mips/pmap_tlb.c | 1052 --------------------------------------
2 files changed, 0 insertions(+), 1542 deletions(-)
diffs (truncated from 1550 to 300 lines):
diff -r ab83a73066d4 -r 28f361d193f2 sys/arch/mips/mips/pmap_segtab.c
--- a/sys/arch/mips/mips/pmap_segtab.c Tue Jul 12 03:49:32 2016 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,490 +0,0 @@
-/* $NetBSD: pmap_segtab.c,v 1.10 2015/06/11 15:50:17 matt Exp $ */
-
-/*-
- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center and by Chris G. Demetriou.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * the Systems Programming Group of the University of Utah Computer
- * Science Department and Ralph Campbell.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)pmap.c 8.4 (Berkeley) 1/26/94
- */
-
-#include <sys/cdefs.h>
-
-__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.10 2015/06/11 15:50:17 matt Exp $");
-
-/*
- * Manages physical address maps.
- *
- * In addition to hardware address maps, this
- * module is called upon to provide software-use-only
- * maps which may or may not be stored in the same
- * form as hardware maps. These pseudo-maps are
- * used to store intermediate results from copy
- * operations to and from address spaces.
- *
- * Since the information managed by this module is
- * also stored by the logical address mapping module,
- * this module may throw away valid virtual-to-physical
- * mappings at almost any time. However, invalidations
- * of virtual-to-physical mappings must be done as
- * requested.
- *
- * In order to cope with hardware architectures which
- * make virtual-to-physical map invalidates expensive,
- * this module may delay invalidate or reduced protection
- * operations until such time as they are actually
- * necessary. This module is given full information as
- * to which processors are currently using which maps,
- * and to when physical maps must be made correct.
- */
-
-#define __PMAP_PRIVATE
-
-#include "opt_multiprocessor.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/mutex.h>
-#include <sys/atomic.h>
-
-#include <uvm/uvm.h>
-
-#include <mips/pte.h>
-
-CTASSERT(NBPG >= sizeof(pmap_segtab_t));
-
-struct pmap_segtab_info {
- pmap_segtab_t *free_segtab; /* free list kept locally */
-#ifdef DEBUG
- uint32_t nget_segtab;
- uint32_t nput_segtab;
- uint32_t npage_segtab;
-#define SEGTAB_ADD(n, v) (pmap_segtab_info.n ## _segtab += (v))
-#else
-#define SEGTAB_ADD(n, v) ((void) 0)
-#endif
-#ifdef PMAP_PTP_CACHE
- struct pgflist ptp_pgflist; /* Keep a list of idle page tables. */
-#endif
-} pmap_segtab_info = {
-#ifdef PMAP_PTP_CACHE
- .ptp_pgflist = LIST_HEAD_INITIALIZER(pmap_segtab_info.ptp_pgflist),
-#endif
-};
-
-kmutex_t pmap_segtab_lock __cacheline_aligned;
-
-static inline struct vm_page *
-pmap_pte_pagealloc(void)
-{
- struct vm_page *pg;
-
- pg = PMAP_ALLOC_POOLPAGE(UVM_PGA_ZERO|UVM_PGA_USERESERVE);
- if (pg) {
-#ifdef UVM_PAGE_TRKOWN
- pg->owner_tag = NULL;
-#endif
- UVM_PAGE_OWN(pg, "pmap-ptp");
- }
-
- return pg;
-}
-
-static inline pt_entry_t *
-pmap_segmap(struct pmap *pmap, vaddr_t va)
-{
- pmap_segtab_t *stp = pmap->pm_segtab;
- KASSERT(pmap != pmap_kernel() || !pmap_md_direct_mapped_vaddr_p(va));
-#ifdef _LP64
- stp = stp->seg_seg[(va >> XSEGSHIFT) & (NSEGPG - 1)];
- if (stp == NULL)
- return NULL;
-#endif
-
- return stp->seg_tab[(va >> SEGSHIFT) & (PMAP_SEGTABSIZE - 1)];
-}
-
-pt_entry_t *
-pmap_pte_lookup(pmap_t pmap, vaddr_t va)
-{
- pt_entry_t *pte = pmap_segmap(pmap, va);
- if (pte == NULL)
- return NULL;
-
- return pte + ((va >> PGSHIFT) & (NPTEPG - 1));
-}
-
-static void
-pmap_segtab_free(pmap_segtab_t *stp)
-{
- /*
- * Insert the the segtab into the segtab freelist.
- */
- mutex_spin_enter(&pmap_segtab_lock);
- stp->seg_seg[0] = pmap_segtab_info.free_segtab;
- pmap_segtab_info.free_segtab = stp;
- SEGTAB_ADD(nput, 1);
- mutex_spin_exit(&pmap_segtab_lock);
-}
-
-static void
-pmap_segtab_release(pmap_t pmap, pmap_segtab_t **stp_p, bool free_stp,
- pte_callback_t callback, uintptr_t flags,
- vaddr_t va, vsize_t vinc)
-{
- pmap_segtab_t *stp = *stp_p;
-
- for (size_t i = va / vinc; i < PMAP_SEGTABSIZE; i++, va += vinc) {
-#ifdef _LP64
- if (vinc > NBSEG) {
- if (stp->seg_seg[i] != NULL) {
- pmap_segtab_release(pmap, &stp->seg_seg[i],
- true, callback, flags, va, vinc / NSEGPG);
- KASSERT(stp->seg_seg[i] == NULL);
- }
- continue;
- }
-#endif
- KASSERT(vinc == NBSEG);
-
- /* get pointer to segment map */
- pt_entry_t *pte = stp->seg_tab[i];
- if (pte == NULL)
- continue;
-
- /*
- * If our caller want a callback, do so.
- */
- if (callback != NULL) {
- (*callback)(pmap, va, va + vinc, pte, flags);
- }
-#ifdef DEBUG
- for (size_t j = 0; j < NPTEPG; j++) {
- if (!pte_zero_p(pte[j]))
- panic("%s: pte entry %p not 0 (%#"PRIxPTE")",
- __func__, &pte[j], pte_value(pte[j]));
- }
-#endif
- // PMAP_UNMAP_POOLPAGE should handle any VCA issues itself
- paddr_t pa = PMAP_UNMAP_POOLPAGE((vaddr_t)pte);
- struct vm_page *pg = PHYS_TO_VM_PAGE(pa);
-#ifdef PMAP_PTP_CACHE
- mutex_spin_enter(&pmap_segtab_lock);
- LIST_INSERT_HEAD(&pmap_segtab_info.ptp_pgflist, pg, listq.list);
- mutex_spin_exit(&pmap_segtab_lock);
-#else
- uvm_pagefree(pg);
-#endif
-
- stp->seg_tab[i] = NULL;
- }
-
- if (free_stp) {
- pmap_segtab_free(stp);
- *stp_p = NULL;
- }
-}
-
-/*
- * Create and return a physical map.
- *
- * If the size specified for the map
- * is zero, the map is an actual physical
- * map, and may be referenced by the
- * hardware.
- *
- * If the size specified is non-zero,
- * the map will be used in software only, and
- * is bounded by that size.
- */
-static pmap_segtab_t *
-pmap_segtab_alloc(void)
-{
- pmap_segtab_t *stp;
-
- again:
- mutex_spin_enter(&pmap_segtab_lock);
- if (__predict_true((stp = pmap_segtab_info.free_segtab) != NULL)) {
- pmap_segtab_info.free_segtab = stp->seg_seg[0];
- stp->seg_seg[0] = NULL;
- SEGTAB_ADD(nget, 1);
- }
- mutex_spin_exit(&pmap_segtab_lock);
-
- if (__predict_false(stp == NULL)) {
- struct vm_page * const stp_pg = pmap_pte_pagealloc();
-
- if (__predict_false(stp_pg == NULL)) {
- /*
- * XXX What else can we do? Could we deadlock here?
- */
- uvm_wait("pmap_create");
- goto again;
- }
- SEGTAB_ADD(npage, 1);
- const paddr_t stp_pa = VM_PAGE_TO_PHYS(stp_pg);
-
- stp = (pmap_segtab_t *)PMAP_MAP_POOLPAGE(stp_pa);
- const size_t n = NBPG / sizeof(*stp);
- if (n > 1) {
- /*
- * link all the segtabs in this page together
- */
- for (size_t i = 1; i < n - 1; i++) {
- stp[i].seg_seg[0] = &stp[i+1];
- }
- /*
- * Now link the new segtabs into the free segtab list.
- */
Home |
Main Index |
Thread Index |
Old Index