vchiq_core.c (302408) | vchiq_core.c (305309) |
---|---|
1/** 2 * Copyright (c) 2010-2012 Broadcom. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions, and the following disclaimer, --- 608 unchanged lines hidden (view full) --- 617/* Called by the recycle thread. */ 618static void 619process_free_queue(VCHIQ_STATE_T *state) 620{ 621 VCHIQ_SHARED_STATE_T *local = state->local; 622 BITSET_T service_found[BITSET_SIZE(VCHIQ_MAX_SERVICES)]; 623 int slot_queue_available; 624 | 1/** 2 * Copyright (c) 2010-2012 Broadcom. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions, and the following disclaimer, --- 608 unchanged lines hidden (view full) --- 617/* Called by the recycle thread. */ 618static void 619process_free_queue(VCHIQ_STATE_T *state) 620{ 621 VCHIQ_SHARED_STATE_T *local = state->local; 622 BITSET_T service_found[BITSET_SIZE(VCHIQ_MAX_SERVICES)]; 623 int slot_queue_available; 624 |
625 /* Use a read memory barrier to ensure that any state that may have 626 ** been modified by another thread is not masked by stale prefetched 627 ** values. */ 628 rmb(); 629 | |
630 /* Find slots which have been freed by the other side, and return them 631 ** to the available queue. */ 632 slot_queue_available = state->slot_queue_available; 633 | 625 /* Find slots which have been freed by the other side, and return them 626 ** to the available queue. */ 627 slot_queue_available = state->slot_queue_available; 628 |
629 /* Use a memory barrier to ensure that any state that may have been 630 ** modified by another thread is not masked by stale prefetched 631 ** values. */ 632 mb(); 633 |
|
634 while (slot_queue_available != local->slot_queue_recycle) { 635 unsigned int pos; 636 int slot_index = local->slot_queue[slot_queue_available++ & 637 VCHIQ_SLOT_QUEUE_MASK]; 638 char *data = (char *)SLOT_DATA_FROM_INDEX(state, slot_index); 639 int data_found = 0; 640 | 634 while (slot_queue_available != local->slot_queue_recycle) { 635 unsigned int pos; 636 int slot_index = local->slot_queue[slot_queue_available++ & 637 VCHIQ_SLOT_QUEUE_MASK]; 638 char *data = (char *)SLOT_DATA_FROM_INDEX(state, slot_index); 639 int data_found = 0; 640 |
641 rmb(); 642 |
|
641 vchiq_log_trace(vchiq_core_log_level, "%d: pfq %d=%x %x %x", 642 state->id, slot_index, (unsigned int)data, 643 local->slot_queue_recycle, slot_queue_available); 644 645 /* Initialise the bitmask for services which have used this 646 ** slot */ 647 BITSET_ZERO(service_found); 648 --- 99 unchanged lines hidden (view full) --- 748 if (count > 0) 749 state->data_use_count = 750 count - 1; 751 spin_unlock("a_spinlock); 752 if (count == state->data_quota) 753 up(&state->data_quota_event); 754 } 755 | 643 vchiq_log_trace(vchiq_core_log_level, "%d: pfq %d=%x %x %x", 644 state->id, slot_index, (unsigned int)data, 645 local->slot_queue_recycle, slot_queue_available); 646 647 /* Initialise the bitmask for services which have used this 648 ** slot */ 649 BITSET_ZERO(service_found); 650 --- 99 unchanged lines hidden (view full) --- 750 if (count > 0) 751 state->data_use_count = 752 count - 1; 753 spin_unlock("a_spinlock); 754 if (count == state->data_quota) 755 up(&state->data_quota_event); 756 } 757 |
758 mb(); 759 |
|
756 state->slot_queue_available = slot_queue_available; 757 up(&state->slot_available_event); 758 } 759} 760 761/* Called by the slot handler and application threads */ 762static VCHIQ_STATUS_T 763queue_message(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, --- 135 unchanged lines hidden (view full) --- 899 (header->data + pos, elements[i].data, 900 (size_t) elements[i].size) != 901 VCHIQ_SUCCESS) { 902 lmutex_unlock(&state->slot_mutex); 903 VCHIQ_SERVICE_STATS_INC(service, 904 error_count); 905 return VCHIQ_ERROR; 906 } | 760 state->slot_queue_available = slot_queue_available; 761 up(&state->slot_available_event); 762 } 763} 764 765/* Called by the slot handler and application threads */ 766static VCHIQ_STATUS_T 767queue_message(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, --- 135 unchanged lines hidden (view full) --- 903 (header->data + pos, elements[i].data, 904 (size_t) elements[i].size) != 905 VCHIQ_SUCCESS) { 906 lmutex_unlock(&state->slot_mutex); 907 VCHIQ_SERVICE_STATS_INC(service, 908 error_count); 909 return VCHIQ_ERROR; 910 } |
907 if (i == 0) { 908 if (SRVTRACE_ENABLED(service, 909 VCHIQ_LOG_INFO)) 910 vchiq_log_dump_mem("Sent", 0, 911 header->data + pos, 912 min(64u, 913 elements[0].size)); 914 } | |
915 } 916 | 911 } 912 |
913 if (SRVTRACE_ENABLED(service, 914 VCHIQ_LOG_INFO)) 915 vchiq_log_dump_mem("Sent", 0, 916 header->data, 917 min(16, pos)); 918 |
|
917 spin_lock("a_spinlock); 918 service_quota->message_use_count++; 919 920 tx_end_index = 921 SLOT_QUEUE_INDEX_FROM_POS(state->local_tx_pos - 1); 922 923 /* If this transmission can't fit in the last slot used by any 924 ** service, the data_use_count must be increased. */ --- 122 unchanged lines hidden (view full) --- 1047 (header->data + pos, elements[i].data, 1048 (size_t) elements[i].size) != 1049 VCHIQ_SUCCESS) { 1050 lmutex_unlock(&state->sync_mutex); 1051 VCHIQ_SERVICE_STATS_INC(service, 1052 error_count); 1053 return VCHIQ_ERROR; 1054 } | 919 spin_lock("a_spinlock); 920 service_quota->message_use_count++; 921 922 tx_end_index = 923 SLOT_QUEUE_INDEX_FROM_POS(state->local_tx_pos - 1); 924 925 /* If this transmission can't fit in the last slot used by any 926 ** service, the data_use_count must be increased. */ --- 122 unchanged lines hidden (view full) --- 1049 (header->data + pos, elements[i].data, 1050 (size_t) elements[i].size) != 1051 VCHIQ_SUCCESS) { 1052 lmutex_unlock(&state->sync_mutex); 1053 VCHIQ_SERVICE_STATS_INC(service, 1054 error_count); 1055 return VCHIQ_ERROR; 1056 } |
1055 if (i == 0) { 1056 if (vchiq_sync_log_level >= 1057 VCHIQ_LOG_TRACE) 1058 vchiq_log_dump_mem("Sent Sync", 1059 0, header->data + pos, 1060 min(64u, 1061 elements[0].size)); 1062 } | |
1063 } 1064 | 1057 } 1058 |
1059 if (vchiq_sync_log_level >= VCHIQ_LOG_TRACE) 1060 vchiq_log_dump_mem("Sent Sync", 1061 0, header->data, 1062 min(16, pos)); 1063 |
|
1065 VCHIQ_SERVICE_STATS_INC(service, ctrl_tx_count); 1066 VCHIQ_SERVICE_STATS_ADD(service, ctrl_tx_bytes, size); 1067 } else { 1068 vchiq_log_info(vchiq_sync_log_level, 1069 "%d: qms %s@%x,%x (%d->%d)", state->id, 1070 msg_type_str(VCHIQ_MSG_TYPE(msgid)), 1071 (unsigned int)header, size, 1072 VCHIQ_MSG_SRCPORT(msgid), --- 654 unchanged lines hidden (view full) --- 1727 vchiq_log_info(SRVTRACE_LEVEL(service), 1728 "Rcvd Msg %s(%u) from %c%c%c%c s:%d d:%d " 1729 "len:%d", 1730 msg_type_str(type), type, 1731 VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), 1732 remoteport, localport, size); 1733 if (size > 0) 1734 vchiq_log_dump_mem("Rcvd", 0, header->data, | 1064 VCHIQ_SERVICE_STATS_INC(service, ctrl_tx_count); 1065 VCHIQ_SERVICE_STATS_ADD(service, ctrl_tx_bytes, size); 1066 } else { 1067 vchiq_log_info(vchiq_sync_log_level, 1068 "%d: qms %s@%x,%x (%d->%d)", state->id, 1069 msg_type_str(VCHIQ_MSG_TYPE(msgid)), 1070 (unsigned int)header, size, 1071 VCHIQ_MSG_SRCPORT(msgid), --- 654 unchanged lines hidden (view full) --- 1726 vchiq_log_info(SRVTRACE_LEVEL(service), 1727 "Rcvd Msg %s(%u) from %c%c%c%c s:%d d:%d " 1728 "len:%d", 1729 msg_type_str(type), type, 1730 VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), 1731 remoteport, localport, size); 1732 if (size > 0) 1733 vchiq_log_dump_mem("Rcvd", 0, header->data, |
1735 min(64, size)); | 1734 min(16, size)); |
1736 } 1737 1738 if (((unsigned int)header & VCHIQ_SLOT_MASK) + calc_stride(size) 1739 > VCHIQ_SLOT_SIZE) { 1740 vchiq_log_error(vchiq_core_log_level, 1741 "header %x (msgid %x) - size %x too big for " 1742 "slot", 1743 (unsigned int)header, (unsigned int)msgid, --- 453 unchanged lines hidden (view full) --- 2197 : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); 2198 vchiq_log_trace(vchiq_sync_log_level, 2199 "Rcvd Msg %s from %c%c%c%c s:%d d:%d len:%d", 2200 msg_type_str(type), 2201 VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), 2202 remoteport, localport, size); 2203 if (size > 0) 2204 vchiq_log_dump_mem("Rcvd", 0, header->data, | 1735 } 1736 1737 if (((unsigned int)header & VCHIQ_SLOT_MASK) + calc_stride(size) 1738 > VCHIQ_SLOT_SIZE) { 1739 vchiq_log_error(vchiq_core_log_level, 1740 "header %x (msgid %x) - size %x too big for " 1741 "slot", 1742 (unsigned int)header, (unsigned int)msgid, --- 453 unchanged lines hidden (view full) --- 2196 : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); 2197 vchiq_log_trace(vchiq_sync_log_level, 2198 "Rcvd Msg %s from %c%c%c%c s:%d d:%d len:%d", 2199 msg_type_str(type), 2200 VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), 2201 remoteport, localport, size); 2202 if (size > 0) 2203 vchiq_log_dump_mem("Rcvd", 0, header->data, |
2205 min(64, size)); | 2204 min(16, size)); |
2206 } 2207 2208 switch (type) { 2209 case VCHIQ_MSG_OPENACK: 2210 if (size >= sizeof(struct vchiq_openack_payload)) { 2211 const struct vchiq_openack_payload *payload = 2212 (struct vchiq_openack_payload *) 2213 header->data; --- 1741 unchanged lines hidden --- | 2205 } 2206 2207 switch (type) { 2208 case VCHIQ_MSG_OPENACK: 2209 if (size >= sizeof(struct vchiq_openack_payload)) { 2210 const struct vchiq_openack_payload *payload = 2211 (struct vchiq_openack_payload *) 2212 header->data; --- 1741 unchanged lines hidden --- |