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