Top Banner
Integrating the driver experience public Automotive Virtual Platform Using VIRTIO Mikhail Golubev @ Automotive Linux Summit 2019
23

Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

Apr 04, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

Integrating the driver experience

public

Automotive Virtual Platform Using VIRTIOMikhail Golubev @ Automotive Linux Summit 2019

Page 2: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

2www.opensynergy.com | public

Agenda

• “Paving the Path to Standardization of Virtualization” Dr. Ralph Sasse @ ALS Tokyo 2018

• VIRTIO in a nutshell

• virtio-video

• virtio-snd

• Demo

Page 3: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

3www.opensynergy.com | public

vdriver

Mechanisms for device sharing in COQOS

Hypervisor

SoC device

driver

driver

in Hypervisor

driver

Hypervisor

SoC

driver

device with virtualization support

driver

Hypervisor

SoC device

virtual driver

virtdev1 virtdevN

distributed frameworks over VNET

vdriverdriver

Hypervisor

SoC device

driver

frame-worksharing

frame-work

VNET

• Only used for UART (optionally)

• not recommended for other devices as the Hypervisor is minimalistic

Example: UART

• COQOS supports this when the SoC hardware supports virtualized devices

• Recommended wherever the hardware supports it, as it tends to give the best performance and separation

Example: GPU on RCAR-H3

• Single driver in VM that acts as "server"

• Driver-specific sharing logic is needed

• Other VMs use "virtual driver"• Compromise between

performance and flexibility• Can use VIRTIO

Example: shared block device

• Allows reuse of existing frameworks for distributed applications over virtual network

• Supports complex sharing semantics at the cost of more overhead

Example: NFS, PULSE AUDIO

VIRTIO

Page 4: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

4www.opensynergy.com | public

Hypervisor BHypervisor A

• Virtual machine guest that could be moved among different hypervisor systems and/or HW platforms without further modification through establishing an industry standard / de-facto standard.

VISION: Run Guests without modifications

SoC-A SoC-B

Guest

vDRV

Page 5: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

6www.opensynergy.com | public

• “virtio: Towards a de-Facto Standard For Virtual I/O Devices” [Rusty Russell 2008]

• Formally standardized since March 2016 (OASIS VIRTIO-v1.0)

• VIRTIO provides the transport layer and device models for many devices (OASIS VIRTIO-v1.1 approved 2019)

• Block Storage, SCSI

• Network

• Console

• Entropy (rng)

• Memory balloon

• Crypto

• GPU 2D

• Input (hid)

• Socket (vsock)

• Many more in development (vIOMMU, etc.)

• For the Automotive domain there is work in progress

• Audio

• Sensors

• Media Acceleration (VPU, IPU, CODEC)

Introduction to VIRTIO

Page 6: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

7www.opensynergy.com | public

SoC

Hypervisor

Linux/Android user space

Linux kernel space

Client VM Memory

Device HW

Driver VM

Kernel Subsystem

virtio_<transport>

virtio-<device>

BufferVQ

Plumbing

SG list

Open Source

Hypervisor Vendor

virtio Support

Device

Virtualization

Framework

VQ=virt-queue

SG=Scatter Gather

Bulk data transport via DMA-like memory model

• Buffer allocations handled by „Driver“ part (client)

• Direct R/W access to allocated buffers in the „Device“ part (server)

Metadata transport via virt-queues (ring buffers, asynchronous pipeline)

Virtualized device Architecture with VIRTIODevice VM

Page 7: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

8www.opensynergy.com | public

• Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output devices, codec devices

• Hardware video acceleration offloads the CPU, increases performance, and saves power

• An abstract video streaming device that operates input and/or output data buffers is used to share video devices with several guests

• Buffers are essentially scatter-gather lists used for DMA operations (similar to virtio-gpu).

• The buffers are used to organize data streams, e.g. from a camera (output stream) or from a decoder (input stream with decoded data and output stream with decoded frames).

Virtual video streaming device concept

Page 8: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

9www.opensynergy.com | public

The virtio-video device performs operations on video streams

Decoding

Encoding

Input/output

Control

Virtual video required functional

OutputInput

Control

Codec

SoC

Virtio-Video Driver

Page 9: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

10www.opensynergy.com | public

Two codec device types exist:

Stateful Video Codec*

Decoder takes complete chunks of the bitstream and decodes them into raw video frames in display order. The decoder is expected not to require any additional information from the client to process these buffers

Encoder takes raw video frames in display order and encodes them into a bitstream. It generates complete chunks of the bitstream, including all metadata, headers, etc. The resulting bitstream does not require any further post-processing by the client

Stateless Video Codec*

Is a decoder that works without retaining any kind of state between processed frames. This means that each frame is decoded independently of any previous and future frames, and that the client is responsible for maintaining the decoding state and providing it to the decoder with each decoding request

Codec device types

* from the LKML: https://lkml.org/lkml/2019/1/24/246

Page 10: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

11www.opensynergy.com | public

Stateless decoders

Codec device types

Bitstream Parser

Metadata

Encoded Frame

Control

Decode

Video Stream

Legend: Software Hardware

Frames

Page 11: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

12www.opensynergy.com | public

Stateful decoders

Codec device types

Bitstream Parser

Metadata

Encoded Frame

Control

Decode

