aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/sgi-xp/xpc_sn2.c
diff options
context:
space:
mode:
authorDean Nelson <dcn@sgi.com>2008-07-30 01:34:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-30 12:41:49 -0400
commit97bf1aa1e1bb18de9bb1987c6eb9ad751bf08aab (patch)
treec07472cdffc9c53aefa7f7eeb6098b18bc4f7ac1 /drivers/misc/sgi-xp/xpc_sn2.c
parentaaa3cd694c0c4ae534e8aafdf4227e395c57d6bd (diff)
sgi-xp: move xpc_allocate() into xpc_send()/xpc_send_notify()
Move xpc_allocate() functionality into xpc_send()/xpc_send_notify() so xpc_allocate() no longer needs to be called by XPNET. Signed-off-by: Dean Nelson <dcn@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/misc/sgi-xp/xpc_sn2.c')
-rw-r--r--drivers/misc/sgi-xp/xpc_sn2.c64
1 files changed, 29 insertions, 35 deletions
diff --git a/drivers/misc/sgi-xp/xpc_sn2.c b/drivers/misc/sgi-xp/xpc_sn2.c
index 7216df36bc73..db67d348b35c 100644
--- a/drivers/misc/sgi-xp/xpc_sn2.c
+++ b/drivers/misc/sgi-xp/xpc_sn2.c
@@ -1532,18 +1532,6 @@ xpc_allocate_msg_sn2(struct xpc_channel *ch, u32 flags,
1532 enum xp_retval ret; 1532 enum xp_retval ret;
1533 s64 put; 1533 s64 put;
1534 1534
1535 /* this reference will be dropped in xpc_send_msg_sn2() */
1536 xpc_msgqueue_ref(ch);
1537
1538 if (ch->flags & XPC_C_DISCONNECTING) {
1539 xpc_msgqueue_deref(ch);
1540 return ch->reason;
1541 }
1542 if (!(ch->flags & XPC_C_CONNECTED)) {
1543 xpc_msgqueue_deref(ch);
1544 return xpNotConnected;
1545 }
1546
1547 /* 1535 /*
1548 * Get the next available message entry from the local message queue. 1536 * Get the next available message entry from the local message queue.
1549 * If none are available, we'll make sure that we grab the latest 1537 * If none are available, we'll make sure that we grab the latest
@@ -1582,16 +1570,12 @@ xpc_allocate_msg_sn2(struct xpc_channel *ch, u32 flags,
1582 if (ret == xpTimeout) 1570 if (ret == xpTimeout)
1583 xpc_IPI_send_local_msgrequest_sn2(ch); 1571 xpc_IPI_send_local_msgrequest_sn2(ch);
1584 1572
1585 if (flags & XPC_NOWAIT) { 1573 if (flags & XPC_NOWAIT)
1586 xpc_msgqueue_deref(ch);
1587 return xpNoWait; 1574 return xpNoWait;
1588 }
1589 1575
1590 ret = xpc_allocate_msg_wait(ch); 1576 ret = xpc_allocate_msg_wait(ch);
1591 if (ret != xpInterrupted && ret != xpTimeout) { 1577 if (ret != xpInterrupted && ret != xpTimeout)
1592 xpc_msgqueue_deref(ch);
1593 return ret; 1578 return ret;
1594 }
1595 } 1579 }
1596 1580
1597 /* get the message's address and initialize it */ 1581 /* get the message's address and initialize it */
@@ -1606,7 +1590,6 @@ xpc_allocate_msg_sn2(struct xpc_channel *ch, u32 flags,
1606 (void *)msg, msg->number, ch->partid, ch->number); 1590 (void *)msg, msg->number, ch->partid, ch->number);
1607 1591
1608 *address_of_msg = msg; 1592 *address_of_msg = msg;
1609
1610 return xpSuccess; 1593 return xpSuccess;
1611} 1594}
1612 1595
@@ -1616,24 +1599,38 @@ xpc_allocate_msg_sn2(struct xpc_channel *ch, u32 flags,
1616 * message is being sent to. 1599 * message is being sent to.
1617 */ 1600 */
1618static enum xp_retval 1601static enum xp_retval
1619xpc_send_msg_sn2(struct xpc_channel *ch, struct xpc_msg *msg, u8 notify_type, 1602xpc_send_msg_sn2(struct xpc_channel *ch, u32 flags, void *payload,
1620 xpc_notify_func func, void *key) 1603 u16 payload_size, u8 notify_type, xpc_notify_func func,
1604 void *key)
1621{ 1605{
1622 enum xp_retval ret = xpSuccess; 1606 enum xp_retval ret = xpSuccess;
1607 struct xpc_msg *msg = msg;
1623 struct xpc_notify *notify = notify; 1608 struct xpc_notify *notify = notify;
1624 s64 put, msg_number = msg->number; 1609 s64 msg_number;
1610 s64 put;
1625 1611
1626 DBUG_ON(notify_type == XPC_N_CALL && func == NULL); 1612 DBUG_ON(notify_type == XPC_N_CALL && func == NULL);
1627 DBUG_ON((((u64)msg - (u64)ch->local_msgqueue) / ch->msg_size) != 1613
1628 msg_number % ch->local_nentries); 1614 if (XPC_MSG_SIZE(payload_size) > ch->msg_size)
1629 DBUG_ON(msg->flags & XPC_M_READY); 1615 return xpPayloadTooBig;
1616
1617 xpc_msgqueue_ref(ch);
1630 1618
1631 if (ch->flags & XPC_C_DISCONNECTING) { 1619 if (ch->flags & XPC_C_DISCONNECTING) {
1632 /* drop the reference grabbed in xpc_allocate_msg_sn2() */ 1620 ret = ch->reason;
1633 xpc_msgqueue_deref(ch); 1621 goto out_1;
1634 return ch->reason; 1622 }
1623 if (!(ch->flags & XPC_C_CONNECTED)) {
1624 ret = xpNotConnected;
1625 goto out_1;
1635 } 1626 }
1636 1627
1628 ret = xpc_allocate_msg_sn2(ch, flags, &msg);
1629 if (ret != xpSuccess)
1630 goto out_1;
1631
1632 msg_number = msg->number;
1633
1637 if (notify_type != 0) { 1634 if (notify_type != 0) {
1638 /* 1635 /*
1639 * Tell the remote side to send an ACK interrupt when the 1636 * Tell the remote side to send an ACK interrupt when the
@@ -1663,13 +1660,12 @@ xpc_send_msg_sn2(struct xpc_channel *ch, struct xpc_msg *msg, u8 notify_type,
1663 atomic_dec(&ch->n_to_notify); 1660 atomic_dec(&ch->n_to_notify);
1664 ret = ch->reason; 1661 ret = ch->reason;
1665 } 1662 }
1666 1663 goto out_1;
1667 /* drop reference grabbed in xpc_allocate_msg_sn2() */
1668 xpc_msgqueue_deref(ch);
1669 return ret;
1670 } 1664 }
1671 } 1665 }
1672 1666
1667 memcpy(&msg->payload, payload, payload_size);
1668
1673 msg->flags |= XPC_M_READY; 1669 msg->flags |= XPC_M_READY;
1674 1670
1675 /* 1671 /*
@@ -1684,7 +1680,7 @@ xpc_send_msg_sn2(struct xpc_channel *ch, struct xpc_msg *msg, u8 notify_type,
1684 if (put == msg_number) 1680 if (put == msg_number)
1685 xpc_send_msgs_sn2(ch, put); 1681 xpc_send_msgs_sn2(ch, put);
1686 1682
1687 /* drop the reference grabbed in xpc_allocate_msg_sn2() */ 1683out_1:
1688 xpc_msgqueue_deref(ch); 1684 xpc_msgqueue_deref(ch);
1689 return ret; 1685 return ret;
1690} 1686}
@@ -1821,8 +1817,6 @@ xpc_init_sn2(void)
1821 xpc_IPI_send_openrequest = xpc_IPI_send_openrequest_sn2; 1817 xpc_IPI_send_openrequest = xpc_IPI_send_openrequest_sn2;
1822 xpc_IPI_send_openreply = xpc_IPI_send_openreply_sn2; 1818 xpc_IPI_send_openreply = xpc_IPI_send_openreply_sn2;
1823 1819
1824 xpc_allocate_msg = xpc_allocate_msg_sn2;
1825
1826 xpc_send_msg = xpc_send_msg_sn2; 1820 xpc_send_msg = xpc_send_msg_sn2;
1827 xpc_received_msg = xpc_received_msg_sn2; 1821 xpc_received_msg = xpc_received_msg_sn2;
1828} 1822}