mirror of
https://github.com/torvalds/linux.git
synced 2024-11-27 06:31:52 +00:00
staging: bcm2835-camera: Ensure all buffers are returned on disable
With the recent change to match MMAL and V4L2 buffers there
is a need to wait for all MMAL buffers to be returned during
stop_streaming.
Fixes: 9384167070
("staging: bcm2835-camera: Remove V4L2/MMAL buffer remapping")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
fcdd047e8a
commit
70ec64ccda
@ -584,6 +584,7 @@ static void stop_streaming(struct vb2_queue *vq)
|
|||||||
int ret;
|
int ret;
|
||||||
unsigned long timeout;
|
unsigned long timeout;
|
||||||
struct bm2835_mmal_dev *dev = vb2_get_drv_priv(vq);
|
struct bm2835_mmal_dev *dev = vb2_get_drv_priv(vq);
|
||||||
|
struct vchiq_mmal_port *port = dev->capture.port;
|
||||||
|
|
||||||
v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p\n",
|
v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p\n",
|
||||||
__func__, dev);
|
__func__, dev);
|
||||||
@ -607,12 +608,6 @@ static void stop_streaming(struct vb2_queue *vq)
|
|||||||
&dev->capture.frame_count,
|
&dev->capture.frame_count,
|
||||||
sizeof(dev->capture.frame_count));
|
sizeof(dev->capture.frame_count));
|
||||||
|
|
||||||
/* wait for last frame to complete */
|
|
||||||
timeout = wait_for_completion_timeout(&dev->capture.frame_cmplt, HZ);
|
|
||||||
if (timeout == 0)
|
|
||||||
v4l2_err(&dev->v4l2_dev,
|
|
||||||
"timed out waiting for frame completion\n");
|
|
||||||
|
|
||||||
v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
|
v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
|
||||||
"disabling connection\n");
|
"disabling connection\n");
|
||||||
|
|
||||||
@ -627,6 +622,21 @@ static void stop_streaming(struct vb2_queue *vq)
|
|||||||
ret);
|
ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* wait for all buffers to be returned */
|
||||||
|
while (atomic_read(&port->buffers_with_vpu)) {
|
||||||
|
v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
|
||||||
|
"%s: Waiting for buffers to be returned - %d outstanding\n",
|
||||||
|
__func__, atomic_read(&port->buffers_with_vpu));
|
||||||
|
timeout = wait_for_completion_timeout(&dev->capture.frame_cmplt,
|
||||||
|
HZ);
|
||||||
|
if (timeout == 0) {
|
||||||
|
v4l2_err(&dev->v4l2_dev, "%s: Timeout waiting for buffers to be returned - %d outstanding\n",
|
||||||
|
__func__,
|
||||||
|
atomic_read(&port->buffers_with_vpu));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (disable_camera(dev) < 0)
|
if (disable_camera(dev) < 0)
|
||||||
v4l2_err(&dev->v4l2_dev, "Failed to disable camera\n");
|
v4l2_err(&dev->v4l2_dev, "Failed to disable camera\n");
|
||||||
}
|
}
|
||||||
|
@ -246,6 +246,8 @@ static void buffer_work_cb(struct work_struct *work)
|
|||||||
struct mmal_msg_context *msg_context =
|
struct mmal_msg_context *msg_context =
|
||||||
container_of(work, struct mmal_msg_context, u.bulk.work);
|
container_of(work, struct mmal_msg_context, u.bulk.work);
|
||||||
|
|
||||||
|
atomic_dec(&msg_context->u.bulk.port->buffers_with_vpu);
|
||||||
|
|
||||||
msg_context->u.bulk.port->buffer_cb(msg_context->u.bulk.instance,
|
msg_context->u.bulk.port->buffer_cb(msg_context->u.bulk.instance,
|
||||||
msg_context->u.bulk.port,
|
msg_context->u.bulk.port,
|
||||||
msg_context->u.bulk.status,
|
msg_context->u.bulk.status,
|
||||||
@ -389,6 +391,8 @@ buffer_from_host(struct vchiq_mmal_instance *instance,
|
|||||||
INIT_WORK(&msg_context->u.bulk.buffer_to_host_work,
|
INIT_WORK(&msg_context->u.bulk.buffer_to_host_work,
|
||||||
buffer_to_host_work_cb);
|
buffer_to_host_work_cb);
|
||||||
|
|
||||||
|
atomic_inc(&port->buffers_with_vpu);
|
||||||
|
|
||||||
/* prep the buffer from host message */
|
/* prep the buffer from host message */
|
||||||
memset(&m, 0xbc, sizeof(m)); /* just to make debug clearer */
|
memset(&m, 0xbc, sizeof(m)); /* just to make debug clearer */
|
||||||
|
|
||||||
|
@ -72,6 +72,9 @@ struct vchiq_mmal_port {
|
|||||||
struct list_head buffers;
|
struct list_head buffers;
|
||||||
/* lock to serialise adding and removing buffers from list */
|
/* lock to serialise adding and removing buffers from list */
|
||||||
spinlock_t slock;
|
spinlock_t slock;
|
||||||
|
|
||||||
|
/* Count of buffers the VPU has yet to return */
|
||||||
|
atomic_t buffers_with_vpu;
|
||||||
/* callback on buffer completion */
|
/* callback on buffer completion */
|
||||||
vchiq_mmal_buffer_cb buffer_cb;
|
vchiq_mmal_buffer_cb buffer_cb;
|
||||||
/* callback context */
|
/* callback context */
|
||||||
|
Loading…
Reference in New Issue
Block a user