Lines Matching +full:remote +full:- +full:wakeup +full:- +full:connected
7 * Copyright (c) 2004-2009 Silicon Graphics, Inc. All Rights Reserved.
11 * Cross Partition Communication (XPC) support - standard version.
30 * came from. Thus, xpc_send_IRQ_sn2() does a remote amo write
32 * from, so after the IPI arrives, the remote partition checks the amo
34 * code must periodically check for this case. Also, remote amo
35 * operations do not reliably time out. Thus we do a remote PIO read
36 * solely to know whether the remote partition is down and whether we
37 * should stop sending IPIs to it. This remote PIO read operation is
39 * cleanup) any errors due to the remote amo write, PIO read, and/or
130 /* non-zero if any remote partition disengage was timed out */
171 DBUG_ON(time_is_after_jiffies(part->disengage_timeout)); in xpc_timeout_partition_disengage()
175 DBUG_ON(part->disengage_timeout != 0); in xpc_timeout_partition_disengage()
232 if (part->act_state == XPC_P_AS_INACTIVE || in xpc_check_remote_hb()
233 part->act_state == XPC_P_AS_DEACTIVATING) { in xpc_check_remote_hb()
264 (int)(xpc_hb_check_timeout - jiffies), in xpc_hb_checker()
267 /* checking of remote heartbeats is skewed by IRQ handling */ in xpc_hb_checker()
272 dev_dbg(xpc_part, "checking remote heartbeats\n"); in xpc_hb_checker()
327 * disconnecting channels, will ensure that each of the partition's connected
333 while (part->act_state != XPC_P_AS_DEACTIVATING || in xpc_channel_mgr()
334 atomic_read(&part->nchannels_active) > 0 || in xpc_channel_mgr()
352 atomic_dec(&part->channel_mgr_requests); in xpc_channel_mgr()
353 (void)wait_event_interruptible(part->channel_mgr_wq, in xpc_channel_mgr()
354 (atomic_read(&part->channel_mgr_requests) > 0 || in xpc_channel_mgr()
355 part->chctl.all_flags != 0 || in xpc_channel_mgr()
356 (part->act_state == XPC_P_AS_DEACTIVATING && in xpc_channel_mgr()
357 atomic_read(&part->nchannels_active) == 0 && in xpc_channel_mgr()
359 atomic_set(&part->channel_mgr_requests, 1); in xpc_channel_mgr()
389 * between the specified remote partition and the local one.
403 DBUG_ON(part->channels != NULL); in xpc_setup_ch_structures()
404 part->channels = kcalloc(XPC_MAX_NCHANNELS, in xpc_setup_ch_structures()
407 if (part->channels == NULL) { in xpc_setup_ch_structures()
412 /* allocate the remote open and close args */ in xpc_setup_ch_structures()
414 part->remote_openclose_args = in xpc_setup_ch_structures()
416 GFP_KERNEL, &part-> in xpc_setup_ch_structures()
418 if (part->remote_openclose_args == NULL) { in xpc_setup_ch_structures()
419 dev_err(xpc_chan, "can't get memory for remote connect args\n"); in xpc_setup_ch_structures()
424 part->chctl.all_flags = 0; in xpc_setup_ch_structures()
425 spin_lock_init(&part->chctl_lock); in xpc_setup_ch_structures()
427 atomic_set(&part->channel_mgr_requests, 1); in xpc_setup_ch_structures()
428 init_waitqueue_head(&part->channel_mgr_wq); in xpc_setup_ch_structures()
430 part->nchannels = XPC_MAX_NCHANNELS; in xpc_setup_ch_structures()
432 atomic_set(&part->nchannels_active, 0); in xpc_setup_ch_structures()
433 atomic_set(&part->nchannels_engaged, 0); in xpc_setup_ch_structures()
435 for (ch_number = 0; ch_number < part->nchannels; ch_number++) { in xpc_setup_ch_structures()
436 ch = &part->channels[ch_number]; in xpc_setup_ch_structures()
438 ch->partid = partid; in xpc_setup_ch_structures()
439 ch->number = ch_number; in xpc_setup_ch_structures()
440 ch->flags = XPC_C_DISCONNECTED; in xpc_setup_ch_structures()
442 atomic_set(&ch->kthreads_assigned, 0); in xpc_setup_ch_structures()
443 atomic_set(&ch->kthreads_idle, 0); in xpc_setup_ch_structures()
444 atomic_set(&ch->kthreads_active, 0); in xpc_setup_ch_structures()
446 atomic_set(&ch->references, 0); in xpc_setup_ch_structures()
447 atomic_set(&ch->n_to_notify, 0); in xpc_setup_ch_structures()
449 spin_lock_init(&ch->lock); in xpc_setup_ch_structures()
450 init_completion(&ch->wdisconnect_wait); in xpc_setup_ch_structures()
452 atomic_set(&ch->n_on_msg_allocate_wq, 0); in xpc_setup_ch_structures()
453 init_waitqueue_head(&ch->msg_allocate_wq); in xpc_setup_ch_structures()
454 init_waitqueue_head(&ch->idle_wq); in xpc_setup_ch_structures()
465 part->setup_state = XPC_P_SS_SETUP; in xpc_setup_ch_structures()
471 kfree(part->remote_openclose_args_base); in xpc_setup_ch_structures()
472 part->remote_openclose_args = NULL; in xpc_setup_ch_structures()
474 kfree(part->channels); in xpc_setup_ch_structures()
475 part->channels = NULL; in xpc_setup_ch_structures()
481 * between the specified remote partition and the local one.
486 DBUG_ON(atomic_read(&part->nchannels_engaged) != 0); in xpc_teardown_ch_structures()
487 DBUG_ON(atomic_read(&part->nchannels_active) != 0); in xpc_teardown_ch_structures()
494 DBUG_ON(part->setup_state != XPC_P_SS_SETUP); in xpc_teardown_ch_structures()
495 part->setup_state = XPC_P_SS_WTEARDOWN; in xpc_teardown_ch_structures()
497 wait_event(part->teardown_wq, (atomic_read(&part->references) == 0)); in xpc_teardown_ch_structures()
503 kfree(part->remote_openclose_args_base); in xpc_teardown_ch_structures()
504 part->remote_openclose_args = NULL; in xpc_teardown_ch_structures()
505 kfree(part->channels); in xpc_teardown_ch_structures()
506 part->channels = NULL; in xpc_teardown_ch_structures()
508 part->setup_state = XPC_P_SS_TORNDOWN; in xpc_teardown_ch_structures()
531 spin_lock_irqsave(&part->act_lock, irq_flags); in xpc_activating()
533 if (part->act_state == XPC_P_AS_DEACTIVATING) { in xpc_activating()
534 part->act_state = XPC_P_AS_INACTIVE; in xpc_activating()
535 spin_unlock_irqrestore(&part->act_lock, irq_flags); in xpc_activating()
536 part->remote_rp_pa = 0; in xpc_activating()
541 DBUG_ON(part->act_state != XPC_P_AS_ACTIVATION_REQ); in xpc_activating()
542 part->act_state = XPC_P_AS_ACTIVATING; in xpc_activating()
545 spin_unlock_irqrestore(&part->act_lock, irq_flags); in xpc_activating()
567 if (part->reason == xpReactivating) { in xpc_activating()
582 spin_lock_irqsave(&part->act_lock, irq_flags); in xpc_activate_partition()
584 DBUG_ON(part->act_state != XPC_P_AS_INACTIVE); in xpc_activate_partition()
586 part->act_state = XPC_P_AS_ACTIVATION_REQ; in xpc_activate_partition()
589 spin_unlock_irqrestore(&part->act_lock, irq_flags); in xpc_activate_partition()
594 spin_lock_irqsave(&part->act_lock, irq_flags); in xpc_activate_partition()
595 part->act_state = XPC_P_AS_INACTIVE; in xpc_activate_partition()
597 spin_unlock_irqrestore(&part->act_lock, irq_flags); in xpc_activate_partition()
604 int idle = atomic_read(&ch->kthreads_idle); in xpc_activate_kthreads()
605 int assigned = atomic_read(&ch->kthreads_assigned); in xpc_activate_kthreads()
606 int wakeup; in xpc_activate_kthreads() local
611 wakeup = (needed > idle) ? idle : needed; in xpc_activate_kthreads()
612 needed -= wakeup; in xpc_activate_kthreads()
614 dev_dbg(xpc_chan, "wakeup %d idle kthreads, partid=%d, " in xpc_activate_kthreads()
615 "channel=%d\n", wakeup, ch->partid, ch->number); in xpc_activate_kthreads()
617 /* only wakeup the requested number of kthreads */ in xpc_activate_kthreads()
618 wake_up_nr(&ch->idle_wq, wakeup); in xpc_activate_kthreads()
624 if (needed + assigned > ch->kthreads_assigned_limit) { in xpc_activate_kthreads()
625 needed = ch->kthreads_assigned_limit - assigned; in xpc_activate_kthreads()
631 needed, ch->partid, ch->number); in xpc_activate_kthreads()
649 !(ch->flags & XPC_C_DISCONNECTING)) { in xpc_kthread_waitmsgs()
653 if (atomic_inc_return(&ch->kthreads_idle) > in xpc_kthread_waitmsgs()
654 ch->kthreads_idle_limit) { in xpc_kthread_waitmsgs()
656 atomic_dec(&ch->kthreads_idle); in xpc_kthread_waitmsgs()
663 (void)wait_event_interruptible_exclusive(ch->idle_wq, in xpc_kthread_waitmsgs()
665 (ch->flags & XPC_C_DISCONNECTING))); in xpc_kthread_waitmsgs()
667 atomic_dec(&ch->kthreads_idle); in xpc_kthread_waitmsgs()
669 } while (!(ch->flags & XPC_C_DISCONNECTING)); in xpc_kthread_waitmsgs()
687 ch = &part->channels[ch_number]; in xpc_kthread_start()
689 if (!(ch->flags & XPC_C_DISCONNECTING)) { in xpc_kthread_start()
693 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
694 if (!(ch->flags & XPC_C_CONNECTEDCALLOUT)) { in xpc_kthread_start()
695 ch->flags |= XPC_C_CONNECTEDCALLOUT; in xpc_kthread_start()
696 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
700 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
701 ch->flags |= XPC_C_CONNECTEDCALLOUT_MADE; in xpc_kthread_start()
702 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
706 * made that the remote partition sent some messages. in xpc_kthread_start()
711 n_needed = n_of_deliverable_payloads(ch) - 1; in xpc_kthread_start()
712 if (n_needed > 0 && !(ch->flags & XPC_C_DISCONNECTING)) in xpc_kthread_start()
716 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
724 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
725 if ((ch->flags & XPC_C_CONNECTEDCALLOUT_MADE) && in xpc_kthread_start()
726 !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) { in xpc_kthread_start()
727 ch->flags |= XPC_C_DISCONNECTINGCALLOUT; in xpc_kthread_start()
728 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
732 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
733 ch->flags |= XPC_C_DISCONNECTINGCALLOUT_MADE; in xpc_kthread_start()
735 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
737 if (atomic_dec_return(&ch->kthreads_assigned) == 0 && in xpc_kthread_start()
738 atomic_dec_return(&part->nchannels_engaged) == 0) { in xpc_kthread_start()
768 u64 args = XPC_PACK_ARGS(ch->partid, ch->number); in xpc_create_kthreads()
769 struct xpc_partition *part = &xpc_partitions[ch->partid]; in xpc_create_kthreads()
774 while (needed-- > 0) { in xpc_create_kthreads()
782 if (!atomic_inc_not_zero(&ch->kthreads_assigned)) { in xpc_create_kthreads()
784 BUG_ON(!(ch->flags & in xpc_create_kthreads()
789 } else if (ch->flags & XPC_C_DISCONNECTING) { in xpc_create_kthreads()
792 } else if (atomic_inc_return(&ch->kthreads_assigned) == 1 && in xpc_create_kthreads()
793 atomic_inc_return(&part->nchannels_engaged) == 1) { in xpc_create_kthreads()
800 "xpc%02dc%d", ch->partid, ch->number); in xpc_create_kthreads()
806 * !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) is true, in xpc_create_kthreads()
814 if (atomic_dec_return(&ch->kthreads_assigned) == 0 && in xpc_create_kthreads()
815 atomic_dec_return(&part->nchannels_engaged) == 0) { in xpc_create_kthreads()
821 if (atomic_read(&ch->kthreads_assigned) < in xpc_create_kthreads()
822 ch->kthreads_idle_limit) { in xpc_create_kthreads()
828 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_create_kthreads()
831 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_create_kthreads()
854 ch = &part->channels[ch_number]; in xpc_disconnect_wait()
856 if (!(ch->flags & XPC_C_WDISCONNECT)) { in xpc_disconnect_wait()
861 wait_for_completion(&ch->wdisconnect_wait); in xpc_disconnect_wait()
863 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_disconnect_wait()
864 DBUG_ON(!(ch->flags & XPC_C_DISCONNECTED)); in xpc_disconnect_wait()
867 if (ch->delayed_chctl_flags) { in xpc_disconnect_wait()
868 if (part->act_state != XPC_P_AS_DEACTIVATING) { in xpc_disconnect_wait()
869 spin_lock(&part->chctl_lock); in xpc_disconnect_wait()
870 part->chctl.flags[ch->number] |= in xpc_disconnect_wait()
871 ch->delayed_chctl_flags; in xpc_disconnect_wait()
872 spin_unlock(&part->chctl_lock); in xpc_disconnect_wait()
875 ch->delayed_chctl_flags = 0; in xpc_disconnect_wait()
878 ch->flags &= ~XPC_C_WDISCONNECT; in xpc_disconnect_wait()
879 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_disconnect_wait()
899 return -ENOMEM; in xpc_setup_partitions()
905 * xpc_disconnect() can be made prior to the activation of any remote in xpc_setup_partitions()
915 part->activate_IRQ_rcvd = 0; in xpc_setup_partitions()
916 spin_lock_init(&part->act_lock); in xpc_setup_partitions()
917 part->act_state = XPC_P_AS_INACTIVE; in xpc_setup_partitions()
920 timer_setup(&part->disengage_timer, in xpc_setup_partitions()
923 part->setup_state = XPC_P_SS_UNSET; in xpc_setup_partitions()
924 init_waitqueue_head(&part->teardown_wq); in xpc_setup_partitions()
925 atomic_set(&part->references, 0); in xpc_setup_partitions()
978 part->act_state == XPC_P_AS_INACTIVE) { in xpc_do_exit()
986 if (part->disengage_timeout > disengage_timeout) in xpc_do_exit()
987 disengage_timeout = part->disengage_timeout; in xpc_do_exit()
992 dev_info(xpc_part, "waiting for remote " in xpc_do_exit()
994 "%ld seconds\n", (disengage_timeout - in xpc_do_exit()
1098 part->act_state != XPC_P_AS_INACTIVE) { in xpc_die_deactivate()
1109 * Given that one iteration through the following while-loop takes in xpc_die_deactivate()
1123 if (!keep_waiting--) { in xpc_die_deactivate()
1128 "remote partition %d timed " in xpc_die_deactivate()
1135 if (!wait_to_print--) { in xpc_die_deactivate()
1136 dev_info(xpc_part, "waiting for remote partitions to " in xpc_die_deactivate()
1192 if (die_args->trapnr == X86_TRAP_DF) in xpc_system_die()
1195 if (((die_args->trapnr == X86_TRAP_MF) || in xpc_system_die()
1196 (die_args->trapnr == X86_TRAP_XF)) && in xpc_system_die()
1197 !user_mode(die_args->regs)) in xpc_system_die()
1227 ret = -ENODEV; in xpc_init()
1264 * The real work-horse behind xpc. This processes incoming in xpc_init()
1265 * interrupts and monitors remote heartbeats. in xpc_init()
1270 ret = -EBUSY; in xpc_init()
1284 /* mark this new thread as a non-starter */ in xpc_init()
1288 return -EBUSY; in xpc_init()