All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: Tomasz Figa <tfiga@chromium.org>
Cc: "Zach Reizner" <zachr@chromium.org>,
	"David Airlie" <airlied@linux.ie>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	virtualization@lists.linux-foundation.org,
	"Keiichi Watanabe" <keiichiw@chromium.org>,
	stevensd@chromium.org, "Daniel Vetter" <daniel@ffwll.ch>,
	"Stéphane Marchesin" <marcheu@chromium.org>,
	"Pawel Osciak" <posciak@chromium.org>
Subject: Re: [RFC PATCH] drm/virtio: Export resource handles via DMA-buf API
Date: Fri, 13 Sep 2019 10:07:07 +0200	[thread overview]
Message-ID: <20190913080707.unhyoezesvfhx5np__33667.4016945594$1568362040$gmane$org@sirius.home.kraxel.org> (raw)
In-Reply-To: <CAAFQd5AFXfu7ysFCi1XQS61DK8nbSk5-=UHkvpYWDtFae5YQ6Q@mail.gmail.com>

  Hi,

> > > To seamlessly enable buffer sharing with drivers using such frameworks,
> > > make the virtio-gpu driver expose the resource handle as the DMA address
> > > of the buffer returned from the DMA-buf mapping operation.  Arguably, the
> > > resource handle is a kind of DMA address already, as it is the buffer
> > > identifier that the device needs to access the backing memory, which is
> > > exactly the same role a DMA address provides for native devices.
> 
> First of all, thanks for taking a look at this.
> 
> > No.  A scatter list has guest dma addresses, period.  Stuffing something
> > else into a scatterlist is asking for trouble, things will go seriously
> > wrong when someone tries to use such a fake scatterlist as real scatterlist.
> 
> What is a "guest dma address"? The definition of a DMA address in the
> Linux DMA API is an address internal to the DMA master address space.
> For virtio, the resource handle namespace may be such an address
> space.

No.  DMA master address space in virtual machines is pretty much the
same it is on physical machines.  So, on x86 without iommu, identical
to (guest) physical address space.  You can't re-define it like that.

> However, we could as well introduce a separate DMA address
> space if resource handles are not the right way to refer to the memory
> from other virtio devices.

s/other virtio devices/other devices/

dma-bufs are for buffer sharing between devices, not limited to virtio.
You can't re-define that in some virtio-specific way.

> > Also note that "the DMA address of the buffer" is bonkers in virtio-gpu
> > context.  virtio-gpu resources are not required to be physically
> > contigous in memory, so typically you actually need a scatter list to
> > describe them.
> 
> There is no such requirement even on a bare metal system, see any
> system that has an IOMMU, which is typical on ARM/ARM64. The DMA
> address space must be contiguous only from the DMA master point of
> view.

Yes, the iommu (if present) could remap your scatterlist that way.  You
can't depend on that though.

What is the plan here?  Host-side buffer sharing I guess?  So you are
looking for some way to pass buffer handles from the guest to the host,
even in case those buffers are not created by your driver but imported
from somewhere else?

cheers,
  Gerd

  reply	other threads:[~2019-09-13  8:07 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-12  9:41 [RFC PATCH] drm/virtio: Export resource handles via DMA-buf API Tomasz Figa
2019-09-12 12:38 ` Gerd Hoffmann
2019-09-12 12:38 ` Gerd Hoffmann
2019-09-12 14:04   ` Tomasz Figa
2019-09-13  8:07     ` Gerd Hoffmann [this message]
2019-09-13  8:07     ` Gerd Hoffmann
2019-09-13  8:31       ` Tomasz Figa
2019-09-13 11:05         ` Gerd Hoffmann
2019-09-13 11:05         ` Gerd Hoffmann
2019-09-19 11:41           ` Keiichi Watanabe
2019-09-17 13:23 ` Daniel Vetter
2019-09-17 13:23 ` Daniel Vetter
2019-10-05  5:41   ` Tomasz Figa
2019-10-05  5:41     ` Tomasz Figa
2019-10-08 10:03     ` Daniel Vetter
2019-10-08 10:03     ` Daniel Vetter
2019-10-08 10:49       ` Tomasz Figa
2019-10-08 15:04         ` Daniel Vetter
2019-10-16  3:19           ` Tomasz Figa
2019-10-16  6:12             ` Gerd Hoffmann
2019-10-16  6:12             ` Gerd Hoffmann
2019-10-16  6:12               ` Gerd Hoffmann
2019-10-16  8:27               ` Tomasz Figa
2019-10-16  9:18             ` Daniel Vetter
2019-10-16  9:18             ` Daniel Vetter
2019-10-16 10:31               ` Tomasz Figa
2019-10-08 15:04         ` Daniel Vetter

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='20190913080707.unhyoezesvfhx5np__33667.4016945594$1568362040$gmane$org@sirius.home.kraxel.org' \
    --to=kraxel@redhat.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=keiichiw@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcheu@chromium.org \
    --cc=posciak@chromium.org \
    --cc=stevensd@chromium.org \
    --cc=tfiga@chromium.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=zachr@chromium.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.