bulk_waiter->actual = 0;
bulk_waiter->bulk = NULL;
break;
- case VCHIQ_BULK_MODE_WAITING:
- bulk_waiter = userdata;
- bulk = bulk_waiter->bulk;
- goto waiting;
default:
goto error_exit;
}
state->id, service->localport, dir_char, queue->local_insert,
queue->remote_insert, queue->process);
-waiting:
vchiq_service_put(service);
- status = 0;
-
if (bulk_waiter) {
bulk_waiter->bulk = bulk;
if (wait_for_completion_interruptible(&bulk_waiter->event))
status = -EINVAL;
}
- return status;
+ return 0;
unlock_both_error_exit:
mutex_unlock(&state->slot_mutex);
return status;
}
+/*
+ * This function is called by VCHIQ ioctl interface and is interruptible.
+ * It may receive -EAGAIN to indicate that a signal has been received
+ * and the call should be retried after being returned to user context.
+ */
+int
+vchiq_bulk_xfer_waiting_interruptible(struct vchiq_instance *instance,
+ unsigned int handle, struct bulk_waiter *userdata)
+{
+ struct vchiq_service *service = find_service_by_handle(instance, handle);
+ struct bulk_waiter *bulk_waiter;
+ int status = -EINVAL;
+
+ if (!service)
+ return -EINVAL;
+
+ if (!userdata)
+ goto error_exit;
+
+ if (service->srvstate != VCHIQ_SRVSTATE_OPEN)
+ goto error_exit;
+
+ if (vchiq_check_service(service))
+ goto error_exit;
+
+ bulk_waiter = userdata;
+
+ vchiq_service_put(service);
+
+ status = 0;
+
+ if (wait_for_completion_interruptible(&bulk_waiter->event))
+ return -EAGAIN;
+ else if (bulk_waiter->actual == VCHIQ_BULK_ACTUAL_ABORTED)
+ return -EINVAL;
+
+ return status;
+
+error_exit:
+ vchiq_service_put(service);
+
+ return status;
+}
+
int
vchiq_queue_message(struct vchiq_instance *instance, unsigned int handle,
ssize_t (*copy_callback)(void *context, void *dest,
extern void
remote_event_pollall(struct vchiq_state *state);
+extern int
+vchiq_bulk_xfer_waiting_interruptible(struct vchiq_instance *instance,
+ unsigned int handle, struct bulk_waiter *userdata);
+
extern int
vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, void *offset,
void __user *uoffset, int size, void *userdata, enum vchiq_bulk_mode mode,
dev_dbg(service->state->dev, "arm: found bulk_waiter %pK for pid %d\n",
waiter, current->pid);
userdata = &waiter->bulk_waiter;
+
+ status = vchiq_bulk_xfer_waiting_interruptible(instance, args->handle, userdata);
+
+ goto bulk_transfer_handled;
} else {
userdata = args->userdata;
}
status = vchiq_bulk_transfer(instance, args->handle, NULL, args->data, args->size,
userdata, args->mode, dir);
+bulk_transfer_handled:
if (!waiter) {
ret = 0;
goto out;