The name filed of tegracam_device makes kernel panic

Hi, guys! I ported a camera driver reference with imx219, and I get a wired thing , if I fill the name filed(max length is 32) of tegracam_device with characters larger than 8 in probe function, the driver crashes. this can be showed up by changing “imx219” to “imx21921” in line 713 of imx219.c. My question is why cann’t filled the name filed larger than 8?

Could you provide the log?

And try to modify the 32 to 64 of the name size.

struct tegracam_device {
  	struct camera_common_data	*s_data;
  	struct media_pad		pad;
  	u32 				version;
  	bool				is_streaming;
  	/* variables to be filled by the driver to register */
  	char				name[32];

this is the log:

[ 1.018233] tegradc tegradc.1: dpd enable lookup fail:-19 [ 1.529674] Host read timeout at address 545c00c4 [ 1.725758] imx219 6-003c: imx219_board_setup: invalid sensor model id: 5050 [ 1.733622] Unable to handle kernel read from unreadable memory at virtual address 00000000 [ 1.741988] Mem abort info: [ 1.744782] ESR = 0x96000005 [ 1.747853] Exception class = DABT (current EL), IL = 32 bits [ 1.753777] SET = 0, FnV = 0 [ 1.756830] EA = 0, S1PTW = 0 [ 1.759981] Data abort info: [ 1.762871] ISV = 0, ISS = 0x00000005 [ 1.766717] CM = 0, WnR = 0 [ 1.769696] [0000000000000000] user address but active_mm is swapper [ 1.776064] Internal error: Oops: 96000005 [#1] PREEMPT SMP [ 1.781635] Modules linked in: [ 1.784708] CPU: 3 PID: 1 Comm: swapper/0 Not tainted 4.9.140-tegra #27 [ 1.791316] Hardware name: NVIDIA Jetson Nano Developer Kit (DT) [ 1.797317] task: ffffffc0fa6f0000 task.stack: ffffffc0fa66c000 [ 1.803251] PC is at kernel_init_freeable+0x18c/0x244 [ 1.808299] LR is at kernel_init_freeable+0x1a0/0x244 [ 1.813348] pc : [] lr : [] pstate: 60400045 [ 1.820736] sp : ffffffc0fa66fe40 [ 1.824048] x29: ffffffc0fa66fe40 x28: ffffffc0fa5d3820 [ 1.829380] x27: 0000000000000000 x26: ffffffc0f2930018 [ 1.834708] x25: ffffffc0f83ec850 x24: ffffffc0f83ec818 [ 1.840033] x23: ffffff8009658e70 x22: 0000000000000006 [ 1.845359] x21: 0000000000000007 x20: ffffff800a12d000 [ 1.850684] x19: 000000000000019e x18: 0000000000000b7d [ 1.856011] x17: 0000000000000001 x16: 0000000000000000 [ 1.861336] x15: 0000000000000cdd x14: 0000000000000b7d [ 1.866662] x13: 000000000039e2f3 x12: 0000000000000b7d [ 1.871986] x11: 0000000000000a35 x10: 0000000000000400 [ 1.877312] x9 : 0000000000000a35 x8 : 0000000000000400 [ 1.882638] x7 : 00000000afb50401 x6 : ffffffc0f7f96280 [ 1.887965] x5 : ffffffc0fa6f0000 x4 : ffffffc0ff0280e0 [ 1.892004] tegra-pcie 1003000.pcie: g [ 1.898589] x3 : 0000000000000000 x2 : 0000000000000000 [ 1.903914] x1 : 0000000000000000 x0 : 0000000000000000 [ 1.909240] [ 1.910731] Process swapper/0 (pid: 1, stack limit = 0xffffffc0fa66c000) [ 1.917427] Call trace: [ 1.919875] [] kernel_init_freeable+0x18c/0x244 [ 1.925975] [] kernel_init+0x18/0x108 [ 1.931206] [] ret_from_fork+0x10/0x40 [ 1.936528] ---[ end trace cd4d45147d3a1d1f ]--- [ 1.947161] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b [ 1.947161] [ 1.956307] SMP: stopping secondary CPUs [ 1.960245] Kernel Offset: disabled [ 1.963737] Memory Limit: none [ 1.972479] Rebooting in 5 seconds..

and if modify the 32 to 64 of the name size, kernel painc also.

Could you try comment the imx219_board_setup() function call in the imx219_probe.
And why you need to add characters? You may need modify the device tree and the .name in the driver too.

Kernel panic too if comment the imx219_board_setup() function.
I just copy the imx219 driver and change the driver name to my camera, and the get this panic. and this panic makes me confused that I filled the name with characters less than 32, why does it cause kernel panic.

Did you modify the .name and i2c_device_id[] too.

yes, it is the same string value.

Could you confirm modify the string in the device tree too.
Also confirm by example “sudo cat /proc/device-tree/i2c@3180000/ov5693_c@36/compatible”

i2c@546c0000 {
 			imx219_single_cam0: rbpcv2_imx219_a@10 {
 				compatible = "nvidia,imx219";

Yes, I modify it too.
I had a test on imx219 driver on origion sdk. I modify these steps(just change imx219 to imx21921):
step 1: in tegra210-camera-rbpcv2-imx219.dtsi

i2c@546c0000 {
			imx219_single_cam0: rbpcv2_imx219_a@10 {
				compatible = "nvidia,imx21921";

step 2. line 55 of imx219.c

static const struct of_device_id imx219_of_match[] = {
	{ .compatible = "nvidia,imx21921", },

step 3. line 758 of imx219.c

static const struct i2c_device_id imx219_id[] = {
	{ "imx21921", 0 },

step 4. line 765 of imx219.c

static struct i2c_driver imx219_i2c_driver = {
	.driver = {
		.name = "imx21921",
		.owner = THIS_MODULE,

step 5. line 713 of imx291.c

priv->i2c_client = tc_dev->client = client;
	tc_dev->dev = dev;
	strncpy(tc_dev->name, "imx21921", sizeof(tc_dev->name));

then the kernel panic, there is the log:

[ 1.022894] tegradc tegradc.1: dpd enable lookup fail:-19 [ 1.528935] Host read timeout at address 545c00c4 [ 2.837576] tegra-vii2c 546c0000.i2c: --- register dump for debugging ---- [ 2.844503] tegra-vii2c 546c0000.i2c: I2C_CNFG - 0x22c00 [ 2.849847] tegra-vii2c 546c0000.i2c: I2C_PACKET_TRANSFER_STATUS - 0x10001 [ 2.856745] tegra-vii2c 546c0000.i2c: I2C_FIFO_CONTROL - 0xe0 [ 2.862553] tegra-vii2c 546c0000.i2c: I2C_FIFO_STATUS - 0x800070 [ 2.868599] tegra-vii2c 546c0000.i2c: I2C_INT_MASK - 0xac [ 2.874016] tegra-vii2c 546c0000.i2c: I2C_INT_STATUS - 0x0 [ 2.879510] tegra-vii2c 546c0000.i2c: msg->len - 2 [ 2.884321] tegra-vii2c 546c0000.i2c: is_msg_write - 1 [ 2.889467] tegra-vii2c 546c0000.i2c: buf_remaining - 0 [ 2.894707] tegra-vii2c 546c0000.i2c: i2c transfer timed out, addr 0x0010, data 0x00 [ 2.902550] imx21921 6-0010: imx219_board_setup: error during i2c read probe (-110) [ 2.910246] imx21921 6-0010: board setup failed [ 2.915046] Unable to handle kernel read from unreadable memory at virtual address 40f9400280 [ 2.923576] Mem abort info: [ 2.926384] ESR = 0x86000005 [ 2.929439] Exception class = IABT (current EL), IL = 32 bits [ 2.935384] SET = 0, FnV = 0 [ 2.938453] EA = 0, S1PTW = 0 [ 2.941608] [00000040f9400280] user address but active_mm is swapper [ 2.947977] Internal error: Oops: 86000005 [#1] PREEMPT SMP [ 2.953546] Modules linked in: [ 2.956617] CPU: 3 PID: 1 Comm: swapper/0 Not tainted 4.9.140-tegra #10 [ 2.963225] Hardware name: NVIDIA Jetson Nano Developer Kit (DT) [ 2.969226] task: ffffffc0fa6f0000 task.stack: ffffffc0fa66c000 [ 2.975142] PC is at 0x40f9400280 [ 2.978468] LR is at do_one_initcall+0x44/0x130 [ 2.982995] pc : [<00000040f9400280>] lr : [] pstate: 40400045 [ 2.990382] sp : ffffffc0fa66fdd0 [ 2.993693] x29: ffffffc0fa66fdd0 x28: ffffff8008af2970 [ 2.999020] x27: ffffffc0fa66fb80 x26: 00000000ffffff92 [ 3.004346] x25: ffffffc0f972c918 x24: ffffff8008af2f14 [ 3.009671] x23: ffffff8009668d60 x22: 0000000000000006 [ 3.014995] x21: ffffffc0fa6f0000 x20: 0000000000000000 [ 3.020318] x19: b4000040f9400280 x18: 0000000000000000 [ 3.025642] x17: 0000000000000001 x16: 0000000000000000 [ 3.030966] x15: 0000000000002800 x14: 00000000000003ea [ 3.036289] x13: 00000000000d4513 x12: 00000000000003ea [ 3.041613] x11: 0000000000001932 x10: 0000000000000400 [ 3.046935] x9 : 0000000000000002 x8 : 0000000000000001 [ 3.052260] x7 : 000000000001b392 x6 : ffffffc0f9b01d00 [ 3.057585] x5 : ffffffc0fa6f0000 x4 : ffffffc0ff00f0e0 [ 3.062907] x3 : 0000000000000000 x2 : 0000000000000000 [ 3.068230] x1 : 0000000000000000 x0 : 0000000000000000 [ 3.073553] [ 3.075043] Process swapper/0 (pid: 1, stack limit = 0xffffffc0fa66c000) [ 3.081738] Call trace: [ 3.084184] [<00000040f9400280>] 0x40f9400280 [ 3.088547] [] kernel_init_freeable+0x1a0/0x244 [ 3.094645] [] kernel_init+0x18/0x108 [ 3.099865] [] ret_from_fork+0x10/0x40 [ 3.105186] ---[ end trace 07e7b556885326ff ]--- [ 3.116633] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b [ 3.116633] [ 3.125771] SMP: stopping secondary CPUs [ 3.129707] Kernel Offset: disabled [ 3.133197] Memory Limit: none [ 3.142925] Rebooting in 5 seconds..

and if did not do step 5, the kernel boots normally.

Could you try to modify the Makefile to imx21921.o

obj-$(CONFIG_VIDEO_IMX219) += imx21921.o

I can’t understand, the file name is imx219.c.

@yeshuang
I just try the ov5693 to add some string found not problem it’s different with imx219 is ov5693 is LKM.
Could you try to modify the imx219 to LKM to try.

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide%2Fcamera_sensor_prog.html%23wwpID0E0PH0HA

And what my early comment is change the imx219.c to imx21921.c

Load as LKM crash as the same. Here is the log:
[ 323.245651] tegra-vii2c 546c0000.i2c: no acknowledge from address 0x10
[ 323.252929] imx21921 6-0010: imx219_board_setup: error during i2c read probe (-121)
[ 323.260636] imx21921 6-0010: board setup failed
[ 323.265204] Unable to handle kernel read from unreadable memory at virtual address ffffff8008f6b8
[ 323.274257] Mem abort info:
[ 323.277044] ESR = 0x8600000f
[ 323.280115] Exception class = IABT (current EL), IL = 32 bits
[ 323.286049] SET = 0, FnV = 0
[ 323.289094] EA = 0, S1PTW = 0
[ 323.292251] swapper pgtable: 4k pages, 39-bit VAs, pgd = ffffff800a1b7000
[ 323.299061] [ffffff8008f6b958] *pgd=000000017f1fe003, *pud=000000017f1fe003, *pmd=000000017f1fc03
[ 323.310072] Internal error: Oops: 8600000f [#1] PREEMPT SMP
[ 323.315636] Modules linked in: imx219(+) bnep zram overlay fuse spidev nvgpu bluedroid_pm ip_tabs
[ 323.325605] CPU: 3 PID: 19457 Comm: insmod Not tainted 4.9.140-tegra #12
[ 323.332305] Hardware name: NVIDIA Jetson Nano Developer Kit (DT)
[ 323.338314] task: ffffffc0b7d39c00 task.stack: ffffffc0afbc8000
[ 323.344246] PC is at modinfo_attrs+0x10/0x48
[ 323.348529] LR is at modinfo_attrs+0x10/0x48
[ 323.352809] pc : [] lr : [] pstate: 40400045
[ 323.360207] sp : ffffffc0afbcbab0
[ 323.363557] x29: ffffffc0afbcbab0 x28: 0000000000000018
[ 323.368926] x27: 00000000000000f0 x26: 0000000000000030
[ 323.374297] x25: 0000000000000000 x24: ffffff8008f6b958
[ 323.379720] x23: ffffffc0afbcbab0 x22: 0000000000000018
[ 323.385103] x21: 000000000bfef45c x20: 0000000000000030
[ 323.390475] x19: 0000000000000000 x18: 0000000000000010
[ 323.395892] x17: 0000000000000000 x16: 0000000000000000
[ 323.401274] x15: ffffffffffffffff x14: ffffff808a126a82
[ 323.406645] x13: ffffff800a126a90 x12: 0000000000000006
[ 323.412063] x11: 0000000005f5e0ff x10: 00000000000003ae
[ 323.417508] x9 : 00000000ffffffd0 x8 : ffffff80083d47b0
[ 323.422952] x7 : ffffff8009e94358 x6 : ffffffc0ff000bf0
[ 323.428389] x5 : ffffffc0ff000bf0 x4 : 0000000000000000
[ 323.433828] x3 : ffffffc0ff0067f8 x2 : ffffffc0ff000bf0
[ 323.439265] x1 : ffffffc0b7d39c00 x0 : 00000000ffffff87
[ 323.444698]
[ 323.446271] Process insmod (pid: 19457, stack limit = 0xffffffc0afbc8000)
[ 323.453120] Call trace:
[ 323.455671] [] modinfo_attrs+0x10/0x48
[ 323.461074] [] driver_probe_device+0xd8/0x408
[ 323.467073] [] __driver_attach+0xdc/0x128
[ 323.472737] [] bus_for_each_dev+0x5c/0xa8
[ 323.478385] [] driver_attach+0x30/0x40
[ 323.483772] [] bus_add_driver+0x20c/0x2a8
[ 323.489421] [] driver_register+0x6c/0x110
[ 323.495070] [] i2c_register_driver+0x4c/0xb0
[ 323.501053] [] imx219_i2c_driver_init+0x18/0x30 [imx219]
[ 323.508011] [] do_one_initcall+0x44/0x130
[ 323.513672] [] do_init_module+0x64/0x1a8
[ 323.519244] [] load_module+0x10a4/0x12d8
[ 323.524808] [] SyS_finit_module+0xd8/0xf0
[ 323.530456] [] el0_svc_naked+0x34/0x38
[ 323.535860] —[ end trace 057b63181817a026 ]—

I think you should reduce the string of the driver name to forward to get your driver up first.

OK, Thank you!