From: Dmitry Morozov <dmitry.morozov@opensynergy.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: "Tomasz Figa" <tfiga@chromium.org>,
stevensd@chromium.org, virtio-dev@lists.oasis-open.org,
"Keiichi Watanabe" <keiichiw@chromium.org>,
"Alexandre Courbot" <acourbot@chromium.org>,
alexlau@chromium.org, dgreid@chromium.org,
"Stéphane Marchesin" <marcheu@chromium.org>,
"Pawel Osciak" <posciak@chromium.org>,
"Hans Verkuil" <hverkuil@xs4all.nl>,
"Linux Media Mailing List" <linux-media@vger.kernel.org>,
"Daniel Vetter" <daniel@ffwll.ch>
Subject: Re: [virtio-dev] [PATCH] [RFC RESEND] vdec: Add virtio video decode device specification
Date: Tue, 15 Oct 2019 16:06:36 +0200 [thread overview]
Message-ID: <9670471.GKRsIjc3Fr@os-lin-dmo> (raw)
In-Reply-To: <20191015075422.yeknnqlsy3nun44r@sirius.home.kraxel.org>
Hello Gerd,
On Dienstag, 15. Oktober 2019 09:54:22 CEST Gerd Hoffmann wrote:
> On Mon, Oct 14, 2019 at 03:05:03PM +0200, Dmitry Morozov wrote:
> > On Montag, 14. Oktober 2019 14:34:43 CEST Gerd Hoffmann wrote:
> > > Hi,
> > >
> > > > My take on this (for a decoder) would be to allocate memory for output
> > > > buffers from a secure ION heap, import in the v4l2 driver, and then to
> > > > provide those to the device using virtio. The device side then uses
> > > > the
> > > > dmabuf framework to make the buffers accessible for the hardware. I'm
> > > > not
> > > > sure about that, it's just an idea.
> > >
> > > Virtualization aside, how does the complete video decoding workflow
> > > work? I assume along the lines of ...
> > >
> > > (1) allocate buffer for decoded video frames (from ion).
> > > (2) export those buffers as dma-buf.
> > > (3) import dma-buf to video decoder.
> > > (4) import dma-buf to gpu.
> > >
> > > ... to establish buffers shared between video decoder and gpu?
> > >
> > > Then feed the video stream into the decoder, which decodes into the ion
> > > buffers? Ask the gpu to scanout the ion buffers to show the video?
> > >
> > > cheers,
> > >
> > > Gerd
> >
> > Yes, exactly.
> >
> > [decoder]
> > 1) Input buffers are allocated using VIDIOC_*BUFS.
>
> Ok.
>
> > 2) Output buffers are allocated in a guest specific manner (ION, gbm).
>
> Who decides whenever ION or gbm is used? The phrase "secure ION heap"
> used above sounds like using ION is required for decoding drm-protected
> content.
I mention the secure ION heap to address this Chrome OS related point:
> 3) protected content decoding: the memory for decoded video frames
> must not be accessible to the guest at all
There was an RFC to implement a secure memory allocation framework, but
apparently it was not accepted: https://lwn.net/Articles/661549/.
In case of Android, it allocates GPU buffers for output frames, so it is the
gralloc implementation who decides how to allocate memory. It can use some
dedicated ION heap or can use libgbm. It can also be some proprietary
implementation.
>
> So, do we have to worry about ION here? Or can we just use gbm?
If we replace vendor specific code in the Android guest and provide a way to
communicate meatdata for buffer allocations from the device to the driver, we
can use gbm. In the PC world it might be easier.
>
> [ Note: don't know much about ion, other than that it is used by
> android, is in staging right now and patches to move it
> out of staging are floating around @ dri-devel ]
>
> > 3) Both input and output buffers are exported as dma-bufs.
> > 4) The backing storage of both inputs and outputs is made available to the
> > device.
> > 5) Decoder hardware writes to output buffers directly.
>
> As expected.
>
> > 6) Back to the guest side, the output dma-bufs are used by (virtio-) gpu.
>
> Ok. So, virtio-gpu has support for dma-buf exports (in drm-misc-next,
> should land upstream in kernel 5.5). dma-buf imports are not that
> simple unfortunately. When using the gbm allocation route dma-buf
> exports are good enough though.
>
> The virtio-gpu resources have both a host buffer and a guest buffer[1]
> Data can be copied using the DRM_IOCTL_VIRTGPU_TRANSFER_{FROM,TO}_HOST
> ioctls. The dma-buf export will export the guest buffer (which lives
> in guest ram).
>
> It would make sense for the decoded video to go directly to the host
> buffer though. First because we want avoid copying the video frames for
> performance reasons, and second because we might not be able to copy
> video frames (drm ...).
>
> This is where the buffer registry idea comes in. Attach a (host)
> identifier to (guest) dma-bufs, which then allows host device emulation
> share buffers, i.e. virtio-vdec device emulation could decode to a
> dma-buf it got from virtio-gpu device emulation.
Yes. Also, as I mentioned above, in case of gbm the buffers already can
originate from GPU.
Best regards,
Dmitry.
>
> Alternatively we could use virtual ION (or whatever it becomes after
> de-staging) for buffer management, with both virtio-vdec and virtio-gpu
> importing dma-bufs from virtual ION on both guest and host side.
>
> cheers,
> Gerd
>
> [1] support for shared buffers is in progress.
next prev parent reply other threads:[~2019-10-15 14:06 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-19 9:34 [PATCH] [RFC RESEND] vdec: Add virtio video decode device specification Keiichi Watanabe
2019-09-19 9:52 ` Hans Verkuil
2019-09-19 11:15 ` Keiichi Watanabe
2019-09-19 11:17 ` Keiichi Watanabe
2019-09-23 8:56 ` [virtio-dev] " Gerd Hoffmann
2019-10-05 6:08 ` Tomasz Figa
2019-10-07 14:00 ` Dmitry Morozov
2019-10-07 14:14 ` Tomasz Figa
2019-10-07 15:09 ` Dmitry Morozov
2019-10-09 3:55 ` Tomasz Figa
2019-10-11 8:53 ` Dmitry Morozov
2019-10-14 12:34 ` Gerd Hoffmann
2019-10-14 13:05 ` Dmitry Morozov
2019-10-15 7:54 ` Gerd Hoffmann
2019-10-15 14:06 ` Dmitry Morozov [this message]
2019-10-17 8:06 ` Tomasz Figa
2019-10-17 6:40 ` Tomasz Figa
2019-10-17 7:19 ` Gerd Hoffmann
2019-10-17 8:11 ` Tomasz Figa
2019-10-17 10:13 ` Gerd Hoffmann
2019-10-29 7:39 ` David Stevens
2019-10-31 7:30 ` Keiichi Watanabe
2019-10-31 9:10 ` David Stevens
2019-11-07 8:29 ` Keiichi Watanabe
2019-10-14 12:19 ` Gerd Hoffmann
2019-10-17 6:58 ` Tomasz Figa
2019-10-17 7:44 ` Gerd Hoffmann
2019-10-17 8:23 ` Tomasz Figa
2019-10-17 10:22 ` Gerd Hoffmann
2019-10-17 7:06 ` David Stevens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9670471.GKRsIjc3Fr@os-lin-dmo \
--to=dmitry.morozov@opensynergy.com \
--cc=acourbot@chromium.org \
--cc=alexlau@chromium.org \
--cc=daniel@ffwll.ch \
--cc=dgreid@chromium.org \
--cc=hverkuil@xs4all.nl \
--cc=keiichiw@chromium.org \
--cc=kraxel@redhat.com \
--cc=linux-media@vger.kernel.org \
--cc=marcheu@chromium.org \
--cc=posciak@chromium.org \
--cc=stevensd@chromium.org \
--cc=tfiga@chromium.org \
--cc=virtio-dev@lists.oasis-open.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox