{"action":"created","issue":{"url":"https://api.github.com/repos/raspberrypi/linux/issues/817","labels_url":"https://api.github.com/repos/raspberrypi/linux/issues/817/labels{/name}","comments_url":"https://api.github.com/repos/raspberrypi/linux/issues/817/comments","events_url":"https://api.github.com/repos/raspberrypi/linux/issues/817/events","html_url":"https://github.com/raspberrypi/linux/issues/817","id":57026493,"number":817,"title":"BCM2835-V4L2 triggers warning of bad buffer handling on stop_streaming.","user":{"login":"6by9","id":5822349,"avatar_url":"https://avatars.githubusercontent.com/u/5822349?v=3","gravatar_id":"","url":"https://api.github.com/users/6by9","html_url":"https://github.com/6by9","followers_url":"https://api.github.com/users/6by9/followers","following_url":"https://api.github.com/users/6by9/following{/other_user}","gists_url":"https://api.github.com/users/6by9/gists{/gist_id}","starred_url":"https://api.github.com/users/6by9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/6by9/subscriptions","organizations_url":"https://api.github.com/users/6by9/orgs","repos_url":"https://api.github.com/users/6by9/repos","events_url":"https://api.github.com/users/6by9/events{/privacy}","received_events_url":"https://api.github.com/users/6by9/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-02-09T12:50:59Z","updated_at":"2015-07-14T14:10:10Z","closed_at":null,"body":"From https://github.com/raspberrypi/firmware/issues/347 the V4L2 driver is tripping a warning in V4L2-core of buffers not being returned on stop_streaming().\r\nNew issue to fix the warning, as the original issue in mjpeg-streamer turned out to be a client issue. \r\n\r\nhttps://github.com/raspberrypi/linux/blob/rpi-3.18.y/drivers/media/v4l2-core/videobuf2-core.c#L2135\r\n```\r\n    /*\r\n    * If you see this warning, then the driver isn't cleaning up properly\r\n    * in stop_streaming(). See the stop_streaming() documentation in\r\n    * videobuf2-core.h for more information how buffers should be returned\r\n    * to vb2 in stop_streaming().\r\n    */\r\n```\r\nThe docs for stop_streaming then say\r\n```\r\n    * @stop_streaming: called when 'streaming' state must be disabled; driver\r\n    * should stop any DMA transactions or wait until they\r\n    * finish and give back all buffers it got from buf_queue()\r\n    * callback by calling @vb2_buffer_done() with either\r\n    * VB2_BUF_STATE_DONE or VB2_BUF_STATE_ERROR; may use\r\n    * vb2_wait_for_all_buffers() function\r\n```\r\nSomehow it seems there is a case where buffers aren't being returned to the core when stopping."},"comment":{"url":"https://api.github.com/repos/raspberrypi/linux/issues/comments/121249227","html_url":"https://github.com/raspberrypi/linux/issues/817#issuecomment-121249227","issue_url":"https://api.github.com/repos/raspberrypi/linux/issues/817","id":121249227,"user":{"login":"6by9","id":5822349,"avatar_url":"https://avatars.githubusercontent.com/u/5822349?v=3","gravatar_id":"","url":"https://api.github.com/users/6by9","html_url":"https://github.com/6by9","followers_url":"https://api.github.com/users/6by9/followers","following_url":"https://api.github.com/users/6by9/following{/other_user}","gists_url":"https://api.github.com/users/6by9/gists{/gist_id}","starred_url":"https://api.github.com/users/6by9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/6by9/subscriptions","organizations_url":"https://api.github.com/users/6by9/orgs","repos_url":"https://api.github.com/users/6by9/repos","events_url":"https://api.github.com/users/6by9/events{/privacy}","received_events_url":"https://api.github.com/users/6by9/received_events","type":"User","site_admin":false},"created_at":"2015-07-14T14:10:10Z","updated_at":"2015-07-14T14:10:10Z","body":"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).\r\n\r\nMultiple 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.\r\n\r\nActually 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.\r\nIn 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.\r\n\r\nIt is only a warning (the GPU will have flushed all buffers and therefore won't be writing to them), so annoying rather than critical."}}