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 | 106 |
1 files changed, 31 insertions, 75 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 0c387b6473a5..183f5cf887e0 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -395,13 +395,21 @@ remote_event_create(wait_queue_head_t *wq, struct remote_event *event) init_waitqueue_head(wq); } +/* + * All the event waiting routines in VCHIQ used a custom semaphore + * implementation that filtered most signals. This achieved a behaviour similar + * to the "killable" family of functions. While cleaning up this code all the + * routines where switched to the "interruptible" family of functions, as the + * former was deemed unjustified and the use "killable" set all VCHIQ's + * threads in D state. + */ static inline int remote_event_wait(wait_queue_head_t *wq, struct remote_event *event) { if (!event->fired) { event->armed = 1; dsb(sy); - if (wait_event_killable(*wq, event->fired)) { + if (wait_event_interruptible(*wq, event->fired)) { event->armed = 0; return 0; } @@ -560,7 +568,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_killable( + (wait_for_completion_interruptible( &state->slot_available_event))) return NULL; /* No space available */ } @@ -792,7 +800,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, WARN_ON(!(stride <= VCHIQ_SLOT_SIZE)); if (!(flags & QMFLAGS_NO_MUTEX_LOCK) && - (mutex_lock_killable(&state->slot_mutex) != 0)) + mutex_lock_killable(&state->slot_mutex)) return VCHIQ_RETRY; if (type == VCHIQ_MSG_DATA) { @@ -804,8 +812,8 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, return VCHIQ_ERROR; } - WARN_ON((flags & (QMFLAGS_NO_MUTEX_LOCK | - QMFLAGS_NO_MUTEX_UNLOCK)) != 0); + WARN_ON(flags & (QMFLAGS_NO_MUTEX_LOCK | + QMFLAGS_NO_MUTEX_UNLOCK)); if (service->closing) { /* The service has been closed */ @@ -830,7 +838,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, spin_unlock("a_spinlock); mutex_unlock(&state->slot_mutex); - if (wait_for_completion_killable( + if (wait_for_completion_interruptible( &state->data_quota_event)) return VCHIQ_RETRY; @@ -861,12 +869,12 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, service_quota->slot_use_count); VCHIQ_SERVICE_STATS_INC(service, quota_stalls); mutex_unlock(&state->slot_mutex); - if (wait_for_completion_killable( + if (wait_for_completion_interruptible( &service_quota->quota_event)) return VCHIQ_RETRY; if (service->closing) return VCHIQ_ERROR; - if (mutex_lock_killable(&state->slot_mutex) != 0) + if (mutex_lock_killable(&state->slot_mutex)) return VCHIQ_RETRY; if (service->srvstate != VCHIQ_SRVSTATE_OPEN) { /* The service has been closed */ @@ -904,8 +912,8 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, header, size, VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid)); - WARN_ON((flags & (QMFLAGS_NO_MUTEX_LOCK | - QMFLAGS_NO_MUTEX_UNLOCK)) != 0); + WARN_ON(flags & (QMFLAGS_NO_MUTEX_LOCK | + QMFLAGS_NO_MUTEX_UNLOCK)); callback_result = copy_message_data(copy_callback, context, @@ -1032,8 +1040,8 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, local = state->local; - if ((VCHIQ_MSG_TYPE(msgid) != VCHIQ_MSG_RESUME) && - (mutex_lock_killable(&state->sync_mutex) != 0)) + if (VCHIQ_MSG_TYPE(msgid) != VCHIQ_MSG_RESUME && + mutex_lock_killable(&state->sync_mutex)) return VCHIQ_RETRY; remote_event_wait(&state->sync_release_event, &local->sync_release); @@ -2428,7 +2436,7 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id) QMFLAGS_IS_BLOCKING); if (status == VCHIQ_SUCCESS) { /* Wait for the ACK/NAK */ - if (wait_for_completion_killable(&service->remove_event)) { + if (wait_for_completion_interruptible(&service->remove_event)) { status = VCHIQ_RETRY; vchiq_release_service_internal(service); } else if ((service->srvstate != VCHIQ_SRVSTATE_OPEN) && @@ -2514,7 +2522,7 @@ do_abort_bulks(struct vchiq_service *service) VCHIQ_STATUS_T status; /* Abort any outstanding bulk transfers */ - if (mutex_lock_killable(&service->bulk_mutex) != 0) + if (mutex_lock_killable(&service->bulk_mutex)) return 0; abort_outstanding_bulks(service, &service->bulk_tx); abort_outstanding_bulks(service, &service->bulk_rx); @@ -2795,7 +2803,7 @@ vchiq_connect_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) } if (state->conn_state == VCHIQ_CONNSTATE_CONNECTING) { - if (wait_for_completion_killable(&state->connect)) + if (wait_for_completion_interruptible(&state->connect)) return VCHIQ_RETRY; vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); @@ -2823,45 +2831,6 @@ vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) } VCHIQ_STATUS_T -vchiq_pause_internal(struct vchiq_state *state) -{ - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; - - switch (state->conn_state) { - case VCHIQ_CONNSTATE_CONNECTED: - /* Request a pause */ - vchiq_set_conn_state(state, VCHIQ_CONNSTATE_PAUSING); - request_poll(state, NULL, 0); - break; - default: - vchiq_log_error(vchiq_core_log_level, - "%s in state %s\n", - __func__, conn_state_names[state->conn_state]); - status = VCHIQ_ERROR; - VCHIQ_STATS_INC(state, error_count); - break; - } - - return status; -} - -VCHIQ_STATUS_T -vchiq_resume_internal(struct vchiq_state *state) -{ - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; - - if (state->conn_state == VCHIQ_CONNSTATE_PAUSED) { - vchiq_set_conn_state(state, VCHIQ_CONNSTATE_RESUMING); - request_poll(state, NULL, 0); - } else { - status = VCHIQ_ERROR; - VCHIQ_STATS_INC(state, error_count); - } - - return status; -} - -VCHIQ_STATUS_T vchiq_close_service(VCHIQ_SERVICE_HANDLE_T handle) { /* Unregister the service */ @@ -2894,7 +2863,7 @@ vchiq_close_service(VCHIQ_SERVICE_HANDLE_T handle) } while (1) { - if (wait_for_completion_killable(&service->remove_event)) { + if (wait_for_completion_interruptible(&service->remove_event)) { status = VCHIQ_RETRY; break; } @@ -2955,7 +2924,7 @@ vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) request_poll(service->state, service, VCHIQ_POLL_REMOVE); } while (1) { - if (wait_for_completion_killable(&service->remove_event)) { + if (wait_for_completion_interruptible(&service->remove_event)) { status = VCHIQ_RETRY; break; } @@ -3029,7 +2998,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, queue = (dir == VCHIQ_BULK_TRANSMIT) ? &service->bulk_tx : &service->bulk_rx; - if (mutex_lock_killable(&service->bulk_mutex) != 0) { + if (mutex_lock_killable(&service->bulk_mutex)) { status = VCHIQ_RETRY; goto error_exit; } @@ -3038,13 +3007,12 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, VCHIQ_SERVICE_STATS_INC(service, bulk_stalls); do { mutex_unlock(&service->bulk_mutex); - if (wait_for_completion_killable( + if (wait_for_completion_interruptible( &service->bulk_remove_event)) { status = VCHIQ_RETRY; goto error_exit; } - if (mutex_lock_killable(&service->bulk_mutex) - != 0) { + if (mutex_lock_killable(&service->bulk_mutex)) { status = VCHIQ_RETRY; goto error_exit; } @@ -3072,7 +3040,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, /* The slot mutex must be held when the service is being closed, so claim it here to ensure that isn't happening */ - if (mutex_lock_killable(&state->slot_mutex) != 0) { + if (mutex_lock_killable(&state->slot_mutex)) { status = VCHIQ_RETRY; goto cancel_bulk_error_exit; } @@ -3093,9 +3061,8 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, QMFLAGS_IS_BLOCKING | QMFLAGS_NO_MUTEX_LOCK | QMFLAGS_NO_MUTEX_UNLOCK); - if (status != VCHIQ_SUCCESS) { + if (status != VCHIQ_SUCCESS) goto unlock_both_error_exit; - } queue->local_insert++; @@ -3115,7 +3082,7 @@ waiting: if (bulk_waiter) { bulk_waiter->bulk = bulk; - if (wait_for_completion_killable(&bulk_waiter->event)) + if (wait_for_completion_interruptible(&bulk_waiter->event)) status = VCHIQ_RETRY; else if (bulk_waiter->actual == VCHIQ_BULK_ACTUAL_ABORTED) status = VCHIQ_ERROR; @@ -3571,17 +3538,6 @@ VCHIQ_STATUS_T vchiq_send_remote_use(struct vchiq_state *state) return status; } -VCHIQ_STATUS_T vchiq_send_remote_release(struct vchiq_state *state) -{ - VCHIQ_STATUS_T status = VCHIQ_RETRY; - - if (state->conn_state != VCHIQ_CONNSTATE_DISCONNECTED) - status = queue_message(state, NULL, - VCHIQ_MAKE_MSG(VCHIQ_MSG_REMOTE_RELEASE, 0, 0), - NULL, NULL, 0, 0); - return status; -} - VCHIQ_STATUS_T vchiq_send_remote_use_active(struct vchiq_state *state) { VCHIQ_STATUS_T status = VCHIQ_RETRY; |