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