Mon Jun 6 02:49:39 2011 UTC ()
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.


(mrg)
diff -r1.7 -r1.8 src/sys/arch/sparc64/sparc64/cache.c
diff -r1.21 -r1.22 src/sys/arch/sparc64/sparc64/cache.h
diff -r1.41 -r1.42 src/sys/arch/sparc64/sparc64/ipifuncs.c

cvs diff -r1.7 -r1.8 src/sys/arch/sparc64/sparc64/cache.c (expand / switch to unified diff)

--- src/sys/arch/sparc64/sparc64/cache.c 2011/06/06 01:16:48 1.7
+++ src/sys/arch/sparc64/sparc64/cache.c 2011/06/06 02:49:39 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cache.c,v 1.7 2011/06/06 01:16:48 mrg Exp $ */ 1/* $NetBSD: cache.c,v 1.8 2011/06/06 02:49:39 mrg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2011 Matthew R. Green 4 * Copyright (c) 2011 Matthew R. Green
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -25,81 +25,82 @@ @@ -25,81 +25,82 @@
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE. 28 * SUCH DAMAGE.
29 */ 29 */
30 30
31/* 31/*
32 * Handle picking the right types of the different cache call. 32 * Handle picking the right types of the different cache call.
33 * 33 *
34 * This module could take on a larger role. 34 * This module could take on a larger role.
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__KERNEL_RCSID(0, "$NetBSD: cache.c,v 1.7 2011/06/06 01:16:48 mrg Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: cache.c,v 1.8 2011/06/06 02:49:39 mrg Exp $");
39 39
40#include "opt_multiprocessor.h" 40#include "opt_multiprocessor.h"
41 41
42#include <sys/param.h> 42#include <sys/param.h>
43#include <sys/reboot.h> 43#include <sys/reboot.h>
44 44
45#include <machine/cpu.h> 45#include <machine/cpu.h>
46 46
47#include <sparc64/sparc64/cache.h> 47#include <sparc64/sparc64/cache.h>
48 48
49static void 49static void
50cache_nop(void) 50cache_nop(void)
51{ 51{
52} 52}
53 53
54static void 54static void
55blast_dcache_real(void) 55blast_dcache_real(void)
56{ 56{
57 57
58 sp_blast_dcache(dcache_size, dcache_line_size); 58 sp_blast_dcache(dcache_size, dcache_line_size);
59} 59}
60 60
61#if 0 
62static void 61static void
63sp_dcache_flush_page_cpuset(paddr_t pa, sparc64_cpuset_t cs) 62sp_dcache_flush_page_cpuset(paddr_t pa, sparc64_cpuset_t cs)
64{ 63{
65 64
66 dcache_flush_page(pa); 65 dcache_flush_page(pa);
67} 66}
68 67
69void (*dcache_flush_page)(paddr_t) = dcache_flush_page_us; 68void (*dcache_flush_page)(paddr_t) = dcache_flush_page_us;
70void (*dcache_flush_page_cpuset)(paddr_t, sparc64_cpuset_t) = 69void (*dcache_flush_page_cpuset)(paddr_t, sparc64_cpuset_t) =
71 sp_dcache_flush_page_cpuset; 70 sp_dcache_flush_page_cpuset;
72#endif 
73void (*blast_dcache)(void) = blast_dcache_real; 71void (*blast_dcache)(void) = blast_dcache_real;
74void (*blast_icache)(void) = blast_icache_us; 72void (*blast_icache)(void) = blast_icache_us;
75 73
 74#ifdef MULTIPROCESSOR
 75void (*sp_dcache_flush_page)(paddr_t) = dcache_flush_page_us;
 76#endif
 77
76void 78void
77cache_setup_funcs(void) 79cache_setup_funcs(void)
78{ 80{
79 81
80 if (CPU_ISSUN4US || CPU_ISSUN4V) { 82 if (CPU_ISSUN4US || CPU_ISSUN4V) {
81#if 0 
82 dcache_flush_page = (void (*)(paddr_t)) cache_nop; 83 dcache_flush_page = (void (*)(paddr_t)) cache_nop;
 84#ifdef MULTIPROCESSOR
 85 /* XXXMRG shouldn't be necessary -- only caller is nop'ed out */
 86 sp_dcache_flush_page = (void (*)(paddr_t)) cache_nop;
