Lines Matching +full:wake +full:- +full:on +full:- +full:motion

7  * Copyright (c) 2004-2009 Silicon Graphics, Inc.  All Rights Reserved.
11 * Cross Partition Communication (XPC) support - standard version.
29 * . Currently on sn2, we have no way to determine which nasid an IRQ
128 /* non-zero if any remote partition disengage was timed out */
135 /* IRQ handler notifies this wait queue on receipt of an IRQ */
162 * Timer function to enforce the timelimit on the partition disengage.
169 DBUG_ON(time_is_after_jiffies(part->disengage_timeout)); in xpc_timeout_partition_disengage()
173 DBUG_ON(part->disengage_timeout != 0); in xpc_timeout_partition_disengage()
230 if (part->act_state == XPC_P_AS_INACTIVE || in xpc_check_remote_hb()
231 part->act_state == XPC_P_AS_DEACTIVATING) { in xpc_check_remote_hb()
254 /* set our heartbeating to other partitions into motion */ in xpc_hb_checker()
262 (int)(xpc_hb_check_timeout - jiffies), in xpc_hb_checker()
301 * based on info provided by SAL. This new thread is short lived and
318 * created by XPC HB with which it calls xpc_activating(). XPC hangs on to
331 while (part->act_state != XPC_P_AS_DEACTIVATING || in xpc_channel_mgr()
332 atomic_read(&part->nchannels_active) > 0 || in xpc_channel_mgr()
348 * wake him up. in xpc_channel_mgr()
350 atomic_dec(&part->channel_mgr_requests); in xpc_channel_mgr()
351 (void)wait_event_interruptible(part->channel_mgr_wq, in xpc_channel_mgr()
352 (atomic_read(&part->channel_mgr_requests) > 0 || in xpc_channel_mgr()
353 part->chctl.all_flags != 0 || in xpc_channel_mgr()
354 (part->act_state == XPC_P_AS_DEACTIVATING && in xpc_channel_mgr()
355 atomic_read(&part->nchannels_active) == 0 && in xpc_channel_mgr()
357 atomic_set(&part->channel_mgr_requests, 1); in xpc_channel_mgr()
401 DBUG_ON(part->channels != NULL); in xpc_setup_ch_structures()
402 part->channels = kcalloc(XPC_MAX_NCHANNELS, in xpc_setup_ch_structures()
405 if (part->channels == NULL) { in xpc_setup_ch_structures()
412 part->remote_openclose_args = in xpc_setup_ch_structures()
414 GFP_KERNEL, &part-> in xpc_setup_ch_structures()
416 if (part->remote_openclose_args == NULL) { in xpc_setup_ch_structures()
422 part->chctl.all_flags = 0; in xpc_setup_ch_structures()
423 spin_lock_init(&part->chctl_lock); in xpc_setup_ch_structures()
425 atomic_set(&part->channel_mgr_requests, 1); in xpc_setup_ch_structures()
426 init_waitqueue_head(&part->channel_mgr_wq); in xpc_setup_ch_structures()
428 part->nchannels = XPC_MAX_NCHANNELS; in xpc_setup_ch_structures()
430 atomic_set(&part->nchannels_active, 0); in xpc_setup_ch_structures()
431 atomic_set(&part->nchannels_engaged, 0); in xpc_setup_ch_structures()
433 for (ch_number = 0; ch_number < part->nchannels; ch_number++) { in xpc_setup_ch_structures()
434 ch = &part->channels[ch_number]; in xpc_setup_ch_structures()
436 ch->partid = partid; in xpc_setup_ch_structures()
437 ch->number = ch_number; in xpc_setup_ch_structures()
438 ch->flags = XPC_C_DISCONNECTED; in xpc_setup_ch_structures()
440 atomic_set(&ch->kthreads_assigned, 0); in xpc_setup_ch_structures()
441 atomic_set(&ch->kthreads_idle, 0); in xpc_setup_ch_structures()
442 atomic_set(&ch->kthreads_active, 0); in xpc_setup_ch_structures()
444 atomic_set(&ch->references, 0); in xpc_setup_ch_structures()
445 atomic_set(&ch->n_to_notify, 0); in xpc_setup_ch_structures()
447 spin_lock_init(&ch->lock); in xpc_setup_ch_structures()
448 init_completion(&ch->wdisconnect_wait); in xpc_setup_ch_structures()
450 atomic_set(&ch->n_on_msg_allocate_wq, 0); in xpc_setup_ch_structures()
451 init_waitqueue_head(&ch->msg_allocate_wq); in xpc_setup_ch_structures()
452 init_waitqueue_head(&ch->idle_wq); in xpc_setup_ch_structures()
463 part->setup_state = XPC_P_SS_SETUP; in xpc_setup_ch_structures()
469 kfree(part->remote_openclose_args_base); in xpc_setup_ch_structures()
470 part->remote_openclose_args = NULL; in xpc_setup_ch_structures()
472 kfree(part->channels); in xpc_setup_ch_structures()
473 part->channels = NULL; in xpc_setup_ch_structures()
484 DBUG_ON(atomic_read(&part->nchannels_engaged) != 0); in xpc_teardown_ch_structures()
485 DBUG_ON(atomic_read(&part->nchannels_active) != 0); in xpc_teardown_ch_structures()
492 DBUG_ON(part->setup_state != XPC_P_SS_SETUP); in xpc_teardown_ch_structures()
493 part->setup_state = XPC_P_SS_WTEARDOWN; in xpc_teardown_ch_structures()
495 wait_event(part->teardown_wq, (atomic_read(&part->references) == 0)); in xpc_teardown_ch_structures()
501 kfree(part->remote_openclose_args_base); in xpc_teardown_ch_structures()
502 part->remote_openclose_args = NULL; in xpc_teardown_ch_structures()
503 kfree(part->channels); in xpc_teardown_ch_structures()
504 part->channels = NULL; in xpc_teardown_ch_structures()
506 part->setup_state = XPC_P_SS_TORNDOWN; in xpc_teardown_ch_structures()
529 spin_lock_irqsave(&part->act_lock, irq_flags); in xpc_activating()
531 if (part->act_state == XPC_P_AS_DEACTIVATING) { in xpc_activating()
532 part->act_state = XPC_P_AS_INACTIVE; in xpc_activating()
533 spin_unlock_irqrestore(&part->act_lock, irq_flags); in xpc_activating()
534 part->remote_rp_pa = 0; in xpc_activating()
539 DBUG_ON(part->act_state != XPC_P_AS_ACTIVATION_REQ); in xpc_activating()
540 part->act_state = XPC_P_AS_ACTIVATING; in xpc_activating()
543 spin_unlock_irqrestore(&part->act_lock, irq_flags); in xpc_activating()
565 if (part->reason == xpReactivating) { in xpc_activating()
580 spin_lock_irqsave(&part->act_lock, irq_flags); in xpc_activate_partition()
582 DBUG_ON(part->act_state != XPC_P_AS_INACTIVE); in xpc_activate_partition()
584 part->act_state = XPC_P_AS_ACTIVATION_REQ; in xpc_activate_partition()
587 spin_unlock_irqrestore(&part->act_lock, irq_flags); in xpc_activate_partition()
592 spin_lock_irqsave(&part->act_lock, irq_flags); in xpc_activate_partition()
593 part->act_state = XPC_P_AS_INACTIVE; in xpc_activate_partition()
595 spin_unlock_irqrestore(&part->act_lock, irq_flags); in xpc_activate_partition()
602 int idle = atomic_read(&ch->kthreads_idle); in xpc_activate_kthreads()
603 int assigned = atomic_read(&ch->kthreads_assigned); in xpc_activate_kthreads()
610 needed -= wakeup; in xpc_activate_kthreads()
613 "channel=%d\n", wakeup, ch->partid, ch->number); in xpc_activate_kthreads()
616 wake_up_nr(&ch->idle_wq, wakeup); in xpc_activate_kthreads()
622 if (needed + assigned > ch->kthreads_assigned_limit) { in xpc_activate_kthreads()
623 needed = ch->kthreads_assigned_limit - assigned; in xpc_activate_kthreads()
629 needed, ch->partid, ch->number); in xpc_activate_kthreads()
647 !(ch->flags & XPC_C_DISCONNECTING)) { in xpc_kthread_waitmsgs()
651 if (atomic_inc_return(&ch->kthreads_idle) > in xpc_kthread_waitmsgs()
652 ch->kthreads_idle_limit) { in xpc_kthread_waitmsgs()
653 /* too many idle kthreads on this channel */ in xpc_kthread_waitmsgs()
654 atomic_dec(&ch->kthreads_idle); in xpc_kthread_waitmsgs()
661 (void)wait_event_interruptible_exclusive(ch->idle_wq, in xpc_kthread_waitmsgs()
663 (ch->flags & XPC_C_DISCONNECTING))); in xpc_kthread_waitmsgs()
665 atomic_dec(&ch->kthreads_idle); in xpc_kthread_waitmsgs()
667 } while (!(ch->flags & XPC_C_DISCONNECTING)); in xpc_kthread_waitmsgs()
685 ch = &part->channels[ch_number]; in xpc_kthread_start()
687 if (!(ch->flags & XPC_C_DISCONNECTING)) { in xpc_kthread_start()
691 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
692 if (!(ch->flags & XPC_C_CONNECTEDCALLOUT)) { in xpc_kthread_start()
693 ch->flags |= XPC_C_CONNECTEDCALLOUT; in xpc_kthread_start()
694 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
698 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
699 ch->flags |= XPC_C_CONNECTEDCALLOUT_MADE; in xpc_kthread_start()
700 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
709 n_needed = n_of_deliverable_payloads(ch) - 1; in xpc_kthread_start()
710 if (n_needed > 0 && !(ch->flags & XPC_C_DISCONNECTING)) in xpc_kthread_start()
714 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
722 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
723 if ((ch->flags & XPC_C_CONNECTEDCALLOUT_MADE) && in xpc_kthread_start()
724 !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) { in xpc_kthread_start()
725 ch->flags |= XPC_C_DISCONNECTINGCALLOUT; in xpc_kthread_start()
726 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
730 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
731 ch->flags |= XPC_C_DISCONNECTINGCALLOUT_MADE; in xpc_kthread_start()
733 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
735 if (atomic_dec_return(&ch->kthreads_assigned) == 0 && in xpc_kthread_start()
736 atomic_dec_return(&part->nchannels_engaged) == 0) { in xpc_kthread_start()
766 u64 args = XPC_PACK_ARGS(ch->partid, ch->number); in xpc_create_kthreads()
767 struct xpc_partition *part = &xpc_partitions[ch->partid]; in xpc_create_kthreads()
772 while (needed-- > 0) { in xpc_create_kthreads()
775 * The following is done on behalf of the newly created in xpc_create_kthreads()
780 if (!atomic_inc_not_zero(&ch->kthreads_assigned)) { in xpc_create_kthreads()
782 BUG_ON(!(ch->flags & in xpc_create_kthreads()
787 } else if (ch->flags & XPC_C_DISCONNECTING) { in xpc_create_kthreads()
790 } else if (atomic_inc_return(&ch->kthreads_assigned) == 1 && in xpc_create_kthreads()
791 atomic_inc_return(&part->nchannels_engaged) == 1) { in xpc_create_kthreads()
798 "xpc%02dc%d", ch->partid, ch->number); in xpc_create_kthreads()
804 * !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) is true, in xpc_create_kthreads()
812 if (atomic_dec_return(&ch->kthreads_assigned) == 0 && in xpc_create_kthreads()
813 atomic_dec_return(&part->nchannels_engaged) == 0) { in xpc_create_kthreads()
819 if (atomic_read(&ch->kthreads_assigned) < in xpc_create_kthreads()
820 ch->kthreads_idle_limit) { in xpc_create_kthreads()
826 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_create_kthreads()
829 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_create_kthreads()
852 ch = &part->channels[ch_number]; in xpc_disconnect_wait()
854 if (!(ch->flags & XPC_C_WDISCONNECT)) { in xpc_disconnect_wait()
859 wait_for_completion(&ch->wdisconnect_wait); in xpc_disconnect_wait()
861 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_disconnect_wait()
862 DBUG_ON(!(ch->flags & XPC_C_DISCONNECTED)); in xpc_disconnect_wait()
865 if (ch->delayed_chctl_flags) { in xpc_disconnect_wait()
866 if (part->act_state != XPC_P_AS_DEACTIVATING) { in xpc_disconnect_wait()
867 spin_lock(&part->chctl_lock); in xpc_disconnect_wait()
868 part->chctl.flags[ch->number] |= in xpc_disconnect_wait()
869 ch->delayed_chctl_flags; in xpc_disconnect_wait()
870 spin_unlock(&part->chctl_lock); in xpc_disconnect_wait()
873 ch->delayed_chctl_flags = 0; in xpc_disconnect_wait()
876 ch->flags &= ~XPC_C_WDISCONNECT; in xpc_disconnect_wait()
877 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_disconnect_wait()
897 return -ENOMEM; in xpc_setup_partitions()
913 part->activate_IRQ_rcvd = 0; in xpc_setup_partitions()
914 spin_lock_init(&part->act_lock); in xpc_setup_partitions()
915 part->act_state = XPC_P_AS_INACTIVE; in xpc_setup_partitions()
918 timer_setup(&part->disengage_timer, in xpc_setup_partitions()
921 part->setup_state = XPC_P_SS_UNSET; in xpc_setup_partitions()
922 init_waitqueue_head(&part->teardown_wq); in xpc_setup_partitions()
923 atomic_set(&part->references, 0); in xpc_setup_partitions()
949 * (if one is running) know that they should exit. Also wake up in xpc_do_exit()
976 part->act_state == XPC_P_AS_INACTIVE) { in xpc_do_exit()
984 if (part->disengage_timeout > disengage_timeout) in xpc_do_exit()
985 disengage_timeout = part->disengage_timeout; in xpc_do_exit()
992 "%ld seconds\n", (disengage_timeout - in xpc_do_exit()
1096 part->act_state != XPC_P_AS_INACTIVE) { in xpc_die_deactivate()
1107 * Given that one iteration through the following while-loop takes in xpc_die_deactivate()
1121 if (!keep_waiting--) { in xpc_die_deactivate()
1133 if (!wait_to_print--) { in xpc_die_deactivate()
1160 if (die_args->trapnr == X86_TRAP_DF) in xpc_system_die()
1163 if (((die_args->trapnr == X86_TRAP_MF) || in xpc_system_die()
1164 (die_args->trapnr == X86_TRAP_XF)) && in xpc_system_die()
1165 !user_mode(die_args->regs)) in xpc_system_die()
1194 ret = -ENODEV; in xpc_init()
1231 * The real work-horse behind xpc. This processes incoming in xpc_init()
1237 ret = -EBUSY; in xpc_init()
1243 * activate based on info provided by SAL. This new thread is short in xpc_init()
1251 /* mark this new thread as a non-starter */ in xpc_init()
1255 return -EBUSY; in xpc_init()