diff options
Diffstat (limited to 'drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c')
-rw-r--r-- | drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 771 |
1 files changed, 302 insertions, 469 deletions
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 9429b8a642fb..7fe20d4b7ba2 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -228,9 +228,9 @@ static inline void vchiq_set_service_state(struct vchiq_service *service, int newstate) { vchiq_log_info(vchiq_core_log_level, "%d: srv:%d %s->%s", - service->state->id, service->localport, - srvstate_names[service->srvstate], - srvstate_names[newstate]); + service->state->id, service->localport, + srvstate_names[service->srvstate], + srvstate_names[newstate]); service->srvstate = newstate; } @@ -257,7 +257,6 @@ find_service_by_handle(unsigned int handle) struct vchiq_service * find_service_by_port(struct vchiq_state *state, int localport) { - if ((unsigned int)localport <= VCHIQ_PORT_MAX) { struct vchiq_service *service; @@ -277,8 +276,7 @@ find_service_by_port(struct vchiq_state *state, int localport) } struct vchiq_service * -find_service_for_instance(struct vchiq_instance *instance, - unsigned int handle) +find_service_for_instance(struct vchiq_instance *instance, unsigned int handle) { struct vchiq_service *service; @@ -299,8 +297,7 @@ find_service_for_instance(struct vchiq_instance *instance, } struct vchiq_service * -find_closed_service_for_instance(struct vchiq_instance *instance, - unsigned int handle) +find_closed_service_for_instance(struct vchiq_instance *instance, unsigned int handle) { struct vchiq_service *service; @@ -467,14 +464,13 @@ make_service_callback(struct vchiq_service *service, enum vchiq_reason reason, enum vchiq_status status; vchiq_log_trace(vchiq_core_log_level, "%d: callback:%d (%s, %pK, %pK)", - service->state->id, service->localport, reason_names[reason], - header, bulk_userdata); - status = service->base.callback(reason, header, service->handle, - bulk_userdata); + service->state->id, service->localport, reason_names[reason], + header, bulk_userdata); + status = service->base.callback(reason, header, service->handle, bulk_userdata); if (status == VCHIQ_ERROR) { vchiq_log_warning(vchiq_core_log_level, - "%d: ignoring ERROR from callback to service %x", - service->state->id, service->handle); + "%d: ignoring ERROR from callback to service %x", + service->state->id, service->handle); status = VCHIQ_SUCCESS; } @@ -489,9 +485,8 @@ vchiq_set_conn_state(struct vchiq_state *state, enum vchiq_connstate newstate) { enum vchiq_connstate oldstate = state->conn_state; - vchiq_log_info(vchiq_core_log_level, "%d: %s->%s", state->id, - conn_state_names[oldstate], - conn_state_names[newstate]); + vchiq_log_info(vchiq_core_log_level, "%d: %s->%s", state->id, conn_state_names[oldstate], + conn_state_names[newstate]); state->conn_state = newstate; vchiq_platform_conn_state_changed(state, oldstate, newstate); } @@ -694,8 +689,7 @@ reserve_space(struct vchiq_state *state, size_t space, int is_blocking) remote_event_signal(&state->remote->trigger); if (!is_blocking || - (wait_for_completion_interruptible( - &state->slot_available_event))) + (wait_for_completion_interruptible(&state->slot_available_event))) return NULL; /* No space available */ } @@ -705,8 +699,7 @@ reserve_space(struct vchiq_state *state, size_t space, int is_blocking) return NULL; } - slot_index = local->slot_queue[ - SLOT_QUEUE_INDEX_FROM_POS_MASKED(tx_pos)]; + slot_index = local->slot_queue[SLOT_QUEUE_INDEX_FROM_POS_MASKED(tx_pos)]; state->tx_data = (char *)SLOT_DATA_FROM_INDEX(state, slot_index); } @@ -718,7 +711,7 @@ reserve_space(struct vchiq_state *state, size_t space, int is_blocking) } static void -process_free_data_message(struct vchiq_state *state, BITSET_T *service_found, +process_free_data_message(struct vchiq_state *state, u32 *service_found, struct vchiq_header *header) { int msgid = header->msgid; @@ -740,11 +733,9 @@ process_free_data_message(struct vchiq_state *state, BITSET_T *service_found, complete("a->quota_event); } else if (count == 0) { vchiq_log_error(vchiq_core_log_level, - "service %d message_use_count=%d (header %pK, msgid %x, header->msgid %x, header->size %x)", - port, - quota->message_use_count, - header, msgid, header->msgid, - header->size); + "service %d message_use_count=%d (header %pK, msgid %x, header->msgid %x, header->size %x)", + port, quota->message_use_count, header, msgid, header->msgid, + header->size); WARN(1, "invalid message use count\n"); } if (!BITSET_IS_SET(service_found, port)) { @@ -763,17 +754,12 @@ process_free_data_message(struct vchiq_state *state, BITSET_T *service_found, * it has dropped below its quota */ complete("a->quota_event); - vchiq_log_trace(vchiq_core_log_level, - "%d: pfq:%d %x@%pK - slot_use->%d", - state->id, port, - header->size, header, - count - 1); + vchiq_log_trace(vchiq_core_log_level, "%d: pfq:%d %x@%pK - slot_use->%d", + state->id, port, header->size, header, count - 1); } else { vchiq_log_error(vchiq_core_log_level, "service %d slot_use_count=%d (header %pK, msgid %x, header->msgid %x, header->size %x)", - port, count, header, - msgid, header->msgid, - header->size); + port, count, header, msgid, header->msgid, header->size); WARN(1, "bad slot use count\n"); } } @@ -781,7 +767,7 @@ process_free_data_message(struct vchiq_state *state, BITSET_T *service_found, /* Called by the recycle thread. */ static void -process_free_queue(struct vchiq_state *state, BITSET_T *service_found, +process_free_queue(struct vchiq_state *state, u32 *service_found, size_t length) { struct vchiq_shared_state *local = state->local; @@ -815,8 +801,8 @@ process_free_queue(struct vchiq_state *state, BITSET_T *service_found, rmb(); vchiq_log_trace(vchiq_core_log_level, "%d: pfq %d=%pK %x %x", - state->id, slot_index, data, - local->slot_queue_recycle, slot_queue_available); + state->id, slot_index, data, local->slot_queue_recycle, + slot_queue_available); /* Initialise the bitmask for services which have used this slot */ memset(service_found, 0, length); @@ -837,9 +823,8 @@ process_free_queue(struct vchiq_state *state, BITSET_T *service_found, pos += calc_stride(header->size); if (pos > VCHIQ_SLOT_SIZE) { vchiq_log_error(vchiq_core_log_level, - "pfq - pos %x: header %pK, msgid %x, header->msgid %x, header->size %x", - pos, header, msgid, header->msgid, - header->size); + "pfq - pos %x: header %pK, msgid %x, header->msgid %x, header->size %x", + pos, header, msgid, header->msgid, header->size); WARN(1, "invalid slot position\n"); } } @@ -868,18 +853,15 @@ process_free_queue(struct vchiq_state *state, BITSET_T *service_found, } static ssize_t -memcpy_copy_callback( - void *context, void *dest, - size_t offset, size_t maxsize) +memcpy_copy_callback(void *context, void *dest, size_t offset, size_t maxsize) { memcpy(dest + offset, context + offset, maxsize); return maxsize; } static ssize_t -copy_message_data( - ssize_t (*copy_callback)(void *context, void *dest, - size_t offset, size_t maxsize), +copy_message_data(ssize_t (*copy_callback)(void *context, void *dest, size_t offset, + size_t maxsize), void *context, void *dest, size_t size) @@ -960,29 +942,26 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, * Ensure this service doesn't use more than its quota of * messages or slots */ - tx_end_index = SLOT_QUEUE_INDEX_FROM_POS( - state->local_tx_pos + stride - 1); + tx_end_index = SLOT_QUEUE_INDEX_FROM_POS(state->local_tx_pos + stride - 1); /* * Ensure data messages don't use more than their quota of * slots */ while ((tx_end_index != state->previous_data_index) && - (state->data_use_count == state->data_quota)) { + (state->data_use_count == state->data_quota)) { VCHIQ_STATS_INC(state, data_stalls); spin_unlock("a_spinlock); mutex_unlock(&state->slot_mutex); - if (wait_for_completion_interruptible( - &state->data_quota_event)) + if (wait_for_completion_interruptible(&state->data_quota_event)) return VCHIQ_RETRY; mutex_lock(&state->slot_mutex); spin_lock("a_spinlock); - tx_end_index = SLOT_QUEUE_INDEX_FROM_POS( - state->local_tx_pos + stride - 1); + tx_end_index = SLOT_QUEUE_INDEX_FROM_POS(state->local_tx_pos + stride - 1); if ((tx_end_index == state->previous_data_index) || - (state->data_use_count < state->data_quota)) { + (state->data_use_count < state->data_quota)) { /* Pass the signal on to other waiters */ complete(&state->data_quota_event); break; @@ -990,19 +969,16 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, } while ((quota->message_use_count == quota->message_quota) || - ((tx_end_index != quota->previous_tx_index) && + ((tx_end_index != quota->previous_tx_index) && (quota->slot_use_count == quota->slot_quota))) { spin_unlock("a_spinlock); vchiq_log_trace(vchiq_core_log_level, - "%d: qm:%d %s,%zx - quota stall (msg %d, slot %d)", - state->id, service->localport, - msg_type_str(type), size, - quota->message_use_count, - quota->slot_use_count); + "%d: qm:%d %s,%zx - quota stall (msg %d, slot %d)", + state->id, service->localport, msg_type_str(type), size, + quota->message_use_count, quota->slot_use_count); VCHIQ_SERVICE_STATS_INC(service, quota_stalls); mutex_unlock(&state->slot_mutex); - if (wait_for_completion_interruptible( - "a->quota_event)) + if (wait_for_completion_interruptible("a->quota_event)) return VCHIQ_RETRY; if (service->closing) return VCHIQ_ERROR; @@ -1014,8 +990,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, return VCHIQ_ERROR; } spin_lock("a_spinlock); - tx_end_index = SLOT_QUEUE_INDEX_FROM_POS( - state->local_tx_pos + stride - 1); + tx_end_index = SLOT_QUEUE_INDEX_FROM_POS(state->local_tx_pos + stride - 1); } spin_unlock("a_spinlock); @@ -1040,11 +1015,9 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, int tx_end_index; int slot_use_count; - vchiq_log_info(vchiq_core_log_level, - "%d: qm %s@%pK,%zx (%d->%d)", - state->id, msg_type_str(VCHIQ_MSG_TYPE(msgid)), - header, size, VCHIQ_MSG_SRCPORT(msgid), - VCHIQ_MSG_DSTPORT(msgid)); + vchiq_log_info(vchiq_core_log_level, "%d: qm %s@%pK,%zx (%d->%d)", state->id, + msg_type_str(VCHIQ_MSG_TYPE(msgid)), header, size, + VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid)); WARN_ON(flags & (QMFLAGS_NO_MUTEX_LOCK | QMFLAGS_NO_MUTEX_UNLOCK)); @@ -1097,19 +1070,16 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, if (slot_use_count) vchiq_log_trace(vchiq_core_log_level, - "%d: qm:%d %s,%zx - slot_use->%d (hdr %p)", - state->id, service->localport, - msg_type_str(VCHIQ_MSG_TYPE(msgid)), size, - slot_use_count, header); + "%d: qm:%d %s,%zx - slot_use->%d (hdr %p)", state->id, + service->localport, msg_type_str(VCHIQ_MSG_TYPE(msgid)), + size, slot_use_count, header); VCHIQ_SERVICE_STATS_INC(service, ctrl_tx_count); VCHIQ_SERVICE_STATS_ADD(service, ctrl_tx_bytes, size); } else { - vchiq_log_info(vchiq_core_log_level, - "%d: qm %s@%pK,%zx (%d->%d)", state->id, - msg_type_str(VCHIQ_MSG_TYPE(msgid)), - header, size, VCHIQ_MSG_SRCPORT(msgid), - VCHIQ_MSG_DSTPORT(msgid)); + vchiq_log_info(vchiq_core_log_level, "%d: qm %s@%pK,%zx (%d->%d)", state->id, + msg_type_str(VCHIQ_MSG_TYPE(msgid)), header, size, + VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid)); if (size != 0) { /* * It is assumed for now that this code path @@ -1138,13 +1108,10 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); vchiq_log_info(SRVTRACE_LEVEL(service), - "Sent Msg %s(%u) to %c%c%c%c s:%u d:%d len:%zu", - msg_type_str(VCHIQ_MSG_TYPE(msgid)), - VCHIQ_MSG_TYPE(msgid), - VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), - VCHIQ_MSG_SRCPORT(msgid), - VCHIQ_MSG_DSTPORT(msgid), - size); + "Sent Msg %s(%u) to %c%c%c%c s:%u d:%d len:%zu", + msg_type_str(VCHIQ_MSG_TYPE(msgid)), VCHIQ_MSG_TYPE(msgid), + VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), VCHIQ_MSG_SRCPORT(msgid), + VCHIQ_MSG_DSTPORT(msgid), size); } /* Make sure the new header is visible to the peer. */ @@ -1194,9 +1161,8 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, int oldmsgid = header->msgid; if (oldmsgid != VCHIQ_MSGID_PADDING) - vchiq_log_error(vchiq_core_log_level, - "%d: qms - msgid %x, not PADDING", - state->id, oldmsgid); + vchiq_log_error(vchiq_core_log_level, "%d: qms - msgid %x, not PADDING", + state->id, oldmsgid); } vchiq_log_info(vchiq_sync_log_level, @@ -1241,13 +1207,10 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); vchiq_log_trace(vchiq_sync_log_level, - "Sent Sync Msg %s(%u) to %c%c%c%c s:%u d:%d len:%d", - msg_type_str(VCHIQ_MSG_TYPE(msgid)), - VCHIQ_MSG_TYPE(msgid), - VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), - VCHIQ_MSG_SRCPORT(msgid), - VCHIQ_MSG_DSTPORT(msgid), - size); + "Sent Sync Msg %s(%u) to %c%c%c%c s:%u d:%d len:%d", + msg_type_str(VCHIQ_MSG_TYPE(msgid)), VCHIQ_MSG_TYPE(msgid), + VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), VCHIQ_MSG_SRCPORT(msgid), + VCHIQ_MSG_DSTPORT(msgid), size); } remote_event_signal(&state->remote->sync_trigger); @@ -1273,8 +1236,7 @@ release_slot(struct vchiq_state *state, struct vchiq_slot_info *slot_info, if (header) { int msgid = header->msgid; - if (((msgid & VCHIQ_MSGID_CLAIMED) == 0) || - (service && service->closing)) { + if (((msgid & VCHIQ_MSGID_CLAIMED) == 0) || (service && service->closing)) { mutex_unlock(&state->recycle_mutex); return; } @@ -1301,10 +1263,9 @@ release_slot(struct vchiq_state *state, struct vchiq_slot_info *slot_info, VCHIQ_SLOT_QUEUE_MASK] = SLOT_INDEX_FROM_INFO(state, slot_info); state->remote->slot_queue_recycle = slot_queue_recycle + 1; - vchiq_log_info(vchiq_core_log_level, - "%d: %s %d - recycle->%x", state->id, __func__, - SLOT_INDEX_FROM_INFO(state, slot_info), - state->remote->slot_queue_recycle); + vchiq_log_info(vchiq_core_log_level, "%d: %s %d - recycle->%x", state->id, __func__, + SLOT_INDEX_FROM_INFO(state, slot_info), + state->remote->slot_queue_recycle); /* * A write barrier is necessary, but remote_event_signal @@ -1339,11 +1300,9 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, { enum vchiq_status status = VCHIQ_SUCCESS; - vchiq_log_trace(vchiq_core_log_level, - "%d: nb:%d %cx - p=%x rn=%x r=%x", - service->state->id, service->localport, - (queue == &service->bulk_tx) ? 't' : 'r', - queue->process, queue->remote_notify, queue->remove); + vchiq_log_trace(vchiq_core_log_level, "%d: nb:%d %cx - p=%x rn=%x r=%x", service->state->id, + service->localport, (queue == &service->bulk_tx) ? 't' : 'r', + queue->process, queue->remote_notify, queue->remove); queue->remote_notify = queue->process; @@ -1358,21 +1317,16 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, if (bulk->data && service->instance) { if (bulk->actual != VCHIQ_BULK_ACTUAL_ABORTED) { if (bulk->dir == VCHIQ_BULK_TRANSMIT) { - VCHIQ_SERVICE_STATS_INC(service, - bulk_tx_count); - VCHIQ_SERVICE_STATS_ADD(service, - bulk_tx_bytes, - bulk->actual); + VCHIQ_SERVICE_STATS_INC(service, bulk_tx_count); + VCHIQ_SERVICE_STATS_ADD(service, bulk_tx_bytes, + bulk->actual); } else { - VCHIQ_SERVICE_STATS_INC(service, - bulk_rx_count); - VCHIQ_SERVICE_STATS_ADD(service, - bulk_rx_bytes, - bulk->actual); + VCHIQ_SERVICE_STATS_INC(service, bulk_rx_count); + VCHIQ_SERVICE_STATS_ADD(service, bulk_rx_bytes, + bulk->actual); } } else { - VCHIQ_SERVICE_STATS_INC(service, - bulk_aborted_count); + VCHIQ_SERVICE_STATS_INC(service, bulk_aborted_count); } if (bulk->mode == VCHIQ_BULK_MODE_BLOCKING) { struct bulk_waiter *waiter; @@ -1387,8 +1341,8 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, } else if (bulk->mode == VCHIQ_BULK_MODE_CALLBACK) { enum vchiq_reason reason = get_bulk_reason(bulk); - status = make_service_callback(service, - reason, NULL, bulk->userdata); + status = make_service_callback(service, reason, NULL, + bulk->userdata); if (status == VCHIQ_RETRY) break; } @@ -1401,9 +1355,8 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, status = VCHIQ_SUCCESS; if (status == VCHIQ_RETRY) - request_poll(service->state, service, - (queue == &service->bulk_tx) ? - VCHIQ_POLL_TXNOTIFY : VCHIQ_POLL_RXNOTIFY); + request_poll(service->state, service, (queue == &service->bulk_tx) ? + VCHIQ_POLL_TXNOTIFY : VCHIQ_POLL_RXNOTIFY); return status; } @@ -1444,15 +1397,10 @@ poll_services_of_group(struct vchiq_state *state, int group) VCHIQ_SUCCESS) request_poll(state, service, VCHIQ_POLL_REMOVE); } else if (service_flags & BIT(VCHIQ_POLL_TERMINATE)) { - vchiq_log_info(vchiq_core_log_level, - "%d: ps - terminate %d<->%d", - state->id, service->localport, - service->remoteport); - if (vchiq_close_service_internal( - service, NO_CLOSE_RECVD) != - VCHIQ_SUCCESS) - request_poll(state, service, - VCHIQ_POLL_TERMINATE); + vchiq_log_info(vchiq_core_log_level, "%d: ps - terminate %d<->%d", + state->id, service->localport, service->remoteport); + if (vchiq_close_service_internal(service, NO_CLOSE_RECVD) != VCHIQ_SUCCESS) + request_poll(state, service, VCHIQ_POLL_TERMINATE); } if (service_flags & BIT(VCHIQ_POLL_TXNOTIFY)) notify_bulks(service, &service->bulk_tx, RETRY_POLL); @@ -1479,18 +1427,16 @@ abort_outstanding_bulks(struct vchiq_service *service, { int is_tx = (queue == &service->bulk_tx); - vchiq_log_trace(vchiq_core_log_level, - "%d: aob:%d %cx - li=%x ri=%x p=%x", - service->state->id, service->localport, is_tx ? 't' : 'r', - queue->local_insert, queue->remote_insert, queue->process); + vchiq_log_trace(vchiq_core_log_level, "%d: aob:%d %cx - li=%x ri=%x p=%x", + service->state->id, service->localport, is_tx ? 't' : 'r', + queue->local_insert, queue->remote_insert, queue->process); WARN_ON((int)(queue->local_insert - queue->process) < 0); WARN_ON((int)(queue->remote_insert - queue->process) < 0); while ((queue->process != queue->local_insert) || - (queue->process != queue->remote_insert)) { - struct vchiq_bulk *bulk = - &queue->bulks[BULK_INDEX(queue->process)]; + (queue->process != queue->remote_insert)) { + struct vchiq_bulk *bulk = &queue->bulks[BULK_INDEX(queue->process)]; if (queue->process == queue->remote_insert) { /* fabricate a matching dummy bulk */ @@ -1503,12 +1449,10 @@ abort_outstanding_bulks(struct vchiq_service *service, vchiq_complete_bulk(bulk); vchiq_log_info(SRVTRACE_LEVEL(service), - "%s %c%c%c%c d:%d ABORTED - tx len:%d, rx len:%d", - is_tx ? "Send Bulk to" : "Recv Bulk from", - VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc), - service->remoteport, - bulk->size, - bulk->remote_size); + "%s %c%c%c%c d:%d ABORTED - tx len:%d, rx len:%d", + is_tx ? "Send Bulk to" : "Recv Bulk from", + VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc), + service->remoteport, bulk->size, bulk->remote_size); } else { /* fabricate a matching dummy bulk */ bulk->data = 0; @@ -1541,10 +1485,8 @@ parse_open(struct vchiq_state *state, struct vchiq_header *header) payload = (struct vchiq_open_payload *)header->data; fourcc = payload->fourcc; - vchiq_log_info(vchiq_core_log_level, - "%d: prs OPEN@%pK (%d->'%c%c%c%c')", - state->id, header, localport, - VCHIQ_FOURCC_AS_4CHARS(fourcc)); + vchiq_log_info(vchiq_core_log_level, "%d: prs OPEN@%pK (%d->'%c%c%c%c')", + state->id, header, localport, VCHIQ_FOURCC_AS_4CHARS(fourcc)); service = get_listening_service(state, fourcc); if (!service) @@ -1554,17 +1496,12 @@ parse_open(struct vchiq_state *state, struct vchiq_header *header) version = payload->version; version_min = payload->version_min; - if ((service->version < version_min) || - (version < service->version_min)) { + if ((service->version < version_min) || (version < service->version_min)) { /* Version mismatch */ vchiq_loud_error_header(); - vchiq_loud_error("%d: service %d (%c%c%c%c) " - "version mismatch - local (%d, min %d)" - " vs. remote (%d, min %d)", - state->id, service->localport, - VCHIQ_FOURCC_AS_4CHARS(fourcc), - service->version, service->version_min, - version, version_min); + vchiq_loud_error("%d: service %d (%c%c%c%c) version mismatch - local (%d, min %d) vs. remote (%d, min %d)", + state->id, service->localport, VCHIQ_FOURCC_AS_4CHARS(fourcc), + service->version, service->version_min, version, version_min); vchiq_loud_error_footer(); vchiq_service_put(service); service = NULL; @@ -1584,25 +1521,18 @@ parse_open(struct vchiq_state *state, struct vchiq_header *header) /* Acknowledge the OPEN */ if (service->sync) { - if (queue_message_sync(state, NULL, openack_id, - memcpy_copy_callback, - &ack_payload, - sizeof(ack_payload), - 0) == VCHIQ_RETRY) + if (queue_message_sync(state, NULL, openack_id, memcpy_copy_callback, + &ack_payload, sizeof(ack_payload), 0) == VCHIQ_RETRY) goto bail_not_ready; } else { - if (queue_message(state, NULL, openack_id, - memcpy_copy_callback, - &ack_payload, - sizeof(ack_payload), - 0) == VCHIQ_RETRY) + if (queue_message(state, NULL, openack_id, memcpy_copy_callback, + &ack_payload, sizeof(ack_payload), 0) == VCHIQ_RETRY) goto bail_not_ready; } /* The service is now open */ - vchiq_set_service_state(service, - service->sync ? VCHIQ_SRVSTATE_OPENSYNC - : VCHIQ_SRVSTATE_OPEN); + vchiq_set_service_state(service, service->sync ? VCHIQ_SRVSTATE_OPENSYNC + : VCHIQ_SRVSTATE_OPEN); } /* Success - the message has been dealt with */ @@ -1612,7 +1542,7 @@ parse_open(struct vchiq_state *state, struct vchiq_header *header) fail_open: /* No available service, or an invalid request - send a CLOSE */ if (queue_message(state, NULL, MAKE_CLOSE(0, VCHIQ_MSG_SRCPORT(msgid)), - NULL, NULL, 0, 0) == VCHIQ_RETRY) + NULL, NULL, 0, 0) == VCHIQ_RETRY) goto bail_not_ready; return 1; @@ -1642,7 +1572,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) unsigned int localport, remoteport; int msgid, size, type, ret = -EINVAL; - DEBUG_INITIALISE(state->local) + DEBUG_INITIALISE(state->local); DEBUG_VALUE(PARSE_HEADER, (int)(long)header); msgid = header->msgid; @@ -1676,22 +1606,19 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) */ if (service) vchiq_service_put(service); - service = get_connected_service(state, - remoteport); + service = get_connected_service(state, remoteport); if (service) vchiq_log_warning(vchiq_core_log_level, - "%d: prs %s@%pK (%d->%d) - found connected service %d", - state->id, msg_type_str(type), - header, remoteport, localport, - service->localport); + "%d: prs %s@%pK (%d->%d) - found connected service %d", + state->id, msg_type_str(type), header, + remoteport, localport, service->localport); } if (!service) { vchiq_log_error(vchiq_core_log_level, - "%d: prs %s@%pK (%d->%d) - invalid/closed service %d", - state->id, msg_type_str(type), - header, remoteport, localport, - localport); + "%d: prs %s@%pK (%d->%d) - invalid/closed service %d", + state->id, msg_type_str(type), header, remoteport, + localport, localport); goto skip_message; } break; @@ -1706,21 +1633,18 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) ? service->base.fourcc : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); vchiq_log_info(SRVTRACE_LEVEL(service), - "Rcvd Msg %s(%u) from %c%c%c%c s:%d d:%d len:%d", - msg_type_str(type), type, - VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), - remoteport, localport, size); + "Rcvd Msg %s(%u) from %c%c%c%c s:%d d:%d len:%d", + msg_type_str(type), type, VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), + remoteport, localport, size); if (size > 0) - vchiq_log_dump_mem("Rcvd", 0, header->data, - min(16, size)); + vchiq_log_dump_mem("Rcvd", 0, header->data, min(16, size)); } if (((unsigned long)header & VCHIQ_SLOT_MASK) + calc_stride(size) > VCHIQ_SLOT_SIZE) { vchiq_log_error(vchiq_core_log_level, - "header %pK (msgid %x) - size %x too big for slot", - header, (unsigned int)msgid, - (unsigned int)size); + "header %pK (msgid %x) - size %x too big for slot", + header, (unsigned int)msgid, (unsigned int)size); WARN(1, "oversized for slot\n"); } @@ -1737,66 +1661,55 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) header->data; service->peer_version = payload->version; } - vchiq_log_info(vchiq_core_log_level, - "%d: prs OPENACK@%pK,%x (%d->%d) v:%d", - state->id, header, size, remoteport, localport, - service->peer_version); + vchiq_log_info(vchiq_core_log_level, "%d: prs OPENACK@%pK,%x (%d->%d) v:%d", + state->id, header, size, remoteport, localport, + service->peer_version); if (service->srvstate == VCHIQ_SRVSTATE_OPENING) { service->remoteport = remoteport; - vchiq_set_service_state(service, - VCHIQ_SRVSTATE_OPEN); + vchiq_set_service_state(service, VCHIQ_SRVSTATE_OPEN); complete(&service->remove_event); } else { - vchiq_log_error(vchiq_core_log_level, - "OPENACK received in state %s", - srvstate_names[service->srvstate]); + vchiq_log_error(vchiq_core_log_level, "OPENACK received in state %s", + srvstate_names[service->srvstate]); } break; case VCHIQ_MSG_CLOSE: WARN_ON(size); /* There should be no data */ - vchiq_log_info(vchiq_core_log_level, - "%d: prs CLOSE@%pK (%d->%d)", - state->id, header, remoteport, localport); + vchiq_log_info(vchiq_core_log_level, "%d: prs CLOSE@%pK (%d->%d)", + state->id, header, remoteport, localport); mark_service_closing_internal(service, 1); - if (vchiq_close_service_internal(service, - CLOSE_RECVD) == VCHIQ_RETRY) + if (vchiq_close_service_internal(service, CLOSE_RECVD) == VCHIQ_RETRY) goto bail_not_ready; - vchiq_log_info(vchiq_core_log_level, - "Close Service %c%c%c%c s:%u d:%d", - VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc), - service->localport, - service->remoteport); + vchiq_log_info(vchiq_core_log_level, "Close Service %c%c%c%c s:%u d:%d", + VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc), + service->localport, service->remoteport); break; case VCHIQ_MSG_DATA: - vchiq_log_info(vchiq_core_log_level, - "%d: prs DATA@%pK,%x (%d->%d)", - state->id, header, size, remoteport, localport); + vchiq_log_info(vchiq_core_log_level, "%d: prs DATA@%pK,%x (%d->%d)", + state->id, header, size, remoteport, localport); if ((service->remoteport == remoteport) && (service->srvstate == VCHIQ_SRVSTATE_OPEN)) { header->msgid = msgid | VCHIQ_MSGID_CLAIMED; claim_slot(state->rx_info); DEBUG_TRACE(PARSE_LINE); - if (make_service_callback(service, - VCHIQ_MESSAGE_AVAILABLE, header, - NULL) == VCHIQ_RETRY) { + if (make_service_callback(service, VCHIQ_MESSAGE_AVAILABLE, header, + NULL) == VCHIQ_RETRY) { DEBUG_TRACE(PARSE_LINE); goto bail_not_ready; } VCHIQ_SERVICE_STATS_INC(service, ctrl_rx_count); - VCHIQ_SERVICE_STATS_ADD(service, ctrl_rx_bytes, - size); + VCHIQ_SERVICE_STATS_ADD(service, ctrl_rx_bytes, size); } else { VCHIQ_STATS_INC(state, error_count); } break; case VCHIQ_MSG_CONNECT: - vchiq_log_info(vchiq_core_log_level, - "%d: prs CONNECT@%pK", state->id, header); + vchiq_log_info(vchiq_core_log_level, "%d: prs CONNECT@%pK", state->id, header); state->version_common = ((struct vchiq_slot_zero *) state->slot_data)->version; complete(&state->connect); @@ -1828,11 +1741,10 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) if ((int)(queue->remote_insert - queue->local_insert) >= 0) { vchiq_log_error(vchiq_core_log_level, - "%d: prs %s@%pK (%d->%d) unexpected (ri=%d,li=%d)", - state->id, msg_type_str(type), - header, remoteport, localport, - queue->remote_insert, - queue->local_insert); + "%d: prs %s@%pK (%d->%d) unexpected (ri=%d,li=%d)", + state->id, msg_type_str(type), header, remoteport, + localport, queue->remote_insert, + queue->local_insert); mutex_unlock(&service->bulk_mutex); break; } @@ -1845,24 +1757,18 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) goto bail_not_ready; } - bulk = &queue->bulks[ - BULK_INDEX(queue->remote_insert)]; + bulk = &queue->bulks[BULK_INDEX(queue->remote_insert)]; bulk->actual = *(int *)header->data; queue->remote_insert++; - vchiq_log_info(vchiq_core_log_level, - "%d: prs %s@%pK (%d->%d) %x@%pad", - state->id, msg_type_str(type), - header, remoteport, localport, - bulk->actual, &bulk->data); + vchiq_log_info(vchiq_core_log_level, "%d: prs %s@%pK (%d->%d) %x@%pad", + state->id, msg_type_str(type), header, remoteport, localport, + bulk->actual, &bulk->data); - vchiq_log_trace(vchiq_core_log_level, - "%d: prs:%d %cx li=%x ri=%x p=%x", - state->id, localport, - (type == VCHIQ_MSG_BULK_RX_DONE) ? - 'r' : 't', - queue->local_insert, - queue->remote_insert, queue->process); + vchiq_log_trace(vchiq_core_log_level, "%d: prs:%d %cx li=%x ri=%x p=%x", + state->id, localport, + (type == VCHIQ_MSG_BULK_RX_DONE) ? 'r' : 't', + queue->local_insert, queue->remote_insert, queue->process); DEBUG_TRACE(PARSE_LINE); WARN_ON(queue->process == queue->local_insert); @@ -1875,35 +1781,30 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) } break; case VCHIQ_MSG_PADDING: - vchiq_log_trace(vchiq_core_log_level, - "%d: prs PADDING@%pK,%x", - state->id, header, size); + vchiq_log_trace(vchiq_core_log_level, "%d: prs PADDING@%pK,%x", + state->id, header, size); break; case VCHIQ_MSG_PAUSE: /* If initiated, signal the application thread */ - vchiq_log_trace(vchiq_core_log_level, - "%d: prs PAUSE@%pK,%x", - state->id, header, size); + vchiq_log_trace(vchiq_core_log_level, "%d: prs PAUSE@%pK,%x", + state->id, header, size); if (state->conn_state == VCHIQ_CONNSTATE_PAUSED) { - vchiq_log_error(vchiq_core_log_level, - "%d: PAUSE received in state PAUSED", - state->id); + vchiq_log_error(vchiq_core_log_level, "%d: PAUSE received in state PAUSED", + state->id); break; } if (state->conn_state != VCHIQ_CONNSTATE_PAUSE_SENT) { /* Send a PAUSE in response */ - if (queue_message(state, NULL, MAKE_PAUSE, - NULL, NULL, 0, QMFLAGS_NO_MUTEX_UNLOCK) - == VCHIQ_RETRY) + if (queue_message(state, NULL, MAKE_PAUSE, NULL, NULL, 0, + QMFLAGS_NO_MUTEX_UNLOCK) == VCHIQ_RETRY) goto bail_not_ready; } /* At this point slot_mutex is held */ vchiq_set_conn_state(state, VCHIQ_CONNSTATE_PAUSED); break; case VCHIQ_MSG_RESUME: - vchiq_log_trace(vchiq_core_log_level, - "%d: prs RESUME@%pK,%x", - state->id, header, size); + vchiq_log_trace(vchiq_core_log_level, "%d: prs RESUME@%pK,%x", + state->id, header, size); /* Release the slot mutex */ mutex_unlock(&state->slot_mutex); vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); @@ -1919,9 +1820,8 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) break; default: - vchiq_log_error(vchiq_core_log_level, - "%d: prs invalid msgid %x@%pK,%x", - state->id, msgid, header, size); + vchiq_log_error(vchiq_core_log_level, "%d: prs invalid msgid %x@%pK,%x", + state->id, msgid, header, size); WARN(1, "invalid message\n"); break; } @@ -1943,7 +1843,7 @@ parse_rx_slots(struct vchiq_state *state) struct vchiq_shared_state *remote = state->remote; int tx_pos; - DEBUG_INITIALISE(state->local) + DEBUG_INITIALISE(state->local); tx_pos = remote->tx_pos; @@ -2031,8 +1931,7 @@ handle_poll(struct vchiq_state *state) * since the PAUSE should have flushed * through outstanding messages. */ - vchiq_log_error(vchiq_core_log_level, - "Failed to send RESUME message"); + vchiq_log_error(vchiq_core_log_level, "Failed to send RESUME message"); } break; default: @@ -2049,7 +1948,7 @@ slot_handler_func(void *v) struct vchiq_state *state = v; struct vchiq_shared_state *local = state->local; - DEBUG_INITIALISE(local) + DEBUG_INITIALISE(local); while (1) { DEBUG_COUNT(SLOT_HANDLER_COUNT); @@ -2082,7 +1981,7 @@ recycle_func(void *v) { struct vchiq_state *state = v; struct vchiq_shared_state *local = state->local; - BITSET_T *found; + u32 *found; size_t length; length = sizeof(*found) * BITSET_SIZE(VCHIQ_MAX_SERVICES); @@ -2130,9 +2029,9 @@ sync_func(void *v) if (!service) { vchiq_log_error(vchiq_sync_log_level, - "%d: sf %s@%pK (%d->%d) - invalid/closed service %d", - state->id, msg_type_str(type), - header, remoteport, localport, localport); + "%d: sf %s@%pK (%d->%d) - invalid/closed service %d", + state->id, msg_type_str(type), header, + remoteport, localport, localport); release_message_sync(state, header); continue; } @@ -2144,13 +2043,11 @@ sync_func(void *v) ? service->base.fourcc : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); vchiq_log_trace(vchiq_sync_log_level, - "Rcvd Msg %s from %c%c%c%c s:%d d:%d len:%d", - msg_type_str(type), - VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), - remoteport, localport, size); + "Rcvd Msg %s from %c%c%c%c s:%d d:%d len:%d", + msg_type_str(type), VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), + remoteport, localport, size); if (size > 0) - vchiq_log_dump_mem("Rcvd", 0, header->data, - min(16, size)); + vchiq_log_dump_mem("Rcvd", 0, header->data, min(16, size)); } switch (type) { @@ -2161,14 +2058,12 @@ sync_func(void *v) header->data; service->peer_version = payload->version; } - vchiq_log_info(vchiq_sync_log_level, - "%d: sf OPENACK@%pK,%x (%d->%d) v:%d", - state->id, header, size, remoteport, localport, - service->peer_version); + vchiq_log_info(vchiq_sync_log_level, "%d: sf OPENACK@%pK,%x (%d->%d) v:%d", + state->id, header, size, remoteport, localport, + service->peer_version); if (service->srvstate == VCHIQ_SRVSTATE_OPENING) { service->remoteport = remoteport; - vchiq_set_service_state(service, - VCHIQ_SRVSTATE_OPENSYNC); + vchiq_set_service_state(service, VCHIQ_SRVSTATE_OPENSYNC); service->sync = 1; complete(&service->remove_event); } @@ -2176,25 +2071,22 @@ sync_func(void *v) break; case VCHIQ_MSG_DATA: - vchiq_log_trace(vchiq_sync_log_level, - "%d: sf DATA@%pK,%x (%d->%d)", - state->id, header, size, remoteport, localport); + vchiq_log_trace(vchiq_sync_log_level, "%d: sf DATA@%pK,%x (%d->%d)", + state->id, header, size, remoteport, localport); if ((service->remoteport == remoteport) && (service->srvstate == VCHIQ_SRVSTATE_OPENSYNC)) { - if (make_service_callback(service, - VCHIQ_MESSAGE_AVAILABLE, header, - NULL) == VCHIQ_RETRY) + if (make_service_callback(service, VCHIQ_MESSAGE_AVAILABLE, header, + NULL) == VCHIQ_RETRY) vchiq_log_error(vchiq_sync_log_level, - "synchronous callback to service %d returns VCHIQ_RETRY", - localport); + "synchronous callback to service %d returns VCHIQ_RETRY", + localport); } break; default: - vchiq_log_error(vchiq_sync_log_level, - "%d: sf unexpected msgid %x@%pK,%x", - state->id, msgid, header, size); + vchiq_log_error(vchiq_sync_log_level, "%d: sf unexpected msgid %x@%pK,%x", + state->id, msgid, header, size); release_message_sync(state, header); break; } @@ -2237,9 +2129,8 @@ vchiq_init_slots(void *mem_base, int mem_size) num_slots -= first_data_slot; if (num_slots < 4) { - vchiq_log_error(vchiq_core_log_level, - "%s - insufficient memory %x bytes", - __func__, mem_size); + vchiq_log_error(vchiq_core_log_level, "%s - insufficient memory %x bytes", + __func__, mem_size); return NULL; } @@ -2330,7 +2221,7 @@ vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero) state->default_slot_quota = state->slot_queue_available / 2; state->default_message_quota = min((unsigned short)(state->default_slot_quota * 256), - (unsigned short)~0); + (unsigned short)~0); state->previous_data_index = -1; state->data_use_count = 0; @@ -2359,9 +2250,7 @@ vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero) * bring up slot handler thread */ snprintf(threadname, sizeof(threadname), "vchiq-slot/%d", state->id); - state->slot_handler_thread = kthread_create(&slot_handler_func, - (void *)state, - threadname); + state->slot_handler_thread = kthread_create(&slot_handler_func, (void *)state, threadname); if (IS_ERR(state->slot_handler_thread)) { vchiq_loud_error_header(); @@ -2372,9 +2261,7 @@ vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero) set_user_nice(state->slot_handler_thread, -19); snprintf(threadname, sizeof(threadname), "vchiq-recy/%d", state->id); - state->recycle_thread = kthread_create(&recycle_func, - (void *)state, - threadname); + state->recycle_thread = kthread_create(&recycle_func, (void *)state, threadname); if (IS_ERR(state->recycle_thread)) { vchiq_loud_error_header(); vchiq_loud_error("couldn't create thread %s", threadname); @@ -2385,9 +2272,7 @@ vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero) set_user_nice(state->recycle_thread, -19); snprintf(threadname, sizeof(threadname), "vchiq-sync/%d", state->id); - state->sync_thread = kthread_create(&sync_func, - (void *)state, - threadname); + state->sync_thread = kthread_create(&sync_func, (void *)state, threadname); if (IS_ERR(state->sync_thread)) { vchiq_loud_error_header(); vchiq_loud_error("couldn't create thread %s", threadname); @@ -2474,7 +2359,7 @@ struct vchiq_service * vchiq_add_service_internal(struct vchiq_state *state, const struct vchiq_service_params_kernel *params, int srvstate, struct vchiq_instance *instance, - vchiq_userdata_term userdata_term) + void (*userdata_term)(void *userdata)) { struct vchiq_service *service; struct vchiq_service __rcu **pservice = NULL; @@ -2603,12 +2488,9 @@ vchiq_add_service_internal(struct vchiq_state *state, /* Bring this service online */ vchiq_set_service_state(service, srvstate); - vchiq_log_info(vchiq_core_msg_log_level, - "%s Service %c%c%c%c SrcPort:%d", - (srvstate == VCHIQ_SRVSTATE_OPENING) - ? "Open" : "Add", - VCHIQ_FOURCC_AS_4CHARS(params->fourcc), - service->localport); + vchiq_log_info(vchiq_core_msg_log_level, "%s Service %c%c%c%c SrcPort:%d", + (srvstate == VCHIQ_SRVSTATE_OPENING) ? "Open" : "Add", + VCHIQ_FOURCC_AS_4CHARS(params->fourcc), service->localport); /* Don't unlock the service - leave it with a ref_count of 1. */ @@ -2703,19 +2585,15 @@ release_service_messages(struct vchiq_service *service) int msgid = header->msgid; int port = VCHIQ_MSG_DSTPORT(msgid); - if ((port == service->localport) && - (msgid & VCHIQ_MSGID_CLAIMED)) { - vchiq_log_info(vchiq_core_log_level, - " fsi - hdr %pK", header); - release_slot(state, slot_info, header, - NULL); + if ((port == service->localport) && (msgid & VCHIQ_MSGID_CLAIMED)) { + vchiq_log_info(vchiq_core_log_level, " fsi - hdr %pK", header); + release_slot(state, slot_info, header, NULL); } pos += calc_stride(header->size); if (pos > VCHIQ_SLOT_SIZE) { vchiq_log_error(vchiq_core_log_level, - "fsi - pos %x: header %pK, msgid %x, header->msgid %x, header->size %x", - pos, header, msgid, - header->msgid, header->size); + "fsi - pos %x: header %pK, msgid %x, header->msgid %x, header->size %x", + pos, header, msgid, header->msgid, header->size); WARN(1, "invalid slot position\n"); } } @@ -2769,15 +2647,13 @@ close_service_complete(struct vchiq_service *service, int failstate) case VCHIQ_SRVSTATE_LISTENING: break; default: - vchiq_log_error(vchiq_core_log_level, - "%s(%x) called in state %s", __func__, - service->handle, srvstate_names[service->srvstate]); + vchiq_log_error(vchiq_core_log_level, "%s(%x) called in state %s", __func__, + service->handle, srvstate_names[service->srvstate]); WARN(1, "%s in unexpected state\n", __func__); return VCHIQ_ERROR; } - status = make_service_callback(service, - VCHIQ_SERVICE_CLOSED, NULL, NULL); + status = make_service_callback(service, VCHIQ_SERVICE_CLOSED, NULL, NULL); if (status != VCHIQ_RETRY) { int uc = service->service_use_count; @@ -2818,9 +2694,8 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) int close_id = MAKE_CLOSE(service->localport, VCHIQ_MSG_DSTPORT(service->remoteport)); - vchiq_log_info(vchiq_core_log_level, "%d: csi:%d,%d (%s)", - service->state->id, service->localport, close_recvd, - srvstate_names[service->srvstate]); + vchiq_log_info(vchiq_core_log_level, "%d: csi:%d,%d (%s)", service->state->id, + service->localport, close_recvd, srvstate_names[service->srvstate]); switch (service->srvstate) { case VCHIQ_SRVSTATE_CLOSED: @@ -2828,9 +2703,8 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) case VCHIQ_SRVSTATE_LISTENING: case VCHIQ_SRVSTATE_CLOSEWAIT: if (close_recvd) { - vchiq_log_error(vchiq_core_log_level, - "%s(1) called in state %s", - __func__, srvstate_names[service->srvstate]); + vchiq_log_error(vchiq_core_log_level, "%s(1) called in state %s", + __func__, srvstate_names[service->srvstate]); } else if (is_server) { if (service->srvstate == VCHIQ_SRVSTATE_LISTENING) { status = VCHIQ_ERROR; @@ -2839,8 +2713,7 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) service->remoteport = VCHIQ_PORT_FREE; if (service->srvstate == VCHIQ_SRVSTATE_CLOSEWAIT) - vchiq_set_service_state(service, - VCHIQ_SRVSTATE_LISTENING); + vchiq_set_service_state(service, VCHIQ_SRVSTATE_LISTENING); } complete(&service->remove_event); } else { @@ -2850,13 +2723,11 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) case VCHIQ_SRVSTATE_OPENING: if (close_recvd) { /* The open was rejected - tell the user */ - vchiq_set_service_state(service, - VCHIQ_SRVSTATE_CLOSEWAIT); + vchiq_set_service_state(service, VCHIQ_SRVSTATE_CLOSEWAIT); complete(&service->remove_event); } else { /* Shutdown mid-open - let the other side know */ - status = queue_message(state, service, close_id, - NULL, NULL, 0, 0); + status = queue_message(state, service, close_id, NULL, NULL, 0, 0); } break; @@ -2872,8 +2743,8 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) release_service_messages(service); if (status == VCHIQ_SUCCESS) - status = queue_message(state, service, close_id, - NULL, NULL, 0, QMFLAGS_NO_MUTEX_UNLOCK); + status = queue_message(state, service, close_id, NULL, + NULL, 0, QMFLAGS_NO_MUTEX_UNLOCK); if (status != VCHIQ_SUCCESS) { if (service->srvstate == VCHIQ_SRVSTATE_OPENSYNC) @@ -2897,8 +2768,7 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) if (service->sync) mutex_unlock(&state->sync_mutex); - status = close_service_complete(service, - VCHIQ_SRVSTATE_CLOSERECVD); + status = close_service_complete(service, VCHIQ_SRVSTATE_CLOSERECVD); break; case VCHIQ_SRVSTATE_CLOSESENT: @@ -2912,23 +2782,19 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) } if (status == VCHIQ_SUCCESS) - status = close_service_complete(service, - VCHIQ_SRVSTATE_CLOSERECVD); + status = close_service_complete(service, VCHIQ_SRVSTATE_CLOSERECVD); break; case VCHIQ_SRVSTATE_CLOSERECVD: if (!close_recvd && is_server) /* Force into LISTENING mode */ - vchiq_set_service_state(service, - VCHIQ_SRVSTATE_LISTENING); - status = close_service_complete(service, - VCHIQ_SRVSTATE_CLOSERECVD); + vchiq_set_service_state(service, VCHIQ_SRVSTATE_LISTENING); + status = close_service_complete(service, VCHIQ_SRVSTATE_CLOSERECVD); break; default: - vchiq_log_error(vchiq_core_log_level, - "%s(%d) called in state %s", __func__, - close_recvd, srvstate_names[service->srvstate]); + vchiq_log_error(vchiq_core_log_level, "%s(%d) called in state %s", __func__, + close_recvd, srvstate_names[service->srvstate]); break; } @@ -2941,8 +2807,8 @@ vchiq_terminate_service_internal(struct vchiq_service *service) { struct vchiq_state *state = service->state; - vchiq_log_info(vchiq_core_log_level, "%d: tsi - (%d<->%d)", - state->id, service->localport, service->remoteport); + vchiq_log_info(vchiq_core_log_level, "%d: tsi - (%d<->%d)", state->id, + service->localport, service->remoteport); mark_service_closing(service); @@ -2956,8 +2822,7 @@ vchiq_free_service_internal(struct vchiq_service *service) { struct vchiq_state *state = service->state; - vchiq_log_info(vchiq_core_log_level, "%d: fsi - (%d)", - state->id, service->localport); + vchiq_log_info(vchiq_core_log_level, "%d: fsi - (%d)", state->id, service->localport); switch (service->srvstate) { case VCHIQ_SRVSTATE_OPENING: @@ -2967,10 +2832,8 @@ vchiq_free_service_internal(struct vchiq_service *service) case VCHIQ_SRVSTATE_CLOSEWAIT: break; default: - vchiq_log_error(vchiq_core_log_level, - "%d: fsi - (%d) in state %s", - state->id, service->localport, - srvstate_names[service->srvstate]); + vchiq_log_error(vchiq_core_log_level, "%d: fsi - (%d) in state %s", state->id, + service->localport, srvstate_names[service->srvstate]); return; } @@ -2990,17 +2853,15 @@ vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *instanc /* Find all services registered to this client and enable them. */ i = 0; - while ((service = next_service_by_instance(state, instance, - &i)) != NULL) { + while ((service = next_service_by_instance(state, instance, &i)) != NULL) { if (service->srvstate == VCHIQ_SRVSTATE_HIDDEN) - vchiq_set_service_state(service, - VCHIQ_SRVSTATE_LISTENING); + vchiq_set_service_state(service, VCHIQ_SRVSTATE_LISTENING); vchiq_service_put(service); } if (state->conn_state == VCHIQ_CONNSTATE_DISCONNECTED) { - if (queue_message(state, NULL, MAKE_CONNECT, NULL, NULL, - 0, QMFLAGS_IS_BLOCKING) == VCHIQ_RETRY) + if (queue_message(state, NULL, MAKE_CONNECT, NULL, NULL, 0, + QMFLAGS_IS_BLOCKING) == VCHIQ_RETRY) return VCHIQ_RETRY; vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTING); @@ -3025,8 +2886,7 @@ vchiq_shutdown_internal(struct vchiq_state *state, struct vchiq_instance *instan /* Find all services registered to this client and remove them. */ i = 0; - while ((service = next_service_by_instance(state, instance, - &i)) != NULL) { + while ((service = next_service_by_instance(state, instance, &i)) != NULL) { (void)vchiq_remove_service(service->handle); vchiq_service_put(service); } @@ -3042,9 +2902,8 @@ vchiq_close_service(unsigned int handle) if (!service) return VCHIQ_ERROR; - vchiq_log_info(vchiq_core_log_level, - "%d: close_service:%d", - service->state->id, service->localport); + vchiq_log_info(vchiq_core_log_level, "%d: close_service:%d", + service->state->id, service->localport); if ((service->srvstate == VCHIQ_SRVSTATE_FREE) || (service->srvstate == VCHIQ_SRVSTATE_LISTENING) || @@ -3075,9 +2934,9 @@ vchiq_close_service(unsigned int handle) break; vchiq_log_warning(vchiq_core_log_level, - "%d: close_service:%d - waiting in state %s", - service->state->id, service->localport, - srvstate_names[service->srvstate]); + "%d: close_service:%d - waiting in state %s", + service->state->id, service->localport, + srvstate_names[service->srvstate]); } if ((status == VCHIQ_SUCCESS) && @@ -3101,9 +2960,8 @@ vchiq_remove_service(unsigned int handle) if (!service) return VCHIQ_ERROR; - vchiq_log_info(vchiq_core_log_level, - "%d: remove_service:%d", - service->state->id, service->localport); + vchiq_log_info(vchiq_core_log_level, "%d: remove_service:%d", + service->state->id, service->localport); if (service->srvstate == VCHIQ_SRVSTATE_FREE) { vchiq_service_put(service); @@ -3137,9 +2995,9 @@ vchiq_remove_service(unsigned int handle) break; vchiq_log_warning(vchiq_core_log_level, - "%d: remove_service:%d - waiting in state %s", - service->state->id, service->localport, - srvstate_names[service->srvstate]); + "%d: remove_service:%d - waiting in state %s", + service->state->id, service->localport, + srvstate_names[service->srvstate]); } if ((status == VCHIQ_SUCCESS) && @@ -3159,11 +3017,9 @@ vchiq_remove_service(unsigned int handle) * When called in blocking mode, the userdata field points to a bulk_waiter * structure. */ -enum vchiq_status vchiq_bulk_transfer(unsigned int handle, - void *offset, void __user *uoffset, - int size, void *userdata, - enum vchiq_bulk_mode mode, - enum vchiq_bulk_dir dir) +enum vchiq_status vchiq_bulk_transfer(unsigned int handle, void *offset, void __user *uoffset, + int size, void *userdata, enum vchiq_bulk_mode mode, + enum vchiq_bulk_dir dir) { struct vchiq_service *service = find_service_by_handle(handle); struct vchiq_bulk_queue *queue; @@ -3220,8 +3076,7 @@ enum vchiq_status vchiq_bulk_transfer(unsigned int handle, VCHIQ_SERVICE_STATS_INC(service, bulk_stalls); do { mutex_unlock(&service->bulk_mutex); - if (wait_for_completion_interruptible( - &service->bulk_remove_event)) { + if (wait_for_completion_interruptible(&service->bulk_remove_event)) { status = VCHIQ_RETRY; goto error_exit; } @@ -3246,10 +3101,9 @@ enum vchiq_status vchiq_bulk_transfer(unsigned int handle, wmb(); - vchiq_log_info(vchiq_core_log_level, - "%d: bt (%d->%d) %cx %x@%pad %pK", - state->id, service->localport, service->remoteport, dir_char, - size, &bulk->data, userdata); + vchiq_log_info(vchiq_core_log_level, "%d: bt (%d->%d) %cx %x@%pad %pK", + state->id, service->localport, service->remoteport, + dir_char, size, &bulk->data, userdata); /* * The slot mutex must be held when the service is being closed, so @@ -3284,11 +3138,9 @@ enum vchiq_status vchiq_bulk_transfer(unsigned int handle, mutex_unlock(&state->slot_mutex); mutex_unlock(&service->bulk_mutex); - vchiq_log_trace(vchiq_core_log_level, - "%d: bt:%d %cx li=%x ri=%x p=%x", - state->id, - service->localport, dir_char, - queue->local_insert, queue->remote_insert, queue->process); + vchiq_log_trace(vchiq_core_log_level, "%d: bt:%d %cx li=%x ri=%x p=%x", + state->id, service->localport, dir_char, queue->local_insert, + queue->remote_insert, queue->process); waiting: vchiq_service_put(service); @@ -3338,7 +3190,6 @@ vchiq_queue_message(unsigned int handle, if (!size) { VCHIQ_SERVICE_STATS_INC(service, error_count); goto error_exit; - } if (size > VCHIQ_MAX_MSG_SIZE) { @@ -3351,11 +3202,11 @@ vchiq_queue_message(unsigned int handle, switch (service->srvstate) { case VCHIQ_SRVSTATE_OPEN: status = queue_message(service->state, service, data_id, - copy_callback, context, size, 1); + copy_callback, context, size, 1); break; case VCHIQ_SRVSTATE_OPENSYNC: status = queue_message_sync(service->state, service, data_id, - copy_callback, context, size, 1); + copy_callback, context, size, 1); break; default: status = VCHIQ_ERROR; @@ -3470,8 +3321,7 @@ void vchiq_get_config(struct vchiq_config *config) } int -vchiq_set_service_option(unsigned int handle, - enum vchiq_service_option option, int value) +vchiq_set_service_option(unsigned int handle, enum vchiq_service_option option, int value) { struct vchiq_service *service = find_service_by_handle(handle); struct vchiq_service_quota *quota; @@ -3565,16 +3415,14 @@ vchiq_dump_shared_state(void *dump_context, struct vchiq_state *state, int len; int err; - len = scnprintf(buf, sizeof(buf), - " %s: slots %d-%d tx_pos=%x recycle=%x", - label, shared->slot_first, shared->slot_last, - shared->tx_pos, shared->slot_queue_recycle); + len = scnprintf(buf, sizeof(buf), " %s: slots %d-%d tx_pos=%x recycle=%x", + label, shared->slot_first, shared->slot_last, + shared->tx_pos, shared->slot_queue_recycle); err = vchiq_dump(dump_context, buf, len + 1); if (err) return err; - len = scnprintf(buf, sizeof(buf), - " Slots claimed:"); + len = scnprintf(buf, sizeof(buf), " Slots claimed:"); err = vchiq_dump(dump_context, buf, len + 1); if (err) return err; @@ -3583,9 +3431,8 @@ vchiq_dump_shared_state(void *dump_context, struct vchiq_state *state, struct vchiq_slot_info slot_info = *SLOT_INFO_FROM_INDEX(state, i); if (slot_info.use_count != slot_info.release_count) { - len = scnprintf(buf, sizeof(buf), - " %d: %d/%d", i, slot_info.use_count, - slot_info.release_count); + len = scnprintf(buf, sizeof(buf), " %d: %d/%d", i, slot_info.use_count, + slot_info.release_count); err = vchiq_dump(dump_context, buf, len + 1); if (err) return err; @@ -3594,7 +3441,7 @@ vchiq_dump_shared_state(void *dump_context, struct vchiq_state *state, for (i = 1; i < shared->debug[DEBUG_ENTRIES]; i++) { len = scnprintf(buf, sizeof(buf), " DEBUG: %s = %d(%x)", - debug_names[i], shared->debug[i], shared->debug[i]); + debug_names[i], shared->debug[i], shared->debug[i]); err = vchiq_dump(dump_context, buf, len + 1); if (err) return err; @@ -3610,45 +3457,43 @@ int vchiq_dump_state(void *dump_context, struct vchiq_state *state) int err; len = scnprintf(buf, sizeof(buf), "State %d: %s", state->id, - conn_state_names[state->conn_state]); + conn_state_names[state->conn_state]); err = vchiq_dump(dump_context, buf, len + 1); if (err) return err; - len = scnprintf(buf, sizeof(buf), - " tx_pos=%x(@%pK), rx_pos=%x(@%pK)", - state->local->tx_pos, - state->tx_data + (state->local_tx_pos & VCHIQ_SLOT_MASK), - state->rx_pos, - state->rx_data + (state->rx_pos & VCHIQ_SLOT_MASK)); + len = scnprintf(buf, sizeof(buf), " tx_pos=%x(@%pK), rx_pos=%x(@%pK)", + state->local->tx_pos, + state->tx_data + (state->local_tx_pos & VCHIQ_SLOT_MASK), + state->rx_pos, + state->rx_data + (state->rx_pos & VCHIQ_SLOT_MASK)); err = vchiq_dump(dump_context, buf, len + 1); if (err) return err; - len = scnprintf(buf, sizeof(buf), - " Version: %d (min %d)", - VCHIQ_VERSION, VCHIQ_VERSION_MIN); + len = scnprintf(buf, sizeof(buf), " Version: %d (min %d)", + VCHIQ_VERSION, VCHIQ_VERSION_MIN); err = vchiq_dump(dump_context, buf, len + 1); if (err) return err; if (VCHIQ_ENABLE_STATS) { len = scnprintf(buf, sizeof(buf), - " Stats: ctrl_tx_count=%d, ctrl_rx_count=%d, error_count=%d", - state->stats.ctrl_tx_count, state->stats.ctrl_rx_count, - state->stats.error_count); + " Stats: ctrl_tx_count=%d, ctrl_rx_count=%d, error_count=%d", + state->stats.ctrl_tx_count, state->stats.ctrl_rx_count, + state->stats.error_count); err = vchiq_dump(dump_context, buf, len + 1); if (err) return err; } len = scnprintf(buf, sizeof(buf), - " Slots: %d available (%d data), %d recyclable, %d stalls (%d data)", - ((state->slot_queue_available * VCHIQ_SLOT_SIZE) - + " Slots: %d available (%d data), %d recyclable, %d stalls (%d data)", + ((state->slot_queue_available * VCHIQ_SLOT_SIZE) - state->local_tx_pos) / VCHIQ_SLOT_SIZE, - state->data_quota - state->data_use_count, - state->local->slot_queue_recycle - state->slot_queue_available, - state->stats.slot_stalls, state->stats.data_stalls); + state->data_quota - state->data_use_count, + state->local->slot_queue_recycle - state->slot_queue_available, + state->stats.slot_stalls, state->stats.data_stalls); err = vchiq_dump(dump_context, buf, len + 1); if (err) return err; @@ -3712,21 +3557,17 @@ int vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) "%u", service->remoteport); if (service->public_fourcc != VCHIQ_FOURCC_INVALID) - scnprintf(remoteport + len2, - sizeof(remoteport) - len2, - " (client %x)", service->client_id); + scnprintf(remoteport + len2, sizeof(remoteport) - len2, + " (client %x)", service->client_id); } else { strscpy(remoteport, "n/a", sizeof(remoteport)); } len += scnprintf(buf + len, sizeof(buf) - len, - " '%c%c%c%c' remote %s (msg use %d/%d, slot use %d/%d)", - VCHIQ_FOURCC_AS_4CHARS(fourcc), - remoteport, - quota->message_use_count, - quota->message_quota, - quota->slot_use_count, - quota->slot_quota); + " '%c%c%c%c' remote %s (msg use %d/%d, slot use %d/%d)", + VCHIQ_FOURCC_AS_4CHARS(fourcc), remoteport, + quota->message_use_count, quota->message_quota, + quota->slot_use_count, quota->slot_quota); err = vchiq_dump(dump_context, buf, len + 1); if (err) @@ -3739,13 +3580,13 @@ int vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) service->bulk_rx.remote_insert; len = scnprintf(buf, sizeof(buf), - " Bulk: tx_pending=%d (size %d), rx_pending=%d (size %d)", - tx_pending, - tx_pending ? service->bulk_tx.bulks[ - BULK_INDEX(service->bulk_tx.remove)].size : 0, - rx_pending, - rx_pending ? service->bulk_rx.bulks[ - BULK_INDEX(service->bulk_rx.remove)].size : 0); + " Bulk: tx_pending=%d (size %d), rx_pending=%d (size %d)", + tx_pending, + tx_pending ? + service->bulk_tx.bulks[BULK_INDEX(service->bulk_tx.remove)].size : + 0, rx_pending, rx_pending ? + service->bulk_rx.bulks[BULK_INDEX(service->bulk_rx.remove)].size : + 0); if (VCHIQ_ENABLE_STATS) { err = vchiq_dump(dump_context, buf, len + 1); @@ -3753,32 +3594,27 @@ int vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) return err; len = scnprintf(buf, sizeof(buf), - " Ctrl: tx_count=%d, tx_bytes=%llu, rx_count=%d, rx_bytes=%llu", - service->stats.ctrl_tx_count, - service->stats.ctrl_tx_bytes, - service->stats.ctrl_rx_count, - service->stats.ctrl_rx_bytes); + " Ctrl: tx_count=%d, tx_bytes=%llu, rx_count=%d, rx_bytes=%llu", + service->stats.ctrl_tx_count, service->stats.ctrl_tx_bytes, + service->stats.ctrl_rx_count, service->stats.ctrl_rx_bytes); err = vchiq_dump(dump_context, buf, len + 1); if (err) return err; len = scnprintf(buf, sizeof(buf), - " Bulk: tx_count=%d, tx_bytes=%llu, rx_count=%d, rx_bytes=%llu", - service->stats.bulk_tx_count, - service->stats.bulk_tx_bytes, - service->stats.bulk_rx_count, - service->stats.bulk_rx_bytes); + " Bulk: tx_count=%d, tx_bytes=%llu, rx_count=%d, rx_bytes=%llu", + service->stats.bulk_tx_count, service->stats.bulk_tx_bytes, + service->stats.bulk_rx_count, service->stats.bulk_rx_bytes); err = vchiq_dump(dump_context, buf, len + 1); if (err) return err; len = scnprintf(buf, sizeof(buf), - " %d quota stalls, %d slot stalls, %d bulk stalls, %d aborted, %d errors", - service->stats.quota_stalls, - service->stats.slot_stalls, - service->stats.bulk_stalls, - service->stats.bulk_aborted_count, - service->stats.error_count); + " %d quota stalls, %d slot stalls, %d bulk stalls, %d aborted, %d errors", + service->stats.quota_stalls, service->stats.slot_stalls, + service->stats.bulk_stalls, + service->stats.bulk_aborted_count, + service->stats.error_count); } } @@ -3795,9 +3631,9 @@ void vchiq_loud_error_header(void) { vchiq_log_error(vchiq_core_log_level, - "============================================================================"); + "============================================================================"); vchiq_log_error(vchiq_core_log_level, - "============================================================================"); + "============================================================================"); vchiq_log_error(vchiq_core_log_level, "====="); } @@ -3806,9 +3642,9 @@ vchiq_loud_error_footer(void) { vchiq_log_error(vchiq_core_log_level, "====="); vchiq_log_error(vchiq_core_log_level, - "============================================================================"); + "============================================================================"); vchiq_log_error(vchiq_core_log_level, - "============================================================================"); + "============================================================================"); } enum vchiq_status vchiq_send_remote_use(struct vchiq_state *state) @@ -3828,8 +3664,7 @@ enum vchiq_status vchiq_send_remote_use_active(struct vchiq_state *state) NULL, NULL, 0, 0); } -void vchiq_log_dump_mem(const char *label, u32 addr, const void *void_mem, - size_t num_bytes) +void vchiq_log_dump_mem(const char *label, u32 addr, const void *void_mem, size_t num_bytes) { const u8 *mem = void_mem; size_t offset; @@ -3858,11 +3693,9 @@ void vchiq_log_dump_mem(const char *label, u32 addr, const void *void_mem, *s++ = '\0'; if (label && (*label != '\0')) - vchiq_log_trace(VCHIQ_LOG_TRACE, - "%s: %08x: %s", label, addr, line_buf); + vchiq_log_trace(VCHIQ_LOG_TRACE, "%s: %08x: %s", label, addr, line_buf); else - vchiq_log_trace(VCHIQ_LOG_TRACE, - "%08x: %s", addr, line_buf); + vchiq_log_trace(VCHIQ_LOG_TRACE, "%08x: %s", addr, line_buf); addr += 16; mem += 16; |