staging: vchiq: Move copy callback handling into vchiq

All vchi users use the kernel variant of the copy callback. The only
user for the user space variant of the copy callback is in the ioctl
implementation. So move all this copying logic into vchiq, and expose a
new function that explicitly passes kernel messages.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20200527115400.31391-4-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Nicolas Saenz Julienne
2020-05-27 13:53:08 +02:00
committed by Greg Kroah-Hartman
parent 6620ce704e
commit a224f284d0
4 changed files with 22 additions and 33 deletions

View File

@@ -3147,6 +3147,12 @@ vchiq_queue_message(unsigned int handle,
return status;
}
enum vchiq_status vchiq_queue_kernel_message(unsigned int handle, void *context,
size_t size)
{
return vchiq_queue_message(handle, memcpy_copy_callback, context, size);
}
void
vchiq_release_message(unsigned int handle,
struct vchiq_header *header)

View File

@@ -587,6 +587,13 @@ lock_service(struct vchiq_service *service);
extern void
unlock_service(struct vchiq_service *service);
extern 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);
/* The following functions are called from vchiq_core, and external
** implementations must be provided. */

View File

@@ -105,12 +105,8 @@ extern enum vchiq_status vchiq_close_service(unsigned int service);
extern enum vchiq_status vchiq_remove_service(unsigned int service);
extern enum vchiq_status vchiq_use_service(unsigned int service);
extern enum vchiq_status vchiq_release_service(unsigned int service);
extern 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);
extern enum vchiq_status vchiq_queue_kernel_message(unsigned int handle,
void *context, size_t size);
extern void vchiq_release_message(unsigned int service,
struct vchiq_header *header);
extern enum vchiq_status vchiq_bulk_transmit(unsigned int service,

View File

@@ -99,20 +99,15 @@ EXPORT_SYMBOL(vchi_msg_remove);
*
***********************************************************/
static
int32_t vchi_msg_queue(struct vchi_service_handle *handle,
ssize_t (*copy_callback)(void *context, void *dest,
size_t offset, size_t maxsize),
void *context,
uint32_t data_size)
int32_t vchi_msg_queue(struct vchi_service_handle *handle, void *context,
uint32_t data_size)
{
struct shim_service *service = (struct shim_service *)handle;
enum vchiq_status status;
while (1) {
status = vchiq_queue_message(service->handle,
copy_callback,
context,
data_size);
status = vchiq_queue_kernel_message(service->handle, context,
data_size);
/*
* vchiq_queue_message() may return VCHIQ_RETRY, so we need to
@@ -128,25 +123,10 @@ int32_t vchi_msg_queue(struct vchi_service_handle *handle,
return vchiq_status_to_vchi(status);
}
static ssize_t
vchi_queue_kernel_message_callback(void *context,
void *dest,
size_t offset,
size_t maxsize)
int vchi_queue_kernel_message(struct vchi_service_handle *handle, void *data,
unsigned int size)
{
memcpy(dest, context + offset, maxsize);
return maxsize;
}
int
vchi_queue_kernel_message(struct vchi_service_handle *handle,
void *data,
unsigned int size)
{
return vchi_msg_queue(handle,
vchi_queue_kernel_message_callback,
data,
size);
return vchi_msg_queue(handle, data, size);
}
EXPORT_SYMBOL(vchi_queue_kernel_message);