Skip to contentSkip to conversation

Add Tegra driver for video capture

RFC PATCH Superseded Sowjanya Komatineni 3 participants 63 messages Apr 29, 2020 – May 4, 2020 8 messages not in the archive

Subsystems (10)

v11 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

Sowjanya Komatineni

author maintainer
#0 lore raw

v11 cover 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.

[v11]: Includes,
- v10 feedback

[v10]: Includes,
- updated patches for latest linux-next base
- Kconfig update
- minor cleanup/improvements

[v9]: Includes,
- small fix to explicitly check for both vi and csi channels availability before TPG setup and cleanup so in the cases of later Tegras where CSI is not child to VI and if either of the platform drivers are not registered, TPG setup will be skipped.

[v8]: Includes,
- minor change to use device managed allocation fo vi and csi for now. May need to change back to non device managed allocation later when support for direct host1x client driver unbind and bind is added.

[v7]: Includes,
- v6 feedback
- moved registering v4l2 nodes and creating tpg media links to happen after both host1x client inits so during direct host1x client driver unbind and bind order of client unregister/register will not impact.
- All channels resources and freeing happens during v4l2 device release callback.
- module unload/load works with below host1x bus driver fix.
http://patchwork.ozlabs.org/patch/1268191/

[v6]: Includes,
- v5 feedback
- fix for csi_tpg clock parent
- fix to free channel resources in video device release callback for registered video devices as resource might still be in use when application holds handle to it during driver unbind.
- added blanking intervals based on resolution and bpp for csi internal tpg.
- added implementation for subdev pad ops enum_frame_size and enum_frame_interval.

[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 in case 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        |   73 +-
 MAINTAINERS                                        |   10 +
 arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi     |   10 +
 arch/arm64/boot/dts/nvidia/tegra210.dtsi           |   52 +-
 drivers/clk/tegra/clk-tegra210.c                   |    7 +
 drivers/staging/media/Kconfig                      |    2 +
 drivers/staging/media/Makefile                     |    1 +
 drivers/staging/media/tegra-video/Kconfig          |   12 +
 drivers/staging/media/tegra-video/Makefile         |    8 +
 drivers/staging/media/tegra-video/TODO             |   10 +
 drivers/staging/media/tegra-video/csi.c            |  535 ++++++++++
 drivers/staging/media/tegra-video/csi.h            |  144 +++
 drivers/staging/media/tegra-video/tegra210.c       | 1007 ++++++++++++++++++
 drivers/staging/media/tegra-video/vi.c             | 1078 ++++++++++++++++++++
 drivers/staging/media/tegra-video/vi.h             |  256 +++++
 drivers/staging/media/tegra-video/video.c          |  155 +++
 drivers/staging/media/tegra-video/video.h          |   29 +
 include/dt-bindings/clock/tegra210-car.h           |    2 +-
 include/dt-bindings/reset/tegra210-car.h           |    1 +
 19 files changed, 3375 insertions(+), 17 deletions(-)
 create mode 100644 drivers/staging/media/tegra-video/Kconfig
 create mode 100644 drivers/staging/media/tegra-video/Makefile
 create mode 100644 drivers/staging/media/tegra-video/TODO
 create mode 100644 drivers/staging/media/tegra-video/csi.c
 create mode 100644 drivers/staging/media/tegra-video/csi.h
 create mode 100644 drivers/staging/media/tegra-video/tegra210.c
 create mode 100644 drivers/staging/media/tegra-video/vi.c
 create mode 100644 drivers/staging/media/tegra-video/vi.h
 create mode 100644 drivers/staging/media/tegra-video/video.c
 create mode 100644 drivers/staging/media/tegra-video/video.h

v4l2-compliance SHA: 81e45d957c4db39397f893100b3d2729ef39b052, 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 0x02000007: from remote pad 0x1000006 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
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 : 0x0300000b
Type : V4L Video
Entity Info:

        ID               : 0x00000009 (9)
        Name             : 54080000.vi-output-1
        Function         : V4L2 I/O
        Pad 0x0100000a   : 0: Sink
          Link 0x0200000f: from remote pad 0x100000e 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
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 : 0x03000013
Type : V4L Video
Entity Info:

        ID               : 0x00000011 (17)
        Name             : 54080000.vi-output-2
        Function         : V4L2 I/O
        Pad 0x01000012   : 0: Sink
          Link 0x02000017: from remote pad 0x1000016 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
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 : 0x0300001b
Type : V4L Video
Entity Info:

        ID               : 0x00000019 (25)
        Name             : 54080000.vi-output-3
        Function         : V4L2 I/O
        Pad 0x0100001a   : 0: Sink
          Link 0x0200001f: from remote pad 0x100001e 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
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 : 0x03000023
Type : V4L Video
Entity Info:

        ID               : 0x00000021 (33)
        Name             : 54080000.vi-output-4
        Function         : V4L2 I/O
        Pad 0x01000022   : 0: Sink
          Link 0x02000027: from remote pad 0x1000026 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
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 : 0x0300002b
Type : V4L Video
Entity Info:

        ID               : 0x00000029 (41)
        Name             : 54080000.vi-output-5
        Function         : V4L2 I/O
        Pad 0x0100002a   : 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
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

Signature · 1 line
2.7.4
author maintainer
#1 lore raw

RFC PATCH v11 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.

---
 arch/arm64/boot/dts/nvidia/tegra210.dtsi | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/nvidia/tegra210.dtsi +3 -2
index 64c46ce..d0eff92 100644
@@ -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>,
Signature · 1 line
2.7.4
author maintainer
#2 lore raw

RFC PATCH v11 2/9 arm64: tegra: Add reset-cells to mc

In reply to Sowjanya Komatineni

Tegra210 device tree is missing reset-cells property for mc node.

This patch fixes it.

---
 arch/arm64/boot/dts/nvidia/tegra210.dtsi | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/nvidia/tegra210.dtsi +1 -0
index d0eff92..5b1dfd8 100644
@@ -894,6 +894,7 @@
 		interrupts = <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>;
 
 		#iommu-cells = <1>;
+		#reset-cells = <1>;
 	};
 
 	sata@70020000 {
Signature · 1 line
2.7.4
author maintainer
#3 lore raw

RFC PATCH v11 3/9 dt-bindings: clock: tegra: Add clk id for CSI TPG clock

In reply to Sowjanya Komatineni

Tegra210 uses PLLD out internally for CSI TPG.

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

---
 include/dt-bindings/clock/tegra210-car.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/dt-bindings/clock/tegra210-car.h +1 -1
index 7a8f10b..d8909e0 100644
@@ -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
Signature · 1 line
2.7.4
author maintainer
#4 lore raw

RFC PATCH v11 4/9 clk: tegra: Add Tegra210 CSI TPG clock gate

In reply to Sowjanya Komatineni

Tegra210 CSI hardware internally uses PLLD for internal test pattern generator logic.

PLLD_BASE register in CAR has a bit CSI_CLK_SOURCE to enable PLLD out to CSI during TPG mode.

This patch adds this CSI TPG clock gate to Tegra210 clock driver to allow Tegra video driver to ungate CSI TPG clock during TPG mode and gate during non TPG mode.

---
 drivers/clk/tegra/clk-tegra210.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/clk/tegra/clk-tegra210.c +7 -0
index defe3b7..81a879b 100644
@@ -3035,6 +3035,13 @@ static __init void tegra210_periph_clk_init(void __iomem *clk_base,
 					     periph_clk_enb_refcnt);
 	clks[TEGRA210_CLK_DSIB] = clk;
 
+	/* csi_tpg */
+	clk = clk_register_gate(NULL, "csi_tpg", "pll_d",
+				CLK_SET_RATE_PARENT, clk_base + PLLD_BASE,
+				23, 0, &pll_d_lock);
+	clk_register_clkdev(clk, "csi_tpg", NULL);
+	clks[TEGRA210_CLK_CSI_TPG] = clk;
+
 	/* la */
 	clk = tegra_clk_register_periph("la", la_parents,
 			ARRAY_SIZE(la_parents), &tegra210_la, clk_base,
Signature · 1 line
2.7.4
author maintainer
#5 lore raw

RFC PATCH v11 5/9 dt-binding: tegra: Add VI and CSI bindings

In reply to 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.

---
 .../display/tegra/nvidia,tegra20-host1x.txt        | 73 ++++++++++++++++++----
 1 file changed, 60 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt +60 -13
index 9999255..4731921 100644
@@ -40,14 +40,30 @@ 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: clocks: Must contain one entry, for the module clock.
     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
+  - Tegra20/Tegra30/Tegra114/Tegra124:
+    - 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
+  - Tegra210:
+    - 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,tegra210-csi"
+      - reg: Physical base address offset to parent and length of the controller
+        registers.
+      - clocks: Must contain entries csi, cilab, cilcd, cile, csi_tpg 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 +325,44 @@ 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>;
+			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>,
+						  <&tegra_car TEGRA210_CLK_CSI_TPG>;
+				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>,
+						       <972000000>;
+
+				clocks = <&tegra_car TEGRA210_CLK_CSI>,
+					 <&tegra_car TEGRA210_CLK_CILAB>,
+					 <&tegra_car TEGRA210_CLK_CILCD>,
+					 <&tegra_car TEGRA210_CLK_CILE>,
+					 <&tegra_car TEGRA210_CLK_CSI_TPG>;
+				clock-names = "csi", "cilab", "cilcd", "cile", "csi_tpg";
+				power-domains = <&pd_sor>;
+			};
 		};
 
 		epp {
Signature · 1 line
2.7.4
author maintainer
#6 lore raw

RFC PATCH v11 6/9 media: tegra: Add Tegra210 Video input driver

In reply to Sowjanya Komatineni

Tegra210 contains a powerful Video Input (VI) hardware controller which can support up to 6 MIPI CSI camera sensors.

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

Tegra210 supports built-in test pattern generator from CSI to VI.

This patch adds a v4l2 capture driver with media interface for Tegra210 built-in CSI to VI test pattern generator.

This patch includes TPG support only and all the video pipeline configuration happens through the video device node.

---
 drivers/staging/media/Kconfig                |    2 +
 drivers/staging/media/Makefile               |    1 +
 drivers/staging/media/tegra-video/Kconfig    |   12 +
 drivers/staging/media/tegra-video/Makefile   |    8 +
 drivers/staging/media/tegra-video/TODO       |   10 +
 drivers/staging/media/tegra-video/csi.c      |  535 +++++++++++++
 drivers/staging/media/tegra-video/csi.h      |  144 ++++
 drivers/staging/media/tegra-video/tegra210.c | 1007 ++++++++++++++++++++++++
 drivers/staging/media/tegra-video/vi.c       | 1078 ++++++++++++++++++++++++++
 drivers/staging/media/tegra-video/vi.h       |  256 ++++++
 drivers/staging/media/tegra-video/video.c    |  155 ++++
 drivers/staging/media/tegra-video/video.h    |   29 +
 12 files changed, 3237 insertions(+)
 create mode 100644 drivers/staging/media/tegra-video/Kconfig
 create mode 100644 drivers/staging/media/tegra-video/Makefile
 create mode 100644 drivers/staging/media/tegra-video/TODO
 create mode 100644 drivers/staging/media/tegra-video/csi.c
 create mode 100644 drivers/staging/media/tegra-video/csi.h
 create mode 100644 drivers/staging/media/tegra-video/tegra210.c
 create mode 100644 drivers/staging/media/tegra-video/vi.c
 create mode 100644 drivers/staging/media/tegra-video/vi.h
 create mode 100644 drivers/staging/media/tegra-video/video.c
 create mode 100644 drivers/staging/media/tegra-video/video.h
drivers/staging/media/Kconfig +2 -0
index c6b4fb5..6e54ba1 100644
@@ -36,6 +36,8 @@ source "drivers/staging/media/sunxi/Kconfig"
 
 source "drivers/staging/media/tegra-vde/Kconfig"
 
+source "drivers/staging/media/tegra-video/Kconfig"
+
 source "drivers/staging/media/ipu3/Kconfig"
 
 source "drivers/staging/media/soc_camera/Kconfig"
drivers/staging/media/Makefile +1 -0
index 8b24be1..c38b83b 100644
@@ -5,6 +5,7 @@ obj-$(CONFIG_VIDEO_MESON_VDEC)	+= meson/vdec/
 obj-$(CONFIG_VIDEO_OMAP4)	+= omap4iss/
 obj-$(CONFIG_VIDEO_ROCKCHIP_VDEC)	+= rkvdec/
 obj-$(CONFIG_VIDEO_SUNXI)	+= sunxi/
+obj-$(CONFIG_VIDEO_TEGRA)	+= tegra-video/
 obj-$(CONFIG_TEGRA_VDE)		+= tegra-vde/
 obj-$(CONFIG_VIDEO_HANTRO)	+= hantro/
 obj-$(CONFIG_VIDEO_IPU3_IMGU)	+= ipu3/
drivers/staging/media/tegra-video/Kconfig new file +12 -0
new file mode 100644
index 0000000..6cee329
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config VIDEO_TEGRA
+	tristate "NVIDIA Tegra VI driver"
+	depends on TEGRA_HOST1X || COMPILE_TEST
+	select VIDEO_V4L2
+	select MEDIA_CONTROLLER
+	select VIDEOBUF2_DMA_CONTIG
+	help
+	  Choose this option if you have an NVIDIA Tegra SoC.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called tegra-video.
drivers/staging/media/tegra-video/Makefile new file +8 -0
new file mode 100644
index 0000000..dfa2ef8
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+tegra-video-objs := \
+		video.o \
+		vi.o \
+		csi.o
+
+tegra-video-$(CONFIG_ARCH_TEGRA_210_SOC) += tegra210.o
+obj-$(CONFIG_VIDEO_TEGRA) += tegra-video.o
drivers/staging/media/tegra-video/TODO new file +10 -0
new file mode 100644
index 0000000..5dcb7a8
@@ -0,0 +1,10 @@
+TODO list
+* Currently driver supports Tegra build-in TPG only with direct media links
+  from CSI to VI. Update the driver to do TPG Vs Sensor media links based on
+  the kernel config CONFIG_VIDEO_TEGRA_TPG.
+* Add real camera sensor capture support
+* Add RAW10 packed video format support to Tegra210 video formats
+* Add Tegra CSI MIPI pads calibration
+* Add MIPI clock Settle time computation based on the data rate
+* Add support for Ganged mode
+* Make sure v4l2-compliance tests pass with all of the above implementations.
drivers/staging/media/tegra-video/csi.c new file +535 -0

535 lines not on this page · raw message

drivers/staging/media/tegra-video/csi.h new file +144 -0

144 lines not on this page · raw message

drivers/staging/media/tegra-video/tegra210.c new file +1007 -0

1,007 lines not on this page · raw message

drivers/staging/media/tegra-video/vi.c new file +1078 -0

1,078 lines not on this page · raw message

drivers/staging/media/tegra-video/vi.h new file +256 -0

191 lines not on this page · raw message

drivers/staging/media/tegra-video/video.c new file +155 -0

155 lines not on this page · raw message

drivers/staging/media/tegra-video/video.h new file +29 -0
new file mode 100644
index 0000000..fadaf21

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.7.4

Part of the diff is not shown here. View the raw message.

#7 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

30.04.2020 01:00, Sowjanya Komatineni пишет:

Quoted 16 lines
drivers/staging/media/tegra-video/csi.c new file +16 -0
+static int tegra_csi_init(struct host1x_client *client)
+{
+	struct tegra_csi *csi = host1x_client_to_csi(client);
+	struct tegra_video_device *vid = dev_get_drvdata(client->host);
+	int ret;
+
+	INIT_LIST_HEAD(&csi->csi_chans);
+
+	ret = tegra_csi_tpg_channels_alloc(csi);
+	if (ret < 0) {
+		dev_err(csi->dev,
+			"failed to allocate tpg channels: %d\n", ret);
+		goto cleanup;
+	}
+
+	ret = tegra_csi_channels_init(csi);

drivers/staging/media/tegra-video/csi.c line 420

Quoted 10 lines
drivers/staging/media/tegra-video/csi.c new file +10 -0
+	if (ret < 0)
+		goto cleanup;
+
+	vid->csi = csi;
+
+	return 0;
+
+cleanup:
+	tegra_csi_channels_cleanup(csi);
+	pm_runtime_put_sync(csi->dev);

This pm_runtime_put_sync() should be removed.

Quoted 2 lines
(quoted diff) +2 -0
+	return ret;
+}
author maintainer
#8 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 20 lines · Dmitry Osipenko

30.04.2020 01:00, Sowjanya Komatineni пишет:

Quoted 19 lines
drivers/staging/media/tegra-video/csi.c new file +19 -0
+static int tegra_csi_init(struct host1x_client *client)
+{
+	struct tegra_csi *csi = host1x_client_to_csi(client);
+	struct tegra_video_device *vid = dev_get_drvdata(client->host);
+	int ret;
+
+	INIT_LIST_HEAD(&csi->csi_chans);
+
+	ret = tegra_csi_tpg_channels_alloc(csi);
+	if (ret < 0) {
+		dev_err(csi->dev,
+			"failed to allocate tpg channels: %d\n", ret);
+		goto cleanup;
+	}
+
+	ret = tegra_csi_channels_init(csi);
+	if (ret < 0)
+		goto cleanup;
+
Quoted 8 lines

drivers/staging/media/tegra-video/csi.c line 420

Quoted 7 lines
drivers/staging/media/tegra-video/csi.c new file +7 -0
+	vid->csi = csi;
+
+	return 0;
+
+cleanup:
+	tegra_csi_channels_cleanup(csi);
+	pm_runtime_put_sync(csi->dev);

This pm_runtime_put_sync() should be removed.

Sorry, I had it correct in follow-up patches and missed this to remove in v12.

Will double check all changes before sending v12 once all v11 feedback from you is done.

Quoted 3 lines
Quoted 3 lines
(quoted diff) +2 -0
+	return ret;
+}
#9 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

In reply to Sowjanya Komatineni

30.04.2020 01:00, Sowjanya Komatineni пишет:

drivers/staging/media/tegra-video/csi.h line 95

Quoted 11 lines
drivers/staging/media/tegra-video/csi.h new file +11 -0
+/**
+ * struct tegra_csi_ops - Tegra CSI operations
+ *
+ * @csi_streaming: programs csi hardware to enable or disable streaming.
+ * @csi_err_recover: csi hardware block recovery in case of any capture errors
+ *		due to missing source stream or due to improper csi input from
+ *		the external source.
+ */
+struct tegra_csi_ops {
+	int (*csi_streaming)(struct tegra_csi_channel *csi_chan, u8 pg_mode,
+			     int enable);

What about to split csi_streaming() into csi_start_streaming() / csi_stop_streaming()?

This will make tegra_csi_ops to be consistent with the tegra_ve_ops. A separated start/stop operations are somewhat more natural to have in general.

author maintainer
#10 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 15 lines · Dmitry Osipenko

30.04.2020 01:00, Sowjanya Komatineni пишет:

drivers/staging/media/tegra-video/csi.h line 95

Quoted 11 lines
drivers/staging/media/tegra-video/csi.h new file +11 -0
+/**
+ * struct tegra_csi_ops - Tegra CSI operations
+ *
+ * @csi_streaming: programs csi hardware to enable or disable streaming.
+ * @csi_err_recover: csi hardware block recovery in case of any capture errors
+ *		due to missing source stream or due to improper csi input from
+ *		the external source.
+ */
+struct tegra_csi_ops {
+	int (*csi_streaming)(struct tegra_csi_channel *csi_chan, u8 pg_mode,
+			     int enable);

What about to split csi_streaming() into csi_start_streaming() / csi_stop_streaming()?

Quoted 3 lines

This will make tegra_csi_ops to be consistent with the tegra_ve_ops. A separated start/stop operations are somewhat more natural to have in general.

vi ops is for vb2_ops which has separate start/stop so has seperate start/stop for vi ops.

csi is subdev and csi ops is for v4l2_subdev_ops which as s_stream callback only.

So, created single stream function for csi to match same as subdev_ops.

#11 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

30.04.2020 22:32, Sowjanya Komatineni пишет:

Quoted 25 lines · Dmitry Osipenko
Quoted 19 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

Quoted 7 lines

+/**
+ * struct tegra_csi_ops - Tegra CSI operations
+ *
+ * @csi_streaming: programs csi hardware to enable or disable streaming.
+ * @csi_err_recover: csi hardware block recovery in case of any capture errors

Quoted 8 lines

+ *        due to missing source stream or due to improper csi input from
+ *        the external source.
+ */
+struct tegra_csi_ops {
+    int (*csi_streaming)(struct tegra_csi_channel *csi_chan, u8 pg_mode,
+                 int enable);

What about to split csi_streaming() into csi_start_streaming() / csi_stop_streaming()?

Quoted 3 lines

This will make tegra_csi_ops to be consistent with the tegra_ve_ops. A separated start/stop operations are somewhat more natural to have in general.

Quoted 7 lines

vi ops is for vb2_ops which has separate start/stop so has seperate start/stop for vi ops.

csi is subdev and csi ops is for v4l2_subdev_ops which as s_stream callback only.

So, created single stream function for csi to match same as subdev_ops.

It will be nicer to have separate ops for CSI, regardless of the subdev_ops. It should be okay to have a single-combined ops if CSI start/stop was trivial, but it's not the case here.

For example, the pm_runtime_put() shouldn't be invoked if stream's stopping fails. The stopping can't fail for the current code, but this could change in the future.

You could make csi_streaming to return void, telling explicitly that this code can't fail. Then the combined OPS should be okay to have.

author maintainer
#12 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 35 lines · Dmitry Osipenko

30.04.2020 22:32, Sowjanya Komatineni пишет:

Quoted 23 lines · Dmitry Osipenko
Quoted 19 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

Quoted 7 lines

+/**
+ * struct tegra_csi_ops - Tegra CSI operations
+ *
+ * @csi_streaming: programs csi hardware to enable or disable streaming.
+ * @csi_err_recover: csi hardware block recovery in case of any capture errors

Quoted 8 lines

+ *        due to missing source stream or due to improper csi input from
+ *        the external source.
+ */
+struct tegra_csi_ops {
+    int (*csi_streaming)(struct tegra_csi_channel *csi_chan, u8 pg_mode,
+                 int enable);

What about to split csi_streaming() into csi_start_streaming() / csi_stop_streaming()?

Quoted 3 lines

This will make tegra_csi_ops to be consistent with the tegra_ve_ops. A separated start/stop operations are somewhat more natural to have in general.

Quoted 7 lines

vi ops is for vb2_ops which has separate start/stop so has seperate start/stop for vi ops.

csi is subdev and csi ops is for v4l2_subdev_ops which as s_stream callback only.

So, created single stream function for csi to match same as subdev_ops.

It will be nicer to have separate ops for CSI, regardless of the subdev_ops. It should be okay to have a single-combined ops if CSI start/stop was trivial, but it's not the case here.

Quoted 6 lines

For example, the pm_runtime_put() shouldn't be invoked if stream's stopping fails. The stopping can't fail for the current code, but this could change in the future.

You could make csi_streaming to return void, telling explicitly that this code can't fail. Then the combined OPS should be okay to have.

we don't return anything for stop stream. OK can make it split to explicitly specify no return code during stop stream.

will split this in v12

#13 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

In reply to Sowjanya Komatineni

30.04.2020 01:00, Sowjanya Komatineni пишет:

drivers/staging/media/tegra-video/vi.c line 184

Quoted 11 lines
drivers/staging/media/tegra-video/vi.c new file +11 -0
+void tegra_channel_release_buffers(struct tegra_vi_channel *chan,
+				   enum vb2_buffer_state state)
+{
+	struct tegra_channel_buffer *buf, *nbuf;
+
+	spin_lock(&chan->start_lock);
+	list_for_each_entry_safe(buf, nbuf, &chan->capture, queue) {
+		vb2_buffer_done(&buf->buf.vb2_buf, state);
+		list_del(&buf->queue);
+	}
+

I'd remove this blank line to make lock/unlock block more human-readable.

drivers/staging/media/tegra-video/vi.c line 192

Quoted 8 lines
drivers/staging/media/tegra-video/vi.c new file +8 -0
+	spin_unlock(&chan->start_lock);
+
+	spin_lock(&chan->done_lock);
+	list_for_each_entry_safe(buf, nbuf, &chan->done, queue) {
+		vb2_buffer_done(&buf->buf.vb2_buf, state);
+		list_del(&buf->queue);
+	}
+

And thins line too.

Quoted 2 lines
(quoted diff) +2 -0
+	spin_unlock(&chan->done_lock);
+}
#14 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

In reply to Sowjanya Komatineni

30.04.2020 01:00, Sowjanya Komatineni пишет:

Review

Quoted 2 lines
(quoted diff) +2 -0
+/* -------------------------------------------------------------------- */
+

Such comments should be unnecessary.

#15 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

In reply to Sowjanya Komatineni

30.04.2020 01:00, Sowjanya Komatineni пишет:

drivers/staging/media/tegra-video/tegra210.c line 424

Quoted 9 lines
drivers/staging/media/tegra-video/tegra210.c new file +9 -0
+static int chan_capture_kthread_finish(void *data)
+{
+	struct tegra_vi_channel *chan = data;
+	struct tegra_channel_buffer *buf;
+
+	set_freezable();
+
+	while (1) {
+		try_to_freeze();

I guess it won't be great to freeze in the middle of a capture process, so:

		if (list_empty(&chan->done))
			try_to_freeze();
Quoted 17 lines
drivers/staging/media/tegra-video/tegra210.c new file +17 -0
+		wait_event_interruptible(chan->done_wait,
+					 !list_empty(&chan->done) ||
+					 kthread_should_stop());
+
+		/* dequeue buffers and finish capture */
+		buf = dequeue_buf_done(chan);
+		while (buf) {
+			tegra_channel_capture_done(chan, buf);
+			buf = dequeue_buf_done(chan);
+		}
+
+		if (kthread_should_stop())
+			break;
+	}
+
+	return 0;
+}
#16 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

30.04.2020 16:56, Dmitry Osipenko пишет:

Quoted 12 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

drivers/staging/media/tegra-video/tegra210.c line 424

Quoted 9 lines
drivers/staging/media/tegra-video/tegra210.c new file +9 -0
+static int chan_capture_kthread_finish(void *data)
+{
+	struct tegra_vi_channel *chan = data;
+	struct tegra_channel_buffer *buf;
+
+	set_freezable();
+
+	while (1) {
+		try_to_freeze();

I guess it won't be great to freeze in the middle of a capture process, so:

Quoted 2 lines
		if (list_empty(&chan->done))
			try_to_freeze();

And here should be some locking protection in order not race with the chan_capture_kthread_start because kthread_finish could freeze before kthread_start.

Quoted 18 lines
Quoted 17 lines
drivers/staging/media/tegra-video/tegra210.c new file +17 -0
+		wait_event_interruptible(chan->done_wait,
+					 !list_empty(&chan->done) ||
+					 kthread_should_stop());
+
+		/* dequeue buffers and finish capture */
+		buf = dequeue_buf_done(chan);
+		while (buf) {
+			tegra_channel_capture_done(chan, buf);
+			buf = dequeue_buf_done(chan);
+		}
+
+		if (kthread_should_stop())
+			break;
+	}
+
+	return 0;
+}
#17 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

30.04.2020 17:02, Dmitry Osipenko пишет:

Quoted 16 lines

30.04.2020 16:56, Dmitry Osipenko пишет:

Quoted 12 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

drivers/staging/media/tegra-video/tegra210.c line 424

Quoted 9 lines
drivers/staging/media/tegra-video/tegra210.c new file +9 -0
+static int chan_capture_kthread_finish(void *data)
+{
+	struct tegra_vi_channel *chan = data;
+	struct tegra_channel_buffer *buf;
+
+	set_freezable();
+
+	while (1) {
+		try_to_freeze();

I guess it won't be great to freeze in the middle of a capture process, so:

Quoted 2 lines
		if (list_empty(&chan->done))
			try_to_freeze();
Quoted 3 lines

And here should be some locking protection in order not race with the chan_capture_kthread_start because kthread_finish could freeze before kthread_start.

Or maybe both start / finish threads should simply be allowed to freeze only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&

    list_empty(&chan->done))
	try_to_freeze();
author maintainer
#18 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 18 lines · Dmitry Osipenko

30.04.2020 17:02, Dmitry Osipenko пишет:

Quoted 14 lines

30.04.2020 16:56, Dmitry Osipenko пишет:

Quoted 11 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

drivers/staging/media/tegra-video/tegra210.c line 424

Quoted 9 lines
drivers/staging/media/tegra-video/tegra210.c new file +9 -0
+static int chan_capture_kthread_finish(void *data)
+{
+	struct tegra_vi_channel *chan = data;
+	struct tegra_channel_buffer *buf;
+
+	set_freezable();
+
+	while (1) {
+		try_to_freeze();

I guess it won't be great to freeze in the middle of a capture process, so:

Quoted 2 lines
		if (list_empty(&chan->done))
			try_to_freeze();
Quoted 3 lines

And here should be some locking protection in order not race with the chan_capture_kthread_start because kthread_finish could freeze before kthread_start.

Quoted 6 lines

Or maybe both start / finish threads should simply be allowed to freeze only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&

     list_empty(&chan->done))
	try_to_freeze();

good to freeze when not in middle of the frame capture but why should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

I guess we can freeze before dequeue for capture and in finish thread we can freeze after capture done. This also don't need to check for list_empty with freeze to allow between frame captures.

author maintainer
#19 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 27 lines · Sowjanya Komatineni
Quoted 18 lines · Dmitry Osipenko

30.04.2020 17:02, Dmitry Osipenko пишет:

Quoted 14 lines

30.04.2020 16:56, Dmitry Osipenko пишет:

Quoted 13 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

drivers/staging/media/tegra-video/tegra210.c line 424

Quoted 9 lines
drivers/staging/media/tegra-video/tegra210.c new file +9 -0
+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();

I guess it won't be great to freeze in the middle of a capture process, so:
        if (list_empty(&chan->done))
            try_to_freeze();

Quoted 3 lines

And here should be some locking protection in order not race with the chan_capture_kthread_start because kthread_finish could freeze before kthread_start.

Quoted 6 lines

Or maybe both start / finish threads should simply be allowed to freeze only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
     list_empty(&chan->done))
    try_to_freeze();

Quoted 6 lines

good to freeze when not in middle of the frame capture but why should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

I guess we can freeze before dequeue for capture and in finish thread we can freeze after capture done. This also don't need to check for list_empty with freeze to allow between frame captures.

Also if we add check for both lists empty, freeze is not allowed as long as streaming is going on and in case of continuous streaming freeze will never happen.

author maintainer
#20 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 29 lines · Sowjanya Komatineni
Quoted 27 lines · Sowjanya Komatineni
Quoted 24 lines · Dmitry Osipenko

30.04.2020 17:02, Dmitry Osipenko пишет:

Quoted 14 lines

30.04.2020 16:56, Dmitry Osipenko пишет:

Quoted 13 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

drivers/staging/media/tegra-video/tegra210.c line 424

Quoted 9 lines
drivers/staging/media/tegra-video/tegra210.c new file +9 -0
+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();

I guess it won't be great to freeze in the middle of a capture process, so:
        if (list_empty(&chan->done))
            try_to_freeze();

Quoted 3 lines

And here should be some locking protection in order not race with the chan_capture_kthread_start because kthread_finish could freeze before kthread_start.

Or maybe both start / finish threads should simply be allowed to freeze only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
     list_empty(&chan->done))
    try_to_freeze();

Quoted 7 lines
Quoted 6 lines

good to freeze when not in middle of the frame capture but why should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

I guess we can freeze before dequeue for capture and in finish thread we can freeze after capture done. This also don't need to check for list_empty with freeze to allow between frame captures.

Also if we add check for both lists empty, freeze is not allowed as long as streaming is going on and in case of continuous streaming freeze will never happen.

Hi Dmitry,

Will update in v12 to not allow freeze in middle of a frame capture.

Can you please confirm on above if you agree to allow freeze to happen in b/w frame captures?

Also as most feedback has been received from you by now, appreciate if you can provide all in this v11 if you have anything else so we will not have any new changes after v12.

Thanks

Sowjanya

author maintainer
#21 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 31 lines · Sowjanya Komatineni
Quoted 29 lines · Sowjanya Komatineni
Quoted 27 lines · Sowjanya Komatineni
Quoted 24 lines · Dmitry Osipenko

30.04.2020 17:02, Dmitry Osipenko пишет:

Quoted 14 lines

30.04.2020 16:56, Dmitry Osipenko пишет:

Quoted 13 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

Review

Quoted 9 lines
(quoted diff) +9 -0
+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();

I guess it won't be great to freeze in the middle of a capture process, so:
        if (list_empty(&chan->done))
            try_to_freeze();

Quoted 3 lines

And here should be some locking protection in order not race with the chan_capture_kthread_start because kthread_finish could freeze before kthread_start.

Or maybe both start / finish threads should simply be allowed to freeze only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
     list_empty(&chan->done))
    try_to_freeze();

Quoted 8 lines
Quoted 7 lines
Quoted 6 lines

good to freeze when not in middle of the frame capture but why should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

I guess we can freeze before dequeue for capture and in finish thread we can freeze after capture done. This also don't need to check for list_empty with freeze to allow between frame captures.

Also if we add check for both lists empty, freeze is not allowed as long as streaming is going on and in case of continuous streaming freeze will never happen.

To allow freeze b/w frames (but not in middle of a frame),

for capture_start thread, probably we can do unconditional try_to_freeze()

for capture_finish thread, at end of capture done we can do try_to_freeze() only when done list is empty

Quoted 12 lines

Hi Dmitry,

Will update in v12 to not allow freeze in middle of a frame capture.

Can you please confirm on above if you agree to allow freeze to happen in b/w frame captures?

Also as most feedback has been received from you by now, appreciate if you can provide all in this v11 if you have anything else so we will not have any new changes after v12.

Thanks

Sowjanya

author maintainer
#22 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 39 lines · Sowjanya Komatineni
Quoted 37 lines · Sowjanya Komatineni
Quoted 35 lines · Sowjanya Komatineni
Quoted 33 lines · Sowjanya Komatineni
Quoted 18 lines · Dmitry Osipenko

30.04.2020 17:02, Dmitry Osipenko пишет:

Quoted 14 lines

30.04.2020 16:56, Dmitry Osipenko пишет:

Quoted 13 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

Review

Quoted 9 lines
(quoted diff) +9 -0
+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();

I guess it won't be great to freeze in the middle of a capture process, so:
        if (list_empty(&chan->done))
            try_to_freeze();

Quoted 3 lines

And here should be some locking protection in order not race with the chan_capture_kthread_start because kthread_finish could freeze before kthread_start.

Quoted 6 lines

Or maybe both start / finish threads should simply be allowed to freeze only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
     list_empty(&chan->done))
    try_to_freeze();

good to freeze when not in middle of the frame capture but why should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

I guess we can freeze before dequeue for capture and in finish thread we can freeze after capture done. This also don't need to check for list_empty with freeze to allow between frame captures.

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

Also if we add check for both lists empty, freeze is not allowed as long as streaming is going on and in case of continuous streaming freeze will never happen.

To allow freeze b/w frames (but not in middle of a frame),

for capture_start thread, probably we can do unconditional try_to_freeze()

for capture_finish thread, at end of capture done we can do try_to_freeze() only when done list is empty

My understanding is buffer updates/release should not happen after frozen state. So we should let frame capture of outstanding buffer to finish before freezing in capture_finish thread.

But for capture_start thread we can unconditionally freeze before dequeuing next buffer for capture.

With this when both threads are in frozen state and no buffer updates/captures will happen after frozen state.

I think its not required to finish streaming of all frames completely to let threads to enter frozen state as streaming can be continuous as well.

Quoted 12 lines
Quoted 12 lines

Hi Dmitry,

Will update in v12 to not allow freeze in middle of a frame capture.

Can you please confirm on above if you agree to allow freeze to happen in b/w frame captures?

Also as most feedback has been received from you by now, appreciate if you can provide all in this v11 if you have anything else so we will not have any new changes after v12.

Thanks

Sowjanya

#23 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

30.04.2020 22:09, Sowjanya Komatineni пишет:

Quoted 48 lines · Sowjanya Komatineni
Quoted 46 lines · Sowjanya Komatineni
Quoted 44 lines · Sowjanya Komatineni
Quoted 42 lines · Sowjanya Komatineni
Quoted 40 lines · Dmitry Osipenko
Quoted 21 lines

30.04.2020 17:02, Dmitry Osipenko пишет:

Quoted 15 lines

30.04.2020 16:56, Dmitry Osipenko пишет:

Quoted 14 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

Review

Quoted 9 lines
(quoted diff) +9 -0
+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();

I guess it won't be great to freeze in the middle of a capture process, so:
        if (list_empty(&chan->done)) try_to_freeze();

Quoted 5 lines

And here should be some locking protection in order not race with the
chan_capture_kthread_start because kthread_finish could freeze before
kthread_start.

Quoted 7 lines

Or maybe both start / finish threads should simply be allowed to freeze
only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
     list_empty(&chan->done))
    try_to_freeze();

good to freeze when not in middle of the frame capture but why should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

I guess we can freeze before dequeue for capture and in finish thread we can freeze after capture done. This also don't need to check for list_empty with freeze to allow between frame captures.

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

Also if we add check for both lists empty, freeze is not allowed as long as streaming is going on and in case of continuous streaming freeze will never happen.

To allow freeze b/w frames (but not in middle of a frame),

for capture_start thread, probably we can do unconditional try_to_freeze()

Is it possible to use wait_event_freezable()?

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Will the wait_event_interruptible() be woken up when system freezes?

Quoted 2 lines
Quoted 2 lines

for capture_finish thread, at end of capture done we can do try_to_freeze() only when done list is empty

This doesn't prevent situation where the done-list is empty and the "finish" thread freezes, in the same time the "start" thread issues new capture and then freezes too.

1. "start" thread issues capture

2. "finish" thread wakes and waits for the capture to complete

3. "start" thread begins another capture, waits for FRAME_START

4. system freezing activates

5. "finish" thread completes the capture and freezes because done-list is empty

6. "start" thread gets FRAME_START, issues another capture and freezes

Quoted 4 lines

My understanding is buffer updates/release should not happen after frozen state. So we should let frame capture of outstanding buffer to finish before freezing in capture_finish thread.

Quoted 8 lines

But for capture_start thread we can unconditionally freeze before dequeuing next buffer for capture.

With this when both threads are in frozen state and no buffer updates/captures will happen after frozen state.

I think its not required to finish streaming of all frames completely to let threads to enter frozen state as streaming can be continuous as well.

Yes, only freezing in the middle of IO should be avoided.

https://lwn.net/Articles/705269/

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

Hi Dmitry,

Will update in v12 to not allow freeze in middle of a frame capture.

Can you please confirm on above if you agree to allow freeze to happen in b/w frame captures?

Also as most feedback has been received from you by now, appreciate if you can provide all in this v11 if you have anything else so we will not have any new changes after v12.

I'll take another look tomorrow / during weekend and let you know.

author maintainer
#24 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 48 lines · Dmitry Osipenko

30.04.2020 22:09, Sowjanya Komatineni пишет:

Quoted 47 lines · Sowjanya Komatineni
Quoted 46 lines · Sowjanya Komatineni
Quoted 36 lines · Sowjanya Komatineni
Quoted 35 lines · Sowjanya Komatineni
Quoted 34 lines · Dmitry Osipenko
Quoted 21 lines

30.04.2020 17:02, Dmitry Osipenko пишет:

Quoted 15 lines

30.04.2020 16:56, Dmitry Osipenko пишет:

Quoted 14 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

Review

Quoted 9 lines
(quoted diff) +9 -0
+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();

I guess it won't be great to freeze in the middle of a capture process, so:
        if (list_empty(&chan->done)) try_to_freeze();

Quoted 5 lines

And here should be some locking protection in order not race with the
chan_capture_kthread_start because kthread_finish could freeze before
kthread_start.

Quoted 7 lines

Or maybe both start / finish threads should simply be allowed to freeze
only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
     list_empty(&chan->done))
    try_to_freeze();

good to freeze when not in middle of the frame capture but why should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

I guess we can freeze before dequeue for capture and in finish thread we can freeze after capture done. This also don't need to check for list_empty with freeze to allow between frame captures.

Also if we add check for both lists empty, freeze is not allowed as long as streaming is going on and in case of continuous streaming freeze will never happen.

To allow freeze b/w frames (but not in middle of a frame),

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

for capture_start thread, probably we can do unconditional try_to_freeze()

Is it possible to use wait_event_freezable()?

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Will the wait_event_interruptible() be woken up when system freezes?

Based on wait_event_freezable implementation, looks like it similar to wait_event_interruptible + try_to_free() as it does freezable_schedule unlike schedule with wait_event_interruptible.

So using this for capture_start may be ok to allow freeze before start of frame. But can't use for capture_finish as this is same as wait_event_interruptible followed by unconditional try_to_freeze.

Quoted 11 lines
Quoted 3 lines
Quoted 3 lines

for capture_finish thread, at end of capture done we can do try_to_freeze() only when done list is empty

This doesn't prevent situation where the done-list is empty and the "finish" thread freezes, in the same time the "start" thread issues new capture and then freezes too.

1. "start" thread issues capture

2. "finish" thread wakes and waits for the capture to complete

Quoted 8 lines

3. "start" thread begins another capture, waits for FRAME_START

4. system freezing activates

5. "finish" thread completes the capture and freezes because done-list is empty

6. "start" thread gets FRAME_START, issues another capture and freezes

This will not happen as we allow double buffering done list will not be empty till stream stop happens

There will always be 1 outstanding frame in done list

Quoted 27 lines
Quoted 4 lines

My understanding is buffer updates/release should not happen after frozen state. So we should let frame capture of outstanding buffer to finish before freezing in capture_finish thread.

Quoted 8 lines

But for capture_start thread we can unconditionally freeze before dequeuing next buffer for capture.

With this when both threads are in frozen state and no buffer updates/captures will happen after frozen state.

I think its not required to finish streaming of all frames completely to let threads to enter frozen state as streaming can be continuous as well.

Yes, only freezing in the middle of IO should be avoided.

https://lwn.net/Articles/705269/

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

Hi Dmitry,

Will update in v12 to not allow freeze in middle of a frame capture.

Can you please confirm on above if you agree to allow freeze to happen in b/w frame captures?

Also as most feedback has been received from you by now, appreciate if you can provide all in this v11 if you have anything else so we will not have any new changes after v12.

I'll take another look tomorrow / during weekend and let you know.

author maintainer
#25 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 77 lines · Sowjanya Komatineni
Quoted 48 lines · Dmitry Osipenko

30.04.2020 22:09, Sowjanya Komatineni пишет:

Quoted 47 lines · Sowjanya Komatineni
Quoted 46 lines · Sowjanya Komatineni
Quoted 36 lines · Sowjanya Komatineni
Quoted 35 lines · Sowjanya Komatineni
Quoted 34 lines · Dmitry Osipenko
Quoted 21 lines

30.04.2020 17:02, Dmitry Osipenko пишет:

Quoted 15 lines

30.04.2020 16:56, Dmitry Osipenko пишет:

Quoted 14 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

Review

Quoted 9 lines
(quoted diff) +9 -0
+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();

I guess it won't be great to freeze in the middle of a capture process, so:
         if (list_empty(&chan->done)) try_to_freeze();

Quoted 5 lines

And here should be some locking protection in order not race with the
chan_capture_kthread_start because kthread_finish could freeze before
kthread_start.

Quoted 7 lines

Or maybe both start / finish threads should simply be allowed to freeze
only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
      list_empty(&chan->done))
     try_to_freeze();

