2020-03-23 17:53:48

by Sowjanya Komatineni

[permalink] [raw]
Subject: [RFC PATCH v5 0/9] Add Tegra driver for video capture

This series adds Tegra210 VI and CSI driver for built-in test pattern
generator (TPG) capture.

Tegra210 supports max 6 channels on VI and 6 ports on CSI where each
CSI port is one-to-one mapped to VI channel for video capture.

This series has TPG support only where it creates hard media links
between CSI subdevice and VI video device without device graphs.

v4l2-compliance results are available below the patch diff.

[v5]: Includes,
- v4 feedback
- fix for venc powergate mc reset order.
- fix to have unbind and bind work during v4l2-ctl sleep and streaming.

[v4]: Includes,
- v3 feedback changes and some improvements
- Fixes tegra_channel_buffer struct to use v4l2 buffer as first
member. This also fixes crash of unable to handle kernel write
to read-only memory.
- Uses separate host1x sync ids for frame start and memory write
ack as single sync id for both can cause sync loss between exact
frame start and memory write ack events.
- Uses client managed host1x syncpoints.
- Includes fix to increment syncpoint counter to match cached value
to synchronize in case of timeouts or missed hardware triggers.
- Frame start and memory write ack syncpoint FIFO's are of size 2.
So, updated capture logic to avoid adding more than 2 sync point
condition requests to FIFOs to avoid overflow.
- Implemented PM ops for runtime suspend and resume along with generic
power domains to allow proper power gate and ungate sequencing along
with MC VI flush during power gate.
- Fixed Tegra210 device tree sor power domain clocks.
- Added missing reset-cells to mc node.

[v3]: Includes,
- video device node handling set/get formats of all devices
in the pipeline.
- Removed subdev nodes.
- Fixed frame sync timeout issue due to CSI clocks not properly
set for corresponding blocks.
- uses minimum 3 buffers to be queued to fixed memory race between
DMA writes and userspace reads causing kernel hang reporting
kernel write to read-only memory.
- Improved capture threads and done threads to avoid possible
race conditions and added recovery incase of frame sync timeout.
- Passes all the V4L compliance tests.

[v2]: Includes,
- v0 feedback
- Merged files to have Tegra specific separately
- Moved CSI device as child to VI as Tegra210 CSI is
part of VI sharing same host interface and register
space.
- Added link_validate for format validation.
- Fixes for passing v4l2-compliance for media, video,
and subdevices.

[v1]: Includes,
- Adds CSI TPG clock to Tegra210 clock driver
- Host1x video driver with VI and CSI clients.
- Support for Tegra210 only.
- VI CSI TPG support with hard media links in driver.
- Video formats supported by Tegra210 VI
- CSI TPG supported video formats


Sowjanya Komatineni (9):
arm64: tegra: Fix sor powergate clocks and reset
arm64: tegra: Add reset-cells to mc
dt-bindings: clock: tegra: Add clk id for CSI TPG clock
clk: tegra: Add Tegra210 CSI TPG clock gate
dt-binding: tegra: Add VI and CSI bindings
media: tegra: Add Tegra210 Video input driver
MAINTAINERS: Add Tegra Video driver section
dt-bindings: reset: Add ID for Tegra210 VI reset
arm64: tegra: Add Tegra VI CSI support in device tree

.../display/tegra/nvidia,tegra20-host1x.txt | 67 +-
MAINTAINERS | 10 +
arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi | 10 +
arch/arm64/boot/dts/nvidia/tegra210.dtsi | 51 +-
drivers/clk/tegra/clk-tegra210.c | 7 +
drivers/staging/media/Kconfig | 2 +
drivers/staging/media/Makefile | 1 +
drivers/staging/media/tegra/Kconfig | 10 +
drivers/staging/media/tegra/Makefile | 8 +
drivers/staging/media/tegra/TODO | 10 +
drivers/staging/media/tegra/tegra-common.h | 263 +++++
drivers/staging/media/tegra/tegra-csi.c | 522 ++++++++++
drivers/staging/media/tegra/tegra-csi.h | 118 +++
drivers/staging/media/tegra/tegra-vi.c | 1058 ++++++++++++++++++++
drivers/staging/media/tegra/tegra-vi.h | 83 ++
drivers/staging/media/tegra/tegra-video.c | 129 +++
drivers/staging/media/tegra/tegra-video.h | 32 +
drivers/staging/media/tegra/tegra210.c | 754 ++++++++++++++
drivers/staging/media/tegra/tegra210.h | 192 ++++
include/dt-bindings/clock/tegra210-car.h | 2 +-
include/dt-bindings/reset/tegra210-car.h | 1 +
21 files changed, 3313 insertions(+), 17 deletions(-)
create mode 100644 drivers/staging/media/tegra/Kconfig
create mode 100644 drivers/staging/media/tegra/Makefile
create mode 100644 drivers/staging/media/tegra/TODO
create mode 100644 drivers/staging/media/tegra/tegra-common.h
create mode 100644 drivers/staging/media/tegra/tegra-csi.c
create mode 100644 drivers/staging/media/tegra/tegra-csi.h
create mode 100644 drivers/staging/media/tegra/tegra-vi.c
create mode 100644 drivers/staging/media/tegra/tegra-vi.h
create mode 100644 drivers/staging/media/tegra/tegra-video.c
create mode 100644 drivers/staging/media/tegra/tegra-video.h
create mode 100644 drivers/staging/media/tegra/tegra210.c
create mode 100644 drivers/staging/media/tegra/tegra210.h

v4l2-compliance SHA: e7402fb758fd106955c3b7d5a5e961d1cb606f4a, 32 bits, 32-bit time_t

Compliance test for tegra-video device /dev/media0:

Media Driver Info:
Driver name : tegra-video
Model : NVIDIA Tegra Video Input Device
Serial :
Bus info : platform:54080000.vi
Media version : 5.6.0
Hardware revision: 0x00000003 (3)
Driver version : 5.6.0

Required ioctls:
test MEDIA_IOC_DEVICE_INFO: OK

Allow for multiple opens:
test second /dev/media0 open: OK
test MEDIA_IOC_DEVICE_INFO: OK
test for unlimited opens: OK

Media Controller ioctls:
test MEDIA_IOC_G_TOPOLOGY: OK
Entities: 12 Interfaces: 6 Pads: 12 Links: 12
test MEDIA_IOC_ENUM_ENTITIES/LINKS: OK
test MEDIA_IOC_SETUP_LINK: OK
test invalid ioctls: OK

Total for tegra-video device /dev/media0: 8, Succeeded: 8, Failed: 0, Warnings: 0
--------------------------------------------------------------------------------
Compliance test for tegra-video device /dev/video0:

Driver Info:
Driver name : tegra-video
Card type : 54080000.vi-output-0
Bus info : platform:54080000.vi
Driver version : 5.6.0
Capabilities : 0x85200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x05200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Media Driver Info:
Driver name : tegra-video
Model : NVIDIA Tegra Video Input Device
Serial :
Bus info : platform:54080000.vi
Media version : 5.6.0
Hardware revision: 0x00000003 (3)
Driver version : 5.6.0
Interface Info:
ID : 0x03000003
Type : V4L Video
Entity Info:
ID : 0x00000001 (1)
Name : 54080000.vi-output-0
Function : V4L2 I/O
Pad 0x01000002 : 0: Sink
Link 0x0200001b: from remote pad 0x100001a of entity 'tpg-0': Data, Enabled

Required ioctls:
test MC information (see 'Media Driver Info' above): OK
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second /dev/video0 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

test invalid ioctls: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls (Input 0):
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 2 Private Controls: 0

Format ioctls (Input 0):
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)

Codec ioctls (Input 0):
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls (Input 0):
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Test input 0:

Streaming ioctls:
test read/write: OK
test blocking wait: OK
test MMAP (no poll): OK
test MMAP (select): OK
test MMAP (epoll): OK
test USERPTR (no poll): OK (Not Supported)
test USERPTR (select): OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device

Total for tegra-video device /dev/video0: 53, Succeeded: 53, Failed: 0, Warnings: 0
--------------------------------------------------------------------------------
Compliance test for tegra-video device /dev/video1:

Driver Info:
Driver name : tegra-video
Card type : 54080000.vi-output-1
Bus info : platform:54080000.vi
Driver version : 5.6.0
Capabilities : 0x85200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x05200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Media Driver Info:
Driver name : tegra-video
Model : NVIDIA Tegra Video Input Device
Serial :
Bus info : platform:54080000.vi
Media version : 5.6.0
Hardware revision: 0x00000003 (3)
Driver version : 5.6.0
Interface Info:
ID : 0x03000007
Type : V4L Video
Entity Info:
ID : 0x00000005 (5)
Name : 54080000.vi-output-1
Function : V4L2 I/O
Pad 0x01000006 : 0: Sink
Link 0x0200001f: from remote pad 0x100001e of entity 'tpg-1': Data, Enabled

Required ioctls:
test MC information (see 'Media Driver Info' above): OK
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second /dev/video1 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

test invalid ioctls: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls (Input 0):
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 2 Private Controls: 0

Format ioctls (Input 0):
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)

Codec ioctls (Input 0):
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls (Input 0):
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Test input 0:

Streaming ioctls:
test read/write: OK
test blocking wait: OK
test MMAP (no poll): OK
test MMAP (select): OK
test MMAP (epoll): OK
test USERPTR (no poll): OK (Not Supported)
test USERPTR (select): OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device

Total for tegra-video device /dev/video1: 53, Succeeded: 53, Failed: 0, Warnings: 0
--------------------------------------------------------------------------------
Compliance test for tegra-video device /dev/video2:

Driver Info:
Driver name : tegra-video
Card type : 54080000.vi-output-2
Bus info : platform:54080000.vi
Driver version : 5.6.0
Capabilities : 0x85200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x05200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Media Driver Info:
Driver name : tegra-video
Model : NVIDIA Tegra Video Input Device
Serial :
Bus info : platform:54080000.vi
Media version : 5.6.0
Hardware revision: 0x00000003 (3)
Driver version : 5.6.0
Interface Info:
ID : 0x0300000b
Type : V4L Video
Entity Info:
ID : 0x00000009 (9)
Name : 54080000.vi-output-2
Function : V4L2 I/O
Pad 0x0100000a : 0: Sink
Link 0x02000023: from remote pad 0x1000022 of entity 'tpg-2': Data, Enabled

Required ioctls:
test MC information (see 'Media Driver Info' above): OK
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second /dev/video2 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

test invalid ioctls: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls (Input 0):
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 2 Private Controls: 0

Format ioctls (Input 0):
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)

Codec ioctls (Input 0):
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls (Input 0):
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Test input 0:

