Orin in jp5.0.2 camera [vi output, imx1] process cpu occupies 100%

I can see the error message as follows:
[ 6006.249721] tegra-camrtc-capture-vi tegra-capture-vi: uncorr_err: request timed out after 2500 ms
[ 6006.258881] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: attempting to reset the capture channel
[ 6006.269506] (NULL device *): vi_capture_control_message: NULL VI channel received
[ 6006.277262] t194-nvcsi 13e40000.host1x:nvcsi@15a00000: csi5_stream_close: Error in closing stream_id=4, csi_port=4
[ 6006.287962] (NULL device *): vi_capture_control_message: NULL VI channel received
[ 6006.295691] t194-nvcsi 13e40000.host1x:nvcsi@15a00000: csi5_stream_open: VI channel not found for stream- 4 vc- 1
[ 6006.306520] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: successfully reset the capture channel

Does this message mean keep dropping capture request and request the buffers?

how can i " revise the code for sending error flag to update vb2_state",Give me some specific guidance

The following information is printed when the dequeuing thread exits:
[ 285.471124] ------------[ cut here ]------------
[ 285.476114] channel context at 7 is busy
[ 285.476143] WARNING: CPU: 0 PID: 3212 at /home/glx/nvidia/custom_orin_jp5.0.2/Linux_for_Tegra/sources/kernel/nvidia/drivers/platform/tegra/rtcpu/capture-ivc.c:176 tegra_capture_ivc_notify_chan_id+0x188/0x1b0
[ 285.495114] Modules linked in: nv_imx185(E) tztek_camera_driver(E) tztek_max9296(E) max9296_class(E) xt_conntrack(E) xt_MASQUERADE(E) nf_conntrack_netlink(E) nfnetlink(E) nvidia_modeset(OE) fuse(E) xt_addrtype(E) iptable_filter(E) iptable_nat(E) nf_nat(E) nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) libcrc32c(E) br_netfilter(E) lzo_rle(E) lzo_compress(E) zram(E) overlay(E) ramoops(E) reed_solomon(E) loop(E) snd_soc_tegra186_asrc(E) snd_soc_tegra210_iqc(E) snd_soc_tegra186_dspk(E) snd_soc_tegra186_arad(E) snd_soc_tegra210_ope(E) snd_soc_tegra210_mvc(E) snd_soc_tegra210_admaif(E) snd_soc_tegra210_afc(E) snd_soc_tegra210_dmic(E) snd_soc_tegra210_adx(E) snd_soc_tegra210_amx(E) snd_soc_tegra210_sfc(E) snd_soc_tegra210_mixer(E) snd_soc_tegra210_i2s(E) snd_soc_tegra_pcm(E) aes_ce_blk(E) crypto_simd(E) cryptd(E) aes_ce_cipher(E) snd_hda_codec_hdmi(E) ghash_ce(E) sha2_ce(E) snd_soc_tegra210_adsp(E) ucsi_ccg(E) sha256_arm64(E) snd_soc_tegra_machine_driver(E) sha1_ce(E) typec_ucsi(E)
[ 285.495179] snd_hda_tegra(E) snd_soc_tegra_utils(E) ofpart(E) ina3221(E) input_leds(E) nvgpu(E) cmdlinepart(E) nvadsp(E) pwm_fan(E) qspi_mtd(E) snd_soc_simple_card_utils(E) snd_soc_spdif_tx(E) snd_hda_codec(E) typec(E) nct1008(E) snd_soc_tegra210_ahub(E) tegra_bpmp_thermal(E) snd_soc_rt5640(E) userspace_alert(E) tegra210_adma(E) mtd(E) snd_hda_core(E) snd_soc_rl6231(E) spi_tegra114(E) nvidia(OE) binfmt_misc(E) nvmap(E) ip_tables(E) x_tables(E)
[ 285.495218] CPU: 0 PID: 3212 Comm: deq185 1-0042 Tainted: G W OE 5.10.104-tegra #13
[ 285.495220] Hardware name: /, BIOS 1.0-d7fb19b 08/10/2022
[ 285.495223] pstate: 40c00009 (nZcv daif +PAN +UAO -TCO BTYPE=–)
[ 285.495226] pc : tegra_capture_ivc_notify_chan_id+0x188/0x1b0
[ 285.495229] lr : tegra_capture_ivc_notify_chan_id+0x188/0x1b0
[ 285.495230] sp : ffff800029fcbaf0
[ 285.495232] x29: ffff800029fcbaf0 x28: 0000000000000000
[ 285.495235] x27: 0000000000001043 x26: ffff27b7f27f6400
[ 285.495238] x25: ffff27b81eba44b8 x24: ffff27b704716088
[ 285.495241] x23: 000000000000004f x22: ffff27b704716080
[ 285.495243] x21: ffff27b704716a60 x20: 0000000000000007
[ 285.495246] x19: 000000000000004f x18: 0000000000000000
[ 285.495248] x17: 0000000000000000 x16: ffffb2b2e3fb06cc
[ 285.495251] x15: ffff27b7184beaf0 x14: ffffffffffffffff
[ 285.495254] x13: ffffb2b2e5f46de8 x12: ffffb2b2e5f46a1b
[ 285.495256] x11: 0000000000000000 x10: 0000000000000a80
[ 285.495259] x9 : ffff800029fcbaf0 x8 : 2073692037207461
[ 285.495262] x7 : 20747865746e6f63 x6 : c0000000ffffefff
[ 285.495264] x5 : ffff27be2c4ca958 x4 : ffffb2b2e5c47968
[ 285.495267] x3 : 0000000000000001 x2 : ffff27be2c4ca960
[ 285.495270] x1 : 0af96452ff1f4b00 x0 : 0000000000000000
[ 285.495273] Call trace:
[ 285.495276] tegra_capture_ivc_notify_chan_id+0x188/0x1b0
[ 285.495280] vi_capture_setup+0x35c/0x670
[ 285.495283] tegra_channel_capture_setup+0xe4/0x2c0
[ 285.495285] vi5_channel_error_recover+0x144/0x220
[ 285.495288] tegra_channel_error_recover+0x3c/0x50
[ 285.495290] tegra_channel_kthread_capture_dequeue+0x144/0x1f0
[ 285.495293] kthread+0x148/0x170
[ 285.495296] ret_from_fork+0x10/0x18
[ 285.495299] —[ end trace 92807d38d916c8d6 ]—
[ 285.500699] tegra194-vi5 13e40000.host1x:vi1@14c00000: failed to update control callback
[ 285.509333] tegra-camrtc-capture-vi tegra-capture-vi: vi capture setup failed
[ 285.517036] tegra-camrtc-capture-vi tegra-capture-vi: fatal: error recovery failed

