TC358840 tegra_channel_init_subdevices kernel error!

Hi,
On Tx2 board, I refer imx274.dtsi and modify tc358840.c, compile and install successfully, my tc358840 device tree is:

/ {
	host1x {
		vi@15700000 {
			num-channels = <1>;
			ports {
				#address-cells = <1>;
				#size-cells = <0>;
				port@0 {
					reg = <0>;
					tc358840a_vi_in0: endpoint {
						port-index = <0>;
						bus-width = <2>;
						remote-endpoint = <&tc358840a_csi_out0>;
					};
				};
			};
		};

		nvcsi@150c0000 {
			num-channels = <1>;
			#address-cells = <1>;
			#size-cells = <0>;
			channel@0 {
				reg = <0>;
				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						tc358840a_csi_in0: endpoint@0 {
							port-index = <0>;
							bus-width = <2>;
							remote-endpoint = <&tc358840a_imx274_out0>;
						};
					};
					port@1 {
						reg = <1>;
						tc358840a_csi_out0: endpoint@1 {
							remote-endpoint = <&tc358840a_vi_in0>;
						};
					};
				};
			};
		};
	};

	i2c@3180000 {
			tc358840@0f {
				compatible = "toshiba,tc358840";
				/* I2C device address */
				reg = <0x0f>;

				/* V4L2 device node location */
				devnode = "video0";

				/* Physical dimensions of sensor */
				physical_w = "3.674";
				physical_h = "2.738";

				sensor_model = "tc358840";

				lineinitcnt = <0x00000FA0>;
				lptxtimecnt = <0x00000004>;
				tclk_headercnt = <0x00180203>;
				tclk_trailcnt = <0x00040005>;
				ths_headercnt = <0x000D0004>;
				twakeup = <0x00003E80>;
				tclk_postcnt = <0x0000000A>;
				ths_trailcnt = <0x00080006>;
				hstxvregcnt = <0x00000020>;
				btacnt = <0>;

				pll_prd = <10>;
				pll_fbd = <230>;
				pll_frs = <0>;

				refclk_hz = <27000000>;
				//mclk = "cam_mclk1";
				ddc5v_delay = <1>;
				enable_hdcp = <0>;
				csi_port = <0>; 

				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						tc358840a_imx274_out0: endpoint {
							port-index = <0>;
							bus-width = <2>;
							remote-endpoint = <&tc358840a_csi_in0>;
							};
						};
					};
				};
			};
};

/ {

	tegra-camera-platform {
		compatible = "nvidia, tegra-camera-platform";
		/**
		* Physical settings to calculate max ISO BW
		*
		* num_csi_lanes = <>;
		* Total number of CSI lanes when all cameras are active
		*
		* max_lane_speed = <>;
		* Max lane speed in Kbit/s
		*
		* min_bits_per_pixel = <>;
		* Min bits per pixel
		*
		* vi_peak_byte_per_pixel = <>;
		* Max byte per pixel for the VI ISO case
		*
		* vi_bw_margin_pct = <>;
		* Vi bandwidth margin in percentage
		*
		* max_pixel_rate = <>;
		* Max pixel rate in Kpixel/s for the ISP ISO case
		*
		* isp_peak_byte_per_pixel = <>;
		* Max byte per pixel for the ISP ISO case
		*
		* isp_bw_margin_pct = <>;
		* Isp bandwidth margin in percentage
		*/
		num_csi_lanes = <2>;
		max_lane_speed = <1500000>;
		min_bits_per_pixel = <16>;
		vi_peak_byte_per_pixel = <2>;
		vi_bw_margin_pct = <25>;
		max_pixel_rate = <750000>;
		isp_peak_byte_per_pixel = <5>;
		isp_bw_margin_pct = <25>;

		/**
		 * The general guideline for naming badge_info contains 3 parts, and is as follows,
		 * The first part is the camera_board_id for the module; if the module is in a FFD
		 * platform, then use the platform name for this part.
		 * The second part contains the position of the module, ex. "rear" or "front".
		 * The third part contains the last 6 characters of a part number which is found
		 * in the module's specsheet from the vender.
		 */
		modules {
			module0 {
				badge = "tc358840_bottom_A6V26";
				position = "rear";
				orientation = "0";
				drivernode0 {
					/* Declare PCL support driver (classically known as guid)  */
					pcl_id = "v4l2_sensor";
					/* Driver v4l2 device name */
					devname = "tc358840 2-000f";
					/* Declare the device-tree hierarchy to driver instance */
					proc-device-tree = "/proc/device-tree/i2c@3180000/tc358840@0f";
				};
			};
		};
	};
};