83#endif 87#endif
84 blast_dcache = cache_nop; 88 blast_dcache = cache_nop;
85 blast_icache = cache_nop; 89 blast_icache = cache_nop;
86 } else { 90 } else {
87 if (CPU_IS_USIII_UP()) { 91 if (CPU_IS_USIII_UP()) {
88#if 0 
89 dcache_flush_page = dcache_flush_page_usiii; 92 dcache_flush_page = dcache_flush_page_usiii;
 93#ifdef MULTIPROCESSOR
 94 sp_dcache_flush_page = dcache_flush_page_usiii;
90#endif 95#endif
91 blast_icache = blast_icache_usiii; 96 blast_icache = blast_icache_usiii;
92printf("set usIII dcache/icache funcs\n"); 
93 } 97 }
94#ifdef MULTIPROCESSOR 98#ifdef MULTIPROCESSOR
95 if (sparc_ncpus > 1 && (boothowto & RB_MD1) == 0) { 99 if (sparc_ncpus > 1 && (boothowto & RB_MD1) == 0) {
96printf("set MP dcache funcs\n"); 
97#if 0 
98 dcache_flush_page = smp_dcache_flush_page_allcpu; 100 dcache_flush_page = smp_dcache_flush_page_allcpu;
99 dcache_flush_page_cpuset = smp_dcache_flush_page_cpuset; 101 dcache_flush_page_cpuset = smp_dcache_flush_page_cpuset;
100#endif 
101 blast_dcache = smp_blast_dcache; 102 blast_dcache = smp_blast_dcache;
102 } 103 }
103#endif 104#endif
104 } 105 }
105} 106}

cvs diff -r1.21 -r1.22 src/sys/arch/sparc64/sparc64/cache.h (expand / switch to unified diff)

--- src/sys/arch/sparc64/sparc64/cache.h 2011/06/06 01:16:48 1.21
+++ src/sys/arch/sparc64/sparc64/cache.h 2011/06/06 02:49:39 1.22
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cache.h,v 1.21 2011/06/06 01:16:48 mrg Exp $ */ 1/* $NetBSD: cache.h,v 1.22 2011/06/06 02:49:39 mrg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2011 Matthew R. Green 4 * Copyright (c) 2011 Matthew R. Green
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -92,37 +92,26 @@ extern int icache_size; @@ -92,37 +92,26 @@ extern int icache_size;
92 92
93/* The following are for I$ and D$ flushes and are in locore.s */ 93/* The following are for I$ and D$ flushes and are in locore.s */
94void dcache_flush_page_us(paddr_t); /* flush page from D$ */ 94void dcache_flush_page_us(paddr_t); /* flush page from D$ */
95void dcache_flush_page_usiii(paddr_t); /* flush page from D$ */ 95void dcache_flush_page_usiii(paddr_t); /* flush page from D$ */
96void sp_blast_dcache(int, int); /* Clear entire D$ */ 96void sp_blast_dcache(int, int); /* Clear entire D$ */
97void blast_icache_us(void); /* Clear entire I$ */ 97void blast_icache_us(void); /* Clear entire I$ */
98void blast_icache_usiii(void); /* Clear entire I$ */ 98void blast_icache_usiii(void); /* Clear entire I$ */
99 99
100/* The following flush a range from the D$ and I$ but not E$. */ 100/* The following flush a range from the D$ and I$ but not E$. */
101void cache_flush_phys_us(paddr_t, psize_t, int); 101void cache_flush_phys_us(paddr_t, psize_t, int);
102void cache_flush_phys_usiii(paddr_t, psize_t, int); 102void cache_flush_phys_usiii(paddr_t, psize_t, int);
103 103
104static __inline__ void 104static __inline__ void
105dcache_flush_page(paddr_t pa) 
106{ 
107 if (CPU_ISSUN4US || CPU_ISSUN4V) 
108 return; 
109 if (CPU_IS_USIII_UP()) 
110 dcache_flush_page_usiii(pa); 
111 else 
112 dcache_flush_page_us(pa); 
113} 
114 
115static __inline__ void 
116cache_flush_phys(paddr_t pa, psize_t size, int ecache) 105cache_flush_phys(paddr_t pa, psize_t size, int ecache)
117{ 106{
118 if (CPU_IS_USIII_UP() || CPU_IS_SPARC64_V_UP()) 107 if (CPU_IS_USIII_UP() || CPU_IS_SPARC64_V_UP())
119 cache_flush_phys_usiii(pa, size, ecache); 108 cache_flush_phys_usiii(pa, size, ecache);
120 else 109 else
121 cache_flush_phys_us(pa, size, ecache); 110 cache_flush_phys_us(pa, size, ecache);
122} 111}
123 112
124/* SPARC64 specific */ 113/* SPARC64 specific */
125/* Assembly routines to flush TLB mappings */ 114/* Assembly routines to flush TLB mappings */
126void sp_tlb_flush_pte_us(vaddr_t, int); 115void sp_tlb_flush_pte_us(vaddr_t, int);
127void sp_tlb_flush_pte_usiii(vaddr_t, int); 116void sp_tlb_flush_pte_usiii(vaddr_t, int);
128void sp_tlb_flush_all_us(void); 117void sp_tlb_flush_all_us(void);
@@ -136,35 +125,35 @@ sp_tlb_flush_pte(vaddr_t va, int ctx) @@ -136,35 +125,35 @@ sp_tlb_flush_pte(vaddr_t va, int ctx)
136 else 125 else
137 sp_tlb_flush_pte_us(va, ctx); 126 sp_tlb_flush_pte_us(va, ctx);
138} 127}
139 128
140static __inline__ void 129static __inline__ void
141sp_tlb_flush_all(void) 130sp_tlb_flush_all(void)
142{ 131{
143 if (CPU_IS_USIII_UP() || CPU_IS_SPARC64_V_UP()) 132 if (CPU_IS_USIII_UP() || CPU_IS_SPARC64_V_UP())
144 sp_tlb_flush_all_usiii(); 133 sp_tlb_flush_all_usiii();
145 else 134 else
146 sp_tlb_flush_all_us(); 135 sp_tlb_flush_all_us();
147} 136}
148 137
149#if 0 
150extern void (*dcache_flush_page)(paddr_t); 138extern void (*dcache_flush_page)(paddr_t);
151extern void (*dcache_flush_page_cpuset)(paddr_t, sparc64_cpuset_t); 139extern void (*dcache_flush_page_cpuset)(paddr_t, sparc64_cpuset_t);
152#endif 
153extern void (*blast_dcache)(void); 140extern void (*blast_dcache)(void);
154extern void (*blast_icache)(void); 141extern void (*blast_icache)(void);
155 142
156void cache_setup_funcs(void); 143void cache_setup_funcs(void);
157 144
158#ifdef MULTIPROCESSOR 145#ifdef MULTIPROCESSOR
 146extern void (*sp_dcache_flush_page)(paddr_t);
 147
