Repository navigation
media: bcm2835-unicam: Correctly handle error states on stream on/off - #3984
Conversation
| unicam_disable(dev); | ||
| clk_disable_unprepare(dev->clock); | ||
| err_vpu_clock: | ||
| ret = clk_set_min_rate(dev->vpu_clock, 0); |
There was a problem hiding this comment.
ouch - that's subtle!
Good spot ;-)
|
This should really be two patches, but never mind. With the start_streaming fixed to return an error, does the framework actually call stop_streaming if VIDIOC_STREAMOFF is called multiple times? I don't think it will as https://elixir.bootlin.com/linux/latest/source/drivers/media/common/videobuf2/videobuf2-core.c#L1925 will block it. However isn't it easier to do a at the start of the function, rather than keeping our own internal state? We should never exit start_streaming without either succeeding, or having undone all changes. |
It does seem to go into stop_streaming() with the error return value fixed. I get the clock_disable_unprepare() errors thrown into the kernel logs.
Sure, I can make that change and push a new version. |
On a failure in start_streaming(), the error code would not propagate to the calling function on all conditions. This would cause the userland caller to not know of the failure. Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Turns out, this is not the case :) In This causes the internal vb2 state to think we are streaming, so the suggested test in |
|
Ah, that annoying second device node. Who thought that was a good idea?! ;-) |
Indeed. I'll push an update with the existing changes split into 2 patches. |
I'm with you there. I wish metadata travelled with/was associated with the buffer it's representing directly somehow. |
Tell me about it! |
clk_disable_unprepare() is called unconditionally in stop_streaming(). This is incorrect in the cases where start_streaming() fails, and unprepares all clocks as part of the failure cleanup. To avoid this, ensure that clk_disable_unprepare() is only called in stop_streaming() if the clocks are in a prepared state. Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
There was a problem hiding this comment.
Hrm, not quite used to github yet, I thought this was just on the single return bug fix patch, but it looks like here it's on both ;-)
Both look ok to me though I think.
Reviewed-by: Kieran Bingham kieran.bingham@ideasonboard.com
kernel: overlays: Add PCF85063 and PCF85063A to i2c-rtc kernel: configs: Add RTC_DRV_PCF85063=m kernel: ARM: dts: CM4 audio pins are not connected kernel: PCI: brcmstb: Advertise MSI-X support kernel: media: bcm2835-unicam: Clear clock state when stopping streaming See: raspberrypi/linux#3986 kernel: media: bcm2835-unicam: Correctly handle error states on stream on/off See: raspberrypi/linux#3984 kernel: media: i2c: imx219: Selection compliance fixes See: raspberrypi/linux#3983 kernel: drm/vc4: Correct DSI register definition See: raspberrypi/linux#3980 firmware: arm_dt: Handle parent interrupt controllers when masking firmware: config: Add cm4 and pi400 config section filters firmware: MMAL/IL/ISP component: Set the ISP boost frequency once on open firmware: sdcard: Remove legacy NOOBS support to support booting from primary partition 4 firmware: arm_loader: Move 2711 RAM to PCIe address 16GB firmware: video_decode: Add parameter to disable timestamp validation firmware: Imx477 camera tuning fixes See: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=291032#p1770287 See: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=291032&start=25#p1771066
kernel: overlays: Add PCF85063 and PCF85063A to i2c-rtc kernel: configs: Add RTC_DRV_PCF85063=m kernel: ARM: dts: CM4 audio pins are not connected kernel: PCI: brcmstb: Advertise MSI-X support kernel: media: bcm2835-unicam: Clear clock state when stopping streaming See: raspberrypi/linux#3986 kernel: media: bcm2835-unicam: Correctly handle error states on stream on/off See: raspberrypi/linux#3984 kernel: media: i2c: imx219: Selection compliance fixes See: raspberrypi/linux#3983 kernel: drm/vc4: Correct DSI register definition See: raspberrypi/linux#3980 firmware: arm_dt: Handle parent interrupt controllers when masking firmware: config: Add cm4 and pi400 config section filters firmware: MMAL/IL/ISP component: Set the ISP boost frequency once on open firmware: sdcard: Remove legacy NOOBS support to support booting from primary partition 4 firmware: arm_loader: Move 2711 RAM to PCIe address 16GB firmware: video_decode: Add parameter to disable timestamp validation firmware: Imx477 camera tuning fixes See: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=291032#p1770287 See: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=291032&start=25#p1771066
kernel: overlays: Add PCF85063 and PCF85063A to i2c-rtc kernel: configs: Add RTC_DRV_PCF85063=m kernel: ARM: dts: CM4 audio pins are not connected kernel: media: bcm2835-unicam: Clear clock state when stopping streaming See: raspberrypi/linux#3986 kernel: media: bcm2835-unicam: Correctly handle error states on stream on/off See: raspberrypi/linux#3984 kernel: media: i2c: imx219: Selection compliance fixes See: raspberrypi/linux#3983 firmware: arm_dt: Handle parent interrupt controllers when masking firmware: config: Add cm4 and pi400 config section filters firmware: MMAL/IL/ISP component: Set the ISP boost frequency once on open firmware: sdcard: Remove legacy NOOBS support to support booting from primary partition 4 firmware: arm_loader: Move 2711 RAM to PCIe address 16GB firmware: video_decode: Add parameter to disable timestamp validation firmware: Imx477 camera tuning fixes See: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=291032#p1770287 See: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=291032&start=25#p1771066
kernel: overlays: Add PCF85063 and PCF85063A to i2c-rtc kernel: configs: Add RTC_DRV_PCF85063=m kernel: ARM: dts: CM4 audio pins are not connected kernel: media: bcm2835-unicam: Clear clock state when stopping streaming See: raspberrypi/linux#3986 kernel: media: bcm2835-unicam: Correctly handle error states on stream on/off See: raspberrypi/linux#3984 kernel: media: i2c: imx219: Selection compliance fixes See: raspberrypi/linux#3983 firmware: arm_dt: Handle parent interrupt controllers when masking firmware: config: Add cm4 and pi400 config section filters firmware: MMAL/IL/ISP component: Set the ISP boost frequency once on open firmware: sdcard: Remove legacy NOOBS support to support booting from primary partition 4 firmware: arm_loader: Move 2711 RAM to PCIe address 16GB firmware: video_decode: Add parameter to disable timestamp validation firmware: Imx477 camera tuning fixes See: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=291032#p1770287 See: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=291032&start=25#p1771066
On a failure in start_streaming(), the error code would not propagate to
the calling function on all conditions. This would cause the userland
caller to not know of the failure.
Additionally, clk_disable_unprepare() was called unconditionally in
stop_streaming(). This is incorrect in the cases where start_streaming()
fails, and unprepares all clocks as part of the failure cleanup. Ensure
that clk_disable_unprepare() is only called in stop_streaming() if the
clocks are in a prepared state.
Signed-off-by: Naushir Patuck naush@raspberrypi.com