However, I got kernel error after added mode parameters into tc358840@0f node:

i2c@3180000 {
			tc358840@0f {
				compatible = "toshiba,tc358840";
				/* I2C device address */
				reg = <0x0f>;

				/* V4L2 device node location */
				devnode = "video0";

				/* Physical dimensions of sensor */
				physical_w = "3.674";
				physical_h = "2.738";

				sensor_model = "tc358840";

				lineinitcnt = <0x00000FA0>;
				lptxtimecnt = <0x00000004>;
				tclk_headercnt = <0x00180203>;
				tclk_trailcnt = <0x00040005>;
				ths_headercnt = <0x000D0004>;
				twakeup = <0x00003E80>;
				tclk_postcnt = <0x0000000A>;
				ths_trailcnt = <0x00080006>;
				hstxvregcnt = <0x00000020>;
				btacnt = <0>;

				pll_prd = <10>;
				pll_fbd = <230>;
				pll_frs = <0>;

				refclk_hz = <27000000>;
				//mclk = "cam_mclk1";
				ddc5v_delay = <1>;
				enable_hdcp = <0>;
				csi_port = <0>; 

				mode0 {
						mclk_khz = "27000";
						num_lanes = [32 00];
						tegra_sinterface = "serial_c";
						phy_mode = "DPHY";
						discontinuous_clk = "no";
						dpcm_enable = "false";
						cil_settletime = [30 00];
						active_w = "1920";
						active_h = "1080";
						mode_type = "yuv";
						pixel_phase = "uyvy";
						csi_pixel_bit_depth = "16";
						readout_orientation = [30 00];
						line_length = "2688";
						inherent_gain = [31 00];
						mclk_multiplier = "6.67";
						pix_clk_hz = "160000000";
						gain_factor = "10";
						min_gain_val = "10";
						max_gain_val = "160";
						step_gain_val = [31 00];
						default_gain = "10";
						min_hdr_ratio = [31 00];
						max_hdr_ratio = [31 00];
						framerate_factor = "1000000";
						min_framerate = "1816577";
						max_framerate = "30000000";
						step_framerate = [31 00];
						default_framerate = "30000000";
						exposure_factor = "1000000";
						min_exp_time = "34";
						max_exp_time = "550385";
						step_exp_time = [31 00];
						default_exp_time = "33334";
						embedded_metadata_height = [30 00];
				};
				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						tc358840a_imx274_out0: endpoint {
							port-index = <0>;
							bus-width = <2>;
							remote-endpoint = <&tc358840a_csi_in0>;
							};
						};
					};
				};
			};
};

the error message is:

