VI hasn't found active link

Hello,

We are building a camera sensor board and interfacing to the CSI port of the TX2 mother board from a third party. In our custom board we are using ADV7604 decoder for converting analog video to the parallel RGB888 1x24 format and then using FPGA which is converting that parallel RGB data into CSI format and interfacing that with CSI of the mother board from the third party. Our FPGA is not configurable.

So We modified the ADV7604 driver and compiled as a loadable module. Updated the device tree accordingly. After flashing the kernel video0 node is getting created but kernel is getting panicked at following point:

[   10.815844] adv7604 30-0020: adv7604 found @ 0x40 (i2c-2-mux (chan_id 0))

[ 10.815853] VD: Before v4l2_async_register_subdev
[ 10.815853] tegra-vi4 15700000.vi: subdev adv7604 30-0020 bound
[ 10.816126] VD: Group Id is 1
[ 10.816126] VD: Inside tegra_channel_init_subdevices function and after snprintf call
[ 10.816128] VD: Inside whileloop
[ 10.816128] VD: Before media_entity_remote_pad function call
[ 10.816188] VD: pad = null
[ 10.816189] VD: inside tegra_channel_fmt_align
[ 10.816199] VD: inside tegra_channel_fmt_align
[ 10.816199] Internal error: Accessing user space memory outside uaccess.h routines: 96000005 [#1] PREEMPT SMP
[ 10.816206] Modules linked in: adv7604(+) nvgpu bluedroid_pm ip_tables x_tables
[ 10.816210] CPU: 5 PID: 3221 Comm: systemd-udevd Not tainted 4.9.140-tegra-tegra #4
[ 10.816211] Hardware name: quill (DT)
[ 10.816213] task: ffffffc1d61fe200 task.stack: ffffffc1d62d0000
[ 10.816221] PC is at tegra_channel_populate_dev_info+0x60/0x1c0
[ 10.816223] LR is at tegra_channel_populate_dev_info+0x50/0x1c0
[ 10.816225] pc : [] lr : [] pstate: 40400045
[ 10.816226] sp : ffffffc1d62d3780
[ 10.816229] x29: ffffffc1d62d3780 x28: 0000000000000000
[ 10.816231] x27: ffffff80094b6000 x26: ffffff80094b6000
[ 10.816234] x25: 00000000009a2065 x24: ffffffc1e5294050
[ 10.816236] x23: 000000000000000a x22: ffffffc1ebbfa770
[ 10.816238] x21: ffffffc1ebbfa018 x20: ffffffc1d62d3838
[ 10.816240] x19: ffffffc1eb6b8c10 x18: 0000000000000001
[ 10.816242] x17: 0000000000000002 x16: 0000000000000000
[ 10.816244] x15: ffffffffffffffff x14: ffffffc1d62d3780
[ 10.816246] x13: ffffffc1d62d3685 x12: ffffffffffffffff
[ 10.816248] x11: ffffffc1d62d3640 x10: ffffffc1d62d3640
[ 10.816250] x9 : 0000000000000042 x8 : 0000000000000002
[ 10.816252] x7 : ffffff8008fb6dc8 x6 : 0000000000000083
[ 10.816254] x5 : 000000000000008d x4 : 0000000000000001
[ 10.816256] x3 : 0000000000000000 x2 : 0000000000000000
[ 10.816257] x1 : 0000000000000000 x0 : 0000000000000000

[ 10.816260] Process systemd-udevd (pid: 3221, stack limit = 0xffffffc1d62d0000)
[ 10.816261] Call trace:
[ 10.816265] [] tegra_channel_populate_dev_info+0x60/0x1c0
[ 10.816267] [] tegra_channel_init_subdevices+0x25c/0x850
[ 10.816269] [] tegra_vi_graph_notify_complete+0x328/0x6d8
[ 10.816273] [] v4l2_async_test_notify+0x104/0x120
[ 10.816275] [] v4l2_async_register_subdev+0x88/0x100
[ 10.816286] [] adv76xx_probe.part.6+0xce4/0xea0 [adv7604]
[ 10.816294] [] adv76xx_probe+0x60/0x70 [adv7604]
[ 10.816297] [] i2c_device_probe+0x144/0x258
[ 10.816301] [] driver_probe_device+0xd8/0x408
[ 10.816303] [] __driver_attach+0xdc/0x128
[ 10.816306] [] bus_for_each_dev+0x5c/0xa8
[ 10.816308] [] driver_attach+0x30/0x40
[ 10.816310] [] bus_add_driver+0x20c/0x2a8
[ 10.816312] [] driver_register+0x6c/0x110
[ 10.816314] [] i2c_register_driver+0x4c/0xb0
[ 10.816322] [] adv76xx_driver_init+0x14/0x30 [adv7604]
[ 10.816325] [] do_one_initcall+0x44/0x130
[ 10.816329] [] do_init_module+0x64/0x1a8
[ 10.816332] [] load_module+0x10a4/0x12d8
[ 10.816334] [] SyS_finit_module+0xd8/0xf0
[ 10.816336] [] __sys_trace_return+0x0/0x4
[ 10.816340] —[ end trace 4440dd5658edb83d ]—
[ 10.860624] CAN device driver interface

I tried to trace the problem area by printk() and came up with conclusion that problem is in sources/kernel/nvidia/drivers/media/platform/tegra/camera/vi/channel.c file . Inside this file there is a function tegra_channel_init_subdevices() in which there is function call:

pad = media_entity_remote_pad(pad);

which return value is NULL; that is creating the problem. As shown in the log: Internal error: Accessing user space memory outside uaccess.h routines it is because of this NULL return.

I referred this link Media Controller framework and understand the meaning as mentioned below:

struct media_pad * media_entity_remote_pad(const struct media_pad * pad)

Find the pad at the remote end of a link

Parameters

const struct media_pad * pad
Pad at the local end of the link

Description

Search for a remote pad connected to the given pad by iterating over all links originating or terminating at that pad until an enabled link is found.

Return

returns a pointer to the pad at the remote end of the first found enabled link, or NULL if no enabled link has been found.

So as per my understanding VI is trying to search for enabled link but not getting anyone of it. Here is my pad initialisation code snippet:

state->source_pad = state->info->num_dv_ports
		  + (state->info->has_afe ? 2 : 0);
for (i = 0; i < state->source_pad; ++i){
	state->pads[i].flags = MEDIA_PAD_FL_SINK;
	printk(" VD: Inside the for loop counting MEDIA_PAD_FL_SINK ");
}
state->pads[state->source_pad].flags = MEDIA_PAD_FL_SOURCE;
sd->entity.obj_type = MEDIA_ENTITY_TYPE_V4L2_SUBDEV;
sd->entity.function = MEDIA_ENT_F_CAM_HW;

err = media_entity_pads_init(&sd->entity, state->source_pad + 1,
			state->pads);

Could you please explain me why VI is not able to find any enable link as I enabled the source pad in the AV7604 driver? What the parameters is there VI is looking for? Please find the attached device tree and tell us if any changes is required.

vikas.txt (6.5 KB)

Thanks and Regards,
Vikas Dwivedi

hello vikas.wfh,

you may review the Port bindings for the VI, NvCSI, and sensor modules;
please also verify the port binding results by checking media device information.

may also I have your confirmation that the sensor works or not before you compile the driver as a loadable module. (i.e. compile as built-in driver).
there’s developer guide, Loadable Kernel Module (LKM) you may also refer to.
thanks

Hello JerryChang,

Here is my port binding result by command:
sds@sds-desktop:~$ media-ctl -p -d /dev/media0
Media controller API version 0.1.0

Media device information

driver tegra-vi4
model NVIDIA Tegra Video Input Device
serial
bus info
hw revision 0x3
driver version 0.0.0

Device topology

  • entity 1: 150c0000.nvcsi–2 (2 pads, 1 link)
    type V4L2 subdev subtype Unknown flags 0
    pad0: Sink
    pad1: Source
    -> “vi-output, 150c0000.nvcsi–2”:0 [ENABLED]

  • entity 4: 150c0000.nvcsi–1 (2 pads, 0 link)
    type V4L2 subdev subtype Unknown flags 0
    pad0: Sink
    pad1: Source

  • entity 7: adv7604 30-0020 (7 pads, 0 link)
    type V4L2 subdev subtype Unknown flags 0
    pad0: Sink
    pad1: Sink
    pad2: Sink
    pad3: Sink
    pad4: Sink
    pad5: Sink
    pad6: Source

  • entity 15: vi-output, 150c0000.nvcsi–2 (1 pad, 1 link)
    type Node subtype V4L flags 0
    device node name /dev/video0
    pad0: Sink
    <- “150c0000.nvcsi–2”:1 [ENABLED]

After comparing with Port binding verification we came to know in the entity 1 nvcsi is not getting binded by ADV7604 source pad.

Please make me understand what we are missing or doing wrong ? I have attached my device tree in the previous post, Please have a look and correct me how I can solve this problem.

Thanks and Regards,

Vikas Dwivedi

hello vikas.wfh,

please revise your device tree settings,
you should have port binding as following,
for example,

adv7604 --> NvCSI --> VI

due to you have to compile kernel sources to generated dtb file.
you may disassembler the output dtb file into text file for quick checking,
for example,
$ dtc -I dtb -O dts -o output.txt tegra186-quill-p3310-1000-c03-00-base.dtb

Hi JerryChang,

Thank you for your kind help.

Problem get resolved now after understanding the Port bindings and verify the port binding results concept. Actually in my device 7 pads is there: 6 sink pad and one source pad. I initialized the 7 ports for every pads and node is getting created now without any panic.

Note: My system is having dual channel video mechanism so do not get confused with multiple entity.

Please find the media device information:

*Media controller API version 0.1.0

Media device information

driver tegra-vi4
model NVIDIA Tegra Video Input Device
serial
bus info
hw revision 0x3
driver version 0.0.0

Device topology

  • entity 1: 150c0000.nvcsi–2 (2 pads, 2 links)
    type V4L2 subdev subtype Unknown flags 0
    device node name /dev/v4l-subdev0
    pad0: Sink
    <- “adv7604 30-0020”:6 [ENABLED]
    pad1: Source
    -> “vi-output, adv7604 30-0020”:0 [ENABLED]

  • entity 4: adv7604 30-0020 (7 pads, 1 link)
    type V4L2 subdev subtype Unknown flags 0
    device node name /dev/v4l-subdev1
    pad0: Sink
    [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000 stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
    pad1: Sink
    [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000 stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
    pad2: Sink
    [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000 stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
    pad3: Sink
    [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000 stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
    pad4: Sink
    [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000 stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
    pad5: Sink
    [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000 stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
    pad6: Source
    [fmt:RGB888_1X24/1600x1200 field:none colorspace:srgb
    crop.bounds:(0,0)/1600x1200
    crop:(0,0)/1600x1200]
    [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000 stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
    [dv.query:no-link]
    [dv.current:BT.656/1120 1600x1200p60 (2160x1250) stds:DMT flags:]
    -> “150c0000.nvcsi–2”:0 [ENABLED]

  • entity 12: vi-output, adv7604 30-0020 (1 pad, 1 link)
    type Node subtype V4L flags 0
    device node name /dev/video0
    pad0: Sink
    <- “150c0000.nvcsi–2”:1 [ENABLED]

  • entity 24: 150c0000.nvcsi–1 (2 pads, 2 links)
    type V4L2 subdev subtype Unknown flags 0
    device node name /dev/v4l-subdev2
    pad0: Sink
    <- “adv7604 32-0020”:6 [ENABLED]
    pad1: Source
    -> “vi-output, adv7604 32-0020”:0 [ENABLED]

  • entity 27: adv7604 32-0020 (7 pads, 1 link)
    type V4L2 subdev subtype Unknown flags 0
    device node name /dev/v4l-subdev3
    pad0: Sink
    [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000 stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
    pad1: Sink
    [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000 stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
    pad2: Sink
    [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000 stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
    pad3: Sink
    [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000 stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
    pad4: Sink
    [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000 stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
    pad5: Sink
    [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000 stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
    pad6: Source
    [fmt:RGB888_1X24/1600x1200 field:none colorspace:srgb
    crop.bounds:(0,0)/1600x1200
    crop:(0,0)/1600x1200]
    [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000 stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
    [dv.query:no-link]
    [dv.current:BT.656/1120 1600x1200p60 (2160x1250) stds:DMT flags:]
    -> “150c0000.nvcsi–1”:0 [ENABLED]

  • entity 35: vi-output, adv7604 32-0020 (1 pad, 1 link)
    type Node subtype V4L flags 0
    device node name /dev/video1
    pad0: Sink
    <- “150c0000.nvcsi–1”:1 [ENABLED]

You can refer my device tree: tegra186-tx2-ADV7604-2CAM_updated.txt (9.3 KB)