Lines Matching full:txn

211 	struct relay_transaction *txn;  in __relay_get_transaction()  local
227 txn = mempool_alloc(&relay->pool, incoming ? GFP_ATOMIC : GFP_KERNEL); in __relay_get_transaction()
228 if (!txn) in __relay_get_transaction()
231 txn->incoming = incoming; in __relay_get_transaction()
232 txn->remote = remote; in __relay_get_transaction()
233 txn->rid = rid; in __relay_get_transaction()
234 txn->offset = remote ? in __relay_get_transaction()
235 prepare_pf2guc(incoming ? txn->response_buf : txn->request_buf, remote, rid) : in __relay_get_transaction()
236 prepare_vf2guc(incoming ? txn->response_buf : txn->request_buf, rid); in __relay_get_transaction()
238 relay_assert(relay, txn->offset); in __relay_get_transaction()
239 relay_assert(relay, txn->offset + GUC_RELAY_MSG_MAX_LEN <= ARRAY_SIZE(txn->request_buf)); in __relay_get_transaction()
240 relay_assert(relay, txn->offset + GUC_RELAY_MSG_MAX_LEN <= ARRAY_SIZE(txn->response_buf)); in __relay_get_transaction()
242 txn->request = txn->request_buf + txn->offset; in __relay_get_transaction()
243 memcpy(&txn->request_buf[txn->offset], action, sizeof(u32) * action_len); in __relay_get_transaction()
244 txn->request_len = action_len; in __relay_get_transaction()
246 txn->response = resp ?: txn->response_buf + txn->offset; in __relay_get_transaction()
247 txn->response_len = resp_size ?: GUC_RELAY_MSG_MAX_LEN; in __relay_get_transaction()
248 txn->reply = -ENOMSG; in __relay_get_transaction()
249 INIT_LIST_HEAD(&txn->link); in __relay_get_transaction()
250 init_completion(&txn->done); in __relay_get_transaction()
252 return txn; in __relay_get_transaction()
271 static void relay_release_transaction(struct xe_guc_relay *relay, struct relay_transaction *txn) in relay_release_transaction() argument
273 relay_assert(relay, list_empty(&txn->link)); in relay_release_transaction()
275 txn->offset = 0; in relay_release_transaction()
276 txn->response = NULL; in relay_release_transaction()
277 txn->reply = -ESTALE; in relay_release_transaction()
278 mempool_free(txn, &relay->pool); in relay_release_transaction()
281 static int relay_send_transaction(struct xe_guc_relay *relay, struct relay_transaction *txn) in relay_send_transaction() argument
283 u32 len = txn->incoming ? txn->response_len : txn->request_len; in relay_send_transaction()
284 u32 *buf = txn->incoming ? txn->response_buf : txn->request_buf; in relay_send_transaction()
285 u32 *msg = buf + txn->offset; in relay_send_transaction()
288 relay_assert(relay, txn->offset); in relay_send_transaction()
289 relay_assert(relay, txn->offset + len <= GUC_CTB_MAX_DWORDS); in relay_send_transaction()
295 txn->rid, txn->remote, (int)sizeof(u32) * len, msg); in relay_send_transaction()
297 ret = xe_guc_ct_send_block(relay_to_ct(relay), buf, len + txn->offset); in relay_send_transaction()
307 ERR_PTR(ret), (int)sizeof(u32) * txn->offset, buf); in relay_send_transaction()
310 txn->rid, txn->remote, ERR_PTR(ret), (int)sizeof(u32) * len, msg); in relay_send_transaction()
406 struct relay_transaction *txn, in relay_send_message_and_wait() argument
410 u32 *msg = &txn->request_buf[txn->offset]; in relay_send_message_and_wait()
411 u32 len = txn->request_len; in relay_send_message_and_wait()
422 txn->rid, txn->remote, action, data0); in relay_send_message_and_wait()
426 list_add_tail(&txn->link, &relay->pending_relays); in relay_send_message_and_wait()
430 ret = relay_send_transaction(relay, txn); in relay_send_message_and_wait()
435 n = wait_for_completion_timeout(&txn->done, timeout); in relay_send_message_and_wait()
436 if (unlikely(n == 0 && txn->reply)) { in relay_send_message_and_wait()
442 txn->remote, txn->rid, txn->reply, jiffies_to_msecs(timeout - n)); in relay_send_message_and_wait()
443 if (unlikely(txn->reply)) { in relay_send_message_and_wait()
444 reinit_completion(&txn->done); in relay_send_message_and_wait()
445 if (txn->reply == -EAGAIN) in relay_send_message_and_wait()
447 if (txn->reply == -EBUSY) { in relay_send_message_and_wait()
451 if (txn->reply > 0) in relay_send_message_and_wait()
452 ret = from_relay_error(txn->reply); in relay_send_message_and_wait()
454 ret = txn->reply; in relay_send_message_and_wait()
458 relay_debug(relay, "%u.%u response %*ph\n", txn->remote, txn->rid, in relay_send_message_and_wait()
459 (int)sizeof(u32) * txn->response_len, txn->response); in relay_send_message_and_wait()
460 relay_assert(relay, txn->response_len >= GUC_RELAY_MSG_MIN_LEN); in relay_send_message_and_wait()
461 ret = txn->response_len; in relay_send_message_and_wait()
465 list_del_init(&txn->link); in relay_send_message_and_wait()
470 guc_hxg_type_to_string(type), txn->rid, in relay_send_message_and_wait()
471 action, data0, txn->remote, ERR_PTR(ret), in relay_send_message_and_wait()
481 struct relay_transaction *txn; in relay_send_to() local
492 txn = relay_new_transaction(relay, target, msg, len, buf, buf_size); in relay_send_to()
493 if (IS_ERR(txn)) in relay_send_to()
494 return PTR_ERR(txn); in relay_send_to()
498 ret = relay_send_message_and_wait(relay, txn, buf, buf_size); in relay_send_to()
504 ret = relay_send_transaction(relay, txn); in relay_send_to()
511 relay_release_transaction(relay, txn); in relay_send_to()
692 struct relay_transaction *txn; in relay_dequeue_transaction() local
695 txn = list_first_entry_or_null(&relay->incoming_actions, struct relay_transaction, link); in relay_dequeue_transaction()
696 if (txn) in relay_dequeue_transaction()
697 list_del_init(&txn->link); in relay_dequeue_transaction()
700 return txn; in relay_dequeue_transaction()
705 struct relay_transaction *txn; in relay_process_incoming_action() local
710 txn = relay_dequeue_transaction(relay); in relay_process_incoming_action()
711 if (!txn) in relay_process_incoming_action()
714 type = FIELD_GET(GUC_HXG_MSG_0_TYPE, txn->request_buf[txn->offset]); in relay_process_incoming_action()
716 ret = relay_action_handler(relay, txn->remote, in relay_process_incoming_action()
717 txn->request_buf + txn->offset, txn->request_len, in relay_process_incoming_action()
718 txn->response_buf + txn->offset, in relay_process_incoming_action()
719 ARRAY_SIZE(txn->response_buf) - txn->offset); in relay_process_incoming_action()
723 ret = guc_hxg_msg_encode_busy(txn->response_buf + txn->offset, 0); in relay_process_incoming_action()
727 txn->response_len = ret; in relay_process_incoming_action()
728 ret = relay_send_transaction(relay, txn); in relay_process_incoming_action()
735 guc_hxg_type_to_string(type), txn->rid, txn->remote, in relay_process_incoming_action()
736 ERR_PTR(ret), 4 * txn->request_len, txn->request_buf + txn->offset); in relay_process_incoming_action()
738 txn->response_len = prepare_error_reply(txn->response_buf + txn->offset, in relay_process_incoming_action()
739 txn->remote ? in relay_process_incoming_action()
741 txn->remote ? in relay_process_incoming_action()
743 ret = relay_send_transaction(relay, txn); in relay_process_incoming_action()
749 list_add(&txn->link, &relay->incoming_actions); in relay_process_incoming_action()
756 txn->rid, ERR_PTR(ret), 4 * txn->request_len, in relay_process_incoming_action()
757 txn->request_buf + txn->offset); in relay_process_incoming_action()
759 relay_release_transaction(relay, txn); in relay_process_incoming_action()
793 struct relay_transaction *txn; in relay_queue_action_msg() local
795 txn = relay_new_incoming_transaction(relay, origin, rid, msg, len); in relay_queue_action_msg()
796 if (IS_ERR(txn)) in relay_queue_action_msg()
797 return PTR_ERR(txn); in relay_queue_action_msg()
800 list_add_tail(&txn->link, &relay->incoming_actions); in relay_queue_action_msg()