Lines Matching refs:ch

412 	struct xpc_channel *ch;  in xpc_setup_ch_structures()  local
451 ch = &part->channels[ch_number]; in xpc_setup_ch_structures()
453 ch->partid = partid; in xpc_setup_ch_structures()
454 ch->number = ch_number; in xpc_setup_ch_structures()
455 ch->flags = XPC_C_DISCONNECTED; in xpc_setup_ch_structures()
457 atomic_set(&ch->kthreads_assigned, 0); in xpc_setup_ch_structures()
458 atomic_set(&ch->kthreads_idle, 0); in xpc_setup_ch_structures()
459 atomic_set(&ch->kthreads_active, 0); in xpc_setup_ch_structures()
461 atomic_set(&ch->references, 0); in xpc_setup_ch_structures()
462 atomic_set(&ch->n_to_notify, 0); in xpc_setup_ch_structures()
464 spin_lock_init(&ch->lock); in xpc_setup_ch_structures()
465 init_completion(&ch->wdisconnect_wait); in xpc_setup_ch_structures()
467 atomic_set(&ch->n_on_msg_allocate_wq, 0); in xpc_setup_ch_structures()
468 init_waitqueue_head(&ch->msg_allocate_wq); in xpc_setup_ch_structures()
469 init_waitqueue_head(&ch->idle_wq); in xpc_setup_ch_structures()
617 xpc_activate_kthreads(struct xpc_channel *ch, int needed) in xpc_activate_kthreads() argument
619 int idle = atomic_read(&ch->kthreads_idle); in xpc_activate_kthreads()
620 int assigned = atomic_read(&ch->kthreads_assigned); in xpc_activate_kthreads()
630 "channel=%d\n", wakeup, ch->partid, ch->number); in xpc_activate_kthreads()
633 wake_up_nr(&ch->idle_wq, wakeup); in xpc_activate_kthreads()
639 if (needed + assigned > ch->kthreads_assigned_limit) { in xpc_activate_kthreads()
640 needed = ch->kthreads_assigned_limit - assigned; in xpc_activate_kthreads()
646 needed, ch->partid, ch->number); in xpc_activate_kthreads()
648 xpc_create_kthreads(ch, needed, 0); in xpc_activate_kthreads()
655 xpc_kthread_waitmsgs(struct xpc_partition *part, struct xpc_channel *ch) in xpc_kthread_waitmsgs() argument
663 while (n_of_deliverable_payloads(ch) > 0 && in xpc_kthread_waitmsgs()
664 !(ch->flags & XPC_C_DISCONNECTING)) { in xpc_kthread_waitmsgs()
665 xpc_deliver_payload(ch); in xpc_kthread_waitmsgs()
668 if (atomic_inc_return(&ch->kthreads_idle) > in xpc_kthread_waitmsgs()
669 ch->kthreads_idle_limit) { in xpc_kthread_waitmsgs()
671 atomic_dec(&ch->kthreads_idle); in xpc_kthread_waitmsgs()
678 (void)wait_event_interruptible_exclusive(ch->idle_wq, in xpc_kthread_waitmsgs()
679 (n_of_deliverable_payloads(ch) > 0 || in xpc_kthread_waitmsgs()
680 (ch->flags & XPC_C_DISCONNECTING))); in xpc_kthread_waitmsgs()
682 atomic_dec(&ch->kthreads_idle); in xpc_kthread_waitmsgs()
684 } while (!(ch->flags & XPC_C_DISCONNECTING)); in xpc_kthread_waitmsgs()
693 struct xpc_channel *ch; in xpc_kthread_start() local
702 ch = &part->channels[ch_number]; in xpc_kthread_start()
704 if (!(ch->flags & XPC_C_DISCONNECTING)) { in xpc_kthread_start()
708 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
709 if (!(ch->flags & XPC_C_CONNECTEDCALLOUT)) { in xpc_kthread_start()
710 ch->flags |= XPC_C_CONNECTEDCALLOUT; in xpc_kthread_start()
711 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
713 xpc_connected_callout(ch); in xpc_kthread_start()
715 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
716 ch->flags |= XPC_C_CONNECTEDCALLOUT_MADE; in xpc_kthread_start()
717 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
726 n_needed = n_of_deliverable_payloads(ch) - 1; in xpc_kthread_start()
727 if (n_needed > 0 && !(ch->flags & XPC_C_DISCONNECTING)) in xpc_kthread_start()
728 xpc_activate_kthreads(ch, n_needed); in xpc_kthread_start()
731 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
734 xpc_kthread_waitmsgs(part, ch); in xpc_kthread_start()
739 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
740 if ((ch->flags & XPC_C_CONNECTEDCALLOUT_MADE) && in xpc_kthread_start()
741 !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) { in xpc_kthread_start()
742 ch->flags |= XPC_C_DISCONNECTINGCALLOUT; in xpc_kthread_start()
743 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
745 xpc_disconnect_callout(ch, xpDisconnecting); in xpc_kthread_start()
747 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_kthread_start()
748 ch->flags |= XPC_C_DISCONNECTINGCALLOUT_MADE; in xpc_kthread_start()
750 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_kthread_start()
752 if (atomic_dec_return(&ch->kthreads_assigned) == 0 && in xpc_kthread_start()
757 xpc_msgqueue_deref(ch); in xpc_kthread_start()
779 xpc_create_kthreads(struct xpc_channel *ch, int needed, in xpc_create_kthreads() argument
783 u64 args = XPC_PACK_ARGS(ch->partid, ch->number); in xpc_create_kthreads()
784 struct xpc_partition *part = &xpc_partitions[ch->partid]; in xpc_create_kthreads()
797 if (!atomic_inc_not_zero(&ch->kthreads_assigned)) { in xpc_create_kthreads()
799 BUG_ON(!(ch->flags & in xpc_create_kthreads()
804 } else if (ch->flags & XPC_C_DISCONNECTING) { in xpc_create_kthreads()
807 } else if (atomic_inc_return(&ch->kthreads_assigned) == 1 && in xpc_create_kthreads()
812 xpc_msgqueue_ref(ch); in xpc_create_kthreads()
815 "xpc%02dc%d", ch->partid, ch->number); in xpc_create_kthreads()
829 if (atomic_dec_return(&ch->kthreads_assigned) == 0 && in xpc_create_kthreads()
833 xpc_msgqueue_deref(ch); in xpc_create_kthreads()
836 if (atomic_read(&ch->kthreads_assigned) < in xpc_create_kthreads()
837 ch->kthreads_idle_limit) { in xpc_create_kthreads()
843 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_create_kthreads()
844 XPC_DISCONNECT_CHANNEL(ch, xpLackOfResources, in xpc_create_kthreads()
846 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_create_kthreads()
859 struct xpc_channel *ch; in xpc_disconnect_wait() local
869 ch = &part->channels[ch_number]; in xpc_disconnect_wait()
871 if (!(ch->flags & XPC_C_WDISCONNECT)) { in xpc_disconnect_wait()
876 wait_for_completion(&ch->wdisconnect_wait); in xpc_disconnect_wait()
878 spin_lock_irqsave(&ch->lock, irq_flags); in xpc_disconnect_wait()
879 DBUG_ON(!(ch->flags & XPC_C_DISCONNECTED)); in xpc_disconnect_wait()
882 if (ch->delayed_chctl_flags) { in xpc_disconnect_wait()
885 part->chctl.flags[ch->number] |= in xpc_disconnect_wait()
886 ch->delayed_chctl_flags; in xpc_disconnect_wait()
890 ch->delayed_chctl_flags = 0; in xpc_disconnect_wait()
893 ch->flags &= ~XPC_C_WDISCONNECT; in xpc_disconnect_wait()
894 spin_unlock_irqrestore(&ch->lock, irq_flags); in xpc_disconnect_wait()