Skip to content

Backtrace in media_pipeline_stop with bcm2835-unicam #5412

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

Open
floe opened this issue Mar 28, 2023 · 1 comment
Open

Backtrace in media_pipeline_stop with bcm2835-unicam #5412

floe opened this issue Mar 28, 2023 · 1 comment

Comments

@floe
Copy link
Contributor

floe commented Mar 28, 2023

Describe the bug

I'm running a Raspberry Pi with HQ camera as timelapse webcam. Everything seems to be working fine, so this is probably relatively low priority, but I still wanted to mention that I'm getting the following backtrace in media_pipeline_stop for every picture taken with libcamera.

Steps to reproduce the behaviour

The following Python code triggers this issue when run repeatedly every 2 minutes via cronjob:

#!/usr/bin/python3

# based on https://github.com/raspberrypi/picamera2/blob/main/examples/opencv_mertens_merge.py

#import numpy as np
import time,os,cv2,shutil
from picamera2 import Picamera2
from libcamera import Transform
from datetime import datetime

RATIO = 3.0
RATIO2 = RATIO*RATIO

picam2 = Picamera2()
controls = {}

def expose(prefix,duration):
    controls["ExposureTime"] = int(duration)
    print(controls)
    picam2.set_controls(controls)
    picam2.start()
    data = picam2.capture_array()
    picam2.stop()
    means = cv2.mean(data)
    mean = (means[0]+means[1]+means[2])/3
    if mean < 15 or mean > 240:
        return 0
    cv2.imwrite(prefix+".jpg", data)
    return mean

# "main()"

prefix = datetime.now().strftime("%Y%m%d-%H%M%S")
path = "/var/ram/"+prefix
os.mkdir(path)
os.chdir(path)

# Run for a second to get a reasonable "middle" exposure level.
picam2.configure(picam2.create_preview_configuration())
picam2.start()
time.sleep(1)
metadata = picam2.capture_metadata()
picam2.stop()

# get the auto-calibrated values
exposure_normal = metadata["ExposureTime"]
gain = metadata["AnalogueGain"] * metadata["DigitalGain"]
wb = metadata["ColourGains"]

# create default configuration
controls = { "ExposureTime": exposure_normal, "AnalogueGain": gain, "AeEnable": False, "ColourGains": wb }
capture_config = picam2.create_still_configuration(main = {"size": (3840, 2160), "format": "RGB888"}) 
#transform=Transform(hflip=1,vflip=1)) #, controls=controls)
picam2.configure(capture_config)

# get 5 exposures
expose(prefix+"-vs", exposure_normal / RATIO2)
expose(prefix+"-sh", exposure_normal / RATIO )
expose(prefix+"-nm", exposure_normal         )
expose(prefix+"-lg", exposure_normal * RATIO )
expose(prefix+"-vl", exposure_normal * RATIO2)

Device (s)

Raspberry Pi Zero W / WH

System

Raspberry Pi reference 2022-09-22
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 8a42abcd1dbd8c9c1fdfca4e0c3778255b2f9cc4, stage2

Mar 17 2023 10:52:42
Copyright (c) 2012 Broadcom
version 82f3750a65fadae9a38077e3c2e217ad158c8d54 (clean) (release) (start)

Linux XXXXXXX 6.1.19+ #1637 Tue Mar 14 11:01:56 GMT 2023 armv6l GNU/Linux

Logs

[244731.171175] ------------[ cut here ]------------
[244731.171210] WARNING: CPU: 0 PID: 900 at drivers/media/mc/mc-entity.c:873 media_pipeline_stop+0x28/0x34 [mc]
[244731.171417] Modules linked in: cmac algif_hash aes_arm aes_generic ecb algif_skcipher af_alg bnep imx477 hci_uart btbcm bluetooth brcmfmac ecdh_generic ecc libaes vc4 brcmutil sha256_generic libsha256 snd_soc_hdmi_codec 8021q garp stp llc drm_display_helper cec cfg80211 drm_dma_helper drm_kms_helper snd_soc_core bcm2835_unicam snd_compress v4l2_dv_timings snd_pcm_dmaengine syscopyarea v4l2_fwnode sysfillrect sysimgblt bcm2835_codec(C) i2c_mux_pinctrl fb_sys_fops i2c_mux raspberrypi_hwmon v4l2_async bcm2835_v4l2(C) bcm2835_isp(C) v4l2_mem2mem bcm2835_mmal_vchiq(C) rfkill videobuf2_vmalloc videobuf2_dma_contig videobuf2_memops videobuf2_v4l2 videobuf2_common snd_bcm2835(C) videodev snd_pcm snd_timer i2c_bcm2835 snd vc_sm_cma(C) mc uio_pdrv_genirq uio fixed drm fuse drm_panel_orientation_quirks backlight ip_tables x_tables ipv6
[244731.171829] CPU: 0 PID: 900 Comm: raspberry_fakeh Tainted: G WC 6.1.19+ #1637
[244731.171848] Hardware name: BCM2835
[244731.171865] unwind_backtrace from show_stack+0x18/0x1c
[244731.171904] show_stack from dump_stack_lvl+0x34/0x58
[244731.171934] dump_stack_lvl from __warn+0x7c/0xf8
[244731.171967] __warn from warn_slowpath_fmt+0x60/0xcc
[244731.172002] warn_slowpath_fmt from media_pipeline_stop+0x28/0x34 [mc]
[244731.172150] media_pipeline_stop [mc] from unicam_stop_streaming+0x88/0x168 [bcm2835_unicam]
[244731.172343] unicam_stop_streaming [bcm2835_unicam] from __vb2_queue_cancel+0x30/0x284 [videobuf2_common]
[244731.172554] __vb2_queue_cancel [videobuf2_common] from vb2_core_streamoff+0x20/0xb8 [videobuf2_common]
[244731.172739] vb2_core_streamoff [videobuf2_common] from __video_do_ioctl+0x224/0x458 [videodev]
[244731.173460] __video_do_ioctl [videodev] from video_usercopy+0x118/0x574 [videodev]
[244731.174268] video_usercopy [videodev] from sys_ioctl+0x10c/0x90c
[244731.174705] sys_ioctl from ret_fast_syscall+0x0/0x1c
[244731.174732] Exception stack(0xdc905fa8 to 0xdc905ff0)
[244731.174752] 5fa0: a4311ef0 a430d65c 0000000f 40045613 a4312f30 00000000
[244731.174770] 5fc0: a4311ef0 a430d65c a430d670 00000036 0238e568 00000000 b6e90134 0238e508
[244731.174783] 5fe0: a52b9d44 a4cc770c a5237940 b6d0dd4c
[244731.174795] ---[ end trace 0000000000000000 ]---

Additional context

No response

@6by9
Copy link
Contributor

6by9 commented Mar 28, 2023

See #5409

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

No branches or pull requests

2 participants