[   33.207041] tc358840 2-000f: tc358840_get_fmt():
[   33.211690] tc358840 2-000f: tc358840_get_fmt(): width=1920, height=1080, code=0x0000200F, field=1
[   33.220662] tegra_channel_init_subdevices: 4
[   33.225034] tegra_channel_init_subdevices: 5
[   33.229324] tegra_channel_init_subdevices: 5-3
[   33.233837] tegra_channel_sensorprops_setup: 1
[   33.238360] tegra_channel_sensorprops_setup: 2
[   33.242880] tegra_channel_sensorprops_setup: 3
[   33.247401] tegra_channel_sensorprops_setup: num_modes = 1
[   33.252946] tegra_channel_sensorprops_setup: 3-1
[   33.257725] Internal error: Accessing user space memory outside uaccess.h routines: 96000005 [#1] PREEMPT SMP
[   33.267647] Modules linked in: tc358840(+) bnep fuse bcmdhd zram cfg80211 spidev overlay userspace_alert nvgpu bluedroid_pm ip_tables x_tables
[   33.280751] CPU: 0 PID: 7281 Comm: insmod Not tainted 4.9.201-tegra #41
[   33.287371] Hardware name: quill (DT)
[   33.291047] task: ffffffc1b8975400 task.stack: ffffffc1c155c000
[   33.297007] PC is at tegra_channel_init_subdevices+0x79c/0x868
[   33.302852] LR is at tegra_channel_init_subdevices+0x784/0x868
[   33.308693] pc : [<ffffff8008b3e5dc>] lr : [<ffffff8008b3e5c4>] pstate: 40400045
[   33.316091] sp : ffffffc1c155f810
[   33.319413] x29: ffffffc1c155f810 x28: 0000000000000000 
[   33.324775] x27: 0000000000000002 x26: ffffffc1c06c2000 
[   33.330135] x25: ffffffc1c59dc000 x24: ffffffc1b76a8000 
[   33.335495] x23: ffffffc1b76cd858 x22: 0000000000000000 
[   33.340854] x21: ffffffc1c59d8000 x20: ffffff8009071000 
[   33.346212] x19: ffffffc1e93cf018 x18: 0000000000000010 
[   33.351568] x17: 0000000000000000 x16: 0000000000000000 
[   33.356924] x15: ffffffffffffffff x14: ffffff808a14a5b7 
[   33.362282] x13: ffffff800a14a5c5 x12: 0000000000000000 
[   33.367640] x11: 0000000005f5e0ff x10: 000000000000054d 
[   33.372998] x9 : ffffffc1c06c20d0 x8 : ffffff80083d6638 
[   33.378356] x7 : ffffff8009eb4440 x6 : ffffffc1f5f74bf0 
[   33.383714] x5 : ffffffc1f5f74bf0 x4 : 0000000000000000 
[   33.389071] x3 : ffffffc1f5f7a7f8 x2 : 0000000000000000 
[   33.394428] x1 : ffffff8009072048 x0 : ffffff80094c9ec8 
[   33.399785] 
[   33.401288] Process insmod (pid: 7281, stack limit = 0xffffffc1c155c000)
[   33.407993] Call trace:
[   33.410462] [<ffffff8008b3e5dc>] tegra_channel_init_subdevices+0x79c/0x868
[   33.417348] [<ffffff8008b3f2d0>] tegra_vi_graph_notify_complete+0x2e8/0x6e8
[   33.424324] [<ffffff8008b22cd4>] v4l2_async_test_notify+0x104/0x120
[   33.430601] [<ffffff8008b22f10>] v4l2_async_register_subdev+0x88/0x100
[   33.437183] [<ffffff8001153ae8>] tc358840_probe+0x5a8/0x738 [tc358840]
[   33.443725] [<ffffff8008aebeb4>] i2c_device_probe+0x144/0x258
[   33.449492] [<ffffff8008780ee8>] driver_probe_device+0xd8/0x408
[   33.455419] [<ffffff80087812f4>] __driver_attach+0xdc/0x128
[   33.461000] [<ffffff800877e964>] bus_for_each_dev+0x5c/0xa8
[   33.466579] [<ffffff80087806e8>] driver_attach+0x30/0x40
[   33.471898] [<ffffff800878011c>] bus_add_driver+0x20c/0x2a8
[   33.477481] [<ffffff800878222c>] driver_register+0x6c/0x110
[   33.483061] [<ffffff8008aec5a4>] i2c_register_driver+0x4c/0xb0
[   33.488929] [<ffffff8001141018>] tc358840_driver_init+0x18/0x30 [tc358840]
[   33.495819] [<ffffff8008083b3c>] do_one_initcall+0x44/0x130
[   33.501409] [<ffffff80081c1644>] do_init_module+0x64/0x1a8
[   33.506909] [<ffffff8008156698>] load_module+0x10a0/0x12d0
[   33.512402] [<ffffff8008156b78>] SyS_finit_module+0xd8/0xf0
[   33.517980] [<ffffff8008083900>] el0_svc_naked+0x34/0x38
[   33.523304] ---[ end trace f97d58752f93ac6d ]---

What is the problem?

Why do you need to add mode0, I think this driver don’t need to add this it could duplicate reported the sensor mode.

If don’t have mode parameters, how v4l2 module knows active_w and other parameters, and how v4l2 module calculate cil_settletime?
As I know, cil_settletime, discontinuous_clk, etc, are essential for MIPI CSI…

The tc358840.c have report the mode by itself, you should add it in this driver.

Ok…
There is, my hardware module is tc358743, I find a file tc358743.c in kernel-4.9 folder, can it work well without modification? Or Is it been tested by official?

No sure, but it been verify by many user. Have a reference to below link or googling it.

Thank you!

my tc358743 driver has installed successfully, also generate /dev/video0…
when I use v4l2-ctl to capture data, I got the error:

 tegra-vi4 15700000.vi: dma_alloc_coherent of size 0 failed

What’s the command?
Check the trace log to check if can get more information.

https://elinux.org/Jetson/l4t/Camera_BringUp

The command is:
v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --stream-mmap --stream-count=10000 --set-ctrl bypass_mode=0

The kernel log is :

root@linux:/home/jetson#[  281.270151] tc358840 2-000f: tc358743_query_dv_timings: @@@@@ timings detected error
[  281.279159] tc358840 2-000f: tc358743_query_dv_timings: @@@@@ timings detected error
[  282.291151] tegra-vi4 15700000.vi: dma_alloc_coherent of size 0 failed

The MIPI log is :

root@linux:/home/jetson# v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --stream-mmap --stream-count=10000 --set-ctrl bypass_mode=0
New timings found
VIDIOC_REQBUFS: failed: Cannot allocate memory
root@linux:/home/jetson# cat /sys/kernel/debug/tracing/trace# tracer: nop
#
# entries-in-buffer/entries-written: 52/52   #P:6
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
     kworker/5:0-42    [005] ....   246.578383: rtos_queue_peek_from_isr_failed: tstamp:7964200424 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   246.746350: rtos_queue_peek_from_isr_failed: tstamp:7969200427 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   246.914349: rtos_queue_peek_from_isr_failed: tstamp:7974200434 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   247.082340: rtos_queue_peek_from_isr_failed: tstamp:7979200440 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   247.250353: rtos_queue_peek_from_isr_failed: tstamp:7984200449 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   247.362355: rtos_queue_peek_from_isr_failed: tstamp:7989200452 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   247.530347: rtos_queue_peek_from_isr_failed: tstamp:7994200461 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   247.698335: rtos_queue_peek_from_isr_failed: tstamp:7999200468 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   247.866341: rtos_queue_peek_from_isr_failed: tstamp:8004200475 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   248.034332: rtos_queue_peek_from_isr_failed: tstamp:8009200481 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   248.202344: rtos_queue_peek_from_isr_failed: tstamp:8014200487 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   248.370338: rtos_queue_peek_from_isr_failed: tstamp:8019200493 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   248.482330: rtos_queue_peek_from_isr_failed: tstamp:8024200541 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   248.650321: rtos_queue_peek_from_isr_failed: tstamp:8029200549 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   248.818308: rtos_queue_peek_from_isr_failed: tstamp:8034200556 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   248.986299: rtos_queue_peek_from_isr_failed: tstamp:8039200561 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   249.154298: rtos_queue_peek_from_isr_failed: tstamp:8044200567 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   249.322316: rtos_queue_peek_from_isr_failed: tstamp:8049200576 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   249.490296: rtos_queue_peek_from_isr_failed: tstamp:8054200582 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   249.602301: rtos_queue_peek_from_isr_failed: tstamp:8059200589 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   249.770283: rtos_queue_peek_from_isr_failed: tstamp:8064200641 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   249.938281: rtos_queue_peek_from_isr_failed: tstamp:8069200601 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   250.106291: rtos_queue_peek_from_isr_failed: tstamp:8074200607 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   250.274269: rtos_queue_peek_from_isr_failed: tstamp:8079200616 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   250.442274: rtos_queue_peek_from_isr_failed: tstamp:8084200622 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   250.610304: rtos_queue_peek_from_isr_failed: tstamp:8089200630 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   250.722282: rtos_queue_peek_from_isr_failed: tstamp:8094200636 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   250.890224: rtos_queue_peek_from_isr_failed: tstamp:8099200642 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   251.058261: rtos_queue_peek_from_isr_failed: tstamp:8104200649 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   251.226255: rtos_queue_peek_from_isr_failed: tstamp:8109200657 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   251.394274: rtos_queue_peek_from_isr_failed: tstamp:8114200664 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   251.562254: rtos_queue_peek_from_isr_failed: tstamp:8119200672 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   251.730247: rtos_queue_peek_from_isr_failed: tstamp:8124200677 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   251.842252: rtos_queue_peek_from_isr_failed: tstamp:8129200683 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   252.010240: rtos_queue_peek_from_isr_failed: tstamp:8134200690 queue:0x0b4b4500
     kworker/5:0-42    [005] ....   252.122169: rtos_queue_peek_from_isr_failed: tstamp:8137807567 queue:0x0b4b4500
          v4l_id-7475  [005] ....   255.547999: tegra_channel_open: vi-output, tc358840 2-000f
          v4l_id-7475  [003] ....   255.549810: tegra_channel_set_power: tc358840 2-000f : 0x1
          v4l_id-7475  [003] ....   255.560716: tegra_channel_set_power: 150c0000.nvcsi--1 : 0x1
          v4l_id-7475  [003] ....   255.565803: csi_s_power: enable : 0x1
          v4l_id-7475  [003] ....   255.572966: tegra_channel_close: vi-output, tc358840 2-000f
          v4l_id-7475  [003] ....   255.572971: tegra_channel_set_power: tc358840 2-000f : 0x0
          v4l_id-7475  [003] ....   255.583804: tegra_channel_set_power: 150c0000.nvcsi--1 : 0x0
          v4l_id-7475  [004] ....   255.589889: csi_s_power: enable : 0x0
        v4l2-ctl-7481  [000] ....   281.214258: tegra_channel_open: vi-output, tc358840 2-000f
        v4l2-ctl-7481  [000] ....   281.215437: tegra_channel_set_power: tc358840 2-000f : 0x1
        v4l2-ctl-7481  [000] ....   281.226385: tegra_channel_set_power: 150c0000.nvcsi--1 : 0x1
        v4l2-ctl-7481  [000] ....   281.231486: csi_s_power: enable : 0x1
        v4l2-ctl-7481  [000] ....   282.298077: tegra_channel_close: vi-output, tc358840 2-000f
        v4l2-ctl-7481  [000] ....   282.298095: tegra_channel_set_power: tc358840 2-000f : 0x0
        v4l2-ctl-7481  [000] ....   282.309273: tegra_channel_set_power: 150c0000.nvcsi--1 : 0x0
        v4l2-ctl-7481  [000] ....   282.314451: csi_s_power: enable : 0x0
root@linux:/home/jetson# 

I post my device tree files and driver, please help to check them if possible…
Thank you very much!
tc358743.c (72.7 KB)
tegra186-camera-imx274-a00.dtsi (4.5 KB)
tegra186-quill-camera-imx274-a00.dtsi (1.5 KB)
tegra186-quill-camera-plugin-manager-imx274.dtsi (3.1 KB)

From the trace log looks like NVCSI/VI didn’t receive any validate data from MIPI bus.

What is the posible reason of dma_alloc_coherent failed?

tegra-vi4 15700000.vi: dma_alloc_coherent of size 0 failed

Looks like allocate DMA buffer failed.
Have breakdown from …/kernel/kernel-4.9/drivers/media/v4l2-core/videobuf2-dma-contig.c

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