Streaming ioctls:
test read/write: OK
test blocking wait: OK
test MMAP (no poll): OK
test MMAP (select): OK
test MMAP (epoll): OK
test USERPTR (no poll): OK (Not Supported)
test USERPTR (select): OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device

Total for tegra-video device /dev/video2: 53, Succeeded: 53, Failed: 0, Warnings: 0
--------------------------------------------------------------------------------
Compliance test for tegra-video device /dev/video3:

Driver Info:
Driver name : tegra-video
Card type : 54080000.vi-output-3
Bus info : platform:54080000.vi
Driver version : 5.6.0
Capabilities : 0x85200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x05200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Media Driver Info:
Driver name : tegra-video
Model : NVIDIA Tegra Video Input Device
Serial :
Bus info : platform:54080000.vi
Media version : 5.6.0
Hardware revision: 0x00000003 (3)
Driver version : 5.6.0
Interface Info:
ID : 0x0300000f
Type : V4L Video
Entity Info:
ID : 0x0000000d (13)
Name : 54080000.vi-output-3
Function : V4L2 I/O
Pad 0x0100000e : 0: Sink
Link 0x02000027: from remote pad 0x1000026 of entity 'tpg-3': Data, Enabled

Required ioctls:
test MC information (see 'Media Driver Info' above): OK
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second /dev/video3 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

test invalid ioctls: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls (Input 0):
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 2 Private Controls: 0

Format ioctls (Input 0):
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)

Codec ioctls (Input 0):
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls (Input 0):
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Test input 0:

Streaming ioctls:
test read/write: OK
test blocking wait: OK
test MMAP (no poll): OK
test MMAP (select): OK
test MMAP (epoll): OK
test USERPTR (no poll): OK (Not Supported)
test USERPTR (select): OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device

Total for tegra-video device /dev/video3: 53, Succeeded: 53, Failed: 0, Warnings: 0
--------------------------------------------------------------------------------
Compliance test for tegra-video device /dev/video4:

Driver Info:
Driver name : tegra-video
Card type : 54080000.vi-output-4
Bus info : platform:54080000.vi
Driver version : 5.6.0
Capabilities : 0x85200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x05200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Media Driver Info:
Driver name : tegra-video
Model : NVIDIA Tegra Video Input Device
Serial :
Bus info : platform:54080000.vi
Media version : 5.6.0
Hardware revision: 0x00000003 (3)
Driver version : 5.6.0
Interface Info:
ID : 0x03000013
Type : V4L Video
Entity Info:
ID : 0x00000011 (17)
Name : 54080000.vi-output-4
Function : V4L2 I/O
Pad 0x01000012 : 0: Sink
Link 0x0200002b: from remote pad 0x100002a of entity 'tpg-4': Data, Enabled

Required ioctls:
test MC information (see 'Media Driver Info' above): OK
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second /dev/video4 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

test invalid ioctls: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls (Input 0):
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 2 Private Controls: 0

Format ioctls (Input 0):
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)

Codec ioctls (Input 0):
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls (Input 0):
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Test input 0:

Streaming ioctls:
test read/write: OK
test blocking wait: OK
test MMAP (no poll): OK
test MMAP (select): OK
test MMAP (epoll): OK
test USERPTR (no poll): OK (Not Supported)
test USERPTR (select): OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device

Total for tegra-video device /dev/video4: 53, Succeeded: 53, Failed: 0, Warnings: 0
--------------------------------------------------------------------------------
Compliance test for tegra-video device /dev/video5:

Driver Info:
Driver name : tegra-video
Card type : 54080000.vi-output-5
Bus info : platform:54080000.vi
Driver version : 5.6.0
Capabilities : 0x85200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x05200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Media Driver Info:
Driver name : tegra-video
Model : NVIDIA Tegra Video Input Device
Serial :
Bus info : platform:54080000.vi
Media version : 5.6.0
Hardware revision: 0x00000003 (3)
Driver version : 5.6.0
Interface Info:
ID : 0x03000017
Type : V4L Video
Entity Info:
ID : 0x00000015 (21)
Name : 54080000.vi-output-5
Function : V4L2 I/O
Pad 0x01000016 : 0: Sink
Link 0x0200002f: from remote pad 0x100002e of entity 'tpg-5': Data, Enabled

Required ioctls:
test MC information (see 'Media Driver Info' above): OK
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second /dev/video5 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

test invalid ioctls: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls (Input 0):
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 2 Private Controls: 0

Format ioctls (Input 0):
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)

Codec ioctls (Input 0):
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls (Input 0):
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)

Test input 0:

Streaming ioctls:
test read/write: OK
test blocking wait: OK
test MMAP (no poll): OK
test MMAP (select): OK
test MMAP (epoll): OK
test USERPTR (no poll): OK (Not Supported)
test USERPTR (select): OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device

Total for tegra-video device /dev/video5: 53, Succeeded: 53, Failed: 0, Warnings: 0

Grand Total for tegra-video device /dev/media0: 326, Succeeded: 326, Failed: 0, Warnings: 0

--
2.7.4


2020-03-23 17:54:17

by Sowjanya Komatineni

[permalink] [raw]
Subject: [RFC PATCH v5 5/9] dt-binding: tegra: Add VI and CSI bindings

Tegra contains VI controller which can support up to 6 MIPI CSI
camera sensors.

Each Tegra CSI port from CSI unit can be one-to-one mapper to
VI channel and can capture from an external camera sensor or
from built-in test pattern generator.

This patch adds dt-bindings for Tegra VI and CSI.

Signed-off-by: Sowjanya Komatineni <[email protected]>
---
.../display/tegra/nvidia,tegra20-host1x.txt | 67 +++++++++++++++++-----
1 file changed, 54 insertions(+), 13 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
index 9999255..9421569 100644
--- a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
+++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
@@ -40,14 +40,25 @@ of the following host1x client modules:

Required properties:
- compatible: "nvidia,tegra<chip>-vi"
- - reg: Physical base address and length of the controller's registers.
+ - reg: Physical base address and length of the controller registers.
- interrupts: The interrupt outputs from the controller.
- - clocks: Must contain one entry, for the module clock.
+ - clocks: Must contain an entry for the module clock "vi"
See ../clocks/clock-bindings.txt for details.
- - resets: Must contain an entry for each entry in reset-names.
- See ../reset/reset.txt for details.
- - reset-names: Must include the following entries:
- - vi
+ - power-domains: Must include venc powergate node as vi is in VE partition.
+
+ Tegra210 has CSI part of VI sharing same host interface and register
+ space. So, VI device node should have CSI child node.
+
+ - csi: mipi csi interface to vi
+
+ Required properties:
+ - compatible: "nvidia,tegra<chip>-csi"
+ - reg: Physical base address offset to parent and length of the controller
+ registers.
+ - clocks: Must contain entries csi, cilab, cilcd, cile clocks.
+ See ../clocks/clock-bindings.txt for details.
+ - power-domains: Must include sor powergate node as csicil is in
+ SOR partition.

- epp: encoder pre-processor

@@ -309,13 +320,43 @@ Example:
reset-names = "mpe";
};

