aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/sgi-xp/xpc_channel.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_channel.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_channel.c')
-rw-r--r--drivers/misc/sgi-xp/xpc_channel.c112
1 files changed, 39 insertions, 73 deletions
diff --git a/drivers/misc/sgi-xp/xpc_channel.c b/drivers/misc/sgi-xp/xpc_channel.c
index 26c5e12c1220..55182c8dd32a 100644
--- a/drivers/misc/sgi-xp/xpc_channel.c
+++ b/drivers/misc/sgi-xp/xpc_channel.c
@@ -1192,87 +1192,54 @@ xpc_allocate_msg_wait(struct xpc_channel *ch)
1192} 1192}
1193 1193
1194/* 1194/*
1195 * Allocate an entry for a message from the message queue associated with the 1195 * Send a message that contains the user's payload on the specified channel
1196 * specified channel. NOTE that this routine can sleep waiting for a message 1196 * connected to the specified partition.
1197 * entry to become available. To not sleep, pass in the XPC_NOWAIT flag.
1198 * 1197 *
1199 * Arguments: 1198 * NOTE that this routine can sleep waiting for a message entry to become
1199 * available. To not sleep, pass in the XPC_NOWAIT flag.
1200 * 1200 *
1201 * partid - ID of partition to which the channel is connected. 1201 * Once sent, this routine will not wait for the message to be received, nor
1202 * ch_number - channel #. 1202 * will notification be given when it does happen.
1203 * flags - see xpc.h for valid flags.
1204 * payload - address of the allocated payload area pointer (filled in on
1205 * return) in which the user-defined message is constructed.
1206 */
1207enum xp_retval
1208xpc_initiate_allocate(short partid, int ch_number, u32 flags, void **payload)
1209{
1210 struct xpc_partition *part = &xpc_partitions[partid];
1211 enum xp_retval ret = xpUnknownReason;
1212 struct xpc_msg *msg = NULL;
1213
1214 DBUG_ON(partid < 0 || partid >= xp_max_npartitions);
1215 DBUG_ON(ch_number < 0 || ch_number >= part->nchannels);
1216
1217 *payload = NULL;
1218
1219 if (xpc_part_ref(part)) {
1220 ret = xpc_allocate_msg(&part->channels[ch_number], flags, &msg);
1221 xpc_part_deref(part);
1222
1223 if (msg != NULL)
1224 *payload = &msg->payload;
1225 }
1226
1227 return ret;
1228}
1229
1230/*
1231 * Send a message previously allocated using xpc_initiate_allocate() on the
1232 * specified channel connected to the specified partition.
1233 *
1234 * This routine will not wait for the message to be received, nor will
1235 * notification be given when it does happen. Once this routine has returned
1236 * the message entry allocated via xpc_initiate_allocate() is no longer
1237 * accessable to the caller.
1238 *
1239 * This routine, although called by users, does not call xpc_part_ref() to
1240 * ensure that the partition infrastructure is in place. It relies on the
1241 * fact that we called xpc_msgqueue_ref() in xpc_allocate_msg().
1242 * 1203 *
1243 * Arguments: 1204 * Arguments:
1244 * 1205 *
1245 * partid - ID of partition to which the channel is connected. 1206 * partid - ID of partition to which the channel is connected.
1246 * ch_number - channel # to send message on. 1207 * ch_number - channel # to send message on.
1247 * payload - pointer to the payload area allocated via 1208 * flags - see xp.h for valid flags.
1248 * xpc_initiate_allocate(). 1209 * payload - pointer to the payload which is to be sent.
1210 * payload_size - size of the payload in bytes.
1249 */ 1211 */
1250enum xp_retval 1212enum xp_retval
1251xpc_initiate_send(short partid, int ch_number, void *payload) 1213xpc_initiate_send(short partid, int ch_number, u32 flags, void *payload,
1214 u16 payload_size)
1252{ 1215{
1253 struct xpc_partition *part = &xpc_partitions[partid]; 1216 struct xpc_partition *part = &xpc_partitions[partid];
1254 struct xpc_msg *msg = XPC_MSG_ADDRESS(payload); 1217 enum xp_retval ret = xpUnknownReason;
1255 enum xp_retval ret;
1256 1218
1257 dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *)msg, 1219 dev_dbg(xpc_chan, "payload=0x%p, partid=%d, channel=%d\n", payload,
1258 partid, ch_number); 1220 partid, ch_number);
1259 1221
1260 DBUG_ON(partid < 0 || partid >= xp_max_npartitions); 1222 DBUG_ON(partid < 0 || partid >= xp_max_npartitions);
1261 DBUG_ON(ch_number < 0 || ch_number >= part->nchannels); 1223 DBUG_ON(ch_number < 0 || ch_number >= part->nchannels);
1262 DBUG_ON(msg == NULL); 1224 DBUG_ON(payload == NULL);
1263 1225
1264 ret = xpc_send_msg(&part->channels[ch_number], msg, 0, NULL, NULL); 1226 if (xpc_part_ref(part)) {
1227 ret = xpc_send_msg(&part->channels[ch_number], flags, payload,
1228 payload_size, 0, NULL, NULL);
1229 xpc_part_deref(part);
1230 }
1265 1231
1266 return ret; 1232 return ret;
1267} 1233}
1268 1234
1269/* 1235/*
1270 * Send a message previously allocated using xpc_initiate_allocate on the 1236 * Send a message that contains the user's payload on the specified channel
1271 * specified channel connected to the specified partition. 1237 * connected to the specified partition.
1272 * 1238 *
1273 * This routine will not wait for the message to be sent. Once this routine 1239 * NOTE that this routine can sleep waiting for a message entry to become
1274 * has returned the message entry allocated via xpc_initiate_allocate() is no 1240 * available. To not sleep, pass in the XPC_NOWAIT flag.
1275 * longer accessable to the caller. 1241 *
1242 * This routine will not wait for the message to be sent or received.
1276 * 1243 *
1277 * Once the remote end of the channel has received the message, the function 1244 * Once the remote end of the channel has received the message, the function
1278 * passed as an argument to xpc_initiate_send_notify() will be called. This 1245 * passed as an argument to xpc_initiate_send_notify() will be called. This
@@ -1282,38 +1249,37 @@ xpc_initiate_send(short partid, int ch_number, void *payload)
1282 * 1249 *
1283 * If this routine returns an error, the caller's function will NOT be called. 1250 * If this routine returns an error, the caller's function will NOT be called.
1284 * 1251 *
1285 * This routine, although called by users, does not call xpc_part_ref() to
1286 * ensure that the partition infrastructure is in place. It relies on the
1287 * fact that we called xpc_msgqueue_ref() in xpc_allocate_msg().
1288 *
1289 * Arguments: 1252 * Arguments:
1290 * 1253 *
1291 * partid - ID of partition to which the channel is connected. 1254 * partid - ID of partition to which the channel is connected.
1292 * ch_number - channel # to send message on. 1255 * ch_number - channel # to send message on.
1293 * payload - pointer to the payload area allocated via 1256 * flags - see xp.h for valid flags.
1294 * xpc_initiate_allocate(). 1257 * payload - pointer to the payload which is to be sent.
1258 * payload_size - size of the payload in bytes.
1295 * func - function to call with asynchronous notification of message 1259 * func - function to call with asynchronous notification of message
1296 * receipt. THIS FUNCTION MUST BE NON-BLOCKING. 1260 * receipt. THIS FUNCTION MUST BE NON-BLOCKING.
1297 * key - user-defined key to be passed to the function when it's called. 1261 * key - user-defined key to be passed to the function when it's called.
1298 */ 1262 */
1299enum xp_retval 1263enum xp_retval
1300xpc_initiate_send_notify(short partid, int ch_number, void *payload, 1264xpc_initiate_send_notify(short partid, int ch_number, u32 flags, void *payload,
1301 xpc_notify_func func, void *key) 1265 u16 payload_size, xpc_notify_func func, void *key)
1302{ 1266{
1303 struct xpc_partition *part = &xpc_partitions[partid]; 1267 struct xpc_partition *part = &xpc_partitions[partid];
1304 struct xpc_msg *msg = XPC_MSG_ADDRESS(payload); 1268 enum xp_retval ret = xpUnknownReason;
1305 enum xp_retval ret;
1306 1269
1307 dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *)msg, 1270 dev_dbg(xpc_chan, "payload=0x%p, partid=%d, channel=%d\n", payload,
1308 partid, ch_number); 1271 partid, ch_number);
1309 1272
1310 DBUG_ON(partid < 0 || partid >= xp_max_npartitions); 1273 DBUG_ON(partid < 0 || partid >= xp_max_npartitions);
1311 DBUG_ON(ch_number < 0 || ch_number >= part->nchannels); 1274 DBUG_ON(ch_number < 0 || ch_number >= part->nchannels);
1312 DBUG_ON(msg == NULL); 1275 DBUG_ON(payload == NULL);
1313 DBUG_ON(func == NULL); 1276 DBUG_ON(func == NULL);
1314 1277
1315 ret = xpc_send_msg(&part->channels[ch_number], msg, XPC_N_CALL, 1278 if (xpc_part_ref(part)) {
1316 func, key); 1279 ret = xpc_send_msg(&part->channels[ch_number], flags, payload,
1280 payload_size, XPC_N_CALL, func, key);
1281 xpc_part_deref(part);
1282 }
1317 return ret; 1283 return ret;
1318} 1284}
1319 1285
@@ -1372,7 +1338,7 @@ xpc_deliver_msg(struct xpc_channel *ch)
1372 * partid - ID of partition to which the channel is connected. 1338 * partid - ID of partition to which the channel is connected.
1373 * ch_number - channel # message received on. 1339 * ch_number - channel # message received on.
1374 * payload - pointer to the payload area allocated via 1340 * payload - pointer to the payload area allocated via
1375 * xpc_initiate_allocate(). 1341 * xpc_initiate_send() or xpc_initiate_send_notify().
1376 */ 1342 */
1377void 1343void
1378xpc_initiate_received(short partid, int ch_number, void *payload) 1344xpc_initiate_received(short partid, int ch_number, void *payload)