convert dcache_flush_page() into a function pointer. introduce a

sp_dcache_flush_page() to help the smp version.

XXX: probably best to have usI/II and usIII (and nop) of this and
XXX: avoid the need for sp_dcache_flush_page at all.
This commit is contained in:
mrg 2011-06-06 02:49:39 +00:00
parent fd360a0fec
commit 4138bf2744
3 changed files with 19 additions and 37 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cache.c,v 1.7 2011/06/06 01:16:48 mrg Exp $ */
/* $NetBSD: cache.c,v 1.8 2011/06/06 02:49:39 mrg Exp $ */
/*
* Copyright (c) 2011 Matthew R. Green
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cache.c,v 1.7 2011/06/06 01:16:48 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: cache.c,v 1.8 2011/06/06 02:49:39 mrg Exp $");
#include "opt_multiprocessor.h"
@ -58,7 +58,6 @@ blast_dcache_real(void)
sp_blast_dcache(dcache_size, dcache_line_size);
}
#if 0
static void
sp_dcache_flush_page_cpuset(paddr_t pa, sparc64_cpuset_t cs)
{
@ -69,35 +68,37 @@ sp_dcache_flush_page_cpuset(paddr_t pa, sparc64_cpuset_t cs)
void (*dcache_flush_page)(paddr_t) = dcache_flush_page_us;
void (*dcache_flush_page_cpuset)(paddr_t, sparc64_cpuset_t) =
sp_dcache_flush_page_cpuset;
#endif
void (*blast_dcache)(void) = blast_dcache_real;
void (*blast_icache)(void) = blast_icache_us;
#ifdef MULTIPROCESSOR
void (*sp_dcache_flush_page)(paddr_t) = dcache_flush_page_us;
#endif
void
cache_setup_funcs(void)
{
if (CPU_ISSUN4US || CPU_ISSUN4V) {
#if 0
dcache_flush_page = (void (*)(paddr_t)) cache_nop;
#ifdef MULTIPROCESSOR
/* XXXMRG shouldn't be necessary -- only caller is nop'ed out */
sp_dcache_flush_page = (void (*)(paddr_t)) cache_nop;
#endif
blast_dcache = cache_nop;
blast_icache = cache_nop;
} else {
if (CPU_IS_USIII_UP()) {
#if 0
dcache_flush_page = dcache_flush_page_usiii;
#ifdef MULTIPROCESSOR
sp_dcache_flush_page = dcache_flush_page_usiii;
#endif
blast_icache = blast_icache_usiii;
printf("set usIII dcache/icache funcs\n");
}
#ifdef MULTIPROCESSOR
if (sparc_ncpus > 1 && (boothowto & RB_MD1) == 0) {
printf("set MP dcache funcs\n");
#if 0
dcache_flush_page = smp_dcache_flush_page_allcpu;
dcache_flush_page_cpuset = smp_dcache_flush_page_cpuset;
#endif
blast_dcache = smp_blast_dcache;
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: cache.h,v 1.21 2011/06/06 01:16:48 mrg Exp $ */
/* $NetBSD: cache.h,v 1.22 2011/06/06 02:49:39 mrg Exp $ */
/*
* Copyright (c) 2011 Matthew R. Green
@ -101,17 +101,6 @@ void blast_icache_usiii(void); /* Clear entire I$ */
void cache_flush_phys_us(paddr_t, psize_t, int);
void cache_flush_phys_usiii(paddr_t, psize_t, int);
static __inline__ void
dcache_flush_page(paddr_t pa)
{
if (CPU_ISSUN4US || CPU_ISSUN4V)
return;
if (CPU_IS_USIII_UP())
dcache_flush_page_usiii(pa);
else
dcache_flush_page_us(pa);
}
static __inline__ void
cache_flush_phys(paddr_t pa, psize_t size, int ecache)
{
@ -146,25 +135,25 @@ sp_tlb_flush_all(void)
sp_tlb_flush_all_us();
}
#if 0
extern void (*dcache_flush_page)(paddr_t);
extern void (*dcache_flush_page_cpuset)(paddr_t, sparc64_cpuset_t);
#endif
extern void (*blast_dcache)(void);
extern void (*blast_icache)(void);
void cache_setup_funcs(void);
#ifdef MULTIPROCESSOR
extern void (*sp_dcache_flush_page)(paddr_t);
void smp_tlb_flush_pte(vaddr_t, struct pmap *);
void smp_dcache_flush_page_cpuset(paddr_t pa, sparc64_cpuset_t);
void smp_dcache_flush_page_allcpu(paddr_t pa);
void smp_blast_dcache(void);
#define tlb_flush_pte(va,pm ) smp_tlb_flush_pte(va, pm)
#define tlb_flush_pte(va,pm) smp_tlb_flush_pte(va, pm)
#define dcache_flush_page_all(pa) smp_dcache_flush_page_cpuset(pa, cpus_active)
#define dcache_flush_page_cpuset(pa,cs) smp_dcache_flush_page_cpuset(pa, cs)
#else
#define tlb_flush_pte(va,pm) sp_tlb_flush_pte(va, (pm)->pm_ctx[0])
#define dcache_flush_page_all(pa) dcache_flush_page(pa)
#define dcache_flush_page_cpuset(pa,cs) dcache_flush_page(pa)
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipifuncs.c,v 1.41 2011/06/06 01:16:48 mrg Exp $ */
/* $NetBSD: ipifuncs.c,v 1.42 2011/06/06 02:49:39 mrg Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.41 2011/06/06 01:16:48 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.42 2011/06/06 02:49:39 mrg Exp $");
#include "opt_ddb.h"
@ -422,26 +422,21 @@ smp_dcache_flush_page_cpuset(paddr_t pa, sparc64_cpuset_t activecpus)
{
ipifunc_t func;
if (CPU_ISSUN4US || CPU_ISSUN4V)
return;
if (CPU_IS_USIII_UP())
func = sparc64_ipi_dcache_flush_page_usiii;
else
func = sparc64_ipi_dcache_flush_page_us;
sparc64_multicast_ipi(activecpus, func, pa, dcache_line_size);
dcache_flush_page(pa);
sp_dcache_flush_page(pa);
}
#if 0
void
smp_dcache_flush_page_allcpu(paddr_t pa)
{
smp_dcache_flush_page_cpuset(pa, cpus_active);
}
#endif
/*
* Flush the D$ on all CPUs.
@ -450,9 +445,6 @@ void
smp_blast_dcache(void)
{
if (CPU_ISSUN4US || CPU_ISSUN4V)
return;
sparc64_multicast_ipi(cpus_active, sparc64_ipi_blast_dcache,
dcache_size, dcache_line_size);
sp_blast_dcache(dcache_size, dcache_line_size);