good to freeze when not in middle of the frame capture but why should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

I guess we can freeze before dequeue for capture and in finish thread we can freeze after capture done. This also don't need to check for list_empty with freeze to allow between frame captures.

Also if we add check for both lists empty, freeze is not allowed as long as streaming is going on and in case of continuous streaming freeze will never happen.

To allow freeze b/w frames (but not in middle of a frame),

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

for capture_start thread, probably we can do unconditional try_to_freeze()

Is it possible to use wait_event_freezable()?

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Will the wait_event_interruptible() be woken up when system freezes?

Based on wait_event_freezable implementation, looks like it similar to wait_event_interruptible + try_to_free() as it does freezable_schedule unlike schedule with wait_event_interruptible.

So using this for capture_start may be ok to allow freeze before start of frame. But can't use for capture_finish as this is same as wait_event_interruptible followed by unconditional try_to_freeze.

Quoted 15 lines
Quoted 3 lines
Quoted 3 lines

for capture_finish thread, at end of capture done we can do try_to_freeze() only when done list is empty

This doesn't prevent situation where the done-list is empty and the "finish" thread freezes, in the same time the "start" thread issues new capture and then freezes too.

1. "start" thread issues capture

2. "finish" thread wakes and waits for the capture to complete

3. "start" thread begins another capture, waits for FRAME_START

4. system freezing activates

Quoted 8 lines
Quoted 4 lines

5. "finish" thread completes the capture and freezes because done-list is empty

6. "start" thread gets FRAME_START, issues another capture and freezes

This will not happen as we allow double buffering done list will not be empty till stream stop happens

There will always be 1 outstanding frame in done list

Correction, there will always be 1 outstanding buffer except beginning during beginning of stream.

Except during beginning frames, done list will not be empty for all subsequent streaming process

Quoted 28 lines
Quoted 28 lines
Quoted 5 lines

My understanding is buffer updates/release should not happen after frozen state. So we should let frame capture of outstanding buffer to finish before freezing in capture_finish thread.

Quoted 8 lines

But for capture_start thread we can unconditionally freeze before dequeuing next buffer for capture.

With this when both threads are in frozen state and no buffer updates/captures will happen after frozen state.

I think its not required to finish streaming of all frames completely to let threads to enter frozen state as streaming can be continuous as well.

Yes, only freezing in the middle of IO should be avoided.

https://lwn.net/Articles/705269/

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

Hi Dmitry,

Will update in v12 to not allow freeze in middle of a frame capture.

Can you please confirm on above if you agree to allow freeze to happen in b/w frame captures?

Also as most feedback has been received from you by now, appreciate if you can provide all in this v11 if you have anything else so we will not have any new changes after v12.

I'll take another look tomorrow / during weekend and let you know.

author maintainer
#26 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 84 lines · Sowjanya Komatineni
Quoted 82 lines · Sowjanya Komatineni
Quoted 48 lines · Dmitry Osipenko

30.04.2020 22:09, Sowjanya Komatineni пишет:

Quoted 47 lines · Sowjanya Komatineni
Quoted 46 lines · Sowjanya Komatineni
Quoted 36 lines · Sowjanya Komatineni
Quoted 35 lines · Sowjanya Komatineni
Quoted 34 lines · Dmitry Osipenko
Quoted 21 lines

30.04.2020 17:02, Dmitry Osipenko пишет:

Quoted 15 lines

30.04.2020 16:56, Dmitry Osipenko пишет:

Quoted 14 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

Review

Quoted 9 lines
(quoted diff) +9 -0
+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();

I guess it won't be great to freeze in the middle of a capture process, so:
         if (list_empty(&chan->done)) try_to_freeze();

Quoted 5 lines

And here should be some locking protection in order not race with the
chan_capture_kthread_start because kthread_finish could freeze before
kthread_start.

Quoted 7 lines

Or maybe both start / finish threads should simply be allowed to freeze
only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
      list_empty(&chan->done))
     try_to_freeze();

good to freeze when not in middle of the frame capture but why should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

I guess we can freeze before dequeue for capture and in finish thread we can freeze after capture done. This also don't need to check for list_empty with freeze to allow between frame captures.

Also if we add check for both lists empty, freeze is not allowed as long as streaming is going on and in case of continuous streaming freeze will never happen.

To allow freeze b/w frames (but not in middle of a frame),

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

for capture_start thread, probably we can do unconditional try_to_freeze()

Is it possible to use wait_event_freezable()?

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Will the wait_event_interruptible() be woken up when system freezes?

Based on wait_event_freezable implementation, looks like it similar to wait_event_interruptible + try_to_free() as it does freezable_schedule unlike schedule with wait_event_interruptible.

So using this for capture_start may be ok to allow freeze before start of frame. But can't use for capture_finish as this is same as wait_event_interruptible followed by unconditional try_to_freeze.

Quoted 19 lines
Quoted 3 lines
Quoted 3 lines

for capture_finish thread, at end of capture done we can do try_to_freeze() only when done list is empty

This doesn't prevent situation where the done-list is empty and the "finish" thread freezes, in the same time the "start" thread issues new capture and then freezes too.

1. "start" thread issues capture

2. "finish" thread wakes and waits for the capture to complete

3. "start" thread begins another capture, waits for FRAME_START

4. system freezing activates

5. "finish" thread completes the capture and freezes because done-list is empty

6. "start" thread gets FRAME_START, issues another capture and freezes

Quoted 7 lines
Quoted 3 lines

This will not happen as we allow double buffering done list will not be empty till stream stop happens

There will always be 1 outstanding frame in done list

Correction, there will always be 1 outstanding buffer except beginning during beginning of stream.

Except during beginning frames, done list will not be empty for all subsequent streaming process

Also to be clear, hardware sees next frame start event prior to previous frame mw_ack event as mw_ack event happens after frame end. So once initial buffer got queued to done list to finish processes, while waiting for mw_ack next frame start happens and pushes next buffer to done list.

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 6 lines

My understanding is buffer updates/release should not happen after frozen state. So we should let frame capture of outstanding buffer to finish before freezing in capture_finish thread.

Quoted 8 lines

But for capture_start thread we can unconditionally freeze before dequeuing next buffer for capture.

With this when both threads are in frozen state and no buffer updates/captures will happen after frozen state.

I think its not required to finish streaming of all frames completely to let threads to enter frozen state as streaming can be continuous as well.

Yes, only freezing in the middle of IO should be avoided.

https://lwn.net/Articles/705269/

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

Hi Dmitry,

Will update in v12 to not allow freeze in middle of a frame capture.

Can you please confirm on above if you agree to allow freeze to happen in b/w frame captures?

Also as most feedback has been received from you by now, appreciate if you can provide all in this v11 if you have anything else so we will not have any new changes after v12.

I'll take another look tomorrow / during weekend and let you know.

#27 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

30.04.2020 23:02, Sowjanya Komatineni пишет:

Quoted 99 lines · Sowjanya Komatineni
Quoted 97 lines · Sowjanya Komatineni
Quoted 85 lines · Dmitry Osipenko
Quoted 49 lines

30.04.2020 22:09, Sowjanya Komatineni пишет:

Quoted 48 lines · Sowjanya Komatineni
Quoted 47 lines · Sowjanya Komatineni
Quoted 37 lines · Sowjanya Komatineni
Quoted 36 lines · Sowjanya Komatineni
Quoted 35 lines · Dmitry Osipenko
Quoted 22 lines

30.04.2020 17:02, Dmitry Osipenko пишет:

Quoted 15 lines

30.04.2020 16:56, Dmitry Osipenko пишет:

Quoted 14 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

Quoted 9 lines

+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();

I guess it won't be great to freeze in the middle of a capture process, so:
         if (list_empty(&chan->done)) try_to_freeze();

Quoted 6 lines

And here should be some locking protection in order not race with
the
chan_capture_kthread_start because kthread_finish could freeze before
kthread_start.

Quoted 7 lines

Or maybe both start / finish threads should simply be allowed to freeze
only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
      list_empty(&chan->done))
     try_to_freeze();

good to freeze when not in middle of the frame capture but why should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

I guess we can freeze before dequeue for capture and in finish thread we can freeze after capture done. This also don't need to check for list_empty with freeze to allow between frame captures.

Also if we add check for both lists empty, freeze is not allowed as long as streaming is going on and in case of continuous streaming freeze will never happen.

To allow freeze b/w frames (but not in middle of a frame),

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

for capture_start thread, probably we can do unconditional try_to_freeze()

Is it possible to use wait_event_freezable()?

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Will the wait_event_interruptible() be woken up when system freezes?

Based on wait_event_freezable implementation, looks like it similar to wait_event_interruptible + try_to_free() as it does freezable_schedule unlike schedule with wait_event_interruptible.

So using this for capture_start may be ok to allow freeze before start of frame. But can't use for capture_finish as this is same as wait_event_interruptible followed by unconditional try_to_freeze.

Quoted 18 lines
Quoted 3 lines
Quoted 3 lines

for capture_finish thread, at end of capture done we can do try_to_freeze() only when done list is empty

This doesn't prevent situation where the done-list is empty and the "finish" thread freezes, in the same time the "start" thread issues new capture and then freezes too.

1. "start" thread issues capture

2. "finish" thread wakes and waits for the capture to complete

3. "start" thread begins another capture, waits for FRAME_START

4. system freezing activates

5. "finish" thread completes the capture and freezes because done-list is empty

Quoted 6 lines
Quoted 1 line

6. "start" thread gets FRAME_START, issues another capture and freezes

This will not happen as we allow double buffering done list will not be empty till stream stop happens

There will always be 1 outstanding frame in done list

Correction, there will always be 1 outstanding buffer except beginning during beginning of stream.

Quoted 8 lines
Quoted 2 lines

Except during beginning frames, done list will not be empty for all subsequent streaming process

Also to be clear, hardware sees next frame start event prior to previous frame mw_ack event as mw_ack event happens after frame end. So once initial buffer got queued to done list to finish processes, while waiting for mw_ack next frame start happens and pushes next buffer to done list.

What about this variant:

1. "start" thread wakes up to start capture

2. system freezing activates

3. "finish" thread wakes up and freezes

4. "start" thread issues capture and freezes

And again, I assume that system's freezing should wake wait_event_interruptible(), otherwise it won't be possible to freeze idling threads at all and freezing should fail (IIUC).

And in this case synchronization between start/finish threads should be needed in regards to freezing.

Note that this could be a wrong assumption, I'm not closely familiar with how freezer works.

author maintainer
#28 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 100 lines · Dmitry Osipenko

30.04.2020 23:02, Sowjanya Komatineni пишет:

Quoted 92 lines · Sowjanya Komatineni
Quoted 91 lines · Sowjanya Komatineni
Quoted 79 lines · Dmitry Osipenko
Quoted 49 lines

30.04.2020 22:09, Sowjanya Komatineni пишет:

Quoted 48 lines · Sowjanya Komatineni
Quoted 47 lines · Sowjanya Komatineni
Quoted 37 lines · Sowjanya Komatineni
Quoted 36 lines · Sowjanya Komatineni
Quoted 35 lines · Dmitry Osipenko
Quoted 22 lines

30.04.2020 17:02, Dmitry Osipenko пишет:

Quoted 15 lines

30.04.2020 16:56, Dmitry Osipenko пишет:

Quoted 14 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:
+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();
I guess it won't be great to freeze in the middle of a capture
process, so:
         if (list_empty(&chan->done))
             try_to_freeze();

Quoted 6 lines

And here should be some locking protection in order not race with
the
chan_capture_kthread_start because kthread_finish could freeze before
kthread_start.

Quoted 7 lines

Or maybe both start / finish threads should simply be allowed to freeze
only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
      list_empty(&chan->done))
     try_to_freeze();

good to freeze when not in middle of the frame capture but why should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

I guess we can freeze before dequeue for capture and in finish thread we can freeze after capture done. This also don't need to check for list_empty with freeze to allow between frame captures.

Also if we add check for both lists empty, freeze is not allowed as long as streaming is going on and in case of continuous streaming freeze will never happen.

To allow freeze b/w frames (but not in middle of a frame),

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

for capture_start thread, probably we can do unconditional try_to_freeze()

Is it possible to use wait_event_freezable()?

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Will the wait_event_interruptible() be woken up when system freezes?

Based on wait_event_freezable implementation, looks like it similar to wait_event_interruptible + try_to_free() as it does freezable_schedule unlike schedule with wait_event_interruptible.

So using this for capture_start may be ok to allow freeze before start of frame. But can't use for capture_finish as this is same as wait_event_interruptible followed by unconditional try_to_freeze.

Quoted 14 lines
Quoted 2 lines
Quoted 2 lines

for capture_finish thread, at end of capture done we can do try_to_freeze() only when done list is empty

This doesn't prevent situation where the done-list is empty and the "finish" thread freezes, in the same time the "start" thread issues new capture and then freezes too.

1. "start" thread issues capture

2. "finish" thread wakes and waits for the capture to complete

3. "start" thread begins another capture, waits for FRAME_START

4. system freezing activates

Quoted 8 lines
Quoted 4 lines

5. "finish" thread completes the capture and freezes because done-list is empty

6. "start" thread gets FRAME_START, issues another capture and freezes

This will not happen as we allow double buffering done list will not be empty till stream stop happens

There will always be 1 outstanding frame in done list

Correction, there will always be 1 outstanding buffer except beginning during beginning of stream.

Quoted 7 lines
Quoted 2 lines

Except during beginning frames, done list will not be empty for all subsequent streaming process

Also to be clear, hardware sees next frame start event prior to previous frame mw_ack event as mw_ack event happens after frame end. So once initial buffer got queued to done list to finish processes, while waiting for mw_ack next frame start happens and pushes next buffer to done list.

Quoted 7 lines

What about this variant:

1. "start" thread wakes up to start capture

2. system freezing activates

3. "finish" thread wakes up and freezes

finish thread will wake up only when done list is not empty/kthread_stop/wake even from capture start thread.

Also when I said will allow try_to_free when done list is empty I meant to have this at end of capture_done() in finish thread

Quoted 6 lines

4. "start" thread issues capture and freezes

And again, I assume that system's freezing should wake wait_event_interruptible(), otherwise it won't be possible to freeze idling threads at all and freezing should fail (IIUC).

Based on kernel doc on freezing, looks like when we mark thread as freezable, freeze state happens when we explicitly call try_to_freeze.

I don't think its other way where freeze causes wait_event_interruptible to wake up.

Quoted 2 lines

And in this case synchronization between start/finish threads should be needed in regards to freezing.

Was thinking to have counter to track outstanding frame w.r.t single shot issue b/w start and finish and allow to freeze only when no outstanding frames in process.

This will make sure freeze will not happen when any buffers are in progress

Quoted 2 lines

Note that this could be a wrong assumption, I'm not closely familiar with how freezer works.

author maintainer
#29 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 123 lines · Sowjanya Komatineni
Quoted 100 lines · Dmitry Osipenko

30.04.2020 23:02, Sowjanya Komatineni пишет:

Quoted 92 lines · Sowjanya Komatineni
Quoted 91 lines · Sowjanya Komatineni
Quoted 79 lines · Dmitry Osipenko
Quoted 49 lines

30.04.2020 22:09, Sowjanya Komatineni пишет:

Quoted 48 lines · Sowjanya Komatineni
Quoted 47 lines · Sowjanya Komatineni
Quoted 37 lines · Sowjanya Komatineni
Quoted 36 lines · Sowjanya Komatineni
Quoted 35 lines · Dmitry Osipenko
Quoted 22 lines

30.04.2020 17:02, Dmitry Osipenko пишет:

Quoted 21 lines

30.04.2020 16:56, Dmitry Osipenko пишет:
30.04.2020 01:00, Sowjanya Komatineni пишет:
+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();
I guess it won't be great to freeze in the middle of a capture
process, so:
          if (list_empty(&chan->done))
              try_to_freeze();
And here should be some locking protection in order not race
with
the
chan_capture_kthread_start because kthread_finish could freeze
before
kthread_start.

Quoted 7 lines

Or maybe both start / finish threads should simply be allowed to freeze
only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
       list_empty(&chan->done))
      try_to_freeze();

good to freeze when not in middle of the frame capture but why should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

I guess we can freeze before dequeue for capture and in finish thread we can freeze after capture done. This also don't need to check for list_empty with freeze to allow between frame captures.

Also if we add check for both lists empty, freeze is not allowed as long as streaming is going on and in case of continuous streaming freeze will never happen.

To allow freeze b/w frames (but not in middle of a frame),

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

for capture_start thread, probably we can do unconditional try_to_freeze()

Is it possible to use wait_event_freezable()?

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Will the wait_event_interruptible() be woken up when system freezes?

Based on wait_event_freezable implementation, looks like it similar to wait_event_interruptible + try_to_free() as it does freezable_schedule unlike schedule with wait_event_interruptible.

So using this for capture_start may be ok to allow freeze before start of frame. But can't use for capture_finish as this is same as wait_event_interruptible followed by unconditional try_to_freeze.

Quoted 14 lines
Quoted 2 lines
Quoted 2 lines

for capture_finish thread, at end of capture done we can do try_to_freeze() only when done list is empty

This doesn't prevent situation where the done-list is empty and the "finish" thread freezes, in the same time the "start" thread issues new capture and then freezes too.

1. "start" thread issues capture

2. "finish" thread wakes and waits for the capture to complete

3. "start" thread begins another capture, waits for FRAME_START

4. system freezing activates

Quoted 8 lines
Quoted 4 lines

5. "finish" thread completes the capture and freezes because done-list is empty

6. "start" thread gets FRAME_START, issues another capture and freezes

This will not happen as we allow double buffering done list will not be empty till stream stop happens

There will always be 1 outstanding frame in done list

Correction, there will always be 1 outstanding buffer except beginning during beginning of stream.

Quoted 7 lines
Quoted 2 lines

Except during beginning frames, done list will not be empty for all subsequent streaming process

Also to be clear, hardware sees next frame start event prior to previous frame mw_ack event as mw_ack event happens after frame end. So once initial buffer got queued to done list to finish processes, while waiting for mw_ack next frame start happens and pushes next buffer to done list.

Quoted 7 lines

What about this variant:

1. "start" thread wakes up to start capture

2. system freezing activates

3. "finish" thread wakes up and freezes

finish thread will wake up only when done list is not empty/kthread_stop/wake even from capture start thread.

Also when I said will allow try_to_free when done list is empty I meant to have this at end of capture_done() in finish thread

Quoted 6 lines

4. "start" thread issues capture and freezes

And again, I assume that system's freezing should wake wait_event_interruptible(), otherwise it won't be possible to freeze idling threads at all and freezing should fail (IIUC).

Based on kernel doc on freezing, looks like when we mark thread as freezable, freeze state happens when we explicitly call try_to_freeze.

Quoted 11 lines

I don't think its other way where freeze causes wait_event_interruptible to wake up.

Quoted 2 lines

And in this case synchronization between start/finish threads should be needed in regards to freezing.

Was thinking to have counter to track outstanding frame w.r.t single shot issue b/w start and finish and allow to freeze only when no outstanding frames in process.

This will make sure freeze will not happen when any buffers are in progress

Quoted 2 lines

Note that this could be a wrong assumption, I'm not closely familiar with how freezer works.

kthread_start can unconditionally allow try_to_freeze before start of frame capture

We can compute captures inflight w.r.t single shot issued during capture start and finished frames by kthread_finish and allow kthread_finish to freeze only when captures inflight is 0.

This allows freeze to happen b/w frames but not in middle of frame

author maintainer
#30 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 120 lines · Sowjanya Komatineni
Quoted 118 lines · Sowjanya Komatineni
Quoted 101 lines · Dmitry Osipenko

30.04.2020 23:02, Sowjanya Komatineni пишет:

Quoted 93 lines · Sowjanya Komatineni
Quoted 92 lines · Sowjanya Komatineni
Quoted 80 lines · Dmitry Osipenko
Quoted 49 lines

30.04.2020 22:09, Sowjanya Komatineni пишет:

Quoted 48 lines · Sowjanya Komatineni
Quoted 47 lines · Sowjanya Komatineni
Quoted 37 lines · Sowjanya Komatineni
Quoted 36 lines · Sowjanya Komatineni
Quoted 35 lines · Dmitry Osipenko
Quoted 29 lines

30.04.2020 17:02, Dmitry Osipenko пишет:
30.04.2020 16:56, Dmitry Osipenko пишет:
30.04.2020 01:00, Sowjanya Komatineni пишет:
+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();
I guess it won't be great to freeze in the middle of a capture
process, so:
          if (list_empty(&chan->done))
              try_to_freeze();
And here should be some locking protection in order not race
with
the
chan_capture_kthread_start because kthread_finish could freeze
before
kthread_start.
Or maybe both start / finish threads should simply be allowed to
freeze
only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
       list_empty(&chan->done))
      try_to_freeze();

good to freeze when not in middle of the frame capture but why should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

I guess we can freeze before dequeue for capture and in finish thread we can freeze after capture done. This also don't need to check for list_empty with freeze to allow between frame captures.

Also if we add check for both lists empty, freeze is not allowed as long as streaming is going on and in case of continuous streaming freeze will never happen.

To allow freeze b/w frames (but not in middle of a frame),

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

for capture_start thread, probably we can do unconditional try_to_freeze()

Is it possible to use wait_event_freezable()?

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Will the wait_event_interruptible() be woken up when system freezes?

Based on wait_event_freezable implementation, looks like it similar to wait_event_interruptible + try_to_free() as it does freezable_schedule unlike schedule with wait_event_interruptible.

So using this for capture_start may be ok to allow freeze before start of frame. But can't use for capture_finish as this is same as wait_event_interruptible followed by unconditional try_to_freeze.

Quoted 14 lines
Quoted 2 lines
Quoted 2 lines

for capture_finish thread, at end of capture done we can do try_to_freeze() only when done list is empty

This doesn't prevent situation where the done-list is empty and the "finish" thread freezes, in the same time the "start" thread issues new capture and then freezes too.

1. "start" thread issues capture

2. "finish" thread wakes and waits for the capture to complete

3. "start" thread begins another capture, waits for FRAME_START

4. system freezing activates

Quoted 8 lines
Quoted 4 lines

5. "finish" thread completes the capture and freezes because done-list is empty

6. "start" thread gets FRAME_START, issues another capture and freezes

This will not happen as we allow double buffering done list will not be empty till stream stop happens

There will always be 1 outstanding frame in done list

Correction, there will always be 1 outstanding buffer except beginning during beginning of stream.

Quoted 7 lines
Quoted 2 lines

Except during beginning frames, done list will not be empty for all subsequent streaming process

Also to be clear, hardware sees next frame start event prior to previous frame mw_ack event as mw_ack event happens after frame end. So once initial buffer got queued to done list to finish processes, while waiting for mw_ack next frame start happens and pushes next buffer to done list.

Quoted 7 lines

What about this variant:

1. "start" thread wakes up to start capture

2. system freezing activates

3. "finish" thread wakes up and freezes

finish thread will wake up only when done list is not empty/kthread_stop/wake even from capture start thread.

Also when I said will allow try_to_free when done list is empty I meant to have this at end of capture_done() in finish thread

Quoted 3 lines

4. "start" thread issues capture and freezes

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

And again, I assume that system's freezing should wake wait_event_interruptible(), otherwise it won't be possible to freeze idling threads at all and freezing should fail (IIUC).

Based on kernel doc on freezing, looks like when we mark thread as freezable, freeze state happens when we explicitly call try_to_freeze.

I don't think its other way where freeze causes wait_event_interruptible to wake up.

Based on my understanding when we mark thread as freezable,

with wait_event_freezable() - after wait event, it invokes try_to_freeze(). So frozen state enters unconditionally with this.

with wait_event_interruptible - we do try_to_freeze when its safe to enter frozen state.

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Quoted 18 lines
Quoted 10 lines
Quoted 3 lines

And in this case synchronization between start/finish threads should be needed in regards to freezing.

Was thinking to have counter to track outstanding frame w.r.t single shot issue b/w start and finish and allow to freeze only when no outstanding frames in process.

This will make sure freeze will not happen when any buffers are in progress

Quoted 2 lines

Note that this could be a wrong assumption, I'm not closely familiar with how freezer works.

kthread_start can unconditionally allow try_to_freeze before start of frame capture

We can compute captures inflight w.r.t single shot issued during capture start and finished frames by kthread_finish and allow kthread_finish to freeze only when captures inflight is 0.

This allows freeze to happen b/w frames but not in middle of frame

author maintainer
#31 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 130 lines · Sowjanya Komatineni
Quoted 120 lines · Sowjanya Komatineni
Quoted 118 lines · Sowjanya Komatineni
Quoted 101 lines · Dmitry Osipenko

30.04.2020 23:02, Sowjanya Komatineni пишет:

Quoted 93 lines · Sowjanya Komatineni
Quoted 92 lines · Sowjanya Komatineni
Quoted 80 lines · Dmitry Osipenko
Quoted 49 lines

30.04.2020 22:09, Sowjanya Komatineni пишет:

Quoted 48 lines · Sowjanya Komatineni
Quoted 47 lines · Sowjanya Komatineni
Quoted 37 lines · Sowjanya Komatineni
Quoted 36 lines · Sowjanya Komatineni
Quoted 35 lines · Dmitry Osipenko

30.04.2020 17:02, Dmitry Osipenko пишет:
30.04.2020 16:56, Dmitry Osipenko пишет:
30.04.2020 01:00, Sowjanya Komatineni пишет:
+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();
I guess it won't be great to freeze in the middle of a capture
process, so:
          if (list_empty(&chan->done))
              try_to_freeze();
And here should be some locking protection in order not race
with
the
chan_capture_kthread_start because kthread_finish could freeze
before
kthread_start.
Or maybe both start / finish threads should simply be allowed to
freeze
only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
       list_empty(&chan->done))
      try_to_freeze();
good to freeze when not in middle of the frame capture but why
should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

I guess we can freeze before dequeue for capture and in finish
thread we can freeze after capture done. This also don't need to
check for list_empty with freeze to allow between frame captures.

Also if we add check for both lists empty, freeze is not allowed as long as streaming is going on and in case of continuous streaming freeze will never happen.

To allow freeze b/w frames (but not in middle of a frame),

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

for capture_start thread, probably we can do unconditional try_to_freeze()

Is it possible to use wait_event_freezable()?

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Will the wait_event_interruptible() be woken up when system freezes?

Based on wait_event_freezable implementation, looks like it similar to wait_event_interruptible + try_to_free() as it does freezable_schedule unlike schedule with wait_event_interruptible.

So using this for capture_start may be ok to allow freeze before start of frame. But can't use for capture_finish as this is same as wait_event_interruptible followed by unconditional try_to_freeze.

Quoted 14 lines
Quoted 2 lines
Quoted 2 lines

for capture_finish thread, at end of capture done we can do try_to_freeze() only when done list is empty

This doesn't prevent situation where the done-list is empty and the "finish" thread freezes, in the same time the "start" thread issues new capture and then freezes too.

1. "start" thread issues capture

2. "finish" thread wakes and waits for the capture to complete

3. "start" thread begins another capture, waits for FRAME_START

4. system freezing activates

Quoted 8 lines
Quoted 4 lines

5. "finish" thread completes the capture and freezes because done-list is empty

6. "start" thread gets FRAME_START, issues another capture and freezes

This will not happen as we allow double buffering done list will not be empty till stream stop happens

There will always be 1 outstanding frame in done list

Correction, there will always be 1 outstanding buffer except beginning during beginning of stream.

Quoted 7 lines
Quoted 2 lines