- vi {
- compatible = "nvidia,tegra20-vi";
- reg = <0x54080000 0x00040000>;
- interrupts = <0 69 0x04>;
- clocks = <&tegra_car TEGRA20_CLK_VI>;
- resets = <&tegra_car 100>;
- reset-names = "vi";
+ vi@54080000 {
+ compatible = "nvidia,tegra210-vi";
+ reg = <0x0 0x54080000 0x0 0x700>;
+ interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
+ assigned-clocks = <&tegra_car TEGRA210_CLK_VI>;
+ assigned-clock-parents = <&tegra_car TEGRA210_CLK_PLL_C4_OUT0>;
+
+ clocks = <&tegra_car TEGRA210_CLK_VI>;
+ clock-names = "vi";
+ power-domains = <&pd_venc>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ ranges = <0x0 0x0 0x54080000 0x2000>;
+
+ csi@838 {
+ compatible = "nvidia,tegra210-csi";
+ reg = <0x838 0x1300>;
+ assigned-clocks = <&tegra_car TEGRA210_CLK_CILAB>,
+ <&tegra_car TEGRA210_CLK_CILCD>,
+ <&tegra_car TEGRA210_CLK_CILE>;
+ assigned-clock-parents = <&tegra_car TEGRA210_CLK_PLL_P>,
+ <&tegra_car TEGRA210_CLK_PLL_P>,
+ <&tegra_car TEGRA210_CLK_PLL_P>;
+ assigned-clock-rates = <102000000>,
+ <102000000>,
+ <102000000>;
+
+ clocks = <&tegra_car TEGRA210_CLK_CSI>,
+ <&tegra_car TEGRA210_CLK_CILAB>,
+ <&tegra_car TEGRA210_CLK_CILCD>,
+ <&tegra_car TEGRA210_CLK_CILE>;
+ clock-names = "csi", "cilab", "cilcd", "cile";
+ power-domains = <&pd_sor>;
+ };
+
};

epp {
--
2.7.4

2020-03-23 17:55:04

by Sowjanya Komatineni

[permalink] [raw]
Subject: [RFC PATCH v5 3/9] dt-bindings: clock: tegra: Add clk id for CSI TPG clock

Tegra210 uses PLLD out internally for CSI TPG.

This patch adds clk id for this CSI TPG clock from PLLD.

Acked-by: Stephen Boyd <[email protected]>
Signed-off-by: Sowjanya Komatineni <[email protected]>
---
include/dt-bindings/clock/tegra210-car.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/dt-bindings/clock/tegra210-car.h b/include/dt-bindings/clock/tegra210-car.h
index 7a8f10b..d8909e0 100644
--- a/include/dt-bindings/clock/tegra210-car.h
+++ b/include/dt-bindings/clock/tegra210-car.h
@@ -351,7 +351,7 @@
#define TEGRA210_CLK_PLL_P_OUT_XUSB 317
#define TEGRA210_CLK_XUSB_SSP_SRC 318
#define TEGRA210_CLK_PLL_RE_OUT1 319
-/* 320 */
+#define TEGRA210_CLK_CSI_TPG 320
/* 321 */
#define TEGRA210_CLK_ISP 322
#define TEGRA210_CLK_PLL_A_OUT_ADSP 323
--
2.7.4

2020-03-23 17:55:04

by Sowjanya Komatineni

[permalink] [raw]
Subject: [RFC PATCH v5 1/9] arm64: tegra: Fix sor powergate clocks and reset

Tegra210 device tree lists csi clock and reset under SOR powergate
node.

But Tegra210 has csicil in SOR partition and csi in VENC partition.

So, this patch includes fix for sor powergate node.

Signed-off-by: Sowjanya Komatineni <[email protected]>
---
arch/arm64/boot/dts/nvidia/tegra210.dtsi | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/nvidia/tegra210.dtsi b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
index 64c46ce..d0eff92 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
@@ -796,7 +796,9 @@
pd_sor: sor {
clocks = <&tegra_car TEGRA210_CLK_SOR0>,
<&tegra_car TEGRA210_CLK_SOR1>,
- <&tegra_car TEGRA210_CLK_CSI>,
+ <&tegra_car TEGRA210_CLK_CILAB>,
+ <&tegra_car TEGRA210_CLK_CILCD>,
+ <&tegra_car TEGRA210_CLK_CILE>,
<&tegra_car TEGRA210_CLK_DSIA>,
<&tegra_car TEGRA210_CLK_DSIB>,
<&tegra_car TEGRA210_CLK_DPAUX>,
@@ -804,7 +806,6 @@
<&tegra_car TEGRA210_CLK_MIPI_CAL>;
resets = <&tegra_car TEGRA210_CLK_SOR0>,
<&tegra_car TEGRA210_CLK_SOR1>,
- <&tegra_car TEGRA210_CLK_CSI>,
<&tegra_car TEGRA210_CLK_DSIA>,
<&tegra_car TEGRA210_CLK_DSIB>,
<&tegra_car TEGRA210_CLK_DPAUX>,
--
2.7.4

2020-03-23 17:55:31

by Sowjanya Komatineni

[permalink] [raw]
Subject: [RFC PATCH v5 9/9] arm64: tegra: Add Tegra VI CSI support in device tree

Tegra210 contains VI controller for video input capture from MIPI
CSI camera sensors and also supports built-in test pattern generator.

CSI ports can be one-to-one mapped to VI channels for capturing from
an external sensor or from built-in test pattern generator.

This patch adds support for VI and CSI and enables them in Tegra210
device tree.

Signed-off-by: Sowjanya Komatineni <[email protected]>
---
arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi | 10 ++++++
arch/arm64/boot/dts/nvidia/tegra210.dtsi | 45 +++++++++++++++++++++++++-
2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi b/arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi
index 313a4c2..b57d837 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi
@@ -14,6 +14,16 @@
status = "okay";
};

+ vi@54080000 {
+ status = "okay";
+
+ avdd-dsi-csi-supply = <&vdd_dsi_csi>;
+
+ csi@838 {
+ status = "okay";
+ };
+ };
+
sor@54580000 {
status = "okay";

diff --git a/arch/arm64/boot/dts/nvidia/tegra210.dtsi b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
index 5b1dfd8..2deba87 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
@@ -137,9 +137,43 @@

vi@54080000 {
compatible = "nvidia,tegra210-vi";
- reg = <0x0 0x54080000 0x0 0x00040000>;
+ reg = <0x0 0x54080000 0x0 0x700>;
interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
status = "disabled";
+ assigned-clocks = <&tegra_car TEGRA210_CLK_VI>;
+ assigned-clock-parents = <&tegra_car TEGRA210_CLK_PLL_C4_OUT0>;
+
+ clocks = <&tegra_car TEGRA210_CLK_VI>;
+ clock-names = "vi";
+ power-domains = <&pd_venc>;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ ranges = <0x0 0x0 0x54080000 0x2000>;
+
+ csi@838 {
+ compatible = "nvidia,tegra210-csi";
+ reg = <0x838 0x1300>;
+ status = "disabled";
+ assigned-clocks = <&tegra_car TEGRA210_CLK_CILAB>,
+ <&tegra_car TEGRA210_CLK_CILCD>,
+ <&tegra_car TEGRA210_CLK_CILE>;
+ assigned-clock-parents = <&tegra_car TEGRA210_CLK_PLL_P>,
+ <&tegra_car TEGRA210_CLK_PLL_P>,
+ <&tegra_car TEGRA210_CLK_PLL_P>;
+ assigned-clock-rates = <102000000>,
+ <102000000>,
+ <102000000>;
+
+ clocks = <&tegra_car TEGRA210_CLK_CSI>,
+ <&tegra_car TEGRA210_CLK_CILAB>,
+ <&tegra_car TEGRA210_CLK_CILCD>,
+ <&tegra_car TEGRA210_CLK_CILE>;
+ clock-names = "csi", "cilab", "cilcd", "cile";
+ power-domains = <&pd_sor>;
+ };
+
};

tsec@54100000 {
@@ -839,6 +873,15 @@
reset-names = "vic";
#power-domain-cells = <0>;
};
+
+ pd_venc: venc {
+ clocks = <&tegra_car TEGRA210_CLK_VI>,
+ <&tegra_car TEGRA210_CLK_CSI>;
+ resets = <&mc TEGRA210_MC_RESET_VI>,
+ <&tegra_car TEGRA210_RST_VI>,
+ <&tegra_car TEGRA210_CLK_CSI>;
+ #power-domain-cells = <0>;
+ };
};

sdmmc1_3v3: sdmmc1-3v3 {
--
2.7.4

2020-03-24 19:19:42

by Dmitry Osipenko

[permalink] [raw]
Subject: Re: [RFC PATCH v5 9/9] arm64: tegra: Add Tegra VI CSI support in device tree

23.03.2020 20:52, Sowjanya Komatineni пишет:
...
> + pd_venc: venc {
> + clocks = <&tegra_car TEGRA210_CLK_VI>,
> + <&tegra_car TEGRA210_CLK_CSI>;
> + resets = <&mc TEGRA210_MC_RESET_VI>,

The MC resetting should be needed only for a hardware hot-resetting. It
should be wrong to add it to the power domain.

> + <&tegra_car TEGRA210_RST_VI>,
> + <&tegra_car TEGRA210_CLK_CSI>;
> + #power-domain-cells = <0>;
> + };
> };

2020-03-24 19:20:45

by Dmitry Osipenko

[permalink] [raw]
Subject: Re: [RFC PATCH v5 5/9] dt-binding: tegra: Add VI and CSI bindings

23.03.2020 20:52, Sowjanya Komatineni пишет:
> Tegra contains VI controller which can support up to 6 MIPI CSI
> camera sensors.
>
> Each Tegra CSI port from CSI unit can be one-to-one mapper to
> VI channel and can capture from an external camera sensor or
> from built-in test pattern generator.
>
> This patch adds dt-bindings for Tegra VI and CSI.
>
> Signed-off-by: Sowjanya Komatineni <[email protected]>
> ---
> .../display/tegra/nvidia,tegra20-host1x.txt | 67 +++++++++++++++++-----
> 1 file changed, 54 insertions(+), 13 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
> index 9999255..9421569 100644
> --- a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
> +++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
> @@ -40,14 +40,25 @@ of the following host1x client modules:
>
> Required properties:
> - compatible: "nvidia,tegra<chip>-vi"
> - - reg: Physical base address and length of the controller's registers.
> + - reg: Physical base address and length of the controller registers.
> - interrupts: The interrupt outputs from the controller.
> - - clocks: Must contain one entry, for the module clock.
> + - clocks: Must contain an entry for the module clock "vi"
> See ../clocks/clock-bindings.txt for details.

> - - resets: Must contain an entry for each entry in reset-names.
> - See ../reset/reset.txt for details.
> - - reset-names: Must include the following entries:
> - - vi

This should be a wrong change because ARM32 Tegra SoCs do not use power
domain.

> + - power-domains: Must include venc powergate node as vi is in VE partition.

2020-03-24 21:05:35

by Sowjanya Komatineni

[permalink] [raw]
Subject: Re: [RFC PATCH v5 9/9] arm64: tegra: Add Tegra VI CSI support in device tree


On 3/24/20 12:19 PM, Dmitry Osipenko wrote:
> External email: Use caution opening links or attachments
>
>
> 23.03.2020 20:52, Sowjanya Komatineni пишет:
> ...
>> + pd_venc: venc {
>> + clocks = <&tegra_car TEGRA210_CLK_VI>,
>> + <&tegra_car TEGRA210_CLK_CSI>;
>> + resets = <&mc TEGRA210_MC_RESET_VI>,
> The MC resetting should be needed only for a hardware hot-resetting. It
> should be wrong to add it to the power domain.
TRM recommends to do MC client hot-reset during VE power gate and ungate.
>
>> + <&tegra_car TEGRA210_RST_VI>,
>> + <&tegra_car TEGRA210_CLK_CSI>;
>> + #power-domain-cells = <0>;
>> + };
>> };

2020-03-24 21:16:54

by Sowjanya Komatineni

[permalink] [raw]
Subject: Re: [RFC PATCH v5 5/9] dt-binding: tegra: Add VI and CSI bindings


On 3/24/20 12:20 PM, Dmitry Osipenko wrote:
> External email: Use caution opening links or attachments
>
>
> 23.03.2020 20:52, Sowjanya Komatineni пишет:
>> Tegra contains VI controller which can support up to 6 MIPI CSI
>> camera sensors.
>>
>> Each Tegra CSI port from CSI unit can be one-to-one mapper to
>> VI channel and can capture from an external camera sensor or
>> from built-in test pattern generator.
>>
>> This patch adds dt-bindings for Tegra VI and CSI.
>>
>> Signed-off-by: Sowjanya Komatineni <[email protected]>
>> ---
>> .../display/tegra/nvidia,tegra20-host1x.txt | 67 +++++++++++++++++-----
>> 1 file changed, 54 insertions(+), 13 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
>> index 9999255..9421569 100644
>> --- a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
>> +++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
>> @@ -40,14 +40,25 @@ of the following host1x client modules:
>>
>> Required properties:
>> - compatible: "nvidia,tegra<chip>-vi"
>> - - reg: Physical base address and length of the controller's registers.
>> + - reg: Physical base address and length of the controller registers.
>> - interrupts: The interrupt outputs from the controller.
>> - - clocks: Must contain one entry, for the module clock.
>> + - clocks: Must contain an entry for the module clock "vi"
>> See ../clocks/clock-bindings.txt for details.
>> - - resets: Must contain an entry for each entry in reset-names.
>> - See ../reset/reset.txt for details.
>> - - reset-names: Must include the following entries:
>> - - vi
> This should be a wrong change because ARM32 Tegra SoCs do not use power
> domain.

Will update tegra20-host1x.txt to specify power-domains for Tegra210+
and to keep reset properties for prior Tegra210.

>> + - power-domains: Must include venc powergate node as vi is in VE partition.

2020-03-24 22:49:34

by Dmitry Osipenko

[permalink] [raw]
Subject: Re: [RFC PATCH v5 9/9] arm64: tegra: Add Tegra VI CSI support in device tree

25.03.2020 00:04, Sowjanya Komatineni пишет:
>
> On 3/24/20 12:19 PM, Dmitry Osipenko wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> 23.03.2020 20:52, Sowjanya Komatineni пишет:
>> ...
>>> +                     pd_venc: venc {
>>> +                             clocks = <&tegra_car TEGRA210_CLK_VI>,
>>> +                                      <&tegra_car TEGRA210_CLK_CSI>;
>>> +                             resets = <&mc TEGRA210_MC_RESET_VI>,
>> The MC resetting should be needed only for a hardware hot-resetting. It
>> should be wrong to add it to the power domain.
> TRM recommends to do MC client hot-reset during VE power gate and ungate.

Could you please tell what TRM it is and what's the page#?

2020-03-25 00:02:10

by Sowjanya Komatineni

[permalink] [raw]
Subject: Re: [RFC PATCH v5 9/9] arm64: tegra: Add Tegra VI CSI support in device tree


On 3/24/20 3:48 PM, Dmitry Osipenko wrote:
> External email: Use caution opening links or attachments
>
>
> 25.03.2020 00:04, Sowjanya Komatineni пишет:
>> On 3/24/20 12:19 PM, Dmitry Osipenko wrote:
>>> External email: Use caution opening links or attachments
>>>
>>>
>>> 23.03.2020 20:52, Sowjanya Komatineni пишет:
>>> ...
>>>> + pd_venc: venc {
>>>> + clocks = <&tegra_car TEGRA210_CLK_VI>,
>>>> + <&tegra_car TEGRA210_CLK_CSI>;
>>>> + resets = <&mc TEGRA210_MC_RESET_VI>,
>>> The MC resetting should be needed only for a hardware hot-resetting. It
>>> should be wrong to add it to the power domain.
>> TRM recommends to do MC client hot-reset during VE power gate and ungate.
> Could you please tell what TRM it is and what's the page#?
Tegra TX1 TRM Page 425, Section 12.2.7.14 Procedures for VE Power Domains

2020-03-25 00:23:43

by Dmitry Osipenko

[permalink] [raw]
Subject: Re: [RFC PATCH v5 9/9] arm64: tegra: Add Tegra VI CSI support in device tree

25.03.2020 03:01, Sowjanya Komatineni пишет:
>
> On 3/24/20 3:48 PM, Dmitry Osipenko wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> 25.03.2020 00:04, Sowjanya Komatineni пишет:
>>> On 3/24/20 12:19 PM, Dmitry Osipenko wrote:
>>>> External email: Use caution opening links or attachments
>>>>
>>>>
>>>> 23.03.2020 20:52, Sowjanya Komatineni пишет:
>>>> ...
>>>>> +                     pd_venc: venc {
>>>>> +                             clocks = <&tegra_car TEGRA210_CLK_VI>,
>>>>> +                                      <&tegra_car TEGRA210_CLK_CSI>;
>>>>> +                             resets = <&mc TEGRA210_MC_RESET_VI>,
>>>> The MC resetting should be needed only for a hardware hot-resetting. It
>>>> should be wrong to add it to the power domain.
>>> TRM recommends to do MC client hot-reset during VE power gate and
>>> ungate.
>> Could you please tell what TRM it is and what's the page#?
> Tegra TX1 TRM Page 425, Section 12.2.7.14 Procedures for VE Power Domains

Okay, thanks.

2020-03-30 10:05:20

by Hans Verkuil

[permalink] [raw]
Subject: Re: [RFC PATCH v5 0/9] Add Tegra driver for video capture

Hi Sowjanya,

On 3/23/20 6:52 PM, Sowjanya Komatineni wrote:
> This series adds Tegra210 VI and CSI driver for built-in test pattern
> generator (TPG) capture.
>
> Tegra210 supports max 6 channels on VI and 6 ports on CSI where each
> CSI port is one-to-one mapped to VI channel for video capture.
>
> This series has TPG support only where it creates hard media links
> between CSI subdevice and VI video device without device graphs.
>
> v4l2-compliance results are available below the patch diff.
>
> [v5]: Includes,
> - v4 feedback
> - fix for venc powergate mc reset order.
> - fix to have unbind and bind work during v4l2-ctl sleep and streaming.

Unfortunately, I still crash on this.

I do the following:

Run: v4l2-ctl --stream-mmap

Then, from another shell as root:

cd /sys/devices/platform/50000000.host1x/tegra-video/driver
echo -n tegra-video > unbind

I get this crash:

[ 315.691971] Unable to handle kernel NULL pointer dereference at virtual address 00000000000000b0
[ 315.700749] Mem abort info:
[ 315.703536] ESR = 0x96000004
[ 315.706587] EC = 0x25: DABT (current EL), IL = 32 bits
[ 315.711886] SET = 0, FnV = 0
[ 315.714933] EA = 0, S1PTW = 0
[ 315.718064] Data abort info:
[ 315.720936] ISV = 0, ISS = 0x00000004
[ 315.724763] CM = 0, WnR = 0
[ 315.727726] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000178ee8000
[ 315.734152] [00000000000000b0] pgd=0000000000000000
[ 315.739024] Internal error: Oops: 96000004 [#1] PREEMPT SMP
[ 315.744584] Modules linked in: r8152 nouveau lp855x_bl tegra_drm ttm
[ 315.750942] CPU: 3 PID: 2206 Comm: bash Tainted: G W 5.6.0-rc1-arm64 #118
[ 315.759017] Hardware name: NVIDIA Jetson TX1 Developer Kit (DT)
[ 315.764927] pstate: 20000085 (nzCv daIf -PAN -UAO)
[ 315.769718] pc : _raw_write_lock_irqsave+0xb0/0x2b8
[ 315.774590] lr : ida_free+0x48/0x158
[ 315.778155] sp : ffff800011d8bba0
[ 315.781462] x29: ffff800011d8bba0 x28: ffff0000f4095400
[ 315.786766] x27: 0000000000000000 x26: 0000000000000000
[ 315.792070] x25: 0000000000000000 x24: 0000000000000000
[ 315.797372] x23: ffff0000f21ad400 x22: ffff0000f5c93000
[ 315.802674] x21: ffff0000f4095400 x20: ffff0000f86b5540
[ 315.807975] x19: 0000000000000000 x18: 0000000000000000
[ 315.813276] x17: 0000000000000001 x16: 0000000000000019
[ 315.818578] x15: 000000148ccdabe2 x14: 0000000000000136
[ 315.823879] x13: 0000000000000001 x12: 00000000000003f8
[ 315.829180] x11: 0000000000000000 x10: 0000000000000000
[ 315.834482] x9 : ffff0000ff899990 x8 : ffff0000ff899000
[ 315.839784] x7 : 0000000040000000 x6 : 0000000000210d00
[ 315.845085] x5 : 0000000000000001 x4 : 0000000000000000
[ 315.850386] x3 : 00000000000000b0 x2 : 0000000000000001
[ 315.855687] x1 : 0000000000000000 x0 : 0000000000000001
[ 315.860988] Call trace:
[ 315.863432] _raw_write_lock_irqsave+0xb0/0x2b8
[ 315.867956] ida_free+0x48/0x158
[ 315.871184] __media_device_unregister_entity+0x28/0xf0
[ 315.876402] media_device_unregister+0x6c/0x148
[ 315.880927] host1x_video_remove+0x20/0x48
[ 315.885021] host1x_device_remove+0x1c/0x30
[ 315.889198] device_release_driver_internal+0xf4/0x1c0
[ 315.894325] device_driver_detach+0x14/0x20
[ 315.898503] unbind_store+0xd4/0xf8
[ 315.901986] drv_attr_store+0x20/0x30
[ 315.905645] sysfs_kf_write+0x40/0x50
[ 315.909301] kernfs_fop_write+0xf8/0x210
[ 315.913219] __vfs_write+0x18/0x40
[ 315.916616] vfs_write+0xdc/0x1c8
[ 315.919926] ksys_write+0x68/0xf0
[ 315.923235] __arm64_sys_write+0x18/0x20
[ 315.927154] el0_svc_common.constprop.0+0x68/0x160
[ 315.931936] do_el0_svc+0x20/0x80
[ 315.935246] el0_sync_handler+0x10c/0x180
[ 315.939246] el0_sync+0x140/0x180
[ 315.942560] Code: 8803fc02 35ffffa3 17fffda6 f9800071 (885ffc60)
[ 315.948644] ---[ end trace e42b943f3c1af06c ]---

The following diff fixes this:

------------------ cut here ------------------
diff --git a/drivers/staging/media/tegra/tegra-vi.c b/drivers/staging/media/tegra/tegra-vi.c
index 9714152aa6a7..53cf37af9602 100644
--- a/drivers/staging/media/tegra/tegra-vi.c
+++ b/drivers/staging/media/tegra/tegra-vi.c
@@ -583,7 +583,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan)
/* initialize the video_device */
chan->video->fops = &tegra_channel_fops;
chan->video->v4l2_dev = &vid->v4l2_dev;
- chan->video->release = video_device_release_empty;
+ chan->video->release = video_device_release;
chan->video->queue = &chan->queue;
snprintf(chan->video->name, sizeof(chan->video->name), "%s-%s-%u",
dev_name(vi->dev), "output", chan->portno);
@@ -647,6 +647,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan)
media_entity_cleanup(&chan->video->entity);
release_vdev:
video_device_release(chan->video);
+ chan->video = NULL;
return ret;
}

@@ -707,7 +708,6 @@ static void tegra_vi_channels_cleanup(struct tegra_vi *vi)
mutex_lock(&chan->video_lock);
vb2_queue_release(&chan->queue);
mutex_unlock(&chan->video_lock);
- video_device_release(chan->video);
}

if (chan->frame_start_sp)
------------------ cut here ------------------

Regards,

Hans

2020-03-30 11:02:40

by Hans Verkuil

[permalink] [raw]
Subject: Re: [RFC PATCH v5 0/9] Add Tegra driver for video capture

On 3/30/20 12:04 PM, Hans Verkuil wrote:
> Hi Sowjanya,
>
> On 3/23/20 6:52 PM, Sowjanya Komatineni wrote:
>> This series adds Tegra210 VI and CSI driver for built-in test pattern
>> generator (TPG) capture.
>>
>> Tegra210 supports max 6 channels on VI and 6 ports on CSI where each
>> CSI port is one-to-one mapped to VI channel for video capture.
>>
>> This series has TPG support only where it creates hard media links
>> between CSI subdevice and VI video device without device graphs.
>>
>> v4l2-compliance results are available below the patch diff.
>>
>> [v5]: Includes,
>> - v4 feedback
>> - fix for venc powergate mc reset order.
>> - fix to have unbind and bind work during v4l2-ctl sleep and streaming.
>
> Unfortunately, I still crash on this.
>
> I do the following:
>
> Run: v4l2-ctl --stream-mmap
>
> Then, from another shell as root:
>
> cd /sys/devices/platform/50000000.host1x/tegra-video/driver
> echo -n tegra-video > unbind
>
> I get this crash:
>
> [ 315.691971] Unable to handle kernel NULL pointer dereference at virtual address 00000000000000b0
> [ 315.700749] Mem abort info:
> [ 315.703536] ESR = 0x96000004
> [ 315.706587] EC = 0x25: DABT (current EL), IL = 32 bits
> [ 315.711886] SET = 0, FnV = 0
> [ 315.714933] EA = 0, S1PTW = 0
> [ 315.718064] Data abort info:
> [ 315.720936] ISV = 0, ISS = 0x00000004
> [ 315.724763] CM = 0, WnR = 0
> [ 315.727726] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000178ee8000
> [ 315.734152] [00000000000000b0] pgd=0000000000000000
> [ 315.739024] Internal error: Oops: 96000004 [#1] PREEMPT SMP
> [ 315.744584] Modules linked in: r8152 nouveau lp855x_bl tegra_drm ttm
> [ 315.750942] CPU: 3 PID: 2206 Comm: bash Tainted: G W 5.6.0-rc1-arm64 #118
> [ 315.759017] Hardware name: NVIDIA Jetson TX1 Developer Kit (DT)
> [ 315.764927] pstate: 20000085 (nzCv daIf -PAN -UAO)
> [ 315.769718] pc : _raw_write_lock_irqsave+0xb0/0x2b8
> [ 315.774590] lr : ida_free+0x48/0x158
> [ 315.778155] sp : ffff800011d8bba0
> [ 315.781462] x29: ffff800011d8bba0 x28: ffff0000f4095400
> [ 315.786766] x27: 0000000000000000 x26: 0000000000000000
> [ 315.792070] x25: 0000000000000000 x24: 0000000000000000
> [ 315.797372] x23: ffff0000f21ad400 x22: ffff0000f5c93000
> [ 315.802674] x21: ffff0000f4095400 x20: ffff0000f86b5540
> [ 315.807975] x19: 0000000000000000 x18: 0000000000000000
> [ 315.813276] x17: 0000000000000001 x16: 0000000000000019
> [ 315.818578] x15: 000000148ccdabe2 x14: 0000000000000136
> [ 315.823879] x13: 0000000000000001 x12: 00000000000003f8
> [ 315.829180] x11: 0000000000000000 x10: 0000000000000000
> [ 315.834482] x9 : ffff0000ff899990 x8 : ffff0000ff899000
> [ 315.839784] x7 : 0000000040000000 x6 : 0000000000210d00
> [ 315.845085] x5 : 0000000000000001 x4 : 0000000000000000
> [ 315.850386] x3 : 00000000000000b0 x2 : 0000000000000001
> [ 315.855687] x1 : 0000000000000000 x0 : 0000000000000001
> [ 315.860988] Call trace:
> [ 315.863432] _raw_write_lock_irqsave+0xb0/0x2b8
> [ 315.867956] ida_free+0x48/0x158
> [ 315.871184] __media_device_unregister_entity+0x28/0xf0
> [ 315.876402] media_device_unregister+0x6c/0x148
> [ 315.880927] host1x_video_remove+0x20/0x48
> [ 315.885021] host1x_device_remove+0x1c/0x30
> [ 315.889198] device_release_driver_internal+0xf4/0x1c0
> [ 315.894325] device_driver_detach+0x14/0x20
> [ 315.898503] unbind_store+0xd4/0xf8
> [ 315.901986] drv_attr_store+0x20/0x30
> [ 315.905645] sysfs_kf_write+0x40/0x50
> [ 315.909301] kernfs_fop_write+0xf8/0x210
> [ 315.913219] __vfs_write+0x18/0x40
> [ 315.916616] vfs_write+0xdc/0x1c8
> [ 315.919926] ksys_write+0x68/0xf0
> [ 315.923235] __arm64_sys_write+0x18/0x20
> [ 315.927154] el0_svc_common.constprop.0+0x68/0x160
> [ 315.931936] do_el0_svc+0x20/0x80
> [ 315.935246] el0_sync_handler+0x10c/0x180
> [ 315.939246] el0_sync+0x140/0x180
> [ 315.942560] Code: 8803fc02 35ffffa3 17fffda6 f9800071 (885ffc60)
> [ 315.948644] ---[ end trace e42b943f3c1af06c ]---
>
> The following diff fixes this:
>
> ------------------ cut here ------------------
> diff --git a/drivers/staging/media/tegra/tegra-vi.c b/drivers/staging/media/tegra/tegra-vi.c
> index 9714152aa6a7..53cf37af9602 100644
> --- a/drivers/staging/media/tegra/tegra-vi.c
> +++ b/drivers/staging/media/tegra/tegra-vi.c
> @@ -583,7 +583,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan)
> /* initialize the video_device */
> chan->video->fops = &tegra_channel_fops;
> chan->video->v4l2_dev = &vid->v4l2_dev;
> - chan->video->release = video_device_release_empty;
> + chan->video->release = video_device_release;
> chan->video->queue = &chan->queue;
> snprintf(chan->video->name, sizeof(chan->video->name), "%s-%s-%u",
> dev_name(vi->dev), "output", chan->portno);
> @@ -647,6 +647,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan)
> media_entity_cleanup(&chan->video->entity);
> release_vdev:
> video_device_release(chan->video);
> + chan->video = NULL;
> return ret;
> }
>
> @@ -707,7 +708,6 @@ static void tegra_vi_channels_cleanup(struct tegra_vi *vi)
> mutex_lock(&chan->video_lock);
> vb2_queue_release(&chan->queue);
> mutex_unlock(&chan->video_lock);
> - video_device_release(chan->video);
> }
>
> if (chan->frame_start_sp)
> ------------------ cut here ------------------

Note: Sakari suggested to embed struct video_device into struct tegra_vi_channel.
In that case chan->video->release should remain video_device_release_empty and
all video_device_alloc()/release() calls would have to be dropped.

Regards,

Hans

2020-03-30 16:18:13

by Sowjanya Komatineni

[permalink] [raw]
Subject: Re: [RFC PATCH v5 0/9] Add Tegra driver for video capture


On 3/30/20 4:02 AM, Hans Verkuil wrote:
> External email: Use caution opening links or attachments
>
>
> On 3/30/20 12:04 PM, Hans Verkuil wrote:
>> Hi Sowjanya,
>>
>> On 3/23/20 6:52 PM, Sowjanya Komatineni wrote:
>>> This series adds Tegra210 VI and CSI driver for built-in test pattern
>>> generator (TPG) capture.
>>>
>>> Tegra210 supports max 6 channels on VI and 6 ports on CSI where each
>>> CSI port is one-to-one mapped to VI channel for video capture.
>>>
>>> This series has TPG support only where it creates hard media links
>>> between CSI subdevice and VI video device without device graphs.
>>>
>>> v4l2-compliance results are available below the patch diff.
>>>
>>> [v5]: Includes,
>>> - v4 feedback
>>> - fix for venc powergate mc reset order.
>>> - fix to have unbind and bind work during v4l2-ctl sleep and streaming.
>> Unfortunately, I still crash on this.
>>
>> I do the following:
>>
>> Run: v4l2-ctl --stream-mmap
>>
>> Then, from another shell as root:
>>
>> cd /sys/devices/platform/50000000.host1x/tegra-video/driver
>> echo -n tegra-video > unbind
>>
>> I get this crash:
>>
>> [ 315.691971] Unable to handle kernel NULL pointer dereference at virtual address 00000000000000b0
>> [ 315.700749] Mem abort info:
>> [ 315.703536] ESR = 0x96000004
>> [ 315.706587] EC = 0x25: DABT (current EL), IL = 32 bits
>> [ 315.711886] SET = 0, FnV = 0
>> [ 315.714933] EA = 0, S1PTW = 0
>> [ 315.718064] Data abort info:
>> [ 315.720936] ISV = 0, ISS = 0x00000004
>> [ 315.724763] CM = 0, WnR = 0
>> [ 315.727726] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000178ee8000
>> [ 315.734152] [00000000000000b0] pgd=0000000000000000
>> [ 315.739024] Internal error: Oops: 96000004 [#1] PREEMPT SMP
>> [ 315.744584] Modules linked in: r8152 nouveau lp855x_bl tegra_drm ttm
>> [ 315.750942] CPU: 3 PID: 2206 Comm: bash Tainted: G W 5.6.0-rc1-arm64 #118
>> [ 315.759017] Hardware name: NVIDIA Jetson TX1 Developer Kit (DT)
>> [ 315.764927] pstate: 20000085 (nzCv daIf -PAN -UAO)
>> [ 315.769718] pc : _raw_write_lock_irqsave+0xb0/0x2b8
>> [ 315.774590] lr : ida_free+0x48/0x158
>> [ 315.778155] sp : ffff800011d8bba0
>> [ 315.781462] x29: ffff800011d8bba0 x28: ffff0000f4095400
>> [ 315.786766] x27: 0000000000000000 x26: 0000000000000000
>> [ 315.792070] x25: 0000000000000000 x24: 0000000000000000
>> [ 315.797372] x23: ffff0000f21ad400 x22: ffff0000f5c93000
>> [ 315.802674] x21: ffff0000f4095400 x20: ffff0000f86b5540
>> [ 315.807975] x19: 0000000000000000 x18: 0000000000000000
>> [ 315.813276] x17: 0000000000000001 x16: 0000000000000019
>> [ 315.818578] x15: 000000148ccdabe2 x14: 0000000000000136
>> [ 315.823879] x13: 0000000000000001 x12: 00000000000003f8
>> [ 315.829180] x11: 0000000000000000 x10: 0000000000000000
>> [ 315.834482] x9 : ffff0000ff899990 x8 : ffff0000ff899000
>> [ 315.839784] x7 : 0000000040000000 x6 : 0000000000210d00
>> [ 315.845085] x5 : 0000000000000001 x4 : 0000000000000000
>> [ 315.850386] x3 : 00000000000000b0 x2 : 0000000000000001
>> [ 315.855687] x1 : 0000000000000000 x0 : 0000000000000001
>> [ 315.860988] Call trace:
>> [ 315.863432] _raw_write_lock_irqsave+0xb0/0x2b8
>> [ 315.867956] ida_free+0x48/0x158
>> [ 315.871184] __media_device_unregister_entity+0x28/0xf0
>> [ 315.876402] media_device_unregister+0x6c/0x148
>> [ 315.880927] host1x_video_remove+0x20/0x48
>> [ 315.885021] host1x_device_remove+0x1c/0x30
>> [ 315.889198] device_release_driver_internal+0xf4/0x1c0
>> [ 315.894325] device_driver_detach+0x14/0x20
>> [ 315.898503] unbind_store+0xd4/0xf8
>> [ 315.901986] drv_attr_store+0x20/0x30
>> [ 315.905645] sysfs_kf_write+0x40/0x50
>> [ 315.909301] kernfs_fop_write+0xf8/0x210
>> [ 315.913219] __vfs_write+0x18/0x40
>> [ 315.916616] vfs_write+0xdc/0x1c8
>> [ 315.919926] ksys_write+0x68/0xf0
>> [ 315.923235] __arm64_sys_write+0x18/0x20
>> [ 315.927154] el0_svc_common.constprop.0+0x68/0x160
>> [ 315.931936] do_el0_svc+0x20/0x80
>> [ 315.935246] el0_sync_handler+0x10c/0x180
>> [ 315.939246] el0_sync+0x140/0x180
>> [ 315.942560] Code: 8803fc02 35ffffa3 17fffda6 f9800071 (885ffc60)
>> [ 315.948644] ---[ end trace e42b943f3c1af06c ]---
>>
>> The following diff fixes this:
>>
>> ------------------ cut here ------------------
>> diff --git a/drivers/staging/media/tegra/tegra-vi.c b/drivers/staging/media/tegra/tegra-vi.c
>> index 9714152aa6a7..53cf37af9602 100644
>> --- a/drivers/staging/media/tegra/tegra-vi.c
>> +++ b/drivers/staging/media/tegra/tegra-vi.c
>> @@ -583,7 +583,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan)
>> /* initialize the video_device */
>> chan->video->fops = &tegra_channel_fops;
>> chan->video->v4l2_dev = &vid->v4l2_dev;
>> - chan->video->release = video_device_release_empty;
>> + chan->video->release = video_device_release;
>> chan->video->queue = &chan->queue;
>> snprintf(chan->video->name, sizeof(chan->video->name), "%s-%s-%u",
>> dev_name(vi->dev), "output", chan->portno);
>> @@ -647,6 +647,7 @@ static int tegra_channel_init(struct tegra_vi_channel *chan)
>> media_entity_cleanup(&chan->video->entity);
>> release_vdev:
>> video_device_release(chan->video);
>> + chan->video = NULL;
>> return ret;
>> }
>>
>> @@ -707,7 +708,6 @@ static void tegra_vi_channels_cleanup(struct tegra_vi *vi)
>> mutex_lock(&chan->video_lock);
>> vb2_queue_release(&chan->queue);
>> mutex_unlock(&chan->video_lock);
>> - video_device_release(chan->video);
>> }
>>
>> if (chan->frame_start_sp)
>> ------------------ cut here ------------------
> Note: Sakari suggested to embed struct video_device into struct tegra_vi_channel.
> In that case chan->video->release should remain video_device_release_empty and
> all video_device_alloc()/release() calls would have to be dropped.

