xref: /titanic_41/usr/src/uts/sun4/os/mp_call.c (revision 2449e17f82f6097fd2c665b64723e31ceecbeca6)
1 /*
2  * CDDL HEADER START
3  *
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
7  * with the License.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * Facilities for cross-processor subroutine calls using "mailbox" interrupts.
31  */
32 
33 #include <sys/types.h>
34 #include <sys/thread.h>
35 #include <sys/cpuvar.h>
36 #include <sys/x_call.h>
37 #include <sys/systm.h>
38 #include <sys/machsystm.h>
39 #include <sys/intr.h>
40 
41 /*
42  * Interrupt another CPU.
43  * 	This is useful to make the other CPU go through a trap so that
44  *	it recognizes an address space trap (AST) for preempting a thread.
45  *
46  *	It is possible to be preempted here and be resumed on the CPU
47  *	being poked, so it isn't an error to poke the current CPU.
48  *	We could check this and still get preempted after the check, so
49  *	we don't bother.
50  */
51 void
52 poke_cpu(int cpun)
53 {
54 	uint32_t *ptr = (uint32_t *)&cpu[cpun]->cpu_m.poke_cpu_outstanding;
55 
56 	/*
57 	 * If panicstr is set or a poke_cpu is already pending,
58 	 * no need to send another one. Use atomic swap to protect
59 	 * against multiple CPUs sending redundant pokes.
60 	 */
61 	if (panicstr || *ptr == B_TRUE ||
62 	    atomic_swap_32(ptr, B_TRUE) == B_TRUE)
63 		return;
64 
65 	xt_one(cpun, setsoftint_tl1, poke_cpu_inum, 0);
66 }
67