Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

media: bcm2835-unicam: Fix bug in buffer swapping logic #4189

Merged
merged 1 commit into from
Mar 5, 2021

Conversation

naushir
Copy link
Contributor

@naushir naushir commented Mar 5, 2021

If multiple sets of interrupts occur simultaneously, it may be unsafe
to swap buffers, as the hardware may already be re-using the current
buffers. In such cases, avoid swapping buffers, and wait for the next
opportunity at the Frame End interrupt to signal completion.

Additionally, check the packet compare status when watching for frame
end for buffers swaps, as this could also signify a frame end event.

Signed-off-by: Naushir Patuck [email protected]

If multiple sets of interrupts occur simultaneously, it may be unsafe
to swap buffers, as the hardware may already be re-using the current
buffers. In such cases, avoid swapping buffers, and wait for the next
opportunity at the Frame End interrupt to signal completion.

Additionally, check the packet compare status when watching for frame
end for buffers swaps, as this could also signify a frame end event.

Signed-off-by: Naushir Patuck <[email protected]>
@naushir
Copy link
Contributor Author

naushir commented Mar 5, 2021

@mdevaev and @JakubVanek here is a candidate fix for #4128.

Please let me know if you have any issues with this fix.

@naushir
Copy link
Contributor Author

naushir commented Mar 5, 2021

Attached as a patch file for your convenience.

0001-media-bcm2835-unicam-Fix-bug-in-buffer-swapping-logi.zip

@pelwell
Copy link
Contributor

pelwell commented Mar 5, 2021

FYI, clicking on any commit and adding .patch to the URL gets you the patch.

@naushir
Copy link
Contributor Author

naushir commented Mar 5, 2021

FYI, clicking on any commit and adding .patch to the URL gets you the patch.

Useful shortcut, thanks!

@mdevaev
Copy link
Contributor

mdevaev commented Mar 5, 2021

Testing...

@JakubVanek
Copy link
Contributor

It looks good here - with this patch I can't reproduce any of the problems using JPEG or H264 modes of ustreamer. Before applying this, the NULL dereference occurred the second time I plugged in the cable. Thank you!

@mdevaev
Copy link
Contributor

mdevaev commented Mar 5, 2021

I don't see the problem anymore either. Apparently this is fixed. Thanks!

@naushir
Copy link
Contributor Author

naushir commented Mar 5, 2021

Thanks!

@6by9 this looks like it has fixed this problem.

@6by9
Copy link
Contributor

6by9 commented Mar 5, 2021

Your commit text would be frowned upon as it describes two things.

fe is a touch cryptic to the casual reader.

But I'm happy enough with it.

@pelwell pelwell merged commit c1cfa73 into raspberrypi:rpi-5.10.y Mar 5, 2021
@naushir naushir deleted the unicam_fix branch March 6, 2021 09:29
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Mar 15, 2021
kernel: drm/vc4: crtc: Reduce PV fifo threshold on hvs4
See: raspberrypi/linux#4207

kernel: vc4/drm: Adjustments to hdmi audio dma to reduce glitches
See: raspberrypi/linux#4208

kernel: overlays: gpio-led: new overlay
See: raspberrypi/linux#4206

kernel: bcm2835-codec tweaks
See: raspberrypi/linux#4113

kernel: Assign crypto aliases to different AES implementation modules
See: raspberrypi/linux#4198

kernel: media: bcm2835-unicam: Fix bug in buffer swapping logic
See: raspberrypi/linux#4189

kernel: configs: Add CONFIG_RTS_HCTOSYS=y
See: raspberrypi/linux#4205

kernel: overlays: Improve the i2c-rtc,i2c_csi_dsi option

firmware: video_decode: For VC1/WMV with no signalled header bytes, use start of 1st buffer
See: raspberrypi/linux#4113
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this pull request Mar 15, 2021
kernel: drm/vc4: crtc: Reduce PV fifo threshold on hvs4
See: raspberrypi/linux#4207

kernel: vc4/drm: Adjustments to hdmi audio dma to reduce glitches
See: raspberrypi/linux#4208

kernel: overlays: gpio-led: new overlay
See: raspberrypi/linux#4206

kernel: bcm2835-codec tweaks
See: raspberrypi/linux#4113

kernel: Assign crypto aliases to different AES implementation modules
See: raspberrypi/linux#4198

kernel: media: bcm2835-unicam: Fix bug in buffer swapping logic
See: raspberrypi/linux#4189

kernel: configs: Add CONFIG_RTS_HCTOSYS=y
See: raspberrypi/linux#4205

kernel: overlays: Improve the i2c-rtc,i2c_csi_dsi option

firmware: video_decode: For VC1/WMV with no signalled header bytes, use start of 1st buffer
See: raspberrypi/linux#4113
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants