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 | 231 |
1 files changed, 138 insertions, 93 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 56a23a297fa4..76351078affb 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -132,7 +132,7 @@ vchiq_set_service_state(struct vchiq_service *service, int newstate) } struct vchiq_service * -find_service_by_handle(VCHIQ_SERVICE_HANDLE_T handle) +find_service_by_handle(unsigned int handle) { struct vchiq_service *service; @@ -177,8 +177,8 @@ find_service_by_port(struct vchiq_state *state, int localport) } struct vchiq_service * -find_service_for_instance(VCHIQ_INSTANCE_T instance, - VCHIQ_SERVICE_HANDLE_T handle) +find_service_for_instance(struct vchiq_instance *instance, + unsigned int handle) { struct vchiq_service *service; @@ -201,8 +201,8 @@ find_service_for_instance(VCHIQ_INSTANCE_T instance, } struct vchiq_service * -find_closed_service_for_instance(VCHIQ_INSTANCE_T instance, - VCHIQ_SERVICE_HANDLE_T handle) +find_closed_service_for_instance(struct vchiq_instance *instance, + unsigned int handle) { struct vchiq_service *service; @@ -227,7 +227,7 @@ find_closed_service_for_instance(VCHIQ_INSTANCE_T instance, } struct vchiq_service * -next_service_by_instance(struct vchiq_state *state, VCHIQ_INSTANCE_T instance, +next_service_by_instance(struct vchiq_state *state, struct vchiq_instance *instance, int *pidx) { struct vchiq_service *service = NULL; @@ -295,7 +295,7 @@ unlock: } int -vchiq_get_client_id(VCHIQ_SERVICE_HANDLE_T handle) +vchiq_get_client_id(unsigned int handle) { struct vchiq_service *service = find_service_by_handle(handle); int id; @@ -308,7 +308,7 @@ vchiq_get_client_id(VCHIQ_SERVICE_HANDLE_T handle) } void * -vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T handle) +vchiq_get_service_userdata(unsigned int handle) { struct vchiq_service *service = handle_to_service(handle); @@ -316,7 +316,7 @@ vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T handle) } int -vchiq_get_service_fourcc(VCHIQ_SERVICE_HANDLE_T handle) +vchiq_get_service_fourcc(unsigned int handle) { struct vchiq_service *service = handle_to_service(handle); @@ -354,11 +354,11 @@ mark_service_closing(struct vchiq_service *service) mark_service_closing_internal(service, 0); } -static inline VCHIQ_STATUS_T -make_service_callback(struct vchiq_service *service, VCHIQ_REASON_T reason, +static inline enum vchiq_status +make_service_callback(struct vchiq_service *service, enum vchiq_reason reason, struct vchiq_header *header, void *bulk_userdata) { - VCHIQ_STATUS_T status; + 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], @@ -375,9 +375,9 @@ make_service_callback(struct vchiq_service *service, VCHIQ_REASON_T reason, } inline void -vchiq_set_conn_state(struct vchiq_state *state, VCHIQ_CONNSTATE_T newstate) +vchiq_set_conn_state(struct vchiq_state *state, enum vchiq_connstate newstate) { - VCHIQ_CONNSTATE_T oldstate = state->conn_state; + enum vchiq_connstate oldstate = state->conn_state; vchiq_log_info(vchiq_core_log_level, "%d: %s->%s", state->id, conn_state_names[oldstate], @@ -542,7 +542,7 @@ reserve_space(struct vchiq_state *state, size_t space, int is_blocking) if (space > slot_space) { struct vchiq_header *header; /* Fill the remaining space with padding */ - WARN_ON(state->tx_data == NULL); + WARN_ON(!state->tx_data); header = (struct vchiq_header *) (state->tx_data + (tx_pos & VCHIQ_SLOT_MASK)); header->msgid = VCHIQ_MSGID_PADDING; @@ -779,7 +779,7 @@ copy_message_data( } /* Called by the slot handler and application threads */ -static VCHIQ_STATUS_T +static enum vchiq_status queue_message(struct vchiq_state *state, struct vchiq_service *service, int msgid, ssize_t (*copy_callback)(void *context, void *dest, @@ -1027,7 +1027,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, } /* Called by the slot handler and application threads */ -static VCHIQ_STATUS_T +static enum vchiq_status queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, int msgid, ssize_t (*copy_callback)(void *context, void *dest, @@ -1178,11 +1178,11 @@ release_slot(struct vchiq_state *state, struct vchiq_slot_info *slot_info, } /* Called by the slot handler - don't hold the bulk mutex */ -static VCHIQ_STATUS_T +static enum vchiq_status notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, int retry_poll) { - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + enum vchiq_status status = VCHIQ_SUCCESS; vchiq_log_trace(vchiq_core_log_level, "%d: nb:%d %cx - p=%x rn=%x r=%x", @@ -1230,7 +1230,7 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, spin_unlock(&bulk_waiter_spinlock); } else if (bulk->mode == VCHIQ_BULK_MODE_CALLBACK) { - VCHIQ_REASON_T reason = (bulk->dir == + enum vchiq_reason reason = (bulk->dir == VCHIQ_BULK_TRANSMIT) ? ((bulk->actual == VCHIQ_BULK_ACTUAL_ABORTED) ? @@ -2078,7 +2078,7 @@ init_bulk_queue(struct vchiq_bulk_queue *queue) } inline const char * -get_conn_state_name(VCHIQ_CONNSTATE_T conn_state) +get_conn_state_name(enum vchiq_connstate conn_state) { return conn_state_names[conn_state]; } @@ -2123,18 +2123,15 @@ vchiq_init_slots(void *mem_base, int mem_size) return slot_zero; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero) { struct vchiq_shared_state *local; struct vchiq_shared_state *remote; - VCHIQ_STATUS_T status; + enum vchiq_status status; char threadname[16]; int i; - vchiq_log_warning(vchiq_core_log_level, - "%s: slot_zero = %pK", __func__, slot_zero); - if (vchiq_states[0]) { pr_err("%s: VCHIQ state already initialized\n", __func__); return VCHIQ_ERROR; @@ -2283,8 +2280,8 @@ fail_free_handler_thread: struct vchiq_service * vchiq_add_service_internal(struct vchiq_state *state, const struct vchiq_service_params *params, - int srvstate, VCHIQ_INSTANCE_T instance, - VCHIQ_USERDATA_TERM_T userdata_term) + int srvstate, struct vchiq_instance *instance, + vchiq_userdata_term userdata_term) { struct vchiq_service *service; struct vchiq_service **pservice = NULL; @@ -2412,7 +2409,7 @@ vchiq_add_service_internal(struct vchiq_state *state, return service; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_open_service_internal(struct vchiq_service *service, int client_id) { struct vchiq_open_payload payload = { @@ -2421,7 +2418,7 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id) service->version, service->version_min }; - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + enum vchiq_status status = VCHIQ_SUCCESS; service->client_id = client_id; vchiq_use_service_internal(service); @@ -2519,7 +2516,7 @@ release_service_messages(struct vchiq_service *service) static int do_abort_bulks(struct vchiq_service *service) { - VCHIQ_STATUS_T status; + enum vchiq_status status; /* Abort any outstanding bulk transfers */ if (mutex_lock_killable(&service->bulk_mutex)) @@ -2535,10 +2532,10 @@ do_abort_bulks(struct vchiq_service *service) return (status == VCHIQ_SUCCESS); } -static VCHIQ_STATUS_T +static enum vchiq_status close_service_complete(struct vchiq_service *service, int failstate) { - VCHIQ_STATUS_T status; + enum vchiq_status status; int is_server = (service->public_fourcc != VCHIQ_FOURCC_INVALID); int newstate; @@ -2597,11 +2594,11 @@ close_service_complete(struct vchiq_service *service, int failstate) } /* Called by the slot handler */ -VCHIQ_STATUS_T +enum vchiq_status vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) { struct vchiq_state *state = service->state; - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + enum vchiq_status status = VCHIQ_SUCCESS; int is_server = (service->public_fourcc != VCHIQ_FOURCC_INVALID); vchiq_log_info(vchiq_core_log_level, "%d: csi:%d,%d (%s)", @@ -2777,8 +2774,8 @@ vchiq_free_service_internal(struct vchiq_service *service) unlock_service(service); } -VCHIQ_STATUS_T -vchiq_connect_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) +enum vchiq_status +vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *instance) { struct vchiq_service *service; int i; @@ -2813,8 +2810,8 @@ vchiq_connect_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) return VCHIQ_SUCCESS; } -VCHIQ_STATUS_T -vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) +enum vchiq_status +vchiq_shutdown_internal(struct vchiq_state *state, struct vchiq_instance *instance) { struct vchiq_service *service; int i; @@ -2830,12 +2827,12 @@ vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) return VCHIQ_SUCCESS; } -VCHIQ_STATUS_T -vchiq_close_service(VCHIQ_SERVICE_HANDLE_T handle) +enum vchiq_status +vchiq_close_service(unsigned int handle) { /* Unregister the service */ struct vchiq_service *service = find_service_by_handle(handle); - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + enum vchiq_status status = VCHIQ_SUCCESS; if (!service) return VCHIQ_ERROR; @@ -2889,12 +2886,12 @@ vchiq_close_service(VCHIQ_SERVICE_HANDLE_T handle) return status; } -VCHIQ_STATUS_T -vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) +enum vchiq_status +vchiq_remove_service(unsigned int handle) { /* Unregister the service */ struct vchiq_service *service = find_service_by_handle(handle); - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + enum vchiq_status status = VCHIQ_SUCCESS; if (!service) return VCHIQ_ERROR; @@ -2955,10 +2952,10 @@ vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) * When called in blocking mode, the userdata field points to a bulk_waiter * structure. */ -VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, +enum vchiq_status vchiq_bulk_transfer(unsigned int handle, void *offset, int size, void *userdata, - VCHIQ_BULK_MODE_T mode, - VCHIQ_BULK_DIR_T dir) + enum vchiq_bulk_mode mode, + enum vchiq_bulk_dir dir) { struct vchiq_service *service = find_service_by_handle(handle); struct vchiq_bulk_queue *queue; @@ -2968,7 +2965,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, const char dir_char = (dir == VCHIQ_BULK_TRANSMIT) ? 't' : 'r'; const int dir_msgtype = (dir == VCHIQ_BULK_TRANSMIT) ? VCHIQ_MSG_BULK_TX : VCHIQ_MSG_BULK_RX; - VCHIQ_STATUS_T status = VCHIQ_ERROR; + enum vchiq_status status = VCHIQ_ERROR; int payload[2]; if (!service || service->srvstate != VCHIQ_SRVSTATE_OPEN || @@ -3103,15 +3100,15 @@ error_exit: return status; } -VCHIQ_STATUS_T -vchiq_queue_message(VCHIQ_SERVICE_HANDLE_T handle, +enum vchiq_status +vchiq_queue_message(unsigned int handle, ssize_t (*copy_callback)(void *context, void *dest, size_t offset, size_t maxsize), void *context, size_t size) { struct vchiq_service *service = find_service_by_handle(handle); - VCHIQ_STATUS_T status = VCHIQ_ERROR; + enum vchiq_status status = VCHIQ_ERROR; if (!service || (vchiq_check_service(service) != VCHIQ_SUCCESS)) @@ -3156,7 +3153,7 @@ error_exit: } void -vchiq_release_message(VCHIQ_SERVICE_HANDLE_T handle, +vchiq_release_message(unsigned int handle, struct vchiq_header *header) { struct vchiq_service *service = find_service_by_handle(handle); @@ -3195,10 +3192,10 @@ release_message_sync(struct vchiq_state *state, struct vchiq_header *header) remote_event_signal(&state->remote->sync_release); } -VCHIQ_STATUS_T -vchiq_get_peer_version(VCHIQ_SERVICE_HANDLE_T handle, short *peer_version) +enum vchiq_status +vchiq_get_peer_version(unsigned int handle, short *peer_version) { - VCHIQ_STATUS_T status = VCHIQ_ERROR; + enum vchiq_status status = VCHIQ_ERROR; struct vchiq_service *service = find_service_by_handle(handle); if (!service || @@ -3224,12 +3221,12 @@ void vchiq_get_config(struct vchiq_config *config) config->version_min = VCHIQ_VERSION_MIN; } -VCHIQ_STATUS_T -vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T handle, - VCHIQ_SERVICE_OPTION_T option, int value) +enum vchiq_status +vchiq_set_service_option(unsigned int handle, + enum vchiq_service_option option, int value) { struct vchiq_service *service = find_service_by_handle(handle); - VCHIQ_STATUS_T status = VCHIQ_ERROR; + enum vchiq_status status = VCHIQ_ERROR; if (service) { switch (option) { @@ -3301,7 +3298,7 @@ vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T handle, return status; } -static void +static int vchiq_dump_shared_state(void *dump_context, struct vchiq_state *state, struct vchiq_shared_state *shared, const char *label) { @@ -3321,16 +3318,21 @@ vchiq_dump_shared_state(void *dump_context, struct vchiq_state *state, int i; char buf[80]; 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); - vchiq_dump(dump_context, buf, len + 1); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; len = scnprintf(buf, sizeof(buf), " Slots claimed:"); - vchiq_dump(dump_context, buf, len + 1); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; for (i = shared->slot_first; i <= shared->slot_last; i++) { struct vchiq_slot_info slot_info = @@ -3339,27 +3341,34 @@ vchiq_dump_shared_state(void *dump_context, struct vchiq_state *state, len = scnprintf(buf, sizeof(buf), " %d: %d/%d", i, slot_info.use_count, slot_info.release_count); - vchiq_dump(dump_context, buf, len + 1); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; } } 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]); - vchiq_dump(dump_context, buf, len + 1); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; } + return 0; } -void -vchiq_dump_state(void *dump_context, struct vchiq_state *state) +int vchiq_dump_state(void *dump_context, struct vchiq_state *state) { char buf[80]; int len; int i; + int err; len = scnprintf(buf, sizeof(buf), "State %d: %s", state->id, conn_state_names[state->conn_state]); - vchiq_dump(dump_context, buf, len + 1); + 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)", @@ -3367,12 +3376,16 @@ vchiq_dump_state(void *dump_context, struct vchiq_state *state) state->tx_data + (state->local_tx_pos & VCHIQ_SLOT_MASK), state->rx_pos, state->rx_data + (state->rx_pos & VCHIQ_SLOT_MASK)); - vchiq_dump(dump_context, buf, len + 1); + 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); - vchiq_dump(dump_context, buf, len + 1); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; if (VCHIQ_ENABLE_STATS) { len = scnprintf(buf, sizeof(buf), @@ -3380,7 +3393,9 @@ vchiq_dump_state(void *dump_context, struct vchiq_state *state) "error_count=%d", state->stats.ctrl_tx_count, state->stats.ctrl_rx_count, state->stats.error_count); - vchiq_dump(dump_context, buf, len + 1); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; } len = scnprintf(buf, sizeof(buf), @@ -3391,30 +3406,49 @@ vchiq_dump_state(void *dump_context, struct vchiq_state *state) state->data_quota - state->data_use_count, state->local->slot_queue_recycle - state->slot_queue_available, state->stats.slot_stalls, state->stats.data_stalls); - vchiq_dump(dump_context, buf, len + 1); - - vchiq_dump_platform_state(dump_context); - - vchiq_dump_shared_state(dump_context, state, state->local, "Local"); - vchiq_dump_shared_state(dump_context, state, state->remote, "Remote"); - - vchiq_dump_platform_instances(dump_context); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; + + err = vchiq_dump_platform_state(dump_context); + if (err) + return err; + + err = vchiq_dump_shared_state(dump_context, + state, + state->local, + "Local"); + if (err) + return err; + err = vchiq_dump_shared_state(dump_context, + state, + state->remote, + "Remote"); + if (err) + return err; + + err = vchiq_dump_platform_instances(dump_context); + if (err) + return err; for (i = 0; i < state->unused_service; i++) { struct vchiq_service *service = find_service_by_port(state, i); if (service) { - vchiq_dump_service_state(dump_context, service); + err = vchiq_dump_service_state(dump_context, service); unlock_service(service); + if (err) + return err; } } + return 0; } -void -vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) +int vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) { char buf[80]; int len; + int err; len = scnprintf(buf, sizeof(buf), "Service %u: %s (ref %u)", service->localport, srvstate_names[service->srvstate], @@ -3447,7 +3481,9 @@ vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) service_quota->slot_use_count, service_quota->slot_quota); - vchiq_dump(dump_context, buf, len + 1); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; tx_pending = service->bulk_tx.local_insert - service->bulk_tx.remote_insert; @@ -3466,7 +3502,9 @@ vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) BULK_INDEX(service->bulk_rx.remove)].size : 0); if (VCHIQ_ENABLE_STATS) { - vchiq_dump(dump_context, buf, len + 1); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; len = scnprintf(buf, sizeof(buf), " Ctrl: tx_count=%d, tx_bytes=%llu, " @@ -3475,7 +3513,9 @@ vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) service->stats.ctrl_tx_bytes, service->stats.ctrl_rx_count, service->stats.ctrl_rx_bytes); - vchiq_dump(dump_context, buf, len + 1); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; len = scnprintf(buf, sizeof(buf), " Bulk: tx_count=%d, tx_bytes=%llu, " @@ -3484,7 +3524,9 @@ vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) service->stats.bulk_tx_bytes, service->stats.bulk_rx_count, service->stats.bulk_rx_bytes); - vchiq_dump(dump_context, buf, len + 1); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; len = scnprintf(buf, sizeof(buf), " %d quota stalls, %d slot stalls, " @@ -3497,10 +3539,13 @@ vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) } } - vchiq_dump(dump_context, buf, len + 1); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; if (service->srvstate != VCHIQ_SRVSTATE_FREE) - vchiq_dump_platform_service_state(dump_context, service); + err = vchiq_dump_platform_service_state(dump_context, service); + return err; } void @@ -3527,9 +3572,9 @@ vchiq_loud_error_footer(void) "================"); } -VCHIQ_STATUS_T vchiq_send_remote_use(struct vchiq_state *state) +enum vchiq_status vchiq_send_remote_use(struct vchiq_state *state) { - VCHIQ_STATUS_T status = VCHIQ_RETRY; + enum vchiq_status status = VCHIQ_RETRY; if (state->conn_state != VCHIQ_CONNSTATE_DISCONNECTED) status = queue_message(state, NULL, @@ -3538,9 +3583,9 @@ VCHIQ_STATUS_T vchiq_send_remote_use(struct vchiq_state *state) return status; } -VCHIQ_STATUS_T vchiq_send_remote_use_active(struct vchiq_state *state) +enum vchiq_status vchiq_send_remote_use_active(struct vchiq_state *state) { - VCHIQ_STATUS_T status = VCHIQ_RETRY; + enum vchiq_status status = VCHIQ_RETRY; if (state->conn_state != VCHIQ_CONNSTATE_DISCONNECTED) status = queue_message(state, NULL, @@ -3578,7 +3623,7 @@ void vchiq_log_dump_mem(const char *label, u32 addr, const void *void_mem, } *s++ = '\0'; - if ((label != NULL) && (*label != '\0')) + if (label && (*label != '\0')) vchiq_log_trace(VCHIQ_LOG_TRACE, "%s: %08x: %s", label, addr, line_buf); else |