Tue Dec 13 12:27:06 2011 UTC ()
Disable spl_intr() spamming when debug printing is enabled.


(reinoud)
diff -r1.8 -r1.9 src/sys/arch/usermode/usermode/intr.c

cvs diff -r1.8 -r1.9 src/sys/arch/usermode/usermode/intr.c (switch to unified diff)

--- src/sys/arch/usermode/usermode/intr.c 2011/09/16 16:25:44 1.8
+++ src/sys/arch/usermode/usermode/intr.c 2011/12/13 12:27:06 1.9
@@ -1,136 +1,136 @@ @@ -1,136 +1,136 @@
1/* $NetBSD: intr.c,v 1.8 2011/09/16 16:25:44 reinoud Exp $ */ 1/* $NetBSD: intr.c,v 1.9 2011/12/13 12:27:06 reinoud Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
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.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
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: intr.c,v 1.8 2011/09/16 16:25:44 reinoud Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.9 2011/12/13 12:27:06 reinoud Exp $");
31 31
32#include <sys/types.h> 32#include <sys/types.h>
33 33
34#include <machine/intr.h> 34#include <machine/intr.h>
35#include <machine/thunk.h> 35#include <machine/thunk.h>
36 36
37//#define INTR_USE_SIGPROCMASK 37//#define INTR_USE_SIGPROCMASK
38 38
39#define MAX_QUEUED_EVENTS 128 39#define MAX_QUEUED_EVENTS 128
40 40
41static int usermode_x = IPL_NONE; 41static int usermode_x = IPL_NONE;
42 42
43#ifdef INTR_USE_SIGPROCMASK 43#ifdef INTR_USE_SIGPROCMASK
44static bool block_sigalrm = false; 44static bool block_sigalrm = false;
45#endif 45#endif
46 46
47 47
48struct spl_intr_event { 48struct spl_intr_event {
49 void (*func)(void *); 49 void (*func)(void *);
50 void *arg; 50 void *arg;
51}; 51};
52 52
53struct spl_intr_event spl_intrs[IPL_HIGH+1][MAX_QUEUED_EVENTS]; 53struct spl_intr_event spl_intrs[IPL_HIGH+1][MAX_QUEUED_EVENTS];
54int spl_intr_wr[IPL_HIGH+1]; 54int spl_intr_wr[IPL_HIGH+1];
55int spl_intr_rd[IPL_HIGH+1]; 55int spl_intr_rd[IPL_HIGH+1];
56 56
57void 57void
58splinit(void) 58splinit(void)
59{ 59{
60 int i; 60 int i;
61 for (i = 0; i <= IPL_HIGH; i++) { 61 for (i = 0; i <= IPL_HIGH; i++) {
62 spl_intr_rd[i] = 1; 62 spl_intr_rd[i] = 1;
63 spl_intr_wr[i] = 1; 63 spl_intr_wr[i] = 1;
64 } 64 }
65} 65}
66 66
67void 67void
68spl_intr(int x, void (*func)(void *), void *arg) 68spl_intr(int x, void (*func)(void *), void *arg)
69{ 69{
70 struct spl_intr_event *spli; 70 struct spl_intr_event *spli;
71 71
72 if (x >= usermode_x) { 72 if (x >= usermode_x) {
73 func(arg); 73 func(arg);
74 return; 74 return;
75 } 75 }
76 76
77 dprintf_debug("spl_intr: queue %d when %d\n", x, usermode_x); 77// dprintf_debug("spl_intr: queue %d when %d\n", x, usermode_x);
78 spli = &spl_intrs[x][spl_intr_wr[x]]; 78 spli = &spl_intrs[x][spl_intr_wr[x]];
79 spli->func = func; 79 spli->func = func;
80 spli->arg = arg; 80 spli->arg = arg;
81 81
82 spl_intr_wr[x] = (spl_intr_wr[x] + 1) % MAX_QUEUED_EVENTS; 82 spl_intr_wr[x] = (spl_intr_wr[x] + 1) % MAX_QUEUED_EVENTS;
83 if (spl_intr_wr[x] == spl_intr_rd[x]) 83 if (spl_intr_wr[x] == spl_intr_rd[x])
84 panic("%s: spl list %d full!\n", __func__, x); 84 panic("%s: spl list %d full!\n", __func__, x);
85} 85}
86 86
87int 87int
88splraise(int x) 88splraise(int x)
89{ 89{
90 int oldx = usermode_x; 90 int oldx = usermode_x;
91 91
92 if (x > usermode_x) { 92 if (x > usermode_x) {
93 usermode_x = x; 93 usermode_x = x;
94 } 94 }
95 95
96#ifdef INTR_USE_SIGPROCMASK 96#ifdef INTR_USE_SIGPROCMASK
97 if (x >= IPL_SCHED && !block_sigalrm) { 97 if (x >= IPL_SCHED && !block_sigalrm) {
98 thunk_sigblock(SIGALRM); 98 thunk_sigblock(SIGALRM);
99 block_sigalrm = true; 99 block_sigalrm = true;
100 } 100 }
101#endif 101#endif
102 102
103 return oldx; 103 return oldx;
104} 104}
105 105
106void 106void
107spllower(int x) 107spllower(int x)
108{ 108{
109 struct spl_intr_event *spli; 109 struct spl_intr_event *spli;
110 int y; 110 int y;
111 111
112 /* `eat' interrupts that came by until we got back to x */ 112 /* `eat' interrupts that came by until we got back to x */
113 if (usermode_x > x) { 113 if (usermode_x > x) {
114//restart: 114//restart:
115 for (y = usermode_x; y >= x; y--) { 115 for (y = usermode_x; y >= x; y--) {
116 while (spl_intr_rd[y] != spl_intr_wr[y]) { 116 while (spl_intr_rd[y] != spl_intr_wr[y]) {
117 dprintf_debug("spl y %d firing\n", y); 117// dprintf_debug("spl y %d firing\n", y);
118 spli = &spl_intrs[y][spl_intr_rd[y]]; 118 spli = &spl_intrs[y][spl_intr_rd[y]];
119 if (!spli->func) 119 if (!spli->func)
120 panic("%s: spli->func is NULL for ipl %d, rd %d, wr %d\n", 120 panic("%s: spli->func is NULL for ipl %d, rd %d, wr %d\n",
121 __func__, y, spl_intr_rd[y], spl_intr_wr[y]); 121 __func__, y, spl_intr_rd[y], spl_intr_wr[y]);
122 spli->func(spli->arg); 122 spli->func(spli->arg);
123 spl_intr_rd[y] = (spl_intr_rd[y] + 1) % MAX_QUEUED_EVENTS; 123 spl_intr_rd[y] = (spl_intr_rd[y] + 1) % MAX_QUEUED_EVENTS;
124// goto restart; 124// goto restart;
125 } 125 }
126 } 126 }
127 usermode_x = x; 127 usermode_x = x;
128 } 128 }
129 129
130#ifdef INTR_USE_SIGPROCMASK 130#ifdef INTR_USE_SIGPROCMASK
131 if (x < IPL_SCHED && block_sigalrm) { 131 if (x < IPL_SCHED && block_sigalrm) {
132 thunk_sigunblock(SIGALRM); 132 thunk_sigunblock(SIGALRM);
133 block_sigalrm = false; 133 block_sigalrm = false;
134 } 134 }
135#endif 135#endif
136} 136}