159void smp_tlb_flush_pte(vaddr_t, struct pmap *); 148void smp_tlb_flush_pte(vaddr_t, struct pmap *);
160void smp_dcache_flush_page_cpuset(paddr_t pa, sparc64_cpuset_t); 149void smp_dcache_flush_page_cpuset(paddr_t pa, sparc64_cpuset_t);
 150void smp_dcache_flush_page_allcpu(paddr_t pa);
161void smp_blast_dcache(void); 151void smp_blast_dcache(void);
162#define tlb_flush_pte(va,pm ) smp_tlb_flush_pte(va, pm) 152#define tlb_flush_pte(va,pm) smp_tlb_flush_pte(va, pm)
163#define dcache_flush_page_all(pa) smp_dcache_flush_page_cpuset(pa, cpus_active) 153#define dcache_flush_page_all(pa) smp_dcache_flush_page_cpuset(pa, cpus_active)
164#define dcache_flush_page_cpuset(pa,cs) smp_dcache_flush_page_cpuset(pa, cs) 154#define dcache_flush_page_cpuset(pa,cs) smp_dcache_flush_page_cpuset(pa, cs)
165#else 155#else
166#define tlb_flush_pte(va,pm) sp_tlb_flush_pte(va, (pm)->pm_ctx[0]) 156#define tlb_flush_pte(va,pm) sp_tlb_flush_pte(va, (pm)->pm_ctx[0])
167#define dcache_flush_page_all(pa) dcache_flush_page(pa) 157#define dcache_flush_page_all(pa) dcache_flush_page(pa)
168#define dcache_flush_page_cpuset(pa,cs) dcache_flush_page(pa) 158#define dcache_flush_page_cpuset(pa,cs) dcache_flush_page(pa)
169 
170#endif 159#endif

cvs diff -r1.41 -r1.42 src/sys/arch/sparc64/sparc64/ipifuncs.c (expand / switch to unified diff)