Except during beginning frames, done list will not be empty for all subsequent streaming process

Also to be clear, hardware sees next frame start event prior to previous frame mw_ack event as mw_ack event happens after frame end. So once initial buffer got queued to done list to finish processes, while waiting for mw_ack next frame start happens and pushes next buffer to done list.

Quoted 7 lines

What about this variant:

1. "start" thread wakes up to start capture

2. system freezing activates

3. "finish" thread wakes up and freezes

finish thread will wake up only when done list is not empty/kthread_stop/wake even from capture start thread.

Also when I said will allow try_to_free when done list is empty I meant to have this at end of capture_done() in finish thread

Quoted 3 lines

4. "start" thread issues capture and freezes

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

And again, I assume that system's freezing should wake wait_event_interruptible(), otherwise it won't be possible to freeze idling threads at all and freezing should fail (IIUC).

Based on kernel doc on freezing, looks like when we mark thread as freezable, freeze state happens when we explicitly call try_to_freeze.

I don't think its other way where freeze causes wait_event_interruptible to wake up.

Quoted 8 lines

Based on my understanding when we mark thread as freezable,

with wait_event_freezable() - after wait event, it invokes try_to_freeze(). So frozen state enters unconditionally with this.

with wait_event_interruptible - we do try_to_freeze when its safe to enter frozen state.

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Sorry correction. When system tries to freeze tasks looks like it will sending signal to thread and wake up happens when signal is sent to thread and freezable thread should invoke try_to_free when its safe to free

Quoted 19 lines
Quoted 19 lines
Quoted 11 lines
Quoted 4 lines

And in this case synchronization between start/finish threads should be needed in regards to freezing.

Was thinking to have counter to track outstanding frame w.r.t single shot issue b/w start and finish and allow to freeze only when no outstanding frames in process.

This will make sure freeze will not happen when any buffers are in progress

Quoted 2 lines

Note that this could be a wrong assumption, I'm not closely familiar with how freezer works.

kthread_start can unconditionally allow try_to_freeze before start of frame capture

We can compute captures inflight w.r.t single shot issued during capture start and finished frames by kthread_finish and allow kthread_finish to freeze only when captures inflight is 0.

This allows freeze to happen b/w frames but not in middle of frame

author maintainer
#32 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 134 lines · Sowjanya Komatineni
Quoted 132 lines · Sowjanya Komatineni
Quoted 120 lines · Sowjanya Komatineni
Quoted 118 lines · Sowjanya Komatineni
Quoted 101 lines · Dmitry Osipenko

30.04.2020 23:02, Sowjanya Komatineni пишет:

Quoted 93 lines · Sowjanya Komatineni
Quoted 92 lines · Sowjanya Komatineni
Quoted 80 lines · Dmitry Osipenko
Quoted 49 lines

30.04.2020 22:09, Sowjanya Komatineni пишет:

Quoted 48 lines · Sowjanya Komatineni
Quoted 47 lines · Sowjanya Komatineni
Quoted 37 lines · Sowjanya Komatineni
Quoted 36 lines · Sowjanya Komatineni

On 4/30/20 7:13 AM, Dmitry Osipenko wrote:
30.04.2020 17:02, Dmitry Osipenko пишет:
30.04.2020 16:56, Dmitry Osipenko пишет:
30.04.2020 01:00, Sowjanya Komatineni пишет:
+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();
I guess it won't be great to freeze in the middle of a capture
process, so:
          if (list_empty(&chan->done))
              try_to_freeze();
And here should be some locking protection in order not race
with
the
chan_capture_kthread_start because kthread_finish could freeze
before
kthread_start.
Or maybe both start / finish threads should simply be allowed to
freeze
only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
       list_empty(&chan->done))
      try_to_freeze();
good to freeze when not in middle of the frame capture but why
should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

Quoted 7 lines
Quoted 7 lines

I guess we can freeze before dequeue for capture and in finish
thread we can freeze after capture done. This also don't need to
check for list_empty with freeze to allow between frame captures.

Also if we add check for both lists empty, freeze is not allowed as
long as streaming is going on and in case of continuous streaming
freeze will never happen.

To allow freeze b/w frames (but not in middle of a frame),

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

for capture_start thread, probably we can do unconditional try_to_freeze()

Is it possible to use wait_event_freezable()?

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Will the wait_event_interruptible() be woken up when system freezes?

Based on wait_event_freezable implementation, looks like it similar to wait_event_interruptible + try_to_free() as it does freezable_schedule unlike schedule with wait_event_interruptible.

So using this for capture_start may be ok to allow freeze before start of frame. But can't use for capture_finish as this is same as wait_event_interruptible followed by unconditional try_to_freeze.

Quoted 14 lines
Quoted 2 lines
Quoted 2 lines

for capture_finish thread, at end of capture done we can do try_to_freeze() only when done list is empty

This doesn't prevent situation where the done-list is empty and the "finish" thread freezes, in the same time the "start" thread issues new capture and then freezes too.

1. "start" thread issues capture

2. "finish" thread wakes and waits for the capture to complete

3. "start" thread begins another capture, waits for FRAME_START

4. system freezing activates

Quoted 8 lines
Quoted 4 lines

5. "finish" thread completes the capture and freezes because done-list is empty

6. "start" thread gets FRAME_START, issues another capture and freezes

This will not happen as we allow double buffering done list will not be empty till stream stop happens

There will always be 1 outstanding frame in done list

Correction, there will always be 1 outstanding buffer except beginning during beginning of stream.

Quoted 7 lines
Quoted 2 lines

Except during beginning frames, done list will not be empty for all subsequent streaming process

Also to be clear, hardware sees next frame start event prior to previous frame mw_ack event as mw_ack event happens after frame end. So once initial buffer got queued to done list to finish processes, while waiting for mw_ack next frame start happens and pushes next buffer to done list.

Quoted 7 lines

What about this variant:

1. "start" thread wakes up to start capture

2. system freezing activates

3. "finish" thread wakes up and freezes

finish thread will wake up only when done list is not empty/kthread_stop/wake even from capture start thread.

Also when I said will allow try_to_free when done list is empty I meant to have this at end of capture_done() in finish thread

Quoted 3 lines

4. "start" thread issues capture and freezes

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

And again, I assume that system's freezing should wake wait_event_interruptible(), otherwise it won't be possible to freeze idling threads at all and freezing should fail (IIUC).

Based on kernel doc on freezing, looks like when we mark thread as freezable, freeze state happens when we explicitly call try_to_freeze.

I don't think its other way where freeze causes wait_event_interruptible to wake up.

Based on my understanding when we mark thread as freezable,

Quoted 7 lines
Quoted 6 lines

with wait_event_freezable() - after wait event, it invokes try_to_freeze(). So frozen state enters unconditionally with this.

with wait_event_interruptible - we do try_to_freeze when its safe to enter frozen state.

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Sorry correction. When system tries to freeze tasks looks like it will sending signal to thread and wake up happens when signal is sent to thread and freezable thread should invoke try_to_free when its safe to free

freeze_task() sends fake signal

https://elixir.bootlin.com/linux/v5.7-rc2/source/kernel/freezer.c#L115

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines

And in this case synchronization between start/finish threads should be needed in regards to freezing.

Was thinking to have counter to track outstanding frame w.r.t single shot issue b/w start and finish and allow to freeze only when no outstanding frames in process.

This will make sure freeze will not happen when any buffers are in progress

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

Note that this could be a wrong assumption, I'm not closely familiar with how freezer works.

kthread_start can unconditionally allow try_to_freeze before start of frame capture

We can compute captures inflight w.r.t single shot issued during capture start and finished frames by kthread_finish and allow kthread_finish to freeze only when captures inflight is 0.

This allows freeze to happen b/w frames but not in middle of frame

will have caps inflight check in v12 to allow freeze finish thread only when no captures are in progress

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
author maintainer
#33 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 161 lines · Sowjanya Komatineni
Quoted 134 lines · Sowjanya Komatineni
Quoted 132 lines · Sowjanya Komatineni
Quoted 120 lines · Sowjanya Komatineni
Quoted 118 lines · Sowjanya Komatineni
Quoted 101 lines · Dmitry Osipenko

30.04.2020 23:02, Sowjanya Komatineni пишет:

Quoted 93 lines · Sowjanya Komatineni
Quoted 92 lines · Sowjanya Komatineni
Quoted 80 lines · Dmitry Osipenko
Quoted 49 lines

30.04.2020 22:09, Sowjanya Komatineni пишет:

Quoted 48 lines · Sowjanya Komatineni
Quoted 47 lines · Sowjanya Komatineni
Quoted 44 lines · Sowjanya Komatineni

On 4/30/20 9:04 AM, Sowjanya Komatineni wrote:
On 4/30/20 7:13 AM, Dmitry Osipenko wrote:
30.04.2020 17:02, Dmitry Osipenko пишет:
30.04.2020 16:56, Dmitry Osipenko пишет:
30.04.2020 01:00, Sowjanya Komatineni пишет:
+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();
I guess it won't be great to freeze in the middle of a capture
process, so:
          if (list_empty(&chan->done))
              try_to_freeze();
And here should be some locking protection in order not race
with
the
chan_capture_kthread_start because kthread_finish could freeze
before
kthread_start.
Or maybe both start / finish threads should simply be allowed to
freeze
only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
list_empty(&chan->done))
      try_to_freeze();
good to freeze when not in middle of the frame capture but why
should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

I guess we can freeze before dequeue for capture and in finish
thread we can freeze after capture done. This also don't need to
check for list_empty with freeze to allow between frame captures.

Also if we add check for both lists empty, freeze is not allowed as
long as streaming is going on and in case of continuous streaming
freeze will never happen.

To allow freeze b/w frames (but not in middle of a frame),

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

for capture_start thread, probably we can do unconditional try_to_freeze()

Is it possible to use wait_event_freezable()?

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Will the wait_event_interruptible() be woken up when system freezes?

Based on wait_event_freezable implementation, looks like it similar to wait_event_interruptible + try_to_free() as it does freezable_schedule unlike schedule with wait_event_interruptible.

So using this for capture_start may be ok to allow freeze before start of frame. But can't use for capture_finish as this is same as wait_event_interruptible followed by unconditional try_to_freeze.

Quoted 14 lines
Quoted 2 lines
Quoted 2 lines

for capture_finish thread, at end of capture done we can do try_to_freeze() only when done list is empty

This doesn't prevent situation where the done-list is empty and the "finish" thread freezes, in the same time the "start" thread issues new capture and then freezes too.

1. "start" thread issues capture

2. "finish" thread wakes and waits for the capture to complete

3. "start" thread begins another capture, waits for FRAME_START

4. system freezing activates

Quoted 8 lines
Quoted 4 lines

5. "finish" thread completes the capture and freezes because done-list is empty

6. "start" thread gets FRAME_START, issues another capture and freezes

This will not happen as we allow double buffering done list will not be empty till stream stop happens

There will always be 1 outstanding frame in done list

Correction, there will always be 1 outstanding buffer except beginning during beginning of stream.

Quoted 7 lines
Quoted 2 lines

Except during beginning frames, done list will not be empty for all subsequent streaming process

Also to be clear, hardware sees next frame start event prior to previous frame mw_ack event as mw_ack event happens after frame end. So once initial buffer got queued to done list to finish processes, while waiting for mw_ack next frame start happens and pushes next buffer to done list.

Quoted 7 lines

What about this variant:

1. "start" thread wakes up to start capture

2. system freezing activates

3. "finish" thread wakes up and freezes

finish thread will wake up only when done list is not empty/kthread_stop/wake even from capture start thread.

Also when I said will allow try_to_free when done list is empty I meant to have this at end of capture_done() in finish thread

Quoted 3 lines

4. "start" thread issues capture and freezes

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

And again, I assume that system's freezing should wake wait_event_interruptible(), otherwise it won't be possible to freeze idling threads at all and freezing should fail (IIUC).

Based on kernel doc on freezing, looks like when we mark thread as freezable, freeze state happens when we explicitly call try_to_freeze.

I don't think its other way where freeze causes wait_event_interruptible to wake up.

Based on my understanding when we mark thread as freezable,

Quoted 7 lines
Quoted 6 lines

with wait_event_freezable() - after wait event, it invokes try_to_freeze(). So frozen state enters unconditionally with this.

with wait_event_interruptible - we do try_to_freeze when its safe to enter frozen state.

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Sorry correction. When system tries to freeze tasks looks like it will sending signal to thread and wake up happens when signal is sent to thread and freezable thread should invoke try_to_free when its safe to free

freeze_task() sends fake signal

https://elixir.bootlin.com/linux/v5.7-rc2/source/kernel/freezer.c#L115

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 5 lines

And in this case synchronization between start/finish threads should be needed in regards to freezing.

Was thinking to have counter to track outstanding frame w.r.t single shot issue b/w start and finish and allow to freeze only when no outstanding frames in process.

This will make sure freeze will not happen when any buffers are in progress

Quoted 2 lines

Note that this could be a wrong assumption, I'm not closely familiar with how freezer works.

Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

kthread_start can unconditionally allow try_to_freeze before start of frame capture

We can compute captures inflight w.r.t single shot issued during capture start and finished frames by kthread_finish and allow kthread_finish to freeze only when captures inflight is 0.

This allows freeze to happen b/w frames but not in middle of frame

will have caps inflight check in v12 to allow freeze finish thread only when no captures are in progress

try_to_freeze() returns thread frozen state and looks like we can use this in kthread finish to allow finish thread to freeze only when kthread_start is already frozen and no buffers in progress/initiated for capture.

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#41 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

02.05.2020 06:55, Sowjanya Komatineni пишет:

Quoted 159 lines · Sowjanya Komatineni
Quoted 157 lines · Sowjanya Komatineni
Quoted 126 lines · Sowjanya Komatineni
Quoted 123 lines · Sowjanya Komatineni
Quoted 120 lines · Sowjanya Komatineni
Quoted 80 lines · Sowjanya Komatineni
Quoted 68 lines · Sowjanya Komatineni
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 15 lines

And in this case synchronization between start/finish
threads should be
needed in regards to freezing.

Was thinking to have counter to track outstanding frame
w.r.t single shot issue b/w start and finish and allow to
freeze only when no outstanding frames in process.

This will make sure freeze will not happen when any buffers
are in progress

Note that this could be a wrong assumption, I'm not
closely familiar
with how freezer works.

kthread_start can unconditionally allow try_to_freeze before start of frame capture

We can compute captures inflight w.r.t single shot issued during capture start and finished frames by kthread_finish and allow kthread_finish to freeze only when captures inflight is 0.

This allows freeze to happen b/w frames but not in middle of frame

Quoted 9 lines
Quoted 2 lines

will have caps inflight check in v12 to allow freeze finish thread only when no captures are in progress

try_to_freeze() returns thread frozen state and looks like we can use this in kthread finish to allow finish thread to freeze only when kthread_start is already frozen and no buffers in progress/initiated for capture.

chan->capture_frozen holds frozen state returned from try_to_freeze() in start kthread

chan->capture_reqs increments after every single shot issued.

static int chan_capture_kthread_finish(void *data)

{
    struct tegra_vi_channel *chan = data;
    struct tegra_channel_buffer *buf;
    int caps_inflight;

    set_freezable();

    while (1) {
        wait_event_interruptible(chan->done_wait,
                     !list_empty(&chan->done) ||
                     kthread_should_stop());

        /* dequeue buffers and finish capture */ buf = dequeue_buf_done(chan); while (buf) { tegra_channel_capture_done(chan, buf); buf = dequeue_buf_done(chan); }

        if (kthread_should_stop())
            break;

Quoted 7 lines

        caps_inflight = chan->capture_reqs - chan->sequence; if (chan->capture_frozen && !caps_inflight) try_to_freeze();
    }

    return 0;
}

Quoted 7 lines

Freezing happens prior to suspend() during suspend entry and when we implement suspend/resume during suspend we stop streaming where we stop threads anyway.

So, was thinking why we need these threads freezable here?

Hi Dmitry,

Did some testing and below are latest observation and fix I tested.

wait_event_interruptible() uses schedule() which blocks the freezer. When I do suspend while keeping streaming active in background, I see freezing of these threads fail and call trace shows __schedule -> __switch_to from these kthreads.

wait_event_freezable() uses freezable_schedule() which should not block the freezer but we can't use this here as we need conditional try_to_freeze().

So, doing below sequence works where we set PF_FREEZER_SKIP flag thru freezer_not_count() before wait_event which calls schedule() and remove PF_FREEZER_SKIP after schedule allows try_to_freeze to work and also conditional try_to_freeze below prevents freezing thread in middle of capture.

while (1) {
    freezer_not_count()
    wait_event_interruptible()
    freezer_count()
    ...
    ...
    if (chan->capture_frozen && !caps_inflight)
        try_to_freeze()
}

Quoted 15 lines
Quoted 3 lines
Quoted 3 lines

Please comment if you agree with above sequence. Will include this in v12.

sorry, freezer_count() does try_to_freeze after clearing skip flag. So, dont think we can use this as we need conditional try_to_freeze. Please ignore above sequence.

Quoted 9 lines
Quoted 1 line

Or probably we can take closer look on this later when we add suspend/resume support as it need more testing as well.

As this is initial series which has TPG only I think we shouldn't get blocked on this now. Series-2 and 3 will be for sensor support and on next series when we add suspend/resume will look into this.

When freeze activity starts and in case if finish thread freezes prior to start thread issuing capture, its the VI hardware writes data to the allocated buffer address.

finish thread just checks for the event from the hardware and we don't handle/process directly on memory in this driver.

So even we freeze done thread when single shot is issued frame buffer gets updated.

In case if capture thread is frozen there will not buffers queued to process by finish thread. So, this will not be an issue.

Quoted 8 lines
Quoted 3 lines

So, probably we don't need to do conditional try_to_freeze and what we have should work good in this corner case.

I still need to change wait_event_interruptible() to wait_event_freezable() but no need to synchronize finish thread freeze with start thread as even on issuing capture start its vi hardware that does frame buffer update and finish thread just checks for mw_ack event and returns buffer to application.

The problem we are primarily trying to avoid is to have suspending being done in the middle of IO.

IIUC, even if system will be suspended in the middle of VI IO, it won't be fatal. In worst case the buffer capture should fail on resume from suspend. Could you please try to simulate this potential issue and see what result will be on suspending in the middle of VI IO?

We don't want to suspend system / stop streaming in the middle of IO, so this problem of a proper threads tear-down still exists. It should become easier to resolve the problem in a case of a proper suspending callback because the "start" thread could be turned down at any time, so it should be easier to maintain a proper tear-down order when threads are fully controlled by the driver, i.e. the "start" thread goes down first and the "finish" is second, blocking until the capture is completed.

I think yours suggestion about dropping the freezing from the threads for now and returning back to it later on (once a proper suspend/resume support will be added) sounds reasonable.

But if you'd want to keep the freezing, then the easy solution could be like that:

1. "start" thread could freeze at any time
2. "finish" thread could freeze only when the "start" thread is frozen
and capture isn't in-progress. Use frozen(kthread_start_capture) to check the freezing state.

https://elixir.bootlin.com/linux/v5.7-rc3/source/include/linux/freezer.h#L25

author maintainer
#42 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 178 lines · Dmitry Osipenko

02.05.2020 06:55, Sowjanya Komatineni пишет:

Quoted 146 lines · Sowjanya Komatineni
Quoted 145 lines · Sowjanya Komatineni
Quoted 116 lines · Sowjanya Komatineni
Quoted 114 lines · Sowjanya Komatineni
Quoted 112 lines · Sowjanya Komatineni
Quoted 70 lines · Sowjanya Komatineni
Quoted 68 lines · Sowjanya Komatineni
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

And in this case synchronization between start/finish
threads should be
needed in regards to freezing.
Was thinking to have counter to track outstanding frame
w.r.t single shot issue b/w start and finish and allow to
freeze only when no outstanding frames in process.

This will make sure freeze will not happen when any buffers
are in progress

Note that this could be a wrong assumption, I'm not
closely familiar
with how freezer works.
kthread_start can unconditionally allow try_to_freeze before
start of frame capture

We can compute captures inflight w.r.t single shot issued
during capture start and finished frames by kthread_finish
and allow kthread_finish to freeze only when captures
inflight is 0.

This allows freeze to happen b/w frames but not in middle of
frame

Quoted 8 lines
Quoted 2 lines

will have caps inflight check in v12 to allow freeze finish thread only when no captures are in progress

try_to_freeze() returns thread frozen state and looks like we can use this in kthread finish to allow finish thread to freeze only when kthread_start is already frozen and no buffers in progress/initiated for capture.

chan->capture_frozen holds frozen state returned from try_to_freeze() in start kthread

chan->capture_reqs increments after every single shot issued.

static int chan_capture_kthread_finish(void *data)

{
    struct tegra_vi_channel *chan = data;
    struct tegra_channel_buffer *buf;
    int caps_inflight;

    set_freezable();

    while (1) { wait_event_interruptible(chan->done_wait, !list_empty(&chan->done) || kthread_should_stop());

        /* dequeue buffers and finish capture */ buf = dequeue_buf_done(chan); while (buf) { tegra_channel_capture_done(chan, buf); buf = dequeue_buf_done(chan); }

        if (kthread_should_stop())
            break;

        caps_inflight = chan->capture_reqs - chan->sequence; if (chan->capture_frozen && !caps_inflight) try_to_freeze();
    }

Quoted 10 lines
Quoted 2 lines

    return 0;
}

Freezing happens prior to suspend() during suspend entry and when we implement suspend/resume during suspend we stop streaming where we stop threads anyway.

So, was thinking why we need these threads freezable here?

Hi Dmitry,

Did some testing and below are latest observation and fix I tested.

wait_event_interruptible() uses schedule() which blocks the freezer. When I do suspend while keeping streaming active in background, I see freezing of these threads fail and call trace shows __schedule -> __switch_to from these kthreads.

wait_event_freezable() uses freezable_schedule() which should not block the freezer but we can't use this here as we need conditional try_to_freeze().

So, doing below sequence works where we set PF_FREEZER_SKIP flag thru freezer_not_count() before wait_event which calls schedule() and remove PF_FREEZER_SKIP after schedule allows try_to_freeze to work and also conditional try_to_freeze below prevents freezing thread in middle of capture.

while (1) {
    freezer_not_count()
    wait_event_interruptible()
    freezer_count()
    ...
    ...
    if (chan->capture_frozen && !caps_inflight)
        try_to_freeze()
}

Quoted 14 lines
Quoted 3 lines
Quoted 3 lines

Please comment if you agree with above sequence. Will include this in v12.

sorry, freezer_count() does try_to_freeze after clearing skip flag. So, dont think we can use this as we need conditional try_to_freeze. Please ignore above sequence.

Quoted 8 lines

Or probably we can take closer look on this later when we add suspend/resume support as it need more testing as well.

As this is initial series which has TPG only I think we shouldn't get blocked on this now. Series-2 and 3 will be for sensor support and on next series when we add suspend/resume will look into this.

When freeze activity starts and in case if finish thread freezes prior to start thread issuing capture, its the VI hardware writes data to the allocated buffer address.

finish thread just checks for the event from the hardware and we don't handle/process directly on memory in this driver.

So even we freeze done thread when single shot is issued frame buffer gets updated.

In case if capture thread is frozen there will not buffers queued to process by finish thread. So, this will not be an issue.

Quoted 8 lines
Quoted 3 lines

So, probably we don't need to do conditional try_to_freeze and what we have should work good in this corner case.

I still need to change wait_event_interruptible() to wait_event_freezable() but no need to synchronize finish thread freeze with start thread as even on issuing capture start its vi hardware that does frame buffer update and finish thread just checks for mw_ack event and returns buffer to application.

The problem we are primarily trying to avoid is to have suspending being done in the middle of IO.

