All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Yang <lfy@google.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: "Gerd Hoffmann" <kraxel@redhat.com>,
	geoff@hostfission.com, virtio-dev@lists.oasis-open.org,
	"Alex Lau" <alexlau@chromium.org>,
	"Alexandre Courbot" <acourbot@chromium.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	"Tomasz Figa" <tfiga@chromium.org>,
	"Keiichi Watanabe" <keiichiw@chromium.org>,
	"David Stevens" <stevensd@chromium.org>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Stéphane Marchesin" <marcheu@chromium.org>,
	"Dylan Reid" <dgreid@chromium.org>,
	"Gurchetan Singh" <gurchetansingh@chromium.org>,
	"Hans Verkuil" <hverkuil@xs4all.nl>,
	"Dmitry Morozov" <dmitry.morozov@opensynergy.com>,
	"Pawel Osciak" <posciak@chromium.org>,
	"Linux Media Mailing List" <linux-media@vger.kernel.org>
Subject: Re: guest / host buffer sharing ...
Date: Thu, 7 Nov 2019 07:10:15 -0800	[thread overview]
Message-ID: <CAEkmjvU8or7YT7CCBe7aUx-XQ3yJpUrY4CfBOnqk7pUH9d9RGQ@mail.gmail.com> (raw)
In-Reply-To: <CAJSP0QXG5Z3zCnPL+Y7EQfCeey2Fb9OdPdx531Jz2Ofk63wndg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3242 bytes --]

So I'm not really sure why people are having issues sharing buffers that
live on the GPU. Doesn't that show up as some integer ID on the host, and
some $GuestFramework (dmabuf, gralloc) ID on the guest, and it all works
out due to maintaining the correspondence in your particular stack of
virtual devices? For example, if you want to do video decode in hardware on
an Android guest, there should be a gralloc buffer whose handle contains
enough information to reconstruct the GPU buffer ID on the host, because
gralloc is how processes communicate gpu buffer ids to each other on
Android.

BTW, if we have a new device just for this, this should also be more
flexible than being udmabuf on the host. There are other OSes than Linux.
Keep in mind, also, that across different drivers even on Linux, e.g.,
NVIDIA proprietary, dmabuf might not always be available.

As for host CPU memory that is allocated in various ways, I think Android
Emulator has built a very flexible/general solution, esp if we need to
share a host CPU buffer allocated via something thats not completely under
our control, such as Vulkan. We reserve a PCI BAR for that and map memory
directly from the host Vk drier into there, via the address space device.
It's

https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-master-dev/hw/pci/goldfish_address_space.c

https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-master-dev/android/android-emu/android/emulation/address_space_device.cpp#205


Number of copies is also completely under the user's control, unlike
ivshmem. It also is not tied to any particular device such as gpu or codec.
Since the memory is owned by the host and directly mapped to the guest PCI
without any abstraction, it's contiguous, it doesn't carve out guest RAM,
doesn't waste CMA, etc.

On Thu, Nov 7, 2019 at 4:13 AM Stefan Hajnoczi <stefanha@gmail.com> wrote:

> On Wed, Nov 6, 2019 at 1:50 PM Gerd Hoffmann <kraxel@redhat.com> wrote:
> > > In the graphics buffer sharing use case, how does the other side
> > > determine how to interpret this data?
> >
> > The idea is to have free form properties (name=value, with value being
> > a string) for that kind of metadata.
> >
> > > Shouldn't there be a VIRTIO
> > > device spec for the messaging so compatible implementations can be
> > > written by others?
> >
> > Adding a list of common properties to the spec certainly makes sense,
> > so everybody uses the same names.  Adding struct-ed properties for
> > common use cases might be useful too.
>
> Why not define VIRTIO devices for wayland and friends?
>
> This new device exposes buffer sharing plus properties - effectively a
> new device model nested inside VIRTIO.  The VIRTIO device model has
> the necessary primitives to solve the buffer sharing problem so I'm
> struggling to see the purpose of this new device.
>
> Custom/niche applications that do not wish to standardize their device
> type can maintain out-of-tree VIRTIO devices.  Both kernel and
> userspace drivers can be written for the device and there is already
> VIRTIO driver code that can be reused.  They have access to the full
> VIRTIO device model, including feature negotiation and configuration
> space.
>
> Stefan
>
>