hello lixing.gao,

please add this patch, it adds NULL check to VI-5 drivers.
for example,

 drivers/media/platform/tegra/camera/vi/vi5_fops.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/tegra/camera/vi/vi5_fops.c b/drivers/media/platform/tegra/camera/vi/vi5_fops.c
index 061bd3838..46c6bb52f 100644
--- a/drivers/media/platform/tegra/camera/vi/vi5_fops.c
+++ b/drivers/media/platform/tegra/camera/vi/vi5_fops.c
@@ -96,8 +96,14 @@ static int tegra_vi5_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
 	struct v4l2_subdev *sd = chan->subdev_on_csi;
 	struct camera_common_data *s_data =
 				to_camera_common_data(sd->dev);
-	struct tegracam_ctrl_handler *handler = s_data->tegracam_ctrl_hdl;
-	struct tegracam_sensor_data *sensor_data = &handler->sensor_data;
+	struct tegracam_ctrl_handler *handler;
+	struct tegracam_sensor_data *sensor_data;
+
+	if (!s_data || !s_data->tegracam_ctrl_hdl)
+		goto no_support;
+
+	handler = s_data->tegracam_ctrl_hdl;
+	sensor_data = &handler->sensor_data;
 
 	/* TODO: Support reading blobs for multiple devices */
 	switch (ctrl->id) {
@@ -124,6 +130,7 @@ static int tegra_vi5_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
 		return -EINVAL;
 	}
 
+no_support:
 	return 0;
 }

you should be able to check vb2 buffer state in your application,
here show the struct of the vb2 buffer.

enum vb2_buffer_state {
  	VB2_BUF_STATE_DEQUEUED,
  	VB2_BUF_STATE_IN_REQUEST,
  	VB2_BUF_STATE_PREPARING,
  	VB2_BUF_STATE_QUEUED,
  	VB2_BUF_STATE_ACTIVE,
  	VB2_BUF_STATE_DONE,
  	VB2_BUF_STATE_ERROR,
 };


struct vb2_buffer {
...
  	enum vb2_buffer_state	state;

you should check the buffer state, it should be VB2_BUF_STATE_ERROR if your camera disconnected.
please handle such error condition to terminate capture request.