Video Stream

Legend: Software Hardware

Frames

Virtualiztation

Capable

Page 12: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

13www.opensynergy.com | public

APIs to access video devices

Several major APIs exist at the moment:

• OpenMAX

A royalty-free, cross-platform API that provides comprehensive streaming media codec and application portability.

• VA-API

Provides access to graphics hardware acceleration capabilities for video processing. It consists of a main library and driver-specific acceleration backends for each supported hardware vendor.

• V4L2

API that has been designed to control media devices in Linux. Supports the DMABUF framework, which provides a generic method for sharing buffers between multiple devices.

Page 13: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

14www.opensynergy.com | public

Guest 1 (Linux)

virtio-video on Linux based systems

User

Kernelv4l2

SoC

Hypervisor

• V4l2 based driver

• Stateful interface

• Supports:

• Hardware video codec virtualization

• Camera input

• Memory to Memory or device to device by use of dma-buffers

• Memory model same as virtio-gpu

• Virtio-gpu and video can share buffers

All of the above is only WIP so far!

Media Framework

Guest N

Guest 1 (Linux)

v4l2

virtio-video

Media AppMedia App

virtio

Media Framework

virtio-video

Page 14: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

15www.opensynergy.com | public

Configuration

No APIs really make it possible to get all supported hardware features. Datasheet is the only source of reliable information

Virtio device configuration layout can be very complex, especially for devices with many customizable controls

BSP versions

The media subsystem in the upstream kernel is evolving rapidly. E.g. the 4.14 kernel does not contain a definition of the H265/HEVC video format

Android integration

Currently OMX is ubiquitous. Codec2 is a new HAL

No v4l2 based Codec2 solutions

virtio-video challenges

Page 15: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

16www.opensynergy.com | public

The virtio-snd device performs operations on PCM audio streams

Playback

Record

Controls

Required audio functional

CapturePlayback

Control

SoC

virtio-snd Driver

Page 16: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

17www.opensynergy.com | public

PCM audio stream

Sample

LN

Sample

RN

Sample

LN-1

Sample

RN-1

Sample

LN-2

Sample

RN-1

Frame

Channel

Track

Time

Page 17: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

18www.opensynergy.com | public

Guest 1 (Linux)

virtio-snd on Linux based systems

User

KernelALSA

SoC

Hypervisor

• ALSA based driver

• Supports:

• Audio playback

• Audio capture

• Mmap capable

• Playback command flow:

• Set format

• Prepare

• Playback pre-buffer

• Start

• Pause/unpause

• Stop

Guest N

Guest 1 (Linux)

ALSA

virtio-snd

Media AppMedia App

virtio

Media Framework

virtio-snd

Media Framework

Page 18: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

19www.opensynergy.com | public

Don‘t stop

Don‘t interrupt

Playback stream seeking

Latency should be low

Stream start-up time should be low

virtio-snd challanges

Page 19: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

20www.opensynergy.com | public

virtio-video

POC

With COOQS hypervision on Linux Renesas RCar H3

virtio-snd

Spec is on virtio-devel mailing list

Dicussion still ongoing

POC

With COOQS hypervision on Linux Renesas RCar H3

Qemu-KVM running Linux

Qemu-KVM running Windows 10

Quemu-ARM running Android

Linux kernel driver RFC patchset is ready and will be posted shortly

Qemu reference implementation to follow

virtio-video and virtio-snd outlook

Page 20: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

21www.opensynergy.com | public

Guest 1 (Linux)

Demo setup

Weston

virtio-snd

SoC

Hypervisor

• RCar H3 Salvator XS

• Two Poky Linux guests

• Virtio devices

• Video

• Sound

• Gpu 2D

• Block device

• 720p H264 encoded sample video

Guest 1 (Linux)

GStreamer

virtio

virtio-video

virtio-gpu

virtio-blk

Page 21: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

22www.opensynergy.com | public

Demo

Page 22: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

23www.opensynergy.com | public

Questions? Comments?

Page 23: Automotive Virtual Platform Using VIRTIO · 2019-12-21 · public | 8 • Paravirtualised guests require video streaming devices, including video cameras, streaming capture and output

OpenSynergy, COQOS Hypervisor SDK, Blue SDK, IrDA SDK, Voice SDK, Qonformat, and other OpenSynergy products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of OpenSynergy GmbH in Germany and in other countries around the world. All other product and service names in this document are the trademarks of their respective companies. These materials are subject to change without notice. These materials are provided by OpenSynergy GmbH for informational purposes only, without representation or warranty of any

kind and OpenSynergy GmbH shall not be liable for errors or omissions with respect to the materials. © OpenSynergy GmbH 2018

Headquarter Further Locations

California

OpenSynergy, Inc. (USA)

501 W. Broadway, Suite 832San Diego, California 92101USAPhone +1 619 962 1725

Munich

OpenSynergy GmbH

Starnberger Str. 22D-82131 Gauting / MunichGermanyPhone: + 49 89 / 8934 1333

Utah

OpenSynergy, Inc. (USA)

765 East 340 SouthSuite 106American Fork, Utah 84003USA

Berlin

OpenSynergy GmbH

Rotherstraße 20D-10245 BerlinGermanyPhone +49 30 / 6098 5400

E-Mail [email protected] www.opensynergy.com