Thanks Hans. Tried several unbind/unbind not sure why it did not repro
during my testing.

video device is also part of tegra_vi_channel. So, v6 will remove
video_device_alloc and use video_device_release_empty like I had in v3.

This should help fix crash during unbind.

>
> Regards,
>
> Hans

2020-04-03 05:45:40

by Sowjanya Komatineni

[permalink] [raw]
Subject: Re: [RFC PATCH v5 0/9] Add Tegra driver for video capture


On 3/30/20 9:16 AM, Sowjanya Komatineni wrote:
>
> On 3/30/20 4:02 AM, Hans Verkuil wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> On 3/30/20 12:04 PM, Hans Verkuil wrote:
>>> Hi Sowjanya,
>>>
>>> On 3/23/20 6:52 PM, Sowjanya Komatineni wrote:
>>>> This series adds Tegra210 VI and CSI driver for built-in test pattern
>>>> generator (TPG) capture.
>>>>
>>>> Tegra210 supports max 6 channels on VI and 6 ports on CSI where each
>>>> CSI port is one-to-one mapped to VI channel for video capture.
>>>>
>>>> This series has TPG support only where it creates hard media links
>>>> between CSI subdevice and VI video device without device graphs.
>>>>
>>>> v4l2-compliance results are available below the patch diff.
>>>>
>>>> [v5]:        Includes,
>>>>       - v4 feedback
>>>>       - fix for venc powergate mc reset order.
>>>>       - fix to have unbind and bind work during v4l2-ctl sleep and
>>>> streaming.
>>> Unfortunately, I still crash on this.
>>>
>>> I do the following:
>>>
>>> Run: v4l2-ctl --stream-mmap
>>>
>>> Then, from another shell as root:
>>>
>>> cd /sys/devices/platform/50000000.host1x/tegra-video/driver
>>> echo -n tegra-video > unbind
>>>
>>> I get this crash:
>>>
>>> [  315.691971] Unable to handle kernel NULL pointer dereference at
>>> virtual address 00000000000000b0
>>> [  315.700749] Mem abort info:
>>> [  315.703536]   ESR = 0x96000004
>>> [  315.706587]   EC = 0x25: DABT (current EL), IL = 32 bits
>>> [  315.711886]   SET = 0, FnV = 0
>>> [  315.714933]   EA = 0, S1PTW = 0
>>> [  315.718064] Data abort info:
>>> [  315.720936]   ISV = 0, ISS = 0x00000004
>>> [  315.724763]   CM = 0, WnR = 0
>>> [  315.727726] user pgtable: 4k pages, 48-bit VAs,
>>> pgdp=0000000178ee8000
>>> [  315.734152] [00000000000000b0] pgd=0000000000000000
>>> [  315.739024] Internal error: Oops: 96000004 [#1] PREEMPT SMP
>>> [  315.744584] Modules linked in: r8152 nouveau lp855x_bl tegra_drm ttm
>>> [  315.750942] CPU: 3 PID: 2206 Comm: bash Tainted: G W        
>>> 5.6.0-rc1-arm64 #118
>>> [  315.759017] Hardware name: NVIDIA Jetson TX1 Developer Kit (DT)
>>> [  315.764927] pstate: 20000085 (nzCv daIf -PAN -UAO)
>>> [  315.769718] pc : _raw_write_lock_irqsave+0xb0/0x2b8
>>> [  315.774590] lr : ida_free+0x48/0x158
>>> [  315.778155] sp : ffff800011d8bba0
>>> [  315.781462] x29: ffff800011d8bba0 x28: ffff0000f4095400
>>> [  315.786766] x27: 0000000000000000 x26: 0000000000000000
>>> [  315.792070] x25: 0000000000000000 x24: 0000000000000000
>>> [  315.797372] x23: ffff0000f21ad400 x22: ffff0000f5c93000
>>> [  315.802674] x21: ffff0000f4095400 x20: ffff0000f86b5540
>>> [  315.807975] x19: 0000000000000000 x18: 0000000000000000
>>> [  315.813276] x17: 0000000000000001 x16: 0000000000000019
>>> [  315.818578] x15: 000000148ccdabe2 x14: 0000000000000136
>>> [  315.823879] x13: 0000000000000001 x12: 00000000000003f8
>>> [  315.829180] x11: 0000000000000000 x10: 0000000000000000
>>> [  315.834482] x9 : ffff0000ff899990 x8 : ffff0000ff899000
>>> [  315.839784] x7 : 0000000040000000 x6 : 0000000000210d00
>>> [  315.845085] x5 : 0000000000000001 x4 : 0000000000000000
>>> [  315.850386] x3 : 00000000000000b0 x2 : 0000000000000001
>>> [  315.855687] x1 : 0000000000000000 x0 : 0000000000000001
>>> [  315.860988] Call trace:
>>> [  315.863432]  _raw_write_lock_irqsave+0xb0/0x2b8
>>> [  315.867956]  ida_free+0x48/0x158
>>> [  315.871184]  __media_device_unregister_entity+0x28/0xf0
>>> [  315.876402]  media_device_unregister+0x6c/0x148
>>> [  315.880927]  host1x_video_remove+0x20/0x48
>>> [  315.885021]  host1x_device_remove+0x1c/0x30
>>> [  315.889198]  device_release_driver_internal+0xf4/0x1c0
>>> [  315.894325]  device_driver_detach+0x14/0x20
>>> [  315.898503]  unbind_store+0xd4/0xf8
>>> [  315.901986]  drv_attr_store+0x20/0x30
>>> [  315.905645]  sysfs_kf_write+0x40/0x50
>>> [  315.909301]  kernfs_fop_write+0xf8/0x210
>>> [  315.913219]  __vfs_write+0x18/0x40
>>> [  315.916616]  vfs_write+0xdc/0x1c8
>>> [  315.919926]  ksys_write+0x68/0xf0
>>> [  315.923235]  __arm64_sys_write+0x18/0x20
>>> [  315.927154]  el0_svc_common.constprop.0+0x68/0x160
>>> [  315.931936]  do_el0_svc+0x20/0x80
>>> [  315.935246]  el0_sync_handler+0x10c/0x180
>>> [  315.939246]  el0_sync+0x140/0x180
>>> [  315.942560] Code: 8803fc02 35ffffa3 17fffda6 f9800071 (885ffc60)
>>> [  315.948644] ---[ end trace e42b943f3c1af06c ]---
>>>
>>> The following diff fixes this:
>>>
>>> ------------------ cut here ------------------
>>> diff --git a/drivers/staging/media/tegra/tegra-vi.c
>>> b/drivers/staging/media/tegra/tegra-vi.c
>>> index 9714152aa6a7..53cf37af9602 100644
>>> --- a/drivers/staging/media/tegra/tegra-vi.c
>>> +++ b/drivers/staging/media/tegra/tegra-vi.c
>>> @@ -583,7 +583,7 @@ static int tegra_channel_init(struct
>>> tegra_vi_channel *chan)
>>>        /* initialize the video_device */
>>>        chan->video->fops = &tegra_channel_fops;
>>>        chan->video->v4l2_dev = &vid->v4l2_dev;
>>> -     chan->video->release = video_device_release_empty;
>>> +     chan->video->release = video_device_release;
>>>        chan->video->queue = &chan->queue;
>>>        snprintf(chan->video->name, sizeof(chan->video->name),
>>> "%s-%s-%u",
>>>                 dev_name(vi->dev), "output", chan->portno);
>>> @@ -647,6 +647,7 @@ static int tegra_channel_init(struct
>>> tegra_vi_channel *chan)
>>>        media_entity_cleanup(&chan->video->entity);
>>>   release_vdev:
>>>        video_device_release(chan->video);
>>> +     chan->video = NULL;
>>>        return ret;
>>>   }
>>>
>>> @@ -707,7 +708,6 @@ static void tegra_vi_channels_cleanup(struct
>>> tegra_vi *vi)
>>>                        mutex_lock(&chan->video_lock);
>>>                        vb2_queue_release(&chan->queue);
>>>                        mutex_unlock(&chan->video_lock);
>>> -                     video_device_release(chan->video);
>>>                }
>>>
>>>                if (chan->frame_start_sp)
>>> ------------------ cut here ------------------
>> Note: Sakari suggested to embed struct video_device into struct
>> tegra_vi_channel.
>> In that case chan->video->release should remain
>> video_device_release_empty and
>> all video_device_alloc()/release() calls would have to be dropped.
>
> Thanks Hans. Tried several unbind/unbind not sure why it did not repro
> during my testing.
>
> video device is also part of tegra_vi_channel. So, v6 will remove
> video_device_alloc and use video_device_release_empty like I had in v3.
>
> This should help fix crash during unbind.
>
>>
>> Regards,
>>
>>          Hans

