You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BCM2835-V4L2 triggers warning of bad buffer handling on stop_streaming. #817
From raspberrypi/firmware#347 the V4L2 driver is tripping a warning in V4L2-core of buffers not being returned on stop_streaming().
New issue to fix the warning, as the original issue in mjpeg-streamer turned out to be a client issue.
/*
* If you see this warning, then the driver isn't cleaning up properly
* in stop_streaming(). See the stop_streaming() documentation in
* videobuf2-core.h for more information how buffers should be returned
* to vb2 in stop_streaming().
*/
The docs for stop_streaming then say
* @stop_streaming: called when 'streaming' state must be disabled; driver
* should stop any DMA transactions or wait until they
* finish and give back all buffers it got from buf_queue()
* callback by calling @vb2_buffer_done() with either
* VB2_BUF_STATE_DONE or VB2_BUF_STATE_ERROR; may use
* vb2_wait_for_all_buffers() function
Somehow it seems there is a case where buffers aren't being returned to the core when stopping.
Yes, more creating the issue so I don't forget. I'll also be adding it to my own list of jobs to look into.
I did have a quick look before but couldn't see an obvious reason as all the buffers should be returned on flush, and on being returned from the GPU they should be released back to V4L2 core. Some extra logging in the core might show up some more information.
It'll happen on all Pi's with all Pi cameras! "Me too"s aren't going to help on this one.
It is only a warning which the framework then cleans up after, and this issue was only logged so that I don't forget to look into it (I'm one the ex-Broadcom people, and originally wrote a large chunk of the V4L2 driver).
This issue is solely linked to the error message [74093.661426] WARNING: CPU: 0 PID: 27775 at drivers/media/v4l2-core/videobuf2-core.c:2135 __vb2_queue_cancel+0xf4/0x160 [videobuf2_core]()
That IS only a warning.
If you have an issue with one particular app then please either raise a new issue, or post on the forums as more people who may be able to help read those. You'll need to provide LOTS more detail as to how you are configuring MotionEye - resolution, encoding, and framerate as an absolute minimum.
I know the reason behind the warning now - only waiting for one buffer to come back, rather than all. I haven't had a chance to fix it yet. Probably need a counting semaphore (as MMAL does normally) rather than just waiting on a completion.
I know that your problem is not related to this issue, which is just there as a reminder to me to look into this warning. (The V4L2 framework got updated between 3.12 and 3.18, and now does a sanity check on all buffers being returned. The Pi driver currently doesn't do that)
(a) Look at the first post on http://www.raspberrypi.org/forums/viewtopic.php?f=43&t=62364 which lists a few simple steps for exercising the V4L2 driver (the v4l2-ctl commands). Do those work for you? If yes, then it isn't a generic V4L2 driver issue. (If no, then I'd suspect your camera module to be at fault)
(b) Have you checked your sensor works using Raspistill or raspivid?
(c) It seems MotionEye is referenced heavily from http://www.raspberrypi.org/forums/viewtopic.php?f=43&t=83369 Have you read that thread?
(d) Post on the forums asking for assistance.
(e) If you have a test case that you can demonstrably show that the kernel is at fault, then create a new issue here with full details for reproducing the issue.
This is not a good place to post if you want help triaging an issue.
I know - I still haven't looked at it in detail (looking after small children and having to go to work gets in the way).
Multiple buffers are submitted to the GPU. On stop, we flush the component, but only wait for one buffer to be returned before declaring "job done" and returning. If the GPU had more than one buffer, then they will all have been flushed and returned to the driver, but not released back to videobuf2 so it objects that nominally buffers are still in flight.
Actually by the looks of it, even if only one buffer is with the GPU, getting that buffer back signals the completion but doesn't return the buffer to videobuf2 (https://github.com/raspberrypi/linux/blob/rpi-4.0.y/drivers/media/platform/bcm2835/bcm2835-camera.c#L335) - a call to vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); from there may be sufficient to shut the warning up in a fair percentage of cases.
In fact that may be all that is required (mmal-vchiq.c function port_disable() is waiting for all callbacks to have been made before completing, therefore buffer_cb should have been called the necessary number of times to make videobuf2 happy.
It is only a warning (the GPU will have flushed all buffers and therefore won't be writing to them), so annoying rather than critical.
Seems to have been a one liner fix required - it is that vb2_buffer_done call when length!=0 but we aren't capturing.
Just pushing to my account (stupid slow broadband!) and will create a PR in the morning.
Activity
popcornmix commentedon Feb 9, 2015
Is this something you can investigate?
6by9 commentedon Feb 9, 2015
Yes, more creating the issue so I don't forget. I'll also be adding it to my own list of jobs to look into.
I did have a quick look before but couldn't see an obvious reason as all the buffers should be returned on flush, and on being returned from the GPU they should be released back to V4L2 core. Some extra logging in the core might show up some more information.
brguy commentedon Feb 21, 2015
I have the same issue here using Raspian and a Pi NoIR camera.
6by9 commentedon Feb 21, 2015
It'll happen on all Pi's with all Pi cameras! "Me too"s aren't going to help on this one.
It is only a warning which the framework then cleans up after, and this issue was only logged so that I don't forget to look into it (I'm one the ex-Broadcom people, and originally wrote a large chunk of the V4L2 driver).
melroy89 commentedon Mar 16, 2015
I'm using MotionEye with the Raspberry Pi Camera I got simular issues:
Mar 16 01:37:53 raspcam kernel: [ 120.314824] bcm2835-v4l2: error 0 waiting for frame completion
Mar 16 01:38:29 raspcam kernel: [ 156.344834] bcm2835-v4l2: error 0 waiting for frame completion
Mar 16 01:40:24 raspcam kernel: [ 271.934879] bcm2835-v4l2: error 0 waiting for frame completion
Mar 16 01:41:00 raspcam kernel: [ 307.464841] bcm2835-v4l2: error 0 waiting for frame completion
Mar 16 01:43:25 raspcam kernel: [ 452.964878] bcm2835-v4l2: error 0 waiting for frame completion
The live stream gets disconnect after 20 sec. It is NOT just a warning. Please help me!
6by9 commentedon Mar 16, 2015
This issue is solely linked to the error message
[74093.661426] WARNING: CPU: 0 PID: 27775 at drivers/media/v4l2-core/videobuf2-core.c:2135 __vb2_queue_cancel+0xf4/0x160 [videobuf2_core]()That IS only a warning.
If you have an issue with one particular app then please either raise a new issue, or post on the forums as more people who may be able to help read those. You'll need to provide LOTS more detail as to how you are configuring MotionEye - resolution, encoding, and framerate as an absolute minimum.
6by9 commentedon Mar 16, 2015
I know the reason behind the warning now - only waiting for one buffer to come back, rather than all. I haven't had a chance to fix it yet. Probably need a counting semaphore (as MMAL does normally) rather than just waiting on a completion.
melroy89 commentedon Mar 17, 2015
You think my issue is related to MotionEye? Uhm..
6by9 commentedon Mar 17, 2015
I know that your problem is not related to this issue, which is just there as a reminder to me to look into this warning. (The V4L2 framework got updated between 3.12 and 3.18, and now does a sanity check on all buffers being returned. The Pi driver currently doesn't do that)
(a) Look at the first post on http://www.raspberrypi.org/forums/viewtopic.php?f=43&t=62364 which lists a few simple steps for exercising the V4L2 driver (the
v4l2-ctlcommands). Do those work for you? If yes, then it isn't a generic V4L2 driver issue. (If no, then I'd suspect your camera module to be at fault)(b) Have you checked your sensor works using Raspistill or raspivid?
(c) It seems MotionEye is referenced heavily from http://www.raspberrypi.org/forums/viewtopic.php?f=43&t=83369 Have you read that thread?
(d) Post on the forums asking for assistance.
(e) If you have a test case that you can demonstrably show that the kernel is at fault, then create a new issue here with full details for reproducing the issue.
This is not a good place to post if you want help triaging an issue.
melroy89 commentedon Mar 18, 2015
Thanks for your reply 6by9.
pelwell commentedon Jul 14, 2015
Ping @6by9 - this is still an issue.
6by9 commentedon Jul 14, 2015
I know - I still haven't looked at it in detail (looking after small children and having to go to work gets in the way).
Multiple buffers are submitted to the GPU. On stop, we flush the component, but only wait for one buffer to be returned before declaring "job done" and returning. If the GPU had more than one buffer, then they will all have been flushed and returned to the driver, but not released back to videobuf2 so it objects that nominally buffers are still in flight.
Actually by the looks of it, even if only one buffer is with the GPU, getting that buffer back signals the completion but doesn't return the buffer to videobuf2 (https://github.com/raspberrypi/linux/blob/rpi-4.0.y/drivers/media/platform/bcm2835/bcm2835-camera.c#L335) - a call to
vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);from there may be sufficient to shut the warning up in a fair percentage of cases.In fact that may be all that is required (mmal-vchiq.c function
port_disable()is waiting for all callbacks to have been made before completing, thereforebuffer_cbshould have been called the necessary number of times to make videobuf2 happy.It is only a warning (the GPU will have flushed all buffers and therefore won't be writing to them), so annoying rather than critical.
6by9 commentedon Jul 15, 2015
Seems to have been a one liner fix required - it is that vb2_buffer_done call when length!=0 but we aren't capturing.
Just pushing to my account (stupid slow broadband!) and will create a PR in the morning.
BCM2835-V4L2: Return buffers to videobuf2 on shutdown
BCM2835-V4L2: Return buffers to videobuf2 on shutdown
214 remaining items
bcm2835: add v4l2 camera device
bcm2835: add v4l2 camera device
bcm2835: add v4l2 camera device
bcm2835: add v4l2 camera device
bcm2835: add v4l2 camera device
bcm2835: add v4l2 camera device
bcm2835: add v4l2 camera device
bcm2835: add v4l2 camera device
bcm2835: add v4l2 camera device
bcm2835: add v4l2 camera device
bcm2835: add v4l2 camera device
rpi_1049_f2d51efbeac118fa3c386f34cab3d7f2be7d5261
bcm2835: add v4l2 camera device
rpi_1049_f2d51efbeac118fa3c386f34cab3d7f2be7d5261
bcm2835: add v4l2 camera device