Commit b2bbe3dc authored by Nicolas Saenz Julienne's avatar Nicolas Saenz Julienne Committed by Greg Kroah-Hartman
Browse files

staging: vchi: Get rid of vchi_bulk_queue_receive()



Its vchiq counterpart, vchiq_bulk_receive() is only used by vchi. We can
then merge both functions by moving vchi_bulk_queue_receive()'s retry
mechanism into vchiq_bulk_receive() and let services call the later.

Signed-off-by: default avatarNicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200629150945.10720-41-nsaenzjulienne@suse.de


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 76dbbe77
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -58,13 +58,6 @@ extern int32_t vchi_held_msg_release(unsigned handle, struct vchiq_header *messa
 * Global bulk API
 *****************************************************************************/

// Routine to prepare interface for a transfer from the other side
extern int32_t vchi_bulk_queue_receive(unsigned handle,
				       void *data_dst,
				       uint32_t data_size,
				       enum vchiq_bulk_mode mode,
				       void *transfer_handle);

// Routine to queue up data ready for transfer to the other (once they have signalled they are ready)
extern int32_t vchi_bulk_queue_transmit(unsigned handle,
					const void *data_src,
+27 −15
Original line number Diff line number Diff line
@@ -374,12 +374,13 @@ vchiq_bulk_transmit(unsigned int handle, const void *data,
}
EXPORT_SYMBOL(vchiq_bulk_transmit);

enum vchiq_status
vchiq_bulk_receive(unsigned int handle, void *data,
	unsigned int size, void *userdata, enum vchiq_bulk_mode mode)
enum vchiq_status vchiq_bulk_receive(unsigned int handle, void *data,
				     unsigned int size, void *userdata,
				     enum vchiq_bulk_mode mode)
{
	enum vchiq_status status;

	while (1) {
		switch (mode) {
		case VCHIQ_BULK_MODE_NOCALLBACK:
		case VCHIQ_BULK_MODE_CALLBACK:
@@ -394,6 +395,17 @@ vchiq_bulk_receive(unsigned int handle, void *data,
			return VCHIQ_ERROR;
		}

		/*
		 * vchiq_*_bulk_transfer() may return VCHIQ_RETRY, so we need
		 * to implement a retry mechanism since this function is
		 * supposed to block until queued
		 */
		if (status != VCHIQ_RETRY)
			break;

		msleep(1);
	}

	return status;
}
EXPORT_SYMBOL(vchiq_bulk_receive);
+0 −38
Original line number Diff line number Diff line
@@ -31,44 +31,6 @@ int vchi_queue_kernel_message(unsigned handle, void *data, unsigned int size)
}
EXPORT_SYMBOL(vchi_queue_kernel_message);

/***********************************************************
 * Name: vchi_bulk_queue_receive
 *
 * Arguments:  VCHI_BULK_HANDLE_T handle,
 *             void *data_dst,
 *             const uint32_t data_size,
 *             enum vchi_flags flags
 *             void *bulk_handle
 *
 * Description: Routine to setup a rcv buffer
 *
 * Returns: int32_t - success == 0
 *
 ***********************************************************/
int32_t vchi_bulk_queue_receive(unsigned handle, void *data_dst,
				uint32_t data_size, enum vchiq_bulk_mode mode,
				void *bulk_handle)
{
	enum vchiq_status status;

	while (1) {
		status = vchiq_bulk_receive(handle, data_dst, data_size,
					    bulk_handle, mode);
		/*
		 * vchiq_bulk_receive() may return VCHIQ_RETRY, so we need to
		 * implement a retry mechanism since this function is supposed
		 * to block until queued
		 */
		if (status != VCHIQ_RETRY)
			break;

		msleep(1);
	}

	return status;
}
EXPORT_SYMBOL(vchi_bulk_queue_receive);

/***********************************************************
 * Name: vchi_bulk_queue_transmit
 *
+10 −10
Original line number Diff line number Diff line
@@ -279,7 +279,7 @@ static void buffer_work_cb(struct work_struct *work)
 * VCHI will allow up to 4 bulk receives to be scheduled before blocking.
 * If we block in the service_callback context then we can't process the
 * VCHI_CALLBACK_BULK_RECEIVED message that would otherwise allow the blocked
 * vchi_bulk_queue_receive() call to complete.
 * vchiq_bulk_receive() call to complete.
 */
static void buffer_to_host_work_cb(struct work_struct *work)
{
@@ -295,19 +295,19 @@ static void buffer_to_host_work_cb(struct work_struct *work)
		len = 8;
	/* queue the bulk submission */
	vchi_service_use(instance->service_handle);
	ret = vchi_bulk_queue_receive(instance->service_handle,
	ret = vchiq_bulk_receive(instance->service_handle,
				 msg_context->u.bulk.buffer->buffer,
			         /* Actual receive needs to be a multiple
			          * of 4 bytes
			          */
			         (len + 3) & ~3,
				      VCHIQ_BULK_MODE_CALLBACK,
				      msg_context);
			         msg_context,
			         VCHIQ_BULK_MODE_CALLBACK);

	vchi_service_release(instance->service_handle);

	if (ret != 0)
		pr_err("%s: ctx: %p, vchi_bulk_queue_receive failed %d\n",
		pr_err("%s: ctx: %p, vchiq_bulk_receive failed %d\n",
		       __func__, msg_context, ret);
}