With video device being part of the channel structure, it gets allocated
along with vi channel allocation during host1x vi client init and is
removed during channel free which happens during host1x vi client exit.

Wit this during driver unbind with video node kept opened with v4l2-ctl
sleep, it crashes during media_device_unregister_entity.

Using, separate video device allocation and freeing allocation during
video device release callback,  driver unbind works  as by the time of
entity unregister its it still available.

So, will keep allocating video device separately with video_device_alloc
and will use video_device_release call back in v6.

2020-04-03 07:20:24

by Hans Verkuil

[permalink] [raw]
Subject: Re: [RFC PATCH v5 0/9] Add Tegra driver for video capture

On 4/3/20 7:45 AM, Sowjanya Komatineni wrote:
>
> On 3/30/20 9:16 AM, Sowjanya Komatineni wrote:
>>
>> On 3/30/20 4:02 AM, Hans Verkuil wrote:
>>> External email: Use caution opening links or attachments
>>>
>>>
>>> On 3/30/20 12:04 PM, Hans Verkuil wrote:
>>>> Hi Sowjanya,
>>>>
>>>> On 3/23/20 6:52 PM, Sowjanya Komatineni wrote:
>>>>> This series adds Tegra210 VI and CSI driver for built-in test pattern
>>>>> generator (TPG) capture.
>>>>>
>>>>> Tegra210 supports max 6 channels on VI and 6 ports on CSI where each
>>>>> CSI port is one-to-one mapped to VI channel for video capture.
>>>>>
>>>>> This series has TPG support only where it creates hard media links
>>>>> between CSI subdevice and VI video device without device graphs.
>>>>>
>>>>> v4l2-compliance results are available below the patch diff.
>>>>>
>>>>> [v5]:        Includes,
>>>>>       - v4 feedback
>>>>>       - fix for venc powergate mc reset order.
>>>>>       - fix to have unbind and bind work during v4l2-ctl sleep and
>>>>> streaming.
>>>> Unfortunately, I still crash on this.
>>>>
>>>> I do the following:
>>>>
>>>> Run: v4l2-ctl --stream-mmap
>>>>
>>>> Then, from another shell as root:
>>>>
>>>> cd /sys/devices/platform/50000000.host1x/tegra-video/driver
>>>> echo -n tegra-video > unbind
>>>>
>>>> I get this crash:
>>>>
>>>> [  315.691971] Unable to handle kernel NULL pointer dereference at
>>>> virtual address 00000000000000b0
>>>> [  315.700749] Mem abort info:
>>>> [  315.703536]   ESR = 0x96000004
>>>> [  315.706587]   EC = 0x25: DABT (current EL), IL = 32 bits
>>>> [  315.711886]   SET = 0, FnV = 0
>>>> [  315.714933]   EA = 0, S1PTW = 0
>>>> [  315.718064] Data abort info:
>>>> [  315.720936]   ISV = 0, ISS = 0x00000004
>>>> [  315.724763]   CM = 0, WnR = 0
>>>> [  315.727726] user pgtable: 4k pages, 48-bit VAs,
>>>> pgdp=0000000178ee8000
>>>> [  315.734152] [00000000000000b0] pgd=0000000000000000
>>>> [  315.739024] Internal error: Oops: 96000004 [#1] PREEMPT SMP
>>>> [  315.744584] Modules linked in: r8152 nouveau lp855x_bl tegra_drm ttm
>>>> [  315.750942] CPU: 3 PID: 2206 Comm: bash Tainted: G W        
>>>> 5.6.0-rc1-arm64 #118
>>>> [  315.759017] Hardware name: NVIDIA Jetson TX1 Developer Kit (DT)
>>>> [  315.764927] pstate: 20000085 (nzCv daIf -PAN -UAO)
>>>> [  315.769718] pc : _raw_write_lock_irqsave+0xb0/0x2b8
>>>> [  315.774590] lr : ida_free+0x48/0x158
>>>> [  315.778155] sp : ffff800011d8bba0
>>>> [  315.781462] x29: ffff800011d8bba0 x28: ffff0000f4095400
>>>> [  315.786766] x27: 0000000000000000 x26: 0000000000000000
>>>> [  315.792070] x25: 0000000000000000 x24: 0000000000000000
>>>> [  315.797372] x23: ffff0000f21ad400 x22: ffff0000f5c93000
>>>> [  315.802674] x21: ffff0000f4095400 x20: ffff0000f86b5540
>>>> [  315.807975] x19: 0000000000000000 x18: 0000000000000000
>>>> [  315.813276] x17: 0000000000000001 x16: 0000000000000019
>>>> [  315.818578] x15: 000000148ccdabe2 x14: 0000000000000136
>>>> [  315.823879] x13: 0000000000000001 x12: 00000000000003f8
>>>> [  315.829180] x11: 0000000000000000 x10: 0000000000000000
>>>> [  315.834482] x9 : ffff0000ff899990 x8 : ffff0000ff899000
>>>> [  315.839784] x7 : 0000000040000000 x6 : 0000000000210d00
>>>> [  315.845085] x5 : 0000000000000001 x4 : 0000000000000000
>>>> [  315.850386] x3 : 00000000000000b0 x2 : 0000000000000001
>>>> [  315.855687] x1 : 0000000000000000 x0 : 0000000000000001
>>>> [  315.860988] Call trace:
>>>> [  315.863432]  _raw_write_lock_irqsave+0xb0/0x2b8
>>>> [  315.867956]  ida_free+0x48/0x158
>>>> [  315.871184]  __media_device_unregister_entity+0x28/0xf0
>>>> [  315.876402]  media_device_unregister+0x6c/0x148
>>>> [  315.880927]  host1x_video_remove+0x20/0x48
>>>> [  315.885021]  host1x_device_remove+0x1c/0x30
>>>> [  315.889198]  device_release_driver_internal+0xf4/0x1c0
>>>> [  315.894325]  device_driver_detach+0x14/0x20
>>>> [  315.898503]  unbind_store+0xd4/0xf8
>>>> [  315.901986]  drv_attr_store+0x20/0x30
>>>> [  315.905645]  sysfs_kf_write+0x40/0x50
>>>> [  315.909301]  kernfs_fop_write+0xf8/0x210
>>>> [  315.913219]  __vfs_write+0x18/0x40
>>>> [  315.916616]  vfs_write+0xdc/0x1c8
>>>> [  315.919926]  ksys_write+0x68/0xf0
>>>> [  315.923235]  __arm64_sys_write+0x18/0x20
>>>> [  315.927154]  el0_svc_common.constprop.0+0x68/0x160
>>>> [  315.931936]  do_el0_svc+0x20/0x80
>>>> [  315.935246]  el0_sync_handler+0x10c/0x180
>>>> [  315.939246]  el0_sync+0x140/0x180
>>>> [  315.942560] Code: 8803fc02 35ffffa3 17fffda6 f9800071 (885ffc60)
>>>> [  315.948644] ---[ end trace e42b943f3c1af06c ]---
>>>>
>>>> The following diff fixes this:
>>>>
>>>> ------------------ cut here ------------------
>>>> diff --git a/drivers/staging/media/tegra/tegra-vi.c
>>>> b/drivers/staging/media/tegra/tegra-vi.c
>>>> index 9714152aa6a7..53cf37af9602 100644
>>>> --- a/drivers/staging/media/tegra/tegra-vi.c
>>>> +++ b/drivers/staging/media/tegra/tegra-vi.c
>>>> @@ -583,7 +583,7 @@ static int tegra_channel_init(struct
>>>> tegra_vi_channel *chan)
>>>>        /* initialize the video_device */
>>>>        chan->video->fops = &tegra_channel_fops;
>>>>        chan->video->v4l2_dev = &vid->v4l2_dev;
>>>> -     chan->video->release = video_device_release_empty;
>>>> +     chan->video->release = video_device_release;
>>>>        chan->video->queue = &chan->queue;
>>>>        snprintf(chan->video->name, sizeof(chan->video->name),
>>>> "%s-%s-%u",
>>>>                 dev_name(vi->dev), "output", chan->portno);
>>>> @@ -647,6 +647,7 @@ static int tegra_channel_init(struct
>>>> tegra_vi_channel *chan)
>>>>        media_entity_cleanup(&chan->video->entity);
>>>>   release_vdev:
>>>>        video_device_release(chan->video);
>>>> +     chan->video = NULL;
>>>>        return ret;
>>>>   }
>>>>
>>>> @@ -707,7 +708,6 @@ static void tegra_vi_channels_cleanup(struct
>>>> tegra_vi *vi)
>>>>                        mutex_lock(&chan->video_lock);
>>>>                        vb2_queue_release(&chan->queue);
>>>>                        mutex_unlock(&chan->video_lock);
>>>> -                     video_device_release(chan->video);
>>>>                }
>>>>
>>>>                if (chan->frame_start_sp)
>>>> ------------------ cut here ------------------
>>> Note: Sakari suggested to embed struct video_device into struct
>>> tegra_vi_channel.
>>> In that case chan->video->release should remain
>>> video_device_release_empty and
>>> all video_device_alloc()/release() calls would have to be dropped.
>>
>> Thanks Hans. Tried several unbind/unbind not sure why it did not repro
>> during my testing.
>>
>> video device is also part of tegra_vi_channel. So, v6 will remove
>> video_device_alloc and use video_device_release_empty like I had in v3.
>>
>> This should help fix crash during unbind.
>>
>>>
>>> Regards,
>>>
>>>          Hans
>
> With video device being part of the channel structure, it gets allocated
> along with vi channel allocation during host1x vi client init and is
> removed during channel free which happens during host1x vi client exit.
>
> Wit this during driver unbind with video node kept opened with v4l2-ctl
> sleep, it crashes during media_device_unregister_entity.
>
> Using, separate video device allocation and freeing allocation during
> video device release callback,  driver unbind works  as by the time of
> entity unregister its it still available.
>
> So, will keep allocating video device separately with video_device_alloc
> and will use video_device_release call back in v6.
>

