Code to disable BAT use on cpu's that either don't have BAT's, or don't

gain any benefit from them.  This nets a small speedup on the POWER3, and
is probably needed for POWER5, which might not emulate BATs like the 3 does.
Also, thanks to Matt Thomas, who suggested re-using alitrap rather than
writing a new dsinobattrap that would have looked remarkably identical
when finished.
This commit is contained in:
garbled 2008-02-07 03:20:16 +00:00
parent 2ccede0a9c
commit 5532ebb058
3 changed files with 30 additions and 21 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: oea_machdep.c,v 1.42 2008/02/07 01:17:51 matt Exp $ */
/* $NetBSD: oea_machdep.c,v 1.43 2008/02/07 03:20:16 garbled Exp $ */
/*
* Copyright (C) 2002 Matt Thomas
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: oea_machdep.c,v 1.42 2008/02/07 01:17:51 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: oea_machdep.c,v 1.43 2008/02/07 03:20:16 garbled Exp $");
#include "opt_ppcarch.h"
#include "opt_compat_netbsd.h"
@ -78,6 +78,7 @@ __KERNEL_RCSID(0, "$NetBSD: oea_machdep.c,v 1.42 2008/02/07 01:17:51 matt Exp $"
#include <powerpc/oea/bat.h>
#include <powerpc/oea/sr_601.h>
#include <powerpc/oea/cpufeat.h>
#include <powerpc/trap.h>
#include <powerpc/stdarg.h>
#include <powerpc/spr.h>
@ -96,6 +97,7 @@ struct vm_map *phys_map = NULL;
* Global variables used here and there
*/
extern struct user *proc0paddr;
extern unsigned long oeacpufeat;
static void trap0(void *);
@ -206,10 +208,15 @@ oea_init(void (*handler)(void))
size = (size_t)dsi601size;
memcpy((void *)EXC_DSI, dsi601trap, size);
break;
}
} else
#endif /* PPC_OEA601 */
size = (size_t)dsisize;
memcpy((void *)EXC_DSI, dsitrap, size);
if (oeacpufeat & OEACPU_NOBAT) {
size = (size_t)alisize;
memcpy((void *)EXC_DSI, alitrap, size);
} else {
size = (size_t)dsisize;
memcpy((void *)EXC_DSI, dsitrap, size);
}
break;
case EXC_DECR:
size = (size_t)decrsize;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bus_space.c,v 1.16 2008/02/06 03:15:07 garbled Exp $ */
/* $NetBSD: bus_space.c,v 1.17 2008/02/07 03:20:17 garbled Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.16 2008/02/06 03:15:07 garbled Exp $");
__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.17 2008/02/07 03:20:17 garbled Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -57,7 +57,10 @@ __KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.16 2008/02/06 03:15:07 garbled Exp $
#include <powerpc/oea/bat.h>
#include <powerpc/oea/pte.h>
#include <powerpc/oea/sr_601.h>
#include <powerpc/oea/cpufeat.h>
#include <powerpc/spr.h>
extern unsigned long oeacpufeat;
#endif
/* read_N */
@ -564,7 +567,7 @@ memio_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
#endif
pa = t->pbs_offset + bpa;
#if !defined (PPC_OEA64) && !defined(PPC_IBM4XX)
#if defined (PPC_OEA) || defined(PPC_OEA601)
#ifdef PPC_OEA601
if ((mfpvr() >> 16) == MPC601) {
/*
@ -578,7 +581,7 @@ memio_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
}
} else
#endif /* PPC_OEA601 */
{
if ((oeacpufeat & OEACPU_NOBAT) == 0) {
/*
* Let's try to BAT map this address if possible
*/
@ -589,7 +592,7 @@ memio_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
return (0);
}
}
#endif /* !defined (PPC_OEA64) && !defined(PPC_IBM4XX) */
#endif /* defined (PPC_OEA) || defined(PPC_OEA601) */
#ifndef PPC_IBM4XX
if (extent_flags == 0) {
@ -634,7 +637,7 @@ memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
size = _BUS_SPACE_STRIDE(t, size);
#if !defined (PPC_OEA64) && !defined (PPC_IBM4XX)
#if defined (PPC_OEA) || defined(PPC_OEA601)
#ifdef PPC_OEA601
if ((mfpvr() >> 16) == MPC601) {
register_t sr = iosrtable[va >> ADDR_SR_SHFT];
@ -647,7 +650,7 @@ memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
}
} else
#endif /* PPC_OEA601 */
{
if ((oeacpufeat & OEACPU_NOBAT) == 0) {
register_t batu = battable[va >> ADDR_SR_SHFT].batu;
if (BAT_VALID_P(batu, 0) && BAT_VA_MATCH_P(batu, va) &&
BAT_VA_MATCH_P(batu, va + size - 1)) {
@ -656,10 +659,11 @@ memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
} else {
pmap_extract(pmap_kernel(), va, &pa);
}
}
} else
pmap_extract(pmap_kernel(), va, &pa);
#else
pmap_extract(pmap_kernel(), va, &pa);
#endif /* !defined (PPC_OEA64) && !defined (PPC_IBM4XX) */
#endif /* defined (PPC_OEA) || defined(PPC_OEA601) */
bpa = pa - t->pbs_offset;
if (extent_free(t->pbs_extent, bpa, size, EX_NOWAIT | extent_flags)) {
@ -705,7 +709,7 @@ memio_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
*bpap = bpa;
pa = t->pbs_offset + bpa;
#if !defined (PPC_OEA64) && !defined (PPC_IBM4XX)
#if defined (PPC_OEA) || defined(PPC_OEA601)
#ifdef PPC_OEA601
if ((mfpvr() >> 16) == MPC601) {
register_t sr = iosrtable[pa >> ADDR_SR_SHFT];
@ -716,7 +720,7 @@ memio_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
}
} else
#endif /* PPC_OEA601 */
{
if ((oeacpufeat & OEACPU_NOBAT) == 0) {
register_t batu = battable[pa >> ADDR_SR_SHFT].batu;
if (BAT_VALID_P(batu, 0) && BAT_VA_MATCH_P(batu, pa) &&
BAT_VA_MATCH_P(batu, pa + size - 1)) {
@ -724,7 +728,7 @@ memio_alloc(bus_space_tag_t t, bus_addr_t rstart, bus_addr_t rend,
return (0);
}
}
#endif /* !defined (PPC_OEA64) && !defined (PPC_IBM4XX) */
#endif /* defined (PPC_OEA) || defined(PPC_OEA601) */
*bshp = (bus_space_handle_t) mapiodev(pa, size);
if (*bshp == 0) {
extent_free(t->pbs_extent, bpa, size, EX_NOWAIT | extent_flags);

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap_subr.S,v 1.62 2008/02/05 22:31:50 garbled Exp $ */
/* $NetBSD: trap_subr.S,v 1.63 2008/02/07 03:20:17 garbled Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -178,6 +178,7 @@ _C_LABEL(trapsize) = .-_C_LABEL(trapcode)
/*
* For ALI: has to save DSISR and DAR
* Also used as dsitrap for BATless cpus.
*/
/* LINTSTUB: Var: int alicode[1], alisize[1]; */
.globl _C_LABEL(alitrap),_C_LABEL(alisize)
@ -222,7 +223,6 @@ _C_LABEL(dsitrap):
mfsrr1 %r31 /* test kernel mode */
mtcr %r31
bt 17,1f /* branch if PSL_PR is set */
#if !defined(PPC_OEA64)
mfdar %r31 /* get fault address */
rlwinm %r31,%r31,7,25,28 /* get segment * 8 */
@ -245,8 +245,6 @@ _C_LABEL(dsitrap):
mtdbatu 3,%r30
mtdbatl 3,%r31
3:
#endif /* !PPC_OEA64 */
mfsprg2 %r30 /* restore XER */
mtxer %r30
mtcr %r29 /* restore CR */