IIUC, even if system will be suspended in the middle of VI IO, it won't be fatal. In worst case the buffer capture should fail on resume from suspend. Could you please try to simulate this potential issue and see what result will be on suspending in the middle of VI IO?

We don't want to suspend system / stop streaming in the middle of IO, so this problem of a proper threads tear-down still exists. It should become easier to resolve the problem in a case of a proper suspending callback because the "start" thread could be turned down at any time, so it should be easier to maintain a proper tear-down order when threads are fully controlled by the driver, i.e. the "start" thread goes down first and the "finish" is second, blocking until the capture is completed.

I think yours suggestion about dropping the freezing from the threads for now and returning back to it later on (once a proper suspend/resume support will be added) sounds reasonable.

But if you'd want to keep the freezing, then the easy solution could be like that:

Quoted 6 lines

1. "start" thread could freeze at any time
2. "finish" thread could freeze only when the "start" thread is frozen
and capture isn't in-progress. Use frozen(kthread_start_capture) to check the freezing state.

https://elixir.bootlin.com/linux/v5.7-rc3/source/include/linux/freezer.h#L25

That's exactly what I tried, below is the snippet.

But as mentioned I am seeing freezing fail when I wait_event_interruptible() in either of the threads.

   60.368709] Call trace:
[   60.371216] __switch_to+0xec/0x140
[   60.374768] __schedule+0x32c/0x668
[   60.378315] schedule+0x78/0x118
[   60.381606]  chan_capture_kthread_finish+0x244/0x2a0 [tegra_video] [   60.387865] kthread+0x124/0x150
[   60.391150] ret_from_fork+0x10/0x1c

wait_event_interruptible() API uses schedule() which blocks freezer while wait_event_freezable APIs uses freezable_schedule() which allows to skip freezer during schedule and then clears skip and calls try_to_freeze()

But we can't use wait_event_freezable() here as we need conditional freeze.

    while (1) {
        caps_inflight = chan->capture_reqs - chan->sequence; if (frozen(chan->kthread_start_capture) && !caps_inflight) wait_event_freezable(chan->done_wait, !list_empty(&chan->done) || kthread_should_stop());
        else
            wait_event_interruptible(chan->done_wait, !list_empty(&chan->done) || kthread_should_stop());

        /* dequeue buffers and finish capture */

        ...

        ...

        if (kthread_should_stop())
            break;
    }

author maintainer
#43 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 165 lines · Sowjanya Komatineni
Quoted 163 lines · Dmitry Osipenko

02.05.2020 06:55, Sowjanya Komatineni пишет:

Quoted 146 lines · Sowjanya Komatineni
Quoted 145 lines · Sowjanya Komatineni
Quoted 116 lines · Sowjanya Komatineni
Quoted 114 lines · Sowjanya Komatineni
Quoted 112 lines · Sowjanya Komatineni
Quoted 70 lines · Sowjanya Komatineni
Quoted 68 lines · Sowjanya Komatineni
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

And in this case synchronization between start/finish
threads should be
needed in regards to freezing.
Was thinking to have counter to track outstanding frame
w.r.t single shot issue b/w start and finish and allow to
freeze only when no outstanding frames in process.

This will make sure freeze will not happen when any buffers
are in progress

Note that this could be a wrong assumption, I'm not
closely familiar
with how freezer works.
kthread_start can unconditionally allow try_to_freeze before
start of frame capture

We can compute captures inflight w.r.t single shot issued
during capture start and finished frames by kthread_finish
and allow kthread_finish to freeze only when captures
inflight is 0.

This allows freeze to happen b/w frames but not in middle of
frame

Quoted 8 lines
Quoted 2 lines

will have caps inflight check in v12 to allow freeze finish thread only when no captures are in progress

try_to_freeze() returns thread frozen state and looks like we can use this in kthread finish to allow finish thread to freeze only when kthread_start is already frozen and no buffers in progress/initiated for capture.

chan->capture_frozen holds frozen state returned from try_to_freeze() in start kthread

chan->capture_reqs increments after every single shot issued.

static int chan_capture_kthread_finish(void *data)

{
     struct tegra_vi_channel *chan = data;
     struct tegra_channel_buffer *buf;
     int caps_inflight;

     set_freezable();

     while (1) {
wait_event_interruptible(chan->done_wait,
 !list_empty(&chan->done) ||
                      kthread_should_stop());

         /* dequeue buffers and finish capture */ buf = dequeue_buf_done(chan); while (buf) { tegra_channel_capture_done(chan, buf); buf = dequeue_buf_done(chan); }

         if (kthread_should_stop())
             break;

         caps_inflight = chan->capture_reqs - chan->sequence; if (chan->capture_frozen && !caps_inflight) try_to_freeze();
     }

Quoted 10 lines
Quoted 2 lines

     return 0;
}

Freezing happens prior to suspend() during suspend entry and when we implement suspend/resume during suspend we stop streaming where we stop threads anyway.

So, was thinking why we need these threads freezable here?

Hi Dmitry,

Did some testing and below are latest observation and fix I tested.

wait_event_interruptible() uses schedule() which blocks the freezer. When I do suspend while keeping streaming active in background, I see freezing of these threads fail and call trace shows __schedule -> __switch_to from these kthreads.

wait_event_freezable() uses freezable_schedule() which should not block the freezer but we can't use this here as we need conditional try_to_freeze().

So, doing below sequence works where we set PF_FREEZER_SKIP flag thru freezer_not_count() before wait_event which calls schedule() and remove PF_FREEZER_SKIP after schedule allows try_to_freeze to work and also conditional try_to_freeze below prevents freezing thread in middle of capture.

while (1) {
     freezer_not_count()
     wait_event_interruptible()
     freezer_count()
     ...
     ...
     if (chan->capture_frozen && !caps_inflight)
         try_to_freeze()
}

Quoted 14 lines
Quoted 3 lines
Quoted 3 lines

Please comment if you agree with above sequence. Will include this in v12.

sorry, freezer_count() does try_to_freeze after clearing skip flag. So, dont think we can use this as we need conditional try_to_freeze. Please ignore above sequence.

Quoted 8 lines

Or probably we can take closer look on this later when we add suspend/resume support as it need more testing as well.

As this is initial series which has TPG only I think we shouldn't get blocked on this now. Series-2 and 3 will be for sensor support and on next series when we add suspend/resume will look into this.

When freeze activity starts and in case if finish thread freezes prior to start thread issuing capture, its the VI hardware writes data to the allocated buffer address.

finish thread just checks for the event from the hardware and we don't handle/process directly on memory in this driver.

So even we freeze done thread when single shot is issued frame buffer gets updated.

In case if capture thread is frozen there will not buffers queued to process by finish thread. So, this will not be an issue.

Quoted 8 lines
Quoted 3 lines

So, probably we don't need to do conditional try_to_freeze and what we have should work good in this corner case.

I still need to change wait_event_interruptible() to wait_event_freezable() but no need to synchronize finish thread freeze with start thread as even on issuing capture start its vi hardware that does frame buffer update and finish thread just checks for mw_ack event and returns buffer to application.

The problem we are primarily trying to avoid is to have suspending being done in the middle of IO.

IIUC, even if system will be suspended in the middle of VI IO, it won't be fatal. In worst case the buffer capture should fail on resume from suspend. Could you please try to simulate this potential issue and see what result will be on suspending in the middle of VI IO?

Quoted 7 lines
Quoted 7 lines

We don't want to suspend system / stop streaming in the middle of IO, so this problem of a proper threads tear-down still exists. It should become easier to resolve the problem in a case of a proper suspending callback because the "start" thread could be turned down at any time, so it should be easier to maintain a proper tear-down order when threads are fully controlled by the driver, i.e. the "start" thread goes down first and the "finish" is second, blocking until the capture is completed.

I don't see issue of tear-down threads in case of suspend as we do stop streaming where thread stop happens on both threads and are stopped only after processing all outstanding buffers.

Regarding freezing activity during suspend, If done thread freezes prior to processing buffers for finish, vi hardware is still active by this time which will update the frame buffer for initiated capture. Driver is not directly involved in this frame buffer update.

Finish thread only checks for completion to return buffers back to the application when done.

Quoted 54 lines
Quoted 7 lines

I think yours suggestion about dropping the freezing from the threads for now and returning back to it later on (once a proper suspend/resume support will be added) sounds reasonable.

But if you'd want to keep the freezing, then the easy solution could be like that:

Quoted 7 lines

   1. "start" thread could freeze at any time
   2. "finish" thread could freeze only when the "start" thread is frozen and capture isn't in-progress. Use frozen(kthread_start_capture) to check the freezing state.

https://elixir.bootlin.com/linux/v5.7-rc3/source/include/linux/freezer.h#L25

That's exactly what I tried, below is the snippet.

But as mentioned I am seeing freezing fail when I wait_event_interruptible() in either of the threads.

   60.368709] Call trace:
[   60.371216] __switch_to+0xec/0x140
[   60.374768] __schedule+0x32c/0x668
[   60.378315] schedule+0x78/0x118
[   60.381606]  chan_capture_kthread_finish+0x244/0x2a0 [tegra_video] [   60.387865] kthread+0x124/0x150
[   60.391150] ret_from_fork+0x10/0x1c

wait_event_interruptible() API uses schedule() which blocks freezer while wait_event_freezable APIs uses freezable_schedule() which allows to skip freezer during schedule and then clears skip and calls try_to_freeze()

But we can't use wait_event_freezable() here as we need conditional freeze.

    while (1) {
        caps_inflight = chan->capture_reqs - chan->sequence; if (frozen(chan->kthread_start_capture) && !caps_inflight) wait_event_freezable(chan->done_wait, !list_empty(&chan->done) || kthread_should_stop());
        else
            wait_event_interruptible(chan->done_wait, !list_empty(&chan->done) || kthread_should_stop());

        /* dequeue buffers and finish capture */

        ...

        ...

        if (kthread_should_stop())
            break;
    }

author maintainer
#44 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 175 lines · Sowjanya Komatineni
Quoted 165 lines · Sowjanya Komatineni
Quoted 163 lines · Dmitry Osipenko

02.05.2020 06:55, Sowjanya Komatineni пишет:

Quoted 146 lines · Sowjanya Komatineni
Quoted 145 lines · Sowjanya Komatineni
Quoted 116 lines · Sowjanya Komatineni
Quoted 114 lines · Sowjanya Komatineni
Quoted 112 lines · Sowjanya Komatineni
Quoted 70 lines · Sowjanya Komatineni
Quoted 68 lines · Sowjanya Komatineni
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

And in this case synchronization between start/finish
threads should be
needed in regards to freezing.
Was thinking to have counter to track outstanding frame
w.r.t single shot issue b/w start and finish and allow to
freeze only when no outstanding frames in process.

This will make sure freeze will not happen when any buffers
are in progress

Note that this could be a wrong assumption, I'm not
closely familiar
with how freezer works.
kthread_start can unconditionally allow try_to_freeze before
start of frame capture

We can compute captures inflight w.r.t single shot issued
during capture start and finished frames by kthread_finish
and allow kthread_finish to freeze only when captures
inflight is 0.

This allows freeze to happen b/w frames but not in middle of
frame

Quoted 8 lines
Quoted 2 lines

will have caps inflight check in v12 to allow freeze finish thread only when no captures are in progress

try_to_freeze() returns thread frozen state and looks like we can use this in kthread finish to allow finish thread to freeze only when kthread_start is already frozen and no buffers in progress/initiated for capture.

chan->capture_frozen holds frozen state returned from try_to_freeze() in start kthread

chan->capture_reqs increments after every single shot issued.

static int chan_capture_kthread_finish(void *data)

{
     struct tegra_vi_channel *chan = data;
     struct tegra_channel_buffer *buf;
     int caps_inflight;

     set_freezable();

     while (1) {
wait_event_interruptible(chan->done_wait,
 !list_empty(&chan->done) ||
                      kthread_should_stop());

         /* dequeue buffers and finish capture */ buf = dequeue_buf_done(chan); while (buf) { tegra_channel_capture_done(chan, buf); buf = dequeue_buf_done(chan); }

         if (kthread_should_stop())
             break;

         caps_inflight = chan->capture_reqs - chan->sequence; if (chan->capture_frozen && !caps_inflight) try_to_freeze();
     }

Quoted 10 lines
Quoted 2 lines

     return 0;
}

Freezing happens prior to suspend() during suspend entry and when we implement suspend/resume during suspend we stop streaming where we stop threads anyway.

So, was thinking why we need these threads freezable here?

Hi Dmitry,

Did some testing and below are latest observation and fix I tested.

wait_event_interruptible() uses schedule() which blocks the freezer. When I do suspend while keeping streaming active in background, I see freezing of these threads fail and call trace shows __schedule -> __switch_to from these kthreads.

wait_event_freezable() uses freezable_schedule() which should not block the freezer but we can't use this here as we need conditional try_to_freeze().

So, doing below sequence works where we set PF_FREEZER_SKIP flag thru freezer_not_count() before wait_event which calls schedule() and remove PF_FREEZER_SKIP after schedule allows try_to_freeze to work and also conditional try_to_freeze below prevents freezing thread in middle of capture.

while (1) {
     freezer_not_count()
     wait_event_interruptible()
     freezer_count()
     ...
     ...
     if (chan->capture_frozen && !caps_inflight)
         try_to_freeze()
}

Quoted 14 lines
Quoted 3 lines
Quoted 3 lines

Please comment if you agree with above sequence. Will include this in v12.

sorry, freezer_count() does try_to_freeze after clearing skip flag. So, dont think we can use this as we need conditional try_to_freeze. Please ignore above sequence.

Quoted 8 lines

Or probably we can take closer look on this later when we add suspend/resume support as it need more testing as well.

As this is initial series which has TPG only I think we shouldn't get blocked on this now. Series-2 and 3 will be for sensor support and on next series when we add suspend/resume will look into this.

When freeze activity starts and in case if finish thread freezes prior to start thread issuing capture, its the VI hardware writes data to the allocated buffer address.

finish thread just checks for the event from the hardware and we don't handle/process directly on memory in this driver.

So even we freeze done thread when single shot is issued frame buffer gets updated.

In case if capture thread is frozen there will not buffers queued to process by finish thread. So, this will not be an issue.

Quoted 8 lines
Quoted 3 lines

So, probably we don't need to do conditional try_to_freeze and what we have should work good in this corner case.

I still need to change wait_event_interruptible() to wait_event_freezable() but no need to synchronize finish thread freeze with start thread as even on issuing capture start its vi hardware that does frame buffer update and finish thread just checks for mw_ack event and returns buffer to application.

The problem we are primarily trying to avoid is to have suspending being done in the middle of IO.

IIUC, even if system will be suspended in the middle of VI IO, it won't be fatal. In worst case the buffer capture should fail on resume from suspend. Could you please try to simulate this potential issue and see what result will be on suspending in the middle of VI IO?

Quoted 7 lines
Quoted 7 lines

We don't want to suspend system / stop streaming in the middle of IO, so this problem of a proper threads tear-down still exists. It should become easier to resolve the problem in a case of a proper suspending callback because the "start" thread could be turned down at any time, so it should be easier to maintain a proper tear-down order when threads are fully controlled by the driver, i.e. the "start" thread goes down first and the "finish" is second, blocking until the capture is completed.

Quoted 5 lines

I don't see issue of tear-down threads in case of suspend as we do stop streaming where thread stop happens on both threads and are stopped only after processing all outstanding buffers.

Regarding freezing activity during suspend, If done thread freezes prior to processing buffers for finish, vi hardware is still active by this time which will update the frame buffer for initiated capture. Driver is not directly involved in this frame buffer update.

Finish thread only checks for completion to return buffers back to the application when done.

when done thread freeze happens after start thread initiated capture, vi hardware continues to update frame buffer for ongoing capture till it hits driver suspend callback. Yes worst case this frame data may not be valid data if invoking of this driver suspend happens immediate after this thread freeze during system suspend.

But driver will still hold buffers to return which will be returned back on resume when threads are out from frozen state.

Quoted 56 lines
Quoted 56 lines
Quoted 9 lines

I think yours suggestion about dropping the freezing from the threads for now and returning back to it later on (once a proper suspend/resume support will be added) sounds reasonable.

But if you'd want to keep the freezing, then the easy solution could be like that:

Quoted 7 lines

   1. "start" thread could freeze at any time
   2. "finish" thread could freeze only when the "start" thread is frozen and capture isn't in-progress. Use frozen(kthread_start_capture) to check the freezing state.

https://elixir.bootlin.com/linux/v5.7-rc3/source/include/linux/freezer.h#L25

That's exactly what I tried, below is the snippet.

But as mentioned I am seeing freezing fail when I wait_event_interruptible() in either of the threads.

   60.368709] Call trace:
[   60.371216] __switch_to+0xec/0x140
[   60.374768] __schedule+0x32c/0x668
[   60.378315] schedule+0x78/0x118
[   60.381606]  chan_capture_kthread_finish+0x244/0x2a0 [tegra_video] [   60.387865] kthread+0x124/0x150
[   60.391150] ret_from_fork+0x10/0x1c

wait_event_interruptible() API uses schedule() which blocks freezer while wait_event_freezable APIs uses freezable_schedule() which allows to skip freezer during schedule and then clears skip and calls try_to_freeze()

But we can't use wait_event_freezable() here as we need conditional freeze.

    while (1) {
        caps_inflight = chan->capture_reqs - chan->sequence; if (frozen(chan->kthread_start_capture) && !caps_inflight) wait_event_freezable(chan->done_wait, !list_empty(&chan->done) || kthread_should_stop());
        else
            wait_event_interruptible(chan->done_wait, !list_empty(&chan->done) || kthread_should_stop());

        /* dequeue buffers and finish capture */

        ...

        ...

        if (kthread_should_stop())
            break;
    }

author maintainer
#45 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 179 lines · Sowjanya Komatineni
Quoted 177 lines · Sowjanya Komatineni
Quoted 165 lines · Sowjanya Komatineni
Quoted 163 lines · Dmitry Osipenko

02.05.2020 06:55, Sowjanya Komatineni пишет:

Quoted 146 lines · Sowjanya Komatineni
Quoted 145 lines · Sowjanya Komatineni
Quoted 116 lines · Sowjanya Komatineni
Quoted 114 lines · Sowjanya Komatineni
Quoted 112 lines · Sowjanya Komatineni
Quoted 70 lines · Sowjanya Komatineni
Quoted 68 lines · Sowjanya Komatineni
Quoted 23 lines
Quoted 23 lines

And in this case synchronization between start/finish
threads should be
needed in regards to freezing.
Was thinking to have counter to track outstanding frame
w.r.t single shot issue b/w start and finish and allow to
freeze only when no outstanding frames in process.

This will make sure freeze will not happen when any buffers
are in progress

Note that this could be a wrong assumption, I'm not
closely familiar
with how freezer works.
kthread_start can unconditionally allow try_to_freeze before
start of frame capture

We can compute captures inflight w.r.t single shot issued
during capture start and finished frames by kthread_finish
and allow kthread_finish to freeze only when captures
inflight is 0.

This allows freeze to happen b/w frames but not in middle of
frame

Quoted 8 lines
Quoted 2 lines

will have caps inflight check in v12 to allow freeze finish
thread only when no captures are in progress

try_to_freeze() returns thread frozen state and looks like we can use this in kthread finish to allow finish thread to freeze only when kthread_start is already frozen and no buffers in progress/initiated for capture.

chan->capture_frozen holds frozen state returned from try_to_freeze() in start kthread

chan->capture_reqs increments after every single shot issued.

static int chan_capture_kthread_finish(void *data)

{
     struct tegra_vi_channel *chan = data;
     struct tegra_channel_buffer *buf;
     int caps_inflight;

     set_freezable();

     while (1) {
wait_event_interruptible(chan->done_wait,
 !list_empty(&chan->done) ||
                      kthread_should_stop());

         /* dequeue buffers and finish capture */ buf = dequeue_buf_done(chan); while (buf) { tegra_channel_capture_done(chan, buf); buf = dequeue_buf_done(chan); }

         if (kthread_should_stop())
             break;

         caps_inflight = chan->capture_reqs - chan->sequence; if (chan->capture_frozen && !caps_inflight) try_to_freeze();
     }

Quoted 10 lines
Quoted 2 lines

     return 0;
}

Freezing happens prior to suspend() during suspend entry and when we implement suspend/resume during suspend we stop streaming where we stop threads anyway.

So, was thinking why we need these threads freezable here?

Hi Dmitry,

Did some testing and below are latest observation and fix I tested.

wait_event_interruptible() uses schedule() which blocks the freezer. When I do suspend while keeping streaming active in background, I see freezing of these threads fail and call trace shows __schedule -> __switch_to from these kthreads.

wait_event_freezable() uses freezable_schedule() which should not block the freezer but we can't use this here as we need conditional try_to_freeze().

So, doing below sequence works where we set PF_FREEZER_SKIP flag thru freezer_not_count() before wait_event which calls schedule() and remove PF_FREEZER_SKIP after schedule allows try_to_freeze to work and also conditional try_to_freeze below prevents freezing thread in middle of capture.

while (1) {
     freezer_not_count()
     wait_event_interruptible()
     freezer_count()
     ...
     ...
     if (chan->capture_frozen && !caps_inflight)
         try_to_freeze()
}

Quoted 14 lines
Quoted 3 lines
Quoted 3 lines

Please comment if you agree with above sequence. Will include this in v12.

sorry, freezer_count() does try_to_freeze after clearing skip flag. So, dont think we can use this as we need conditional try_to_freeze. Please ignore above sequence.

Quoted 8 lines

Or probably we can take closer look on this later when we add suspend/resume support as it need more testing as well.

As this is initial series which has TPG only I think we shouldn't get blocked on this now. Series-2 and 3 will be for sensor support and on next series when we add suspend/resume will look into this.

When freeze activity starts and in case if finish thread freezes prior to start thread issuing capture, its the VI hardware writes data to the allocated buffer address.

finish thread just checks for the event from the hardware and we don't handle/process directly on memory in this driver.

So even we freeze done thread when single shot is issued frame buffer gets updated.

In case if capture thread is frozen there will not buffers queued to process by finish thread. So, this will not be an issue.

Quoted 8 lines
Quoted 3 lines

So, probably we don't need to do conditional try_to_freeze and what we have should work good in this corner case.

I still need to change wait_event_interruptible() to wait_event_freezable() but no need to synchronize finish thread freeze with start thread as even on issuing capture start its vi hardware that does frame buffer update and finish thread just checks for mw_ack event and returns buffer to application.

The problem we are primarily trying to avoid is to have suspending being done in the middle of IO.

IIUC, even if system will be suspended in the middle of VI IO, it won't be fatal. In worst case the buffer capture should fail on resume from suspend. Could you please try to simulate this potential issue and see what result will be on suspending in the middle of VI IO?

Quoted 7 lines
Quoted 7 lines

We don't want to suspend system / stop streaming in the middle of IO, so this problem of a proper threads tear-down still exists. It should become easier to resolve the problem in a case of a proper suspending callback because the "start" thread could be turned down at any time, so it should be easier to maintain a proper tear-down order when threads are fully controlled by the driver, i.e. the "start" thread goes down first and the "finish" is second, blocking until the capture is completed.

I don't see issue of tear-down threads in case of suspend as we do stop streaming where thread stop happens on both threads and are stopped only after processing all outstanding buffers.

Quoted 7 lines
Quoted 3 lines

Regarding freezing activity during suspend, If done thread freezes prior to processing buffers for finish, vi hardware is still active by this time which will update the frame buffer for initiated capture. Driver is not directly involved in this frame buffer update.

Finish thread only checks for completion to return buffers back to the application when done.

when done thread freeze happens after start thread initiated capture, vi hardware continues to update frame buffer for ongoing capture till it hits driver suspend callback. Yes worst case this frame data may not be valid data if invoking of this driver suspend happens immediate after this thread freeze during system suspend.