--- src/sys/arch/sparc64/sparc64/ipifuncs.c 2011/06/06 01:16:48 1.41
+++ src/sys/arch/sparc64/sparc64/ipifuncs.c 2011/06/06 02:49:39 1.42
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ipifuncs.c,v 1.41 2011/06/06 01:16:48 mrg Exp $ */ 1/* $NetBSD: ipifuncs.c,v 1.42 2011/06/06 02:49:39 mrg Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2004 The NetBSD Foundation, Inc. 4 * Copyright (c) 2004 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.41 2011/06/06 01:16:48 mrg Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.42 2011/06/06 02:49:39 mrg Exp $");
31 31
32#include "opt_ddb.h" 32#include "opt_ddb.h"
33 33
34#include <sys/param.h> 34#include <sys/param.h>
35#include <sys/systm.h> 35#include <sys/systm.h>
36#include <sys/malloc.h> 36#include <sys/malloc.h>
37#include <sys/xcall.h> 37#include <sys/xcall.h>
38 38
39#include <machine/db_machdep.h> 39#include <machine/db_machdep.h>
40 40
41#include <machine/cpu.h> 41#include <machine/cpu.h>
42#include <machine/cpu_counter.h> 42#include <machine/cpu_counter.h>
43#include <machine/ctlreg.h> 43#include <machine/ctlreg.h>
@@ -412,57 +412,49 @@ smp_tlb_flush_pte(vaddr_t va, struct pma @@ -412,57 +412,49 @@ smp_tlb_flush_pte(vaddr_t va, struct pma
412 sparc64_send_ipi(ci->ci_cpuid, func, va, ctx); 412 sparc64_send_ipi(ci->ci_cpuid, func, va, ctx);
413 } 413 }
414 } 414 }
415} 415}
416 416
417/* 417/*
418 * Make sure this page is flushed from all/some CPUs. 418 * Make sure this page is flushed from all/some CPUs.
419 */ 419 */
420void 420void
421smp_dcache_flush_page_cpuset(paddr_t pa, sparc64_cpuset_t activecpus) 421smp_dcache_flush_page_cpuset(paddr_t pa, sparc64_cpuset_t activecpus)
422{ 422{
423 ipifunc_t func; 423 ipifunc_t func;
424 424
425 if (CPU_ISSUN4US || CPU_ISSUN4V) 
426 return; 
427 
428 if (CPU_IS_USIII_UP()) 425 if (CPU_IS_USIII_UP())
429 func = sparc64_ipi_dcache_flush_page_usiii; 426 func = sparc64_ipi_dcache_flush_page_usiii;
430 else 427 else
431 func = sparc64_ipi_dcache_flush_page_us; 428 func = sparc64_ipi_dcache_flush_page_us;
432 429
433 sparc64_multicast_ipi(activecpus, func, pa, dcache_line_size); 430 sparc64_multicast_ipi(activecpus, func, pa, dcache_line_size);
434 dcache_flush_page(pa); 431 sp_dcache_flush_page(pa);
435} 432}
436 433
437#if 0 
438void 434void
439smp_dcache_flush_page_allcpu(paddr_t pa) 435smp_dcache_flush_page_allcpu(paddr_t pa)
440{ 436{
441 437
442 smp_dcache_flush_page_cpuset(pa, cpus_active); 438 smp_dcache_flush_page_cpuset(pa, cpus_active);
443} 439}
444#endif 
445 440
446/* 441/*
447 * Flush the D$ on all CPUs. 442 * Flush the D$ on all CPUs.
448 */ 443 */
449void 444void
450smp_blast_dcache(void) 445smp_blast_dcache(void)
451{ 446{
452 447
453 if (CPU_ISSUN4US || CPU_ISSUN4V) 
454 return; 
455 
456 sparc64_multicast_ipi(cpus_active, sparc64_ipi_blast_dcache, 448 sparc64_multicast_ipi(cpus_active, sparc64_ipi_blast_dcache,
457 dcache_size, dcache_line_size); 449 dcache_size, dcache_line_size);
458 sp_blast_dcache(dcache_size, dcache_line_size); 450 sp_blast_dcache(dcache_size, dcache_line_size);
459} 451}
460 452
461/* 453/*
462 * Print an error message. 454 * Print an error message.
463 */ 455 */
464void 456void
465sparc64_ipi_error(const char *s, sparc64_cpuset_t cpus_succeeded, 457sparc64_ipi_error(const char *s, sparc64_cpuset_t cpus_succeeded,
466 sparc64_cpuset_t cpus_expected) 458 sparc64_cpuset_t cpus_expected)
467{ 459{
468 int cpuid; 460 int cpuid;