[-- Attachment #2: Type: text/html, Size: 4191 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Frank Yang <lfy@google.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: "Gerd Hoffmann" <kraxel@redhat.com>,
	geoff@hostfission.com, virtio-dev@lists.oasis-open.org,
	"Alex Lau" <alexlau@chromium.org>,
	"Alexandre Courbot" <acourbot@chromium.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	"Tomasz Figa" <tfiga@chromium.org>,
	"Keiichi Watanabe" <keiichiw@chromium.org>,
	"David Stevens" <stevensd@chromium.org>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Stéphane Marchesin" <marcheu@chromium.org>,
	"Dylan Reid" <dgreid@chromium.org>,
	"Gurchetan Singh" <gurchetansingh@chromium.org>,
	"Hans Verkuil" <hverkuil@xs4all.nl>,
	"Dmitry Morozov" <dmitry.morozov@opensynergy.com>,
	"Pawel Osciak" <posciak@chromium.org>,
	"Linux Media Mailing List" <linux-media@vger.kernel.org>
Subject: [virtio-dev] Re: guest / host buffer sharing ...
Date: Thu, 7 Nov 2019 07:10:15 -0800	[thread overview]
Message-ID: <CAEkmjvU8or7YT7CCBe7aUx-XQ3yJpUrY4CfBOnqk7pUH9d9RGQ@mail.gmail.com> (raw)
In-Reply-To: <CAJSP0QXG5Z3zCnPL+Y7EQfCeey2Fb9OdPdx531Jz2Ofk63wndg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3242 bytes --]

So I'm not really sure why people are having issues sharing buffers that
live on the GPU. Doesn't that show up as some integer ID on the host, and
some $GuestFramework (dmabuf, gralloc) ID on the guest, and it all works
out due to maintaining the correspondence in your particular stack of
virtual devices? For example, if you want to do video decode in hardware on
an Android guest, there should be a gralloc buffer whose handle contains
enough information to reconstruct the GPU buffer ID on the host, because
gralloc is how processes communicate gpu buffer ids to each other on
Android.

BTW, if we have a new device just for this, this should also be more
flexible than being udmabuf on the host. There are other OSes than Linux.
Keep in mind, also, that across different drivers even on Linux, e.g.,
NVIDIA proprietary, dmabuf might not always be available.

As for host CPU memory that is allocated in various ways, I think Android
Emulator has built a very flexible/general solution, esp if we need to
share a host CPU buffer allocated via something thats not completely under
our control, such as Vulkan. We reserve a PCI BAR for that and map memory
directly from the host Vk drier into there, via the address space device.
It's

https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-master-dev/hw/pci/goldfish_address_space.c

https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-master-dev/android/android-emu/android/emulation/address_space_device.cpp#205


Number of copies is also completely under the user's control, unlike
ivshmem. It also is not tied to any particular device such as gpu or codec.
Since the memory is owned by the host and directly mapped to the guest PCI
without any abstraction, it's contiguous, it doesn't carve out guest RAM,
doesn't waste CMA, etc.

On Thu, Nov 7, 2019 at 4:13 AM Stefan Hajnoczi <stefanha@gmail.com> wrote:

> On Wed, Nov 6, 2019 at 1:50 PM Gerd Hoffmann <kraxel@redhat.com> wrote:
> > > In the graphics buffer sharing use case, how does the other side
> > > determine how to interpret this data?
> >
> > The idea is to have free form properties (name=value, with value being
> > a string) for that kind of metadata.
> >
> > > Shouldn't there be a VIRTIO
> > > device spec for the messaging so compatible implementations can be
> > > written by others?
> >
> > Adding a list of common properties to the spec certainly makes sense,
> > so everybody uses the same names.  Adding struct-ed properties for
> > common use cases might be useful too.
>
> Why not define VIRTIO devices for wayland and friends?
>
> This new device exposes buffer sharing plus properties - effectively a
> new device model nested inside VIRTIO.  The VIRTIO device model has
> the necessary primitives to solve the buffer sharing problem so I'm
> struggling to see the purpose of this new device.
>
> Custom/niche applications that do not wish to standardize their device
> type can maintain out-of-tree VIRTIO devices.  Both kernel and
> userspace drivers can be written for the device and there is already
> VIRTIO driver code that can be reused.  They have access to the full
> VIRTIO device model, including feature negotiation and configuration
> space.
>
> Stefan
>
>