But driver will still hold buffers to return which will be returned back on resume when threads are out from frozen state.

Also stop stream ioctl request happens during suspend where both threads will be stopped properly. done thread stop happens only after finishing all outstanding buffers.

Stop stream request happens from streaming applications so even without driver suspend/resume implementation currently, streaming will be stopped prior to system  suspend where both threads will be stopped properly (after finishing out standing buffers) and will be resumed by application on system resume

Also tested suspending while streaming with this unconditional freeze, I don't see any issue as application stops stream where v4l_streamoff gets executed during suspend and on resume streaming starts where v4l_streamon happens.

So, I don't see any issue with existing implementation of unconditional freeze.

Quoted 57 lines
Quoted 57 lines
Quoted 57 lines
Quoted 10 lines

I think yours suggestion about dropping the freezing from the threads for now and returning back to it later on (once a proper suspend/resume support will be added) sounds reasonable.

But if you'd want to keep the freezing, then the easy solution could be like that:

Quoted 7 lines

   1. "start" thread could freeze at any time
   2. "finish" thread could freeze only when the "start" thread is frozen and capture isn't in-progress. Use frozen(kthread_start_capture) to check the freezing state.

https://elixir.bootlin.com/linux/v5.7-rc3/source/include/linux/freezer.h#L25

That's exactly what I tried, below is the snippet.

But as mentioned I am seeing freezing fail when I wait_event_interruptible() in either of the threads.

   60.368709] Call trace:
[   60.371216] __switch_to+0xec/0x140
[   60.374768] __schedule+0x32c/0x668
[   60.378315] schedule+0x78/0x118
[   60.381606]  chan_capture_kthread_finish+0x244/0x2a0 [tegra_video] [   60.387865] kthread+0x124/0x150
[   60.391150] ret_from_fork+0x10/0x1c

wait_event_interruptible() API uses schedule() which blocks freezer while wait_event_freezable APIs uses freezable_schedule() which allows to skip freezer during schedule and then clears skip and calls try_to_freeze()

But we can't use wait_event_freezable() here as we need conditional freeze.

    while (1) {
        caps_inflight = chan->capture_reqs - chan->sequence; if (frozen(chan->kthread_start_capture) && !caps_inflight) wait_event_freezable(chan->done_wait, !list_empty(&chan->done) || kthread_should_stop());
        else
            wait_event_interruptible(chan->done_wait, !list_empty(&chan->done) || kthread_should_stop());

        /* dequeue buffers and finish capture */

        ...

        ...

        if (kthread_should_stop())
            break;
    }

author maintainer
#46 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 190 lines · Sowjanya Komatineni
Quoted 179 lines · Sowjanya Komatineni
Quoted 177 lines · Sowjanya Komatineni
Quoted 165 lines · Sowjanya Komatineni
Quoted 163 lines · Dmitry Osipenko

02.05.2020 06:55, Sowjanya Komatineni пишет:

Quoted 146 lines · Sowjanya Komatineni
Quoted 145 lines · Sowjanya Komatineni
Quoted 116 lines · Sowjanya Komatineni
Quoted 114 lines · Sowjanya Komatineni
Quoted 112 lines · Sowjanya Komatineni
Quoted 70 lines · Sowjanya Komatineni
Quoted 68 lines · Sowjanya Komatineni
Quoted 31 lines

And in this case synchronization between start/finish
threads should be
needed in regards to freezing.
Was thinking to have counter to track outstanding frame
w.r.t single shot issue b/w start and finish and allow to
freeze only when no outstanding frames in process.

This will make sure freeze will not happen when any buffers
are in progress

Note that this could be a wrong assumption, I'm not
closely familiar
with how freezer works.
kthread_start can unconditionally allow try_to_freeze before
start of frame capture

We can compute captures inflight w.r.t single shot issued
during capture start and finished frames by kthread_finish
and allow kthread_finish to freeze only when captures
inflight is 0.

This allows freeze to happen b/w frames but not in middle of
frame
will have caps inflight check in v12 to allow freeze finish
thread only when no captures are in progress

try_to_freeze() returns thread frozen state and looks like we
can use this in kthread finish to allow finish thread to freeze
only when kthread_start is already frozen and no buffers in
progress/initiated for capture.

chan->capture_frozen holds frozen state returned from try_to_freeze() in start kthread

chan->capture_reqs increments after every single shot issued.

static int chan_capture_kthread_finish(void *data)

{
     struct tegra_vi_channel *chan = data;
     struct tegra_channel_buffer *buf;
     int caps_inflight;

     set_freezable();

     while (1) {
wait_event_interruptible(chan->done_wait,
 !list_empty(&chan->done) ||
 kthread_should_stop());

         /* dequeue buffers and finish capture */
         buf = dequeue_buf_done(chan);
         while (buf) {
tegra_channel_capture_done(chan, buf);
             buf = dequeue_buf_done(chan);
         }

         if (kthread_should_stop())
             break;

         caps_inflight = chan->capture_reqs - chan->sequence; if (chan->capture_frozen && !caps_inflight) try_to_freeze();
     }

Quoted 10 lines
Quoted 2 lines

     return 0;
}

Freezing happens prior to suspend() during suspend entry and when we implement suspend/resume during suspend we stop streaming where we stop threads anyway.

So, was thinking why we need these threads freezable here?

Hi Dmitry,

Did some testing and below are latest observation and fix I tested.

wait_event_interruptible() uses schedule() which blocks the freezer. When I do suspend while keeping streaming active in background, I see freezing of these threads fail and call trace shows __schedule -> __switch_to from these kthreads.

wait_event_freezable() uses freezable_schedule() which should not block the freezer but we can't use this here as we need conditional try_to_freeze().

So, doing below sequence works where we set PF_FREEZER_SKIP flag thru freezer_not_count() before wait_event which calls schedule() and remove PF_FREEZER_SKIP after schedule allows try_to_freeze to work and also conditional try_to_freeze below prevents freezing thread in middle of capture.

while (1) {
     freezer_not_count()
     wait_event_interruptible()
     freezer_count()
     ...
     ...
     if (chan->capture_frozen && !caps_inflight)
         try_to_freeze()
}

Quoted 14 lines
Quoted 3 lines
Quoted 3 lines

Please comment if you agree with above sequence. Will include this in v12.

sorry, freezer_count() does try_to_freeze after clearing skip flag. So, dont think we can use this as we need conditional try_to_freeze. Please ignore above sequence.

Quoted 8 lines

Or probably we can take closer look on this later when we add suspend/resume support as it need more testing as well.

As this is initial series which has TPG only I think we shouldn't get blocked on this now. Series-2 and 3 will be for sensor support and on next series when we add suspend/resume will look into this.

When freeze activity starts and in case if finish thread freezes prior to start thread issuing capture, its the VI hardware writes data to the allocated buffer address.

finish thread just checks for the event from the hardware and we don't handle/process directly on memory in this driver.

So even we freeze done thread when single shot is issued frame buffer gets updated.

In case if capture thread is frozen there will not buffers queued to process by finish thread. So, this will not be an issue.

Quoted 8 lines
Quoted 3 lines

So, probably we don't need to do conditional try_to_freeze and what we have should work good in this corner case.

I still need to change wait_event_interruptible() to wait_event_freezable() but no need to synchronize finish thread freeze with start thread as even on issuing capture start its vi hardware that does frame buffer update and finish thread just checks for mw_ack event and returns buffer to application.

The problem we are primarily trying to avoid is to have suspending being done in the middle of IO.

IIUC, even if system will be suspended in the middle of VI IO, it won't be fatal. In worst case the buffer capture should fail on resume from suspend. Could you please try to simulate this potential issue and see what result will be on suspending in the middle of VI IO?

Quoted 7 lines
Quoted 7 lines

We don't want to suspend system / stop streaming in the middle of IO, so this problem of a proper threads tear-down still exists. It should become easier to resolve the problem in a case of a proper suspending callback because the "start" thread could be turned down at any time, so it should be easier to maintain a proper tear-down order when threads are fully controlled by the driver, i.e. the "start" thread goes down first and the "finish" is second, blocking until the capture is completed.

I don't see issue of tear-down threads in case of suspend as we do stop streaming where thread stop happens on both threads and are stopped only after processing all outstanding buffers.

Quoted 7 lines
Quoted 3 lines

Regarding freezing activity during suspend, If done thread freezes prior to processing buffers for finish, vi hardware is still active by this time which will update the frame buffer for initiated capture. Driver is not directly involved in this frame buffer update.

Finish thread only checks for completion to return buffers back to the application when done.

when done thread freeze happens after start thread initiated capture, vi hardware continues to update frame buffer for ongoing capture till it hits driver suspend callback. Yes worst case this frame data may not be valid data if invoking of this driver suspend happens immediate after this thread freeze during system suspend.

But driver will still hold buffers to return which will be returned back on resume when threads are out from frozen state.

Quoted 7 lines

Also stop stream ioctl request happens during suspend where both threads will be stopped properly. done thread stop happens only after finishing all outstanding buffers.

Stop stream request happens from streaming applications so even without driver suspend/resume implementation currently, streaming will be stopped prior to system  suspend where both threads will be stopped properly (after finishing out standing buffers) and will be resumed by application on system resume

Also tested suspending while streaming with this unconditional freeze, I don't see any issue as application stops stream where v4l_streamoff gets executed during suspend and on resume streaming starts where v4l_streamon happens.

So, I don't see any issue with existing implementation of unconditional freeze.

To be more clear,

suspend while streaming use case...

- start thread initiating capture
- done thread frozen (with outstanding buffers in process but vi hardware still continues to update frame buffer)
- start thread frozen

application holding video device will issue stream off ioctl
- stop_streaming does kthread_stop

- threads wake up and start thread breaks and finish thread breaks after checking outstanding buffers and returning to application

- vi/csi power/clocks off

on resume, application starts streaming again where fresh start stream happens.

Quoted 59 lines
Quoted 58 lines
Quoted 58 lines
Quoted 58 lines
Quoted 11 lines

I think yours suggestion about dropping the freezing from the threads for now and returning back to it later on (once a proper suspend/resume support will be added) sounds reasonable.

But if you'd want to keep the freezing, then the easy solution could be like that:

Quoted 7 lines

   1. "start" thread could freeze at any time
   2. "finish" thread could freeze only when the "start" thread is frozen and capture isn't in-progress. Use frozen(kthread_start_capture) to check the freezing state.

https://elixir.bootlin.com/linux/v5.7-rc3/source/include/linux/freezer.h#L25

That's exactly what I tried, below is the snippet.

But as mentioned I am seeing freezing fail when I wait_event_interruptible() in either of the threads.

   60.368709] Call trace:
[   60.371216] __switch_to+0xec/0x140
[   60.374768] __schedule+0x32c/0x668
[   60.378315] schedule+0x78/0x118
[   60.381606]  chan_capture_kthread_finish+0x244/0x2a0 [tegra_video] [   60.387865] kthread+0x124/0x150
[   60.391150] ret_from_fork+0x10/0x1c

wait_event_interruptible() API uses schedule() which blocks freezer while wait_event_freezable APIs uses freezable_schedule() which allows to skip freezer during schedule and then clears skip and calls try_to_freeze()

But we can't use wait_event_freezable() here as we need conditional freeze.

    while (1) {
        caps_inflight = chan->capture_reqs - chan->sequence; if (frozen(chan->kthread_start_capture) && !caps_inflight) wait_event_freezable(chan->done_wait, !list_empty(&chan->done) || kthread_should_stop());
        else
            wait_event_interruptible(chan->done_wait, !list_empty(&chan->done) || kthread_should_stop());

        /* dequeue buffers and finish capture */

        ...

        ...

        if (kthread_should_stop())
            break;
    }

author maintainer
#47 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 212 lines · Sowjanya Komatineni
Quoted 190 lines · Sowjanya Komatineni
Quoted 179 lines · Sowjanya Komatineni
Quoted 177 lines · Sowjanya Komatineni
Quoted 165 lines · Sowjanya Komatineni
Quoted 163 lines · Dmitry Osipenko

02.05.2020 06:55, Sowjanya Komatineni пишет:

Quoted 146 lines · Sowjanya Komatineni
Quoted 145 lines · Sowjanya Komatineni
Quoted 116 lines · Sowjanya Komatineni
Quoted 114 lines · Sowjanya Komatineni
Quoted 112 lines · Sowjanya Komatineni
Quoted 70 lines · Sowjanya Komatineni
Quoted 68 lines · Sowjanya Komatineni

And in this case synchronization between start/finish
threads should be
needed in regards to freezing.
Was thinking to have counter to track outstanding frame
w.r.t single shot issue b/w start and finish and allow to
freeze only when no outstanding frames in process.

This will make sure freeze will not happen when any buffers
are in progress

Note that this could be a wrong assumption, I'm not
closely familiar
with how freezer works.
kthread_start can unconditionally allow try_to_freeze before
start of frame capture

We can compute captures inflight w.r.t single shot issued
during capture start and finished frames by kthread_finish
and allow kthread_finish to freeze only when captures
inflight is 0.

This allows freeze to happen b/w frames but not in middle of
frame
will have caps inflight check in v12 to allow freeze finish
thread only when no captures are in progress

try_to_freeze() returns thread frozen state and looks like we
can use this in kthread finish to allow finish thread to freeze
only when kthread_start is already frozen and no buffers in
progress/initiated for capture.

chan->capture_frozen holds frozen state returned from
try_to_freeze() in start kthread

chan->capture_reqs increments after every single shot issued.

static int chan_capture_kthread_finish(void *data)

{
     struct tegra_vi_channel *chan = data;
     struct tegra_channel_buffer *buf;
     int caps_inflight;

     set_freezable();

     while (1) {
wait_event_interruptible(chan->done_wait,
 !list_empty(&chan->done) ||
 kthread_should_stop());

         /* dequeue buffers and finish capture */
         buf = dequeue_buf_done(chan);
         while (buf) {
tegra_channel_capture_done(chan, buf);
             buf = dequeue_buf_done(chan);
         }

         if (kthread_should_stop())
             break;

         caps_inflight = chan->capture_reqs - chan->sequence;
         if (chan->capture_frozen && !caps_inflight)
             try_to_freeze();
     }

Quoted 10 lines
Quoted 2 lines

     return 0;
}

Freezing happens prior to suspend() during suspend entry and when we implement suspend/resume during suspend we stop streaming where we stop threads anyway.

So, was thinking why we need these threads freezable here?

Hi Dmitry,

Did some testing and below are latest observation and fix I tested.

wait_event_interruptible() uses schedule() which blocks the freezer. When I do suspend while keeping streaming active in background, I see freezing of these threads fail and call trace shows __schedule -> __switch_to from these kthreads.

wait_event_freezable() uses freezable_schedule() which should not block the freezer but we can't use this here as we need conditional try_to_freeze().

So, doing below sequence works where we set PF_FREEZER_SKIP flag thru freezer_not_count() before wait_event which calls schedule() and remove PF_FREEZER_SKIP after schedule allows try_to_freeze to work and also conditional try_to_freeze below prevents freezing thread in middle of capture.

while (1) {
     freezer_not_count()
     wait_event_interruptible()
     freezer_count()
     ...
     ...
     if (chan->capture_frozen && !caps_inflight)
         try_to_freeze()
}

Quoted 14 lines
Quoted 3 lines
Quoted 3 lines

Please comment if you agree with above sequence. Will include this in v12.

sorry, freezer_count() does try_to_freeze after clearing skip flag. So, dont think we can use this as we need conditional try_to_freeze. Please ignore above sequence.

Quoted 8 lines

Or probably we can take closer look on this later when we add suspend/resume support as it need more testing as well.

As this is initial series which has TPG only I think we shouldn't get blocked on this now. Series-2 and 3 will be for sensor support and on next series when we add suspend/resume will look into this.

When freeze activity starts and in case if finish thread freezes prior to start thread issuing capture, its the VI hardware writes data to the allocated buffer address.

finish thread just checks for the event from the hardware and we don't handle/process directly on memory in this driver.

So even we freeze done thread when single shot is issued frame buffer gets updated.

In case if capture thread is frozen there will not buffers queued to process by finish thread. So, this will not be an issue.

Quoted 8 lines
Quoted 3 lines

So, probably we don't need to do conditional try_to_freeze and what we have should work good in this corner case.

I still need to change wait_event_interruptible() to wait_event_freezable() but no need to synchronize finish thread freeze with start thread as even on issuing capture start its vi hardware that does frame buffer update and finish thread just checks for mw_ack event and returns buffer to application.

The problem we are primarily trying to avoid is to have suspending being done in the middle of IO.

IIUC, even if system will be suspended in the middle of VI IO, it won't be fatal. In worst case the buffer capture should fail on resume from suspend. Could you please try to simulate this potential issue and see what result will be on suspending in the middle of VI IO?

Quoted 7 lines
Quoted 7 lines

We don't want to suspend system / stop streaming in the middle of IO, so this problem of a proper threads tear-down still exists. It should become easier to resolve the problem in a case of a proper suspending callback because the "start" thread could be turned down at any time, so it should be easier to maintain a proper tear-down order when threads are fully controlled by the driver, i.e. the "start" thread goes down first and the "finish" is second, blocking until the capture is completed.

I don't see issue of tear-down threads in case of suspend as we do stop streaming where thread stop happens on both threads and are stopped only after processing all outstanding buffers.

Quoted 7 lines
Quoted 3 lines

Regarding freezing activity during suspend, If done thread freezes prior to processing buffers for finish, vi hardware is still active by this time which will update the frame buffer for initiated capture. Driver is not directly involved in this frame buffer update.

Finish thread only checks for completion to return buffers back to the application when done.

when done thread freeze happens after start thread initiated capture, vi hardware continues to update frame buffer for ongoing capture till it hits driver suspend callback. Yes worst case this frame data may not be valid data if invoking of this driver suspend happens immediate after this thread freeze during system suspend.

But driver will still hold buffers to return which will be returned back on resume when threads are out from frozen state.

Quoted 7 lines

Also stop stream ioctl request happens during suspend where both threads will be stopped properly. done thread stop happens only after finishing all outstanding buffers.

Stop stream request happens from streaming applications so even without driver suspend/resume implementation currently, streaming will be stopped prior to system  suspend where both threads will be stopped properly (after finishing out standing buffers) and will be resumed by application on system resume

Also tested suspending while streaming with this unconditional freeze, I don't see any issue as application stops stream where v4l_streamoff gets executed during suspend and on resume streaming starts where v4l_streamon happens.

So, I don't see any issue with existing implementation of unconditional freeze.

To be more clear,

suspend while streaming use case...

- start thread initiating capture
- done thread frozen (with outstanding buffers in process but vi hardware still continues to update frame buffer)
- start thread frozen

application holding video device will issue stream off ioctl
- stop_streaming does kthread_stop

Quoted 67 lines

- threads wake up and start thread breaks and finish thread breaks after checking outstanding buffers and returning to application

- vi/csi power/clocks off

on resume, application starts streaming again where fresh start stream happens.

Quoted 59 lines
Quoted 58 lines
Quoted 58 lines
Quoted 58 lines
Quoted 11 lines

I think yours suggestion about dropping the freezing from the threads for now and returning back to it later on (once a proper suspend/resume support will be added) sounds reasonable.

But if you'd want to keep the freezing, then the easy solution could be like that:

Quoted 7 lines

   1. "start" thread could freeze at any time
   2. "finish" thread could freeze only when the "start" thread is frozen and capture isn't in-progress. Use frozen(kthread_start_capture) to check the freezing state.

https://elixir.bootlin.com/linux/v5.7-rc3/source/include/linux/freezer.h#L25

That's exactly what I tried, below is the snippet.

But as mentioned I am seeing freezing fail when I wait_event_interruptible() in either of the threads.

   60.368709] Call trace:
[   60.371216] __switch_to+0xec/0x140
[   60.374768] __schedule+0x32c/0x668
[   60.378315] schedule+0x78/0x118
[   60.381606]  chan_capture_kthread_finish+0x244/0x2a0 [tegra_video] [   60.387865] kthread+0x124/0x150
[   60.391150] ret_from_fork+0x10/0x1c

wait_event_interruptible() API uses schedule() which blocks freezer while wait_event_freezable APIs uses freezable_schedule() which allows to skip freezer during schedule and then clears skip and calls try_to_freeze()

But we can't use wait_event_freezable() here as we need conditional freeze.

    while (1) {
        caps_inflight = chan->capture_reqs - chan->sequence; if (frozen(chan->kthread_start_capture) && !caps_inflight) wait_event_freezable(chan->done_wait, !list_empty(&chan->done) || kthread_should_stop());
        else
            wait_event_interruptible(chan->done_wait, !list_empty(&chan->done) || kthread_should_stop());

        /* dequeue buffers and finish capture */

        ...

        ...

        if (kthread_should_stop())
            break;
    }

Below works if I skip freezer during wait_event_interruptible as we can't use wait_event_freezable when we need conditional try_to_freeze()

But I am not sure if this is allowed to do this explicit PF_FREEZER_SKIP clear.

Also, as explained above I don't even think we need conditional try_to_freeze() as v4l2 ioctl stream off gets called during closing of device node when suspend happens and before stopping threads outstanding buffers are returned properly. So, I don't see any issue with unconditional try_to_freeze()

    while (1) {

        /* allow to freeze only when no captures in progress */ caps_inflight = chan->capture_reqs - chan->sequence; if (frozen(chan->kthread_start_capture) && !caps_inflight) { wait_event_freezable(chan->done_wait, !list_empty(&chan->done) || kthread_should_stop());
        } else {
            /*
             * Skip freeze during wait_event_interruptible as
             * schedule() blocks freezer.
             */
            if (freezing(current)) freezer_do_not_count();

            wait_event_interruptible(chan->done_wait, !list_empty(&chan->done) || kthread_should_stop()); if (freezing(current)) current->flags &= ~PF_FREEZER_SKIP; }

        /* dequeue buffers and finish capture */

        ...

        ...

        if (kthread_should_stop())
            break;
    }

#48 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

In reply to Sowjanya Komatineni

02.05.2020 19:55, Sowjanya Komatineni пишет:

Quoted 3 lines

Also stop stream ioctl request happens during suspend where both threads will be stopped properly. done thread stop happens only after finishing all outstanding buffers.

Do you mean that V4L core takes care of stopping the streami on suspend and re-starting it on resume from suspend?

Quoted 5 lines

Stop stream request happens from streaming applications so even without driver suspend/resume implementation currently, streaming will be stopped prior to system  suspend where both threads will be stopped properly (after finishing out standing buffers) and will be resumed by application on system resume

All userspace is frozen on suspend. System suspension is transparent for userspace applications. I'm not sure what you're meaning here.

Quoted 7 lines

Also tested suspending while streaming with this unconditional freeze, I don't see any issue as application stops stream where v4l_streamoff gets executed during suspend and on resume streaming starts where v4l_streamon happens.

So, I don't see any issue with existing implementation of unconditional freeze.

I don't understand why freezing is needed at all if V4L core takes care of stopping the stream on suspend, what is the point? If there is no real point, then let's make threads non-freezable and done with that.

author maintainer
#49 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 20 lines · Dmitry Osipenko

02.05.2020 19:55, Sowjanya Komatineni пишет:

Quoted 3 lines

Also stop stream ioctl request happens during suspend where both threads will be stopped properly. done thread stop happens only after finishing all outstanding buffers.

Do you mean that V4L core takes care of stopping the streami on suspend and re-starting it on resume from suspend?

Quoted 5 lines

Stop stream request happens from streaming applications so even without driver suspend/resume implementation currently, streaming will be stopped prior to system  suspend where both threads will be stopped properly (after finishing out standing buffers) and will be resumed by application on system resume

All userspace is frozen on suspend. System suspension is transparent for userspace applications. I'm not sure what you're meaning here.

Quoted 5 lines

