static enum xp_retval xpc_allocate_send_msg_slot_uv(struct xpc_channel *ch) { struct xpc_channel_uv *ch_uv = &ch->sn.uv; struct xpc_send_msg_slot_uv *msg_slot; unsigned long irq_flags; int nentries; int entry; size_t nbytes; for (nentries = ch->local_nentries; nentries > 0; nentries--) { nbytes = nentries * sizeof(struct xpc_send_msg_slot_uv); ch_uv->send_msg_slots = kzalloc(nbytes, GFP_KERNEL); if (ch_uv->send_msg_slots == NULL) continue; for (entry = 0; entry < nentries; entry++) { msg_slot = &ch_uv->send_msg_slots[entry]; msg_slot->msg_slot_number = entry; xpc_put_fifo_entry_uv(&ch_uv->msg_slot_free_list, &msg_slot->next); } spin_lock_irqsave(&ch->lock, irq_flags); if (nentries < ch->local_nentries) ch->local_nentries = nentries; spin_unlock_irqrestore(&ch->lock, irq_flags); return xpSuccess; } return xpNoMemory; }
static void xpc_free_msg_slot_uv(struct xpc_channel *ch, struct xpc_send_msg_slot_uv *msg_slot) { xpc_put_fifo_entry_uv(&ch->sn.uv.msg_slot_free_list, &msg_slot->next); /* wakeup anyone waiting for a free msg slot */ if (atomic_read(&ch->n_on_msg_allocate_wq) > 0) wake_up(&ch->msg_allocate_wq); }
static void xpc_handle_notify_mq_msg_uv(struct xpc_partition *part, struct xpc_notify_mq_msg_uv *msg) { struct xpc_partition_uv *part_uv = &part->sn.uv; struct xpc_channel *ch; struct xpc_channel_uv *ch_uv; struct xpc_notify_mq_msg_uv *msg_slot; unsigned long irq_flags; int ch_number = msg->hdr.ch_number; if (unlikely(ch_number >= part->nchannels)) { dev_err(xpc_part, "xpc_handle_notify_IRQ_uv() received invalid " "channel number=0x%x in message from partid=%d\n", ch_number, XPC_PARTID(part)); /* get hb checker to deactivate from the remote partition */ spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock, irq_flags); if (part_uv->act_state_req == 0) xpc_activate_IRQ_rcvd++; part_uv->act_state_req = XPC_P_ASR_DEACTIVATE_UV; part_uv->reason = xpBadChannelNumber; spin_unlock_irqrestore(&xpc_activate_IRQ_rcvd_lock, irq_flags); wake_up_interruptible(&xpc_activate_IRQ_wq); return; } ch = &part->channels[ch_number]; xpc_msgqueue_ref(ch); if (!(ch->flags & XPC_C_CONNECTED)) { xpc_msgqueue_deref(ch); return; } /* see if we're really dealing with an ACK for a previously sent msg */ if (msg->hdr.size == 0) { xpc_handle_notify_mq_ack_uv(ch, msg); xpc_msgqueue_deref(ch); return; } /* we're dealing with a normal message sent via the notify_mq */ ch_uv = &ch->sn.uv; msg_slot = ch_uv->recv_msg_slots + (msg->hdr.msg_slot_number % ch->remote_nentries) * ch->entry_size; BUG_ON(msg_slot->hdr.size != 0); memcpy(msg_slot, msg, msg->hdr.size); xpc_put_fifo_entry_uv(&ch_uv->recv_msg_list, &msg_slot->hdr.u.next); if (ch->flags & XPC_C_CONNECTEDCALLOUT_MADE) { /* * If there is an existing idle kthread get it to deliver * the payload, otherwise we'll have to get the channel mgr * for this partition to create a kthread to do the delivery. */ if (atomic_read(&ch->kthreads_idle) > 0) wake_up_nr(&ch->idle_wq, 1); else xpc_send_chctl_local_msgrequest_uv(part, ch->number); } xpc_msgqueue_deref(ch); }
static void xpc_handle_notify_mq_msg_uv(struct xpc_partition *part, struct xpc_notify_mq_msg_uv *msg) { struct xpc_partition_uv *part_uv = &part->sn.uv; struct xpc_channel *ch; struct xpc_channel_uv *ch_uv; struct xpc_notify_mq_msg_uv *msg_slot; unsigned long irq_flags; int ch_number = msg->hdr.ch_number; if (unlikely(ch_number >= part->nchannels)) { dev_err(xpc_part, "xpc_handle_notify_IRQ_uv() received invalid " "channel number=0x%x in message from partid=%d\n", ch_number, XPC_PARTID(part)); spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock, irq_flags); if (part_uv->act_state_req == 0) xpc_activate_IRQ_rcvd++; part_uv->act_state_req = XPC_P_ASR_DEACTIVATE_UV; part_uv->reason = xpBadChannelNumber; spin_unlock_irqrestore(&xpc_activate_IRQ_rcvd_lock, irq_flags); wake_up_interruptible(&xpc_activate_IRQ_wq); return; } ch = &part->channels[ch_number]; xpc_msgqueue_ref(ch); if (!(ch->flags & XPC_C_CONNECTED)) { xpc_msgqueue_deref(ch); return; } if (msg->hdr.size == 0) { xpc_handle_notify_mq_ack_uv(ch, msg); xpc_msgqueue_deref(ch); return; } ch_uv = &ch->sn.uv; msg_slot = ch_uv->recv_msg_slots + (msg->hdr.msg_slot_number % ch->remote_nentries) * ch->entry_size; BUG_ON(msg->hdr.msg_slot_number != msg_slot->hdr.msg_slot_number); BUG_ON(msg_slot->hdr.size != 0); memcpy(msg_slot, msg, msg->hdr.size); xpc_put_fifo_entry_uv(&ch_uv->recv_msg_list, &msg_slot->hdr.u.next); if (ch->flags & XPC_C_CONNECTEDCALLOUT_MADE) { if (atomic_read(&ch->kthreads_idle) > 0) wake_up_nr(&ch->idle_wq, 1); else xpc_send_chctl_local_msgrequest_uv(part, ch->number); } xpc_msgqueue_deref(ch); }