[-- Attachment #2: Type: text/html, Size: 4191 bytes --]

  reply	other threads:[~2019-11-07 15:11 UTC|newest]

Thread overview: 139+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05 10:54 guest / host buffer sharing Gerd Hoffmann
2019-11-05 10:54 ` [virtio-dev] " Gerd Hoffmann
2019-11-05 10:54 ` Gerd Hoffmann
2019-11-05 11:35 ` Geoffrey McRae
2019-11-06  6:24   ` Gerd Hoffmann
2019-11-06  6:24     ` [virtio-dev] " Gerd Hoffmann
2019-11-06  6:24     ` Gerd Hoffmann
2019-11-06  8:36 ` David Stevens
2019-11-06  8:36   ` [virtio-dev] " David Stevens
2019-11-06  8:36   ` David Stevens
2019-11-06 12:41   ` Gerd Hoffmann
2019-11-06 12:41     ` [virtio-dev] " Gerd Hoffmann
2019-11-06 12:41     ` Gerd Hoffmann
2019-11-06 22:28     ` Geoffrey McRae
2019-11-07  6:48       ` Gerd Hoffmann
2019-11-07  6:48         ` [virtio-dev] " Gerd Hoffmann
2019-11-07  6:48         ` Gerd Hoffmann
2019-11-20 12:13       ` Tomasz Figa
2019-11-20 12:13         ` [virtio-dev] " Tomasz Figa
2019-11-20 12:13         ` Tomasz Figa
2019-11-20 21:41         ` Geoffrey McRae
2019-11-21  5:51           ` Tomasz Figa
2019-11-21  5:51             ` [virtio-dev] " Tomasz Figa
2019-11-21  5:51             ` Tomasz Figa
2019-12-04 22:22             ` Dylan Reid
2019-12-04 22:22               ` Dylan Reid
2019-12-11  5:08               ` David Stevens
2019-12-11  5:08                 ` [virtio-dev] " David Stevens
2019-12-11  5:08                 ` David Stevens
2019-12-11  9:26                 ` Gerd Hoffmann
2019-12-11  9:26                   ` [virtio-dev] " Gerd Hoffmann
2019-12-11  9:26                   ` Gerd Hoffmann
2019-12-11 16:05                   ` [virtio-dev] " Enrico Granata
2019-12-11 16:05                     ` Enrico Granata
2019-12-12  6:40                   ` David Stevens
2019-12-12  6:40                     ` David Stevens
2019-12-12  6:40                     ` David Stevens
2019-12-12  9:41                     ` Gerd Hoffmann
2019-12-12  9:41                       ` Gerd Hoffmann
2019-12-12  9:41                       ` Gerd Hoffmann
2019-12-12 12:26                       ` David Stevens
2019-12-12 12:26                         ` David Stevens
2019-12-12 12:26                         ` David Stevens
2019-12-12 13:30                         ` Gerd Hoffmann
2019-12-12 13:30                           ` Gerd Hoffmann
2019-12-12 13:30                           ` Gerd Hoffmann
2019-12-13  3:21                           ` David Stevens
2019-12-13  3:21                             ` David Stevens
2019-12-13  3:21                             ` David Stevens
2019-12-16 13:47                             ` Gerd Hoffmann
2019-12-16 13:47                               ` Gerd Hoffmann
2019-12-16 13:47                               ` Gerd Hoffmann
2019-12-17 12:59                               ` David Stevens
2019-12-17 12:59                                 ` David Stevens
2019-12-17 12:59                                 ` David Stevens
2019-11-06  8:43 ` Stefan Hajnoczi
2019-11-06  8:43   ` Stefan Hajnoczi
2019-11-06  9:51   ` Gerd Hoffmann
2019-11-06  9:51     ` [virtio-dev] " Gerd Hoffmann
2019-11-06  9:51     ` Gerd Hoffmann
2019-11-06 10:10     ` [virtio-dev] " Dr. David Alan Gilbert
2019-11-06 10:10       ` Dr. David Alan Gilbert
2019-11-06 10:10       ` Dr. David Alan Gilbert
2019-11-07 11:11       ` Gerd Hoffmann
2019-11-07 11:11         ` Gerd Hoffmann
2019-11-07 11:11         ` Gerd Hoffmann
2019-11-07 11:16         ` Dr. David Alan Gilbert
2019-11-07 11:16           ` Dr. David Alan Gilbert
2019-11-07 11:16           ` Dr. David Alan Gilbert
2019-11-08  6:45           ` Gerd Hoffmann
2019-11-08  6:45             ` Gerd Hoffmann
2019-11-08  6:45             ` Gerd Hoffmann
2019-11-06 11:46     ` Stefan Hajnoczi
2019-11-06 11:46       ` Stefan Hajnoczi
2019-11-06 12:50       ` Gerd Hoffmann
2019-11-06 12:50         ` [virtio-dev] " Gerd Hoffmann
2019-11-06 12:50         ` Gerd Hoffmann
2019-11-07 12:10         ` Stefan Hajnoczi
2019-11-07 12:10           ` Stefan Hajnoczi
2019-11-07 15:10           ` Frank Yang [this message]
2019-11-07 15:10             ` [virtio-dev] " Frank Yang
2019-11-20 11:58             ` Tomasz Figa
2019-11-20 11:58               ` [virtio-dev] " Tomasz Figa
2019-11-20 11:58               ` Tomasz Figa
2019-11-08  7:22           ` Gerd Hoffmann
2019-11-08  7:22             ` [virtio-dev] " Gerd Hoffmann
2019-11-08  7:22             ` Gerd Hoffmann
2019-11-08  7:35             ` Stefan Hajnoczi
2019-11-08  7:35               ` Stefan Hajnoczi
2019-11-09  1:41               ` Stéphane Marchesin
2019-11-09  1:41                 ` Stéphane Marchesin
2019-11-09 10:12                 ` Stefan Hajnoczi
2019-11-09 10:12                   ` Stefan Hajnoczi
2019-11-09 11:16                   ` Tomasz Figa
2019-11-09 11:16                     ` [virtio-dev] " Tomasz Figa
2019-11-09 11:16                     ` Tomasz Figa
2019-11-09 12:08                     ` Stefan Hajnoczi
2019-11-09 12:08                       ` Stefan Hajnoczi
2019-11-09 15:12                       ` Tomasz Figa
2019-11-09 15:12                         ` [virtio-dev] " Tomasz Figa
2019-11-09 15:12                         ` Tomasz Figa
2019-11-18 10:20                         ` Stefan Hajnoczi
2019-11-18 10:20                           ` Stefan Hajnoczi
2019-11-20 10:11                           ` Tomasz Figa
2019-11-20 10:11                             ` [virtio-dev] " Tomasz Figa
2019-11-20 10:11                             ` Tomasz Figa
2019-11-20 12:11     ` Tomasz Figa
2019-11-20 12:11       ` [virtio-dev] " Tomasz Figa
2019-11-20 12:11       ` Tomasz Figa
2019-11-11  3:04   ` David Stevens
2019-11-11  3:04     ` [virtio-dev] " David Stevens
2019-11-11  3:04     ` David Stevens
2019-11-11 15:36     ` [virtio-dev] " Liam Girdwood
2019-11-11 15:36       ` Liam Girdwood
2019-11-11 15:36       ` Liam Girdwood
2019-11-12  0:54       ` Gurchetan Singh
2019-11-12  0:54         ` Gurchetan Singh
2019-11-12  0:54         ` Gurchetan Singh
2019-11-12 13:56         ` Liam Girdwood
2019-11-12 13:56           ` Liam Girdwood
2019-11-12 13:56           ` Liam Girdwood
2019-11-12 22:55           ` Gurchetan Singh
2019-11-12 22:55             ` Gurchetan Singh
2019-11-12 22:55             ` Gurchetan Singh
2019-11-19 15:31             ` Liam Girdwood
2019-11-19 15:31               ` Liam Girdwood
2019-11-19 15:31               ` Liam Girdwood
2019-11-20  0:42               ` Gurchetan Singh
2019-11-20  0:42                 ` Gurchetan Singh
2019-11-20  0:42                 ` Gurchetan Singh
2019-11-20  9:53               ` Gerd Hoffmann
2019-11-20  9:53                 ` Gerd Hoffmann
2019-11-20  9:53                 ` Gerd Hoffmann
2019-11-25 16:46                 ` Liam Girdwood
2019-11-25 16:46                   ` Liam Girdwood
2019-11-25 16:46                   ` Liam Girdwood
2019-11-27  7:58                   ` Gerd Hoffmann
2019-11-27  7:58                     ` Gerd Hoffmann
2019-11-27  7:58                     ` Gerd Hoffmann

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=CAEkmjvU8or7YT7CCBe7aUx-XQ3yJpUrY4CfBOnqk7pUH9d9RGQ@mail.gmail.com \
    --to=lfy@google.com \
    --cc=acourbot@chromium.org \
    --cc=alexlau@chromium.org \
    --cc=daniel@ffwll.ch \
    --cc=dgreid@chromium.org \
    --cc=dmitry.morozov@opensynergy.com \
    --cc=geoff@hostfission.com \
    --cc=gurchetansingh@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=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.