Also tested suspending while streaming with this unconditional freeze, I don't see any issue as application stops stream where v4l_streamoff gets executed during suspend and on resume streaming starts where v4l_streamon happens.

Quoted 5 lines
Quoted 2 lines

So, I don't see any issue with existing implementation of unconditional freeze.

I don't understand why freezing is needed at all if V4L core takes care of stopping the stream on suspend, what is the point? If there is no real point, then let's make threads non-freezable and done with that.

video device fops unlocked_ioctl is set to video_ioctl2() in vi driver.

video device fops unlocked_ioctl gets executed with stream off cmd during suspend and stream on cmd during resume which eventually calls v4l_streamoff and v4l_streamon during system suspend/resume.

My understanding to have freezable threads is during system suspend user space applications are frozen prior to kernel freeze and during suspend when opened video character device node gets closed these ioctl gets invoked and stream off during suspend and stream on during resume happens. So probably we still need to use freezable threads to sync with user space application when frozen before really entering suspend.

Will wait for Thierry/Hans comment to correct if my above understanding is wrong and help clarify if we need freezable threads at all in this case...

Note: I see other drivers using freezable threads for capture drivers.

Assuming we use freezable threads, I was saying we don't need conditional try_to_freeze() like you pointed because even if finish thread freeze happens prior to frame capture initiated by start thread, vi hardware will still continue to update this single ongoing buffer and will finish max within 200ms and actually there is no direct processing of this done by finish thread itself except that it returns buffers back when done and in this case it returns back when unfreeze/wake up happens.

So, I don't see any issue of unconditional try_to_freeze() even with freezable threads.

Thanks

Sowjanya

author maintainer
#50 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 30 lines · Sowjanya Komatineni
Quoted 20 lines · Dmitry Osipenko

02.05.2020 19:55, Sowjanya Komatineni пишет:

Quoted 3 lines

Also stop stream ioctl request happens during suspend where both threads will be stopped properly. done thread stop happens only after finishing all outstanding buffers.

Do you mean that V4L core takes care of stopping the streami on suspend and re-starting it on resume from suspend?

Quoted 5 lines

Stop stream request happens from streaming applications so even without driver suspend/resume implementation currently, streaming will be stopped prior to system  suspend where both threads will be stopped properly (after finishing out standing buffers) and will be resumed by application on system resume

All userspace is frozen on suspend. System suspension is transparent for userspace applications. I'm not sure what you're meaning here.

Quoted 5 lines

Also tested suspending while streaming with this unconditional freeze, I don't see any issue as application stops stream where v4l_streamoff gets executed during suspend and on resume streaming starts where v4l_streamon happens.

Quoted 5 lines
Quoted 2 lines

So, I don't see any issue with existing implementation of unconditional freeze.

I don't understand why freezing is needed at all if V4L core takes care of stopping the stream on suspend, what is the point? If there is no real point, then let's make threads non-freezable and done with that.

video device fops unlocked_ioctl is set to video_ioctl2() in vi driver.

Quoted 7 lines

video device fops unlocked_ioctl gets executed with stream off cmd during suspend and stream on cmd during resume which eventually calls v4l_streamoff and v4l_streamon during system suspend/resume.

My understanding to have freezable threads is during system suspend user space applications are frozen prior to kernel freeze and during suspend when opened video character device node gets closed these ioctl gets invoked and stream off during suspend and stream on during resume happens. So probably we still need to use freezable threads to sync with user space application when frozen before really entering suspend.

Will wait for Thierry/Hans comment to correct if my above understanding is wrong and help clarify if we need freezable threads at all in this case...

Note: I see other drivers using freezable threads for capture drivers.

I see only couple of media drivers using freezable threads.

Also, referring to below article probably we don't need freezable threads.

https://lwn.net/Articles/662703/

Probably we can then remove thread as freezable...

Quoted 11 lines

Assuming we use freezable threads, I was saying we don't need conditional try_to_freeze() like you pointed because even if finish thread freeze happens prior to frame capture initiated by start thread, vi hardware will still continue to update this single ongoing buffer and will finish max within 200ms and actually there is no direct processing of this done by finish thread itself except that it returns buffers back when done and in this case it returns back when unfreeze/wake up happens.

So, I don't see any issue of unconditional try_to_freeze() even with freezable threads.

Thanks

Sowjanya

#51 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

In reply to Sowjanya Komatineni
Quoted 28 lines · Sowjanya Komatineni
Quoted 20 lines · Dmitry Osipenko

02.05.2020 19:55, Sowjanya Komatineni пишет:

Quoted 3 lines

Also stop stream ioctl request happens during suspend where both threads will be stopped properly. done thread stop happens only after finishing all outstanding buffers.

Do you mean that V4L core takes care of stopping the streami on suspend and re-starting it on resume from suspend?

Quoted 5 lines

Stop stream request happens from streaming applications so even without driver suspend/resume implementation currently, streaming will be stopped prior to system  suspend where both threads will be stopped properly (after finishing out standing buffers) and will be resumed by application on system resume

All userspace is frozen on suspend. System suspension is transparent for userspace applications. I'm not sure what you're meaning here.

Quoted 5 lines

Also tested suspending while streaming with this unconditional freeze, I don't see any issue as application stops stream where v4l_streamoff gets executed during suspend and on resume streaming starts where v4l_streamon happens.

Quoted 5 lines
Quoted 2 lines

So, I don't see any issue with existing implementation of unconditional freeze.

I don't understand why freezing is needed at all if V4L core takes care of stopping the stream on suspend, what is the point? If there is no real point, then let's make threads non-freezable and done with that.

Quoted 5 lines

video device fops unlocked_ioctl is set to video_ioctl2() in vi driver.

video device fops unlocked_ioctl gets executed with stream off cmd during suspend and stream on cmd during resume which eventually calls v4l_streamoff and v4l_streamon during system suspend/resume.

That's news to me. The 'only' thing that suspend/resume needs to do is to stop the HW DMA on suspend and to restart the HW DMA (and typically reconfigure the whole HW video pipeline) on resume. Userspace doesn't do anything special.

That's how e.g. a UVC webcam behaves when you close the lid of a laptop while it is streaming and open it again later.

It can be hard to get this right, and I suspect many media drivers will fail this test.

Quoted 8 lines

My understanding to have freezable threads is during system suspend user space applications are frozen prior to kernel freeze and during suspend when opened video character device node gets closed these ioctl gets invoked and stream off during suspend and stream on during resume happens. So probably we still need to use freezable threads to sync with user space application when frozen before really entering suspend.

Quoted 5 lines

Will wait for Thierry/Hans comment to correct if my above understanding is wrong and help clarify if we need freezable threads at all in this case...

Note: I see other drivers using freezable threads for capture drivers.

Well, it's often a copy-and-paste without truly understanding what is going on. You should not assume that the author knew what was happening.

To be honest, I'm not an expert on this either.

Looking at the tegra start/finish threads: they basically look at the chan->capture and chan->done lists. Freezing the threads should not be a problem as long as the actual suspend/resume doesn't mess with those lists. If it does, then it may get tricky to prove that it is safe to do suspend/resume (I think).

An alternative is to stop and restart those threads when suspending or resuming. Then those threads do not need to be 'freezable' and it might be easier to validate the code.

In any case, I do not want to postpone the merger of the upcoming v12 for this. Changes can be done in later patches, if needed.

Regards,

Hans

Quoted 18 lines

Assuming we use freezable threads, I was saying we don't need conditional try_to_freeze() like you pointed because even if finish thread freeze happens prior to frame capture initiated by start thread, vi hardware will still continue to update this single ongoing buffer and will finish max within 200ms and actually there is no direct processing of this done by finish thread itself except that it returns buffers back when done and in this case it returns back when unfreeze/wake up happens.

So, I don't see any issue of unconditional try_to_freeze() even with freezable threads.

Thanks

Sowjanya

author maintainer
#52 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 36 lines · Hans Verkuil
Quoted 23 lines · Sowjanya Komatineni
Quoted 22 lines · Dmitry Osipenko

02.05.2020 19:55, Sowjanya Komatineni пишет:

Quoted 3 lines

Also stop stream ioctl request happens during suspend where both threads will be stopped properly. done thread stop happens only after finishing all outstanding buffers.

Do you mean that V4L core takes care of stopping the streami on suspend and re-starting it on resume from suspend?

Quoted 5 lines

Stop stream request happens from streaming applications so even without driver suspend/resume implementation currently, streaming will be stopped prior to system  suspend where both threads will be stopped properly (after finishing out standing buffers) and will be resumed by application on system resume

All userspace is frozen on suspend. System suspension is transparent for userspace applications. I'm not sure what you're meaning here.

Quoted 7 lines

Also tested suspending while streaming with this unconditional freeze, I don't see any issue as application stops stream where v4l_streamoff gets executed during suspend and on resume streaming starts where v4l_streamon happens.

So, I don't see any issue with existing implementation of unconditional freeze.

Quoted 8 lines
Quoted 3 lines

I don't understand why freezing is needed at all if V4L core takes care of stopping the stream on suspend, what is the point? If there is no real point, then let's make threads non-freezable and done with that.

video device fops unlocked_ioctl is set to video_ioctl2() in vi driver.

video device fops unlocked_ioctl gets executed with stream off cmd during suspend and stream on cmd during resume which eventually calls v4l_streamoff and v4l_streamon during system suspend/resume.

That's news to me. The 'only' thing that suspend/resume needs to do is to stop the HW DMA on suspend and to restart the HW DMA (and typically reconfigure the whole HW video pipeline) on resume. Userspace doesn't do anything special.

Quoted 5 lines

That's how e.g. a UVC webcam behaves when you close the lid of a laptop while it is streaming and open it again later.

It can be hard to get this right, and I suspect many media drivers will fail this test.

when video device node path is kept opened during suspend, on suspend entry looks like inode path is tried to closes and on resume opened again causing v4l2 stream off/on thru v4l2 ioctl.

Based on our testing even with downstream and user applications, we always see video device node path close/open during suspend/resume which does v4l2 stream off/on.

Quoted 27 lines
Quoted 7 lines

My understanding to have freezable threads is during system suspend user space applications are frozen prior to kernel freeze and during suspend when opened video character device node gets closed these ioctl gets invoked and stream off during suspend and stream on during resume happens. So probably we still need to use freezable threads to sync with user space application when frozen before really entering suspend.

Quoted 5 lines

Will wait for Thierry/Hans comment to correct if my above understanding is wrong and help clarify if we need freezable threads at all in this case...

Note: I see other drivers using freezable threads for capture drivers.

Well, it's often a copy-and-paste without truly understanding what is going on. You should not assume that the author knew what was happening.

To be honest, I'm not an expert on this either.

Looking at the tegra start/finish threads: they basically look at the chan->capture and chan->done lists. Freezing the threads should not be a problem as long as the actual suspend/resume doesn't mess with those lists. If it does, then it may get tricky to prove that it is safe to do suspend/resume (I think).

An alternative is to stop and restart those threads when suspending or resuming. Then those threads do not need to be 'freezable' and it might be easier to validate the code.

Quoted 6 lines

In any case, I do not want to postpone the merger of the upcoming v12 for this. Changes can be done in later patches, if needed.

Regards,

Hans

Thanks Hans.

Buffers list don't get altered after frozen and during suspend/resume till they are out of freeze.

Will remove freezable threads and move on for v12.

Will validate suspend/resume later after all sensor support.

Quoted 17 lines
Quoted 17 lines

Assuming we use freezable threads, I was saying we don't need conditional try_to_freeze() like you pointed because even if finish thread freeze happens prior to frame capture initiated by start thread, vi hardware will still continue to update this single ongoing buffer and will finish max within 200ms and actually there is no direct processing of this done by finish thread itself except that it returns buffers back when done and in this case it returns back when unfreeze/wake up happens.

So, I don't see any issue of unconditional try_to_freeze() even with freezable threads.

Thanks

Sowjanya

author maintainer
#53 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

In reply to Sowjanya Komatineni
Quoted 84 lines · Sowjanya Komatineni
Quoted 82 lines · Sowjanya Komatineni
Quoted 48 lines · Dmitry Osipenko

30.04.2020 22:09, Sowjanya Komatineni пишет:

Quoted 47 lines · Sowjanya Komatineni
Quoted 46 lines · Sowjanya Komatineni
Quoted 36 lines · Sowjanya Komatineni
Quoted 35 lines · Sowjanya Komatineni
Quoted 34 lines · Dmitry Osipenko
Quoted 21 lines

30.04.2020 17:02, Dmitry Osipenko пишет:

Quoted 15 lines

30.04.2020 16:56, Dmitry Osipenko пишет:

Quoted 14 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

Review

