When using GMSL camera, vi-output process caused high CPU load

Hi, I’m using the Jetson AGX Orin based computer and IMX.390 based GMSL Camera. When capturing camera frames with gstreamer, “vi-output” process caused high CPU load (50~70%).

Environment:

  • Jetson: AGX Orin
  • L4T version: R35.3.1
  • Image sensor: imx.390
  • gstreamer command:
gst-launch-1.0 v4l2src device="/dev/video0" ! "video/x-raw, format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM), width=480, height=270, format=(string)I420" ! nvvidconv ! xvimagesink sync=false

I tried a function trace of “vi-output” and guessed “tegra_channel_kthread_capture_enqueue” thread was in a busy loop.

 vi-output, imx3-10393   [005] ...1 25802.981586: kthread_should_stop <-tegra_channel_kthread_capture_enqueue
 vi-output, imx3-10393   [005] ...1 25802.981587: kthread_should_stop <-tegra_channel_kthread_capture_enqueue
 vi-output, imx3-10393   [005] ...1 25802.981587: kthread_should_stop <-tegra_channel_kthread_capture_enqueue
 vi-output, imx3-10393   [005] ...1 25802.981587: _raw_spin_lock_irqsave <-tegra_channel_kthread_capture_enqueue
 vi-output, imx3-10393   [005] d..2 25802.981587: _raw_spin_unlock_irqrestore <-tegra_channel_kthread_capture_enqueue
 vi-output, imx3-10393   [005] ...1 25802.981587: kthread_should_stop <-tegra_channel_kthread_capture_enqueue
 vi-output, imx3-10393   [005] ...1 25802.981587: kthread_should_stop <-tegra_channel_kthread_capture_enqueue
 vi-output, imx3-10393   [005] ...1 25802.981588: kthread_should_stop <-tegra_channel_kthread_capture_enqueue
 vi-output, imx3-10393   [005] ...1 25802.981588: _raw_spin_lock_irqsave <-tegra_channel_kthread_capture_enqueue
 vi-output, imx3-10393   [005] d..2 25802.981588: _raw_spin_unlock_irqrestore <-tegra_channel_kthread_capture_enqueue
 vi-output, imx3-10393   [005] ...1 25802.981588: kthread_should_stop <-tegra_channel_kthread_capture_enqueue
 vi-output, imx3-10393   [005] ...1 25802.981588: kthread_should_stop <-tegra_channel_kthread_capture_enqueue
 vi-output, imx3-10393   [005] ...1 25802.981589: kthread_should_stop <-tegra_channel_kthread_capture_enqueue

I checked dmesg and found this warning.

corr_err: discarding frame 0, flags: 0, err_data

I thought this error might be the cause. So I applied this patch and the “vi-output” process became low CPU load.

modified   kernel/nvidia/drivers/media/platform/tegra/camera/vi/vi5_fops.c
@@ -691,6 +691,7 @@ static int tegra_channel_kthread_capture_enqueue(void *data)
 					< (chan->capture_queue_depth * chan->valid_ports))) {
 				spin_unlock_irqrestore(
 					&chan->capture_state_lock, flags);
+			    dequeue_buffer(chan, false);
 				break;
 			}
 			spin_unlock_irqrestore(&chan->capture_state_lock,

Is this patch correct? Or if there is another best solution, I would like to know.

Does any side effect for your modification?
Try increase the timeout instead of add dequeue_buffer()

define CAPTURE_TIMEOUT_MS 2500

Hi.

Thank you for your help. I tried changing the timeout value but it did not work.

With my modification, I have confirmed that running the camera for several hours does not cause any problems. However, I do not know the extent to which this modification will have side effects.

How long did you increase?

I changed to 25000.

@@ -39,7 +39,7 @@
 #define VI_CHANNEL_DEV "/dev/capture-vi-channel"
 #define VI_CHAN_PATH_MAX 40
 
-#define CAPTURE_TIMEOUT_MS	2500
+#define CAPTURE_TIMEOUT_MS	25000
 
 static const struct vi_capture_setup default_setup = {
 	.channel_flags = 0

Did you apply the kernel Image to verify the modification?

Thanks

Yes. I checked CAPTURE_TIMEOUT_MS by debug log.

Thanks for your confirm.
Please take time to verify your solution to confirm if any side effect.

Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

Please help to verify this patch.

0001-camera-vi5-fix-stream-on-off-memory-leakage.patch (6.4 KB)
0001-vi5-continue-captures-even-after-corr-errors.patch (2.3 KB)

1 Like