aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
diff options
context:
space:
mode:
authorDave Stevenson <dave.stevenson@raspberrypi.org>2018-05-10 12:42:08 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-11 12:02:05 +0200
commit96b7e81ab6b74e7cefdac0d7a90b746ef7f8597d (patch)
tree62ed9e01ae88efb21de635e3fcfb2115c749c980 /drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
parentstaging: bcm2835-camera: Skip ISP pass to eliminate padding. (diff)
downloadlinux-dev-96b7e81ab6b74e7cefdac0d7a90b746ef7f8597d.tar.xz
linux-dev-96b7e81ab6b74e7cefdac0d7a90b746ef7f8597d.zip
staging: bcm2835-camera: Allocate context once per buffer
The struct mmal_msg_context was being allocated for every message being sent to the VPU, and freed when it came back. Whilst that is required behaviour for some messages (mainly the synchronous ones), it is wasteful for the video buffers that make up the majority of the traffic. Add to the buffer_init/cleanup hooks that it allocates/frees the msg_context required. v2: changes by anholt from the downstream tree: clean up indentation, pass an error value through, forward-declare the struct so we have less void * Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c')
-rw-r--r--drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
index a91ef6ea29ce..037c68b83df9 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
@@ -321,8 +321,6 @@ static void buffer_work_cb(struct work_struct *work)
msg_context->u.bulk.dts,
msg_context->u.bulk.pts);
- /* release message context */
- release_msg_context(msg_context);
}
/* enqueue a bulk receive for a given message context */
@@ -503,11 +501,13 @@ buffer_from_host(struct vchiq_mmal_instance *instance,
return -EINTR;
/* get context */
- msg_context = get_msg_context(instance);
- if (IS_ERR(msg_context)) {
- ret = PTR_ERR(msg_context);
+ if (!buf->msg_context) {
+ pr_err("%s: msg_context not allocated, buf %p\n", __func__,
+ buf);
+ ret = -EINVAL;
goto unlock;
}
+ msg_context = buf->msg_context;
/* store bulk message context for when data arrives */
msg_context->u.bulk.instance = instance;
@@ -557,11 +557,6 @@ buffer_from_host(struct vchiq_mmal_instance *instance,
sizeof(struct mmal_msg_header) +
sizeof(m.u.buffer_from_host));
- if (ret != 0) {
- release_msg_context(msg_context);
- /* todo: is this correct error value? */
- }
-
vchi_service_release(instance->handle);
unlock:
@@ -1775,6 +1770,29 @@ int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
return 0;
}
+int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance,
+ struct mmal_buffer *buf)
+{
+ struct mmal_msg_context *msg_context = get_msg_context(instance);
+
+ if (IS_ERR(msg_context))
+ return (PTR_ERR(msg_context));
+
+ buf->msg_context = msg_context;
+ return 0;
+}
+
+int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf)
+{
+ struct mmal_msg_context *msg_context = buf->msg_context;
+
+ if (msg_context)
+ release_msg_context(msg_context);
+ buf->msg_context = NULL;
+
+ return 0;
+}
+
/* Initialise a mmal component and its ports
*
*/