Lines Matching full:txn
212 struct relay_transaction *txn; in __relay_get_transaction() local
228 txn = mempool_alloc(&relay->pool, incoming ? GFP_ATOMIC : GFP_KERNEL); in __relay_get_transaction()
229 if (!txn) in __relay_get_transaction()
232 txn->incoming = incoming; in __relay_get_transaction()
233 txn->remote = remote; in __relay_get_transaction()
234 txn->rid = rid; in __relay_get_transaction()
235 txn->offset = remote ? in __relay_get_transaction()
236 prepare_pf2guc(incoming ? txn->response_buf : txn->request_buf, remote, rid) : in __relay_get_transaction()
237 prepare_vf2guc(incoming ? txn->response_buf : txn->request_buf, rid); in __relay_get_transaction()
239 relay_assert(relay, txn->offset); in __relay_get_transaction()
240 relay_assert(relay, txn->offset + GUC_RELAY_MSG_MAX_LEN <= ARRAY_SIZE(txn->request_buf)); in __relay_get_transaction()
241 relay_assert(relay, txn->offset + GUC_RELAY_MSG_MAX_LEN <= ARRAY_SIZE(txn->response_buf)); in __relay_get_transaction()
243 txn->request = txn->request_buf + txn->offset; in __relay_get_transaction()
244 memcpy(&txn->request_buf[txn->offset], action, sizeof(u32) * action_len); in __relay_get_transaction()
245 txn->request_len = action_len; in __relay_get_transaction()
247 txn->response = resp ?: txn->response_buf + txn->offset; in __relay_get_transaction()
248 txn->response_len = resp_size ?: GUC_RELAY_MSG_MAX_LEN; in __relay_get_transaction()
249 txn->reply = -ENOMSG; in __relay_get_transaction()
250 INIT_LIST_HEAD(&txn->link); in __relay_get_transaction()
251 init_completion(&txn->done); in __relay_get_transaction()
253 return txn; in __relay_get_transaction()
272 static void relay_release_transaction(struct xe_guc_relay *relay, struct relay_transaction *txn) in relay_release_transaction() argument
274 relay_assert(relay, list_empty(&txn->link)); in relay_release_transaction()
276 txn->offset = 0; in relay_release_transaction()
277 txn->response = NULL; in relay_release_transaction()
278 txn->reply = -ESTALE; in relay_release_transaction()
279 mempool_free(txn, &relay->pool); in relay_release_transaction()
282 static int relay_send_transaction(struct xe_guc_relay *relay, struct relay_transaction *txn) in relay_send_transaction() argument
284 u32 len = txn->incoming ? txn->response_len : txn->request_len; in relay_send_transaction()
285 u32 *buf = txn->incoming ? txn->response_buf : txn->request_buf; in relay_send_transaction()
286 u32 *msg = buf + txn->offset; in relay_send_transaction()
289 relay_assert(relay, txn->offset); in relay_send_transaction()
290 relay_assert(relay, txn->offset + len <= GUC_CTB_MAX_DWORDS); in relay_send_transaction()
296 txn->rid, txn->remote, (int)sizeof(u32) * len, msg); in relay_send_transaction()
298 ret = xe_guc_ct_send_block(relay_to_ct(relay), buf, len + txn->offset); in relay_send_transaction()
308 ERR_PTR(ret), (int)sizeof(u32) * txn->offset, buf); in relay_send_transaction()
311 txn->rid, txn->remote, ERR_PTR(ret), (int)sizeof(u32) * len, msg); in relay_send_transaction()
408 struct relay_transaction *txn, in relay_send_message_and_wait() argument
412 u32 *msg = &txn->request_buf[txn->offset]; in relay_send_message_and_wait()
413 u32 len = txn->request_len; in relay_send_message_and_wait()
424 txn->rid, txn->remote, action, data0); in relay_send_message_and_wait()
428 list_add_tail(&txn->link, &relay->pending_relays); in relay_send_message_and_wait()
432 ret = relay_send_transaction(relay, txn); in relay_send_message_and_wait()
437 n = wait_for_completion_timeout(&txn->done, timeout); in relay_send_message_and_wait()
438 if (unlikely(n == 0 && txn->reply)) { in relay_send_message_and_wait()
444 txn->remote, txn->rid, txn->reply, jiffies_to_msecs(timeout - n)); in relay_send_message_and_wait()
445 if (unlikely(txn->reply)) { in relay_send_message_and_wait()
446 reinit_completion(&txn->done); in relay_send_message_and_wait()
447 if (txn->reply == -EAGAIN) in relay_send_message_and_wait()
449 if (txn->reply == -EBUSY) { in relay_send_message_and_wait()
453 if (txn->reply > 0) in relay_send_message_and_wait()
454 ret = from_relay_error(txn->reply); in relay_send_message_and_wait()
456 ret = txn->reply; in relay_send_message_and_wait()
460 relay_debug(relay, "%u.%u response %*ph\n", txn->remote, txn->rid, in relay_send_message_and_wait()
461 (int)sizeof(u32) * txn->response_len, txn->response); in relay_send_message_and_wait()
462 relay_assert(relay, txn->response_len >= GUC_RELAY_MSG_MIN_LEN); in relay_send_message_and_wait()
463 ret = txn->response_len; in relay_send_message_and_wait()
467 list_del_init(&txn->link); in relay_send_message_and_wait()
472 guc_hxg_type_to_string(type), txn->rid, in relay_send_message_and_wait()
473 action, data0, txn->remote, ERR_PTR(ret), in relay_send_message_and_wait()
483 struct relay_transaction *txn; in relay_send_to() local
494 txn = relay_new_transaction(relay, target, msg, len, buf, buf_size); in relay_send_to()
495 if (IS_ERR(txn)) in relay_send_to()
496 return PTR_ERR(txn); in relay_send_to()
500 ret = relay_send_message_and_wait(relay, txn, buf, buf_size); in relay_send_to()
506 ret = relay_send_transaction(relay, txn); in relay_send_to()
513 relay_release_transaction(relay, txn); in relay_send_to()
694 struct relay_transaction *txn; in relay_dequeue_transaction() local
697 txn = list_first_entry_or_null(&relay->incoming_actions, struct relay_transaction, link); in relay_dequeue_transaction()
698 if (txn) in relay_dequeue_transaction()
699 list_del_init(&txn->link); in relay_dequeue_transaction()
702 return txn; in relay_dequeue_transaction()
707 struct relay_transaction *txn; in relay_process_incoming_action() local
712 txn = relay_dequeue_transaction(relay); in relay_process_incoming_action()
713 if (!txn) in relay_process_incoming_action()
716 type = FIELD_GET(GUC_HXG_MSG_0_TYPE, txn->request_buf[txn->offset]); in relay_process_incoming_action()
718 ret = relay_action_handler(relay, txn->remote, in relay_process_incoming_action()
719 txn->request_buf + txn->offset, txn->request_len, in relay_process_incoming_action()
720 txn->response_buf + txn->offset, in relay_process_incoming_action()
721 ARRAY_SIZE(txn->response_buf) - txn->offset); in relay_process_incoming_action()
725 ret = guc_hxg_msg_encode_busy(txn->response_buf + txn->offset, 0); in relay_process_incoming_action()
729 txn->response_len = ret; in relay_process_incoming_action()
730 ret = relay_send_transaction(relay, txn); in relay_process_incoming_action()
737 guc_hxg_type_to_string(type), txn->rid, txn->remote, in relay_process_incoming_action()
738 ERR_PTR(ret), 4 * txn->request_len, txn->request_buf + txn->offset); in relay_process_incoming_action()
740 txn->response_len = prepare_error_reply(txn->response_buf + txn->offset, in relay_process_incoming_action()
741 txn->remote ? in relay_process_incoming_action()
743 txn->remote ? in relay_process_incoming_action()
745 ret = relay_send_transaction(relay, txn); in relay_process_incoming_action()
751 list_add(&txn->link, &relay->incoming_actions); in relay_process_incoming_action()
758 txn->rid, ERR_PTR(ret), 4 * txn->request_len, in relay_process_incoming_action()
759 txn->request_buf + txn->offset); in relay_process_incoming_action()
761 relay_release_transaction(relay, txn); in relay_process_incoming_action()
795 struct relay_transaction *txn; in relay_queue_action_msg() local
797 txn = relay_new_incoming_transaction(relay, origin, rid, msg, len); in relay_queue_action_msg()
798 if (IS_ERR(txn)) in relay_queue_action_msg()
799 return PTR_ERR(txn); in relay_queue_action_msg()
802 list_add_tail(&txn->link, &relay->incoming_actions); in relay_queue_action_msg()