4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/types.h>
30 #include <sys/param.h>
32 #include <sys/thread.h>
33 #include <sys/cpuvar.h>
34 #include <sys/kstat.h>
35 #include <sys/uadmin.h>
36 #include <sys/systm.h>
37 #include <sys/errno.h>
38 #include <sys/cmn_err.h>
39 #include <sys/procset.h>
40 #include <sys/processor.h>
41 #include <sys/debug.h>
42 #include <sys/cyclic.h>
43 #include <sys/pool_pset.h>
46 * cpu_intr_on - determine whether the CPU is participating
50 cpu_intr_on(cpu_t
*cp
)
52 ASSERT(MUTEX_HELD(&cpu_lock
));
53 return ((cp
->cpu_flags
& CPU_ENABLE
) != 0);
57 * Return the next on-line CPU handling interrupts.
60 cpu_intr_next(cpu_t
*cp
)
64 ASSERT(MUTEX_HELD(&cpu_lock
));
66 c
= cp
->cpu_next_onln
;
77 * cpu_intr_count - count how many CPUs are handling I/O interrupts.
80 cpu_intr_count(cpu_t
*cp
)
85 ASSERT(MUTEX_HELD(&cpu_lock
));
91 } while ((c
= c
->cpu_next
) != cp
);
96 * Enable I/O interrupts on this CPU, if they are disabled.
99 cpu_intr_enable(cpu_t
*cp
)
101 ASSERT(MUTEX_HELD(&cpu_lock
));
102 if (!cpu_intr_on(cp
)) {
109 * cpu_intr_disable - redirect I/O interrupts targetted at this CPU.
111 * semantics: We check the count of CPUs that are accepting
112 * interrupts, because it's stupid to take the last CPU out
113 * of I/O interrupt participation. This also permits the
114 * p_online syscall to fail gracefully in uniprocessor configurations
115 * without having to perform any special platform-specific operations.
118 cpu_intr_disable(cpu_t
*cp
)
122 ASSERT(MUTEX_HELD(&cpu_lock
));
123 if ((cpu_intr_count(cp
) > 1) && (cpu_intr_next(cp
) != NULL
)) {
124 if (cpu_intr_on(cp
)) {
126 * Juggle away cyclics, but don't fail if we don't
127 * manage to juggle all of them away; we want to allow
128 * CPU-bound cyclics to continue to fire on the
131 (void) cyclic_juggle(cp
);
132 e
= cpu_disable_intr(cp
);