Module Name: src
Committed By: matt
Date: Tue Dec 6 17:49:35 UTC 2011
Modified Files:
src/sys/arch/mips/mips [matt-nb5-mips64]: cpu_subr.c pmap_tlb.c
Log Message:
Allocate the locks from the same page we allocate the cpu_info and
pmap_tlb_info structure. This assures they will be in KSEG0.
To generate a diff of this commit:
cvs rdiff -u -r1.1.2.21 -r1.1.2.22 src/sys/arch/mips/mips/cpu_subr.c
cvs rdiff -u -r1.1.2.19 -r1.1.2.20 src/sys/arch/mips/mips/pmap_tlb.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/mips/mips/cpu_subr.c
diff -u src/sys/arch/mips/mips/cpu_subr.c:1.1.2.21 src/sys/arch/mips/mips/cpu_subr.c:1.1.2.22
--- src/sys/arch/mips/mips/cpu_subr.c:1.1.2.21 Sat Dec 3 01:56:55 2011
+++ src/sys/arch/mips/mips/cpu_subr.c Tue Dec 6 17:49:34 2011
@@ -133,16 +133,23 @@ cpu_info_alloc(struct pmap_tlb_info *ti,
/*
* If we weren't passed a pmap_tlb_info to use, the caller wants us
- * to take care of that for him. Since we have room left over in the
- * page we just allocated, just use a piece of that for it.
+ * to take care of allocating one for him. Since we have room left
+ * over in the page we just allocated, just use a piece of that for
+ * it and its locks.
*/
if (ti == NULL) {
- if (cpu_info_offset >= sizeof(*ti)) {
+ const size_t ti_size = roundup2(sizeof(*ti), COHERENCY_UNIT)
+ + 2*COHERENCY_UNIT;
+ if (cpu_info_offset >= ti_size) {
ti = (void *) va;
} else {
- KASSERT(PAGE_SIZE - cpu_info_offset + sizeof(*ci) >= sizeof(*ti));
- ti = (struct pmap_tlb_info *)(va + PAGE_SIZE) - 1;
+ KASSERT(PAGE_SIZE - cpu_info_offset + sizeof(*ci) >= ti_size);
+ ti = (struct pmap_tlb_info *)(va + PAGE_SIZE - ti_size);
}
+ ti->ti_lock = (kmutex_t *)
+ roundup2((intptr_t)ti + sizeof(*ti), COHERENCY_UNIT);
+ ti->ti_hwlock = (kmutex_t *)
+ ((intptr_t)ti->ti_lock + COHERENCY_UNIT);
pmap_tlb_info_init(ti);
}
@@ -946,6 +953,7 @@ cpu_hatch(struct cpu_info *ci)
*/
if (ci->ci_tlb_slot >= 0) {
const uint32_t tlb_lo = MIPS3_PG_G|MIPS3_PG_V
+ | MIPS3_PG_CACHED | MIPS3_PG_D
| mips3_paddr_to_tlbpfn((vaddr_t)ci);
tlb_enter(ci->ci_tlb_slot, -PAGE_SIZE, tlb_lo);
Index: src/sys/arch/mips/mips/pmap_tlb.c
diff -u src/sys/arch/mips/mips/pmap_tlb.c:1.1.2.19 src/sys/arch/mips/mips/pmap_tlb.c:1.1.2.20
--- src/sys/arch/mips/mips/pmap_tlb.c:1.1.2.19 Sat Dec 3 01:56:55 2011
+++ src/sys/arch/mips/mips/pmap_tlb.c Tue Dec 6 17:49:34 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap_tlb.c,v 1.1.2.19 2011/12/03 01:56:55 matt Exp $ */
+/* $NetBSD: pmap_tlb.c,v 1.1.2.20 2011/12/06 17:49:34 matt Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_tlb.c,v 1.1.2.19 2011/12/03 01:56:55 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_tlb.c,v 1.1.2.20 2011/12/06 17:49:34 matt Exp $");
/*
* Manages address spaces in a TLB.
@@ -287,8 +287,14 @@ pmap_tlb_info_init(struct pmap_tlb_info
KASSERT(pmap_tlbs[pmap_ntlbs] == NULL);
- ti->ti_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SCHED);
- ti->ti_hwlock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SCHED);
+ if (ti->ti_lock == NULL)
+ ti->ti_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SCHED);
+ else
+ mutex_init(ti->ti_lock, MUTEX_DEFAULT, IPL_SCHED);
+ if (ti->ti_hwlock == NULL)
+ ti->ti_hwlock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SCHED);
+ else
+ mutex_init(ti->ti_hwlock, MUTEX_DEFAULT, IPL_SCHED);
ti->ti_asid_bitmap[0] = 1;
ti->ti_asid_hint = 1;
ti->ti_asid_max = pmap_tlb0_info.ti_asid_max;