Sounds good. Add a comment before video_device_alloc() explaining why it is
used instead of embedding it in the vi channel data structure.

Regards,

Hans

2020-04-03 07:32:39

by Sowjanya Komatineni

[permalink] [raw]
Subject: Re: [RFC PATCH v5 0/9] Add Tegra driver for video capture


On 4/3/20 12:19 AM, Hans Verkuil wrote:
> External email: Use caution opening links or attachments
>
>
> On 4/3/20 7:45 AM, Sowjanya Komatineni wrote:
>> On 3/30/20 9:16 AM, Sowjanya Komatineni wrote:
>>> On 3/30/20 4:02 AM, Hans Verkuil wrote:
>>>> External email: Use caution opening links or attachments
>>>>
>>>>
>>>> On 3/30/20 12:04 PM, Hans Verkuil wrote:
>>>>> Hi Sowjanya,
>>>>>
>>>>> On 3/23/20 6:52 PM, Sowjanya Komatineni wrote:
>>>>>> This series adds Tegra210 VI and CSI driver for built-in test pattern
>>>>>> generator (TPG) capture.
>>>>>>
>>>>>> Tegra210 supports max 6 channels on VI and 6 ports on CSI where each
>>>>>> CSI port is one-to-one mapped to VI channel for video capture.
>>>>>>
>>>>>> This series has TPG support only where it creates hard media links
>>>>>> between CSI subdevice and VI video device without device graphs.
>>>>>>
>>>>>> v4l2-compliance results are available below the patch diff.
>>>>>>
>>>>>> [v5]: Includes,
>>>>>> - v4 feedback
>>>>>> - fix for venc powergate mc reset order.
>>>>>> - fix to have unbind and bind work during v4l2-ctl sleep and
>>>>>> streaming.
>>>>> Unfortunately, I still crash on this.
>>>>>
>>>>> I do the following:
>>>>>
>>>>> Run: v4l2-ctl --stream-mmap
>>>>>
>>>>> Then, from another shell as root:
>>>>>
>>>>> cd /sys/devices/platform/50000000.host1x/tegra-video/driver
>>>>> echo -n tegra-video > unbind
>>>>>
>>>>> I get this crash:
>>>>>
>>>>> [  315.691971] Unable to handle kernel NULL pointer dereference at
>>>>> virtual address 00000000000000b0
>>>>> [  315.700749] Mem abort info:
>>>>> [  315.703536]   ESR = 0x96000004
>>>>> [  315.706587]   EC = 0x25: DABT (current EL), IL = 32 bits
>>>>> [  315.711886]   SET = 0, FnV = 0
>>>>> [  315.714933]   EA = 0, S1PTW = 0
>>>>> [  315.718064] Data abort info:
>>>>> [  315.720936]   ISV = 0, ISS = 0x00000004
>>>>> [  315.724763]   CM = 0, WnR = 0
>>>>> [  315.727726] user pgtable: 4k pages, 48-bit VAs,
>>>>> pgdp=0000000178ee8000
>>>>> [  315.734152] [00000000000000b0] pgd=0000000000000000
>>>>> [  315.739024] Internal error: Oops: 96000004 [#1] PREEMPT SMP
>>>>> [  315.744584] Modules linked in: r8152 nouveau lp855x_bl tegra_drm ttm
>>>>> [  315.750942] CPU: 3 PID: 2206 Comm: bash Tainted: G W
>>>>> 5.6.0-rc1-arm64 #118
>>>>> [  315.759017] Hardware name: NVIDIA Jetson TX1 Developer Kit (DT)
>>>>> [  315.764927] pstate: 20000085 (nzCv daIf -PAN -UAO)
>>>>> [  315.769718] pc : _raw_write_lock_irqsave+0xb0/0x2b8
>>>>> [  315.774590] lr : ida_free+0x48/0x158
>>>>> [  315.778155] sp : ffff800011d8bba0
>>>>> [  315.781462] x29: ffff800011d8bba0 x28: ffff0000f4095400
>>>>> [  315.786766] x27: 0000000000000000 x26: 0000000000000000
>>>>> [  315.792070] x25: 0000000000000000 x24: 0000000000000000
>>>>> [  315.797372] x23: ffff0000f21ad400 x22: ffff0000f5c93000
>>>>> [  315.802674] x21: ffff0000f4095400 x20: ffff0000f86b5540
>>>>> [  315.807975] x19: 0000000000000000 x18: 0000000000000000
>>>>> [  315.813276] x17: 0000000000000001 x16: 0000000000000019
>>>>> [  315.818578] x15: 000000148ccdabe2 x14: 0000000000000136
>>>>> [  315.823879] x13: 0000000000000001 x12: 00000000000003f8
>>>>> [  315.829180] x11: 0000000000000000 x10: 0000000000000000
>>>>> [  315.834482] x9 : ffff0000ff899990 x8 : ffff0000ff899000
>>>>> [  315.839784] x7 : 0000000040000000 x6 : 0000000000210d00
>>>>> [  315.845085] x5 : 0000000000000001 x4 : 0000000000000000
>>>>> [  315.850386] x3 : 00000000000000b0 x2 : 0000000000000001
>>>>> [  315.855687] x1 : 0000000000000000 x0 : 0000000000000001
>>>>> [  315.860988] Call trace:
>>>>> [  315.863432]  _raw_write_lock_irqsave+0xb0/0x2b8
>>>>> [  315.867956]  ida_free+0x48/0x158
>>>>> [  315.871184]  __media_device_unregister_entity+0x28/0xf0
>>>>> [  315.876402]  media_device_unregister+0x6c/0x148
>>>>> [  315.880927]  host1x_video_remove+0x20/0x48
>>>>> [  315.885021]  host1x_device_remove+0x1c/0x30
>>>>> [  315.889198]  device_release_driver_internal+0xf4/0x1c0
>>>>> [  315.894325]  device_driver_detach+0x14/0x20
>>>>> [  315.898503]  unbind_store+0xd4/0xf8
>>>>> [  315.901986]  drv_attr_store+0x20/0x30
>>>>> [  315.905645]  sysfs_kf_write+0x40/0x50
>>>>> [  315.909301]  kernfs_fop_write+0xf8/0x210
>>>>> [  315.913219]  __vfs_write+0x18/0x40
>>>>> [  315.916616]  vfs_write+0xdc/0x1c8
>>>>> [  315.919926]  ksys_write+0x68/0xf0
>>>>> [  315.923235]  __arm64_sys_write+0x18/0x20
>>>>> [  315.927154]  el0_svc_common.constprop.0+0x68/0x160
>>>>> [  315.931936]  do_el0_svc+0x20/0x80
>>>>> [  315.935246]  el0_sync_handler+0x10c/0x180
>>>>> [  315.939246]  el0_sync+0x140/0x180
>>>>> [  315.942560] Code: 8803fc02 35ffffa3 17fffda6 f9800071 (885ffc60)
>>>>> [  315.948644] ---[ end trace e42b943f3c1af06c ]---
>>>>>
>>>>> The following diff fixes this:
>>>>>
>>>>> ------------------ cut here ------------------
>>>>> diff --git a/drivers/staging/media/tegra/tegra-vi.c
>>>>> b/drivers/staging/media/tegra/tegra-vi.c
>>>>> index 9714152aa6a7..53cf37af9602 100644
>>>>> --- a/drivers/staging/media/tegra/tegra-vi.c
>>>>> +++ b/drivers/staging/media/tegra/tegra-vi.c
>>>>> @@ -583,7 +583,7 @@ static int tegra_channel_init(struct
>>>>> tegra_vi_channel *chan)
>>>>> /* initialize the video_device */
>>>>> chan->video->fops = &tegra_channel_fops;
>>>>> chan->video->v4l2_dev = &vid->v4l2_dev;
>>>>> - chan->video->release = video_device_release_empty;
>>>>> + chan->video->release = video_device_release;
>>>>> chan->video->queue = &chan->queue;
>>>>> snprintf(chan->video->name, sizeof(chan->video->name),
>>>>> "%s-%s-%u",
>>>>> dev_name(vi->dev), "output", chan->portno);
>>>>> @@ -647,6 +647,7 @@ static int tegra_channel_init(struct
>>>>> tegra_vi_channel *chan)
>>>>> media_entity_cleanup(&chan->video->entity);
>>>>> release_vdev:
>>>>> video_device_release(chan->video);
>>>>> + chan->video = NULL;
>>>>> return ret;
>>>>> }
>>>>>
>>>>> @@ -707,7 +708,6 @@ static void tegra_vi_channels_cleanup(struct
>>>>> tegra_vi *vi)
>>>>> mutex_lock(&chan->video_lock);
>>>>> vb2_queue_release(&chan->queue);
>>>>> mutex_unlock(&chan->video_lock);
>>>>> - video_device_release(chan->video);
>>>>> }
>>>>>
>>>>> if (chan->frame_start_sp)
>>>>> ------------------ cut here ------------------
>>>> Note: Sakari suggested to embed struct video_device into struct
>>>> tegra_vi_channel.
>>>> In that case chan->video->release should remain
>>>> video_device_release_empty and
>>>> all video_device_alloc()/release() calls would have to be dropped.
>>> Thanks Hans. Tried several unbind/unbind not sure why it did not repro
>>> during my testing.
>>>
>>> video device is also part of tegra_vi_channel. So, v6 will remove
>>> video_device_alloc and use video_device_release_empty like I had in v3.
>>>
>>> This should help fix crash during unbind.
>>>
>>>> Regards,
>>>>
>>>> Hans
>> With video device being part of the channel structure, it gets allocated
>> along with vi channel allocation during host1x vi client init and is
>> removed during channel free which happens during host1x vi client exit.
>>
>> Wit this during driver unbind with video node kept opened with v4l2-ctl
>> sleep, it crashes during media_device_unregister_entity.
>>
>> Using, separate video device allocation and freeing allocation during
>> video device release callback, driver unbind works as by the time of
>> entity unregister its it still available.
>>
>> So, will keep allocating video device separately with video_device_alloc
>> and will use video_device_release call back in v6.
>>
> Sounds good. Add a comment before video_device_alloc() explaining why it is
> used instead of embedding it in the vi channel data structure.
>
> Regards,
>
> Hans

Other option I was thinking is to add tegra channel specific release
callback and use that for video device release so video lock destroy and
freeing channel free can be done in the last.

With this we don't need to do have separate video device allocation.