xpc_main.c 35 KB

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