Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
Dean Nelson | 45d9ca4 | 2008-04-22 14:46:56 -0500 | [diff] [blame] | 6 | * Copyright (c) 2004-2008 Silicon Graphics, Inc. All Rights Reserved. |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 9 | /* |
| 10 | * Cross Partition Communication (XPC) support - standard version. |
| 11 | * |
| 12 | * XPC provides a message passing capability that crosses partition |
| 13 | * boundaries. This module is made up of two parts: |
| 14 | * |
| 15 | * partition This part detects the presence/absence of other |
| 16 | * partitions. It provides a heartbeat and monitors |
| 17 | * the heartbeats of other partitions. |
| 18 | * |
| 19 | * channel This part manages the channels and sends/receives |
| 20 | * messages across them to/from other partitions. |
| 21 | * |
| 22 | * There are a couple of additional functions residing in XP, which |
| 23 | * provide an interface to XPC for its users. |
| 24 | * |
| 25 | * |
| 26 | * Caveats: |
| 27 | * |
| 28 | * . We currently have no way to determine which nasid an IPI came |
| 29 | * from. Thus, xpc_IPI_send() does a remote AMO write followed by |
| 30 | * an IPI. The AMO indicates where data is to be pulled from, so |
| 31 | * after the IPI arrives, the remote partition checks the AMO word. |
| 32 | * The IPI can actually arrive before the AMO however, so other code |
| 33 | * must periodically check for this case. Also, remote AMO operations |
| 34 | * do not reliably time out. Thus we do a remote PIO read solely to |
| 35 | * know whether the remote partition is down and whether we should |
| 36 | * stop sending IPIs to it. This remote PIO read operation is set up |
| 37 | * in a special nofault region so SAL knows to ignore (and cleanup) |
| 38 | * any errors due to the remote AMO write, PIO read, and/or PIO |
| 39 | * write operations. |
| 40 | * |
| 41 | * If/when new hardware solves this IPI problem, we should abandon |
| 42 | * the current approach. |
| 43 | * |
| 44 | */ |
| 45 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 46 | #include <linux/kernel.h> |
| 47 | #include <linux/module.h> |
| 48 | #include <linux/init.h> |
| 49 | #include <linux/sched.h> |
| 50 | #include <linux/syscalls.h> |
| 51 | #include <linux/cache.h> |
| 52 | #include <linux/interrupt.h> |
Nishanth Aravamudan | 6991392 | 2005-07-08 17:10:00 -0700 | [diff] [blame] | 53 | #include <linux/delay.h> |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 54 | #include <linux/reboot.h> |
Jes Sorensen | f9e505a | 2006-01-17 12:52:21 -0500 | [diff] [blame] | 55 | #include <linux/completion.h> |
Christoph Hellwig | 1eeb66a | 2007-05-08 00:27:03 -0700 | [diff] [blame] | 56 | #include <linux/kdebug.h> |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 57 | #include <asm/sn/intr.h> |
| 58 | #include <asm/sn/sn_sal.h> |
| 59 | #include <asm/uaccess.h> |
Dean Nelson | 45d9ca4 | 2008-04-22 14:46:56 -0500 | [diff] [blame] | 60 | #include "xpc.h" |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 61 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 62 | /* define two XPC debug device structures to be used with dev_dbg() et al */ |
| 63 | |
| 64 | struct device_driver xpc_dbg_name = { |
| 65 | .name = "xpc" |
| 66 | }; |
| 67 | |
| 68 | struct device xpc_part_dbg_subname = { |
| 69 | .bus_id = {0}, /* set to "part" at xpc_init() time */ |
| 70 | .driver = &xpc_dbg_name |
| 71 | }; |
| 72 | |
| 73 | struct device xpc_chan_dbg_subname = { |
| 74 | .bus_id = {0}, /* set to "chan" at xpc_init() time */ |
| 75 | .driver = &xpc_dbg_name |
| 76 | }; |
| 77 | |
| 78 | struct device *xpc_part = &xpc_part_dbg_subname; |
| 79 | struct device *xpc_chan = &xpc_chan_dbg_subname; |
| 80 | |
Dean Nelson | 1f4674b | 2006-01-10 11:08:00 -0600 | [diff] [blame] | 81 | static int xpc_kdebug_ignore; |
| 82 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 83 | /* systune related variables for /proc/sys directories */ |
| 84 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 85 | static int xpc_hb_interval = XPC_HB_DEFAULT_INTERVAL; |
| 86 | static int xpc_hb_min_interval = 1; |
| 87 | static int xpc_hb_max_interval = 10; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 88 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 89 | static int xpc_hb_check_interval = XPC_HB_CHECK_DEFAULT_INTERVAL; |
| 90 | static int xpc_hb_check_min_interval = 10; |
| 91 | static int xpc_hb_check_max_interval = 120; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 92 | |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 93 | int xpc_disengage_request_timelimit = XPC_DISENGAGE_REQUEST_DEFAULT_TIMELIMIT; |
| 94 | static int xpc_disengage_request_min_timelimit = 0; |
| 95 | static int xpc_disengage_request_max_timelimit = 120; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 96 | |
| 97 | static ctl_table xpc_sys_xpc_hb_dir[] = { |
| 98 | { |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 99 | .ctl_name = CTL_UNNUMBERED, |
| 100 | .procname = "hb_interval", |
| 101 | .data = &xpc_hb_interval, |
| 102 | .maxlen = sizeof(int), |
| 103 | .mode = 0644, |
| 104 | .proc_handler = &proc_dointvec_minmax, |
| 105 | .strategy = &sysctl_intvec, |
| 106 | .extra1 = &xpc_hb_min_interval, |
| 107 | .extra2 = &xpc_hb_max_interval}, |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 108 | { |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 109 | .ctl_name = CTL_UNNUMBERED, |
| 110 | .procname = "hb_check_interval", |
| 111 | .data = &xpc_hb_check_interval, |
| 112 | .maxlen = sizeof(int), |
| 113 | .mode = 0644, |
| 114 | .proc_handler = &proc_dointvec_minmax, |
| 115 | .strategy = &sysctl_intvec, |
| 116 | .extra1 = &xpc_hb_check_min_interval, |
| 117 | .extra2 = &xpc_hb_check_max_interval}, |
Eric W. Biederman | 68cbf07 | 2007-02-14 00:33:41 -0800 | [diff] [blame] | 118 | {} |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 119 | }; |
| 120 | static ctl_table xpc_sys_xpc_dir[] = { |
| 121 | { |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 122 | .ctl_name = CTL_UNNUMBERED, |
| 123 | .procname = "hb", |
| 124 | .mode = 0555, |
| 125 | .child = xpc_sys_xpc_hb_dir}, |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 126 | { |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 127 | .ctl_name = CTL_UNNUMBERED, |
| 128 | .procname = "disengage_request_timelimit", |
| 129 | .data = &xpc_disengage_request_timelimit, |
| 130 | .maxlen = sizeof(int), |
| 131 | .mode = 0644, |
| 132 | .proc_handler = &proc_dointvec_minmax, |
| 133 | .strategy = &sysctl_intvec, |
| 134 | .extra1 = &xpc_disengage_request_min_timelimit, |
| 135 | .extra2 = &xpc_disengage_request_max_timelimit}, |
Eric W. Biederman | 68cbf07 | 2007-02-14 00:33:41 -0800 | [diff] [blame] | 136 | {} |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 137 | }; |
| 138 | static ctl_table xpc_sys_dir[] = { |
| 139 | { |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 140 | .ctl_name = CTL_UNNUMBERED, |
| 141 | .procname = "xpc", |
| 142 | .mode = 0555, |
| 143 | .child = xpc_sys_xpc_dir}, |
Eric W. Biederman | 68cbf07 | 2007-02-14 00:33:41 -0800 | [diff] [blame] | 144 | {} |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 145 | }; |
| 146 | static struct ctl_table_header *xpc_sysctl; |
| 147 | |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 148 | /* non-zero if any remote partition disengage request was timed out */ |
| 149 | int xpc_disengage_request_timedout; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 150 | |
| 151 | /* #of IRQs received */ |
| 152 | static atomic_t xpc_act_IRQ_rcvd; |
| 153 | |
| 154 | /* IRQ handler notifies this wait queue on receipt of an IRQ */ |
| 155 | static DECLARE_WAIT_QUEUE_HEAD(xpc_act_IRQ_wq); |
| 156 | |
| 157 | static unsigned long xpc_hb_check_timeout; |
| 158 | |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 159 | /* notification that the xpc_hb_checker thread has exited */ |
Jes Sorensen | f9e505a | 2006-01-17 12:52:21 -0500 | [diff] [blame] | 160 | static DECLARE_COMPLETION(xpc_hb_checker_exited); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 161 | |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 162 | /* notification that the xpc_discovery thread has exited */ |
Jes Sorensen | f9e505a | 2006-01-17 12:52:21 -0500 | [diff] [blame] | 163 | static DECLARE_COMPLETION(xpc_discovery_exited); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 164 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 165 | static struct timer_list xpc_hb_timer; |
| 166 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 167 | static void xpc_kthread_waitmsgs(struct xpc_partition *, struct xpc_channel *); |
| 168 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 169 | static int xpc_system_reboot(struct notifier_block *, unsigned long, void *); |
| 170 | static struct notifier_block xpc_reboot_notifier = { |
| 171 | .notifier_call = xpc_system_reboot, |
| 172 | }; |
| 173 | |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 174 | static int xpc_system_die(struct notifier_block *, unsigned long, void *); |
| 175 | static struct notifier_block xpc_die_notifier = { |
| 176 | .notifier_call = xpc_system_die, |
| 177 | }; |
| 178 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 179 | /* |
| 180 | * Timer function to enforce the timelimit on the partition disengage request. |
| 181 | */ |
| 182 | static void |
| 183 | xpc_timeout_partition_disengage_request(unsigned long data) |
| 184 | { |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 185 | struct xpc_partition *part = (struct xpc_partition *)data; |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 186 | |
Robert P. J. Day | d167cb8 | 2008-03-29 10:05:30 -0400 | [diff] [blame] | 187 | DBUG_ON(time_before(jiffies, part->disengage_request_timeout)); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 188 | |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 189 | (void)xpc_partition_disengaged(part); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 190 | |
| 191 | DBUG_ON(part->disengage_request_timeout != 0); |
| 192 | DBUG_ON(xpc_partition_engaged(1UL << XPC_PARTID(part)) != 0); |
| 193 | } |
| 194 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 195 | /* |
| 196 | * Notify the heartbeat check thread that an IRQ has been received. |
| 197 | */ |
| 198 | static irqreturn_t |
Al Viro | 5dcded1 | 2006-10-08 14:59:19 +0100 | [diff] [blame] | 199 | xpc_act_IRQ_handler(int irq, void *dev_id) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 200 | { |
| 201 | atomic_inc(&xpc_act_IRQ_rcvd); |
| 202 | wake_up_interruptible(&xpc_act_IRQ_wq); |
| 203 | return IRQ_HANDLED; |
| 204 | } |
| 205 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 206 | /* |
| 207 | * Timer to produce the heartbeat. The timer structures function is |
| 208 | * already set when this is initially called. A tunable is used to |
| 209 | * specify when the next timeout should occur. |
| 210 | */ |
| 211 | static void |
| 212 | xpc_hb_beater(unsigned long dummy) |
| 213 | { |
| 214 | xpc_vars->heartbeat++; |
| 215 | |
Robert P. J. Day | d167cb8 | 2008-03-29 10:05:30 -0400 | [diff] [blame] | 216 | if (time_after_eq(jiffies, xpc_hb_check_timeout)) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 217 | wake_up_interruptible(&xpc_act_IRQ_wq); |
| 218 | } |
| 219 | |
| 220 | xpc_hb_timer.expires = jiffies + (xpc_hb_interval * HZ); |
| 221 | add_timer(&xpc_hb_timer); |
| 222 | } |
| 223 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 224 | /* |
| 225 | * This thread is responsible for nearly all of the partition |
| 226 | * activation/deactivation. |
| 227 | */ |
| 228 | static int |
| 229 | xpc_hb_checker(void *ignore) |
| 230 | { |
| 231 | int last_IRQ_count = 0; |
| 232 | int new_IRQ_count; |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 233 | int force_IRQ = 0; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 234 | |
| 235 | /* this thread was marked active by xpc_hb_init() */ |
| 236 | |
| 237 | daemonize(XPC_HB_CHECK_THREAD_NAME); |
| 238 | |
| 239 | set_cpus_allowed(current, cpumask_of_cpu(XPC_HB_CHECK_CPU)); |
| 240 | |
Dean Nelson | 4c013f5 | 2007-11-07 07:53:06 -0600 | [diff] [blame] | 241 | /* set our heartbeating to other partitions into motion */ |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 242 | xpc_hb_check_timeout = jiffies + (xpc_hb_check_interval * HZ); |
Dean Nelson | 4c013f5 | 2007-11-07 07:53:06 -0600 | [diff] [blame] | 243 | xpc_hb_beater(0); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 244 | |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 245 | while (!(volatile int)xpc_exiting) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 246 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 247 | dev_dbg(xpc_part, "woke up with %d ticks rem; %d IRQs have " |
| 248 | "been received\n", |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 249 | (int)(xpc_hb_check_timeout - jiffies), |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 250 | atomic_read(&xpc_act_IRQ_rcvd) - last_IRQ_count); |
| 251 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 252 | /* checking of remote heartbeats is skewed by IRQ handling */ |
Robert P. J. Day | d167cb8 | 2008-03-29 10:05:30 -0400 | [diff] [blame] | 253 | if (time_after_eq(jiffies, xpc_hb_check_timeout)) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 254 | dev_dbg(xpc_part, "checking remote heartbeats\n"); |
| 255 | xpc_check_remote_hb(); |
| 256 | |
| 257 | /* |
| 258 | * We need to periodically recheck to ensure no |
| 259 | * IPI/AMO pairs have been missed. That check |
| 260 | * must always reset xpc_hb_check_timeout. |
| 261 | */ |
| 262 | force_IRQ = 1; |
| 263 | } |
| 264 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 265 | /* check for outstanding IRQs */ |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 266 | new_IRQ_count = atomic_read(&xpc_act_IRQ_rcvd); |
| 267 | if (last_IRQ_count < new_IRQ_count || force_IRQ != 0) { |
| 268 | force_IRQ = 0; |
| 269 | |
| 270 | dev_dbg(xpc_part, "found an IRQ to process; will be " |
| 271 | "resetting xpc_hb_check_timeout\n"); |
| 272 | |
| 273 | last_IRQ_count += xpc_identify_act_IRQ_sender(); |
| 274 | if (last_IRQ_count < new_IRQ_count) { |
| 275 | /* retry once to help avoid missing AMO */ |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 276 | (void)xpc_identify_act_IRQ_sender(); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 277 | } |
| 278 | last_IRQ_count = new_IRQ_count; |
| 279 | |
| 280 | xpc_hb_check_timeout = jiffies + |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 281 | (xpc_hb_check_interval * HZ); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 282 | } |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 283 | |
| 284 | /* wait for IRQ or timeout */ |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 285 | (void)wait_event_interruptible(xpc_act_IRQ_wq, |
| 286 | (last_IRQ_count < |
| 287 | atomic_read(&xpc_act_IRQ_rcvd) |
| 288 | || time_after_eq(jiffies, |
| 289 | xpc_hb_check_timeout) || |
| 290 | (volatile int)xpc_exiting)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | dev_dbg(xpc_part, "heartbeat checker is exiting\n"); |
| 294 | |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 295 | /* mark this thread as having exited */ |
Jes Sorensen | f9e505a | 2006-01-17 12:52:21 -0500 | [diff] [blame] | 296 | complete(&xpc_hb_checker_exited); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 297 | return 0; |
| 298 | } |
| 299 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 300 | /* |
| 301 | * This thread will attempt to discover other partitions to activate |
| 302 | * based on info provided by SAL. This new thread is short lived and |
| 303 | * will exit once discovery is complete. |
| 304 | */ |
| 305 | static int |
| 306 | xpc_initiate_discovery(void *ignore) |
| 307 | { |
| 308 | daemonize(XPC_DISCOVERY_THREAD_NAME); |
| 309 | |
| 310 | xpc_discovery(); |
| 311 | |
| 312 | dev_dbg(xpc_part, "discovery thread is exiting\n"); |
| 313 | |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 314 | /* mark this thread as having exited */ |
Jes Sorensen | f9e505a | 2006-01-17 12:52:21 -0500 | [diff] [blame] | 315 | complete(&xpc_discovery_exited); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 316 | return 0; |
| 317 | } |
| 318 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 319 | /* |
| 320 | * Establish first contact with the remote partititon. This involves pulling |
| 321 | * the XPC per partition variables from the remote partition and waiting for |
| 322 | * the remote partition to pull ours. |
| 323 | */ |
| 324 | static enum xpc_retval |
| 325 | xpc_make_first_contact(struct xpc_partition *part) |
| 326 | { |
| 327 | enum xpc_retval ret; |
| 328 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 329 | while ((ret = xpc_pull_remote_vars_part(part)) != xpcSuccess) { |
| 330 | if (ret != xpcRetry) { |
| 331 | XPC_DEACTIVATE_PARTITION(part, ret); |
| 332 | return ret; |
| 333 | } |
| 334 | |
| 335 | dev_dbg(xpc_chan, "waiting to make first contact with " |
| 336 | "partition %d\n", XPC_PARTID(part)); |
| 337 | |
| 338 | /* wait a 1/4 of a second or so */ |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 339 | (void)msleep_interruptible(250); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 340 | |
| 341 | if (part->act_state == XPC_P_DEACTIVATING) { |
| 342 | return part->reason; |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | return xpc_mark_partition_active(part); |
| 347 | } |
| 348 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 349 | /* |
| 350 | * The first kthread assigned to a newly activated partition is the one |
| 351 | * created by XPC HB with which it calls xpc_partition_up(). XPC hangs on to |
| 352 | * that kthread until the partition is brought down, at which time that kthread |
| 353 | * returns back to XPC HB. (The return of that kthread will signify to XPC HB |
| 354 | * that XPC has dismantled all communication infrastructure for the associated |
| 355 | * partition.) This kthread becomes the channel manager for that partition. |
| 356 | * |
| 357 | * Each active partition has a channel manager, who, besides connecting and |
| 358 | * disconnecting channels, will ensure that each of the partition's connected |
| 359 | * channels has the required number of assigned kthreads to get the work done. |
| 360 | */ |
| 361 | static void |
| 362 | xpc_channel_mgr(struct xpc_partition *part) |
| 363 | { |
| 364 | while (part->act_state != XPC_P_DEACTIVATING || |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 365 | atomic_read(&part->nchannels_active) > 0 || |
| 366 | !xpc_partition_disengaged(part)) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 367 | |
| 368 | xpc_process_channel_activity(part); |
| 369 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 370 | /* |
| 371 | * Wait until we've been requested to activate kthreads or |
| 372 | * all of the channel's message queues have been torn down or |
| 373 | * a signal is pending. |
| 374 | * |
| 375 | * The channel_mgr_requests is set to 1 after being awakened, |
| 376 | * This is done to prevent the channel mgr from making one pass |
| 377 | * through the loop for each request, since he will |
| 378 | * be servicing all the requests in one pass. The reason it's |
| 379 | * set to 1 instead of 0 is so that other kthreads will know |
| 380 | * that the channel mgr is running and won't bother trying to |
| 381 | * wake him up. |
| 382 | */ |
| 383 | atomic_dec(&part->channel_mgr_requests); |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 384 | (void)wait_event_interruptible(part->channel_mgr_wq, |
| 385 | (atomic_read |
| 386 | (&part->channel_mgr_requests) > |
| 387 | 0 || |
| 388 | (volatile u64)part-> |
| 389 | local_IPI_amo != 0 || |
| 390 | ((volatile u8)part->act_state == |
| 391 | XPC_P_DEACTIVATING && |
| 392 | atomic_read(&part-> |
| 393 | nchannels_active) |
| 394 | == 0 && |
| 395 | xpc_partition_disengaged |
| 396 | (part)))); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 397 | atomic_set(&part->channel_mgr_requests, 1); |
| 398 | |
| 399 | // >>> Does it need to wakeup periodically as well? In case we |
| 400 | // >>> miscalculated the #of kthreads to wakeup or create? |
| 401 | } |
| 402 | } |
| 403 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 404 | /* |
| 405 | * When XPC HB determines that a partition has come up, it will create a new |
| 406 | * kthread and that kthread will call this function to attempt to set up the |
| 407 | * basic infrastructure used for Cross Partition Communication with the newly |
| 408 | * upped partition. |
| 409 | * |
| 410 | * The kthread that was created by XPC HB and which setup the XPC |
| 411 | * infrastructure will remain assigned to the partition until the partition |
| 412 | * goes down. At which time the kthread will teardown the XPC infrastructure |
| 413 | * and then exit. |
| 414 | * |
| 415 | * XPC HB will put the remote partition's XPC per partition specific variables |
| 416 | * physical address into xpc_partitions[partid].remote_vars_part_pa prior to |
| 417 | * calling xpc_partition_up(). |
| 418 | */ |
| 419 | static void |
| 420 | xpc_partition_up(struct xpc_partition *part) |
| 421 | { |
| 422 | DBUG_ON(part->channels != NULL); |
| 423 | |
| 424 | dev_dbg(xpc_chan, "activating partition %d\n", XPC_PARTID(part)); |
| 425 | |
| 426 | if (xpc_setup_infrastructure(part) != xpcSuccess) { |
| 427 | return; |
| 428 | } |
| 429 | |
| 430 | /* |
| 431 | * The kthread that XPC HB called us with will become the |
| 432 | * channel manager for this partition. It will not return |
| 433 | * back to XPC HB until the partition's XPC infrastructure |
| 434 | * has been dismantled. |
| 435 | */ |
| 436 | |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 437 | (void)xpc_part_ref(part); /* this will always succeed */ |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 438 | |
| 439 | if (xpc_make_first_contact(part) == xpcSuccess) { |
| 440 | xpc_channel_mgr(part); |
| 441 | } |
| 442 | |
| 443 | xpc_part_deref(part); |
| 444 | |
| 445 | xpc_teardown_infrastructure(part); |
| 446 | } |
| 447 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 448 | static int |
| 449 | xpc_activating(void *__partid) |
| 450 | { |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 451 | partid_t partid = (u64)__partid; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 452 | struct xpc_partition *part = &xpc_partitions[partid]; |
| 453 | unsigned long irq_flags; |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 454 | struct sched_param param = {.sched_priority = MAX_RT_PRIO - 1 }; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 455 | int ret; |
| 456 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 457 | DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS); |
| 458 | |
| 459 | spin_lock_irqsave(&part->act_lock, irq_flags); |
| 460 | |
| 461 | if (part->act_state == XPC_P_DEACTIVATING) { |
| 462 | part->act_state = XPC_P_INACTIVE; |
| 463 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
| 464 | part->remote_rp_pa = 0; |
| 465 | return 0; |
| 466 | } |
| 467 | |
| 468 | /* indicate the thread is activating */ |
| 469 | DBUG_ON(part->act_state != XPC_P_ACTIVATION_REQ); |
| 470 | part->act_state = XPC_P_ACTIVATING; |
| 471 | |
| 472 | XPC_SET_REASON(part, 0, 0); |
| 473 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
| 474 | |
| 475 | dev_dbg(xpc_part, "bringing partition %d up\n", partid); |
| 476 | |
| 477 | daemonize("xpc%02d", partid); |
| 478 | |
| 479 | /* |
| 480 | * This thread needs to run at a realtime priority to prevent a |
| 481 | * significant performance degradation. |
| 482 | */ |
| 483 | ret = sched_setscheduler(current, SCHED_FIFO, ¶m); |
| 484 | if (ret != 0) { |
| 485 | dev_warn(xpc_part, "unable to set pid %d to a realtime " |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 486 | "priority, ret=%d\n", current->pid, ret); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 487 | } |
| 488 | |
| 489 | /* allow this thread and its children to run on any CPU */ |
| 490 | set_cpus_allowed(current, CPU_MASK_ALL); |
| 491 | |
| 492 | /* |
| 493 | * Register the remote partition's AMOs with SAL so it can handle |
| 494 | * and cleanup errors within that address range should the remote |
| 495 | * partition go down. We don't unregister this range because it is |
| 496 | * difficult to tell when outstanding writes to the remote partition |
| 497 | * are finished and thus when it is safe to unregister. This should |
| 498 | * not result in wasted space in the SAL xp_addr_region table because |
| 499 | * we should get the same page for remote_amos_page_pa after module |
| 500 | * reloads and system reboots. |
| 501 | */ |
| 502 | if (sn_register_xp_addr_region(part->remote_amos_page_pa, |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 503 | PAGE_SIZE, 1) < 0) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 504 | dev_warn(xpc_part, "xpc_partition_up(%d) failed to register " |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 505 | "xp_addr region\n", partid); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 506 | |
| 507 | spin_lock_irqsave(&part->act_lock, irq_flags); |
| 508 | part->act_state = XPC_P_INACTIVE; |
| 509 | XPC_SET_REASON(part, xpcPhysAddrRegFailed, __LINE__); |
| 510 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
| 511 | part->remote_rp_pa = 0; |
| 512 | return 0; |
| 513 | } |
| 514 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 515 | xpc_allow_hb(partid, xpc_vars); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 516 | xpc_IPI_send_activated(part); |
| 517 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 518 | /* |
| 519 | * xpc_partition_up() holds this thread and marks this partition as |
| 520 | * XPC_P_ACTIVE by calling xpc_hb_mark_active(). |
| 521 | */ |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 522 | (void)xpc_partition_up(part); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 523 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 524 | xpc_disallow_hb(partid, xpc_vars); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 525 | xpc_mark_partition_inactive(part); |
| 526 | |
| 527 | if (part->reason == xpcReactivating) { |
| 528 | /* interrupting ourselves results in activating partition */ |
| 529 | xpc_IPI_send_reactivate(part); |
| 530 | } |
| 531 | |
| 532 | return 0; |
| 533 | } |
| 534 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 535 | void |
| 536 | xpc_activate_partition(struct xpc_partition *part) |
| 537 | { |
| 538 | partid_t partid = XPC_PARTID(part); |
| 539 | unsigned long irq_flags; |
| 540 | pid_t pid; |
| 541 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 542 | spin_lock_irqsave(&part->act_lock, irq_flags); |
| 543 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 544 | DBUG_ON(part->act_state != XPC_P_INACTIVE); |
| 545 | |
Robin Holt | 7c6c663 | 2006-02-02 12:30:21 -0600 | [diff] [blame] | 546 | part->act_state = XPC_P_ACTIVATION_REQ; |
| 547 | XPC_SET_REASON(part, xpcCloneKThread, __LINE__); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 548 | |
| 549 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
Robin Holt | 7c6c663 | 2006-02-02 12:30:21 -0600 | [diff] [blame] | 550 | |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 551 | pid = kernel_thread(xpc_activating, (void *)((u64)partid), 0); |
Robin Holt | 7c6c663 | 2006-02-02 12:30:21 -0600 | [diff] [blame] | 552 | |
| 553 | if (unlikely(pid <= 0)) { |
| 554 | spin_lock_irqsave(&part->act_lock, irq_flags); |
| 555 | part->act_state = XPC_P_INACTIVE; |
| 556 | XPC_SET_REASON(part, xpcCloneKThreadFailed, __LINE__); |
| 557 | spin_unlock_irqrestore(&part->act_lock, irq_flags); |
| 558 | } |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 559 | } |
| 560 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 561 | /* |
| 562 | * Handle the receipt of a SGI_XPC_NOTIFY IRQ by seeing whether the specified |
| 563 | * partition actually sent it. Since SGI_XPC_NOTIFY IRQs may be shared by more |
| 564 | * than one partition, we use an AMO_t structure per partition to indicate |
| 565 | * whether a partition has sent an IPI or not. >>> If it has, then wake up the |
| 566 | * associated kthread to handle it. |
| 567 | * |
| 568 | * All SGI_XPC_NOTIFY IRQs received by XPC are the result of IPIs sent by XPC |
| 569 | * running on other partitions. |
| 570 | * |
| 571 | * Noteworthy Arguments: |
| 572 | * |
| 573 | * irq - Interrupt ReQuest number. NOT USED. |
| 574 | * |
| 575 | * dev_id - partid of IPI's potential sender. |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 576 | */ |
| 577 | irqreturn_t |
Al Viro | 5dcded1 | 2006-10-08 14:59:19 +0100 | [diff] [blame] | 578 | xpc_notify_IRQ_handler(int irq, void *dev_id) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 579 | { |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 580 | partid_t partid = (partid_t) (u64)dev_id; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 581 | struct xpc_partition *part = &xpc_partitions[partid]; |
| 582 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 583 | DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS); |
| 584 | |
| 585 | if (xpc_part_ref(part)) { |
| 586 | xpc_check_for_channel_activity(part); |
| 587 | |
| 588 | xpc_part_deref(part); |
| 589 | } |
| 590 | return IRQ_HANDLED; |
| 591 | } |
| 592 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 593 | /* |
| 594 | * Check to see if xpc_notify_IRQ_handler() dropped any IPIs on the floor |
| 595 | * because the write to their associated IPI amo completed after the IRQ/IPI |
| 596 | * was received. |
| 597 | */ |
| 598 | void |
| 599 | xpc_dropped_IPI_check(struct xpc_partition *part) |
| 600 | { |
| 601 | if (xpc_part_ref(part)) { |
| 602 | xpc_check_for_channel_activity(part); |
| 603 | |
| 604 | part->dropped_IPI_timer.expires = jiffies + |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 605 | XPC_P_DROPPED_IPI_WAIT; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 606 | add_timer(&part->dropped_IPI_timer); |
| 607 | xpc_part_deref(part); |
| 608 | } |
| 609 | } |
| 610 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 611 | void |
| 612 | xpc_activate_kthreads(struct xpc_channel *ch, int needed) |
| 613 | { |
| 614 | int idle = atomic_read(&ch->kthreads_idle); |
| 615 | int assigned = atomic_read(&ch->kthreads_assigned); |
| 616 | int wakeup; |
| 617 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 618 | DBUG_ON(needed <= 0); |
| 619 | |
| 620 | if (idle > 0) { |
| 621 | wakeup = (needed > idle) ? idle : needed; |
| 622 | needed -= wakeup; |
| 623 | |
| 624 | dev_dbg(xpc_chan, "wakeup %d idle kthreads, partid=%d, " |
| 625 | "channel=%d\n", wakeup, ch->partid, ch->number); |
| 626 | |
| 627 | /* only wakeup the requested number of kthreads */ |
| 628 | wake_up_nr(&ch->idle_wq, wakeup); |
| 629 | } |
| 630 | |
| 631 | if (needed <= 0) { |
| 632 | return; |
| 633 | } |
| 634 | |
| 635 | if (needed + assigned > ch->kthreads_assigned_limit) { |
| 636 | needed = ch->kthreads_assigned_limit - assigned; |
| 637 | // >>>should never be less than 0 |
| 638 | if (needed <= 0) { |
| 639 | return; |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | dev_dbg(xpc_chan, "create %d new kthreads, partid=%d, channel=%d\n", |
| 644 | needed, ch->partid, ch->number); |
| 645 | |
Dean Nelson | a460ef8 | 2006-11-22 08:25:00 -0600 | [diff] [blame] | 646 | xpc_create_kthreads(ch, needed, 0); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 647 | } |
| 648 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 649 | /* |
| 650 | * This function is where XPC's kthreads wait for messages to deliver. |
| 651 | */ |
| 652 | static void |
| 653 | xpc_kthread_waitmsgs(struct xpc_partition *part, struct xpc_channel *ch) |
| 654 | { |
| 655 | do { |
| 656 | /* deliver messages to their intended recipients */ |
| 657 | |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 658 | while ((volatile s64)ch->w_local_GP.get < |
| 659 | (volatile s64)ch->w_remote_GP.put && |
| 660 | !((volatile u32)ch->flags & XPC_C_DISCONNECTING)) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 661 | xpc_deliver_msg(ch); |
| 662 | } |
| 663 | |
| 664 | if (atomic_inc_return(&ch->kthreads_idle) > |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 665 | ch->kthreads_idle_limit) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 666 | /* too many idle kthreads on this channel */ |
| 667 | atomic_dec(&ch->kthreads_idle); |
| 668 | break; |
| 669 | } |
| 670 | |
| 671 | dev_dbg(xpc_chan, "idle kthread calling " |
| 672 | "wait_event_interruptible_exclusive()\n"); |
| 673 | |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 674 | (void)wait_event_interruptible_exclusive(ch->idle_wq, |
| 675 | ((volatile s64)ch-> |
| 676 | w_local_GP.get < |
| 677 | (volatile s64)ch-> |
| 678 | w_remote_GP.put || |
| 679 | ((volatile u32)ch-> |
| 680 | flags & |
| 681 | XPC_C_DISCONNECTING))); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 682 | |
| 683 | atomic_dec(&ch->kthreads_idle); |
| 684 | |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 685 | } while (!((volatile u32)ch->flags & XPC_C_DISCONNECTING)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 686 | } |
| 687 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 688 | static int |
| 689 | xpc_daemonize_kthread(void *args) |
| 690 | { |
| 691 | partid_t partid = XPC_UNPACK_ARG1(args); |
| 692 | u16 ch_number = XPC_UNPACK_ARG2(args); |
| 693 | struct xpc_partition *part = &xpc_partitions[partid]; |
| 694 | struct xpc_channel *ch; |
| 695 | int n_needed; |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 696 | unsigned long irq_flags; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 697 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 698 | daemonize("xpc%02dc%d", partid, ch_number); |
| 699 | |
| 700 | dev_dbg(xpc_chan, "kthread starting, partid=%d, channel=%d\n", |
| 701 | partid, ch_number); |
| 702 | |
| 703 | ch = &part->channels[ch_number]; |
| 704 | |
| 705 | if (!(ch->flags & XPC_C_DISCONNECTING)) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 706 | |
| 707 | /* let registerer know that connection has been established */ |
| 708 | |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 709 | spin_lock_irqsave(&ch->lock, irq_flags); |
Dean Nelson | 4c2cd96 | 2006-02-15 08:02:21 -0600 | [diff] [blame] | 710 | if (!(ch->flags & XPC_C_CONNECTEDCALLOUT)) { |
| 711 | ch->flags |= XPC_C_CONNECTEDCALLOUT; |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 712 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
| 713 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 714 | xpc_connected_callout(ch); |
| 715 | |
Dean Nelson | 4c2cd96 | 2006-02-15 08:02:21 -0600 | [diff] [blame] | 716 | spin_lock_irqsave(&ch->lock, irq_flags); |
| 717 | ch->flags |= XPC_C_CONNECTEDCALLOUT_MADE; |
| 718 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
| 719 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 720 | /* |
| 721 | * It is possible that while the callout was being |
| 722 | * made that the remote partition sent some messages. |
| 723 | * If that is the case, we may need to activate |
| 724 | * additional kthreads to help deliver them. We only |
| 725 | * need one less than total #of messages to deliver. |
| 726 | */ |
| 727 | n_needed = ch->w_remote_GP.put - ch->w_local_GP.get - 1; |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 728 | if (n_needed > 0 && !(ch->flags & XPC_C_DISCONNECTING)) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 729 | xpc_activate_kthreads(ch, n_needed); |
| 730 | } |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 731 | } else { |
| 732 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 733 | } |
| 734 | |
| 735 | xpc_kthread_waitmsgs(part, ch); |
| 736 | } |
| 737 | |
Dean Nelson | a460ef8 | 2006-11-22 08:25:00 -0600 | [diff] [blame] | 738 | /* let registerer know that connection is disconnecting */ |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 739 | |
Dean Nelson | a460ef8 | 2006-11-22 08:25:00 -0600 | [diff] [blame] | 740 | spin_lock_irqsave(&ch->lock, irq_flags); |
| 741 | if ((ch->flags & XPC_C_CONNECTEDCALLOUT_MADE) && |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 742 | !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) { |
Dean Nelson | a460ef8 | 2006-11-22 08:25:00 -0600 | [diff] [blame] | 743 | ch->flags |= XPC_C_DISCONNECTINGCALLOUT; |
Dean Nelson | 4c2cd96 | 2006-02-15 08:02:21 -0600 | [diff] [blame] | 744 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
Dean Nelson | a460ef8 | 2006-11-22 08:25:00 -0600 | [diff] [blame] | 745 | |
| 746 | xpc_disconnect_callout(ch, xpcDisconnecting); |
| 747 | |
| 748 | spin_lock_irqsave(&ch->lock, irq_flags); |
| 749 | ch->flags |= XPC_C_DISCONNECTINGCALLOUT_MADE; |
| 750 | } |
| 751 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
| 752 | |
| 753 | if (atomic_dec_return(&ch->kthreads_assigned) == 0) { |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 754 | if (atomic_dec_return(&part->nchannels_engaged) == 0) { |
| 755 | xpc_mark_partition_disengaged(part); |
| 756 | xpc_IPI_send_disengage(part); |
| 757 | } |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 758 | } |
| 759 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 760 | xpc_msgqueue_deref(ch); |
| 761 | |
| 762 | dev_dbg(xpc_chan, "kthread exiting, partid=%d, channel=%d\n", |
| 763 | partid, ch_number); |
| 764 | |
| 765 | xpc_part_deref(part); |
| 766 | return 0; |
| 767 | } |
| 768 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 769 | /* |
| 770 | * For each partition that XPC has established communications with, there is |
| 771 | * a minimum of one kernel thread assigned to perform any operation that |
| 772 | * may potentially sleep or block (basically the callouts to the asynchronous |
| 773 | * functions registered via xpc_connect()). |
| 774 | * |
| 775 | * Additional kthreads are created and destroyed by XPC as the workload |
| 776 | * demands. |
| 777 | * |
| 778 | * A kthread is assigned to one of the active channels that exists for a given |
| 779 | * partition. |
| 780 | */ |
| 781 | void |
Dean Nelson | a460ef8 | 2006-11-22 08:25:00 -0600 | [diff] [blame] | 782 | xpc_create_kthreads(struct xpc_channel *ch, int needed, |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 783 | int ignore_disconnecting) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 784 | { |
| 785 | unsigned long irq_flags; |
| 786 | pid_t pid; |
| 787 | u64 args = XPC_PACK_ARGS(ch->partid, ch->number); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 788 | struct xpc_partition *part = &xpc_partitions[ch->partid]; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 789 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 790 | while (needed-- > 0) { |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 791 | |
| 792 | /* |
| 793 | * The following is done on behalf of the newly created |
| 794 | * kthread. That kthread is responsible for doing the |
| 795 | * counterpart to the following before it exits. |
| 796 | */ |
Dean Nelson | a460ef8 | 2006-11-22 08:25:00 -0600 | [diff] [blame] | 797 | if (ignore_disconnecting) { |
| 798 | if (!atomic_inc_not_zero(&ch->kthreads_assigned)) { |
| 799 | /* kthreads assigned had gone to zero */ |
| 800 | BUG_ON(!(ch->flags & |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 801 | XPC_C_DISCONNECTINGCALLOUT_MADE)); |
Dean Nelson | a460ef8 | 2006-11-22 08:25:00 -0600 | [diff] [blame] | 802 | break; |
| 803 | } |
| 804 | |
| 805 | } else if (ch->flags & XPC_C_DISCONNECTING) { |
| 806 | break; |
| 807 | |
| 808 | } else if (atomic_inc_return(&ch->kthreads_assigned) == 1) { |
| 809 | if (atomic_inc_return(&part->nchannels_engaged) == 1) |
| 810 | xpc_mark_partition_engaged(part); |
| 811 | } |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 812 | (void)xpc_part_ref(part); |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 813 | xpc_msgqueue_ref(ch); |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 814 | |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 815 | pid = kernel_thread(xpc_daemonize_kthread, (void *)args, 0); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 816 | if (pid < 0) { |
| 817 | /* the fork failed */ |
Dean Nelson | a460ef8 | 2006-11-22 08:25:00 -0600 | [diff] [blame] | 818 | |
| 819 | /* |
| 820 | * NOTE: if (ignore_disconnecting && |
| 821 | * !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) is true, |
| 822 | * then we'll deadlock if all other kthreads assigned |
| 823 | * to this channel are blocked in the channel's |
| 824 | * registerer, because the only thing that will unblock |
| 825 | * them is the xpcDisconnecting callout that this |
| 826 | * failed kernel_thread would have made. |
| 827 | */ |
| 828 | |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 829 | if (atomic_dec_return(&ch->kthreads_assigned) == 0 && |
| 830 | atomic_dec_return(&part->nchannels_engaged) == 0) { |
| 831 | xpc_mark_partition_disengaged(part); |
| 832 | xpc_IPI_send_disengage(part); |
| 833 | } |
| 834 | xpc_msgqueue_deref(ch); |
| 835 | xpc_part_deref(part); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 836 | |
| 837 | if (atomic_read(&ch->kthreads_assigned) < |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 838 | ch->kthreads_idle_limit) { |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 839 | /* |
| 840 | * Flag this as an error only if we have an |
| 841 | * insufficient #of kthreads for the channel |
| 842 | * to function. |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 843 | */ |
| 844 | spin_lock_irqsave(&ch->lock, irq_flags); |
| 845 | XPC_DISCONNECT_CHANNEL(ch, xpcLackOfResources, |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 846 | &irq_flags); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 847 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
| 848 | } |
| 849 | break; |
| 850 | } |
| 851 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 852 | ch->kthreads_created++; // >>> temporary debug only!!! |
| 853 | } |
| 854 | } |
| 855 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 856 | void |
| 857 | xpc_disconnect_wait(int ch_number) |
| 858 | { |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 859 | unsigned long irq_flags; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 860 | partid_t partid; |
| 861 | struct xpc_partition *part; |
| 862 | struct xpc_channel *ch; |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 863 | int wakeup_channel_mgr; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 864 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 865 | /* now wait for all callouts to the caller's function to cease */ |
| 866 | for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) { |
| 867 | part = &xpc_partitions[partid]; |
| 868 | |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 869 | if (!xpc_part_ref(part)) { |
| 870 | continue; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 871 | } |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 872 | |
| 873 | ch = &part->channels[ch_number]; |
| 874 | |
| 875 | if (!(ch->flags & XPC_C_WDISCONNECT)) { |
| 876 | xpc_part_deref(part); |
| 877 | continue; |
| 878 | } |
| 879 | |
Jes Sorensen | f9e505a | 2006-01-17 12:52:21 -0500 | [diff] [blame] | 880 | wait_for_completion(&ch->wdisconnect_wait); |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 881 | |
| 882 | spin_lock_irqsave(&ch->lock, irq_flags); |
| 883 | DBUG_ON(!(ch->flags & XPC_C_DISCONNECTED)); |
| 884 | wakeup_channel_mgr = 0; |
| 885 | |
| 886 | if (ch->delayed_IPI_flags) { |
| 887 | if (part->act_state != XPC_P_DEACTIVATING) { |
| 888 | spin_lock(&part->IPI_lock); |
| 889 | XPC_SET_IPI_FLAGS(part->local_IPI_amo, |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 890 | ch->number, |
| 891 | ch->delayed_IPI_flags); |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 892 | spin_unlock(&part->IPI_lock); |
| 893 | wakeup_channel_mgr = 1; |
| 894 | } |
| 895 | ch->delayed_IPI_flags = 0; |
| 896 | } |
| 897 | |
| 898 | ch->flags &= ~XPC_C_WDISCONNECT; |
| 899 | spin_unlock_irqrestore(&ch->lock, irq_flags); |
| 900 | |
| 901 | if (wakeup_channel_mgr) { |
| 902 | xpc_wakeup_channel_mgr(part); |
| 903 | } |
| 904 | |
| 905 | xpc_part_deref(part); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 906 | } |
| 907 | } |
| 908 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 909 | static void |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 910 | xpc_do_exit(enum xpc_retval reason) |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 911 | { |
| 912 | partid_t partid; |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 913 | int active_part_count, printed_waiting_msg = 0; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 914 | struct xpc_partition *part; |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 915 | unsigned long printmsg_time, disengage_request_timeout = 0; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 916 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 917 | /* a 'rmmod XPC' and a 'reboot' cannot both end up here together */ |
| 918 | DBUG_ON(xpc_exiting == 1); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 919 | |
| 920 | /* |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 921 | * Let the heartbeat checker thread and the discovery thread |
| 922 | * (if one is running) know that they should exit. Also wake up |
| 923 | * the heartbeat checker thread in case it's sleeping. |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 924 | */ |
| 925 | xpc_exiting = 1; |
| 926 | wake_up_interruptible(&xpc_act_IRQ_wq); |
| 927 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 928 | /* ignore all incoming interrupts */ |
| 929 | free_irq(SGI_XPC_ACTIVATE, NULL); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 930 | |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 931 | /* wait for the discovery thread to exit */ |
Jes Sorensen | f9e505a | 2006-01-17 12:52:21 -0500 | [diff] [blame] | 932 | wait_for_completion(&xpc_discovery_exited); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 933 | |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 934 | /* wait for the heartbeat checker thread to exit */ |
Jes Sorensen | f9e505a | 2006-01-17 12:52:21 -0500 | [diff] [blame] | 935 | wait_for_completion(&xpc_hb_checker_exited); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 936 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 937 | /* sleep for a 1/3 of a second or so */ |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 938 | (void)msleep_interruptible(300); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 939 | |
| 940 | /* wait for all partitions to become inactive */ |
| 941 | |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 942 | printmsg_time = jiffies + (XPC_DISENGAGE_PRINTMSG_INTERVAL * HZ); |
| 943 | xpc_disengage_request_timedout = 0; |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 944 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 945 | do { |
| 946 | active_part_count = 0; |
| 947 | |
| 948 | for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) { |
| 949 | part = &xpc_partitions[partid]; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 950 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 951 | if (xpc_partition_disengaged(part) && |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 952 | part->act_state == XPC_P_INACTIVE) { |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 953 | continue; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 954 | } |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 955 | |
| 956 | active_part_count++; |
| 957 | |
| 958 | XPC_DEACTIVATE_PARTITION(part, reason); |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 959 | |
| 960 | if (part->disengage_request_timeout > |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 961 | disengage_request_timeout) { |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 962 | disengage_request_timeout = |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 963 | part->disengage_request_timeout; |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 964 | } |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 965 | } |
| 966 | |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 967 | if (xpc_partition_engaged(-1UL)) { |
| 968 | if (time_after(jiffies, printmsg_time)) { |
| 969 | dev_info(xpc_part, "waiting for remote " |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 970 | "partitions to disengage, timeout in " |
| 971 | "%ld seconds\n", |
| 972 | (disengage_request_timeout - jiffies) |
| 973 | / HZ); |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 974 | printmsg_time = jiffies + |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 975 | (XPC_DISENGAGE_PRINTMSG_INTERVAL * HZ); |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 976 | printed_waiting_msg = 1; |
| 977 | } |
| 978 | |
| 979 | } else if (active_part_count > 0) { |
| 980 | if (printed_waiting_msg) { |
| 981 | dev_info(xpc_part, "waiting for local partition" |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 982 | " to disengage\n"); |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 983 | printed_waiting_msg = 0; |
| 984 | } |
| 985 | |
| 986 | } else { |
| 987 | if (!xpc_disengage_request_timedout) { |
| 988 | dev_info(xpc_part, "all partitions have " |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 989 | "disengaged\n"); |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 990 | } |
| 991 | break; |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 992 | } |
| 993 | |
| 994 | /* sleep for a 1/3 of a second or so */ |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 995 | (void)msleep_interruptible(300); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 996 | |
| 997 | } while (1); |
| 998 | |
| 999 | DBUG_ON(xpc_partition_engaged(-1UL)); |
| 1000 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1001 | /* indicate to others that our reserved page is uninitialized */ |
| 1002 | xpc_rsvd_page->vars_pa = 0; |
| 1003 | |
| 1004 | /* now it's time to eliminate our heartbeat */ |
| 1005 | del_timer_sync(&xpc_hb_timer); |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 1006 | DBUG_ON(xpc_vars->heartbeating_to_mask != 0); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1007 | |
Dean Nelson | 0752c67 | 2006-01-10 11:07:19 -0600 | [diff] [blame] | 1008 | if (reason == xpcUnloading) { |
| 1009 | /* take ourselves off of the reboot_notifier_list */ |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1010 | (void)unregister_reboot_notifier(&xpc_reboot_notifier); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1011 | |
Dean Nelson | 0752c67 | 2006-01-10 11:07:19 -0600 | [diff] [blame] | 1012 | /* take ourselves off of the die_notifier list */ |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1013 | (void)unregister_die_notifier(&xpc_die_notifier); |
Dean Nelson | 0752c67 | 2006-01-10 11:07:19 -0600 | [diff] [blame] | 1014 | } |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1015 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1016 | /* close down protections for IPI operations */ |
| 1017 | xpc_restrict_IPI_ops(); |
| 1018 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1019 | /* clear the interface to XPC's functions */ |
| 1020 | xpc_clear_interface(); |
| 1021 | |
| 1022 | if (xpc_sysctl) { |
| 1023 | unregister_sysctl_table(xpc_sysctl); |
| 1024 | } |
Dean Nelson | 7682a4c | 2006-08-08 15:03:29 -0500 | [diff] [blame] | 1025 | |
| 1026 | kfree(xpc_remote_copy_buffer_base); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1027 | } |
| 1028 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1029 | /* |
Dean Nelson | d6ad033 | 2006-01-10 11:08:55 -0600 | [diff] [blame] | 1030 | * This function is called when the system is being rebooted. |
| 1031 | */ |
| 1032 | static int |
| 1033 | xpc_system_reboot(struct notifier_block *nb, unsigned long event, void *unused) |
| 1034 | { |
| 1035 | enum xpc_retval reason; |
| 1036 | |
Dean Nelson | d6ad033 | 2006-01-10 11:08:55 -0600 | [diff] [blame] | 1037 | switch (event) { |
| 1038 | case SYS_RESTART: |
| 1039 | reason = xpcSystemReboot; |
| 1040 | break; |
| 1041 | case SYS_HALT: |
| 1042 | reason = xpcSystemHalt; |
| 1043 | break; |
| 1044 | case SYS_POWER_OFF: |
| 1045 | reason = xpcSystemPoweroff; |
| 1046 | break; |
| 1047 | default: |
| 1048 | reason = xpcSystemGoingDown; |
| 1049 | } |
| 1050 | |
| 1051 | xpc_do_exit(reason); |
| 1052 | return NOTIFY_DONE; |
| 1053 | } |
| 1054 | |
Dean Nelson | d6ad033 | 2006-01-10 11:08:55 -0600 | [diff] [blame] | 1055 | /* |
| 1056 | * Notify other partitions to disengage from all references to our memory. |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1057 | */ |
| 1058 | static void |
| 1059 | xpc_die_disengage(void) |
| 1060 | { |
| 1061 | struct xpc_partition *part; |
| 1062 | partid_t partid; |
| 1063 | unsigned long engaged; |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 1064 | long time, printmsg_time, disengage_request_timeout; |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1065 | |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1066 | /* keep xpc_hb_checker thread from doing anything (just in case) */ |
| 1067 | xpc_exiting = 1; |
| 1068 | |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1069 | xpc_vars->heartbeating_to_mask = 0; /* indicate we're deactivated */ |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1070 | |
| 1071 | for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) { |
| 1072 | part = &xpc_partitions[partid]; |
| 1073 | |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1074 | if (!XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version)) { |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1075 | |
| 1076 | /* just in case it was left set by an earlier XPC */ |
| 1077 | xpc_clear_partition_engaged(1UL << partid); |
| 1078 | continue; |
| 1079 | } |
| 1080 | |
| 1081 | if (xpc_partition_engaged(1UL << partid) || |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1082 | part->act_state != XPC_P_INACTIVE) { |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1083 | xpc_request_partition_disengage(part); |
| 1084 | xpc_mark_partition_disengaged(part); |
| 1085 | xpc_IPI_send_disengage(part); |
| 1086 | } |
| 1087 | } |
| 1088 | |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 1089 | time = rtc_time(); |
| 1090 | printmsg_time = time + |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1091 | (XPC_DISENGAGE_PRINTMSG_INTERVAL * sn_rtc_cycles_per_second); |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 1092 | disengage_request_timeout = time + |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1093 | (xpc_disengage_request_timelimit * sn_rtc_cycles_per_second); |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1094 | |
| 1095 | /* wait for all other partitions to disengage from us */ |
| 1096 | |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 1097 | while (1) { |
| 1098 | engaged = xpc_partition_engaged(-1UL); |
| 1099 | if (!engaged) { |
| 1100 | dev_info(xpc_part, "all partitions have disengaged\n"); |
| 1101 | break; |
| 1102 | } |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1103 | |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 1104 | time = rtc_time(); |
| 1105 | if (time >= disengage_request_timeout) { |
| 1106 | for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) { |
| 1107 | if (engaged & (1UL << partid)) { |
| 1108 | dev_info(xpc_part, "disengage from " |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1109 | "remote partition %d timed " |
| 1110 | "out\n", partid); |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 1111 | } |
| 1112 | } |
| 1113 | break; |
| 1114 | } |
| 1115 | |
| 1116 | if (time >= printmsg_time) { |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1117 | dev_info(xpc_part, "waiting for remote partitions to " |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1118 | "disengage, timeout in %ld seconds\n", |
| 1119 | (disengage_request_timeout - time) / |
| 1120 | sn_rtc_cycles_per_second); |
Dean Nelson | 1ecaded | 2006-01-06 09:48:21 -0600 | [diff] [blame] | 1121 | printmsg_time = time + |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1122 | (XPC_DISENGAGE_PRINTMSG_INTERVAL * |
| 1123 | sn_rtc_cycles_per_second); |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1124 | } |
| 1125 | } |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1126 | } |
| 1127 | |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1128 | /* |
Dean Nelson | 1f4674b | 2006-01-10 11:08:00 -0600 | [diff] [blame] | 1129 | * This function is called when the system is being restarted or halted due |
| 1130 | * to some sort of system failure. If this is the case we need to notify the |
| 1131 | * other partitions to disengage from all references to our memory. |
| 1132 | * This function can also be called when our heartbeater could be offlined |
| 1133 | * for a time. In this case we need to notify other partitions to not worry |
| 1134 | * about the lack of a heartbeat. |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1135 | */ |
| 1136 | static int |
| 1137 | xpc_system_die(struct notifier_block *nb, unsigned long event, void *unused) |
| 1138 | { |
| 1139 | switch (event) { |
| 1140 | case DIE_MACHINE_RESTART: |
| 1141 | case DIE_MACHINE_HALT: |
| 1142 | xpc_die_disengage(); |
| 1143 | break; |
Dean Nelson | 1f4674b | 2006-01-10 11:08:00 -0600 | [diff] [blame] | 1144 | |
| 1145 | case DIE_KDEBUG_ENTER: |
| 1146 | /* Should lack of heartbeat be ignored by other partitions? */ |
| 1147 | if (!xpc_kdebug_ignore) { |
| 1148 | break; |
| 1149 | } |
| 1150 | /* fall through */ |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1151 | case DIE_MCA_MONARCH_ENTER: |
| 1152 | case DIE_INIT_MONARCH_ENTER: |
| 1153 | xpc_vars->heartbeat++; |
| 1154 | xpc_vars->heartbeat_offline = 1; |
| 1155 | break; |
Dean Nelson | 1f4674b | 2006-01-10 11:08:00 -0600 | [diff] [blame] | 1156 | |
| 1157 | case DIE_KDEBUG_LEAVE: |
| 1158 | /* Is lack of heartbeat being ignored by other partitions? */ |
| 1159 | if (!xpc_kdebug_ignore) { |
| 1160 | break; |
| 1161 | } |
| 1162 | /* fall through */ |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1163 | case DIE_MCA_MONARCH_LEAVE: |
| 1164 | case DIE_INIT_MONARCH_LEAVE: |
| 1165 | xpc_vars->heartbeat++; |
| 1166 | xpc_vars->heartbeat_offline = 0; |
| 1167 | break; |
| 1168 | } |
| 1169 | |
| 1170 | return NOTIFY_DONE; |
| 1171 | } |
| 1172 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1173 | int __init |
| 1174 | xpc_init(void) |
| 1175 | { |
| 1176 | int ret; |
| 1177 | partid_t partid; |
| 1178 | struct xpc_partition *part; |
| 1179 | pid_t pid; |
Dean Nelson | 7682a4c | 2006-08-08 15:03:29 -0500 | [diff] [blame] | 1180 | size_t buf_size; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1181 | |
Dean Nelson | 408865c | 2005-09-08 10:46:58 -0500 | [diff] [blame] | 1182 | if (!ia64_platform_is("sn2")) { |
| 1183 | return -ENODEV; |
| 1184 | } |
| 1185 | |
Dean Nelson | 7682a4c | 2006-08-08 15:03:29 -0500 | [diff] [blame] | 1186 | buf_size = max(XPC_RP_VARS_SIZE, |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1187 | XPC_RP_HEADER_SIZE + XP_NASID_MASK_BYTES); |
Dean Nelson | 7682a4c | 2006-08-08 15:03:29 -0500 | [diff] [blame] | 1188 | xpc_remote_copy_buffer = xpc_kmalloc_cacheline_aligned(buf_size, |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1189 | GFP_KERNEL, |
| 1190 | &xpc_remote_copy_buffer_base); |
Dean Nelson | 7682a4c | 2006-08-08 15:03:29 -0500 | [diff] [blame] | 1191 | if (xpc_remote_copy_buffer == NULL) |
| 1192 | return -ENOMEM; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1193 | |
| 1194 | snprintf(xpc_part->bus_id, BUS_ID_SIZE, "part"); |
| 1195 | snprintf(xpc_chan->bus_id, BUS_ID_SIZE, "chan"); |
| 1196 | |
Eric W. Biederman | 0b4d414 | 2007-02-14 00:34:09 -0800 | [diff] [blame] | 1197 | xpc_sysctl = register_sysctl_table(xpc_sys_dir); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1198 | |
| 1199 | /* |
| 1200 | * The first few fields of each entry of xpc_partitions[] need to |
| 1201 | * be initialized now so that calls to xpc_connect() and |
| 1202 | * xpc_disconnect() can be made prior to the activation of any remote |
| 1203 | * partition. NOTE THAT NONE OF THE OTHER FIELDS BELONGING TO THESE |
| 1204 | * ENTRIES ARE MEANINGFUL UNTIL AFTER AN ENTRY'S CORRESPONDING |
| 1205 | * PARTITION HAS BEEN ACTIVATED. |
| 1206 | */ |
| 1207 | for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) { |
| 1208 | part = &xpc_partitions[partid]; |
| 1209 | |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1210 | DBUG_ON((u64)part != L1_CACHE_ALIGN((u64)part)); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1211 | |
| 1212 | part->act_IRQ_rcvd = 0; |
| 1213 | spin_lock_init(&part->act_lock); |
| 1214 | part->act_state = XPC_P_INACTIVE; |
| 1215 | XPC_SET_REASON(part, 0, 0); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1216 | |
| 1217 | init_timer(&part->disengage_request_timer); |
| 1218 | part->disengage_request_timer.function = |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1219 | xpc_timeout_partition_disengage_request; |
| 1220 | part->disengage_request_timer.data = (unsigned long)part; |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1221 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1222 | part->setup_state = XPC_P_UNSET; |
| 1223 | init_waitqueue_head(&part->teardown_wq); |
| 1224 | atomic_set(&part->references, 0); |
| 1225 | } |
| 1226 | |
| 1227 | /* |
| 1228 | * Open up protections for IPI operations (and AMO operations on |
| 1229 | * Shub 1.1 systems). |
| 1230 | */ |
| 1231 | xpc_allow_IPI_ops(); |
| 1232 | |
| 1233 | /* |
| 1234 | * Interrupts being processed will increment this atomic variable and |
| 1235 | * awaken the heartbeat thread which will process the interrupts. |
| 1236 | */ |
| 1237 | atomic_set(&xpc_act_IRQ_rcvd, 0); |
| 1238 | |
| 1239 | /* |
| 1240 | * This is safe to do before the xpc_hb_checker thread has started |
| 1241 | * because the handler releases a wait queue. If an interrupt is |
| 1242 | * received before the thread is waiting, it will not go to sleep, |
| 1243 | * but rather immediately process the interrupt. |
| 1244 | */ |
| 1245 | ret = request_irq(SGI_XPC_ACTIVATE, xpc_act_IRQ_handler, 0, |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1246 | "xpc hb", NULL); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1247 | if (ret != 0) { |
| 1248 | dev_err(xpc_part, "can't register ACTIVATE IRQ handler, " |
| 1249 | "errno=%d\n", -ret); |
| 1250 | |
| 1251 | xpc_restrict_IPI_ops(); |
| 1252 | |
| 1253 | if (xpc_sysctl) { |
| 1254 | unregister_sysctl_table(xpc_sysctl); |
| 1255 | } |
Dean Nelson | 7682a4c | 2006-08-08 15:03:29 -0500 | [diff] [blame] | 1256 | |
| 1257 | kfree(xpc_remote_copy_buffer_base); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1258 | return -EBUSY; |
| 1259 | } |
| 1260 | |
| 1261 | /* |
| 1262 | * Fill the partition reserved page with the information needed by |
| 1263 | * other partitions to discover we are alive and establish initial |
| 1264 | * communications. |
| 1265 | */ |
| 1266 | xpc_rsvd_page = xpc_rsvd_page_init(); |
| 1267 | if (xpc_rsvd_page == NULL) { |
| 1268 | dev_err(xpc_part, "could not setup our reserved page\n"); |
| 1269 | |
| 1270 | free_irq(SGI_XPC_ACTIVATE, NULL); |
| 1271 | xpc_restrict_IPI_ops(); |
| 1272 | |
| 1273 | if (xpc_sysctl) { |
| 1274 | unregister_sysctl_table(xpc_sysctl); |
| 1275 | } |
Dean Nelson | 7682a4c | 2006-08-08 15:03:29 -0500 | [diff] [blame] | 1276 | |
| 1277 | kfree(xpc_remote_copy_buffer_base); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1278 | return -EBUSY; |
| 1279 | } |
| 1280 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1281 | /* add ourselves to the reboot_notifier_list */ |
| 1282 | ret = register_reboot_notifier(&xpc_reboot_notifier); |
| 1283 | if (ret != 0) { |
| 1284 | dev_warn(xpc_part, "can't register reboot notifier\n"); |
| 1285 | } |
| 1286 | |
Christoph Hellwig | 1eeb66a | 2007-05-08 00:27:03 -0700 | [diff] [blame] | 1287 | /* add ourselves to the die_notifier list */ |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1288 | ret = register_die_notifier(&xpc_die_notifier); |
| 1289 | if (ret != 0) { |
| 1290 | dev_warn(xpc_part, "can't register die notifier\n"); |
| 1291 | } |
| 1292 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1293 | init_timer(&xpc_hb_timer); |
| 1294 | xpc_hb_timer.function = xpc_hb_beater; |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1295 | |
| 1296 | /* |
| 1297 | * The real work-horse behind xpc. This processes incoming |
| 1298 | * interrupts and monitors remote heartbeats. |
| 1299 | */ |
| 1300 | pid = kernel_thread(xpc_hb_checker, NULL, 0); |
| 1301 | if (pid < 0) { |
| 1302 | dev_err(xpc_part, "failed while forking hb check thread\n"); |
| 1303 | |
| 1304 | /* indicate to others that our reserved page is uninitialized */ |
| 1305 | xpc_rsvd_page->vars_pa = 0; |
| 1306 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1307 | /* take ourselves off of the reboot_notifier_list */ |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1308 | (void)unregister_reboot_notifier(&xpc_reboot_notifier); |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1309 | |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1310 | /* take ourselves off of the die_notifier list */ |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1311 | (void)unregister_die_notifier(&xpc_die_notifier); |
Dean Nelson | 780d09e | 2005-11-09 14:41:57 -0600 | [diff] [blame] | 1312 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1313 | del_timer_sync(&xpc_hb_timer); |
| 1314 | free_irq(SGI_XPC_ACTIVATE, NULL); |
| 1315 | xpc_restrict_IPI_ops(); |
| 1316 | |
| 1317 | if (xpc_sysctl) { |
| 1318 | unregister_sysctl_table(xpc_sysctl); |
| 1319 | } |
Dean Nelson | 7682a4c | 2006-08-08 15:03:29 -0500 | [diff] [blame] | 1320 | |
| 1321 | kfree(xpc_remote_copy_buffer_base); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1322 | return -EBUSY; |
| 1323 | } |
| 1324 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1325 | /* |
| 1326 | * Startup a thread that will attempt to discover other partitions to |
| 1327 | * activate based on info provided by SAL. This new thread is short |
| 1328 | * lived and will exit once discovery is complete. |
| 1329 | */ |
| 1330 | pid = kernel_thread(xpc_initiate_discovery, NULL, 0); |
| 1331 | if (pid < 0) { |
| 1332 | dev_err(xpc_part, "failed while forking discovery thread\n"); |
| 1333 | |
| 1334 | /* mark this new thread as a non-starter */ |
Jes Sorensen | f9e505a | 2006-01-17 12:52:21 -0500 | [diff] [blame] | 1335 | complete(&xpc_discovery_exited); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1336 | |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1337 | xpc_do_exit(xpcUnloading); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1338 | return -EBUSY; |
| 1339 | } |
| 1340 | |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1341 | /* set the interface to point at XPC's functions */ |
| 1342 | xpc_set_interface(xpc_initiate_connect, xpc_initiate_disconnect, |
| 1343 | xpc_initiate_allocate, xpc_initiate_send, |
| 1344 | xpc_initiate_send_notify, xpc_initiate_received, |
| 1345 | xpc_initiate_partid_to_nasids); |
| 1346 | |
| 1347 | return 0; |
| 1348 | } |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1349 | |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1350 | module_init(xpc_init); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1351 | |
| 1352 | void __exit |
| 1353 | xpc_exit(void) |
| 1354 | { |
Dean Nelson | a607c38 | 2005-09-01 14:01:37 -0500 | [diff] [blame] | 1355 | xpc_do_exit(xpcUnloading); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1356 | } |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1357 | |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1358 | module_exit(xpc_exit); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1359 | |
| 1360 | MODULE_AUTHOR("Silicon Graphics, Inc."); |
| 1361 | MODULE_DESCRIPTION("Cross Partition Communication (XPC) support"); |
| 1362 | MODULE_LICENSE("GPL"); |
| 1363 | |
| 1364 | module_param(xpc_hb_interval, int, 0); |
| 1365 | MODULE_PARM_DESC(xpc_hb_interval, "Number of seconds between " |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1366 | "heartbeat increments."); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1367 | |
| 1368 | module_param(xpc_hb_check_interval, int, 0); |
| 1369 | MODULE_PARM_DESC(xpc_hb_check_interval, "Number of seconds between " |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1370 | "heartbeat checks."); |
Dean Nelson | 89eb8eb | 2005-03-23 19:50:00 -0700 | [diff] [blame] | 1371 | |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 1372 | module_param(xpc_disengage_request_timelimit, int, 0); |
| 1373 | MODULE_PARM_DESC(xpc_disengage_request_timelimit, "Number of seconds to wait " |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1374 | "for disengage request to complete."); |
Dean Nelson | e54af72 | 2005-10-25 14:07:43 -0500 | [diff] [blame] | 1375 | |
Dean Nelson | 1f4674b | 2006-01-10 11:08:00 -0600 | [diff] [blame] | 1376 | module_param(xpc_kdebug_ignore, int, 0); |
| 1377 | MODULE_PARM_DESC(xpc_kdebug_ignore, "Should lack of heartbeat be ignored by " |
Dean Nelson | 3519050 | 2008-04-22 14:48:55 -0500 | [diff] [blame^] | 1378 | "other partitions when dropping into kdebug."); |