Quoted 9 lines
(quoted diff) +9 -0
+static int chan_capture_kthread_finish(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();

I guess it won't be great to freeze in the middle of a capture process, so:
         if (list_empty(&chan->done)) try_to_freeze();

Quoted 5 lines

And here should be some locking protection in order not race with the
chan_capture_kthread_start because kthread_finish could freeze before
kthread_start.

Quoted 7 lines

Or maybe both start / finish threads should simply be allowed to freeze
only when both capture and done lists are empty.

if (list_empty(&chan->capture) &&
      list_empty(&chan->done))
     try_to_freeze();

good to freeze when not in middle of the frame capture but why should we not allow freeze in between captures?

Other drivers do allow freeze in between frame captures.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

I guess we can freeze before dequeue for capture and in finish thread we can freeze after capture done. This also don't need to check for list_empty with freeze to allow between frame captures.

Also if we add check for both lists empty, freeze is not allowed as long as streaming is going on and in case of continuous streaming freeze will never happen.

To allow freeze b/w frames (but not in middle of a frame),

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

for capture_start thread, probably we can do unconditional try_to_freeze()

Is it possible to use wait_event_freezable()?

https://www.kernel.org/doc/Documentation/power/freezing-of-tasks.txt

Will the wait_event_interruptible() be woken up when system freezes?

Based on wait_event_freezable implementation, looks like it similar to wait_event_interruptible + try_to_free() as it does freezable_schedule unlike schedule with wait_event_interruptible.

So using this for capture_start may be ok to allow freeze before start of frame. But can't use for capture_finish as this is same as wait_event_interruptible followed by unconditional try_to_freeze.

Quoted 19 lines
Quoted 3 lines
Quoted 3 lines

for capture_finish thread, at end of capture done we can do try_to_freeze() only when done list is empty

This doesn't prevent situation where the done-list is empty and the "finish" thread freezes, in the same time the "start" thread issues new capture and then freezes too.

1. "start" thread issues capture

2. "finish" thread wakes and waits for the capture to complete

3. "start" thread begins another capture, waits for FRAME_START

4. system freezing activates

5. "finish" thread completes the capture and freezes because done-list is empty

6. "start" thread gets FRAME_START, issues another capture and freezes

Quoted 8 lines
Quoted 3 lines

This will not happen as we allow double buffering done list will not be empty till stream stop happens

There will always be 1 outstanding frame in done list

Correction, there will always be 1 outstanding buffer except beginning during beginning of stream.

Except during beginning frames, done list will not be empty for all subsequent streaming process

or probably we should add pending buffers b/w 2 threads w.r.t single shot issues and allow freeze only when no pending frame to cover any corner case b/w done list and capture list.

Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 5 lines

My understanding is buffer updates/release should not happen after frozen state. So we should let frame capture of outstanding buffer to finish before freezing in capture_finish thread.

Quoted 8 lines

But for capture_start thread we can unconditionally freeze before dequeuing next buffer for capture.

With this when both threads are in frozen state and no buffer updates/captures will happen after frozen state.

I think its not required to finish streaming of all frames completely to let threads to enter frozen state as streaming can be continuous as well.

Yes, only freezing in the middle of IO should be avoided.

https://lwn.net/Articles/705269/

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

Hi Dmitry,

Will update in v12 to not allow freeze in middle of a frame capture.

Can you please confirm on above if you agree to allow freeze to happen in b/w frame captures?

Also as most feedback has been received from you by now, appreciate if you can provide all in this v11 if you have anything else so we will not have any new changes after v12.

I'll take another look tomorrow / during weekend and let you know.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#55 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

04.05.2020 17:53, Sowjanya Komatineni пишет:

Quoted 9 lines · Dmitry Osipenko
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Hi Dmitry,

Will update in v12 to not allow freeze in middle of a frame capture.

Can you please confirm on above if you agree to allow freeze to happen in b/w frame captures?

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Also as most feedback has been received from you by now, appreciate if you can provide all in this v11 if you have anything else so we will not have any new changes after v12.

I'll take another look tomorrow / during weekend and let you know.

Hi Dmitry,

Will send v12 if there is no more feedback. Please let me know.

Hello Sowjanya,

I don't have any more comments to add, looking forward to v12.

author maintainer
#56 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 12 lines · Dmitry Osipenko

04.05.2020 17:53, Sowjanya Komatineni пишет:

Quoted 11 lines · Dmitry Osipenko
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

Hi Dmitry,

Will update in v12 to not allow freeze in middle of a frame capture.

Can you please confirm on above if you agree to allow freeze to happen in b/w frame captures?

Also as most feedback has been received from you by now, appreciate if you can provide all in this v11 if you have anything else so we will not have any new changes after v12.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I'll take another look tomorrow / during weekend and let you know.

Hi Dmitry,

Will send v12 if there is no more feedback. Please let me know.

Hello Sowjanya,

I don't have any more comments to add, looking forward to v12.

Thanks Dmitry

#57 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

In reply to Sowjanya Komatineni

30.04.2020 01:00, Sowjanya Komatineni пишет:

drivers/staging/media/tegra-video/vi.c line 820

Quoted 9 lines
drivers/staging/media/tegra-video/vi.c new file +8 -0
+int tegra_v4l2_nodes_setup_tpg(struct tegra_video_device *vid)
+{
+	struct tegra_vi *vi = vid->vi;
+	struct tegra_csi *csi = vid->csi;
+	struct tegra_vi_channel *vi_chan;
+	struct tegra_csi_channel *csi_chan;
+	u32 link_flags = MEDIA_LNK_FL_ENABLED;
 
+	int ret = 0;

No need to unnecessarily initialize variables. Same for all other similar occurrences in the code.

#58 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

In reply to Sowjanya Komatineni

30.04.2020 01:00, Sowjanya Komatineni пишет:

drivers/staging/media/tegra-video/vi.c line 760

Quoted 4 lines
drivers/staging/media/tegra-video/vi.c new file +4 -0
+		chan = kzalloc(sizeof(*chan), GFP_KERNEL);
+		if (!chan) {
+			ret = -ENOMEM;
+			return ret;

return -ENOMEM;

Quoted 1 line
(quoted diff) +1 -0
+		}
#59 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

In reply to Sowjanya Komatineni

30.04.2020 01:00, Sowjanya Komatineni пишет:

Quoted 20 lines
drivers/staging/media/tegra-video/tegra210.c new file +20 -0
+static int chan_capture_kthread_start(void *data)
+{
+	struct tegra_vi_channel *chan = data;
+	struct tegra_channel_buffer *buf;
+	int err = 0;
+
+	set_freezable();
+
+	while (1) {
+		try_to_freeze();
+
+		/*
+		 * Source is not streaming if error is non-zero.
+		 * So, do not dequeue buffers on error and let the thread sleep
+		 * till kthread stop signal is received.
+		 */
+		wait_event_interruptible(chan->start_wait,
+					 kthread_should_stop() ||
+					 (!list_empty(&chan->capture) &&
+					 !err));

...

Quoted 4 lines
drivers/staging/media/tegra-video/vi.c new file +4 -0
+static void tegra_channel_buffer_queue(struct vb2_buffer *vb)
+{
+	struct tegra_vi_channel *chan = vb2_get_drv_priv(vb->vb2_queue);
+	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);

drivers/staging/media/tegra-video/vi.c line 144

Quoted 10 lines
drivers/staging/media/tegra-video/vi.c new file +10 -0
+	struct tegra_channel_buffer *buf = to_tegra_channel_buffer(vbuf);
+
+	/* put buffer into the capture queue */
+	spin_lock(&chan->start_lock);
+	list_add_tail(&buf->queue, &chan->capture);
+	spin_unlock(&chan->start_lock);
+
+	/* wait up kthread for capture */
+	wake_up_interruptible(&chan->start_wait);
+}

The V4L doc says that buffers could be enqueued before streaming is started. I guess it should be a trouble here, shouldn't it?

https://elixir.bootlin.com/linux/v5.7-rc3/source/include/media/videobuf2-core.h#L379

author maintainer
#60 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 39 lines · Dmitry Osipenko

30.04.2020 01:00, Sowjanya Komatineni пишет:

Quoted 20 lines
drivers/staging/media/tegra-video/tegra210.c new file +20 -0
+static int chan_capture_kthread_start(void *data)
+{
+	struct tegra_vi_channel *chan = data;
+	struct tegra_channel_buffer *buf;
+	int err = 0;
+
+	set_freezable();
+
+	while (1) {
+		try_to_freeze();
+
+		/*
+		 * Source is not streaming if error is non-zero.
+		 * So, do not dequeue buffers on error and let the thread sleep
+		 * till kthread stop signal is received.
+		 */
+		wait_event_interruptible(chan->start_wait,
+					 kthread_should_stop() ||
+					 (!list_empty(&chan->capture) &&
+					 !err));

...

Quoted 4 lines
drivers/staging/media/tegra-video/vi.c new file +4 -0
+static void tegra_channel_buffer_queue(struct vb2_buffer *vb)
+{
+	struct tegra_vi_channel *chan = vb2_get_drv_priv(vb->vb2_queue);
+	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);

drivers/staging/media/tegra-video/vi.c line 144

Quoted 10 lines
drivers/staging/media/tegra-video/vi.c new file +10 -0
+	struct tegra_channel_buffer *buf = to_tegra_channel_buffer(vbuf);
+
+	/* put buffer into the capture queue */
+	spin_lock(&chan->start_lock);
+	list_add_tail(&buf->queue, &chan->capture);
+	spin_unlock(&chan->start_lock);
+
+	/* wait up kthread for capture */
+	wake_up_interruptible(&chan->start_wait);
+}

The V4L doc says that buffers could be enqueued before streaming is started. I guess it should be a trouble here, shouldn't it?

Quoted 1 line

https://elixir.bootlin.com/linux/v5.7-rc3/source/include/media/videobuf2-core.h#L379

what trouble are you referring here?

I dont think so as we set min buffers needed as 2 always there will be 2 per-queued buffers.

But buffers from this queue will be dequeued only when ready to processes in the capture thread

author maintainer
#61 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 42 lines · Sowjanya Komatineni
Quoted 40 lines · Dmitry Osipenko

30.04.2020 01:00, Sowjanya Komatineni пишет:

Quoted 21 lines
drivers/staging/media/tegra-video/tegra210.c new file +14 -0
+static int chan_capture_kthread_start(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+    int err = 0;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();
+
+        /*
+         * Source is not streaming if error is non-zero.
+         * So, do not dequeue buffers on error and let the thread 

sleep
+         * till kthread stop signal is received. +         */
+        wait_event_interruptible(chan->start_wait, +                     kthread_should_stop() || +                     (!list_empty(&chan->capture) && +                     !err));

...

Quoted 4 lines
drivers/staging/media/tegra-video/vi.c new file +4 -0
+static void tegra_channel_buffer_queue(struct vb2_buffer *vb)
+{
+    struct tegra_vi_channel *chan = vb2_get_drv_priv(vb->vb2_queue);
+    struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);

drivers/staging/media/tegra-video/vi.c line 144

Quoted 10 lines
drivers/staging/media/tegra-video/vi.c new file +10 -0
+    struct tegra_channel_buffer *buf = to_tegra_channel_buffer(vbuf);
+
+    /* put buffer into the capture queue */
+    spin_lock(&chan->start_lock);
+    list_add_tail(&buf->queue, &chan->capture);
+    spin_unlock(&chan->start_lock);
+
+    /* wait up kthread for capture */
+    wake_up_interruptible(&chan->start_wait);
+}

The V4L doc says that buffers could be enqueued before streaming is started. I guess it should be a trouble here, shouldn't it?

Quoted 6 lines
Quoted 2 lines

https://elixir.bootlin.com/linux/v5.7-rc3/source/include/media/videobuf2-core.h#L379

what trouble are you referring here?

I dont think so as we set min buffers needed as 2 always there will be 2 per-queued buffers.

typo* pre-queued buffers before streaming start

Quoted 3 lines

But buffers from this queue will be dequeued only when ready to processes in the capture thread

#62 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

30.04.2020 23:09, Sowjanya Komatineni пишет:

Quoted 44 lines · Sowjanya Komatineni
Quoted 42 lines · Dmitry Osipenko
Quoted 40 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

Quoted 21 lines
drivers/staging/media/tegra-video/tegra210.c new file +14 -0
+static int chan_capture_kthread_start(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+    int err = 0;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();
+
+        /*
+         * Source is not streaming if error is non-zero.
+         * So, do not dequeue buffers on error and let the thread

sleep
+         * till kthread stop signal is received. +         */
+        wait_event_interruptible(chan->start_wait, +                     kthread_should_stop() || +                     (!list_empty(&chan->capture) && +                     !err));

...

Quoted 4 lines
drivers/staging/media/tegra-video/vi.c new file +4 -0
+static void tegra_channel_buffer_queue(struct vb2_buffer *vb)
+{
+    struct tegra_vi_channel *chan = vb2_get_drv_priv(vb->vb2_queue);
+    struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);

drivers/staging/media/tegra-video/vi.c line 144

Quoted 10 lines
drivers/staging/media/tegra-video/vi.c new file +10 -0
+    struct tegra_channel_buffer *buf = to_tegra_channel_buffer(vbuf);
+
+    /* put buffer into the capture queue */
+    spin_lock(&chan->start_lock);
+    list_add_tail(&buf->queue, &chan->capture);
+    spin_unlock(&chan->start_lock);
+
+    /* wait up kthread for capture */
+    wake_up_interruptible(&chan->start_wait);
+}

The V4L doc says that buffers could be enqueued before streaming is started. I guess it should be a trouble here, shouldn't it?

Quoted 11 lines
Quoted 7 lines
Quoted 2 lines

https://elixir.bootlin.com/linux/v5.7-rc3/source/include/media/videobuf2-core.h#L379

what trouble are you referring here?

I dont think so as we set min buffers needed as 2 always there will be 2 per-queued buffers.

typo* pre-queued buffers before streaming start

Quoted 3 lines

But buffers from this queue will be dequeued only when ready to processes in the capture thread

I see now that the threads won't be running until start_streaming() is invoked, should be okay then.

author maintainer
#63 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 47 lines · Dmitry Osipenko

30.04.2020 23:09, Sowjanya Komatineni пишет:

Quoted 46 lines · Sowjanya Komatineni
Quoted 45 lines · Dmitry Osipenko
Quoted 40 lines

30.04.2020 01:00, Sowjanya Komatineni пишет:

Quoted 21 lines
drivers/staging/media/tegra-video/tegra210.c new file +14 -0
+static int chan_capture_kthread_start(void *data)
+{
+    struct tegra_vi_channel *chan = data;
+    struct tegra_channel_buffer *buf;
+    int err = 0;
+
+    set_freezable();
+
+    while (1) {
+        try_to_freeze();
+
+        /*
+         * Source is not streaming if error is non-zero.
+         * So, do not dequeue buffers on error and let the thread

sleep
+         * till kthread stop signal is received. +         */
+        wait_event_interruptible(chan->start_wait, +                     kthread_should_stop() || +                     (!list_empty(&chan->capture) && +                     !err));

...

Quoted 4 lines
drivers/staging/media/tegra-video/vi.c new file +4 -0
+static void tegra_channel_buffer_queue(struct vb2_buffer *vb)
+{
+    struct tegra_vi_channel *chan = vb2_get_drv_priv(vb->vb2_queue);
+    struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);

drivers/staging/media/tegra-video/vi.c line 144

Quoted 10 lines
drivers/staging/media/tegra-video/vi.c new file +10 -0
+    struct tegra_channel_buffer *buf = to_tegra_channel_buffer(vbuf);
+
+    /* put buffer into the capture queue */
+    spin_lock(&chan->start_lock);
+    list_add_tail(&buf->queue, &chan->capture);
+    spin_unlock(&chan->start_lock);
+
+    /* wait up kthread for capture */
+    wake_up_interruptible(&chan->start_wait);
+}

The V4L doc says that buffers could be enqueued before streaming is started. I guess it should be a trouble here, shouldn't it?

Quoted 2 lines

https://elixir.bootlin.com/linux/v5.7-rc3/source/include/media/videobuf2-core.h#L379

what trouble are you referring here?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I dont think so as we set min buffers needed as 2 always there will be 2 per-queued buffers.

typo* pre-queued buffers before streaming start

Quoted 2 lines

But buffers from this queue will be dequeued only when ready to processes in the capture thread

I see now that the threads won't be running until start_streaming() is invoked, should be okay then.

ok. yes threads run only during streaming

#64 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

In reply to Sowjanya Komatineni

30.04.2020 01:00, Sowjanya Komatineni пишет:

Quoted 16 lines
drivers/staging/media/tegra-video/vi.h new file +16 -0
+/*
+ * VI channel input data type enum.
+ * These data type enum value gets programmed into corresponding Tegra VI
+ * channel register bits.
+ */
+enum tegra_image_dt {
+	TEGRA_IMAGE_DT_YUV420_8 = 24,
+	TEGRA_IMAGE_DT_YUV420_10,
+
+	TEGRA_IMAGE_DT_YUV420CSPS_8 = 28,
+	TEGRA_IMAGE_DT_YUV420CSPS_10,
+	TEGRA_IMAGE_DT_YUV422_8,
+	TEGRA_IMAGE_DT_YUV422_10,
+	TEGRA_IMAGE_DT_RGB444,
+	TEGRA_IMAGE_DT_RGB555,
+	TEGRA_IMAGE_DT_RGB565,

drivers/staging/media/tegra-video/vi.h line 225

Quoted 10 lines
drivers/staging/media/tegra-video/vi.h new file +10 -0
+	TEGRA_IMAGE_DT_RGB666,
+	TEGRA_IMAGE_DT_RGB888,
+
+	TEGRA_IMAGE_DT_RAW6 = 40,
+	TEGRA_IMAGE_DT_RAW7,
+	TEGRA_IMAGE_DT_RAW8,
+	TEGRA_IMAGE_DT_RAW10,
+	TEGRA_IMAGE_DT_RAW12,
+	TEGRA_IMAGE_DT_RAW14,
+};

Are these format IDs common to all Tegra SoCs or they unique to T210?

author maintainer
#65 lore raw

Re: [RFC PATCH v11 6/9] media: tegra: Add Tegra210 Video input driver

Quoted 20 lines · Dmitry Osipenko

30.04.2020 01:00, Sowjanya Komatineni пишет:

Quoted 19 lines
drivers/staging/media/tegra-video/vi.h new file +19 -0
+/*
+ * VI channel input data type enum.
+ * These data type enum value gets programmed into corresponding Tegra VI
+ * channel register bits.
+ */
+enum tegra_image_dt {
+	TEGRA_IMAGE_DT_YUV420_8 = 24,
+	TEGRA_IMAGE_DT_YUV420_10,
+
+	TEGRA_IMAGE_DT_YUV420CSPS_8 = 28,
+	TEGRA_IMAGE_DT_YUV420CSPS_10,
+	TEGRA_IMAGE_DT_YUV422_8,
+	TEGRA_IMAGE_DT_YUV422_10,
+	TEGRA_IMAGE_DT_RGB444,
+	TEGRA_IMAGE_DT_RGB555,
+	TEGRA_IMAGE_DT_RGB565,
+	TEGRA_IMAGE_DT_RGB666,
+	TEGRA_IMAGE_DT_RGB888,
+
Quoted 8 lines

drivers/staging/media/tegra-video/vi.h line 225

Quoted 7 lines
drivers/staging/media/tegra-video/vi.h new file +7 -0
+	TEGRA_IMAGE_DT_RAW6 = 40,
+	TEGRA_IMAGE_DT_RAW7,
+	TEGRA_IMAGE_DT_RAW8,
+	TEGRA_IMAGE_DT_RAW10,
+	TEGRA_IMAGE_DT_RAW12,
+	TEGRA_IMAGE_DT_RAW14,
+};

Are these format IDs common to all Tegra SoCs or they unique to T210?

Common for all SoCs

author maintainer
#66 lore raw

RFC PATCH v11 7/9 MAINTAINERS: Add Tegra Video driver section

In reply to Sowjanya Komatineni

Add maintainers and mailing list entries to Tegra Video driver section.

---
 MAINTAINERS | 10 ++++++++++
 1 file changed, 10 insertions(+)
MAINTAINERS +10 -0
index 973b7db..795b201 100644
@@ -16644,6 +16644,16 @@ M:	Laxman Dewangan <[email protected]>
 S:	Supported
 F:	drivers/spi/spi-tegra*
 
+TEGRA VIDEO DRIVER
+M:	Thierry Reding <[email protected]>
+M:	Jonathan Hunter <[email protected]>
+M:	Sowjanya Komatineni <[email protected]>
+L:	[email protected]
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
+F:	drivers/staging/media/tegra/
+
 TEGRA XUSB PADCTL DRIVER
 M:	JC Kuo <[email protected]>
 S:	Supported
Signature · 1 line
2.7.4
author maintainer
#67 lore raw

RFC PATCH v11 8/9 dt-bindings: reset: Add ID for Tegra210 VI reset

In reply to Sowjanya Komatineni

This patch adds ID for Tegra210 VI controller reset to use with device tree.

---
 include/dt-bindings/reset/tegra210-car.h | 1 +
 1 file changed, 1 insertion(+)
include/dt-bindings/reset/tegra210-car.h +1 -0
index 9dc84ec..8755946 100644
@@ -10,5 +10,6 @@
 #define TEGRA210_RESET(x)		(7 * 32 + (x))
 #define TEGRA210_RST_DFLL_DVCO		TEGRA210_RESET(0)
 #define TEGRA210_RST_ADSP		TEGRA210_RESET(1)
+#define TEGRA210_RST_VI			20
 
 #endif	/* _DT_BINDINGS_RESET_TEGRA210_CAR_H */
Signature · 1 line
2.7.4
author maintainer
#68 lore raw

RFC PATCH v11 9/9 arm64: tegra: Add Tegra VI CSI support in device tree

In reply to Sowjanya Komatineni

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.

---
 arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi | 10 ++++++
 arch/arm64/boot/dts/nvidia/tegra210.dtsi       | 46 +++++++++++++++++++++++++-
 2 files changed, 55 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi +10 -0
index 313a4c2..b57d837 100644
@@ -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";
 
arch/arm64/boot/dts/nvidia/tegra210.dtsi +45 -1

60 lines not on this page · raw message

Signature · 1 line
2.7.4
#69 lore raw
In reply to Sowjanya Komatineni
Quoted 10 lines · Sowjanya Komatineni

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.

I'm getting compile errors:

drivers/staging/media/tegra-video/vi.c:1064:1: warning: data definition has no type or storage class

 1064 | MODULE_DEVICE_TABLE(of, tegra_vi_of_id_table);
      | ^~~~~~~~~~~~~~~~~~~
drivers/staging/media/tegra-video/vi.c:1064:1: error: type defaults to ‘int’ in declaration of ‘MODULE_DEVICE_TABLE’ [-Werror=implicit-int]
drivers/staging/media/tegra-video/vi.c:1064:1: warning: parameter names (without types) in function declaration
drivers/staging/media/tegra-video/csi.c:521:1: warning: data definition has no type or storage class
  521 | MODULE_DEVICE_TABLE(of, tegra_csi_of_id_table);
      | ^~~~~~~~~~~~~~~~~~~

drivers/staging/media/tegra-video/csi.c:521:1: error: type defaults to ‘int’ in declaration of ‘MODULE_DEVICE_TABLE’ [-Werror=implicit-int] drivers/staging/media/tegra-video/csi.c:521:1: warning: parameter names (without types) in function declaration

I'm applying the patches on top of the latest media_tree master.

It appears to be a missing module.h include in vi.c and csi.c.

If that's all it is, then just post a follow-up patch and I'll squash it with patch 6/9.

Regards,

Hans

Quoted 888 lines

[v11]: Includes,
- v10 feedback

[v10]: Includes,
- updated patches for latest linux-next base
- Kconfig update
- minor cleanup/improvements

[v9]: Includes,
- small fix to explicitly check for both vi and csi channels availability before TPG setup and cleanup so in the cases of later Tegras where CSI is not child to VI and if either of the platform drivers are not registered, TPG setup will be skipped.

[v8]: Includes,
- minor change to use device managed allocation fo vi and csi for now. May need to change back to non device managed allocation later when support for direct host1x client driver unbind and bind is added.

[v7]: Includes,
- v6 feedback
- moved registering v4l2 nodes and creating tpg media links to happen after both host1x client inits so during direct host1x client driver unbind and bind order of client unregister/register will not impact.
- All channels resources and freeing happens during v4l2 device release callback.
- module unload/load works with below host1x bus driver fix.
http://patchwork.ozlabs.org/patch/1268191/

[v6]: Includes,
- v5 feedback
- fix for csi_tpg clock parent
- fix to free channel resources in video device release callback for registered video devices as resource might still be in use when application holds handle to it during driver unbind.
- added blanking intervals based on resolution and bpp for csi internal tpg.
- added implementation for subdev pad ops enum_frame_size and enum_frame_interval.

[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 in case 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        |   73 +-
 MAINTAINERS                                        |   10 +
 arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi     |   10 +
 arch/arm64/boot/dts/nvidia/tegra210.dtsi           |   52 +-
 drivers/clk/tegra/clk-tegra210.c                   |    7 +
 drivers/staging/media/Kconfig                      |    2 +
 drivers/staging/media/Makefile                     |    1 +
 drivers/staging/media/tegra-video/Kconfig          |   12 +
 drivers/staging/media/tegra-video/Makefile         |    8 +
 drivers/staging/media/tegra-video/TODO             |   10 +
 drivers/staging/media/tegra-video/csi.c            |  535 ++++++++++
 drivers/staging/media/tegra-video/csi.h            |  144 +++
 drivers/staging/media/tegra-video/tegra210.c       | 1007 ++++++++++++++++++
 drivers/staging/media/tegra-video/vi.c             | 1078 ++++++++++++++++++++
 drivers/staging/media/tegra-video/vi.h             |  256 +++++
 drivers/staging/media/tegra-video/video.c          |  155 +++
 drivers/staging/media/tegra-video/video.h          |   29 +
 include/dt-bindings/clock/tegra210-car.h           |    2 +-
 include/dt-bindings/reset/tegra210-car.h           |    1 +
 19 files changed, 3375 insertions(+), 17 deletions(-)
 create mode 100644 drivers/staging/media/tegra-video/Kconfig
 create mode 100644 drivers/staging/media/tegra-video/Makefile
 create mode 100644 drivers/staging/media/tegra-video/TODO
 create mode 100644 drivers/staging/media/tegra-video/csi.c
 create mode 100644 drivers/staging/media/tegra-video/csi.h
 create mode 100644 drivers/staging/media/tegra-video/tegra210.c
 create mode 100644 drivers/staging/media/tegra-video/vi.c
 create mode 100644 drivers/staging/media/tegra-video/vi.h
 create mode 100644 drivers/staging/media/tegra-video/video.c
 create mode 100644 drivers/staging/media/tegra-video/video.h

v4l2-compliance SHA: 81e45d957c4db39397f893100b3d2729ef39b052, 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 0x02000007: from remote pad 0x1000006 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
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 : 0x0300000b
Type : V4L Video
Entity Info:

        ID               : 0x00000009 (9)
        Name             : 54080000.vi-output-1
        Function         : V4L2 I/O
        Pad 0x0100000a   : 0: Sink
          Link 0x0200000f: from remote pad 0x100000e 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
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 : 0x03000013
Type : V4L Video
Entity Info:

        ID               : 0x00000011 (17)
        Name             : 54080000.vi-output-2
        Function         : V4L2 I/O
        Pad 0x01000012   : 0: Sink
          Link 0x02000017: from remote pad 0x1000016 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
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 : 0x0300001b
Type : V4L Video
Entity Info:

        ID               : 0x00000019 (25)
        Name             : 54080000.vi-output-3
        Function         : V4L2 I/O
        Pad 0x0100001a   : 0: Sink
          Link 0x0200001f: from remote pad 0x100001e 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
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 : 0x03000023
Type : V4L Video
Entity Info:

        ID               : 0x00000021 (33)
        Name             : 54080000.vi-output-4
        Function         : V4L2 I/O
        Pad 0x01000022   : 0: Sink
          Link 0x02000027: from remote pad 0x1000026 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
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 : 0x0300002b
Type : V4L Video
Entity Info:

        ID               : 0x00000029 (41)
        Name             : 54080000.vi-output-5
        Function         : V4L2 I/O
        Pad 0x0100002a   : 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
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

author maintainer
#70 lore raw
Quoted 26 lines · Hans Verkuil
Quoted 10 lines · Sowjanya Komatineni

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.

I'm getting compile errors:

drivers/staging/media/tegra-video/vi.c:1064:1: warning: data definition has no type or storage class

  1064 | MODULE_DEVICE_TABLE(of, tegra_vi_of_id_table);
       | ^~~~~~~~~~~~~~~~~~~
drivers/staging/media/tegra-video/vi.c:1064:1: error: type defaults to ‘int’ in declaration of ‘MODULE_DEVICE_TABLE’ [-Werror=implicit-int]
drivers/staging/media/tegra-video/vi.c:1064:1: warning: parameter names (without types) in function declaration
drivers/staging/media/tegra-video/csi.c:521:1: warning: data definition has no type or storage class
   521 | MODULE_DEVICE_TABLE(of, tegra_csi_of_id_table);
       | ^~~~~~~~~~~~~~~~~~~

drivers/staging/media/tegra-video/csi.c:521:1: error: type defaults to ‘int’ in declaration of ‘MODULE_DEVICE_TABLE’ [-Werror=implicit-int] drivers/staging/media/tegra-video/csi.c:521:1: warning: parameter names (without types) in function declaration

I'm applying the patches on top of the latest media_tree master.

Quoted 8 lines

It appears to be a missing module.h include in vi.c and csi.c.

If that's all it is, then just post a follow-up patch and I'll squash it with patch 6/9.

Regards,

Hans

Hi Hans,

Sorry, somehow got that removed and I should have seen compile errors too but somehow did not see them. So didn't noticed that.

I see multiple patches from v11 conflict with latest linux and for clocks I also has to choose different id no in one of the patch.

Discussing with dmitry on his v11 feedback regarding when to allow freeze to happen.

So, probably will send v12 out after confirming with dmitry on having all feedback done now with v11.

Hopefully v12 can be the final version.

Quoted 888 lines
Quoted 888 lines

[v11]: Includes,
- v10 feedback

[v10]: Includes,
- updated patches for latest linux-next base
- Kconfig update
- minor cleanup/improvements

[v9]: Includes,
- small fix to explicitly check for both vi and csi channels availability before TPG setup and cleanup so in the cases of later Tegras where CSI is not child to VI and if either of the platform drivers are not registered, TPG setup will be skipped.

[v8]: Includes,
- minor change to use device managed allocation fo vi and csi for now. May need to change back to non device managed allocation later when support for direct host1x client driver unbind and bind is added.

[v7]: Includes,
- v6 feedback
- moved registering v4l2 nodes and creating tpg media links to happen after both host1x client inits so during direct host1x client driver unbind and bind order of client unregister/register will not impact.
- All channels resources and freeing happens during v4l2 device release callback.
- module unload/load works with below host1x bus driver fix.
http://patchwork.ozlabs.org/patch/1268191/

[v6]: Includes,
- v5 feedback
- fix for csi_tpg clock parent
- fix to free channel resources in video device release callback for registered video devices as resource might still be in use when application holds handle to it during driver unbind.
- added blanking intervals based on resolution and bpp for csi internal tpg.
- added implementation for subdev pad ops enum_frame_size and enum_frame_interval.

[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 in case 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        |   73 +-
  MAINTAINERS                                        |   10 +
  arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi     |   10 +
  arch/arm64/boot/dts/nvidia/tegra210.dtsi           |   52 +-
  drivers/clk/tegra/clk-tegra210.c                   |    7 +
  drivers/staging/media/Kconfig                      |    2 +
  drivers/staging/media/Makefile                     |    1 +
  drivers/staging/media/tegra-video/Kconfig          |   12 +
  drivers/staging/media/tegra-video/Makefile         |    8 +
  drivers/staging/media/tegra-video/TODO             |   10 +
  drivers/staging/media/tegra-video/csi.c            |  535 ++++++++++
  drivers/staging/media/tegra-video/csi.h            |  144 +++
  drivers/staging/media/tegra-video/tegra210.c       | 1007 ++++++++++++++++++
  drivers/staging/media/tegra-video/vi.c             | 1078 ++++++++++++++++++++
  drivers/staging/media/tegra-video/vi.h             |  256 +++++
  drivers/staging/media/tegra-video/video.c          |  155 +++
  drivers/staging/media/tegra-video/video.h          |   29 +
  include/dt-bindings/clock/tegra210-car.h           |    2 +-
  include/dt-bindings/reset/tegra210-car.h           |    1 +
  19 files changed, 3375 insertions(+), 17 deletions(-)

create mode 100644 drivers/staging/media/tegra-video/Kconfig create mode 100644 drivers/staging/media/tegra-video/Makefile create mode 100644 drivers/staging/media/tegra-video/TODO create mode 100644 drivers/staging/media/tegra-video/csi.c create mode 100644 drivers/staging/media/tegra-video/csi.h create mode 100644 drivers/staging/media/tegra-video/tegra210.c create mode 100644 drivers/staging/media/tegra-video/vi.c create mode 100644 drivers/staging/media/tegra-video/vi.h create mode 100644 drivers/staging/media/tegra-video/video.c create mode 100644 drivers/staging/media/tegra-video/video.h

v4l2-compliance SHA: 81e45d957c4db39397f893100b3d2729ef39b052, 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 0x02000007: from remote pad 0x1000006 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
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 : 0x0300000b
Type : V4L Video
Entity Info:

         ID               : 0x00000009 (9)
         Name             : 54080000.vi-output-1
         Function         : V4L2 I/O
         Pad 0x0100000a   : 0: Sink
           Link 0x0200000f: from remote pad 0x100000e 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
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 : 0x03000013
Type : V4L Video
Entity Info:

         ID               : 0x00000011 (17)
         Name             : 54080000.vi-output-2
         Function         : V4L2 I/O
         Pad 0x01000012   : 0: Sink
           Link 0x02000017: from remote pad 0x1000016 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
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 : 0x0300001b
Type : V4L Video
Entity Info:

         ID               : 0x00000019 (25)
         Name             : 54080000.vi-output-3
         Function         : V4L2 I/O
         Pad 0x0100001a   : 0: Sink
           Link 0x0200001f: from remote pad 0x100001e 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
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 : 0x03000023
Type : V4L Video
Entity Info:

         ID               : 0x00000021 (33)
         Name             : 54080000.vi-output-4
         Function         : V4L2 I/O
         Pad 0x01000022   : 0: Sink
           Link 0x02000027: from remote pad 0x1000026 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
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 : 0x0300002b
Type : V4L Video
Entity Info:

         ID               : 0x00000029 (41)
         Name             : 54080000.vi-output-5
         Function         : V4L2 I/O
         Pad 0x0100002a   : 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
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