xpc_main.c 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309
  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. * (C) Copyright 2020 Hewlett Packard Enterprise Development LP
  7. * Copyright (c) 2004-2009 Silicon Graphics, Inc. All Rights Reserved.
  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. * . Currently on sn2, we have no way to determine which nasid an IRQ
  29. * came from. Thus, xpc_send_IRQ_sn2() does a remote amo write
  30. * followed by an IPI. The amo indicates where data is to be pulled
  31. * from, so after the IPI arrives, the remote partition checks the amo
  32. * word. The IPI can actually arrive before the amo however, so other
  33. * code must periodically check for this case. Also, remote amo
  34. * operations do not reliably time out. Thus we do a remote PIO read
  35. * solely to know whether the remote partition is down and whether we
  36. * should stop sending IPIs to it. This remote PIO read operation is
  37. * set up in a special nofault region so SAL knows to ignore (and
  38. * cleanup) any errors due to the remote amo write, PIO read, and/or
  39. * PIO write operations.
  40. *
  41. * If/when new hardware solves this IPI problem, we should abandon
  42. * the current approach.
  43. *
  44. */
  45. #include <linux/module.h>
  46. #include <linux/slab.h>
  47. #include <linux/sysctl.h>
  48. #include <linux/device.h>
  49. #include <linux/delay.h>
  50. #include <linux/reboot.h>
  51. #include <linux/kdebug.h>
  52. #include <linux/kthread.h>
  53. #include "xpc.h"
  54. #ifdef CONFIG_X86_64
  55. #include <asm/traps.h>
  56. #endif
  57. /* define two XPC debug device structures to be used with dev_dbg() et al */
  58. static struct device_driver xpc_dbg_name = {
  59. .name = "xpc"
  60. };
  61. static struct device xpc_part_dbg_subname = {
  62. .init_name = "", /* set to "part" at xpc_init() time */
  63. .driver = &xpc_dbg_name
  64. };
  65. static struct device xpc_chan_dbg_subname = {
  66. .init_name = "", /* set to "chan" at xpc_init() time */
  67. .driver = &xpc_dbg_name
  68. };
  69. struct device *xpc_part = &xpc_part_dbg_subname;
  70. struct device *xpc_chan = &xpc_chan_dbg_subname;
  71. static int xpc_kdebug_ignore;
  72. /* systune related variables for /proc/sys directories */
  73. static int xpc_hb_interval = XPC_HB_DEFAULT_INTERVAL;
  74. static int xpc_hb_min_interval = 1;
  75. static int xpc_hb_max_interval = 10;
  76. static int xpc_hb_check_interval = XPC_HB_CHECK_DEFAULT_INTERVAL;
  77. static int xpc_hb_check_min_interval = 10;
  78. static int xpc_hb_check_max_interval = 120;
  79. int xpc_disengage_timelimit = XPC_DISENGAGE_DEFAULT_TIMELIMIT;
  80. static int xpc_disengage_min_timelimit; /* = 0 */
  81. static int xpc_disengage_max_timelimit = 120;
  82. static const struct ctl_table xpc_sys_xpc_hb[] = {
  83. {
  84. .procname = "hb_interval",
  85. .data = &xpc_hb_interval,
  86. .maxlen = sizeof(int),
  87. .mode = 0644,
  88. .proc_handler = proc_dointvec_minmax,
  89. .extra1 = &xpc_hb_min_interval,
  90. .extra2 = &xpc_hb_max_interval},
  91. {
  92. .procname = "hb_check_interval",
  93. .data = &xpc_hb_check_interval,
  94. .maxlen = sizeof(int),
  95. .mode = 0644,
  96. .proc_handler = proc_dointvec_minmax,
  97. .extra1 = &xpc_hb_check_min_interval,
  98. .extra2 = &xpc_hb_check_max_interval},
  99. };
  100. static const struct ctl_table xpc_sys_xpc[] = {
  101. {
  102. .procname = "disengage_timelimit",
  103. .data = &xpc_disengage_timelimit,
  104. .maxlen = sizeof(int),
  105. .mode = 0644,
  106. .proc_handler = proc_dointvec_minmax,
  107. .extra1 = &xpc_disengage_min_timelimit,
  108. .extra2 = &xpc_disengage_max_timelimit},
  109. };
  110. static struct ctl_table_header *xpc_sysctl;
  111. static struct ctl_table_header *xpc_sysctl_hb;
  112. /* non-zero if any remote partition disengage was timed out */
  113. int xpc_disengage_timedout;
  114. /* #of activate IRQs received and not yet processed */
  115. int xpc_activate_IRQ_rcvd;
  116. DEFINE_SPINLOCK(xpc_activate_IRQ_rcvd_lock);
  117. /* IRQ handler notifies this wait queue on receipt of an IRQ */
  118. DECLARE_WAIT_QUEUE_HEAD(xpc_activate_IRQ_wq);
  119. static unsigned long xpc_hb_check_timeout;
  120. static struct timer_list xpc_hb_timer;
  121. /* notification that the xpc_hb_checker thread has exited */
  122. static DECLARE_COMPLETION(xpc_hb_checker_exited);
  123. /* notification that the xpc_discovery thread has exited */
  124. static DECLARE_COMPLETION(xpc_discovery_exited);
  125. static void xpc_kthread_waitmsgs(struct xpc_partition *, struct xpc_channel *);
  126. static int xpc_system_reboot(struct notifier_block *, unsigned long, void *);
  127. static struct notifier_block xpc_reboot_notifier = {
  128. .notifier_call = xpc_system_reboot,
  129. };
  130. static int xpc_system_die(struct notifier_block *, unsigned long, void *);
  131. static struct notifier_block xpc_die_notifier = {
  132. .notifier_call = xpc_system_die,
  133. };
  134. struct xpc_arch_operations xpc_arch_ops;
  135. /*
  136. * Timer function to enforce the timelimit on the partition disengage.
  137. */
  138. static void
  139. xpc_timeout_partition_disengage(struct timer_list *t)
  140. {
  141. struct xpc_partition *part = timer_container_of(part, t,
  142. disengage_timer);
  143. DBUG_ON(time_is_after_jiffies(part->disengage_timeout));
  144. xpc_partition_disengaged_from_timer(part);
  145. DBUG_ON(part->disengage_timeout != 0);
  146. DBUG_ON(xpc_arch_ops.partition_engaged(XPC_PARTID(part)));
  147. }
  148. /*
  149. * Timer to produce the heartbeat. The timer structures function is
  150. * already set when this is initially called. A tunable is used to
  151. * specify when the next timeout should occur.
  152. */
  153. static void
  154. xpc_hb_beater(struct timer_list *unused)
  155. {
  156. xpc_arch_ops.increment_heartbeat();
  157. if (time_is_before_eq_jiffies(xpc_hb_check_timeout))
  158. wake_up_interruptible(&xpc_activate_IRQ_wq);
  159. xpc_hb_timer.expires = jiffies + (xpc_hb_interval * HZ);
  160. add_timer(&xpc_hb_timer);
  161. }
  162. static void
  163. xpc_start_hb_beater(void)
  164. {
  165. xpc_arch_ops.heartbeat_init();
  166. timer_setup(&xpc_hb_timer, xpc_hb_beater, 0);
  167. xpc_hb_beater(NULL);
  168. }
  169. static void
  170. xpc_stop_hb_beater(void)
  171. {
  172. timer_delete_sync(&xpc_hb_timer);
  173. xpc_arch_ops.heartbeat_exit();
  174. }
  175. /*
  176. * At periodic intervals, scan through all active partitions and ensure
  177. * their heartbeat is still active. If not, the partition is deactivated.
  178. */
  179. static void
  180. xpc_check_remote_hb(void)
  181. {
  182. struct xpc_partition *part;
  183. short partid;
  184. enum xp_retval ret;
  185. for (partid = 0; partid < xp_max_npartitions; partid++) {
  186. if (xpc_exiting)
  187. break;
  188. if (partid == xp_partition_id)
  189. continue;
  190. part = &xpc_partitions[partid];
  191. if (part->act_state == XPC_P_AS_INACTIVE ||
  192. part->act_state == XPC_P_AS_DEACTIVATING) {
  193. continue;
  194. }
  195. ret = xpc_arch_ops.get_remote_heartbeat(part);
  196. if (ret != xpSuccess)
  197. XPC_DEACTIVATE_PARTITION(part, ret);
  198. }
  199. }
  200. /*
  201. * This thread is responsible for nearly all of the partition
  202. * activation/deactivation.
  203. */
  204. static int
  205. xpc_hb_checker(void *ignore)
  206. {
  207. int force_IRQ = 0;
  208. /* this thread was marked active by xpc_hb_init() */
  209. set_cpus_allowed_ptr(current, cpumask_of(XPC_HB_CHECK_CPU));
  210. /* set our heartbeating to other partitions into motion */
  211. xpc_hb_check_timeout = jiffies + (xpc_hb_check_interval * HZ);
  212. xpc_start_hb_beater();
  213. while (!xpc_exiting) {
  214. dev_dbg(xpc_part, "woke up with %d ticks rem; %d IRQs have "
  215. "been received\n",
  216. (int)(xpc_hb_check_timeout - jiffies),
  217. xpc_activate_IRQ_rcvd);
  218. /* checking of remote heartbeats is skewed by IRQ handling */
  219. if (time_is_before_eq_jiffies(xpc_hb_check_timeout)) {
  220. xpc_hb_check_timeout = jiffies +
  221. (xpc_hb_check_interval * HZ);
  222. dev_dbg(xpc_part, "checking remote heartbeats\n");
  223. xpc_check_remote_hb();
  224. }
  225. /* check for outstanding IRQs */
  226. if (xpc_activate_IRQ_rcvd > 0 || force_IRQ != 0) {
  227. force_IRQ = 0;
  228. dev_dbg(xpc_part, "processing activate IRQs "
  229. "received\n");
  230. xpc_arch_ops.process_activate_IRQ_rcvd();
  231. }
  232. /* wait for IRQ or timeout */
  233. (void)wait_event_interruptible(xpc_activate_IRQ_wq,
  234. (time_is_before_eq_jiffies(
  235. xpc_hb_check_timeout) ||
  236. xpc_activate_IRQ_rcvd > 0 ||
  237. xpc_exiting));
  238. }
  239. xpc_stop_hb_beater();
  240. dev_dbg(xpc_part, "heartbeat checker is exiting\n");
  241. /* mark this thread as having exited */
  242. complete(&xpc_hb_checker_exited);
  243. return 0;
  244. }
  245. /*
  246. * This thread will attempt to discover other partitions to activate
  247. * based on info provided by SAL. This new thread is short lived and
  248. * will exit once discovery is complete.
  249. */
  250. static int
  251. xpc_initiate_discovery(void *ignore)
  252. {
  253. xpc_discovery();
  254. dev_dbg(xpc_part, "discovery thread is exiting\n");
  255. /* mark this thread as having exited */
  256. complete(&xpc_discovery_exited);
  257. return 0;
  258. }
  259. /*
  260. * The first kthread assigned to a newly activated partition is the one
  261. * created by XPC HB with which it calls xpc_activating(). XPC hangs on to
  262. * that kthread until the partition is brought down, at which time that kthread
  263. * returns back to XPC HB. (The return of that kthread will signify to XPC HB
  264. * that XPC has dismantled all communication infrastructure for the associated
  265. * partition.) This kthread becomes the channel manager for that partition.
  266. *
  267. * Each active partition has a channel manager, who, besides connecting and
  268. * disconnecting channels, will ensure that each of the partition's connected
  269. * channels has the required number of assigned kthreads to get the work done.
  270. */
  271. static void
  272. xpc_channel_mgr(struct xpc_partition *part)
  273. {
  274. while (part->act_state != XPC_P_AS_DEACTIVATING ||
  275. atomic_read(&part->nchannels_active) > 0 ||
  276. !xpc_partition_disengaged(part)) {
  277. xpc_process_sent_chctl_flags(part);
  278. /*
  279. * Wait until we've been requested to activate kthreads or
  280. * all of the channel's message queues have been torn down or
  281. * a signal is pending.
  282. *
  283. * The channel_mgr_requests is set to 1 after being awakened,
  284. * This is done to prevent the channel mgr from making one pass
  285. * through the loop for each request, since he will
  286. * be servicing all the requests in one pass. The reason it's
  287. * set to 1 instead of 0 is so that other kthreads will know
  288. * that the channel mgr is running and won't bother trying to
  289. * wake him up.
  290. */
  291. atomic_dec(&part->channel_mgr_requests);
  292. (void)wait_event_interruptible(part->channel_mgr_wq,
  293. (atomic_read(&part->channel_mgr_requests) > 0 ||
  294. part->chctl.all_flags != 0 ||
  295. (part->act_state == XPC_P_AS_DEACTIVATING &&
  296. atomic_read(&part->nchannels_active) == 0 &&
  297. xpc_partition_disengaged(part))));
  298. atomic_set(&part->channel_mgr_requests, 1);
  299. }
  300. }
  301. /*
  302. * Guarantee that the kzalloc'd memory is cacheline aligned.
  303. */
  304. void *
  305. xpc_kzalloc_cacheline_aligned(size_t size, gfp_t flags, void **base)
  306. {
  307. /* see if kzalloc will give us cachline aligned memory by default */
  308. *base = kzalloc(size, flags);
  309. if (*base == NULL)
  310. return NULL;
  311. if ((u64)*base == L1_CACHE_ALIGN((u64)*base))
  312. return *base;
  313. kfree(*base);
  314. /* nope, we'll have to do it ourselves */
  315. *base = kzalloc(size + L1_CACHE_BYTES, flags);
  316. if (*base == NULL)
  317. return NULL;
  318. return (void *)L1_CACHE_ALIGN((u64)*base);
  319. }
  320. /*
  321. * Setup the channel structures necessary to support XPartition Communication
  322. * between the specified remote partition and the local one.
  323. */
  324. static enum xp_retval
  325. xpc_setup_ch_structures(struct xpc_partition *part)
  326. {
  327. enum xp_retval ret;
  328. int ch_number;
  329. struct xpc_channel *ch;
  330. short partid = XPC_PARTID(part);
  331. /*
  332. * Allocate all of the channel structures as a contiguous chunk of
  333. * memory.
  334. */
  335. DBUG_ON(part->channels != NULL);
  336. part->channels = kzalloc_objs(struct xpc_channel, XPC_MAX_NCHANNELS);
  337. if (part->channels == NULL) {
  338. dev_err(xpc_chan, "can't get memory for channels\n");
  339. return xpNoMemory;
  340. }
  341. /* allocate the remote open and close args */
  342. part->remote_openclose_args =
  343. xpc_kzalloc_cacheline_aligned(XPC_OPENCLOSE_ARGS_SIZE,
  344. GFP_KERNEL, &part->
  345. remote_openclose_args_base);
  346. if (part->remote_openclose_args == NULL) {
  347. dev_err(xpc_chan, "can't get memory for remote connect args\n");
  348. ret = xpNoMemory;
  349. goto out_1;
  350. }
  351. part->chctl.all_flags = 0;
  352. spin_lock_init(&part->chctl_lock);
  353. atomic_set(&part->channel_mgr_requests, 1);
  354. init_waitqueue_head(&part->channel_mgr_wq);
  355. part->nchannels = XPC_MAX_NCHANNELS;
  356. atomic_set(&part->nchannels_active, 0);
  357. atomic_set(&part->nchannels_engaged, 0);
  358. for (ch_number = 0; ch_number < part->nchannels; ch_number++) {
  359. ch = &part->channels[ch_number];
  360. ch->partid = partid;
  361. ch->number = ch_number;
  362. ch->flags = XPC_C_DISCONNECTED;
  363. atomic_set(&ch->kthreads_assigned, 0);
  364. atomic_set(&ch->kthreads_idle, 0);
  365. atomic_set(&ch->kthreads_active, 0);
  366. atomic_set(&ch->references, 0);
  367. atomic_set(&ch->n_to_notify, 0);
  368. spin_lock_init(&ch->lock);
  369. init_completion(&ch->wdisconnect_wait);
  370. atomic_set(&ch->n_on_msg_allocate_wq, 0);
  371. init_waitqueue_head(&ch->msg_allocate_wq);
  372. init_waitqueue_head(&ch->idle_wq);
  373. }
  374. ret = xpc_arch_ops.setup_ch_structures(part);
  375. if (ret != xpSuccess)
  376. goto out_2;
  377. /*
  378. * With the setting of the partition setup_state to XPC_P_SS_SETUP,
  379. * we're declaring that this partition is ready to go.
  380. */
  381. part->setup_state = XPC_P_SS_SETUP;
  382. return xpSuccess;
  383. /* setup of ch structures failed */
  384. out_2:
  385. kfree(part->remote_openclose_args_base);
  386. part->remote_openclose_args = NULL;
  387. out_1:
  388. kfree(part->channels);
  389. part->channels = NULL;
  390. return ret;
  391. }
  392. /*
  393. * Teardown the channel structures necessary to support XPartition Communication
  394. * between the specified remote partition and the local one.
  395. */
  396. static void
  397. xpc_teardown_ch_structures(struct xpc_partition *part)
  398. {
  399. DBUG_ON(atomic_read(&part->nchannels_engaged) != 0);
  400. DBUG_ON(atomic_read(&part->nchannels_active) != 0);
  401. /*
  402. * Make this partition inaccessible to local processes by marking it
  403. * as no longer setup. Then wait before proceeding with the teardown
  404. * until all existing references cease.
  405. */
  406. DBUG_ON(part->setup_state != XPC_P_SS_SETUP);
  407. part->setup_state = XPC_P_SS_WTEARDOWN;
  408. wait_event(part->teardown_wq, (atomic_read(&part->references) == 0));
  409. /* now we can begin tearing down the infrastructure */
  410. xpc_arch_ops.teardown_ch_structures(part);
  411. kfree(part->remote_openclose_args_base);
  412. part->remote_openclose_args = NULL;
  413. kfree(part->channels);
  414. part->channels = NULL;
  415. part->setup_state = XPC_P_SS_TORNDOWN;
  416. }
  417. /*
  418. * When XPC HB determines that a partition has come up, it will create a new
  419. * kthread and that kthread will call this function to attempt to set up the
  420. * basic infrastructure used for Cross Partition Communication with the newly
  421. * upped partition.
  422. *
  423. * The kthread that was created by XPC HB and which setup the XPC
  424. * infrastructure will remain assigned to the partition becoming the channel
  425. * manager for that partition until the partition is deactivating, at which
  426. * time the kthread will teardown the XPC infrastructure and then exit.
  427. */
  428. static int
  429. xpc_activating(void *__partid)
  430. {
  431. short partid = (u64)__partid;
  432. struct xpc_partition *part = &xpc_partitions[partid];
  433. unsigned long irq_flags;
  434. DBUG_ON(partid < 0 || partid >= xp_max_npartitions);
  435. spin_lock_irqsave(&part->act_lock, irq_flags);
  436. if (part->act_state == XPC_P_AS_DEACTIVATING) {
  437. part->act_state = XPC_P_AS_INACTIVE;
  438. spin_unlock_irqrestore(&part->act_lock, irq_flags);
  439. part->remote_rp_pa = 0;
  440. return 0;
  441. }
  442. /* indicate the thread is activating */
  443. DBUG_ON(part->act_state != XPC_P_AS_ACTIVATION_REQ);
  444. part->act_state = XPC_P_AS_ACTIVATING;
  445. XPC_SET_REASON(part, 0, 0);
  446. spin_unlock_irqrestore(&part->act_lock, irq_flags);
  447. dev_dbg(xpc_part, "activating partition %d\n", partid);
  448. xpc_arch_ops.allow_hb(partid);
  449. if (xpc_setup_ch_structures(part) == xpSuccess) {
  450. (void)xpc_part_ref(part); /* this will always succeed */
  451. if (xpc_arch_ops.make_first_contact(part) == xpSuccess) {
  452. xpc_mark_partition_active(part);
  453. xpc_channel_mgr(part);
  454. /* won't return until partition is deactivating */
  455. }
  456. xpc_part_deref(part);
  457. xpc_teardown_ch_structures(part);
  458. }
  459. xpc_arch_ops.disallow_hb(partid);
  460. xpc_mark_partition_inactive(part);
  461. if (part->reason == xpReactivating) {
  462. /* interrupting ourselves results in activating partition */
  463. xpc_arch_ops.request_partition_reactivation(part);
  464. }
  465. return 0;
  466. }
  467. void
  468. xpc_activate_partition(struct xpc_partition *part)
  469. {
  470. short partid = XPC_PARTID(part);
  471. unsigned long irq_flags;
  472. struct task_struct *kthread;
  473. spin_lock_irqsave(&part->act_lock, irq_flags);
  474. DBUG_ON(part->act_state != XPC_P_AS_INACTIVE);
  475. part->act_state = XPC_P_AS_ACTIVATION_REQ;
  476. XPC_SET_REASON(part, xpCloneKThread, __LINE__);
  477. spin_unlock_irqrestore(&part->act_lock, irq_flags);
  478. kthread = kthread_run(xpc_activating, (void *)((u64)partid), "xpc%02d",
  479. partid);
  480. if (IS_ERR(kthread)) {
  481. spin_lock_irqsave(&part->act_lock, irq_flags);
  482. part->act_state = XPC_P_AS_INACTIVE;
  483. XPC_SET_REASON(part, xpCloneKThreadFailed, __LINE__);
  484. spin_unlock_irqrestore(&part->act_lock, irq_flags);
  485. }
  486. }
  487. void
  488. xpc_activate_kthreads(struct xpc_channel *ch, int needed)
  489. {
  490. int idle = atomic_read(&ch->kthreads_idle);
  491. int assigned = atomic_read(&ch->kthreads_assigned);
  492. int wakeup;
  493. DBUG_ON(needed <= 0);
  494. if (idle > 0) {
  495. wakeup = (needed > idle) ? idle : needed;
  496. needed -= wakeup;
  497. dev_dbg(xpc_chan, "wakeup %d idle kthreads, partid=%d, "
  498. "channel=%d\n", wakeup, ch->partid, ch->number);
  499. /* only wakeup the requested number of kthreads */
  500. wake_up_nr(&ch->idle_wq, wakeup);
  501. }
  502. if (needed <= 0)
  503. return;
  504. if (needed + assigned > ch->kthreads_assigned_limit) {
  505. needed = ch->kthreads_assigned_limit - assigned;
  506. if (needed <= 0)
  507. return;
  508. }
  509. dev_dbg(xpc_chan, "create %d new kthreads, partid=%d, channel=%d\n",
  510. needed, ch->partid, ch->number);
  511. xpc_create_kthreads(ch, needed, 0);
  512. }
  513. /*
  514. * This function is where XPC's kthreads wait for messages to deliver.
  515. */
  516. static void
  517. xpc_kthread_waitmsgs(struct xpc_partition *part, struct xpc_channel *ch)
  518. {
  519. int (*n_of_deliverable_payloads) (struct xpc_channel *) =
  520. xpc_arch_ops.n_of_deliverable_payloads;
  521. do {
  522. /* deliver messages to their intended recipients */
  523. while (n_of_deliverable_payloads(ch) > 0 &&
  524. !(ch->flags & XPC_C_DISCONNECTING)) {
  525. xpc_deliver_payload(ch);
  526. }
  527. if (atomic_inc_return(&ch->kthreads_idle) >
  528. ch->kthreads_idle_limit) {
  529. /* too many idle kthreads on this channel */
  530. atomic_dec(&ch->kthreads_idle);
  531. break;
  532. }
  533. dev_dbg(xpc_chan, "idle kthread calling "
  534. "wait_event_interruptible_exclusive()\n");
  535. (void)wait_event_interruptible_exclusive(ch->idle_wq,
  536. (n_of_deliverable_payloads(ch) > 0 ||
  537. (ch->flags & XPC_C_DISCONNECTING)));
  538. atomic_dec(&ch->kthreads_idle);
  539. } while (!(ch->flags & XPC_C_DISCONNECTING));
  540. }
  541. static int
  542. xpc_kthread_start(void *args)
  543. {
  544. short partid = XPC_UNPACK_ARG1(args);
  545. u16 ch_number = XPC_UNPACK_ARG2(args);
  546. struct xpc_partition *part = &xpc_partitions[partid];
  547. struct xpc_channel *ch;
  548. int n_needed;
  549. unsigned long irq_flags;
  550. int (*n_of_deliverable_payloads) (struct xpc_channel *) =
  551. xpc_arch_ops.n_of_deliverable_payloads;
  552. dev_dbg(xpc_chan, "kthread starting, partid=%d, channel=%d\n",
  553. partid, ch_number);
  554. ch = &part->channels[ch_number];
  555. if (!(ch->flags & XPC_C_DISCONNECTING)) {
  556. /* let registerer know that connection has been established */
  557. spin_lock_irqsave(&ch->lock, irq_flags);
  558. if (!(ch->flags & XPC_C_CONNECTEDCALLOUT)) {
  559. ch->flags |= XPC_C_CONNECTEDCALLOUT;
  560. spin_unlock_irqrestore(&ch->lock, irq_flags);
  561. xpc_connected_callout(ch);
  562. spin_lock_irqsave(&ch->lock, irq_flags);
  563. ch->flags |= XPC_C_CONNECTEDCALLOUT_MADE;
  564. spin_unlock_irqrestore(&ch->lock, irq_flags);
  565. /*
  566. * It is possible that while the callout was being
  567. * made that the remote partition sent some messages.
  568. * If that is the case, we may need to activate
  569. * additional kthreads to help deliver them. We only
  570. * need one less than total #of messages to deliver.
  571. */
  572. n_needed = n_of_deliverable_payloads(ch) - 1;
  573. if (n_needed > 0 && !(ch->flags & XPC_C_DISCONNECTING))
  574. xpc_activate_kthreads(ch, n_needed);
  575. } else {
  576. spin_unlock_irqrestore(&ch->lock, irq_flags);
  577. }
  578. xpc_kthread_waitmsgs(part, ch);
  579. }
  580. /* let registerer know that connection is disconnecting */
  581. spin_lock_irqsave(&ch->lock, irq_flags);
  582. if ((ch->flags & XPC_C_CONNECTEDCALLOUT_MADE) &&
  583. !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) {
  584. ch->flags |= XPC_C_DISCONNECTINGCALLOUT;
  585. spin_unlock_irqrestore(&ch->lock, irq_flags);
  586. xpc_disconnect_callout(ch, xpDisconnecting);
  587. spin_lock_irqsave(&ch->lock, irq_flags);
  588. ch->flags |= XPC_C_DISCONNECTINGCALLOUT_MADE;
  589. }
  590. spin_unlock_irqrestore(&ch->lock, irq_flags);
  591. if (atomic_dec_return(&ch->kthreads_assigned) == 0 &&
  592. atomic_dec_return(&part->nchannels_engaged) == 0) {
  593. xpc_arch_ops.indicate_partition_disengaged(part);
  594. }
  595. xpc_msgqueue_deref(ch);
  596. dev_dbg(xpc_chan, "kthread exiting, partid=%d, channel=%d\n",
  597. partid, ch_number);
  598. xpc_part_deref(part);
  599. return 0;
  600. }
  601. /*
  602. * For each partition that XPC has established communications with, there is
  603. * a minimum of one kernel thread assigned to perform any operation that
  604. * may potentially sleep or block (basically the callouts to the asynchronous
  605. * functions registered via xpc_connect()).
  606. *
  607. * Additional kthreads are created and destroyed by XPC as the workload
  608. * demands.
  609. *
  610. * A kthread is assigned to one of the active channels that exists for a given
  611. * partition.
  612. */
  613. void
  614. xpc_create_kthreads(struct xpc_channel *ch, int needed,
  615. int ignore_disconnecting)
  616. {
  617. unsigned long irq_flags;
  618. u64 args = XPC_PACK_ARGS(ch->partid, ch->number);
  619. struct xpc_partition *part = &xpc_partitions[ch->partid];
  620. struct task_struct *kthread;
  621. void (*indicate_partition_disengaged) (struct xpc_partition *) =
  622. xpc_arch_ops.indicate_partition_disengaged;
  623. while (needed-- > 0) {
  624. /*
  625. * The following is done on behalf of the newly created
  626. * kthread. That kthread is responsible for doing the
  627. * counterpart to the following before it exits.
  628. */
  629. if (ignore_disconnecting) {
  630. if (!atomic_inc_not_zero(&ch->kthreads_assigned)) {
  631. /* kthreads assigned had gone to zero */
  632. BUG_ON(!(ch->flags &
  633. XPC_C_DISCONNECTINGCALLOUT_MADE));
  634. break;
  635. }
  636. } else if (ch->flags & XPC_C_DISCONNECTING) {
  637. break;
  638. } else if (atomic_inc_return(&ch->kthreads_assigned) == 1 &&
  639. atomic_inc_return(&part->nchannels_engaged) == 1) {
  640. xpc_arch_ops.indicate_partition_engaged(part);
  641. }
  642. (void)xpc_part_ref(part);
  643. xpc_msgqueue_ref(ch);
  644. kthread = kthread_run(xpc_kthread_start, (void *)args,
  645. "xpc%02dc%d", ch->partid, ch->number);
  646. if (IS_ERR(kthread)) {
  647. /* the fork failed */
  648. /*
  649. * NOTE: if (ignore_disconnecting &&
  650. * !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) is true,
  651. * then we'll deadlock if all other kthreads assigned
  652. * to this channel are blocked in the channel's
  653. * registerer, because the only thing that will unblock
  654. * them is the xpDisconnecting callout that this
  655. * failed kthread_run() would have made.
  656. */
  657. if (atomic_dec_return(&ch->kthreads_assigned) == 0 &&
  658. atomic_dec_return(&part->nchannels_engaged) == 0) {
  659. indicate_partition_disengaged(part);
  660. }
  661. xpc_msgqueue_deref(ch);
  662. xpc_part_deref(part);
  663. if (atomic_read(&ch->kthreads_assigned) <
  664. ch->kthreads_idle_limit) {
  665. /*
  666. * Flag this as an error only if we have an
  667. * insufficient #of kthreads for the channel
  668. * to function.
  669. */
  670. spin_lock_irqsave(&ch->lock, irq_flags);
  671. XPC_DISCONNECT_CHANNEL(ch, xpLackOfResources,
  672. &irq_flags);
  673. spin_unlock_irqrestore(&ch->lock, irq_flags);
  674. }
  675. break;
  676. }
  677. }
  678. }
  679. void
  680. xpc_disconnect_wait(int ch_number)
  681. {
  682. unsigned long irq_flags;
  683. short partid;
  684. struct xpc_partition *part;
  685. struct xpc_channel *ch;
  686. int wakeup_channel_mgr;
  687. /* now wait for all callouts to the caller's function to cease */
  688. for (partid = 0; partid < xp_max_npartitions; partid++) {
  689. part = &xpc_partitions[partid];
  690. if (!xpc_part_ref(part))
  691. continue;
  692. ch = &part->channels[ch_number];
  693. if (!(ch->flags & XPC_C_WDISCONNECT)) {
  694. xpc_part_deref(part);
  695. continue;
  696. }
  697. wait_for_completion(&ch->wdisconnect_wait);
  698. spin_lock_irqsave(&ch->lock, irq_flags);
  699. DBUG_ON(!(ch->flags & XPC_C_DISCONNECTED));
  700. wakeup_channel_mgr = 0;
  701. if (ch->delayed_chctl_flags) {
  702. if (part->act_state != XPC_P_AS_DEACTIVATING) {
  703. spin_lock(&part->chctl_lock);
  704. part->chctl.flags[ch->number] |=
  705. ch->delayed_chctl_flags;
  706. spin_unlock(&part->chctl_lock);
  707. wakeup_channel_mgr = 1;
  708. }
  709. ch->delayed_chctl_flags = 0;
  710. }
  711. ch->flags &= ~XPC_C_WDISCONNECT;
  712. spin_unlock_irqrestore(&ch->lock, irq_flags);
  713. if (wakeup_channel_mgr)
  714. xpc_wakeup_channel_mgr(part);
  715. xpc_part_deref(part);
  716. }
  717. }
  718. static int
  719. xpc_setup_partitions(void)
  720. {
  721. short partid;
  722. struct xpc_partition *part;
  723. xpc_partitions = kzalloc_objs(struct xpc_partition, xp_max_npartitions);
  724. if (xpc_partitions == NULL) {
  725. dev_err(xpc_part, "can't get memory for partition structure\n");
  726. return -ENOMEM;
  727. }
  728. /*
  729. * The first few fields of each entry of xpc_partitions[] need to
  730. * be initialized now so that calls to xpc_connect() and
  731. * xpc_disconnect() can be made prior to the activation of any remote
  732. * partition. NOTE THAT NONE OF THE OTHER FIELDS BELONGING TO THESE
  733. * ENTRIES ARE MEANINGFUL UNTIL AFTER AN ENTRY'S CORRESPONDING
  734. * PARTITION HAS BEEN ACTIVATED.
  735. */
  736. for (partid = 0; partid < xp_max_npartitions; partid++) {
  737. part = &xpc_partitions[partid];
  738. DBUG_ON((u64)part != L1_CACHE_ALIGN((u64)part));
  739. part->activate_IRQ_rcvd = 0;
  740. spin_lock_init(&part->act_lock);
  741. part->act_state = XPC_P_AS_INACTIVE;
  742. XPC_SET_REASON(part, 0, 0);
  743. timer_setup(&part->disengage_timer,
  744. xpc_timeout_partition_disengage, 0);
  745. part->setup_state = XPC_P_SS_UNSET;
  746. init_waitqueue_head(&part->teardown_wq);
  747. atomic_set(&part->references, 0);
  748. }
  749. return xpc_arch_ops.setup_partitions();
  750. }
  751. static void
  752. xpc_teardown_partitions(void)
  753. {
  754. xpc_arch_ops.teardown_partitions();
  755. kfree(xpc_partitions);
  756. }
  757. static void
  758. xpc_do_exit(enum xp_retval reason)
  759. {
  760. short partid;
  761. int active_part_count, printed_waiting_msg = 0;
  762. struct xpc_partition *part;
  763. unsigned long printmsg_time, disengage_timeout = 0;
  764. /* a 'rmmod XPC' and a 'reboot' cannot both end up here together */
  765. DBUG_ON(xpc_exiting == 1);
  766. /*
  767. * Let the heartbeat checker thread and the discovery thread
  768. * (if one is running) know that they should exit. Also wake up
  769. * the heartbeat checker thread in case it's sleeping.
  770. */
  771. xpc_exiting = 1;
  772. wake_up_interruptible(&xpc_activate_IRQ_wq);
  773. /* wait for the discovery thread to exit */
  774. wait_for_completion(&xpc_discovery_exited);
  775. /* wait for the heartbeat checker thread to exit */
  776. wait_for_completion(&xpc_hb_checker_exited);
  777. /* sleep for a 1/3 of a second or so */
  778. (void)msleep_interruptible(300);
  779. /* wait for all partitions to become inactive */
  780. printmsg_time = jiffies + (XPC_DEACTIVATE_PRINTMSG_INTERVAL * HZ);
  781. xpc_disengage_timedout = 0;
  782. do {
  783. active_part_count = 0;
  784. for (partid = 0; partid < xp_max_npartitions; partid++) {
  785. part = &xpc_partitions[partid];
  786. if (xpc_partition_disengaged(part) &&
  787. part->act_state == XPC_P_AS_INACTIVE) {
  788. continue;
  789. }
  790. active_part_count++;
  791. XPC_DEACTIVATE_PARTITION(part, reason);
  792. if (part->disengage_timeout > disengage_timeout)
  793. disengage_timeout = part->disengage_timeout;
  794. }
  795. if (xpc_arch_ops.any_partition_engaged()) {
  796. if (time_is_before_jiffies(printmsg_time)) {
  797. dev_info(xpc_part, "waiting for remote "
  798. "partitions to deactivate, timeout in "
  799. "%ld seconds\n", (disengage_timeout -
  800. jiffies) / HZ);
  801. printmsg_time = jiffies +
  802. (XPC_DEACTIVATE_PRINTMSG_INTERVAL * HZ);
  803. printed_waiting_msg = 1;
  804. }
  805. } else if (active_part_count > 0) {
  806. if (printed_waiting_msg) {
  807. dev_info(xpc_part, "waiting for local partition"
  808. " to deactivate\n");
  809. printed_waiting_msg = 0;
  810. }
  811. } else {
  812. if (!xpc_disengage_timedout) {
  813. dev_info(xpc_part, "all partitions have "
  814. "deactivated\n");
  815. }
  816. break;
  817. }
  818. /* sleep for a 1/3 of a second or so */
  819. (void)msleep_interruptible(300);
  820. } while (1);
  821. DBUG_ON(xpc_arch_ops.any_partition_engaged());
  822. xpc_teardown_rsvd_page();
  823. if (reason == xpUnloading) {
  824. (void)unregister_die_notifier(&xpc_die_notifier);
  825. (void)unregister_reboot_notifier(&xpc_reboot_notifier);
  826. }
  827. /* clear the interface to XPC's functions */
  828. xpc_clear_interface();
  829. if (xpc_sysctl)
  830. unregister_sysctl_table(xpc_sysctl);
  831. if (xpc_sysctl_hb)
  832. unregister_sysctl_table(xpc_sysctl_hb);
  833. xpc_teardown_partitions();
  834. if (is_uv_system())
  835. xpc_exit_uv();
  836. }
  837. /*
  838. * This function is called when the system is being rebooted.
  839. */
  840. static int
  841. xpc_system_reboot(struct notifier_block *nb, unsigned long event, void *unused)
  842. {
  843. enum xp_retval reason;
  844. switch (event) {
  845. case SYS_RESTART:
  846. reason = xpSystemReboot;
  847. break;
  848. case SYS_HALT:
  849. reason = xpSystemHalt;
  850. break;
  851. case SYS_POWER_OFF:
  852. reason = xpSystemPoweroff;
  853. break;
  854. default:
  855. reason = xpSystemGoingDown;
  856. }
  857. xpc_do_exit(reason);
  858. return NOTIFY_DONE;
  859. }
  860. /* Used to only allow one cpu to complete disconnect */
  861. static unsigned int xpc_die_disconnecting;
  862. /*
  863. * Notify other partitions to deactivate from us by first disengaging from all
  864. * references to our memory.
  865. */
  866. static void
  867. xpc_die_deactivate(void)
  868. {
  869. struct xpc_partition *part;
  870. short partid;
  871. int any_engaged;
  872. long keep_waiting;
  873. long wait_to_print;
  874. if (cmpxchg(&xpc_die_disconnecting, 0, 1))
  875. return;
  876. /* keep xpc_hb_checker thread from doing anything (just in case) */
  877. xpc_exiting = 1;
  878. xpc_arch_ops.disallow_all_hbs(); /*indicate we're deactivated */
  879. for (partid = 0; partid < xp_max_npartitions; partid++) {
  880. part = &xpc_partitions[partid];
  881. if (xpc_arch_ops.partition_engaged(partid) ||
  882. part->act_state != XPC_P_AS_INACTIVE) {
  883. xpc_arch_ops.request_partition_deactivation(part);
  884. xpc_arch_ops.indicate_partition_disengaged(part);
  885. }
  886. }
  887. /*
  888. * Though we requested that all other partitions deactivate from us,
  889. * we only wait until they've all disengaged or we've reached the
  890. * defined timelimit.
  891. *
  892. * Given that one iteration through the following while-loop takes
  893. * approximately 200 microseconds, calculate the #of loops to take
  894. * before bailing and the #of loops before printing a waiting message.
  895. */
  896. keep_waiting = xpc_disengage_timelimit * 1000 * 5;
  897. wait_to_print = XPC_DEACTIVATE_PRINTMSG_INTERVAL * 1000 * 5;
  898. while (1) {
  899. any_engaged = xpc_arch_ops.any_partition_engaged();
  900. if (!any_engaged) {
  901. dev_info(xpc_part, "all partitions have deactivated\n");
  902. break;
  903. }
  904. if (!keep_waiting--) {
  905. for (partid = 0; partid < xp_max_npartitions;
  906. partid++) {
  907. if (xpc_arch_ops.partition_engaged(partid)) {
  908. dev_info(xpc_part, "deactivate from "
  909. "remote partition %d timed "
  910. "out\n", partid);
  911. }
  912. }
  913. break;
  914. }
  915. if (!wait_to_print--) {
  916. dev_info(xpc_part, "waiting for remote partitions to "
  917. "deactivate, timeout in %ld seconds\n",
  918. keep_waiting / (1000 * 5));
  919. wait_to_print = XPC_DEACTIVATE_PRINTMSG_INTERVAL *
  920. 1000 * 5;
  921. }
  922. udelay(200);
  923. }
  924. }
  925. /*
  926. * This function is called when the system is being restarted or halted due
  927. * to some sort of system failure. If this is the case we need to notify the
  928. * other partitions to disengage from all references to our memory.
  929. * This function can also be called when our heartbeater could be offlined
  930. * for a time. In this case we need to notify other partitions to not worry
  931. * about the lack of a heartbeat.
  932. */
  933. static int
  934. xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
  935. {
  936. struct die_args *die_args = _die_args;
  937. switch (event) {
  938. case DIE_TRAP:
  939. if (die_args->trapnr == X86_TRAP_DF)
  940. xpc_die_deactivate();
  941. if (((die_args->trapnr == X86_TRAP_MF) ||
  942. (die_args->trapnr == X86_TRAP_XF)) &&
  943. !user_mode(die_args->regs))
  944. xpc_die_deactivate();
  945. break;
  946. case DIE_INT3:
  947. case DIE_DEBUG:
  948. break;
  949. case DIE_OOPS:
  950. case DIE_GPF:
  951. default:
  952. xpc_die_deactivate();
  953. }
  954. return NOTIFY_DONE;
  955. }
  956. static int __init
  957. xpc_init(void)
  958. {
  959. int ret;
  960. struct task_struct *kthread;
  961. dev_set_name(xpc_part, "part");
  962. dev_set_name(xpc_chan, "chan");
  963. if (is_uv_system()) {
  964. ret = xpc_init_uv();
  965. } else {
  966. ret = -ENODEV;
  967. }
  968. if (ret != 0)
  969. return ret;
  970. ret = xpc_setup_partitions();
  971. if (ret != 0) {
  972. dev_err(xpc_part, "can't get memory for partition structure\n");
  973. goto out_1;
  974. }
  975. xpc_sysctl = register_sysctl("xpc", xpc_sys_xpc);
  976. xpc_sysctl_hb = register_sysctl("xpc/hb", xpc_sys_xpc_hb);
  977. /*
  978. * Fill the partition reserved page with the information needed by
  979. * other partitions to discover we are alive and establish initial
  980. * communications.
  981. */
  982. ret = xpc_setup_rsvd_page();
  983. if (ret != 0) {
  984. dev_err(xpc_part, "can't setup our reserved page\n");
  985. goto out_2;
  986. }
  987. /* add ourselves to the reboot_notifier_list */
  988. ret = register_reboot_notifier(&xpc_reboot_notifier);
  989. if (ret != 0)
  990. dev_warn(xpc_part, "can't register reboot notifier\n");
  991. /* add ourselves to the die_notifier list */
  992. ret = register_die_notifier(&xpc_die_notifier);
  993. if (ret != 0)
  994. dev_warn(xpc_part, "can't register die notifier\n");
  995. /*
  996. * The real work-horse behind xpc. This processes incoming
  997. * interrupts and monitors remote heartbeats.
  998. */
  999. kthread = kthread_run(xpc_hb_checker, NULL, XPC_HB_CHECK_THREAD_NAME);
  1000. if (IS_ERR(kthread)) {
  1001. dev_err(xpc_part, "failed while forking hb check thread\n");
  1002. ret = -EBUSY;
  1003. goto out_3;
  1004. }
  1005. /*
  1006. * Startup a thread that will attempt to discover other partitions to
  1007. * activate based on info provided by SAL. This new thread is short
  1008. * lived and will exit once discovery is complete.
  1009. */
  1010. kthread = kthread_run(xpc_initiate_discovery, NULL,
  1011. XPC_DISCOVERY_THREAD_NAME);
  1012. if (IS_ERR(kthread)) {
  1013. dev_err(xpc_part, "failed while forking discovery thread\n");
  1014. /* mark this new thread as a non-starter */
  1015. complete(&xpc_discovery_exited);
  1016. xpc_do_exit(xpUnloading);
  1017. return -EBUSY;
  1018. }
  1019. /* set the interface to point at XPC's functions */
  1020. xpc_set_interface(xpc_initiate_connect, xpc_initiate_disconnect,
  1021. xpc_initiate_send, xpc_initiate_send_notify,
  1022. xpc_initiate_received, xpc_initiate_partid_to_nasids);
  1023. return 0;
  1024. /* initialization was not successful */
  1025. out_3:
  1026. xpc_teardown_rsvd_page();
  1027. (void)unregister_die_notifier(&xpc_die_notifier);
  1028. (void)unregister_reboot_notifier(&xpc_reboot_notifier);
  1029. out_2:
  1030. if (xpc_sysctl_hb)
  1031. unregister_sysctl_table(xpc_sysctl_hb);
  1032. if (xpc_sysctl)
  1033. unregister_sysctl_table(xpc_sysctl);
  1034. xpc_teardown_partitions();
  1035. out_1:
  1036. if (is_uv_system())
  1037. xpc_exit_uv();
  1038. return ret;
  1039. }
  1040. module_init(xpc_init);
  1041. static void __exit
  1042. xpc_exit(void)
  1043. {
  1044. xpc_do_exit(xpUnloading);
  1045. }
  1046. module_exit(xpc_exit);
  1047. MODULE_AUTHOR("Silicon Graphics, Inc.");
  1048. MODULE_DESCRIPTION("Cross Partition Communication (XPC) support");
  1049. MODULE_LICENSE("GPL");
  1050. module_param(xpc_hb_interval, int, 0);
  1051. MODULE_PARM_DESC(xpc_hb_interval, "Number of seconds between "
  1052. "heartbeat increments.");
  1053. module_param(xpc_hb_check_interval, int, 0);
  1054. MODULE_PARM_DESC(xpc_hb_check_interval, "Number of seconds between "
  1055. "heartbeat checks.");
  1056. module_param(xpc_disengage_timelimit, int, 0);
  1057. MODULE_PARM_DESC(xpc_disengage_timelimit, "Number of seconds to wait "
  1058. "for disengage to complete.");
  1059. module_param(xpc_kdebug_ignore, int, 0);
  1060. MODULE_PARM_DESC(xpc_kdebug_ignore, "Should lack of heartbeat be ignored by "
  1061. "other partitions when dropping into kdebug.");